@veltdev/sdk-staging 5.0.2-beta.78 → 5.0.2-beta.79
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/package.json +1 -1
- package/velt.js +2 -2
package/velt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var SNIPPYLY_VERSION = '5.0.2-beta.
|
|
1
|
+
var SNIPPYLY_VERSION = '5.0.2-beta.79';
|
|
2
2
|
Promise.allSettled||(Promise.allSettled=function(t){return Promise.all(t.map(function(r){return Promise.resolve(r).then(function(e){return{status:"fulfilled",value:e}}).catch(function(e){return{status:"rejected",reason:e}})}))});
|
|
3
3
|
|
|
4
4
|
var TAe=Object.create;var n9=Object.defineProperty,DAe=Object.defineProperties,OAe=Object.getOwnPropertyDescriptor,AAe=Object.getOwnPropertyDescriptors,MAe=Object.getOwnPropertyNames,t9=Object.getOwnPropertySymbols,$ne=Object.getPrototypeOf,sj=Object.prototype.hasOwnProperty,Gne=Object.prototype.propertyIsEnumerable,PAe=Reflect.get;var jne=(n,o,r)=>o in n?n9(n,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[o]=r,h=(n,o)=>{for(var r in o||={})sj.call(o,r)&&jne(n,r,o[r]);if(t9)for(var r of t9(o))Gne.call(o,r)&&jne(n,r,o[r]);return n},y=(n,o)=>DAe(n,AAe(o));var zh=(n,o)=>{var r={};for(var e in n)sj.call(n,e)&&o.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&t9)for(var e of t9(n))o.indexOf(e)<0&&Gne.call(n,e)&&(r[e]=n[e]);return r};var RAe=(n,o)=>()=>(o||n((o={exports:{}}).exports,o),o.exports),r9=(n,o)=>{for(var r in o)n9(n,r,{get:o[r],enumerable:!0})},NAe=(n,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of MAe(o))!sj.call(n,t)&&t!==r&&n9(n,t,{get:()=>o[t],enumerable:!(e=OAe(o,t))||e.enumerable});return n};var Hne=(n,o,r)=>(r=n!=null?TAe($ne(n)):{},NAe(o||!n||!n.__esModule?n9(r,"default",{value:n,enumerable:!0}):r,n));var Wh=(n,o,r)=>PAe($ne(n),r,o);var X=(n,o,r)=>new Promise((e,t)=>{var i=c=>{try{l(r.next(c))}catch(d){t(d)}},a=c=>{try{l(r.throw(c))}catch(d){t(d)}},l=c=>c.done?e(c.value):Promise.resolve(c.value).then(i,a);l((r=r.apply(n,o)).next())});var vne=RAe((e4i,dne)=>{"use strict";var Ft={};Ft.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};Ft.localCName=Ft.generateIdentifier();Ft.splitLines=function(n){return n.trim().split(`
|
|
@@ -498,7 +498,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
498
498
|
<path d="M6 4.66685V15.3335C5.99997 15.4521 6.03158 15.5686 6.09159 15.6709C6.15159 15.7733 6.23781 15.8577 6.34135 15.9156C6.44489 15.9735 6.562 16.0027 6.68059 16.0002C6.79918 15.9978 6.91497 15.9637 7.016 15.9015L15.6827 10.5682C15.7797 10.5085 15.8599 10.425 15.9155 10.3256C15.9711 10.2261 16.0003 10.1141 16.0003 10.0002C16.0003 9.88626 15.9711 9.77423 15.9155 9.6748C15.8599 9.57536 15.7797 9.49183 15.6827 9.43219L7.016 4.09885C6.91497 4.0367 6.79918 4.00262 6.68059 4.00015C6.562 3.99767 6.44489 4.02688 6.34135 4.08476C6.23781 4.14265 6.15159 4.22711 6.09159 4.32943C6.03158 4.43175 5.99997 4.54823 6 4.66685Z" fill="currentColor"/>
|
|
499
499
|
</svg>
|
|
500
500
|
`;break}l.innerHTML=c.trim();let d=l.firstElementChild;return d&&a.appendChild(d),a.addEventListener("click",i),a.__cleanup=()=>{a.removeEventListener("click",i)},a}exitPictureInPicture(){return X(this,null,function*(){try{if("documentPictureInPicture"in window&&(window.documentPictureInPicture.window||this.pipWindow)){this.pipWindow&&!this.pipWindow.closed&&this.pipWindow.close(),this.pipWindow=void 0,this.isPipActive$.next(!1);return}if(document.pictureInPictureElement){yield document.exitPictureInPicture(),this.isPipActive$.next(!1);return}this.isPipActive$.next(!1),this.pipWindow=void 0}catch(e){this.loggingService.catch("Error in PipService exitPictureInPicture:",e),this.isPipActive$.next(!1),this.pipWindow=void 0}})}togglePictureInPicture(e,t){return X(this,null,function*(){try{this.isPipActive$.value||this.pipWindow||document.pictureInPictureElement?yield this.exitPictureInPicture():yield this.openPictureInPicture(e,t)}catch(i){this.loggingService.catch("Error in PipService togglePictureInPicture:",i),this.isPipActive$.next(!1),this.pipWindow=void 0}})}findVideoElement(){return X(this,null,function*(){try{let e=['[data-testid*="velt-recorder-control-panel-video-video"]','[data-testid*="velt-recorder-control-panel-screen-screen"]','video[data-testid*="recorder"]'];for(let i of e){let a=document.querySelector(i);if(a&&a.srcObject)return a}let t=Array.from(document.querySelectorAll("video"));for(let i of t)if(i.srcObject)return i;return null}catch(e){return this.loggingService.catch("Error in PipService findVideoElement:",e),null}})}getIsPipActive$(){return this.isPipActive$.asObservable()}getIsPipActive(){return this.isPipActive$.value}getPipStopRecordingTriggered$(){return this.pipStopRecordingTriggered$.asObservable()}resetPipStopRecordingTriggered(){this.pipStopRecordingTriggered$.next(!1)}getPipPauseRecordingTriggered$(){return this.pipPauseRecordingTriggered$.asObservable()}resetPipPauseRecordingTriggered(){this.pipPauseRecordingTriggered$.next(!1)}enablePictureInPicture(){try{if(this.pictureInPicture$.value===!0)return;this.pictureInPicture$.next(!0),this.messageListener||(this.messageListener=e=>{try{if(e.origin!==window.location.origin){this.loggingService.warn("Received message from untrusted origin:",e.origin);return}if(e.source!==this.pipWindow&&e.source!==window.parent){this.loggingService.warn("Received message from untrusted source window");return}e.data?.type==="pip-stop-recording"?this.pipStopRecordingTriggered$.next(!0):e.data?.type==="pip-pause-recording"||e.data?.type==="pip-resume-recording"?this.pipPauseRecordingTriggered$.next(!0):e.data?.type==="pip-clear-recording"&&this.pipClearRecordingTriggered$.next(!0)}catch(t){this.loggingService.catch("Error in PipService enablePictureInPicture message listener:",t)}},window.addEventListener("message",this.messageListener))}catch(e){this.loggingService.catch("Error in PipService enablePictureInPicture: ",e)}}disablePictureInPicture(){try{if(this.pictureInPicture$.value===!1)return;this.pictureInPicture$.next(!1),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=void 0),this.pipStopRecordingTriggered$.next(!1),this.pipPauseRecordingTriggered$.next(!1),this.pipClearRecordingTriggered$.next(!1),this.isPipActive$.next(!1),this.pipWindow&&!this.pipWindow.closed&&this.pipWindow.close(),this.pipWindow=void 0}catch(e){this.loggingService.catch("Error in PipService disablePictureInPicture: ",e)}}getPictureInPicture$(){return this.pictureInPicture$.asObservable()}isPictureInPictureEnabled(){try{let e=new pr;return this.pictureInPicture$.value&&e.getBrowserName()==="Chrome"}catch(e){return this.loggingService.catch("Error in PipService isPictureInPictureEnabled: ",e),!1}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Un=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_){this.analyticsService=e,this.loggingService=t,this.matDialog=i,this.storageService=a,this.docService=l,this.databaseService=c,this.domService=d,this.attachmentResolverService=g,this.pipService=u,this.recorderAnnotationsResolverService=_,this.recorderStatusSubject$=new Se(null),this.recorderDurationSubject$=new Se(null),this.darkMode$=new Se(null),this.shadowDom$=new Se(null),this.recordingDurations=[],this.chunks=[],this.recordingCountdownEnabled$=new Se(!0),this.recorderInitData$=new it,this.recordedRawData$=new it,this.recordedData$=new it,this.onInitRecording$=new Se(null),this.onRecordingAttributeRemovedFromBodySubject$=new it,this.videoEditor$=new Se(!1),this.videoEditorTimelinePreview$=new Se(!1),this.settingsEmbedded$=new Se(!1),this.autoOpenVideoEditor$=new Se(!1),this.playVideoInFullScreen$=new Se(void 0),this.recordedDataStream=[],this.documentPaths=null,this.uploadPromises=[],this.chunkUrls$=new Se({}),this.recordingQualityConstraints=new Se({safari:{audio:{sampleRate:48e3,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:{width:{min:640,ideal:1280,max:1280},height:{min:360,ideal:720,max:720},frameRate:{min:15,ideal:20,max:30},aspectRatio:{ideal:1.777777778}}},other:{audio:{sampleRate:48e3,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:{width:{min:640,ideal:1280,max:1280},height:{min:360,ideal:720,max:720},frameRate:{min:15,ideal:20,max:30},aspectRatio:{ideal:1.777777778}}}}),this.recordingEncodingOptions=new Se({safari:{videoBitsPerSecond:25e5,audioBitsPerSecond:128e3},other:{videoBitsPerSecond:1e6,audioBitsPerSecond:128e3}}),this.recordingMicEnabled$=new Se(null),this.onboardingTooltip$=new Se(!1),this.audioContext=null,this.audioDestination=null,this.activeInputTracks=new Set,this.retakeOnVideoEditor$=new Se(!1),this.maxRecordingLength=null,this.screenStreamSubject$=new Se(null),this.playbackOnPreviewClick$=new Se(!0),this.onInitRecording$.subscribe(w=>{w?this.setRecordingAttributeAtBody():this.removeRecordingAttributeFromBody()}),this.pipService.getPipPauseRecordingTriggered$().subscribe(w=>{w&&(this.recorderStatusSubject$.value==="started"||this.recorderStatusSubject$.value==="resumed"?this.pauseRecording():this.recorderStatusSubject$.value==="paused"&&this.resumeRecording(),this.pipService.resetPipPauseRecordingTriggered())}),this.databaseService.getDb().pipe($e(w=>!!w),ut(1)).subscribe(w=>{w&&this.getDocumentPaths()},w=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",w)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getDocumentPaths: ",e)}}setRecordedDataStream(e){this.recordedDataStream=e}getRecordedDataStream(){return this.recordedDataStream}setRecordingAttributeAtBody(){try{let e=this.onInitRecording$.getValue();e&&(document.body.setAttribute(F.ATTRIBUTES.VELT_ONGOING_RECORDING,e.type),e?.isCommentRecording&&document.body.setAttribute(F.ATTRIBUTES.VELT_COMMENT_RECORDING,"true"))}catch(e){this.loggingService.catch("Error in RecorderService setRecordingAttributeAtBody: ",e)}}removeRecordingAttributeFromBody(){try{document.body.removeAttribute(F.ATTRIBUTES.VELT_ONGOING_RECORDING),document.body.removeAttribute(F.ATTRIBUTES.VELT_COMMENT_RECORDING),this.onRecordingAttributeRemovedFromBodySubject$.next()}catch(e){this.loggingService.catch("Error in RecorderService removeRecordingAttributeFromBody: ",e)}}onRecordingAttributeRemovedFromBody$(){return this.onRecordingAttributeRemovedFromBodySubject$.asObservable()}getRecorderInitData(){return this.recorderInitData$.asObservable()}onInitRecording(){return this.onInitRecording$.asObservable()}onRecordedData(){return this.recordedData$.asObservable()}setRecordedData(e){this.recordedData$.next(e)}initRecording(e,t,i,a,l,c,d,g,u,_){return X(this,null,function*(){try{let w={};switch(e){case"audio":w.audio={enabled:!0};break;case"video":w.video={enabled:!0},w.audio={enabled:!0};break;case"screen":w.screen={enabled:!0,stream:u},w.video={enabled:!1},w.audio={enabled:!1};break;default:break}u&&e==="screen"&&(w.screen={enabled:!0,stream:u}),this.matDialog.open($U,{panelClass:"velt-mat-dialog-container",data:{type:e,mediaConfig:w,darkMode:[!0,!1].includes(a)?a:this.darkMode$.value,shadowDom:l,isExplicitShadowDom:_,recordingCountdown:g}}).afterClosed().subscribe(A=>{if(A){let M={};switch(e){case"audio":M.audio={enabled:!0,deviceId:A.audio?.deviceId},M.audio=A.audio;break;case"video":M.video={enabled:!0,deviceId:A.video?.deviceId},M.audio={enabled:!0,deviceId:A.audio?.deviceId},M.video=A.video,M.audio=A.audio;break;case"screen":M.screen={enabled:!0},M.audio=A.audio,M.video=A.video,M.screen=A.screen;break;default:break}this.onInitRecording$.next({type:e,panelId:t,mediaConfig:M,isCommentRecording:i,darkMode:[!0,!1].includes(a)?a:!!this.darkMode$.value,shadowDom:l,isExplicitShadowDom:_,commentAnnotationId:c,clientDocumentId:d})}},A=>{this.loggingService.catch("Error in RecorderService initRecording afterClosed: ",A)})}catch(w){this.loggingService.catch("Error in RecorderService initRecording: ",w)}})}startRecording(e,t){return X(this,null,function*(){try{this.loggingService.log("[startRecording] Starting with config:",e,"mediaConfig:",t);let i=new MediaStream,a=yield this.getBrowserSpecificOptions();return yield this.collectMediaTracks(i,e,t),yield this.initializeMediaRecorder(i,a,e),this.setupRecorderData(e,i),i}catch(i){return this.loggingService.catch("Error in RecorderService startRecording: ",i),Promise.reject(i)}})}getBrowserSpecificOptions(){return X(this,null,function*(){try{let e={videoBitsPerSecond:this.recordingEncodingOptions.value[this.isSafari()?"safari":"other"]?.videoBitsPerSecond,audioBitsPerSecond:this.recordingEncodingOptions.value[this.isSafari()?"safari":"other"]?.audioBitsPerSecond},t=this.getSupportedMimeTypes();if(t.length>0){let a=t.find(l=>l.includes("mp4")&&l.includes("h264"))||t.find(l=>l.includes("mp4"))||t[0];e.mimeType=a}return new pr().getBrowserName()==="Firefox"&&(t.includes("video/webm")&&(e.mimeType="video/webm"),e.videoBitsPerSecond=Math.min(e.videoBitsPerSecond||1e6,2e6),e.audioBitsPerSecond=Math.min(e.audioBitsPerSecond||128e3,256e3)),e}catch(e){return this.loggingService.catch("Error in RecorderService getBrowserSpecificOptions: ",e),{}}})}collectMediaTracks(e,t,i){return X(this,null,function*(){try{let a=[],l=[];if(t.type.screen&&i?.screen?.stream){let c=this.getCommonVideoQualityConstraints(!0);i.screen.stream.getTracks().forEach(d=>{d.onended=()=>this.stopRecording(),d.kind==="video"?(d.applyConstraints(h({},c)),l.push(d),this.loggingService.log("[collectMediaTracks] Added screen video track"),this.registerActiveTrack(d)):d.kind==="audio"&&(a.push(d),this.loggingService.log("[collectMediaTracks] Collected tab audio track for mixing"),this.registerActiveTrack(d))})}if(t?.type.audio||t?.type.video)if(this.isFirefox()&&t.type.screen&&(i?.audio?.stream||i?.video?.stream))t.type.audio&&i?.audio?.stream&&i.audio.stream.getAudioTracks().forEach(g=>{a.push(g),this.loggingService.log("[collectMediaTracks] Collected mic audio track for mixing (Firefox)"),this.registerActiveTrack(g)}),t.type.video&&i?.video?.stream&&i.video.stream.getVideoTracks().forEach(g=>{l.push(g),this.loggingService.log("[collectMediaTracks] Added user video track (Firefox)"),this.registerActiveTrack(g)});else{let d=this.buildMediaConstraints(t,i),g=yield navigator.mediaDevices.getUserMedia(d);if(g){if(t?.type.audio){let u=g.getAudioTracks();if(u.length>0)if(this.isSafari()){let _=u[0];if(_.getSettings().sampleRate!==48e3){this.loggingService.log("[collectMediaTracks] Adjusting audio sample rate for Safari");let M=(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:48e3}})).getAudioTracks()[0];a.push(M),this.registerActiveTrack(M),_.stop()}else a.push(_),this.registerActiveTrack(_)}else u.forEach(_=>{a.push(_),this.loggingService.log("[collectMediaTracks] Collected mic audio track for mixing"),this.registerActiveTrack(_)})}if(t?.type.video){let u=g.getVideoTracks();if(u.length>0)if(this.isSafari()){let _=u[0];_.enabled=!0;let w=_.clone();l.push(w),this.loggingService.log("[collectMediaTracks] Added user video track (Safari, cloned)"),i&&i.video&&(i.video.track=_),this.registerActiveTrack(_)}else u.forEach(_=>{l.push(_),this.loggingService.log("[collectMediaTracks] Added user video track"),this.registerActiveTrack(_)})}}}if(a.length>0)if(this.loggingService.log(`[collectMediaTracks] Processing ${a.length} audio track(s)`),a.length===1)e.addTrack(a[0]),this.loggingService.log("[collectMediaTracks] Added single audio track (no mixing needed)");else{this.loggingService.log("[collectMediaTracks] Mixing multiple audio tracks...");let c=yield this.mixAudioTracks(a);c?(e.addTrack(c),this.loggingService.log("[collectMediaTracks] Added mixed audio track to stream")):(this.loggingService.warn("[collectMediaTracks] Failed to mix audio tracks, adding first track only"),e.addTrack(a[0]))}l.forEach(c=>{e.addTrack(c)}),this.loggingService.log(`[collectMediaTracks] Added ${l.length} video track(s) to stream`),this.loggingService.log(`[collectMediaTracks] Final stream: ${e.getAudioTracks().length} audio track(s), ${e.getVideoTracks().length} video track(s)`)}catch(a){this.loggingService.catch("Error in RecorderService collectMediaTracks: ",a);return}})}buildMediaConstraints(e,t){try{let i=this.getCommonVideoQualityConstraints(!!e.type.video),a=this.getCommonAudioConstraints(!!e.type.audio,t);return kYe(!!e.type.video,a,i,t)}catch(i){return this.loggingService.catch("Error in RecorderService buildMediaConstraints: ",i),{}}}getCommonAudioConstraints(e,t){try{if(!e)return!1;let i=this.recordingQualityConstraints.value[this.isSafari()?"safari":"other"]?.audio||{};return xYe(t,i)}catch(i){return this.loggingService.catch("Error in RecorderService getCommonAudioConstraints: ",i),{}}}getCommonVideoQualityConstraints(e){try{return e?this.recordingQualityConstraints.value[this.isSafari()?"safari":"other"]?.video||{}:{}}catch(t){return this.loggingService.catch("Error in RecorderService getCommonVideoQualityConstraints: ",t),{}}}adjustSafariAudioTrack(e,t){return X(this,null,function*(){try{let i=t.getAudioTracks()[0];if(i.getSettings().sampleRate!==48e3){this.loggingService.log("[startRecording] Adjusting audio sample rate for Safari");let l=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:48e3}});e.addTrack(l.getAudioTracks()[0])}else e.addTrack(i)}catch(i){this.loggingService.catch("Error in RecorderService adjustSafariAudioTrack: ",i);return}})}registerActiveTrack(e){try{e&&this.activeInputTracks.add(e)}catch(t){this.loggingService.catch("Error in RecorderService registerActiveTrack:",t)}}stopAllActiveInputTracks(){try{this.activeInputTracks.forEach(e=>{try{e?.readyState!=="ended"&&e.stop()}catch{}}),this.activeInputTracks.clear()}catch(e){this.loggingService.catch("Error in RecorderService stopAllActiveInputTracks:",e)}}mixAudioTracks(e){return X(this,null,function*(){try{if(e.length===0)return this.loggingService.warn("[mixAudioTracks] No audio tracks provided"),null;if(e.length===1)return this.loggingService.log("[mixAudioTracks] Only one audio track, no mixing needed"),e[0];this.loggingService.log(`[mixAudioTracks] Mixing ${e.length} audio tracks`),this.cleanupAudioMixing(),this.audioContext=new AudioContext,this.audioDestination=this.audioContext.createMediaStreamDestination();let t=this.audioContext.createGain();t.gain.value=1,t.connect(this.audioDestination);for(let a of e)try{let l=new MediaStream([a]),c=this.audioContext.createMediaStreamSource(l),d=this.audioContext.createGain();d.gain.value=1,c.connect(d),d.connect(t),this.loggingService.log(`[mixAudioTracks] Connected audio track: ${a.label||"unlabeled"}`)}catch(l){this.loggingService.catch(`[mixAudioTracks] Error connecting track ${a.label}:`,l)}let i=this.audioDestination.stream.getAudioTracks();return i.length>0?(this.loggingService.log("[mixAudioTracks] Successfully created mixed audio track"),i[0]):(this.loggingService.warn("[mixAudioTracks] No mixed track created"),null)}catch(t){return this.loggingService.catch("Error in RecorderService mixAudioTracks:",t),this.cleanupAudioMixing(),null}})}cleanupAudioMixing(){try{this.audioDestination&&(this.audioDestination.stream.getTracks().forEach(e=>{e.stop()}),this.audioDestination=null),this.audioContext&&(this.audioContext.state!=="closed"&&this.audioContext.close().catch(e=>{this.loggingService.catch("Error closing audio context:",e)}),this.audioContext=null)}catch(e){this.loggingService.catch("Error in RecorderService cleanupAudioMixing:",e)}}initializeMediaRecorder(e,t,i){return X(this,null,function*(){try{if(this.mediaRecorder)try{this.mediaRecorder.state!=="inactive"&&this.mediaRecorder.stop(),this.mediaRecorder=null}catch(g){this.loggingService.catch("Error cleaning up old mediaRecorder:",g)}if(e.getTracks().length===0)throw new Error("MediaStream has no tracks");this.mediaRecorder=new MediaRecorder(e,t),this.chunks=[],this.chunkUrls$.next({}),this.uploadPromises=[];let a=0;if(this.isSafari()){let g=e.getVideoTracks();g.length>0&&g.forEach(u=>{u.contentHint="detail",u.enabled=!0})}let c=new pr().getBrowserName()==="Firefox";c&&e.getTracks().forEach(g=>{g.enabled=!0}),this.mediaRecorder.addEventListener("dataavailable",g=>{if(g.data?.size>0){let u=a++;if(this.chunks.push(g.data),this.recorderAnnotationsResolverService.shouldUploadFullRecording())return;let _=`recording_${new Date().getTime()}_${Math.random().toString(36).substring(2,9)}`,w=g.data,A=this.uploadChunk(w,_,u);this.uploadPromises||(this.uploadPromises=[]),this.uploadPromises.push({promise:A,index:u}),A.then(M=>{this.chunkUrls$.next(y(h({},this.chunkUrls$.value),{[u]:M}))}).catch(M=>{})}}),this.mediaRecorder.addEventListener("stop",()=>{c&&this.chunks.length===0&&this.attemptFirefoxCanvasRecording(e),this.onStopRecording()}),this.mediaRecorder.addEventListener("error",g=>{this.loggingService.catch("MediaRecorder error event:",g)});let d=4e3;c&&i.type.screen&&(d=void 0),d?this.mediaRecorder.start(d):this.mediaRecorder.start(),c&&setTimeout(()=>{if(this.chunks.length===0&&this.mediaRecorder.state==="recording")try{this.mediaRecorder.requestData&&this.mediaRecorder.requestData()}catch{}},2e3)}catch(a){throw this.loggingService.catch("Error in RecorderService initializeMediaRecorder: ",a),a}})}uploadChunk(e,t,i){return X(this,null,function*(){try{let l=this.mediaRecorder.mimeType||"video/mp4",c=l.includes("webm")?"webm":"mp4",d=`chunk_${i}_${new Date().getTime()}.${c}`,g=new File([e],d,{type:l});return yield this.uploadChunkToStorage(g,t,i)}catch(a){throw a}})}uploadChunkToStorage(e,t,i){try{if(!this.documentPaths?.documentId)throw new Error("Document ID is required for chunk upload");let a=this.documentPaths?.organizationId,l=this.documentPaths?.documentId,c=`${F.FIREBASE_PARTIAL_PATH_DOCS}/${l}/${F.FIREBASE_PARTIAL_PATH_RECORDER}/${t}`;if(a&&(c=`${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${a}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${l}/${F.FIREBASE_PARTIAL_PATH_RECORDER}/${t}`),this.attachmentResolverService.attachmentDataProviderAvailable("recorder")){let d=this.docService.getBaseMetadata("recorder");return this.storageService.uploadChunk(c,e,i,{useAttachmentResolver:!0,metadata:d,attachmentScope:"recorder"})}return this.storageService.uploadChunk(c,e,i)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunkToStorage: ",a),a}}setupRecorderData(e,t){try{return this.recorderInitData=new RF,this.recorderStatusSubject$.next("started"),this.isSafari()&&e.type.video&&t.getVideoTracks().forEach(i=>{i.enabled=!0}),this.recorderInitData.stream=t,this.recorderInitData.status=this.recorderStatusSubject$.asObservable(),this.recorderInitData.type=this.determineRecorderType(e),this.recorderInitData.recordedTime=this.recorderDurationSubject$.asObservable(),this.recorderInitData.recordedRawData$=this.recordedRawData$.asObservable(),this.recordingDurations=[{start:new Date().getTime()}],this.startTimer(),this.recorderInitData$.next(this.recorderInitData),this.recorderActionsService?.onRecordingStarted(this.getRecorderDataFromInitData()),this.pipService.getIsPipActive()&&window.postMessage({type:"recording-status-update",status:"started"},"*"),this.recorderInitData}catch(i){return this.loggingService.catch("Error in RecorderService setupRecorderData: ",i),null}}determineRecorderType(e){try{return e.type.video?"video":e.type.screen?"screen":(e.type.audio,"audio")}catch(t){return this.loggingService.catch("Error in RecorderService determineRecorderType: ",t),"audio"}}timeout(e){return new Promise(t=>setTimeout(t,e))}pauseRecording(){try{if(this.recorderStatusSubject$.next("paused"),this.mediaRecorder.pause(),this.firefoxFallbackRecorder?.state==="recording")try{this.firefoxFallbackRecorder.pause()}catch(e){this.loggingService.catch("Error pausing Firefox fallback recorder: ",e)}this.recordingDurations?.length&&(this.recordingDurations[this.recordingDurations.length-1].end=new Date().getTime()),this.stopTimer(),this.recorderActionsService?.onRecordingPaused(this.getRecorderDataFromInitData()),this.pipService.getIsPipActive()&&window.postMessage({type:"recording-status-update",status:"paused",recordingType:this.recorderInitData?.type||"video"},window.location.origin)}catch(e){this.loggingService.catch("Error in RecorderService pauseRecording: ",e)}}resumeRecording(){try{if(this.recorderStatusSubject$.next("resumed"),this.mediaRecorder.resume(),this.firefoxFallbackRecorder?.state==="paused")try{this.firefoxFallbackRecorder.resume()}catch(e){this.loggingService.catch("Error resuming Firefox fallback recorder: ",e)}this.recordingDurations.push({start:new Date().getTime()}),this.startTimer(),this.recorderActionsService?.onRecordingResumed(this.getRecorderDataFromInitData()),this.pipService.getIsPipActive()&&window.postMessage({type:"recording-status-update",status:"started",recordingType:this.recorderInitData?.type||"video"},"*")}catch(e){this.loggingService.catch("Error in RecorderService resumeRecording: ",e)}}stopRecording(){try{if(this.mediaRecorder?.state!=="inactive"?(this.mediaRecorder.stop(),this.removeRecordingAttributeFromBody(),this.stopAllActiveInputTracks(),this.cleanupAudioMixing()):this.clearRecording(),this.firefoxFallbackRecorder?.state==="recording")try{this.firefoxFallbackRecorder.stop()}catch(e){this.loggingService.catch("Error stopping Firefox fallback recorder: ",e)}this.recorderActionsService?.onRecordingStopped(this.getRecorderDataFromInitData())}catch(e){this.loggingService.catch("Error in RecorderService stopRecording: ",e)}}onStopRecording(){return X(this,null,function*(){try{this.loggingService.log("[onStopRecording] Starting, current chunks:",this.chunks.length),this.recordingDurations?.length&&(this.recordingDurations[this.recordingDurations?.length-1].end=new Date().getTime()),this.stopTimer(),this.recorderStatusSubject$.next("stopped"),(this.recorderInitData?.stream?.getTracks()||[]).forEach(i=>{i.stop()}),this.stopAllActiveInputTracks(),this.cleanupAudioMixing(),yield this.timeout(100);let t=new pO;if(this.chunks.length>0){let i=this.recorderInitData?.type==="audio"?"audio/mp4":"video/mp4";this.loggingService.log("[onStopRecording] Creating blob with type:",i),t.blob=new Blob(this.chunks,{type:i}),this.loggingService.log("[onStopRecording] Blob created, size:",t.blob.size);try{let a=yield this.getVideoDuration(t.blob);if(a&&isFinite(a)&&a>0){let l={};l.duration=a*1e3,l.display=this.convertMillisecondsToTime(a*1e3),this.recorderDurationSubject$.next(l),t.recordedTime=l}else{let l=this.recorderDurationSubject$.value;t.recordedTime=l}}catch(a){let l=this.recorderDurationSubject$.value;t.recordedTime=l,this.recorderInitData&&this.loggingService.catch("Error in RecorderService onStopRecording getVideoDuration: ",a)}if(t.blob.size===0)throw new Error("Recorded blob has zero size");if(t.url=URL.createObjectURL(t.blob),t.type=this.recorderInitData?.type,t.recordedTime=this.recorderDurationSubject$.value,t?.type!=="audio")try{yield this.timeout(200);let a=yield Whe(t.blob,3);a&&(t.thumbnail=yield qhe(a))}catch(a){this.recorderInitData&&this.loggingService.catch("Error in RecorderService onStopRecording getVideoCover: ",a)}}this.recordedRawData$.next(t)}catch(e){this.loggingService.catch("Error in RecorderService onStopRecording: ",e),this.recordedRawData$.error(e)}})}clearRecording(e){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling RecorderService FUNCTION: clearRecording","color: green;"),this.mediaRecorder)try{this.mediaRecorder.state!=="inactive"&&this.mediaRecorder.stop(),this.mediaRecorder=null}catch(t){this.loggingService.catch("Error cleaning up mediaRecorder:",t)}if(this.recorderStatusSubject$.next(null),this.recorderDurationSubject$.next(null),this.onInitRecording$.next(null),this.recordingDurations=[],this.domService.resetRecordingInProgress(),this.firefoxFallbackRecorder){try{this.firefoxFallbackRecorder.state==="recording"&&this.firefoxFallbackRecorder.stop()}catch(t){this.loggingService.catch("Error stopping Firefox fallback recorder during cleanup: ",t)}this.firefoxFallbackRecorder=void 0}this.cleanupAudioMixing(),this.stopAllActiveInputTracks();try{this.screenStreamSubject$?.value?.getTracks()?.forEach(i=>{i?.readyState!=="ended"&&i.stop()}),this.screenStreamSubject$?.next(null)}catch{}this.recorderInitData?.stream?.getTracks()?.forEach(t=>{t.stop()}),e?.triggerEvent==="cancelled"&&this.recorderActionsService?.onRecordingCancelled(this.getRecorderDataFromInitData()),this.recorderInitData=null,this.recorderInitData$.next(null),this.chunks=[],this.chunkUrls$.next({}),this.stopTimer()}catch(t){this.loggingService.catch("Error in RecorderService clearRecording: ",t)}})}startTimer(){try{this.stopTimer(),this.durationInterval=setInterval(()=>{this.calculateRecordedTime()},1e3)}catch(e){this.loggingService.catch("Error in RecorderService startTimer: ",e)}}stopTimer(){try{this.durationInterval&&clearInterval(this.durationInterval)}catch(e){this.loggingService.catch("Error in RecorderService stopTimer: ",e)}}calculateRecordedTime(){try{if(this?.recordingDurations?.length){let e=0;this.recordingDurations.forEach(i=>{i.end?e+=i?.end-i.start:e+=new Date().getTime()-i.start});let t={};t.duration=e,t.display=this.convertMillisecondsToTime(e),this.recorderDurationSubject$.next(t),this.pipService.getIsPipActive()&&window.postMessage({type:"recording-timer-update",display:t.display},"*")}else this.recorderDurationSubject$.next(null)}catch(e){this.loggingService.catch("Error in RecorderService calculateRecordedTime: ",e)}}checkMaxLength(){try{if(!this.maxRecordingLength||!this.recordingDurations?.length)return!1;let e=0;this.recordingDurations.forEach(i=>{i.end?e+=i?.end-i.start:e+=new Date().getTime()-i.start});let t=e>=this.maxRecordingLength*1e3+500;return t&&this.loggingService.log("%c[WB] Max recording length reached. Duration: "+e+"ms, Target: "+this.maxRecordingLength+"s","color: orange;"),t}catch(e){return this.loggingService.catch("Error in RecorderService checkMaxLength: ",e),!1}}convertMillisecondsToTime(e){try{let t=Math.floor(e/1e3),i=Math.floor(t/60),a=Math.floor(i/60);return t=t%60,i=i%60,`${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`}catch(t){return this.loggingService.catch("Error in RecorderService convertMillisecondsToTime: ",t),""}}getRecorderStatus$(){return this.recorderDurationSubject$.asObservable()}enableRecordingCountdown(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;"),this.recordingCountdownEnabled$.value===!0)return;this.recordingCountdownEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableRecordingCountdown: ",e)}}disableRecordingCountdown(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;"),this.recordingCountdownEnabled$.value===!1)return;this.recordingCountdownEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableRecordingCountdown: ",e)}}getRecordingCountdownEnabled$(){return this.recordingCountdownEnabled$.asObservable()}enableDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;"),this.darkMode$.value===!0)return;this.darkMode$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableDarkMode: ",e)}}disableDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;"),this.darkMode$.value===!1)return;this.darkMode$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableDarkMode: ",e)}}getDarkMode(){return this.darkMode$.value}getDarkMode$(){return this.darkMode$.asObservable()}enableShadowDom(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableShadowDom","color: green;"),this.shadowDom$.value===!0)return;this.shadowDom$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableShadowDom: ",e)}}disableShadowDom(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableShadowDom","color: green;"),this.shadowDom$.value===!1)return;this.shadowDom$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableShadowDom: ",e)}}getShadowDom(){return this.shadowDom$.value}getShadowDom$(){return this.shadowDom$.asObservable()}isSafari(){try{this.loggingService.log("%c[WB] Calling FUNCTION: isSafari","color: green;");let e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("android")}catch(e){return this.loggingService.catch("Error in RecorderService isSafari: ",e),!1}}isFirefox(){try{return new pr().getBrowserName()==="Firefox"}catch(e){return this.loggingService.catch("Error in RecorderService isFirefox: ",e),!1}}getSupportedMimeTypes(){try{return["video/mp4;codecs=h264,aac","video/mp4","audio/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=h264,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","audio/webm;codecs=opus","audio/webm"].filter(i=>MediaRecorder.isTypeSupported(i))}catch(e){return this.loggingService.catch("Error in RecorderService getSupportedMimeTypes: ",e),[]}}enableVideoEditor(){try{if(this.videoEditor$.value===!0)return;this.videoEditor$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableVideoEditor: ",e)}}disableVideoEditor(){try{if(this.videoEditor$.value===!1)return;this.videoEditor$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableVideoEditor: ",e)}}getVideoEditor$(){return this.videoEditor$.asObservable()}getVideoEditor(){return this.videoEditor$.value}enableVideoEditorTimelinePreview(){try{if(this.videoEditorTimelinePreview$.value===!0)return;this.videoEditorTimelinePreview$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableVideoEditorTimelinePreview: ",e)}}disableVideoEditorTimelinePreview(){try{if(this.videoEditorTimelinePreview$.value===!1)return;this.videoEditorTimelinePreview$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableVideoEditorTimelinePreview: ",e)}}getVideoEditorTimelinePreview$(){return this.videoEditorTimelinePreview$.asObservable()}getVideoEditorTimelinePreview(){return this.videoEditorTimelinePreview$.value}waitForChunksUpload(){return X(this,null,function*(){try{if(this.uploadPromises.length===0)return{};let e=this.uploadPromises.map(t=>t.promise);return yield Promise.all(e),this.chunkUrls$.value}catch(e){return this.loggingService.catch("Error in RecorderService waitForChunksUpload: ",e),this.chunkUrls$.value}})}getChunkUrls$(){return this.chunkUrls$.asObservable()}getChunkUrls(){return this.chunkUrls$.value}shouldUploadFullRecording(){return this.recorderAnnotationsResolverService.shouldUploadFullRecording()}setRecorderActionsService(e){try{this.recorderActionsService=e}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",t)}}enableSettingsEmbedded(){try{if(this.settingsEmbedded$.value===!0)return;this.settingsEmbedded$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableSettingsEmbedded: ",e)}}disableSettingsEmbedded(){try{if(this.settingsEmbedded$.value===!1)return;this.settingsEmbedded$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableSettingsEmbedded: ",e)}}getSettingsEmbedded$(){return this.settingsEmbedded$.asObservable()}getSettingsEmbedded(){return this.settingsEmbedded$.value}enableAutoOpenVideoEditor(){try{if(this.autoOpenVideoEditor$.value===!0)return;this.autoOpenVideoEditor$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableAutoOpenVideoEditor: ",e)}}disableAutoOpenVideoEditor(){try{if(this.autoOpenVideoEditor$.value===!1)return;this.autoOpenVideoEditor$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableAutoOpenVideoEditor: ",e)}}getAutoOpenVideoEditor$(){return this.autoOpenVideoEditor$.asObservable()}getAutoOpenVideoEditor(){return this.autoOpenVideoEditor$.value}enablePlayVideoInFullScreen(){try{if(this.playVideoInFullScreen$.value===!0)return;this.playVideoInFullScreen$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enablePlayVideoInFullScreen: ",e)}}disablePlayVideoInFullScreen(){try{if(this.playVideoInFullScreen$.value===!1)return;this.playVideoInFullScreen$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disablePlayVideoInFullScreen: ",e)}}getPlayVideoInFullScreen$(){return this.playVideoInFullScreen$.asObservable()}getPlayVideoInFullScreen(){return this.playVideoInFullScreen$.value}setRecordingQualityConstraints(e){try{let t=this.recordingQualityConstraints.value;t={other:{audio:h(h({},t.other?.audio),e.other?.audio),video:h(h({},t.other?.video),e.other?.video)},safari:{audio:h(h({},t.safari?.audio),e.safari?.audio),video:h(h({},t.safari?.video),e.safari?.video)}},this.recordingQualityConstraints.next(t)}catch(t){this.loggingService.catch("Error in RecorderService setRecordingQualityConstraints: ",t)}}setRecordingEncodingOptions(e){try{let t=this.recordingEncodingOptions.value;t={other:h(h({},t.other),e.other),safari:h(h({},t.safari),e.safari)},this.recordingEncodingOptions.next(t)}catch(t){this.loggingService.catch("Error in RecorderService setRecordingEncodingOptions: ",t)}}getVideoDuration(e){return X(this,null,function*(){return new Promise((t,i)=>{try{let a=URL.createObjectURL(e),l=document.createElement("video"),c=navigator.userAgent.includes("Firefox");c&&(l.preload="auto"),l.onloadedmetadata=()=>{let d=l.duration;c&&d>0&&d<10&&e.size>1e6?setTimeout(()=>{let g=l.duration;URL.revokeObjectURL(a),t(g)},1e3):(URL.revokeObjectURL(a),t(d))},l.onerror=d=>{URL.revokeObjectURL(a),i(d)},l.src=a,l.load()}catch(a){this.loggingService.catch("Error in RecorderService getVideoDuration: ",a),i(a)}})})}enableRecordingMic(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingMic","color: green;"),this.recordingMicEnabled$.value===!0)return;this.recordingMicEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableRecordingMic: ",e)}}disableRecordingMic(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingMic","color: green;"),this.recordingMicEnabled$.value===!1)return;this.recordingMicEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableRecordingMic: ",e)}}getRecordingMicEnabled$(){return this.recordingMicEnabled$.asObservable()}getRecordingMicEnabled(){return this.recordingMicEnabled$.value}setOnboardingTooltip(e){try{if(this.onboardingTooltip$.value===e)return;this.onboardingTooltip$.next(e)}catch(t){this.loggingService.catch("Error in RecorderService setOnboardingTooltip: ",t)}}enableOnboardingTooltip(){try{if(this.onboardingTooltip$.value===!0)return;this.onboardingTooltip$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableOnboardingTooltip: ",e)}}disableOnboardingTooltip(){try{if(this.onboardingTooltip$.value===!1)return;this.onboardingTooltip$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableOnboardingTooltip: ",e)}}getOnboardingTooltip$(){return this.onboardingTooltip$.asObservable()}getOnboardingTooltip(){return this.onboardingTooltip$.value}enableRetakeOnVideoEditor(){try{if(this.retakeOnVideoEditor$.value===!0)return;this.retakeOnVideoEditor$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enableRetakeOnVideoEditor: ",e)}}disableRetakeOnVideoEditor(){try{if(this.retakeOnVideoEditor$.value===!1)return;this.retakeOnVideoEditor$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disableRetakeOnVideoEditor: ",e)}}getRetakeOnVideoEditor$(){return this.retakeOnVideoEditor$.asObservable()}getRetakeOnVideoEditor(){return this.retakeOnVideoEditor$.value}getRecorderStream(){return this.recorderInitData?.stream}getScreenStream$(){return this.screenStreamSubject$.asObservable()}requestScreenPermission(){return X(this,null,function*(){try{if(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)throw new Error("Screen sharing is not supported in this browser");let e=yield navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});if(!e.getVideoTracks()[0])throw new Error("No video track available in screen share stream");return e.getTracks().forEach(i=>{i.onended=()=>{this.screenStreamSubject$.next(null),this.clearRecording()}}),this.screenStreamSubject$.next(e),e}catch(e){return e.name==="NotAllowedError"||e.name==="PermissionDeniedError"?this.loggingService.catch("Screen sharing permission denied by user"):e.name==="NotFoundError"?this.loggingService.catch("No screen sharing device found"):e.name==="NotReadableError"||e.name==="OverconstrainedError"?this.loggingService.catch("Could not access screen sharing device"):this.loggingService.catch("Error in RecorderService requestScreenPermission: ",e),null}})}setMaxRecordingLength(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setMaxRecordingLength","color: green;"),this.maxRecordingLength=e}catch(t){this.loggingService.catch("Error in RecorderService setMaxRecordingLength: ",t)}}getMaxRecordingLength(){return this.maxRecordingLength}attemptFirefoxCanvasRecording(e){return X(this,null,function*(){try{let t=document.createElement("video");t.srcObject=e,t.muted=!0,t.autoplay=!0;let i=document.createElement("canvas"),a=i.getContext("2d");yield new Promise(g=>{t.onloadedmetadata=g}),i.width=t.videoWidth||1280,i.height=t.videoHeight||720;let l=i.captureStream(30);this.firefoxFallbackRecorder=new MediaRecorder(l,{mimeType:"video/webm;codecs=vp8",videoBitsPerSecond:this.recordingEncodingOptions.value.other?.videoBitsPerSecond||1e6});let c=[];this.firefoxFallbackRecorder.addEventListener("dataavailable",g=>{g.data.size>0&&c.push(g.data)}),this.firefoxFallbackRecorder.addEventListener("stop",()=>{if(c.length>0){let g=new Blob(c,{type:"video/webm"});this.chunks=c;let u=new pO;u.blob=g,u.url=URL.createObjectURL(g),u.type=this.recorderInitData?.type,u.recordedTime=this.recorderDurationSubject$.value,this.recordedRawData$.next(u)}this.firefoxFallbackRecorder=void 0});let d=()=>{t.readyState>=2&&a&&a.drawImage(t,0,0,i.width,i.height),t.srcObject&&this.firefoxFallbackRecorder?.state==="recording"&&requestAnimationFrame(d)};this.firefoxFallbackRecorder.start(1e3),d()}catch(t){this.loggingService.catch("Error in RecorderService attemptFirefoxCanvasRecording: ",t)}})}getRecorderDataFromInitData(){return{type:this.recorderInitData?.type}}askDevicePermission(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: askDevicePermission","color: green;"),navigator.mediaDevices.getUserMedia({audio:e.audio??!1,video:e.video??!1}).then(t=>{t.getTracks().forEach(i=>{i.stop()})}).catch(t=>{this.loggingService.catch("Error in RecorderService askDevicePermission: ",t)})}catch(t){this.loggingService.catch("Error in RecorderService askDevicePermission: ",t)}}openPictureInPicture(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: openPictureInPicture","color: green;");let e=this.getRecorderStream();if(!e)return;yield this.pipService.openPictureInPicture(e,()=>this.stopRecording())}catch(e){this.loggingService.catch("Error in RecorderService openPictureInPicture: ",e)}})}enablePlaybackOnPreviewClick(){try{if(this.playbackOnPreviewClick$.value===!0)return;this.playbackOnPreviewClick$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderService enablePlaybackOnPreviewClick: ",e)}}disablePlaybackOnPreviewClick(){try{if(this.playbackOnPreviewClick$.value===!1)return;this.playbackOnPreviewClick$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderService disablePlaybackOnPreviewClick: ",e)}}getPlaybackOnPreviewClick$(){return this.playbackOnPreviewClick$.asObservable()}getPlaybackOnPreviewClick(){return this.playbackOnPreviewClick$.value}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(k),Z(Vo),Z($p),Z(st),Z(Hn),Z(Ve),Z(as),Z(vc),Z(vl))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();function kYe(n,o,r,e){try{return{audio:o,video:n?h(h({deviceId:e?.video?.deviceId?{exact:e.video.deviceId}:void 0},r),e?.video?.deviceId?{}:{facingMode:"user"}):!1}}catch{return{}}}function xYe(n,o={}){try{return h({deviceId:n?.audio?.deviceId?{exact:n.audio.deviceId}:void 0},o)}catch{return{}}}var Ll=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_){this.afAuth=e,this.authService=t,this.configService=i,this.databaseService=a,this.docService=l,this.commonDbService=c,this.iamService=d,this.loggingService=g,this.notificationService=u,this.userPermissionService=_,this.documentPaths=null,this.views$=new Se({}),this.commentViews$=new Se({}),this.documentViews$=new Se({}),this.locationViews$=new Se({}),this.commentViewsByOrganizationIdAndDocumentId$=new Se({}),this.documentViewsByOrganizationIdAndDocumentId$=new Se({}),this.locationViewsByOrganizationIdAndLocationId$=new Se({}),this.documentViewsEnabled$=new Se(!1),this.documentViewsSetByDocumentId={},this.loggingService.log("%c[WB] Creating CLASS: ViewsService","color: blue;");try{this.authService.setViewsService(this),this.databaseService.getDb().pipe($e(w=>!!w),ut(1)).subscribe(w=>{w&&(this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(A=>{this.notificationService.setNotificationViews(A)}),this.authService.getUser$().pipe($e(A=>!!A),ye(A=>this.documentViewsEnabled$.pipe($e(M=>M),ge(()=>A))),ye(A=>this.docService.getDocumentPaths$().pipe(yo(null),Lr(),ge(([M,j])=>(M?.documentId!==j?.documentId&&this.views$.next({}),j)),ge(M=>(this.documentPaths=M,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:A,_documentPaths:M})),ye(M=>this.docService.getDocumentIds$().pipe(ye(j=>(j?.length&&(j.find(q=>q.documentId===this.documentPaths?.documentId)||j.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),j.forEach(q=>{this.setDocumentAsRead({documentId:q.documentId,clientDocumentId:q.clientDocumentId})})),de(M))))))),ye(A=>this.docService.getDocumentMetadata$().pipe($e(M=>!!M),ge(M=>y(h({},A),{_documentMetadata:M}))))).subscribe(),this.authService.getUser$().pipe($e(A=>!!A),ye(A=>this.documentViewsEnabled$.pipe($e(M=>M),ge(()=>A))),ye(A=>this.docService.getLocation$().pipe($e(M=>!!M))),ye(A=>this.docService.getDocumentIds$().pipe(ye(M=>(M.find(j=>j.documentId===this.documentPaths?.documentId)||M.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),M.forEach(j=>{this.setLocationAsRead({documentId:j.documentId,clientDocumentId:j.clientDocumentId})}),de(A)))))).subscribe())},w=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",w)})}catch(w){this.loggingService.catch("Error in ViewsService constructor: ",w)}}setCommentService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentService","color: green;"),this.commentService=e}catch(t){this.loggingService.catch("Error in ViewsService setCommentService: ",t)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ViewsService","color: green;");try{this.documentPaths=null,this.documentViews$.next({}),this.views$.next({}),this.commentViews$.next({}),this.locationViews$.next({}),this.commentViewsByOrganizationIdAndDocumentId$.next({}),this.documentViewsByOrganizationIdAndDocumentId$.next({}),this.locationViewsByOrganizationIdAndLocationId$.next({})}catch(e){this.loggingService.catch("Error in ViewsService clearCache: ",e)}}subscribeViewsData(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let i,a;try{if(e&&(a=tr(e)),t&&typeof t=="object"){let l=Ai(t);i=tr(JSON.stringify(l))}}catch(l){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",l)}return _r(this.afAuth).pipe($e(l=>!!l),ye(l=>this.isFeatureAllowed({firebaseUser:l})),ye(l=>l.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(c=>(l.featureAllowed=c,l))):de(l)),ye(l=>l.featureAllowed?de(l).pipe(ye(c=>this.docService.getDocumentPaths$().pipe(ge(d=>(this.documentPaths=d,c.documentPaths=d,c)))),ye(c=>a?this.getDataFromDocumentIds([a]):this.docService.getDocumentIds$().pipe(ye(d=>{let g=d?.length>0?d.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(g)})))):de([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>t.user?de(y(h({},t),{featureAllowed:!0})):de(y(h({},t),{featureAllowed:!1}))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getCommentViewsById(e){try{return this.commentViews$.value?.[e]?this.commentViews$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in ViewsService getCommentViewsById: ",t);return}}getDocumentViewsById(e){try{return this.documentViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getDocumentViewsById: ",t);return}}getLocationViewsById(e){try{return this.locationViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getLocationViewsById: ",t);return}}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:i}=e;return t?.some(a=>!a)||!this.documentPaths?de([]):this.documentViewsEnabled$.pipe(ye(a=>a?mn([this.getCommentViewsDataFromDocuments(),this.getDocumentViewsDataFromDocuments(t),this.getLocationViewsDataFromDocuments(t)]):mn([this.getCommentViewsDataFromDocuments()])))}else return de(null)}getCommentViews(e){try{let t={};Object.entries(e??{}).forEach(([i,a])=>{let l=a.metadata?.documentId,c=a.views;!l||!c||(t[l]||(t[l]={}),t[l][a.annotationId]=c)}),Object.entries(t??{}).forEach(([i,a])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:i,commentViews:a})})}catch(t){this.loggingService.catch("Error in ViewsService getCommentViews: ",t)}}getCommentViewsDataFromDocuments(){try{return this.commentService?this.commentService?.getAllCommentAnnotations({detectGhostComments:!0,addFilterCommentsOnDomCheck:!0,fromCommentSidebar:!0,skipPositionCalculation:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsContainer"}}}).pipe($e(e=>!!e),dn(e=>{this.getCommentViews(e)})):de([])}catch(e){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",e),de([])}}getDocumentViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,i=de([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(a.documentId=e?.length?e[0]:void 0,a.organizationId=this.documentPaths?.organizationId);let l=[];for(let c=0;c<(e?.length??0);c+=F.LISTENER_BATCH_SIZE)l.push(e?.slice(c,c+F.LISTENER_BATCH_SIZE)??[]);return i=mn(l.map(c=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:y(h({},a),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",c),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[ft("metadata.veltFolderId","==",t)]:[])]})}).pipe(va()))).pipe(ge(c=>ja(c))),i.pipe(ge(c=>({data:c?.data,operation:c?.operation})),ge(({data:c,operation:d})=>{let g={};return e?(Object.entries(c??{}).forEach(([u,_])=>{let w=_.metadata?.documentId;w&&(g[w]||(g[w]={}),g[w][u]=_)}),{data:c,documentMap:g,operation:d}):{data:c,documentMap:g,operation:d}}),ge(({data:c,documentMap:d,operation:g})=>{if(g?.type==="removed"){if(g?.ids?.length){let u=this.documentViews$.value;g?.ids?.forEach(_=>{delete u?.[_]}),this.documentViews$.next(u)}}else Object.entries(d??{}).forEach(([u,_])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,documentViews:_})})}))}getLocationViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,i=de([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(a.documentId=e?.length?e[0]:void 0,a.organizationId=this.documentPaths?.organizationId);let l=[];for(let c=0;c<(e?.length??0);c+=F.LISTENER_BATCH_SIZE)l.push(e?.slice(c,c+F.LISTENER_BATCH_SIZE)??[]);return i=mn(l.map(c=>this.commonDbService.dbListener({feature:"allLocationViews",properties:y(h({},a),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",c),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[ft("metadata.veltFolderId","==",t)]:[])]})}).pipe(va()))).pipe(ge(c=>ja(c))),i.pipe(ge(c=>({data:c?.data,operation:c?.operation})),ge(({data:c,operation:d})=>{let g={};return e?(Object.entries(c??{}).forEach(([u,_])=>{let w=_.metadata?.documentId;w&&(g[w]||(g[w]={}),g[w][u]=_)}),{data:c,documentMap:g,operation:d}):{data:c,documentMap:g,operation:d}}),ge(({data:c,documentMap:d,operation:g})=>{if(g?.type==="removed"){if(g?.ids?.length){let u=this.locationViews$.value;g?.ids?.forEach(_=>{delete u?.[_]}),this.locationViews$.next(u)}}else Object.entries(d??{}).forEach(([u,_])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,locationViews:_})})}))}setViewsData(e){try{this.views$.next(h(h({},this.views$.getValue()),e||{}))}catch(t){this.loggingService.catch("Error in ViewsService setViewsData:",t)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,commentViews:i,queryHash:a}){try{if(i||(i={}),t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l=h(h({},this.commentViews$.value),i);this.commentViews$.next(l),this.commentViewsByOrganizationIdAndDocumentId$.next(y(h({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(h({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(h({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[a]:i})})}))}}catch(l){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,documentViews:i,queryHash:a}){try{if(i||(i={}),t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l=h(h({},this.documentViews$.value),i);this.documentViews$.next(l),this.documentViewsByOrganizationIdAndDocumentId$.next(y(h({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(h({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(h({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[a]:i})})}))}}catch(l){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,locationViews:i,queryHash:a}){try{if(i||(i={}),t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l=h(h({},this.locationViews$.value),i);this.locationViews$.next(l),this.locationViewsByOrganizationIdAndLocationId$.next(y(h({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:y(h({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[t]:y(h({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[t]),{[a]:i})})}))}}catch(l){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}getCommentFeatureViews$(){return this.commentViews$.pipe(bt((e,t)=>JSON.stringify(e||{})===JSON.stringify(t||{})))}setCommentAnnotationAsRead(e){return X(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.updateCommentAnnotationViews(e);let i=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",a=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:a,organizationId:i,metadata:{apiKey:this.configService.getApiKey(),organizationId:i,veltFolderId:e?.metadata?.veltFolderId,documentId:a}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}setCommentAnnotationAsUnread(e){return X(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.removeCommentAnnotationViews(e);let i=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",a=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:a,organizationId:i,metadata:{apiKey:this.configService.getApiKey(),organizationId:i,veltFolderId:e?.metadata?.veltFolderId,documentId:a}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}updateCommentAnnotationViews(e){try{let t=this.authService.getUser(),i={views:{},comments:{}};if(t){let a={},l=e?.views?.comments||{},c=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(g=>{l[g.commentId]||(l[g.commentId]={views:{}}),l[g.commentId].views||(l[g.commentId].views={}),l[g.commentId].views[t.userSnippylyId]||(l[g.commentId].views[t.userSnippylyId]={timestamp:c})});let d=new Set(e.comments?.map(g=>g.commentId+""));if(Object.keys(l??{}).forEach(g=>{d.has(g)||delete l[g]}),e.comments?.length){let g=l[e.comments[0].commentId]?.views||{},u=Object.keys(g??{}).filter(_=>e.comments?.every(w=>l[w.commentId]?.views?.[_]));u.forEach(_=>{a[_]={timestamp:g[_].timestamp}}),e.viewedByUserIds=u}i.views=a,i.comments=l,e.views=i}return i}catch(t){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",t),{views:{},comments:{}}}}removeCommentAnnotationViews(e){try{let t=this.authService.getUser(),i={views:{},comments:{}};if(t){let a={},l=e?.views?.comments||{};e.comments?.forEach(d=>{l[d.commentId]?.views?.[t.userSnippylyId]&&delete l[d.commentId].views[t.userSnippylyId]});let c=new Set(e.comments?.map(d=>d.commentId+""));if(Object.keys(l??{}).forEach(d=>{c.has(d)||delete l[d]}),e.comments?.length){let d=l[e.comments[0].commentId]?.views||{},g=Object.keys(d??{}).filter(u=>e.comments?.every(_=>l[_.commentId]?.views?.[u]));g.forEach(u=>{a[u]={timestamp:d[u].timestamp}}),e.viewedByUserIds=g}else e.viewedByUserIds=[];i.views=a,i.comments=l,e.views=i}return i}catch(t){return this.loggingService.catch("Error in ViewsService removeCommentAnnotationViews:",t),{views:{},comments:{}}}}getNotificationFeatureViews$(){return this.views$.pipe(bt((e,t)=>JSON.stringify(e?.notification||{})===JSON.stringify(t?.notification||{})))}setNotificationsAsRead(e){try{let t=this.authService.getUser();if(t){let i=new Date().getTime()+this.commonDbService.getOffset();e.forEach(a=>{this.commonDbService.updateData({feature:"notificationViewsTimestamp",properties:{id:a,user:t.userSnippylyId,documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??""},data:{timestamp:i}})})}}catch(t){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",t)}}getDocumentViews$(){return this.views$.pipe(bt((e,t)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(t?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(ye(t=>(this.documentPaths=t,e?this.locationViews$.pipe(ge(i=>{let a=Object.keys(i||{}).find(l=>i?.[l]?.location?.id===e);return a?i?.[a]?.users||{}:{}})):this.documentViews$.pipe(ge(i=>{let a=this.documentPaths?.documentId;return a?i?.[a]?.users||{}:{}})))),bt(Zt))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",t),de({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(ye(t=>(this.documentPaths=t,e?this.locationViews$.pipe(ge(i=>{let a=Object.keys(i||{}).find(l=>i?.[l]?.location?.id===e);return a?i?.[a]?.day||{}:{}})):this.documentViews$.pipe(ge(i=>{let a=this.documentPaths?.documentId;return a?i?.[a]?.day||{}:{}})))))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",t),de({})}}enableDocumentViews(){try{if(this.documentViewsEnabled$.value===!0)return;this.documentViewsEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ViewsService enableDocumentViews:",e)}}disableDocumentViews(){try{if(this.documentViewsEnabled$.value===!1)return;this.documentViewsEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in ViewsService disableDocumentViews:",e)}}setDocumentAsRead(i){return X(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let a=this.authService.getUser();if(a&&e&&this.userPermissionService?.hasEditAccess({documentId:e??"",folderId:this.documentPaths?.allDocuments&&this.documentPaths?.veltFolderId?this.documentPaths?.veltFolderId:void 0})){if(this.documentViewsSetByDocumentId[e])return;this.documentViewsSetByDocumentId[e]=!0;let l=new Date().getTime()+this.commonDbService.getOffset(),c=new Date().toISOString().split("T")[0],d=this.getDocumentViewsById(e);if(d){let g=new Date().toISOString().split("T")[0];d?.users[a.userSnippylyId]||(d.users[a.userSnippylyId]={}),d.users[a.userSnippylyId][g]={timestamp:this.timestamp},d?.day[g]||(d.day[g]={}),d.day[g][a.userSnippylyId]={timestamp:this.timestamp},d.metadata=this.docService.getBaseMetadata("documentViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:g,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??""},data:d})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:c,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:l}}),this.commonDbService.updateData({feature:"documentUsersViews",properties:{id:e,user:a.userSnippylyId,date:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:l}}),this.commonDbService.updateData({feature:"documentMetadataViews",properties:{id:e,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})}),this.docService.getDocumentMetadata$(e).pipe($e(g=>g!==null),ut(1)).subscribe(()=>{let g={day:{[c]:{[a.userSnippylyId]:{timestamp:l}}},users:{[a.userSnippylyId]:{[c]:{timestamp:l}}},metadata:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})};this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:c,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0},data:g})});this.checkAndTriggerNotification(a)}}catch(a){this.loggingService.catch("Error in ViewsService setDocumentAsRead:",a)}})}checkAndTriggerNotification(e){try{this.getUniqueViewsByUser().pipe(ut(1)).subscribe(t=>{if(Object.keys(t??{}).length===2){let i=this.docService.getDocumentMetadata();if(i?.creator?.email&&i?.creator?.email!==e.email){let a=[i.creator.email];this.updateNotificationsDatabase(OZ.FIRST_VIEWED,{documentViews:{emails:a}})}}})}catch(t){this.loggingService.catch("Error in checkAndTriggerNotification:",t)}}setLocationAsRead(i){return X(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let a=this.authService.getUser(),l=this.docService.getLocation(),c=l?.locationId,d=l?.location;if(a&&c&&d){let g=new Date().getTime()+this.commonDbService.getOffset(),u=new Date().toISOString().split("T")[0],_=this.getLocationViewsById(c);if(_){let w=new Date().toISOString().split("T")[0];_?.users[a.userSnippylyId]||(_.users[a.userSnippylyId]={}),_.users[a.userSnippylyId][w]={timestamp:this.timestamp},_?.day[w]||(_.day[w]={}),_.day[w][a.userSnippylyId]={timestamp:this.timestamp},_.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"location",data:_,properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:d,properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:c,user:a.userSnippylyId,date:u,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:g}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:c,date:u,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:g}}),this.commonDbService.updateData({feature:"locationMetadataViews",properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t})});let w={day:{[u]:{[a.userSnippylyId]:{timestamp:g}}},users:{[a.userSnippylyId]:{[u]:{timestamp:g}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),location:d};this.commonDbService.updateData({feature:"location",data:w,properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0}})}}}catch(a){this.loggingService.catch("Error in ViewsService setLocationAsRead:",a)}})}updateNotificationsDatabase(e,t={}){try{let i=h({actionType:e,notificationSource:"documentViews"},t);this.notificationService.updateNotificationDatabase(i)}catch(i){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",i)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(t){return new(t||o)(Z(no),Z(Ke),Z(Lt),Z(Hn),Z(st),Z(kn),Z(Vn),Z(k),Z(cn),Z(Oa))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ls=(()=>{let o=class o{constructor(e,t,i,a){this.docService=e,this.loggingService=t,this.authService=i,this.configService=a;try{this.loggingService.log("%c[WB] Creating CLASS: MetadataService","color: blue;")}catch(l){this.loggingService.catch("Error in MetadataService constructor: ",l)}}getGlobalMetadata(){return X(this,null,function*(){try{let e=this.authService.getUser();if(!e)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),{};let t=this.docService.getOrganizationMetadata(e?.organizationId),i=this.docService.getDocumentMetadataOfAvailableDocuments(),a=this.docService.getLocation();t&&(t=JSON.parse(JSON.stringify(t)),delete t?.organizationId,t.organizationId=t?.clientOrganizationId,delete t?.clientOrganizationId,delete t?.pageInfo),i&&(i=JSON.parse(JSON.stringify(i)),i.forEach(u=>{delete u?.locations,delete u?.location,delete u?.locationId,delete u?.pageInfo,delete u?.documentId,u.documentId=u?.clientDocumentId,delete u?.clientDocumentId,delete u?.veltFolderId,u?.clientOrganizationId&&(u.organizationId=u?.clientOrganizationId,delete u?.clientOrganizationId)}));let l=[];a&&(a=JSON.parse(JSON.stringify(a)),a?.location&&l.push(a?.location));let c=this.docService.getLocations();c&&Object.values(c).forEach(u=>{u?.location&&l.push(u?.location)});let d=this.docService.getDocumentPaths()?.folderId;return{organization:t,documents:i,locations:l,folderId:d}}catch(e){return this.loggingService.catch("Error in MetadataService getGlobalMetadata: ",e),{}}})}getDebugInfo(){return X(this,null,function*(){try{let e=this.authService.getUser();if(!e)return null;let t,i;e&&(t=Bo(e)??void 0,i=JSON.parse(JSON.stringify(e)),delete i?.contacts);let a=this.configService.getApiKey(),l=window?.Velt?.version,c=this.docService.getOrganizationMetadata(e?.organizationId),d,g;c&&(d=JSON.parse(JSON.stringify(c)),delete d?.organizationId,d.organizationId=d?.clientOrganizationId,delete d?.clientOrganizationId,delete d?.pageInfo,delete d?.apiKey,g=JSON.parse(JSON.stringify(c)),delete g?.clientOrganizationId,delete g?.pageInfo,delete g?.apiKey);let u=this.docService.getDocumentMetadataOfAvailableDocuments(),_=this.docService.getLocation(),w=[],A=[];_&&(w.push(_),_?.location&&A.push(_?.location));let M=this.docService.getLocations();M&&Object.values(M).forEach(fe=>{w.push(fe),fe?.location&&A.push(fe?.location)});let j=[],q=[];u&&(j=JSON.parse(JSON.stringify(u)),j.forEach(fe=>{delete fe?.apiKey,delete fe?.locations,delete fe?.location,delete fe?.locationId,delete fe?.pageInfo,delete fe?.documentId,fe.documentId=fe?.clientDocumentId,delete fe?.clientDocumentId,delete fe?.veltFolderId,fe?.clientOrganizationId&&(fe.organizationId=fe?.clientOrganizationId,delete fe?.clientOrganizationId)}),q=JSON.parse(JSON.stringify(u)),q.forEach(fe=>{delete fe?.apiKey,delete fe?.locations,delete fe?.location,delete fe?.locationId,delete fe?.pageInfo,delete fe?.clientDocumentId,fe.folderId=fe?.veltFolderId,delete fe?.veltFolderId,delete fe?.clientOrganizationId}));let ie,_e=this.docService.getDocumentPaths();_e?.folderId&&_e?.veltFolderId&&(ie={folderId:_e?.folderId,veltFolderId:_e?.veltFolderId});let ae,ue;ie&&(ae=JSON.parse(JSON.stringify(ie)),delete ae?.veltFolderId,ue=JSON.parse(JSON.stringify(ie)),ue.folderId=ue.veltFolderId,delete ue?.veltFolderId);let Ie={};return Ie.veltVersion=l,Ie.apiKey=a,Ie.serverMap={organization:g??void 0,documents:q,locations:w??void 0,folder:ue??void 0,user:i??void 0,accessFields:this.docService.getProcessedDocContext()??void 0},Ie.clientMap={organization:d??void 0,documents:j,locations:A??void 0,folder:ae??void 0,user:t??void 0,context:this.docService.getDocContext()??void 0},Ie}catch(e){return this.loggingService.catch("Error in MetadataService getDebugInfo: ",e),null}})}getDebugInfo$(){return mn([this.authService.getUser$(),this.docService.getOrganizationConfig$(),this.docService.getOrganizationMetadataMap$(),this.docService.getAllDocumentMetadataMap$(),this.docService.getDocContext$()]).pipe(ye(()=>X(this,null,function*(){return yield this.getDebugInfo()})),bt(Zt))}};o.\u0275fac=function(t){return new(t||o)(Z(st),Z(k),Z(Ke),Z(Lt))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var jS=(()=>{let o=class o{constructor(e,t,i){this.coreActionsService=e,this.loggingService=t,this.metadataService=i,this.buttonClickSubject$=new it,this.buttonToggleMap$=new Se({}),this.contextDataMapping={commentAnnotation:{source:["componentConfigSignal","data","annotation"],target:"commentAnnotation"},unreadCommentsMap:{source:["componentConfigSignal","unreadCommentsMap"],target:"unreadCommentAnnotationsMap"},comment:{source:["commentObj"],target:"comment"},index:{source:["i"],target:"index"},allAnnotations:{source:["componentConfigSignal","annotations"],target:"commentAnnotations"},systemFilteredAnnotations:{source:["componentConfigSignal","filteredCommentPinAnnotations"],target:"systemFilteredAnnotations"},notification:{source:["notification"],target:"notification"},allNotifications:{source:["componentConfigSignal","notificationsInSession"],target:"notifications"}}}buttonClick(c){return X(this,arguments,function*({id:e,type:t,groupId:i,contextData:a,data:l}){try{this.buttonToggle(e,void 0,t,i);let g=this.extractButtonData(a),u=this.createButtonContext(e,t,i),_=yield this.metadataService.getGlobalMetadata(),w={};if(l){let d=l,{componentConfigSignal:M}=d,j=zh(d,["componentConfigSignal"]);if(w=h({},j),M&&typeof M=="function")try{let q=M();q&&typeof q=="object"&&(w=h(h({},w),q))}catch(q){this.loggingService.catch("Error accessing componentConfigSignal: ",q)}}let A=y(h({buttonContext:u},g),{metadata:_,data:w});this.buttonClickSubject$.next(A),this.coreActionsService.triggerAction(nt.VELT_BUTTON_CLICK,A)}catch(g){this.loggingService.catch("Error in ButtonService buttonClick: ",g)}})}buttonActive({id:e,type:t,groupId:i,contextData:a}){try{let l=this.buttonToggleMap$.value?.[i||"ungrouped"]?.[e]||!0;this.buttonToggle(e,l,t,i)}catch(l){this.loggingService.catch("Error in ButtonService buttonClick: ",l)}}buttonToggle(e,t,i,a){try{let l=this.buttonToggleMap$.value,c=this.createNewToggleMap(l,e,t,i,a);this.buttonToggleMap$.next(c)}catch(l){this.loggingService.catch("Error in ButtonService buttonToggle: ",l)}}extractButtonData(e){try{let t={};return Object.entries(this.contextDataMapping).forEach(([i,a])=>{let l=this.getNestedValue(e,a.source);l!==void 0&&(t[a.target]=l)}),t}catch(t){return this.loggingService.catch("Error in ButtonService extractContextData: ",t),{}}}getNestedValue(e,t){try{let i=e;for(let a of t){if(i?.[a]===void 0)return;mo(i[a])?i=i[a]():i=i[a]}return i}catch(i){this.loggingService.catch("Error in ButtonService getNestedValue: ",i);return}}createButtonContext(e,t,i){try{let a={type:t,selections:this.buttonToggleMap$.value,clickedButtonId:e};return(t==="single-select"||t==="multi-select")&&i?y(h({},a),{groupId:i}):a}catch(a){return this.loggingService.catch("Error in ButtonService createButtonMetadata: ",a),{}}}createNewToggleMap(e,t,i,a,l){try{let c=h({},e);return a==="button-toggle"?y(h({},c),{ungrouped:y(h({},c.ungrouped),{[t]:i??!c.ungrouped?.[t]})}):a==="single-select"&&l?y(h({},c),{[l]:{[t]:i??!0}}):a==="multi-select"&&l?y(h({},c),{[l]:y(h({},c[l]),{[t]:i??!c[l]?.[t]})}):c}catch(c){return this.loggingService.catch("Error in ButtonService createNewToggleMap: ",c),{}}}buttonClickSubject(){return this.buttonClickSubject$.asObservable()}buttonToggleMap(){return this.buttonToggleMap$.asObservable()}resetVeltButtonState(e){return X(this,null,function*(){try{if(e){let{id:l,group:c}=e,d=JSON.parse(JSON.stringify(this.buttonToggleMap$.value||{}));c&&l?delete d?.[c]?.[l]:c?delete d?.[c]:l&&Object.keys(d).forEach(g=>{Object.keys(d[g]).forEach(u=>{u===l&&delete d?.[g]?.[u]})}),this.buttonToggleMap$.next(d)}else this.buttonToggleMap$.next({});let t={selections:this.buttonToggleMap$.value},i=yield this.metadataService.getGlobalMetadata(),a={buttonContext:t,metadata:i};this.coreActionsService.triggerAction(nt.VELT_BUTTON_CLICK,a)}catch(t){this.loggingService.catch("Error in ButtonService resetVeltButtonState: ",t)}})}buttonToggleMapValue(){return this.buttonToggleMap$.value}};o.\u0275fac=function(t){return new(t||o)(Z(rr),Z(k),Z(ls))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var $S=(()=>{let o=class o{constructor(e,t){this.httpClient=e,this.loggingService=t,this.fileContentMap$=new Se({})}getFileContent(e){try{let t=tr(e);return this.fileContentMap$.value[t]?de(this.fileContentMap$.value[t]):this.httpClient.get(e,{responseType:"text"}).pipe(ge(i=>(this.fileContentMap$.next(y(h({},this.fileContentMap$.value),{[t]:i})),i)))}catch(t){return this.loggingService.catch("Error in TranscriptionService saveRecorderToDb: ",t),de(null)}}getVttFileTextToArray(e){try{let c=[],d=e.split(`
|
|
501
|
-
`);for(var t=0;t<d.length;t++)if(d[t].indexOf("-->")!==-1){var i=d[t].split(" --> ")[0],a=d[t].split(" --> ")[1],l=d[t+1];c.push({startTime:i,endTime:a,startTimeInSeconds:this.getTimeInSecondsFromVttTime(i),endTimeInSeconds:this.getTimeInSecondsFromVttTime(a),text:l})}return c}catch(c){return this.loggingService.catch("Error in TranscriptionService getVttFileTextToArray: ",c),[]}}getTimeInSecondsFromVttTime(e){try{let t=e.split(":"),i=0;t.length===3&&(i=parseInt(t[0]),t.shift());let a=parseInt(t[0]),l=parseInt(t[1].split(".")[0]),c=parseInt(t[1].split(".")[1]);return((i*60*60+a*60+l)*1e3+c)/1e3}catch(t){return this.loggingService.catch("Error in TranscriptionService getTimeInSecondsFromVttTime: ",t),0}}};o.\u0275fac=function(t){return new(t||o)(Z(L8),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var fo=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we){this.analyticsService=e,this.configService=t,this.docService=i,this.databaseService=a,this.commonDbService=l,this.authService=c,this.domService=d,this.afAuth=g,this.iamService=u,this.functions=_,this.avatarService=w,this.contactService=A,this.storageService=M,this.dialog=j,this.loggingService=q,this.notificationService=ie,this.transcriptionService=_e,this.recorderService=ae,this.recorderUtilsService=ue,this.userPermissionService=Ie,this.recorderAnnotationsResolverService=fe,this.attachmentResolverService=we,this.recorderAnnotationById$=new Se({}),this.documentPaths=null,this.allowedElementIds$=new Se([]),this.addRecorderMode$=new Se(!1),this.recorderContainerDarkMode$=new Se(!1),this.recordingTranscriptionEnabled$=new Se(!0),this.draftRecordings$=new Se([]),this.recorderNotesFound$=new Se(!1),this.recordedData=null,this.videoEditorAutoOpen$=new Se({}),this.commentService=null,this.getAllRecorderAnnotations().subscribe(Ae=>{}),this.loggingService.log("%c[WB] Creating CLASS: RecorderAnnotationService","color: blue;"),this.analyticsService.setRecorderAnnotationService(this),this.authService.setRecorderAnnotationService(this),this.databaseService.getDb().pipe($e(Ae=>!!Ae),ut(1)).subscribe(Ae=>{Ae&&this.getDocumentPaths()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",Ae)}),this.domService.onWindowPointerMove$().subscribe(Ae=>{if(this.addRecorderMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let Pe=this.domService.getBackgroundElement(Ae.clientX,Ae.clientY);Pe&&(this.isElementInsideAllowedElements(Pe)?ZF(Ae.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=Pe):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowPointerMove$ subscription: ",Ae)}),this.domService.onWindowKeyupEsc$().subscribe(Ae=>{this.addRecorderMode$.value&&this.disableAddRecorderMode()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupEsc$ subscription: ",Ae)}),this.domService.onDocumentClick$().subscribe(Ae=>{if(Ae&&this.addRecorderMode$.value){if(Ae.preventDefault(),Ae.stopPropagation(),!ZF(Ae.target)){let Pe=this.domService.getBackgroundElement(Ae.clientX,Ae.clientY);Pe&&this.isElementInsideAllowedElements(Pe)}this.disableAddRecorderMode()}},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onDocumentClick$ subscription: ",Ae)}),this.addRecorderMode$.subscribe(Ae=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),Ae?this.domService.addClassToElement(document.body,"snippyly-add-recorder-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-recorder-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService addRecorderMode$ subscription: ",Ae)}),this.domService.onWindowKeyupBackspace$().subscribe(Ae=>{this.deleteRecorderPinAnnotations()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupBackspace$ subscription: ",Ae)}),this.domService.onWindowKeyupDelete$().subscribe(Ae=>{this.deleteRecorderPinAnnotations()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Ae)}),this.recorderService.onRecordedData().subscribe(Ae=>{this.recordedData=Ae},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onRecordedData subscription: ",Ae)}),this.domService.getDeleteCommmentAnnotations$().subscribe(Ae=>{Ae?.length&&Ae.forEach(Pe=>X(this,null,function*(){}))},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Ae)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in RecorderAnnotationService","color: green;");try{this.recorderAnnotationById$.next({}),this.documentPaths=null,this.allowedElementIds$.next([]),this.addRecorderMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in RecorderAnnotationService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getDocumentPaths: ",e)}}setCommentService(e){this.loggingService.log("%c[WB] Calling FUNCTION: setCommentService","color: green;");try{this.commentService=e}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setCommentService: ",t)}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getDraftRecordings$(){return this.draftRecordings$.asObservable()}getRecorderDataByRecorderId(e){try{return this.recorderAnnotationById$.pipe(ge(()=>this.getAnnotationById(e)),ye(t=>X(this,null,function*(){return t?yield this.createRecorderData(t,!0):void 0})))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderId: ",t),de(void 0)}}getRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t={};return yield Promise.all(e.recorderIds.map(i=>X(this,null,function*(){let a=this.getAnnotationById(i);if(!a)return;let l=yield this.createRecorderData(a,!0);l&&(t[i]=l)}))),{data:Object.keys(t).length>0?t:null}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderIds: ",t),{data:null}}})}fetchRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t=this.recorderAnnotationById$.value,i=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(l=>e.recorderIds.includes(l.annotationId))),a.length===0?[]:(yield Promise.all(a.map(l=>X(this,null,function*(){if(!l)return;let c=yield this.createRecorderData(l,!0);c&&i.push(c)}))),i)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService fetchRecorderDataByRecorderIds: ",t),[]}})}deleteRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t=this.recorderAnnotationById$.value,i=[],a=Object.values(t),l=[];return e?.recorderIds?.length&&(l=a.filter(c=>e.recorderIds.includes(c.annotationId))),l.length===0?[]:(yield Promise.all(l.map(c=>X(this,null,function*(){if(!c)return;let d=yield this.createRecorderData(c,!0);yield this.deleteRecorderPinAnnotation(c),d&&i.push(d)}))),i)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderDataByRecorderIds: ",t),[]}})}getRecordings(e){try{return this.recorderAnnotationById$.pipe(ye(t=>X(this,null,function*(){let i=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(l=>e.recorderIds.includes(l.annotationId))),a.length===0?[]:(yield Promise.all(a.map(l=>X(this,null,function*(){if(!l)return;let c=yield this.createRecorderData(l,!0);c&&i.push(c)}))),i)})),Gn(t=>(this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),de([]))))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),de([])}}setRecorderActionsService(e){try{this.recorderActionsService=e}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",t)}}getVttFileTextToArray(e){try{return this.transcriptionService.getVttFileTextToArray(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getVttFileTextToArray: ",t)}}getAllRecorderAnnotations(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: getAllRecorderAnnotations","color: green;");let a,l;try{if(e&&(l=tr(e)),t&&typeof t=="object"){let c=Ai(t);a=tr(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in RecorderAnnotationService getAllRecorderAnnotations: ",c)}return _r(this.afAuth).pipe($e(c=>!!c),ye(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),ye(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(d=>(c.featureAllowed=d,c))):de(c)),ye(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(ge(d=>(c.featureAllowed=!d,c))):de(c)),ye(c=>c.featureAllowed?de(c).pipe(ye(d=>this.docService.getDocumentPaths$().pipe(ge(g=>(this.documentPaths=g,d.documentPaths=g,d)))),ye(d=>l?this.getDataFromDocumentIds([l]).pipe(ge(g=>(d.annotations=g||[],h({},d)))):this.docService.getDocumentIds$().pipe(ye(g=>{let u=g?.length>0?g.map(_=>_.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(u).pipe(ge(_=>(d.annotations=_||[],h({},d))))}))),ye(d=>this.docService.getLocation$().pipe(ge(g=>(d.location=g,d)))),ye(d=>this.docService.getLocations$().pipe(ge(g=>(d.customLocations=g,d)))),ge(d=>{if(d.filteredAnnotations=[],l&&!a)return d.filteredAnnotations=d.annotations?.slice(),d;{let g=[];return a?g.push(a):(g.push(d?.location?.locationId),g.push(...Object.values(d?.customLocations||[]).map(u=>u.locationId))),d.filteredAnnotations=this.filterAnnotationsByLocationIds(d?.annotations,g),d}}),ye(d=>i?de(d):d?.annotations?.length?this.domService.onWindowResize$().pipe(ge(()=>d)):de(d)),ye(d=>i?de(d):d?.annotations?.length?this.domService.onDomChange$("RecorderAnnotationService getAllRecorderAnnotations").pipe(ge(()=>d)):de(d)),ge(d=>{let g=[];return d?.filteredAnnotations?.forEach(u=>{this.calculateRecorderAnnotationPosition(u),u?.targetElement||g.push(u)}),this.draftRecordings$.next(g),d}),ye(d=>d?.filteredAnnotations?de(d?.filteredAnnotations||[]):de([]))):de([])),bt(Zt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.RECORDER)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Recorder feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:i}=e;if(t?.some(d=>!d)||!this.documentPaths)return de([]);let a=this.docService.getDocumentPaths()?.veltFolderId,l=de([]),c={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(c.documentId=t?.length?t[0]:void 0,c.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let d=[F.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let u=0;u<(d?.length??0);u+=F.LISTENER_CONTEXT_BATCH_SIZE)g.push(d?.slice(u,u+F.LISTENER_CONTEXT_BATCH_SIZE)??[]);l=mn(g.map(u=>this.commonDbService.dbListener({feature:"allRecorders",properties:y(h({},c),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",t),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[ft("metadata.veltFolderId","==",a)]:[],...u?.length?[ft("context.accessFields","array-contains-any",u)]:[])]})}).pipe(va()))).pipe(ge(u=>ja(u)))}else{let d=[];for(let g=0;g<(t?.length??0);g+=F.LISTENER_BATCH_SIZE)d.push(t?.slice(g,g+F.LISTENER_BATCH_SIZE)??[]);l=mn(d.map(g=>this.commonDbService.dbListener({feature:"allRecorders",properties:y(h({},c),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",g),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[ft("metadata.veltFolderId","==",a)]:[])]})}).pipe(va()))).pipe(ge(g=>ja(g)))}return l.pipe(ge(d=>({data:d?.data,operation:d?.operation})),ge(({data:d,operation:g})=>{let u=[];return d&&(u=Object.values(d).filter(_=>typeof _=="object")),{data:u,operation:g}}),ge(({data:d,operation:g})=>{if(!t)return{data:d,documentMap:{},operation:g};let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});return{data:d,documentMap:u,operation:g}}),ge(({data:d,documentMap:g,operation:u})=>{if(!i)if(u?.type==="removed"){if(u?.ids?.length){let _=this.recorderAnnotationById$.value;u?.ids?.forEach(w=>{delete _?.[w]}),this.recorderAnnotationById$.next(_)}}else Object.entries(g).forEach(([_,w])=>{this.setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,annotations:w})});return d}),Gn(d=>(this.loggingService.catch("Error in RecorderAnnotationService getDataFromDocumentId: ",d),de([]))))}else return de([])}setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i?.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.recorderAnnotationById$.value),l);this.recorderAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in RecorderAnnotationService setRecorderAnnotationsByOrganizationIdAndDocumentId:",l)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(i=>t.includes(i.locationId))}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService filterAnnotationsByLocations:",i),[]}}calculateRecorderAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let i=t.iterateNext();if(i&&Xr(i)){let a=i.getBoundingClientRect();if(a&&a.width&&a.height){let{height:l,width:c}=vp(i);e.position={top:l*e.targetElement.topPercentage/100,left:c*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService calculateRecorderAnnotationPosition:",t)}}getAnnotationById(e,t){try{let i=this.recorderAnnotationById$.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in RecorderAnnotationService getAnnotationById: ",i);return}}getBaseMetadataFromRecorderAnnotationId(e){try{let t=this.recorderAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getBaseMetadataFromRecorderAnnotationId: ",t)}}getRecorderAnnotationById(e,t){return this.recorderAnnotationById$.pipe(ye(()=>{let i=this.getAnnotationById(e,t);return i?de(i):de(null)}),Gn(i=>(this.loggingService.catch("Error in RecorderAnnotationService getCommentAnnotationById: ",i),de(null))))}getRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i={};return Object.values(this.recorderAnnotationById$.value).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(i[a?.annotationId]=a)}),Object.values(i)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderAnnotationsByOrganizationIdAndDocumentId:",i),[]}}setLocationToRecorderAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{if(e.targetElement?.xpath){let i=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setLocationToRecorderAnnotation:",t)}}addRecorder(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: addRecorder","color: green;");try{let a=this.authService.getUser();if(a){if(a.isReadOnly||a.isAnonymous)return this.loggingService.catch("Anonymous/Readonly users cannot add recorders."),de(null);{t.from=a,t.color=F.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:l,topPositionY:c}=this.domService.getTopLeftPosition();t.positionX=l,t.positionY=c;let d=this.domService.getCurrentWindowSizeValue();if(t.screenWidth=d.screenWidth,t.screenHeight=d.screenHeight,t.screenScrollHeight=d.screenScrollHeight,t.recorderedElementPath="",e&&(t.targetElement=this.domService.getTargetElementForCursorPosition(e)),t?.targetElement?.xpath){let g=this.domService.getXPath(t.targetElement.xpath);if(g){let u=g.iterateNext();u&&(Xr(u)||(t.targetElement=null))}}return this.setLocationToRecorderAnnotation(t),t.pageInfo=io(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveRecorderToDb(t,i)}}else return de(null)}catch(a){return this.loggingService.catch("Error in RecorderAnnotationService addRecorder: ",a),de(null)}}saveRecorderToDb(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: saveRecorderToDb","color: green;");try{return this.authService.getUser()&&this.authService.isFeatureAllowed(je.RECORDER)?this.docService.getDocumentPaths$().pipe($e(i=>!!i),ut(1),ye(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(a=>!!a),ut(1),ye(a=>X(this,null,function*(){if(this.documentPaths?.recorder){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.recorderUrl=this.generateRecorderUrl(e));let l=JSON.parse(JSON.stringify(e));if(l.position=null,this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||delete l?.isUrlAvailable,!l?.metadata?.documentId){l?.metadata||(l.metadata={});let u=this.docService.getBaseMetadata("recorder",{commentAnnotationId:e.commentAnnotationId});l.metadata=h(h({},l?.metadata),u)}let{documentId:c,organizationId:d}=l?.metadata||{};if(e.commentAnnotationId){let u=this.commentService?.getAnnotationById(e.commentAnnotationId??"");if(u?.context?.access&&u?.context?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:e.from?.userId,accessFields:u.context.accessFields}))return this.loggingService.catch("User does not have context access to add recorder annotation.",void 0,void 0,!0),null;l.context={access:u.context.access,accessFields:u.context.accessFields}}}let g={annotationData:l,actionType:rc.ADDED,notificationSource:"recorder"};if(yield new Promise((u,_)=>X(this,null,function*(){yield this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:d},data:JSON.parse(JSON.stringify(l)),extraData:g,callback:()=>{u(!0)},errorCallback:w=>{_(w)}})})),this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_ADDED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderTime:e?.recordedTime?.duration,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e?.attachment?.size,sourceFeature:t||"recording"}),this.setVideoEditorAutoOpen({[e.annotationId]:!0}),t==="recording"){let u=yield this.createRecorderData(l,!1);u&&this.recorderActionsService?.onRecordingDoneLocal(u)}return this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||this.processRecording(e,"recording","merge"),this.updateNotificationsDatabase(e,rc.ADDED),e}else return null})))))):de(null)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService saveRecorderToDb: ",i),de(null)}}processRecording(e,t,i){return X(this,null,function*(){try{let a=qr(this.functions,Kr({url:Dn?.cloudFunction?.processRecording,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),l=this.docService.getDocumentPaths();e?.metadata?.documentId&&(l=new xm({apiKey:this.configService.getApiKey(),clientDocumentId:e.metadata.clientDocumentId,clientOrganizationId:e.metadata.clientOrganizationId,documentId:e.metadata.documentId,organizationId:e.metadata.organizationId}));let c={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:l?.recorder+e?.annotationId,fromUser:this.authService.getUser(),clientOrganizationId:l?.clientOrganizationId,clientDocumentId:l?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:l?.recorder,annotationId:e?.annotationId,sourceFeature:t||"recording",annotationData:e,skipMerge:!0,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:i,returnType:"transcription",generatePreviewImages:this.recorderService.getVideoEditor()&&this.recorderService.getVideoEditorTimelinePreview()};if(c?.useFirestore){let M=yield this.recorderUtilsService.encryptRecorderAnnotation(e);c.annotationData=M}let d=this.documentPaths?.organizationId,g=this.documentPaths?.documentId;e?.metadata?.documentId&&(g=e.metadata.documentId,d=e.metadata.organizationId);let u=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;d&&(u=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${d}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),c.bucketPath=u;let _;try{_=yield a(c)}catch(M){M?.details?.type==="recording"&&this.recorderActionsService?.onError({type:"recordingFailed",message:"Recording failed",recorderId:M.details.recorderId}),M?.details?.type==="transcription"&&this.recorderActionsService?.onError({type:"transcriptionFailed",message:"Transcription failed",recorderId:M.details.recorderId}),this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",M)}let w=this.getAnnotationById(e?.annotationId);if(!w)return;let A=yield this.createRecorderData(w,!1);if(A){if(_?.data?.transcriptedText&&(A.transcription.contentSummary=_.data.transcriptedText),_?.data?.vttUrl)try{let M=yield this.transcriptionService.getFileContent(_.data.vttUrl).toPromise();M&&(A.transcription.transcriptSegments=this.getVttFileTextToArray(M),A.transcription.vttFileUrl=_.data.vttUrl),A?.assets?.length&&A.assets.forEach(j=>{j.transcription=A.transcription}),A?.assetsAllVersions?.length&&(A.assetsAllVersions[0].transcription=A.transcription),this.recorderActionsService?.onTranscriptionDone(A)}catch(M){this.loggingService.catch("Error fetching VTT content: ",M)}w?.attachments?.length&&this.recordedData&&(this.recordedData.videoUrl=w.attachments[0].url),t==="recording"&&this.recorderActionsService?.onRecordingDone(A)}this.recordedData&&this.recorderService.setRecordedData(this.recordedData)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",a)}})}getDocumentIdAndOrganizationIdFromRecorderAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getDocumentIdAndOrganizationIdFromRecorderAnnotation: ",t),{}}}createRecorderData(e,t=!1){return X(this,null,function*(){try{if(!e)return null;let i=ai(e.metadata||{}),a=Bo(e.from),l={recorderId:e.annotationId||"",from:a,assets:[],metadata:i,assetsAllVersions:[],transcription:{transcriptSegments:[],vttFileUrl:"",contentSummary:""}},c=e;e.latestVersion&&e.recordingEditVersions?.[e.latestVersion]&&(c=e.recordingEditVersions[e.latestVersion]);let d=u=>X(this,null,function*(){let _={transcriptSegments:[],vttFileUrl:"",contentSummary:u?.transcription?.transcriptedText||""};if(t&&u?.transcription?.vttUrl)try{let w=yield this.transcriptionService.getFileContent(u.transcription.vttUrl).toPromise();w&&(_.transcriptSegments=this.getVttFileTextToArray(w),_.vttFileUrl=u.transcription.vttUrl)}catch(w){this.loggingService.catch("Error fetching VTT content: ",w)}return _}),g=yield d(c);if(l.transcription=g,c?.attachments?.length)for(let u of c.attachments)u?.url&&l.assets.push({version:e.latestVersion||1,url:u.url,mimeType:u.mimeType,fileName:u.name,fileSizeInBytes:u.size,fileFormat:u.type,transcription:h({},g),thumbnailUrl:e.attachments?.[0]?.thumbnail});if(e.recordingEditVersions){let u=Object.entries(e.recordingEditVersions).map(M=>X(this,[M],function*([w,A]){let j=parseInt(w),q=yield d(A),ie=A?.attachments?.[0]||A?.attachment;return{version:j,url:ie?.url,mimeType:ie?.mimeType,fileName:ie?.name,fileSizeInBytes:ie?.size,fileFormat:ie?.type,transcription:q,thumbnailUrl:A?.attachments?.[0]?.thumbnail}})),_=yield Promise.all(u);l.assetsAllVersions=_.filter(w=>w.url)}else l.assetsAllVersions=[...l.assets];return l}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService createRecorderData: ",i),null}})}updateRecorder(e,t=!1,i){try{i&&this.setLocationToRecorderAnnotation(e),t&&this.updateNotificationsDatabase(e,rc.UPDATED),this.updateRecorderToDb(e)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateRecorder: ",a)}}resolveRecorder(e){try{this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(e,rc.RESOLVED),this.updateRecorderToDb(e),this.domService.updateSelectedAnnotationInMap([e])}catch(t){this.loggingService.catch("Error in RecorderAnnotationService resolveRecorder: ",t)}}updateRecorderToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateRecorderToDb","color: green;");try{if(e?.targetElement?.xpath){let t=this.domService.getXPath(e.targetElement.xpath);if(t){let i=t.iterateNext();i&&(Xr(i)||(e.targetElement=null))}}if(e.annotationId){let t=this.recorderAnnotationById$.value;this.recorderAnnotationById$.next(y(h({},t),{[e.annotationId]:h({},e)}))}if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(je.RECORDER)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||delete t?.isUrlAvailable,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let l=this.docService.getBaseMetadata("recorder");t.metadata=h(h({},t?.metadata),l)}let{documentId:i,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:i,organizationId:a},data:JSON.parse(JSON.stringify(t)),extraData:{actionType:rc.UPDATED}})}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService updateRecorderToDb: ",t)}}deleteRecorderPinAnnotations(){try{let e=this.domService.getSelectedAnnotationsMap(),t=this.authService.getUser(),i=[];Object.keys(e).forEach(a=>X(this,null,function*(){let l=e[a];l.type==="recorder"&&t&&l.from&&(t?.isAdmin||l.from.userId===t.userId)&&i.push(l)})),i?.length&&(this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETE_TRIGGERED,{annotationId:i.map(a=>a.annotationId).join()}),this.dialog.open(ml,{panelClass:"velt-mat-dialog-container",data:{title:"Delete recording?",message:"This selected recording will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.recorderContainerDarkMode$.value,variant:"recorder"}}).afterClosed().pipe(ut(1)).subscribe(a=>{a&&(i.forEach(l=>X(this,null,function*(){yield this.deleteRecorderPinAnnotation(l)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(c=>{this.domService.removeHighlightFromElement(c)})},100))}),this.domService.resetSelectedAnnotationsMap(!0,"recorder"))}catch(e){this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotations: ",e)}}deleteRecorderPinAnnotation(e,t){if(this.authService.isFeatureAllowed(je.RECORDER)&&this.documentPaths?.recorder&&e?.annotationId){this.updateNotificationsDatabase(e,rc.DELETED);let i=this.attachmentResolverService.attachmentDataProviderAvailable("recorder"),a=this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()?this.recorderUtilsService.mergeStrippedDataWithRecorderAnnotation(h({},e)):e,l=ai(e?.metadata??{});if(a?.attachments?.length)a.attachments.forEach(_=>{let w={organizationId:l?.organizationId??null,documentId:l?.documentId??null,folderId:l?.folderId??null,attachmentId:_.attachmentId,commentAnnotationId:null,apiKey:l?.apiKey??null};this.storageService.deleteAttachment({attachment:_,metadata:w,useAttachmentResolver:i,attachmentScope:"recorder"}).catch(A=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete attachment: ",A)})});else if(a?.attachment){let _={organizationId:l?.organizationId??null,documentId:l?.documentId??null,folderId:l?.folderId??null,attachmentId:a.attachment.attachmentId,commentAnnotationId:null,apiKey:l?.apiKey??null};this.storageService.deleteAttachment({attachment:a.attachment,metadata:_,useAttachmentResolver:i,attachmentScope:"recorder"})}e?.transcription&&!this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()&&(e?.transcription?.srtBucketPath&&this.storageService.deleteFileFromPath(e.transcription.srtBucketPath).catch(_=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete srt file: ",_)}),e?.transcription?.vttBucketPath&&this.storageService.deleteFileFromPath(e.transcription.vttBucketPath).catch(_=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete vtt file: ",_)})),this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderTime:e?.recordedTime?.duration,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e.attachment?.size,sourceFeature:t||"recording"});let{documentId:c,organizationId:d}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e),g={annotationData:e,actionType:rc.DELETED,notificationSource:"recorder"},u={apiKey:this.configService.getApiKey(),organizationId:d,documentId:c,veltFolderId:e?.metadata?.veltFolderId};return this.commonDbService.deleteData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:d,metadata:u},extraData:g}).then(_=>X(this,null,function*(){let w=yield this.createRecorderData(e,!0);w&&this.recorderActionsService?.onDeleteRecording(w)}))}else return Promise.resolve()}enableAddRecorderMode(){this.authService.isFeatureAllowed(je.RECORDER)?this.addRecorderMode$.next(!0):this.loggingService.catch("Error in RecorderAnnotationService enableAddRecorderMode: ","Recorder feature is not enabled.")}disableAddRecorderMode(){this.addRecorderMode$.next(!1)}addRecorderModeChange(){return this.addRecorderMode$.asObservable()}setRecorderContainerDarkMode(e){try{if(this.recorderContainerDarkMode$.value===e)return;this.recorderContainerDarkMode$.next(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderContainerDarkMode: ",t)}}getRecorderContainerDarkMode(){return this.recorderContainerDarkMode$.asObservable()}enableRecordingTranscription(){try{if(this.analyticsService.setFeatureConfig({feature:je.RECORDER,config:{recordingTranscription:!0}}),this.recordingTranscriptionEnabled$.value===!0)return;this.recordingTranscriptionEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderAnnotationService enableRecordingTranscription: ",e)}}disableRecordingTranscription(){try{if(this.analyticsService.setFeatureConfig({feature:je.RECORDER,config:{recordingTranscription:!1}}),this.recordingTranscriptionEnabled$.value===!1)return;this.recordingTranscriptionEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderAnnotationService disableRecordingTranscription: ",e)}}getRecordingTranscriptionEnabled(){return this.recordingTranscriptionEnabled$.value}getRecordingTranscriptionEnabled$(){return this.recordingTranscriptionEnabled$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService isElementInsideAllowedElements: ",t),!1}}attachRecorder(e){let t=document.getElementById(e);if(t){let i=this.domService.getXPath(t),a=this.getRecorderPinAnnotationObject();a&&(a.targetElement={xpath:i,topPercentage:50,leftPercentage:90},this.saveRecorderToDb(a))}}getRecorderPinAnnotationObject(){let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add recorders.");else{let t=new op;t.from=e,t.color=F.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:i,topPositionY:a}=this.domService.getTopLeftPosition();t.positionX=i,t.positionY=a;let l=this.domService.getCurrentWindowSizeValue();t.screenWidth=l.screenWidth,t.screenHeight=l.screenHeight,t.screenScrollHeight=l.screenScrollHeight,t.recorderedElementPath="";let c=this.docService.getLocation();return c&&(t.locationId=c.locationId,t.location=c.location),t}return null}updateNotificationsDatabase(e,t,i={}){try{let a=e;this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()&&(a=JSON.parse(JSON.stringify(e)),a?.from?.userId&&(a.from={userId:a.from.userId}),delete a.transcription,a?.attachments?.length&&(a.attachments=a.attachments.map(c=>({attachmentId:c?.attachmentId,name:c?.name}))),a.attachment=null,a?.chunkUrls&&(a.chunkUrls={}));let l=h({annotationData:a,actionType:t,notificationSource:"recorder",recordingType:e?.recordingType},i);this.notificationService.updateNotificationDatabase(l)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateNotificationsDatabase: ",a)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}getRecorderUrl(e){try{return e?.pageInfo?.recorderUrl?e.pageInfo.recorderUrl:e?.annotationId?(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.recorderUrl=this.generateRecorderUrl(e),this.updateRecorder(e),e.pageInfo?.recorderUrl):""}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getRecorderUrl: ",t);return}}uploadFile(e,t){let i=this.documentPaths?.organizationId,a=this.documentPaths?.documentId;t?.metadata?.documentId&&(a=t.metadata.documentId,i=t.metadata.organizationId);let l=`${F.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;if(i&&(l=`${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${i}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),this.attachmentResolverService.attachmentDataProviderAvailable("recorder")){let c=this.docService.getBaseMetadata("recorder",{commentAnnotationId:t.commentAnnotationId});return this.storageService.uploadFile({path:l,file:e,useAttachmentResolver:!0,metadata:c,attachmentScope:"recorder"})}return this.storageService.uploadFile({path:l,file:e})}uploadFullRecordingAndUpdateAnnotation(e,t){try{if(!t?.annotationId)return;this.uploadFile(e,t).then(i=>{if(!i?.url)return;let l=this.getAnnotationById(t.annotationId)||t;l.attachments?.length&&(l.attachments[0].url=i.url,l.attachments[0].attachmentId=i.attachmentId,i.bucketPath&&(l.attachments[0].bucketPath=i.bucketPath)),l.attachment=l.attachments?.[0]??null,l.lastUpdated=new Date().getTime(),l.isUrlAvailable=!0,this.updateRecorder(l)}).catch(i=>{this.loggingService.catch("Error uploading full recording: ",i)})}catch(i){this.loggingService.catch("Error in RecorderAnnotationService uploadFullRecordingAndUpdateAnnotation: ",i)}}downloadAttachment(e){this.storageService.downloadAttachment(e)}deleteAttachment(e){return this.storageService.deleteAttachment({attachment:e})}generateRecorderUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.RECORDER_ID),t.searchParams.append(F.URL_PARAMS.RECORDER_ID,e.annotationId),t.href}setRecorderNotesFound(e){try{this.recorderNotesFound$.next(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderNotesFound: ",t)}}getRecorderNotesFound$(){try{return this.recorderNotesFound$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),de(!1)}}getRecorderNotesFound(){try{return this.recorderNotesFound$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),!1}}editVideoRecording(e,t,i,a,l,c){return X(this,null,function*(){try{let d=qr(this.functions,Kr({url:Dn?.cloudFunction?.videoBackend,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),g=this.docService.getDocumentPaths();i?.metadata?.documentId&&(g=new xm({apiKey:this.configService.getApiKey(),clientDocumentId:i.metadata.clientDocumentId,clientOrganizationId:i.metadata.clientOrganizationId,documentId:i.metadata.documentId,organizationId:i.metadata.organizationId}));let u={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:g?.recorder+(i?.annotationId||""),fromUser:this.authService.getUser(),clientOrganizationId:g?.clientOrganizationId,clientDocumentId:g?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:g?.recorder,annotationId:i?.annotationId,annotationData:i,videoUrl:e,segments:t,zoomOptions:a,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:l,backendUpload:!0};if(c){let j=yield c.arrayBuffer(),q=new Uint8Array(j),ie="";for(let ae=0;ae<q.length;ae++)ie+=String.fromCharCode(q[ae]);let _e=btoa(ie);u.videoBlobData=_e,u.videoBlobType=c.type,u.videoBlobSize=c.size}if(u?.useFirestore&&i){let j=yield this.recorderUtilsService.encryptRecorderAnnotation(i);u.annotationData=j}let _=this.documentPaths?.organizationId,w=this.documentPaths?.documentId;i?.metadata?.documentId&&(w=i.metadata.documentId,_=i.metadata.organizationId);let A=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${w}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;_&&(A=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${_}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${w}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),u.bucketPath=A;let M=yield d(u);if(l==="standalone"){let j=M?.data;if(j&&j?.videoData){let q=atob(j.videoData),ie=new ArrayBuffer(q.length),_e=new Uint8Array(ie);for(let Ie=0;Ie<q.length;Ie++)_e[Ie]=q.charCodeAt(Ie);let ae=new Blob([_e],{type:j.mimeType||"video/mp4"}),ue=document.createElement("a");ue.href=URL.createObjectURL(ae),ue.download="edited-video.mp4",document.body.appendChild(ue),ue.click(),document.body.removeChild(ue)}}return M}catch(d){throw this.loggingService.catch("Error in RecorderAnnotationService editVideoRecording: ",d),d}})}setVideoEditorAutoOpen(e){try{this.videoEditorAutoOpen$.next(h(h({},this.videoEditorAutoOpen$.value),e))}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setVideoEditorAutoOpen: ",t)}}getVideoEditorAutoOpen$(){try{return this.videoEditorAutoOpen$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),de({})}}getVideoEditorAutoOpen(){try{return this.videoEditorAutoOpen$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),{}}}downloadLatestVideo(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: downloadLatestVideo","color: green;");let t=this.getAnnotationById(e);if(!t)return this.loggingService.catch("Recording not found with ID: "+e),!1;let i,a,l=t.latestVersion;if(l&&t.recordingEditVersions?.[l]?(i=t.recordingEditVersions[l].attachments?.[0]?.url,a=t.recordingEditVersions[l].attachments?.[0]?.name):(i=t.attachments?.[0]?.url||t.attachment?.url,a=t.attachments?.[0]?.name||t.attachment?.name),!i)return this.loggingService.catch("No video URL found for recording: "+e),!1;let c=yield fetch(i);if(!c.ok)return this.loggingService.catch("Failed to fetch video: "+c.statusText),!1;let d=yield c.blob(),g=document.createElement("a");return g.href=URL.createObjectURL(d),g.download=a||`recording-${e}.mp4`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(g.href),this.loggingService.log("Successfully downloaded video: "+a),!0}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService downloadLatestVideo: ",t),!1}})}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Lt),Z(st),Z(Hn),Z(kn),Z(Ke),Z(Ve),Z(no),Z(Vn),Z(Oo),Z(_m),Z(un),Z($p),Z(Vo),Z(k),Z(cn),Z($S),Z(Un),Z(Up),Z(Oa),Z(vl),Z(as))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var IYe=["access","accessFields"];function EYe(n){return n?Object.keys(n).length>0:!1}var Re=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we,Ae,Pe,ze,He,qe,En){this.analyticsService=e,this.areaService=t,this.commonDbService=i,this.configService=a,this.docService=l,this.databaseService=c,this.authService=d,this.domService=g,this.afAuth=u,this.avatarService=_,this.contactService=w,this.storageService=A,this.functions=M,this.dialog=j,this.iamService=q,this.loggingService=ie,this.notificationService=_e,this.customFilterService=ae,this.reactionService=ue,this.hotkeyService=Ie,this.recorderService=fe,this.viewsService=we,this.buttonService=Ae,this.metadataService=Pe,this.commonDbUtilsService=ze,this.attachmentResolverService=He,this.userPermissionService=qe,this.recorderAnnotationService=En,this.customPinsById=new Map,this.commentAdded$=new it,this.commentUpdated$=new it,this.commentAccepted$=new it,this.commentRejected$=new it,this.commentAnnotationDeleted$=new it,this.multiThreadCommentAnnotationDeleted$=new it,this.commentAnnotationById$=new Se(null),this.multiThreadCommentAnnotationById$=new Se(null),this.ghostCommentAnnotationMap$=new Se({}),this.unreadCommentsMap$=new Se(null),this.documentPaths=null,this.user=null,this.customCategoryMap=F.CommentCategoryMap,this.allowedElementIds$=new Se([]),this.allowedElementClassNames$=new Se([]),this.allowedElementQuerySelectors$=new Se([]),this.addCommentMode$=new Se(!1),this.persistentCommentMode$=new Se(!1),this.seenByUsers$=new Se(!0),this.deleteReplyConfirmation$=new Se(!1),this.persistentModeBanner$=new Se(!0),this.commentAddedEmitter=null,this.commentContextProvider=null,this.textCommentMode$=new Se(!0),this.sidebarVisible$=new Se(!1),this.sidebarOpenedByCustomTrigger$=new Se(!1),this.floatingCommentsEnabled$=new Se(!0),this.moderatorMode$=new Se(!1),this.streamMode$=new Se(!1),this.enableSignInButton$=new Se(!1),this.enableUpgradeButton$=new Se(!1),this.onSignInClick$=new it,this.onUpgradeClick$=new it,this.enableAttachment$=new Se(!0),this.enableAttachmentDownload$=new Se(!0),this.enableReactions$=new Se(!0),this.enableAnonymousEmail$=new Se(!0),this.enableFormatOptions$=new Se(!1),this.formatConfig$=new Se({bold:{enable:!0},italic:{enable:!0},underline:{enable:!0},strikethrough:{enable:!0}}),this.allowedRecordings$=new Se(["audio","video","screen"]),this.openSidebar$=new it,this.showScreenSizeInfo$=new Se(!1),this.showCommentIndex$=new Se(!1),this.popoverMode$=new Se(!1),this.popoverTriangleComponent$=new Se(!0),this.draftMode$=new Se(!0),this.enableDialogOnHover$=new Se(!0),this.enableDialogOnTargetElementClick$=new Se(!1),this.enablePriority$=new Se(!1),this.enableStatus$=new Se(!0),this.visibilityOptions$=new Se(!1),this.enableResolve$=new Se(!0),this.enableGhostComments$=new Se(!1),this.enableGhostCommentsMessage$=new Se(!0),this.inboxMode$=new Se(!1),this.enableAutoCategorize$=new Se(!1),this.commentContainerDarkMode$=new Se(!1),this.suggestionMode$=new Se(!1),this.mobileMode$=new Se(!0),this.inlineCommentMode$=new Se(!1),this.minimap$=new Se(!1),this.commentsOnDom$=new Se(!0),this.commentToolEnabled$=new Se(!0),this.totalMediaLength$=new Se(0),this.sidebarUrlNavigationEnabled$=new Se(!1),this.detectionStrategy$=new Se(kF.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Se(!1),this.sidebarButtonOnCommentDialogClick$=new it,this.commentNavigationButtonClick$=new it,this.deviceIndicatorOnCommentPins$=new Se(!1),this.sidebarCommentClick$=new it,this.privateCommentMode$=new Se(!1),this.privateCommentAllowed$=new Se(!1),this.privateModeConfig$=new Se(null),this.scrollToComment$=new Se(!0),this.userMentions$=new Se(!0),this.paginatedContactList$=new Se(!1),this.deleteOnBackspace$=new Se(!0),this.hotkeyEnabled$=new Se(!1),this.recordingSummaryEnabled$=new Se(!0),this.unreadIndicatorMode$=new Se(y0.MINIMAL),this.composerMode$=new Se(AZ.DEFAULT),this.enterKeyToSubmit$=new Se(!1),this.resolvedCommentsOnDom$=new Se(!1),this.bubbleOnPinEnabled$=new Se(!1),this.bubbleOnPinHoverEnabled$=new Se(!0),this.pinDragEnabled$=new Se(!0),this.excludeLocationIdsFromSidebar$=new Se([]),this.multiThread$=new Se(!1),this.groupMatchedComments$=new Se(!1),this.shortUserName$=new Se(!0),this.collapsedComments$=new Se(!1),this.fullExpanded$=new Se(!1),this.queryParamsComments$=new Se(!1),this.resolveStatusAccessAdminOnly$=new Se(!1),this.linkCallback$=new Se(!1),this.svgAsImg$=new Se(!1),this.commentToNearestAllowedElement$=new Se(!1),this.filterCommentsOnDom$=new Se(!1),this.maxReplyAvatars$=new Se(3),this.replyAvatars$=new Se(!1),this.commentplaceholder$=new Se(void 0),this.replyplaceholder$=new Se(void 0),this.editplaceholder$=new Se(void 0),this.editcommentplaceholder$=new Se(void 0),this.editreplyplaceholder$=new Se(void 0),this.screenshotEnabled$=new Se(!1),this.pinShadowDOM$=new Se(!0),this.dialogShadowDOM$=new Se(!0),this.dialogShadowDOMExplicit$=new Se(void 0),this.textCommentToolShadowDOM$=new Se(!0),this.pinDarkMode$=new Se(null),this.textCommentToolDarkMode$=new Se(null),this.textCommentToolbarDarkMode$=new Se(null),this.textCommentToolbarShadowDOM$=new Se(!0),this.sidebarShadowDOM$=new Se(!0),this.changeDetectionInCommentMode$=new Se(!1),this.commentSelectionChange$=new it,this.visibilityOptionClicked$=new it,this.submitComment$=new it,this.clearComposer$=new it,this.composerDataMap=new Map,this.commentsFromSidebarMap$=new Se(null),this.sidebarButtonCountType$=new Se("default"),this.filterGhostCommentsInSidebar$=new Se(!1),this.commentSidebarFilters$=new Se(null),this.effectiveSidebarFilters$=new Se({}),this.customSidebarDataAnnotationIds$=new Se(null),this.commentSidebarSystemFiltersOperator$=new Se(Qc.AND),this.bubbleCommentAnnotationIds$=new Se([]),this.updateCommentDialogPositionTriggerSubject$=new Se(void 0),this.areaCommentEnabled$=new Se(!0),this.commentPinCursorImage$=new Se(""),this.commentAnnotationsFromCommentsContainer$=new Se([]),this.customChipDropdownData$=new Se(null),this.originalCommentAnnotationsByDocumentId$=new Se({}),this.draftCommentAnnotationsByAnnotationId$=new Se(null),this.draftMultiThreadCommentAnnotationsByAnnotationId$=new Se({}),this.pendingAddCommentAnnotationData=new Map,this.copyLink$=new Se(""),this.addCommentDragMode=!1,this.dragSubscriptions=[],this.hotkeySubscriptions=[],this.sidebarData$=new Se(null),this.sidebarCustomActionEventData$=new Se(null),this.sidebarCustomActionEventDataAllChanges$=new Se(null),this.sidebarCustomActionEventDataOnInit$=new Se(null),this.customActions$=new Se(!1),this.focusedThreadMode$=new Se(!1),this.openAnnotationInFocusMode$=new Se(!1),this.customStatusesShown$=new Se(!1),this.readOnly$=new Se(!1),this.customAutocompleteSearch$=new Se(!1),this.deleteThreadWithFirstComment$=new Se(!0),this.assignToType$=new Se("dropdown"),this.pageModeComposerContext$=new Se(null),this.contextInPageModeComposer$=new Se(!1),this.focusPageModeComposer$=new it,this.transformContext$=new Se(null),this.expandMentionGroups$=new Se(!1),this.showMentionGroupsFirst$=new Se(!1),this.showMentionGroupsOnly$=new Se(!1),this.fullScreenInSidebar$=new Se(!1),this.composerFileAttachments$=new Se(null),this.attachmentNameInMessage$=new Se(!1),this.allowedFileTypes$=new Se([]),this.forceCloseAllOnEsc$=new Se(!1),this.autoCompleteScrollConfig$=new Se({itemSize:55,minBufferPx:350,maxBufferPx:600,templateCacheSize:350}),this.commentAnnotationContextDraft=null,this.getCommentAnnotationForClient=tt=>{try{let xt=["commentCategories","color","resolved","inProgress","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","screenScrollTop","taggedElementPath","taggedElementRect","targetElement","position","documentParamsId","documentParams","ghostComment","areaAnnotationId","iam","commentSource","involvedUserIds","mentionedUserIds","viewedByUserIds","views"],Je=JSON.parse(JSON.stringify(tt)),$t={};Object.keys(Je).forEach(Xn=>{xt.includes(Xn)||($t[Xn]=Je[Xn])}),$t?.comments?.forEach(Xn=>{let Ii=[];Xn?.reactionAnnotationIds&&Xn?.reactionAnnotationIds?.forEach(No=>{let eo=this.reactionService.getAnnotationById(No);if(eo){let Bn=this.reactionService.getReactionAnnotationForClient(eo);Ii.push(Bn)}}),Xn.reactionAnnotations=Ii}),Je?.viewedByUserIds?.forEach(Xn=>{let Ii=this.contactService.getUserBySnippylyId(Xn);Ii&&($t.viewedBy||($t.viewedBy=[]),$t.viewedBy.push(Ii))}),this.user?.userSnippylyId&&($t.unread=!Je?.viewedByUserIds?.includes(this.user.userSnippylyId));let sn=Je?.targetElement?.anchor?.fXPath||Je?.targetElement?.fXpath;return sn&&($t.basicAnchorData={xpath:sn,topPercentage:Je?.targetElement?.topPercentage||0,leftPercentage:Je?.targetElement?.leftPercentage||0}),JSON.parse(JSON.stringify($t))}catch{return null}},this.loggingService.log("%c[WB] Creating CLASS: CommentService","color: blue;"),this.analyticsService.setCommentService(this),this.contactService.setCommentService(this),this.notificationService.setCommentService(this),this.docService.setCommentService(this),this.authService.setCommentService(this),this.viewsService.setCommentService(this),this.reactionService.setCommentService(this),this.recorderAnnotationService.setCommentService(this),this.domService.getSelectedAnnotationsMap$().pipe(to(100),Lr()).subscribe(([tt,xt])=>{try{if(this.draftCommentAnnotationsByAnnotationId$.value){let Je=Object.keys(this.draftCommentAnnotationsByAnnotationId$.value||{}),$t=[];Object.keys(tt||{}).forEach(Xn=>{!xt?.[Xn]&&Je.includes(Xn)&&$t.push(Xn)});let sn=JSON.parse(JSON.stringify(this.draftCommentAnnotationsByAnnotationId$.value||{}));$t.forEach(Xn=>{delete sn[Xn]}),dr(sn,this.draftCommentAnnotationsByAnnotationId$.value)||this.draftCommentAnnotationsByAnnotationId$.next(sn)}}catch{}}),this.docService.getDocumentPaths$().pipe(Lr()).subscribe(([tt,xt])=>{tt?.documentId!==xt?.documentId&&this.unreadCommentsMap$.next(null),xt&&this.shouldEnableReadOnly()},tt=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",tt)}),this.draftCommentAnnotationsByAnnotationId$.pipe(Lr()).subscribe(([tt,xt])=>{try{if(this.pendingAddCommentAnnotationData.size===0)return;let Je=Object.keys(tt||{});if(Je.length===0)return;let $t=new Set(Object.keys(xt||{}));Je.forEach(sn=>{!$t.has(sn)&&this.pendingAddCommentAnnotationData.has(sn)&&this.pendingAddCommentAnnotationData.delete(sn)})}catch(Je){this.loggingService.catch("Error in CommentService pendingAddCommentAnnotationData reconcile: ",Je)}}),this.authService.getUser$().subscribe(tt=>{tt||this.resetCacheData()},tt=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",tt)}),this.authService.getUser$().pipe(ye(tt=>tt?mn([this.iamService.isUserAdmin$(),this.contactService.getUserOrganizationContacts$()]).pipe(ge(([xt,Je])=>{let $t=!1;return Je?.find(sn=>sn.userId===tt?.userId)&&($t=!0),{isUserAdmin:xt,isOrgUser:$t}})):de({isUserAdmin:!1,isOrgUser:!1}))).subscribe(({isUserAdmin:tt,isOrgUser:xt})=>{let Je=tt||xt;Je!==this.privateCommentAllowed$.value&&this.privateCommentAllowed$.next(Je)}),this.databaseService.getDb().pipe($e(tt=>!!tt),ut(1)).subscribe(tt=>{tt&&this.getDocumentPaths()},tt=>{this.loggingService.catch("Error in CommentService getDb subscription: ",tt)}),this.domService.onWindowPointerMove$().subscribe(tt=>{if(this.addCommentMode$.value){let xt=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let Je=this.domService.getBackgroundElement(tt.clientX,tt.clientY,!0,!0);if(Je&&gfe(Je,{x:tt.clientX,y:tt.clientY})&&(Je=Je?.parentElement),Je)if(this.isElementInsideAllowedElements(Je))if(Ag(tt.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==Je&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=Je;let $t=this.domService.getSelectedAnnotationsMap("comment")||{},sn=this.commentPinCursorImage$.value||F.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,sn,!!Object.keys($t)?.length),xt=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&xt&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},tt=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",tt)}),this.domService.onWindowKeyupEsc$().subscribe(tt=>{if(this.addCommentMode$.value){let xt=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(xt)?.length&&this.domService.resetSelectedAnnotationsMap(),this.disableAddCommentMode()}},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",tt)}),this.domService.onDocumentClick$().subscribe(tt=>{if(tt&&!WF(tt)){let xt=this.domService.getSelectedAnnotationsMap("comment")||{};if(xt=h(h({},xt),this.domService.getSelectedAnnotationsMap("multiThread")||{}),xt=h(h({},xt),this.domService.getSelectedAnnotationsMap("suggestion")||{}),Object.keys(xt)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),tt.preventDefault(),tt.stopPropagation();return}}if(tt&&this.addCommentMode$.value&&!Ag(tt.target)){let xt=!1;if(this.addCommentDragMode)tt.preventDefault(),tt.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let Je=this.domService.getBackgroundElement(tt.clientX,tt.clientY);if((this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(tt.clientX,tt.clientY)||tt&&WF(tt))&&(Je=null),Je&&(this.isElementInsideAllowedElements(Je)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement(Je))&&(xt=this.isElementInsideManualCommentContainer(Je),!xt)){tt.preventDefault(),tt.stopPropagation();let $t=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(tt,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,$t)}}this.persistentCommentMode$?.value?this.detectToAddAreaComment():xt||this.disableAddCommentMode()}},tt=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",tt)}),this.addCommentMode$.subscribe(tt=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),tt?(this.domService.addClassToElement(document.body,"snippyly-add-comment-mode"),this.detectToAddAreaComment(),this.addIframeContainerStaticAttribute()):(this.removeIframeContainerStaticAttribute(),this.domService.removeClassFromElement(document.body,"snippyly-add-comment-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"),this.dragSubscriptions.forEach(xt=>xt.unsubscribe()),this.clearFreeStyleCommentContext())},tt=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",tt)}),this.domService.onWindowKeyupBackspace$().subscribe(tt=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",tt)}),this.domService.onWindowKeyupDelete$().subscribe(tt=>{this.deleteCommentPinAnnotations("keyupDelete")},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",tt)}),this.domService.getDeleteCommmentAnnotations$().subscribe(tt=>{tt?.length&&(tt?.filter(Je=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes(Je.type))).forEach(Je=>X(this,null,function*(){yield this.deleteCommentPinAnnotation(Je)}))},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",tt)}),this.getPopoverMode$().subscribe(tt=>{tt?document?.body?.setAttribute(F.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(F.ATTRIBUTES.VELT_POPOVER_MODE)},tt=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",tt)}),this.customFilterService.customCategoryMap$.subscribe(tt=>{this.customCategoryMap=tt},tt=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",tt)}),this.hotkeyEnabled$.subscribe(tt=>{tt?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},tt=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",tt)}),this.domService.getSelectedAnnotationsMap$().pipe(Lr()).subscribe(([tt,xt])=>{try{let Je=Object.values(tt||{}).filter(sn=>!["tag","recorder","rewriter","arrow","area"].includes(sn.type)),$t=Object.values(xt||{}).filter(sn=>!["tag","recorder","rewriter","arrow","area"].includes(sn.type));Je?.forEach(sn=>{$t?.find(Xn=>Xn.annotationId===sn.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(sn),selected:!1})}),$t?.forEach(sn=>{Je?.find(Xn=>Xn.annotationId===sn.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(sn),selected:!0})})}catch(Je){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",Je)}},tt=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",tt)})}clearCache(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in CommentService","color: green;"),this.commentAnnotationById$.next(null),this.draftCommentAnnotationsByAnnotationId$.next(null),this.multiThreadCommentAnnotationById$.next({}),this.draftMultiThreadCommentAnnotationsByAnnotationId$.next({}),this.pendingAddCommentAnnotationData.clear(),this.customAutocompleteSearch$.next(!1),this.hightlightElement=null,this.addCommentMode$.next(!1),this.unreadCommentsMap$.next(null),this.documentPaths=null,this.commentsFromSidebarMap$.next(null),this.customSidebarDataAnnotationIds$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearCache: ",e)}}setCommentActionsService(e){try{this.commentActionsService=e}catch(t){this.loggingService.catch("Error in CommentService setCommentActionsService: ",t)}}detectToAddAreaComment(){try{let e=this.areaService.getAreaEnabled(),t=this.getAreaCommentEnabled();if(e&&t){let i,a,l,c=null,d=null;this.dragSubscriptions.forEach(g=>g.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe($e(g=>!(g&&WF(g))),ut(1)).subscribe(g=>{c=null,d=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(u=>{if(c===null){let _=u?.startPoint?.event?.target,w=Po(_),A=Ag(_),M=this.isElementInsideAllowedElements(_);c=!w&&!A&&M}if(c){this.addCommentDragMode=!0,i=u.startPoint,a=u.curPoint;let _=u?.curPoint?.event?.target,w=Po(_),A=Ag(_),M=this.isElementInsideAllowedElements(_);d=!w&&!A&&M,d?l=this.domService.drawRectangle(i,a):l?.remove()}})),this.domService.onWindowPointerUp$().pipe(Rd(1),ut(1)).subscribe(u=>{if(a={x:u.clientX,y:u.clientY},i&&a&&(l?.remove(),c&&d)){let _=[{x:i.x-window.scrollX,y:i.y-window.scrollY},{x:a.x,y:a.y}],w=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(u,void 0,_,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,w)}this.dragSubscriptions.forEach(_=>_.unsubscribe())})}))}}catch(e){this.loggingService.catch("Error in CommentService detectToAddAreaComment: ",e)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling CommentService FUNCTION: resetCacheData","color: green;"),this.commentAnnotationById$.next(null),this.draftCommentAnnotationsByAnnotationId$.next(null),this.multiThreadCommentAnnotationById$.next({}),this.draftMultiThreadCommentAnnotationsByAnnotationId$.next({}),this.pendingAddCommentAnnotationData.clear()}catch(e){this.loggingService.catch("Error in CommentService resetCacheData: ",e)}}addAreaContainerTag(){try{if(!(document.querySelector(F.TAGS.VELT_AREAS)||document.querySelector(F.TAGS.SNIPPYLY_AREAS))){let t=document.createElement(F.TAGS.VELT_AREAS);document.body.appendChild(t)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${F.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(t=>{window.getComputedStyle(t).position==="static"&&t.setAttribute(F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(t=>{t.removeAttribute(F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC)})}catch(e){this.loggingService.catch("Error in CommentService removeIframeContainerStaticAttribute: ",e)}}subscribeHotkeyEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: subscribeHotkeyEvents","color: green;"),this.unsubscribeHotkeyEvents(),this.hotkeySubscriptions.push(this.hotkeyService.getKeyPressEvent("c").subscribe(e=>{e&&!this.addCommentMode$.value&&this.enableAddCommentMode()},e=>{this.loggingService.catch("Error in CommentService hotkeyService.getKeyPressEvent subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CommentService subscribeHotkeyEvents: ",e)}}unsubscribeHotkeyEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribeHotkeyEvents","color: green;"),this.hotkeySubscriptions.forEach(e=>e?.unsubscribe())}catch(e){this.loggingService.catch("Error in CommentService unsubscribeHotkeyEvents: ",e)}}setCommentAddedEmitter(e){try{this.commentAddedEmitter=e}catch(t){this.loggingService.catch("Error in CommentService setCommentAddedEmitter: ",t)}}setContextProvider(e){try{this.commentContextProvider=e}catch(t){this.loggingService.catch("Error in CommentService setContextProvider: ",t)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementIds:e}}),this.allowedElementIds$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementIds: ",t)}}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}setAllowedElementClassNames(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementClassNames:e}}),this.allowedElementClassNames$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementClassNames: ",t)}}getAllowedElementClassNames(){return this.allowedElementClassNames$.asObservable()}setAllowedElementQuerySelectors(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementQuerySelectors:e}}),this.allowedElementQuerySelectors$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementQuerySelectors: ",t)}}getAllowedElementQuerySelectors(){return this.allowedElementQuerySelectors$.asObservable()}getAllCommentAnnotations({customClientDocumentId:e,params:t,excludeDomChanges:i,detectGhostComments:a,skipPositionCalculation:l,query:c,fromCommentSidebar:d,analytics:g,addFilterCommentsOnDomCheck:u}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let _,w,A;g?.enabled&&this.analyticsService.trackEvent(g?.eventName||Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,g?.properties);try{if(e&&(A=`${tr(e)}`),t&&typeof t=="object"){let M=Ai(t);w=M?.id,_=tr(JSON.stringify(M))}}catch(M){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",M)}return _r(this.afAuth).pipe($e(M=>!!M),ye(M=>this.isFeatureAllowed({firebaseUser:M,annotations:[],filteredAnnotations:[]})),ye(M=>M.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(j=>(M.featureAllowed=j,M))):de(M)),ye(M=>M.featureAllowed?de(M).pipe(ye(j=>this.docService.getDocumentPaths$().pipe(ge(q=>(this.documentPaths=q,j.documentPaths=q,j)))),ye(j=>c?.documentIds?.length||A?this.getDataFromDocumentIds({documentIds:A?[A]:c?.documentIds?.map(q=>`${tr(q)}`),organizationId:this.documentPaths?.organizationId,query:c}).pipe(ge(q=>({res:j,data:q}))):this.docService.getDocumentIds$().pipe(ye(q=>{let ie=q?.length>0?q.map(_e=>_e.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ie.length>0?ie:[A??""],organizationId:this.documentPaths?.organizationId,query:c}).pipe(ge(_e=>({res:j,data:_e})))}))),ye(j=>j?.data?(j.res.annotations=j.data||[],de(j.res).pipe(ye(q=>this.docService.getLocation$().pipe(ge(ie=>(q.location=ie,q)))),ye(q=>this.docService.getLocations$().pipe(ge(ie=>(q.customLocations=ie,q)))),ye(q=>this.docService.getExcludedLocationIds$().pipe(ge(ie=>(q.excludedLocationIds=ie,q)))),ge(q=>{if(q.filteredAnnotations=[],c)return q.filteredAnnotations=q.annotations?.slice(),q;if(A&&!_||d)return q.filteredAnnotations=q.annotations?.slice(),q?.excludedLocationIds?.length&&(q.filteredAnnotations=q.filteredAnnotations?.filter(ie=>ie?.location?.id?!q.excludedLocationIds.includes(ie.location.id):!0)),q;{let ie=[],_e=[];return _?(ie.push(_),w&&_e.push(w)):(ie.push(q?.location?.locationId),ie.push(...Object.values(q?.customLocations||[]).map(ae=>ae.locationId)),q?.location?.location?.id&&_e.push(q?.location?.location?.id),_e.push(...Object.values(q?.customLocations||{}).map(ae=>ae.location?.id).filter(ae=>!!ae))),q.filteredAnnotations=this.filterAnnotationsByLocationIds(q?.annotations,ie,_e),q?.excludedLocationIds?.length&&(q.filteredAnnotations=q.filteredAnnotations?.filter(ae=>ae?.location?.id?!q.excludedLocationIds.includes(ae.location.id):!0)),q}}),ye(q=>this.isPrivateCommentAllowed$().pipe(ge(ie=>(ie||(q.filteredAnnotations=q.filteredAnnotations?.filter(_e=>!Pl(_e))),q)))),ye(q=>this.draftCommentAnnotationsByAnnotationId$.pipe(ge(ie=>(q.filteredAnnotations=q.filteredAnnotations?.filter(_e=>!_e.isDraft),ie&&q.filteredAnnotations.push(...Object.values(ie)),q)))),ye(q=>i?de(q):q?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ge(()=>q)):de(q)),ye(q=>i?de(q):this.addCommentMode$.pipe(ye(ie=>ie&&!this.getChangeDetectionInCommentMode()?de(q):q?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(ge(()=>q)):de(q)))),ge(q=>{if(!l){(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(q.filteredAnnotations=q.filteredAnnotations?.map(_e=>{let ae=Object.assign({},_e);return this.calculateCommentAnnotationPosition(ae,a),ae}));let ie={};q.filteredAnnotations?.forEach(_e=>{if(_e?.targetTextRange){let ae=this.domService.getElementFromTargetTextRange(_e?.targetTextRange);ie[_e.annotationId]=!!ae}}),q.textAnnotationsElementMap=ie}return q}),ye(q=>q?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(ge(ie=>(this.updateUnreadAnnotationsMap(q?.annotations,ie),q))):(EYe(this.unreadCommentsMap$.value)&&this.unreadCommentsMap$.next({}),de(q))))):de(null))):de(null)),ge(M=>{try{return typeof M=="object"&&M?JSON.parse(JSON.stringify(M)):M}catch{return M}}),bt((M,j)=>Zt(M?.filteredAnnotations,j?.filteredAnnotations)&&Zt(M?.textAnnotationsElementMap,j?.textAnnotationsElementMap)),ye(M=>M?M?.filteredAnnotations?de(M?.filteredAnnotations||[]):de([]):de(null)),ye(M=>u?this.filterCommentsUsingSidebarSettings(M):de(M)))}getAllMultiThreadCommentAnnotations(e,t,i,a,l,c){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let d,g;try{if(e&&(g=tr(e)),t&&typeof t=="object"){let u=Ai(t);d=tr(JSON.stringify(u))}}catch(u){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",u)}return _r(this.afAuth).pipe($e(u=>!!u),ye(u=>this.isFeatureAllowed({firebaseUser:u,annotations:[],filteredAnnotations:[]})),ye(u=>u.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(_=>(u.featureAllowed=_,u))):de(u)),ye(u=>u.featureAllowed?de(u).pipe(ye(_=>this.docService.getDocumentPaths$().pipe(ge(w=>(this.documentPaths=w,_.documentPaths=w,_)))),ye(_=>g?this.getMultiThreadDataFromDocumentIds([g]).pipe(ge(w=>({res:_,data:w}))):this.docService.getDocumentIds$().pipe(ye(w=>{let A=w?.length>0?w.map(M=>M.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(A.length>0?A:[`${g}`]).pipe(ge(M=>({res:_,data:M})))}))),ye(({res:_,data:w})=>w?(_.annotations=w||[],de(_).pipe(ye(A=>this.docService.getLocation$().pipe(ge(M=>(A.location=M,A)))),ye(A=>this.docService.getLocations$().pipe(ge(M=>(A.customLocations=M,A)))),ye(A=>this.docService.getExcludedLocationIds$().pipe(ge(M=>(A.excludedLocationIds=M,A)))),ge(A=>{if(A.filteredAnnotations=[],g&&!d)return A.filteredAnnotations=A.annotations?.slice(),A?.excludedLocationIds?.length&&(A.filteredAnnotations=A.filteredAnnotations?.filter(M=>M?.location?.id?!A.excludedLocationIds.includes(M.location.id):!0)),A;{let M=[],j=[];return d?M.push(d):(M.push(A?.location?.locationId),M.push(...Object.values(A?.customLocations||[]).map(q=>q.locationId)),A?.location?.location?.id&&j.push(A?.location?.location?.id),j.push(...Object.values(A?.customLocations||{}).map(q=>q.location?.id).filter(q=>!!q))),A.filteredAnnotations=this.filterAnnotationsByLocationIds(A?.annotations,M,j),A?.excludedLocationIds?.length&&(A.filteredAnnotations=A.filteredAnnotations?.filter(q=>q?.location?.id?!A.excludedLocationIds.includes(q.location.id):!0)),A}}),ye(A=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ge(M=>(A.filteredAnnotations=A.filteredAnnotations?.filter(j=>!j.isDraft),M&&A.filteredAnnotations.push(...Object.values(M)),A)))),ye(A=>i?de(A):A?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ge(()=>A)):de(A)),ye(A=>i?de(A):this.addCommentMode$.pipe(ye(M=>M&&!this.getChangeDetectionInCommentMode()?de(A):A?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(ge(()=>A)):de(A)))),ge(A=>(l||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(A.filteredAnnotations=A.filteredAnnotations?.map(M=>{let j=Object.assign({},M);return this.calculateCommentAnnotationPosition(j,a),j})),A)),ye(A=>A?.filteredAnnotations?de(A?.filteredAnnotations||[]):de([])))):de(null))):de(null)),bt(Zt),ye(u=>c?this.filterCommentsUsingSidebarSettings(u):de(u)))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>(this.user=i,y(h({},t),{user:i}))))),ye(t=>Mo(t.config,t.user,je.COMMENT)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}buildVisibilityTokens(e,t,i){try{let a=It(t),l=[F.DEFAULT_VELT_CONTEXT,`${F.VISIBILITY_SELF_PREFIX}${a}`],c=e?.[t];return i&&c?.organization?.[i]?.accessRole&&l.push(`organizationPrivate:${i}`),l}catch(a){return this.loggingService.catch("Error in CommentService buildVisibilityTokens: ",a),[F.DEFAULT_VELT_CONTEXT]}}getDataFromDocuments(e){let{documentIds:t,organizationId:i,query:a}=e;if(!this.configService?.getApiKey())return de(null);if(t?.some(A=>!A)||!this.documentPaths)return de(null);let l,c,d=[];if(a)a?.folderId&&(l=Br(a?.folderId)),a?.locationId&&(d=[...d,a?.locationId]),a?.locationIds?.length&&(d=[...d,...a?.locationIds]),c=a?.statusIds;else{l=this.docService.getDocumentPaths()?.veltFolderId;let A=this.docService.getDocumentPaths()?.locationId;A&&(d=[...d,A])}let g={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(g.documentId=t?.length?t[0]:void 0,g.organizationId=this.documentPaths?.organizationId);let u=this.authService.getUser()?.userId;if(!u)return de(null);let _=this.authService.getIsPrivateCommentsEnabled();return(_?this.userPermissionService.getCurrentUserPermissionsWithServerIds$().pipe($e(A=>A!==null&&!!A[u])):de(null)).pipe(ye(A=>{let M=_?this.buildVisibilityTokens(A,u,i??this.documentPaths?.organizationId):[F.DEFAULT_VELT_CONTEXT],j=this.userPermissionService?.getIsContextEnabled()?this.docService.getProcessedDocContext():[],q=[...M,...j],ie=this.userPermissionService?.getIsContextEnabled(),_e;if(ie){let ae=[];for(let ue=0;ue<q.length;ue+=F.LISTENER_CONTEXT_BATCH_SIZE)ae.push(q.slice(ue,ue+F.LISTENER_CONTEXT_BATCH_SIZE));this.loggingService.logContext("[CONTEXT] getDataFromDocuments called with accessFields:",JSON.parse(JSON.stringify(q??"nil"))),_e=mn(ae.map(ue=>this.commonDbService.dbListener({feature:"allComments",properties:y(h({},g),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",i??this.documentPaths?.organizationId),ft("metadata.documentId","in",t),...c?.length?[ft("status.id","in",c)]:[],...l?[ft("metadata.veltFolderId","==",l)]:[],...d?.length?[ft("location.id","in",d)]:[],...ue?.length?[ft("context.accessFields","array-contains-any",ue)]:[]),po("lastUpdated","desc"),po("createdAt","desc")]})}).pipe(va()))).pipe(ge(ue=>ja(JSON.parse(JSON.stringify(ue)))))}else{let ae=[];for(let ue=0;ue<(t?.length??0);ue+=F.LISTENER_BATCH_SIZE)ae.push(t?.slice(ue,ue+F.LISTENER_BATCH_SIZE)??[]);_e=mn(ae.map(ue=>this.commonDbService.dbListener({feature:"allComments",properties:y(h({},g),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",i??this.documentPaths?.organizationId),ft("metadata.documentId","in",ue),...c?.length?[ft("status.id","in",c)]:[],...l?[ft("metadata.veltFolderId","==",l)]:[],...d?.length?[ft("location.id","in",d)]:[],...q?.length&&_?[ft("context.accessFields","array-contains-any",q)]:[]),po("lastUpdated","desc"),po("createdAt","desc")]})}).pipe(va()))).pipe(ge(ue=>ja(JSON.parse(JSON.stringify(ue)))))}return _e.pipe(ye(ae=>ae?.data?de(ae).pipe(ye(ue=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:ue,feature:"allComments"}).pipe(ge(Ie=>({data:Object.values(Ie?.data||{}).filter(fe=>typeof fe=="object"),operation:Ie?.operation})))),ge(({data:ue,operation:Ie})=>{let fe=ue.reduce((we,Ae)=>{let Pe=Ae.metadata?.documentId;return Pe&&(we[Pe]||(we[Pe]=[]),we[Pe].push(Ae)),we},{});return{data:ue,documentMap:fe,operation:Ie}}),ge(({data:ue,documentMap:Ie,operation:fe})=>c?{data:ue,documentMap:Ie,operation:fe}:(ue?.length&&(ue?.forEach(we=>{this.sanitizeCommentAnnotation(we)}),this.setAnnotationIndex(ue),this.updateAnnotationsForSelectAllContentMode(ue),ue.forEach(we=>{this.customFilterService.convertLegacyAnnotationStatus(we),this.customFilterService.convertLegacyPriority(we),this.customFilterService.convertLegacyCategory(we)})),{data:ue,documentMap:Ie,operation:fe})),Gn(ue=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",ue),de([]))),dn(({documentMap:ue})=>{c||Object.entries(ue??{}).forEach(([Ie,fe])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(fe)))})}),ge(({data:ue,documentMap:Ie,operation:fe})=>({data:this.filterUserDraftComments(ue),documentMap:Ie,operation:fe})),ge(({data:ue,documentMap:Ie,operation:fe})=>({data:this.removeDraftFlags(ue),documentMap:Ie,operation:fe})),ye(({data:ue,documentMap:Ie,operation:fe})=>c?de({data:ue,documentMap:Ie,operation:fe}):this.mergeDraftAnnotations(ue).pipe(ge(we=>({data:we,documentMap:Ie,operation:fe})))),ge(({data:ue,documentMap:Ie,operation:fe})=>{if(!c)if(fe?.type==="removed"){if(fe?.ids?.length){let we=this.commentAnnotationById$.value??{};fe?.ids?.forEach(Ae=>{delete we?.[Ae]}),this.commentAnnotationById$.next(we)}}else Object.entries(Ie??{}).length?Object.entries(Ie??{}).forEach(([Ae,Pe])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:Ae,annotations:Pe})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return ue})):de(null)))}))}fetchCommentAnnotations(e){return X(this,null,function*(){try{let t=this.authService.getUser();if(!t)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),{data:[],hasMore:!1};let i=this.configService?.getApiKey(),a=e?.organizationId??t?.clientOrganizationId,l=ka(a??""),c=[];e?.allDocuments||(c=e?.documentIds?.map(M=>pi(M??""))??this.docService.getDocumentIds()?.map(M=>M.documentId));let d=[];if(d.push(ft("metadata.organizationId","==",l)),d.push(ft("metadata.apiKey","==",i)),e?.folderId){let M=Br(e?.folderId);d.push(ft("metadata.veltFolderId","==",M))}if(e?.locationId&&d.push(ft("location.id","==",e?.locationId)),c?.length&&d.push(ft("metadata.documentId","in",c)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");d.push(ft("resolvedByUserId","==",e?.resolvedBy))}if(e?.mentionedUserIds?.length){if(e?.order==="asc")throw new Error("Order by mentionedUserIds is not supported in ascending order.");d.push(ft("mentionedUserIds","array-contains-any",e?.mentionedUserIds))}if(e?.userIds?.length){if(e?.order==="asc")throw new Error("Order by userIds is not supported in ascending order.");d.push(ft("from.userId","in",e?.userIds))}if(e?.statusIds?.length){if(e?.order==="asc")throw new Error("Order by status id is not supported in ascending order.");d.push(ft("status.id","in",e?.statusIds))}let g=new Date().getTime();if(e?.createdAfter&&d.push(ft("createdAt",">=",e?.createdAfter)),e?.createdBefore&&d.push(ft("createdAt","<=",e?.createdBefore??g)),e?.updatedAfter&&d.push(ft("lastUpdated",">=",e?.updatedAfter??g)),e?.updatedBefore&&d.push(ft("lastUpdated","<=",e?.updatedBefore??g)),d.push(po("lastUpdated",e?.order??"desc"),po("createdAt",e?.order??"desc")),e?.pageToken){let M=yield LZ(e?.pageToken??"","veltencrypttoken","veltencrypttoken");d.push(Xbe(parseInt(M,10),"lastUpdated"))}let u=e?.pageSize??100;d.push(bm(u+1));let _=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:d,apiKey:i??"",organizationId:l}}),w=_.length>u;_=_.slice(0,u);let A=_?.reduce((M,j)=>(M[j?.annotationId]=j,M),{});return A=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:A,shouldAwait:!0}),A=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:A}),{data:Object.values(A??{}),hasMore:w}}catch(t){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",t),t}})}filterUserDraftComments(e){let t=this.authService.getUser();return e.filter(i=>(i.comments=i?.comments?.filter(a=>a?.from?.userId===t?.userId||!a?.isDraft),!!i?.comments?.length))}removeDraftFlags(e){return e.forEach(t=>delete t.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(ge(t=>{let i=t||{};return e?.filter(a=>{i?.[a?.annotationId]&&delete i[a?.annotationId]}),i}),ge(t=>{if(t){let i=e.slice();return i.push(...Object.values(t)),i}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:t,query:i}){return this.getDataFromDocuments({documentIds:e,organizationId:t,query:i})}getMultiThreadDataFromDocumentIds(e){return this.getMultiThreadDataFromDocuments({documentIds:e})}getMultiThreadDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t}=e;if(t?.some(c=>!c)||!this.documentPaths)return de(null);let i=this.docService.getDocumentPaths()?.veltFolderId,a=de([]),l={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(l.documentId=t?.length?t[0]:void 0,l.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let c=[F.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],d=[];for(let g=0;g<(c?.length??0);g+=F.LISTENER_CONTEXT_BATCH_SIZE)d.push(c?.slice(g,g+F.LISTENER_CONTEXT_BATCH_SIZE)??[]);a=mn(d.map(g=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:y(h({},l),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",this.documentPaths?.organizationId),ft("metadata.documentId","in",t),...i?[ft("metadata.veltFolderId","==",i)]:[],...g?.length?[ft("context.accessFields","array-contains-any",g)]:[])]})}).pipe(va()))).pipe(ge(g=>ja(g)))}else{let c=[];for(let d=0;d<(t?.length??0);d+=F.LISTENER_BATCH_SIZE)c.push(t?.slice(d,d+F.LISTENER_BATCH_SIZE)??[]);a=mn(c.map(d=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:y(h({},l),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",this.documentPaths?.organizationId),ft("metadata.documentId","in",d),...i?[ft("metadata.veltFolderId","==",i)]:[])]})}).pipe(va()))).pipe(ge(d=>ja(d)))}return a.pipe(ye(c=>c?.data?de(c).pipe(ge(d=>({data:d?.data,operation:d?.operation})),ge(({data:d,operation:g})=>{let u=[];return d&&(u=Object.values(d??{}).filter(_=>typeof _=="object")),{data:u,operation:g}}),Gn(d=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",d),de({data:[],operation:null}))),ge(({data:d,operation:g})=>{d.forEach(_=>{delete _.isDraft});let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});return{data:d,documentMap:u,operation:g}}),ye(({data:d,documentMap:g,operation:u})=>{let _=[];return this.commentAnnotationById$.pipe(ye(()=>this.domService.getSelectedAnnotationsMap$().pipe(ge(w=>({selectedAnnotationsMap:w})))),ge(({selectedAnnotationsMap:w})=>{let A={};return Object.keys(g??{}).forEach(M=>{let j=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:M});j&&j?.forEach(q=>{A[q?.annotationId]=q})}),_=d.filter(M=>{let j=!1;if(M?.commentAnnotations){for(let q in M?.commentAnnotations)if(A?.[q]&&A?.[q]?.status?.id!==this.customFilterService.resolvedStatus.id){j=!0;break}}return j}),_.forEach(M=>{Object.keys(M?.commentAnnotations||{}).forEach(j=>{M.commentAnnotationsMap||(M.commentAnnotationsMap={}),M.commentAnnotationsMap[j]=A?.[j]})}),{data:_,operation:u}}))}),ye(({data:d,operation:g})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ge(u=>{let _=u||{};return d?.filter(w=>{_?.[w?.annotationId]&&delete _[w?.annotationId]}),_}),ge(u=>{if(u){let _=d.slice();return _.push(...Object.values(u)),{data:_,operation:g}}return{data:d,operation:g}}))),ge(({data:d,operation:g})=>{let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});if(g?.type==="removed"){if(g?.ids?.length){let _=this.multiThreadCommentAnnotationById$.value;g?.ids?.forEach(w=>{delete _?.[w]}),this.multiThreadCommentAnnotationById$.next(_)}}else Object.keys(u??{}).forEach(_=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,annotations:u[_]})});return d})):de(null)))}else return de(null)}updateUnreadAnnotationsMap(e,t){try{let i=new Date(F.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(l=>l?.lastUpdated>i);if(t){let l={},c=!1;a.forEach(d=>{let g=0,u=t?.[d?.annotationId];if(u){let _=u?.comments;_&&d?.comments?.forEach(w=>{_?.[w?.commentId]?.views?.[this.user?.userSnippylyId]||g++})}g?g!==l?.[d?.annotationId]&&(l[d?.annotationId]=g,c=!0):l?.[d?.annotationId]&&(delete l[d?.annotationId],c=!0)}),this.unreadCommentsMap$.next(l)}}catch(i){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",i)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(t=>{if(t?.selectAllContent&&t?.targetElementId){let i=ll(t.targetElementId,["id","data-id"]);if(i){let a=i.textContent;a&&(t.targetTextRange={commonAncestorContainer:this.domService.getXPath(i),text:a,occurrence:1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(i)??void 0},delete t?.targetElement)}}})}catch(t){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",t)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i?.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.commentAnnotationById$.value??{}),l);this.commentAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ge(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",i),de([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i=null;this.commentAnnotationById$.value&&(i={},Object.values(this.commentAnnotationById$.value).forEach(l=>{l?.metadata?.documentId==t&&l?.metadata?.organizationId==e&&(i[l?.annotationId]=l)}));let a=this.draftCommentAnnotationsByAnnotationId$.value;return a&&(i===null&&(i={}),Object.values(a).forEach(l=>{l?.metadata?.documentId===t&&l?.metadata?.organizationId===e&&!i[l?.annotationId]&&(i[l?.annotationId]=l)})),i?Object.values(i):null}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId:",i),[]}}getCommentAnnotationsByDocumentId$({clientDocumentId:e,documentId:t}){try{return e&&!t&&(t=this.docService.generateDocumentId(e)),t?this.docService.getDocumentPaths$().pipe(ye(i=>this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:i?.organizationId,documentId:t}))):de(null)}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByDocumentId$:",i),de(null)}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(ye(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):de([])))}getCommentAnnotationsOnCurrentOrganizationAndDocument(){try{let e=this.docService.getDocumentPaths();return e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e?.organizationId,documentId:e?.documentId}):[]}catch(e){return this.loggingService.catch("Error in CommentService getCommentAnnotationsOnCurrentOrganizationAndDocument:",e),[]}}setOriginalCommentAnnotationsByAnnotationId(e){try{let t={};e?.forEach(i=>{i?.annotationId&&(t[i?.annotationId]=i)}),this.originalCommentAnnotationsByDocumentId$.next(h(h({},this.originalCommentAnnotationsByDocumentId$.value),t))}catch(t){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",t)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.multiThreadCommentAnnotationById$.value),l);this.multiThreadCommentAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){return this.multiThreadCommentAnnotationById$.pipe(ge(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(l=>{l?.metadata?.documentId==t&&l?.metadata?.organizationId==e&&(i[l?.annotationId]=l)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(l=>{l?.metadata?.documentId===t&&l?.metadata?.organizationId===e&&!i[l?.annotationId]&&(i[l?.annotationId]=l)}),Object.values(i)}catch(i){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",i),[]}}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(ye(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):de([])))}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument(){try{let e=this.docService.getDocumentPaths();return this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e?.organizationId,documentId:e?.documentId})}catch(e){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument:",e),[]}}getLocations$(){return this.docService.getLocation$().pipe(ye(e=>this.docService.getLocations$().pipe(ge(t=>({location:e,locations:t})))),ge(e=>{let t=[];return t.push(e?.location?.locationId),t.push(...Object.values(e.locations||[]).map(i=>i.locationId)),t||[]}))}filterAnnotationsByLocationIds(e,t,i){try{return e.filter(a=>t.includes(a.locationId)||i?.includes(a?.location?.id)||t?.find(l=>l==a?.location?.id)||i?.find(l=>l==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in CommentService filterAnnotationsByLocations:",a),[]}}setAnnotationIndex(e){try{e.forEach((t,i)=>{t?.annotationId&&(t.annotationIndex=i+1)})}catch(t){this.loggingService.catch("Error in CommentService setAnnotationIndex:",t)}}calculateCommentAnnotationPosition(e,t){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let i=ll(e.targetElementId,["id","data-id"]);if(i&&this.domService.isElementVisible(i)){let a=i.getAttribute(F.ATTRIBUTES.VELT_COMMENT_TYPE),l=!0;if(a)a==="popover"?l=!0:l=!1;else{let c=document.querySelector(`${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);c&&i?.contains(c)&&(l=!1)}l?e.targetElement={xpath:this.domService.getXPath(i),fXpath:this.domService.getXPath(i,!0),cfXpath:this.domService.getXPath(i,!0,!0),topPercentage:e.targetElement?.topPercentage||50,leftPercentage:e.targetElement?.leftPercentage||90}:e.targetElement=null}else e.targetElement=null}if(e.targetElement){e.position=null,e.ghostComment=null;let i=e.targetElement?.xpath,a=null,l=e?.targetElement?.anchor;if(l){let d=this.domService.resolveAnchorRecord(l);d?.element&&this.domService.isElementVisible(d.element)&&Xr(d.element)&&(a=d.element)}else i&&(a=this.domService.getElementFromXPath(i),this.domService.isXpathWithId(i)||((!a||!this.domService.isElementVisible(a))&&e.targetElement?.cfXpath&&(i=e.targetElement?.cfXpath,a=this.domService.getElementFromXPath(i)),this.getDetectionStrategy()===kF.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(i=e.targetElement?.fXpath,i&&(a=this.domService.getElementFromXPath(i)))));(!a||!this.domService.isElementVisible(a))&&t&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=this.getGhostCommentTargetElement(e),e?.ghostComment?.targetElement?.xpath&&(a=this.domService.getElementFromXPath(e?.ghostComment?.targetElement?.xpath)));let c=!1;if(e?.locationId){let d=this.docService.getLocation();if(!E0({location:d?.location,locationId:d?.locationId},{location:e?.location,locationId:e?.locationId})){let g=this.docService.getAdditionLocationFromElement(a),u=g?this.docService.genarateLocationId(g):void 0;e?.location?.id&&e?.location?.id===g?.id||u&&u===e?.locationId?c=!1:c=!0}}if(c&&(e.ghostComment=null),!c&&a&&Xr(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let g=this.popoverMode$?.value?0:e.targetElement?.topPercentage,u=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:_,width:w}=vp(a);e.position={top:_*(g||0)/100,left:w*(u||0)/100};let A=window.getComputedStyle(a).transform;if(A&&A!=="none")try{let M=new DOMMatrixReadOnly(A),j=Math.sqrt(M.a*M.a+M.b*M.b)||1,q=Math.sqrt(M.c*M.c+M.d*M.d)||1;(Math.abs(j-1)>.01||Math.abs(q-1)>.01)&&(e.position.parentScaleX=j,e.position.parentScaleY=q)}catch{}if(this.transformContext$.value){let{containerSelector:M,transforms:j}=this.transformContext$.value,q=document.querySelector(M);q&&q.contains(a)&&(e.position.transformContext=j)}}!c&&t&&!e?.position&&!e?.ghostComment&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=e.targetElement)}t&&(e.ghostComment?this.addAnnotationToGhostCommentAnnotationMap(e):this.removeAnnotationFromGhostCommentAnnotationMap(e))}catch(i){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",i)}}addComment(ze,He,qe,En,tt){return X(this,arguments,function*(e,t,i,a,l,c=[],d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we,Ae,Pe){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let xt=this.authService.getUser();if(xt)if(xt.isReadOnly||xt.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{yield this.triggerAddCommentAnnotationDraftEvent();let Je=new Vr;_e&&(Je=h(h({},Je),_e)),Je.comments=[],_e?.comments?.length&&(Je.comments=_e.comments.map(ln=>{let Sn=new oc;return Sn=h(h({},Sn),ln),Sn.from=xt,Sn.lastUpdated=new Date,Sn.createdAt=this.timestamp,Sn})),Je.from=xt,Je.color=Je?.color||F.DEFAULT_ANNOTATION_COLOR,Je.lastUpdated=this.timestamp,Je.createdAt=this.timestamp,Je.sourceId=q,Je.assignedTo=_e?.assignedTo||ie,Je.customList=_e?.customList||[],we&&(Je.targetElementId=we);let{topPositionX:$t,topPositionY:sn}=this.domService.getTopLeftPosition();Je.positionX=$t,Je.positionY=sn;let Xn=this.domService.getCurrentWindowSizeValue();if(Je.screenWidth=Xn.screenWidth,Je.screenHeight=Xn.screenHeight,Je.screenScrollHeight=Xn.screenScrollHeight,Je.taggedElementPath="",e&&(Je.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,ln=>{if(this.getSvgAsImg()){let Sn=ln?.closest(`[${F.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);Sn&&Sn instanceof HTMLElement&&(ln=Sn)}if(this.getPopoverMode()){let Sn=ln?.closest(`[${F.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(Sn&&Sn instanceof HTMLElement)return Sn}return ln}),this.getCommentToNearestAllowedElement()&&Je.targetElement?.xpath)){let ln=this.domService.getElementFromXPath(Je.targetElement.xpath);if(ln&&!this.isElementInsideAllowedElements(ln)){let Sn=this.getNearestAllowedElement(ln);if(Sn)Je.targetElement.xpath=this.domService.getXPath(Sn),Je.targetElement.fXpath=this.domService.getXPath(Sn,!0),Je.targetElement.cfXpath=this.domService.getXPath(Sn,!0,!0),Je.targetElement.anchor=this.domService.generateAnchorRecord(Sn);else return}}if(t&&(Je.targetTextRange=t),Je?.targetElement?.xpath){let ln=this.domService.getXPath(Je.targetElement.xpath);if(ln){let Sn=ln.iterateNext();Sn&&(Xr(Sn)||(Je.targetElement=null))}}this.customFilterService.defaultStatus&&!_e?.status&&(Je.status=this.customFilterService.defaultStatus),Je.pageInfo=io(),Je.pageInfo&&(Je.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let Ii=this.docService.getClientDocumentId(),No=this.docService.getLocation()?.location;if(ue&&(Je.context=ue&&Ns(ue),Je.contextId=this.generateContextId(Je.context)),this.commentContextProvider!==null){let ln=this.commentContextProvider(Ii,No),Sn=ln instanceof Promise?yield ln:ln;Sn&&(Je.context=Sn&&Ns(Sn),Je.contextId=this.generateContextId(Je.context),Sn?.commentType==="manual"&&(Je.commentType="manual",delete Je.targetElement))}if(a){Je.sourceId=a?.sourceId;let ln=a?.targetElement,Sn=a?.commentData;if(ln?.targetText)Je.targetTextRange={commonAncestorContainer:"/html/body",text:ln.targetText,occurrence:ln?.occurrence||1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(document.body)??void 0};else if(ln?.elementId)if(Je.targetElementId=ln.elementId,ln?.selectAllContent)Je.selectAllContent=!!ln?.selectAllContent;else{let Co=ll(ln.elementId,["id","data-id"]);Co?Je.targetElement={xpath:this.domService.getXPath(Co),fXpath:this.domService.getXPath(Co,!0),cfXpath:this.domService.getXPath(Co,!0,!0),anchor:this.domService.generateAnchorRecord(Co),topPercentage:50,leftPercentage:90}:Je.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",anchor:this.domService.generateAnchorRecord(document.body),topPercentage:50,leftPercentage:90}}a?.status&&(Je.status=a.status),a?.context&&(Je.context=a.context?Ns(a.context):a.context,Je.contextId=this.generateContextId(Je.context)),Je.comments||(Je.comments=[]);let Ir=this.authService.getUser();Sn?.forEach(Co=>{let Zi=new oc;Zi.commentText=Co.commentText,Zi.commentHtml=Co.commentHtml,Zi.replaceContentHtml=Co.replaceContentHtml,Zi.replaceContentText=Co.replaceContentText,Zi.from=Ir,Je.comments.push(Zi)})}if(l&&(Je.isPageAnnotation=!0),c?.length&&(Je.comments=c),d&&(Je.commentType="chart",Je.metadata=d),u?.sourceId&&(Je.sourceId=u.sourceId),Je?.targetElement?.xpath&&!u){let ln=this.domService.getElementFromXPath(Je.targetElement.xpath);ln&&(u=this.getInlineCommentSectionConfig(ln))}u?.targetInlineCommentElementId&&(Je.targetInlineCommentElementId=u?.targetInlineCommentElementId,Je.targetElementId=u.targetInlineCommentElementId,u?.config?.id&&(Je.inlineCommentSectionConfig=u?.config));let eo=!Je?.comments?.length,Bn=!!(a?.openComment===!1||Ie);this.getPrivateCommentMode()&&(Je?.iam||(Je.iam=new gO),Je.iam.accessMode=ya.PRIVATE),_&&(Je.context=_.context?Ns(_.context):_.context,Je.commentType="manual",delete Je.targetElement,Je.contextId=this.generateContextId(Je.context)),w&&(Je.targetElementId=w.targetElementId,Je.targetElement=w.targetElement);let fc=this.getPrivateModeConfig();if(fc)try{let ln=h({},fc);if(ln.type==="restricted"){let Ir=this.authService.getUser();Ir?.userId&&(ln=ap(ln,Ir.userId))}if(ln.type==="organizationPrivate"&&!ln.organizationId){let Ir=this.docService.getOrganizationConfig();Ir?.clientOrganizationId&&(ln.organizationId=Ir.clientOrganizationId)}let Sn=lp(ln);Je.context||(Je.context={}),Je.context._setAccessFields=Sn,Je.visibilityConfig=h(h({type:ln.type},ln.organizationId&&{organizationId:ln.organizationId}),ln.userIds&&{userIds:ln.userIds})}catch(ln){this.loggingService.catch("Error building accessFields from privateModeConfig: ",ln)}this.saveCommentToDb(Je,i,eo,Bn,g,A,M,ae,j,fe,Ae,Pe)}}catch(xt){this.loggingService.catch("Error in CommentService addComment: ",xt)}})}triggerAddCommentAnnotationDraftEvent(){return X(this,null,function*(){try{this.commentAnnotationContextDraft=null;let e={addContext:i=>{this.commentAnnotationContextDraft=i}},t=yield this.commentActionsService?.getAddCommentAnnotationDraftEventFromCommentAddEventData(e);t&&this.commentActionsService?.triggerAddCommentAnnotationDraftEvent(t)}catch(e){this.loggingService.catch("Error in CommentService triggerAddCommentAnnotationDraftEvent: ",e)}})}triggerAddCommentDraftEventOnAbandon(e,t){return X(this,null,function*(){try{if(!e||!t)return;let i=this.getAnnotationById(e),a=!!i?.comments?.some(l=>l&&!l.isDraft);i&&a&&(yield this.commentActionsService?.triggerAddCommentDraftEventForAnnotation(i,t))}catch(i){this.loggingService.catch("Error in CommentService triggerAddCommentDraftEventOnAbandon: ",i)}})}willDeleteWholeAnnotation(e,t){try{if(!e?.comments?.length)return!1;let i=e.comments.findIndex(a=>a?.commentId===t);return i<0?!1:i===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments.length===1}catch(i){return this.loggingService.catch("Error in CommentService willDeleteWholeAnnotation: ",i),!1}}confirmDeleteCommentIfRequired(e,t){return X(this,null,function*(){try{if(!e?.comments?.length||!t)return!0;let i=e.comments.findIndex(d=>d?.commentId===t?.commentId);if(i<0||!(i===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value))return!0;let l;return this.deleteReplyConfirmation$.value&&(i!==0||this.deleteThreadWithFirstComment$.value===!1)?l={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply",type:"reply"}:l={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"},!!(yield this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:l}).afterClosed().toPromise())}catch(i){return this.loggingService.catch("Error in CommentService confirmDeleteCommentIfRequired: ",i),!1}})}setLocationToCommentAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{let i;e.targetElement?i=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?i=ll(e.targetElementId,["id","data-id"]):e.targetTextRange&&(i=this.domService.getElementFromTargetTextRange(e.targetTextRange));let a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}catch{}}catch(t){this.loggingService.catch("Error in CommentService setLocationToCommentAnnotation:",t)}}getElementForCommentAnnotation(e){try{let t;return e.targetElement?t=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?t=ll(e.targetElementId,["id","data-id"]):e.targetTextRange&&(t=this.domService.getElementFromTargetTextRange(e.targetTextRange)),t}catch(t){return this.loggingService.catch("Error in CommentService getElementForCommentAnnotation: ",t),null}}saveCommentToDb(e,t,i=!1,a=!1,l,c,d,g,u,_,w,A){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(je.COMMENT)&&this.docService.getDocumentPaths$().pipe($e(M=>!!M),ut(1),ye(M=>(this.documentPaths=M,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(j=>!!j),ut(1),ye(j=>X(this,null,function*(){if(this.documentPaths?.comment){e.annotationId=this.commonDbService.generateDocumentId();let q=this.docService.getClientDocumentId(),ie=this.docService.getLocation()?.location;if(d)e.multiThreadAnnotationId=d;else if(this.getMultiThread()){let Pe=sm();e.targetElementId&&(Pe=sm(e.targetElementId),e?.location?.id?Pe=sm([e?.location?.id,e.targetElementId]):e?.locationId&&(Pe=sm([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=Pe}let _e={addContext:Pe=>{Pe.access&&(Pe.accessFields=xO(Pe)),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:Pe}),e.context=Pe&&Ns(Pe),e.contextId=this.generateContextId(e.context),Pe?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&setTimeout(()=>{this.updateCommentAnnotationContext(e.annotationId,Pe)},200)},documentId:q,location:ie,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?_e.elementRef={xpath:e.targetElement.xpath}:_e.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(_e),this.commentAdded$.next(_e),u&&u(_e),_e?.annotation?.annotationId&&this.pendingAddCommentAnnotationData.set(_e.annotation.annotationId,_e),this.setLocationToCommentAnnotation(e);let ae=this.getElementForCommentAnnotation(e),ue=this.docService.getBaseMetadata("comment",{element:ae,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!ue?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=h(h({},e.metadata),ue),_&&(e.metadata=h(h({},e.metadata),_)),l&&typeof l=="object"&&(e.locationId=g||this.docService.genarateLocationId(l),e.location=l,A||this.docService.addLocation({location:l})),i)window.localStorage.setItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let Pe=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);Pe&&JSON.parse(Pe).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let Ie=e.comments,fe=JSON.parse(JSON.stringify(e));if(this.commentAnnotationContextDraft){let Pe=this.commentAnnotationContextDraft;this.commentAnnotationContextDraft=null,Pe.access&&(Pe.accessFields=xO(Pe)),fe.context=Pe&&Ns(Pe)}if(!this.handleDirectAccessFieldsAssignment(fe?.context)&&!fe?.context?.access&&(fe?.context||(fe.context={}),fe.context.access={default:"velt"},fe.context.accessFields=[...fe.context.accessFields||[],F.DEFAULT_VELT_CONTEXT]),fe.visibilityConfig||(fe.visibilityConfig={type:"public"}),fe.position=null,t){fe.targetElement=null,fe.targetTextRange=null;let Pe={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?je.MULTI_THREAD:je.COMMENT},ze=yield this.areaService.generateAreaAnnotationId();fe.areaAnnotationId=ze;let He=this.areaService.addArea(void 0,t,Pe,ze,{locationId:fe.locationId,location:fe.location},fe.context);He&&(fe.metadata=h(h({},fe.metadata),He?.metadata||{}))}!a&&!fe?.targetInlineCommentElementId&&!fe?.isPageAnnotation&&this.domService.toggleAnnotationSelection(fe,c),e.targetTextRange&&sessionStorage.setItem(F.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),fe?.comments?.length?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e.annotationId,commentThreadId:fe?.comments[0]?.commentId,commentThreadIndex:0,commentType:this.getCommentType(fe),commentMode:this.getCommentMode(),source:w??"internal",commentAnnotationCreatedAt:e.createdAt,taggedClientUserIds:fe?.comments[0]?.taggedUserContacts?.map(Pe=>Pe.contact?.userId).filter(Pe=>!!Pe),taggedSnippylyUserIds:fe?.comments[0]?.taggedUserContacts?.filter(Pe=>!!fe?.metadata?.apiKey&&!!Pe.contact?.userId).map(Pe=>hd(fe.metadata.apiKey,Pe.contact.userId))}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(fe),commentMode:this.getCommentMode()});let Ae=this.getAnnotationNumber(e);Ae&&(fe.annotationNumber=Ae),fe?.comments?.length?fe.comments=[]:fe.isDraft=!0,fe?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(fe),fe?.context&&(fe.contextId=this.generateContextId(fe.context),fe.context?.commentType==="manual"&&(fe.commentType="manual",delete fe.targetElement)),Ie?.length?this.saveComment(fe,{type:Tt.NEWLY_ADDED,updatedComment:Ie[0]}):this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:fe}))}})))))).subscribe(()=>{},M=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",M)})}catch(M){this.loggingService.catch("Error in CommentService saveCommentToDb: ",M)}}saveMultiThreadCommentAnnotation(e){return X(this,null,function*(){try{if(e?.multiThreadAnnotationId){let t=this.docService.getDocumentPaths();if(this.databaseService.getDbValue()&&t?.multiThread){let i={annotationId:e.multiThreadAnnotationId,targetElement:e.targetElement,targetElementId:e.targetElementId,targetInlineCommentElementId:e.targetInlineCommentElementId,inlineCommentSectionConfig:e.inlineCommentSectionConfig,areaAnnotationId:e.areaAnnotationId,targetTextRange:e.targetTextRange,from:e.from,locationId:e.locationId,location:e.location,sourceId:e.sourceId,type:"multiThread",metadata:e.metadata,context:e.context};delete e?.targetElement,delete e?.areaAnnotationId,delete e?.targetTextRange;let a=this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:t?.documentId})?.find(l=>l.annotationId===e.multiThreadAnnotationId);if(a||(a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:e.multiThreadAnnotationId}})),a&&(a=JSON.parse(JSON.stringify(a)),delete a.from,i=h(h({},a),i)),i?.commentAnnotations||(i.commentAnnotations={}),i.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(y(h({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[i.annotationId]:y(h({},i),{isDraft:!0})}));else{let c=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[i.annotationId];if(c&&(i=h(h({},i),c)),delete i.isDraft,i.commentAnnotationsMap={},!i?.metadata?.documentId){i?.metadata||(i.metadata={});let u=this.docService.getBaseMetadata("multiThread");i.metadata=h(h({},i?.metadata),u)}let{documentId:d,organizationId:g}=i?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:i.annotationId,documentId:d,organizationId:g},data:JSON.parse(JSON.stringify(i)),callback:()=>{let u=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;u[e.annotationId]&&(delete u[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(u))}})}return i}}return null}catch(t){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",t),null}})}setCommentCategory(e){return X(this,null,function*(){try{if(e?.comments?.length){let t=e.comments[0].commentText?.trim();if(t){let i=yield this.getCommentCategory(t).toPromise();if(i){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let l=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(c=>c.annotationId===e.annotationId);if(l||(l=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:e.annotationId}})),l?.annotationId){let c=l;c.commentCategories=[i];let{documentId:d,organizationId:g}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:d,organizationId:g,metadata:{apiKey:this.configService.getApiKey(),organizationId:g,veltFolderId:c?.metadata?.veltFolderId,documentId:d}},data:JSON.parse(JSON.stringify(c))})}}}}}}catch(t){this.loggingService.catch("Error in CommentService setCommentCategory: ",t)}})}getCommentCategory(e){try{let t=qr(this.functions,Kr({url:Dn.cloudFunction.chatgptCompletion,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a=[{role:"system",content:`Identify category of this sentence from these categories, ${Object.keys(this.customCategoryMap)?.join(", ")}:`},{role:"user",content:e}];return so(t({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(ge(l=>{if(l?.data){let c=l.data,d=c?.length?c[0]?.content?.trim():void 0;return d&&Object.keys(this.customCategoryMap).includes(d)?this.customCategoryMap[d]:void 0}else return}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentCategory: ",t),de(void 0)}}handleDirectAccessFieldsAssignment(e){try{if(!e||typeof e!="object")return!1;if("_setAccessFields"in e||"_replaceAccessFields"in e){let t=e._setAccessFields??e._replaceAccessFields;return delete e.access,delete e.accessFields,Array.isArray(t)&&t.length>0?e.accessFields=t:t==null&&delete e.accessFields,delete e._setAccessFields,delete e._replaceAccessFields,!0}return!1}catch(t){return this.loggingService.catch("Error in CommentService handleDirectAccessFieldsAssignment: ",t),!1}}updateCommentAnnotationContext(e,t,i){return X(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:t,merge:i?.merge});let a=this.authService.getUser(),l=this.docService.getDocumentPaths();if(a&&l?.comment&&e){let c=this.getAnnotationById(e);if(typeof c=="object"&&(c=JSON.parse(JSON.stringify(c))),c||(c=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:e}})),c?.annotationId){let d=t,g=JSON.parse(JSON.stringify(c.context||{}));i?.merge&&(d=h(h({},g),t));let u=this.handleDirectAccessFieldsAssignment(d);if(d&&"_setVisibilityConfig"in d&&(c.visibilityConfig=d._setVisibilityConfig,delete d._setVisibilityConfig),d&&typeof d=="object"&&!u)if("access"in t)t.access!==null&&t.access!==void 0?d.accessFields=xO(d):(delete d.access,delete d.accessFields);else{if(!i?.merge)for(let A of IYe)!(A in t)&&g?.[A]!==void 0&&(d[A]=g[A]);d.access!==null&&d.access!==void 0&&(d.accessFields=xO(d))}let _={context:JSON.parse(JSON.stringify(d||{}))},w=!1;if(_?.context?.commentType==="manual"&&(_.commentType="manual",_.targetElement=null,c?.targetElement&&(c.targetElement=null,w=!0)),c.context=_.context?Ns(_.context):_.context,c.contextId=this.generateContextId(c.context),dr(g,d)&&!w)return Promise.resolve("Comment annotation context is already updated.");if(c?.comments?.length){c.lastUpdated=this.timestamp;let{documentId:A,organizationId:M}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);return this.commonDbService.setData({feature:"comment",properties:{id:e,documentId:A,organizationId:M,metadata:{apiKey:this.configService.getApiKey(),organizationId:M,veltFolderId:c?.metadata?.veltFolderId,documentId:A}},data:JSON.parse(JSON.stringify(c)),callback:()=>{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:_?.context,merge:i?.merge})}})}else return this.draftCommentAnnotationsByAnnotationId$.value?.[e]?(this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e]:c})),Promise.resolve("Draft comment annotation context updated.")):(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:t,merge:i?.merge,error:"Draft comment annotation not found."}),Promise.resolve("Draft comment annotation not found."))}else return this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:t,merge:i?.merge,error:"Comment annotation not found in database."}),Promise.resolve("Comment annotation not found in database.")}}catch(a){return this.loggingService.catch("Error in CommentService updateCommentAnnotationContext: ",a),Promise.resolve("Error in CommentService updateCommentAnnotationContext.")}})}updateComment(e,t,i,a,l,c){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(je.COMMENT)){if(t&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let d=this.domService.getXPath(e.targetElement.xpath);if(d){let g=d.iterateNext();g&&(Xr(g)||(e.targetElement=null))}}if(e?.type==="multiThread"){let d=JSON.parse(JSON.stringify(e));if(d.position=null,d.ghostComment=null,d?.context&&this.handleDirectAccessFieldsAssignment(d.context),!d?.metadata?.documentId){d?.metadata||(d.metadata={});let _=this.docService.getBaseMetadata("multiThread");d.metadata=h(h({},d?.metadata),_)}let{documentId:g,organizationId:u}=d?.metadata||{};i?this.commonDbService.updateData({feature:"multiThread",properties:{id:d.annotationId,documentId:g,organizationId:u},data:JSON.parse(JSON.stringify(d))}):this.commonDbService.setData({feature:"multiThread",properties:{id:d.annotationId,documentId:g,organizationId:u},data:JSON.parse(JSON.stringify(d))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let d=JSON.parse(JSON.stringify(e));if(d.position=null,d.ghostComment=null,d.lastUpdated=this.timestamp,d.status||(d.status=this.customFilterService.defaultStatus),delete d.resolved,delete d.inProgress,this.setLocationFromDocumentParams(d),d?.context&&this.handleDirectAccessFieldsAssignment(d.context),d?.annotationId?.startsWith("TEMP_COMPOSER_"))return;let g=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(g&&JSON.parse(g).annotationId===d.annotationId&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),d?.multiThreadAnnotationId&&!l&&this.saveMultiThreadCommentAnnotation(d).then(u=>{}),d?.comments?.length){if(delete d?.isDraft,d?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[d?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(d),!d?.metadata?.documentId){d?.metadata||(d.metadata={});let A=this.docService.getBaseMetadata("comment");d.metadata=h(h({},d?.metadata),A)}let{documentId:u,organizationId:_}=d?.metadata||{},w=a?h({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;this.viewsService.updateCommentAnnotationViews(d),this.commonDbService.setData({feature:"comment",properties:{id:d.annotationId,documentId:u,targetCommentId:c?.commentId,organizationId:_,metadata:{apiKey:this.configService.getApiKey(),organizationId:_,veltFolderId:d?.metadata?.veltFolderId,documentId:u}},extraData:w,data:JSON.parse(JSON.stringify(d)),callback:A=>X(this,null,function*(){if(a&&!A?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{}),this.getScreenshotEnabled()&&a?.actionType===Tt.NEWLY_ADDED&&this.captureScreenshot(e),a?.actionType===Tt.NEWLY_ADDED||a?.actionType===Tt.ADDED)try{let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:d.annotationId,commentAnnotation:this.getCommentAnnotationForClient(d),metadata:M};this.commentActionsService?.triggerAction(er.COMMENT_SAVED,j)}catch(M){this.loggingService.catch("Error triggering commentSaved event: ",M)}})})}else this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:d}))}}}catch(d){this.loggingService.catch("Error in CommentService updateComment: ",d)}}captureScreenshot(e){return X(this,null,function*(){try{if(this.getScreenshotEnabled()){let i=qr(this.functions,Kr({url:Dn.cloudFunction.screenshot,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a,l={source:"velt",sourceData:{commentAnnotation:e},eventType:"screenshot"};e?.areaAnnotationId&&(a=this.areaService.getAnnotationById(e?.areaAnnotationId),a&&(l.sourceData||(l.sourceData={}),l.sourceData.areaAnnotation=a));let c=yield Fs(l,this.authService.getUser()?.userId??"");yield i({veltData:c})}}catch(t){this.loggingService.catch("Error in CommentService captureScreenshot: ",t)}})}getDocumentIdAndOrganizationIdFromCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromCommentAnnotation: ",t),{}}}getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation: ",t),{}}}setLocationFromDocumentParams(e){e?.documentParams&&(e.location=e.documentParams,delete e.documentParams),e?.documentParamsId&&(e.locationId=e.documentParamsId,delete e.documentParamsId)}deleteCommentPinAnnotations(e){return new Promise((t,i)=>X(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),l=this.authService.getUser(),c=[];Object.keys(a).forEach(d=>{let g=a[d];["tag","recorder","rewriter","arrow","area","multiThread"].includes(g.type)||l&&g.from&&(l?.isAdmin||g.from.userId===l.userId)&&c.push(g)}),c?.length?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:c.map(d=>d.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:{title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"}}).afterClosed().pipe(ut(1)).subscribe(d=>{try{d?(c.forEach(g=>X(this,null,function*(){yield this.deleteCommentPinAnnotation(g)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(u=>{this.domService.removeHighlightFromElement(u)}),t()},100)):t()}catch(g){i(g)}},d=>{i(d)})):t(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),i(a)}}))}deleteCommentPinAnnotation(e,t){return X(this,null,function*(){try{if(setTimeout(()=>{if(this.draftCommentAnnotationsByAnnotationId$?.value?.[e.annotationId]){let i=this.draftCommentAnnotationsByAnnotationId$.value;delete i[e.annotationId],this.draftCommentAnnotationsByAnnotationId$.next(i)}},50),e?.annotationId&&this.pendingAddCommentAnnotationData.delete(e.annotationId),this.authService.isFeatureAllowed(je.COMMENT))if((t||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Tt.DELETED),e.comments?.forEach(i=>{i.reactionAnnotationIds&&i.reactionAnnotationIds.forEach(a=>{this.deleteReaction(a)})}),e?.annotationId){this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode()});let i=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);i&&JSON.parse(i).annotationId===e.annotationId&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),this.areaService.onDeleteTargetAnnotation(e?.annotationId,e?.areaAnnotationId);let a={type:"delete",annotation:null,targetAnnotationId:e.annotationId};this.commentUpdated$.next(a),e?.multiThreadAnnotationId&&(yield this.removeCommentAnnotationFromMultiThread(e)),this.commentAnnotationDeleted$.next(e);let{documentId:l,organizationId:c}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);if(e?.isDraft)return Promise.resolve();{let d={annotationData:e,targetAnnotationData:null,actionType:Tt.DELETED,notificationSource:"comment",isAnnotationDelete:!0};return this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:l,organizationId:c,metadata:{apiKey:this.configService.getApiKey(),organizationId:c,veltFolderId:e?.metadata?.veltFolderId,documentId:l}},extraData:d})}}else return Promise.resolve();return Promise.resolve()}catch(i){return this.loggingService.catch("Error in CommentService deleteCommentPinAnnotation: ",i),Promise.resolve()}})}removeCommentAnnotationFromMultiThread(e){return X(this,null,function*(){try{let t=e?.multiThreadAnnotationId;if(t){let i=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(t);if(!a){let g=e?.metadata?.documentId||i?.documentId,u=e?.metadata?.organizationId||i?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:g,organizationId:u,id:t}})}let l=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t];a&&delete a?.commentAnnotations?.[e.annotationId],l&&(delete l?.commentAnnotations?.[e.annotationId],Object.keys(l?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:c,organizationId:d}=this.getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(a);return Object.keys(a?.commentAnnotations||{}).length===0?(this.areaService.onDeleteTargetAnnotation(a?.annotationId,a?.areaAnnotationId),this.multiThreadCommentAnnotationDeleted$.next(a),this.commonDbService.deleteData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:d}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:d},data:JSON.parse(JSON.stringify(a))})}}catch(t){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",t)}})}getAnnotationById(e,t){try{let i=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in CommentService getAnnotationById: ",i);return}}getBaseMetadataFromCommentAnnotationId(e){try{let t=this.commentAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in CommentService getBaseMetadataFromCommentAnnotationId: ",t)}}getMultiThreadAnnotationById(e,t){try{let i=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in CommentService getAnnotationById: ",i);return}}getBaseMetadataFromMultiThreadCommentAnnotationId(e){try{let t=this.multiThreadCommentAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in CommentService getBaseMetadataFromMultiThreadCommentAnnotationId: ",t)}}getElementRefByAnnotationId(e){try{let t=this.getAnnotationById(e);if(t){let i=t?.targetElement?.xpath;if(i)return{xpath:i}}return}catch(t){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",t);return}}scrollToCommentByAnnotationId(e){try{let t=this.getAnnotationById(e),i=document.getElementById(`comment-pin-container-${e}`);i||(i=document.querySelector(`[data-velt-id='${e}']`)),i||(i=document.querySelector(`${F.TAGS.VELT_COMMENT_TEXT}[${F.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),i&&(i.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),t&&(this.domService.getSelectedAnnotationsMap()[e]||this.domService.toggleAnnotationSelection(t)))}catch(t){this.loggingService.catch("Error in CommentService scrollToCommentByAnnotationId: ",t)}}selectCommentByAnnotationId(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");let i=e?this.getAnnotationById(e):void 0;i?this.domService.toggleAnnotationSelection(i,void 0,void 0,!0):this.domService.resetSelectedAnnotationsMap()}catch(i){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",i)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(je.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([Xo.ADMIN,Xo.COMMENTER])?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_MODE_ENABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!0)):this.loggingService.catch("Error in CommentService enableAddCommentMode: ","User is not allowed to add comment."):this.loggingService.catch("Error in CommentService enableAddCommentMode: ","Comment feature is not enabled.")}catch(e){this.loggingService.catch("Error in CommentService enableAddCommentMode: ",e)}}disableAddCommentMode(){this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!1)}addCommentModeChange(){return this.addCommentMode$.asObservable()}setFreeStyleCommentContext(e){try{this.freeStyleCommentContext=e}catch(t){this.loggingService.catch("Error in CommentService setFreeStyleCommentContext: ",t)}}clearFreeStyleCommentContext(){try{this.freeStyleCommentContext=void 0}catch(e){this.loggingService.catch("Error in CommentService resetFreeStyleCommentContext: ",e)}}enablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteReplyConfirmation:!0}}),this.deleteReplyConfirmation$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteReplyConfirmation: ",e)}}enableSeenByUsers(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{seenByUsers:!0}}),this.seenByUsers$.value===!0)return;this.seenByUsers$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSeenByUsers: ",e)}}disableSeenByUsers(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{seenByUsers:!1}}),this.seenByUsers$.value===!1)return;this.seenByUsers$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSeenByUsers: ",e)}}getSeenByUsers$(){return this.seenByUsers$.asObservable()}disableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{persistentCommentMode:!1}}),this.persistentCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePersistentCommentMode: ",e)}}persistentCommentModeChange(){return this.persistentCommentMode$.asObservable()}enablePersistentModeBanner(){this.persistentModeBanner$.next(!0)}disablePersistentModeBanner(){this.persistentModeBanner$.next(!1)}persistentModeBannerChange(){return this.persistentModeBanner$.asObservable()}setAssignToType(e){try{this.assignToType$.next(e.type)}catch(t){this.loggingService.catch("Error in CommentService setAssignToType: ",t)}}getAssignToType$(){return this.assignToType$.asObservable()}getAssignToType(){return this.assignToType$.value}setPageModeComposerContext(e){try{this.pageModeComposerContext$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setPageModeComposerContext: ",t)}}clearPageModeComposerContext(){try{this.pageModeComposerContext$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearPageModeComposerContext: ",e)}}getPageModeComposerContext$(){return this.pageModeComposerContext$.asObservable()}getPageModeComposerContext(){return this.pageModeComposerContext$.value}enableContextInPageModeComposer(){try{this.contextInPageModeComposer$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableContextInPageModeComposer: ",e)}}disableContextInPageModeComposer(){try{this.contextInPageModeComposer$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableContextInPageModeComposer: ",e)}}getContextInPageModeComposer$(){return this.contextInPageModeComposer$.asObservable()}getContextInPageModeComposer(){return this.contextInPageModeComposer$.value}focusPageModeComposer(){try{this.focusPageModeComposer$.next()}catch(e){this.loggingService.catch("Error in CommentService focusPageModeComposer: ",e)}}getFocusPageModeComposer$(){return this.focusPageModeComposer$.asObservable()}showCommentIndex(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentIndex:e}}),this.showCommentIndex$.value===e)return;this.showCommentIndex$.next(e)}catch(t){this.loggingService.catch("Error in CommentService showCommentIndex: ",t)}}getShowCommentIndex(){return this.showCommentIndex$.asObservable()}enablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverMode:!0}}),this.popoverMode$.value===!0)return;this.popoverMode$.next(!0),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_POPOVER_MODE_ENABLED,{commentMode:this.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentService enablePopoverMode: ",e)}}disablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverMode:!1}}),this.popoverMode$.value===!1)return;this.popoverMode$.next(!1),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_POPOVER_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentService disablePopoverMode: ",e)}}getPopoverMode(){try{return this.popoverMode$.value}catch(e){return this.loggingService.catch("Error in CommentService getPopoverMode: ",e),!1}}getPopoverMode$(){return this.popoverMode$.asObservable()}enablePopoverTriangleComponent(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverTriangleComponent:!0}}),this.popoverTriangleComponent$.value===!0)return;this.popoverTriangleComponent$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePopoverTriangleComponent: ",e)}}disablePopoverTriangleComponent(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverTriangleComponent:!1}}),this.popoverTriangleComponent$.value===!1)return;this.popoverTriangleComponent$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePopoverTriangleComponent: ",e)}}getPopoverTriangleComponent(){try{return this.popoverTriangleComponent$.value}catch(e){return this.loggingService.catch("Error in CommentService getPopoverTriangleComponent: ",e),!1}}getPopoverTriangleComponent$(){return this.popoverTriangleComponent$.asObservable()}enableDraftMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{draftMode:!0}}),this.draftMode$.value===!0)return;this.draftMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDraftMode: ",e)}}disableDraftMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{draftMode:!1}}),this.draftMode$.value===!1)return;this.draftMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDraftMode: ",e)}}getDraftMode$(){return this.draftMode$.asObservable()}getDraftMode(){return this.draftMode$.value}enableTextComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textMode:!0}}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_TEXT_MODE_ENABLED,{commentMode:this.getCommentMode()}),this.textCommentMode$.value===!0)return;this.textCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextComments: ",e)}}disableTextComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textMode:!1}}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_TEXT_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.textCommentMode$.value===!1)return;this.textCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextComments: ",e)}}getTextCommentMode$(){return this.textCommentMode$.asObservable()}isUserGlobalContact$(){return this.contactService.isUserGlobalContact$()}isSidebarOpenedByCustomTrigger(){try{return this.sidebarOpenedByCustomTrigger$.value}catch(e){return this.loggingService.catch("Error in CommentService isSidebarOpenedByCustomTrigger: ",e),!1}}setSidebarVisibility(e,t=!1,i=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR_V2)||document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(F.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> or <${F.TAGS.VELT_COMMENTS_SIDEBAR_V2}> tag is not added.`),t&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||t||i)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1),this.clearPageModeComposerContext()),e?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_OPENED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_CLOSED,{commentMode:this.getCommentMode()})}catch{this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}toggleSidebarVisibility(e=!1,t=!1){try{this.domService.resetSelectedAnnotationsMap(),this.sidebarVisible$.value?(!this.sidebarOpenedByCustomTrigger$.value||e||t)&&(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarOpenedByCustomTrigger$.next(!1),this.sidebarVisible$.value||this.clearPageModeComposerContext()):(document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR_V2)||document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(F.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarVisible$.value?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"closed"}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"opened"})):this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> or <${F.TAGS.VELT_COMMENTS_SIDEBAR_V2}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{floatingCommentDialog:!e}}),this.floatingCommentsEnabled$.value===!e)return;this.floatingCommentsEnabled$.next(!e)}catch(t){this.loggingService.catch("Error in CommentService disableFloatingComments: ",t)}}showFloatingComments$(){return this.floatingCommentsEnabled$.asObservable()}showFloatingComments(){return this.floatingCommentsEnabled$.value}setModeratorMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{moderatorMode:e}}),this.moderatorMode$.value===e)return;this.moderatorMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setModeratorMode: ",t)}}getModeratorMode(){return this.moderatorMode$.value}getModeratorMode$(){return this.moderatorMode$.asObservable()}setStreamMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{streamMode:e}}),this.streamMode$.value===e)return;this.streamMode$.next(e),e?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STREAM_MODE_ENABLED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STREAM_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(t){this.loggingService.catch("Error in CommentService setStreamMode: ",t)}}getStreamMode(){return this.streamMode$.value}getStreamMode$(){return this.streamMode$.asObservable()}getEnableDialogOnHover(){return this.enableDialogOnHover$.value}getEnableDialogOnHover$(){return this.enableDialogOnHover$.asObservable()}setEnableDialogOnHover(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogOnHover:e}}),this.enableDialogOnHover$.value===e)return;this.enableDialogOnHover$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableDialogOnHover: ",t)}}getEnableDialogOnTargetElementClick(){return this.enableDialogOnTargetElementClick$.value}getEnableDialogOnTargetElementClick$(){return this.enableDialogOnTargetElementClick$.asObservable()}setEnableDialogOnTargetElementClick(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogOnTargetElementClick:e}}),this.enableDialogOnTargetElementClick$.value===e)return;this.enableDialogOnTargetElementClick$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableDialogOnTargetElementClick: ",t)}}getEnablePriority(){return this.enablePriority$.value}getEnablePriority$(){return this.enablePriority$.asObservable()}setEnablePriority(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{priority:e}}),this.enablePriority$.value===e)return;this.enablePriority$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnablePriority: ",t)}}getEnableStatus(){return this.enableStatus$.value}getEnableStatus$(){return this.enableStatus$.asObservable()}setEnableStatus(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableStatus: ",t)}}getEnableVisibilityOptions(){return this.visibilityOptions$.value}getEnableVisibilityOptions$(){return this.visibilityOptions$.asObservable()}setEnableVisibilityOptions(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{visibilityOptions:e}}),this.visibilityOptions$.value===e)return;this.visibilityOptions$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableVisibilityOptions: ",t)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveButton:e}}),this.getEnableResolve()===e)return;this.enableResolve$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableResolve: ",t)}}getEnableGhostComments(){return this.enableGhostComments$.value}getEnableGhostComments$(){return this.enableGhostComments$.asObservable()}enableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostComments:!1}}),this.enableGhostComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableGhostComments: ",e)}}getEnableGhostCommentsMessage(){return this.enableGhostCommentsMessage$.value}getEnableGhostCommentsMessage$(){return this.enableGhostCommentsMessage$.asObservable()}enableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostCommentsIndicator:!1}}),this.enableGhostCommentsMessage$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowGhostCommentsMessage: ",e)}}enableInboxMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inboxMode:!0}}),this.inboxMode$.value===!0)return;this.inboxMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableInboxMode: ",e)}}disableInboxMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inboxMode:!1}}),this.inboxMode$.value===!1)return;this.inboxMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableInboxMode: ",e)}}getInboxMode(){return this.inboxMode$.value}getInboxMode$(){return this.inboxMode$.asObservable()}setEnableAutoCategorize(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{autoCategorize:e}}),this.enableAutoCategorize$.value===e)return;this.enableAutoCategorize$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableAutoCategorize: ",t)}}getEnableAutoCategorize(){return this.enableAutoCategorize$.value}getEnableAutoCategorize$(){return this.enableAutoCategorize$.asObservable()}setCommentContainerDarkMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{darkMode:e}}),this.commentContainerDarkMode$.value===e)return;this.commentContainerDarkMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentContainerDarkMode: ",t)}}getCommentContainerDarkMode(){return this.commentContainerDarkMode$.asObservable()}getSuggestionMode(){return this.suggestionMode$.value}getSuggestionMode$(){return this.suggestionMode$.asObservable()}setSuggestionMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{suggestionMode:e}}),this.getSuggestionMode()===e)return;this.suggestionMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setSuggestionMode: ",t)}}getMobileMode(){return this.mobileMode$.value}getMobileMode$(){return this.mobileMode$.asObservable()}setMobileMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{mobileMode:e}}),this.getMobileMode()===e)return;this.mobileMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setMobileMode: ",t)}}enableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inlineCommentMode:!0}}),this.inlineCommentMode$.value===!0)return;this.inlineCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableInlineCommentMode: ",e)}}disableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inlineCommentMode:!1}}),this.inlineCommentMode$.value===!1)return;this.inlineCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableInlineCommentMode: ",e)}}getInlineCommentMode(){return this.inlineCommentMode$.value}getInlineCommentMode$(){return this.inlineCommentMode$.asObservable()}enableMinimap(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{minimap:!0}}),this.minimap$.value===!0)return;this.minimap$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMinimap: ",e)}}disableMinimap(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{minimap:!1}}),this.minimap$.value===!1)return;this.minimap$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableMinimap: ",e)}}getMinimap(){return this.minimap$.value}getMinimap$(){return this.minimap$.asObservable()}showCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentsOnDom:!0}}),this.commentsOnDom$.value===!0)return;this.commentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService showCommentsOnDom: ",e)}}hideCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentsOnDom:!1}}),this.commentsOnDom$.value===!1)return;this.commentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService hideCommentsOnDom: ",e)}}getCommentsOnDom(){return this.commentsOnDom$.value}getCommentsOnDom$(){return this.commentsOnDom$.asObservable()}enableCommentTool(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentTool:!0}}),this.commentToolEnabled$.value===!0)return;this.commentToolEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCommentTool: ",e)}}disableCommentTool(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentTool:!1}}),this.commentToolEnabled$.value===!1)return;this.commentToolEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCommentTool: ",e)}}getCommentTool(){return this.commentToolEnabled$.value}getCommentTool$(){return this.commentToolEnabled$.asObservable()}setTotalMediaLength(e){try{if(this.totalMediaLength$.value===e)return;this.totalMediaLength$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setTotalMediaLength: ",t)}}getTotalMediaLength(){return this.totalMediaLength$.value}getTotalMediaLength$(){return this.totalMediaLength$.asObservable()}enableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarUrlNavigation:!0}}),this.sidebarUrlNavigationEnabled$.value===!0)return;this.sidebarUrlNavigationEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarUrlNavigation: ",e)}}disableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarUrlNavigation:!1}}),this.sidebarUrlNavigationEnabled$.value===!1)return;this.sidebarUrlNavigationEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarUrlNavigation: ",e)}}getSidebarUrlNavigation(){return this.sidebarUrlNavigationEnabled$.value}getSidebarUrlNavigation$(){return this.sidebarUrlNavigationEnabled$.asObservable()}setDetectionStrategy(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{detectionStrategy:e}}),this.detectionStrategy$.value===e)return;this.detectionStrategy$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setDetectionStrategy: ",t)}}getDetectionStrategy(){return this.detectionStrategy$.value}getDetectionStrategy$(){return this.detectionStrategy$.asObservable()}enableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonOnCommentDialog:!0}}),this.sidebarButtonOnCommentDialogVisible$.value===!0)return;this.sidebarButtonOnCommentDialogVisible$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarButtonOnCommentDialog: ",e)}}disableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonOnCommentDialog:!1}}),this.sidebarButtonOnCommentDialogVisible$.value===!1)return;this.sidebarButtonOnCommentDialogVisible$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarButtonOnCommentDialog: ",e)}}getSidebarButtonOnCommentDialogVisibility(){return this.sidebarButtonOnCommentDialogVisible$.value}getSidebarButtonOnCommentDialogVisibility$(){return this.sidebarButtonOnCommentDialogVisible$.asObservable()}onSidebarButtonOnCommentDialogClick(){this.sidebarButtonOnCommentDialogClick$.next()}getSidebarButtonOnCommentDialogClick$(){return this.sidebarButtonOnCommentDialogClick$.asObservable()}enableDeviceIndicatorOnCommentPins(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceIndicatorOnCommentPins:!0}}),this.deviceIndicatorOnCommentPins$.value===!0)return;this.deviceIndicatorOnCommentPins$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeviceIndicatorOnCommentPins: ",e)}}disableDeviceIndicatorOnCommentPins(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceIndicatorOnCommentPins:!1}}),this.deviceIndicatorOnCommentPins$.value===!1)return;this.deviceIndicatorOnCommentPins$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeviceIndicatorOnCommentPins: ",e)}}getDeviceIndicatorOnCommentPins(){return this.deviceIndicatorOnCommentPins$.value}getDeviceIndicatorOnCommentPins$(){return this.deviceIndicatorOnCommentPins$.asObservable()}onSidebarCommentClick(e){this.sidebarCommentClick$.next(e)}getSidebarCommentClick$(){return this.sidebarCommentClick$.asObservable()}onCommentNavigationButtonClick(e){this.commentNavigationButtonClick$.next(e)}getCommentNavigationButtonClick$(){return this.commentNavigationButtonClick$.asObservable()}addBubbleCommentAnnotationIds(e){try{let i=[...this.bubbleCommentAnnotationIds$.value||[],...e],a=[...new Set(i)];this.bubbleCommentAnnotationIds$.next(a)}catch(t){this.loggingService.catch("Error in CommentService addBubbleCommentAnnotationIds: ",t)}}getBubbleCommentAnnotationIds(){return this.bubbleCommentAnnotationIds$.value}getBubbleCommentAnnotationIds$(){return this.bubbleCommentAnnotationIds$.asObservable()}removeBubbleCommentAnnotationIds(e){try{let i=(this.bubbleCommentAnnotationIds$.value||[]).filter(a=>!e.includes(a));this.bubbleCommentAnnotationIds$.next(i)}catch(t){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",t)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{signInButton:e}}),this.enableSignInButton$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableSignInButton: ",t)}}getSignInButton(){return this.enableSignInButton$.value}getSignInButton$(){return this.enableSignInButton$.asObservable()}onSignInClick(){this.onSignInClick$.next()}getSignInButtonClick$(){return this.onSignInClick$.asObservable()}enableUpgradeButton(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{upgradeButton:e}}),this.enableUpgradeButton$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableUpgradeButton: ",t)}}getUpgradeButton(){return this.enableUpgradeButton$.value}getUpgradeButton$(){return this.enableUpgradeButton$.asObservable()}onUpgradeClick(){this.onUpgradeClick$.next()}getUpgradeButtonClick$(){return this.onUpgradeClick$.asObservable()}openSidebar(){this.openSidebar$.next()}getOpenSidebar$(){return this.openSidebar$.asObservable()}enableAttachment(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachments:e}}),this.enableAttachment$.value===e)return;this.enableAttachment$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableAttachment: ",t)}}getEnableAttachment$(){return this.enableAttachment$.asObservable()}enableAttachmentDownload(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentDownload:!0}}),this.enableAttachmentDownload$.value===!0)return;this.enableAttachmentDownload$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAttachmentDownload: ",e)}}disableAttachmentDownload(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentDownload:!1}}),this.enableAttachmentDownload$.value===!1)return;this.enableAttachmentDownload$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAttachmentDownload: ",e)}}getEnableAttachmentDownload$(){return this.enableAttachmentDownload$.asObservable()}getEnableAttachmentDownload(){return this.enableAttachmentDownload$.value}enableFormatOptions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatOptions:!0}}),this.enableFormatOptions$.value===!0)return;this.enableFormatOptions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFormatOptions: ",e)}}disableFormatOptions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatOptions:!1}}),this.enableFormatOptions$.value===!1)return;this.enableFormatOptions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFormatOptions: ",e)}}getEnableFormatOptions$(){return this.enableFormatOptions$.asObservable()}setFormatConfig(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatConfig:e}}),this.formatConfig$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setFormatConfig: ",t)}}getFormatConfig$(){return this.formatConfig$.asObservable()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordings:e}}),e?.includes("all")?this.allowedRecordings$.next(["audio","video","screen"]):e?.includes("none")?this.allowedRecordings$.next([]):this.allowedRecordings$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setAllowedRecordings: ",t)}}getAllowedRecordings(){return this.allowedRecordings$.value}getAllowedRecordings$(){return this.allowedRecordings$.asObservable()}enableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{reactions:!0}}),this.enableReactions$.value===!0)return;this.enableReactions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReactions: ",e)}}disableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{reactions:!1}}),this.enableReactions$.value===!1)return;this.enableReactions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReactions: ",e)}}getEnableReactions(){return this.enableReactions$.value}getEnableReactions$(){return this.enableReactions$.asObservable()}enableAnonymousEmail(){try{if(this.enableAnonymousEmail$.value===!0)return;this.enableAnonymousEmail$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAnonymousEmail: ",e)}}disableAnonymousEmail(){try{if(this.enableAnonymousEmail$.value===!1)return;this.enableAnonymousEmail$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAnonymousEmail: ",e)}}getEnableAnonymousEmail(){return this.enableAnonymousEmail$.value}getEnableAnonymousEmail$(){return this.enableAnonymousEmail$.asObservable()}addCommentOnElement(e){this.addComment(void 0,void 0,void 0,e)}enablePrivateCommentMode(){return X(this,null,function*(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.isPrivateCommentAllowed$().pipe(ut(1)).subscribe(e=>{e?(this.privateCommentMode$.next(!0),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIVATE_COMMENT_MODE_ENABLED)):this.loggingService.logsEnabled&&console.warn("You are not allowed to enable private comment mode.")})}catch(e){this.loggingService.catch("Error in CommentService enablePrivateCommentMode: ",e)}})}disablePrivateCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateCommentMode:!1}}),this.privateCommentMode$.value===!1)return;this.privateCommentMode$.next(!1),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIVATE_COMMENT_MODE_DISABLED)}catch(e){this.loggingService.catch("Error in CommentService disablePrivateCommentMode: ",e)}}getPrivateCommentMode(){return this.privateCommentMode$.value}getPrivateCommentMode$(){return this.privateCommentMode$.asObservable()}isPrivateCommentAllowed(){return this.privateCommentAllowed$.value}isPrivateCommentAllowed$(){return this.privateCommentAllowed$.asObservable()}enablePrivateMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateModeConfig:e}}),!e?.type){this.loggingService.catch("enablePrivateMode: type is required in config");return}let t=h({},e);if(t.type==="restricted"){let i=this.authService.getUser();if(!i?.userId){this.loggingService.catch("enablePrivateMode: Current user not found. Cannot set restricted visibility without userIds.");return}t=ap(t,i.userId)}this.privateModeConfig$.next(t)}catch(t){this.loggingService.catch("Error in CommentService enablePrivateMode: ",t)}}disablePrivateMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateModeConfig:null}}),this.privateModeConfig$.value===null)return;this.privateModeConfig$.next(null)}catch(e){this.loggingService.catch("Error in CommentService disablePrivateMode: ",e)}}getPrivateModeConfig(){return this.privateModeConfig$.value}getPrivateModeConfig$(){return this.privateModeConfig$.asObservable()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{scrollToComment:!0}}),this.scrollToComment$.value===!0)return;this.scrollToComment$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableScrollToComment: ",e)}}disableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{scrollToComment:!1}}),this.scrollToComment$.value===!1)return;this.scrollToComment$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableScrollToComment: ",e)}}getScrollToComment(){return this.scrollToComment$.value}getScrollToComment$(){return this.scrollToComment$.asObservable()}showScreenSizeInfo(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceInfo:e}}),this.showScreenSizeInfo$.value===e)return;this.showScreenSizeInfo$.next(e)}catch(t){this.loggingService.catch("Error in CommentService showScreenSizeInfo: ",t)}}getShowScreenSizeInfo$(){return this.showScreenSizeInfo$.asObservable()}enableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{userMentions:!0}}),this.userMentions$.value===!0)return;this.userMentions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableUserMentions: ",e)}}disableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{userMentions:!1}}),this.userMentions$.value===!1)return;this.userMentions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableUserMentions: ",e)}}getUserMentions(){return this.userMentions$.value}getUserMentions$(){return this.userMentions$.asObservable()}enablePaginatedContactList(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;"),this.paginatedContactList$.value===!0)return;this.paginatedContactList$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePaginatedContactList: ",e)}}disablePaginatedContactList(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;"),this.paginatedContactList$.value===!1)return;this.paginatedContactList$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePaginatedContactList: ",e)}}getPaginatedContactList(){return this.paginatedContactList$.value}getPaginatedContactList$(){return this.paginatedContactList$.asObservable()}enableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteOnBackspace:!0}}),this.deleteOnBackspace$.value===!0)return;this.deleteOnBackspace$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteOnBackspace: ",e)}}disableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteOnBackspace:!1}}),this.deleteOnBackspace$.value===!1)return;this.deleteOnBackspace$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteOnBackspace: ",e)}}getDeleteOnBackspace(){return this.deleteOnBackspace$.value}getDeleteOnBackspace$(){return this.deleteOnBackspace$.asObservable()}enableHotkey(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableHotkey","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{hotkey:!0}}),this.hotkeyEnabled$.value===!0)return;this.hotkeyEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableHotkey: ",e)}}disableHotkey(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableHotkey","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{hotkey:!1}}),this.hotkeyEnabled$.value===!1)return;this.hotkeyEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableHotkey: ",e)}}enableRecordingSummary(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingSummary:!0}}),this.recordingSummaryEnabled$.value===!0)return;this.recordingSummaryEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableRecordingSummary: ",e)}}disableRecordingSummary(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingSummary:!1}}),this.recordingSummaryEnabled$.value===!1)return;this.recordingSummaryEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableRecordingSummary: ",e)}}getRecordingSummaryEnabled(){return this.recordingSummaryEnabled$.value}getRecordingSummaryEnabled$(){return this.recordingSummaryEnabled$.asObservable()}setUnreadIndicatorMode(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{unreadIndicatorMode:e}}),this.unreadIndicatorMode$.value===e)return;this.unreadIndicatorMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setUnreadIndicatorMode: ",t)}}getUnreadIndicatorMode(){return this.unreadIndicatorMode$.value}getUnreadIndicatorMode$(){return this.unreadIndicatorMode$.asObservable()}setComposerMode(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setComposerMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{composerMode:e}}),this.composerMode$.value===e)return;this.composerMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setComposerMode: ",t)}}getComposerMode(){return this.composerMode$.value}getComposerMode$(){return this.composerMode$.asObservable()}enableEnterKeyToSubmit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{enterKeyToSubmit:!0}}),this.enterKeyToSubmit$.value===!0)return;this.enterKeyToSubmit$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableEnterKeyToSubmit: ",e)}}disableEnterKeyToSubmit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{enterKeyToSubmit:!1}}),this.enterKeyToSubmit$.value===!1)return;this.enterKeyToSubmit$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableEnterKeyToSubmit: ",e)}}getEnterKeyToSubmit(){return this.enterKeyToSubmit$.value}getEnterKeyToSubmit$(){return this.enterKeyToSubmit$.asObservable()}enablePinShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinShadowDom:!0}}),this.pinShadowDOM$.value===!0)return;this.pinShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinShadowDOM: ",e)}}disablePinShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinShadowDom:!1}}),this.pinShadowDOM$.value===!1)return;this.pinShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinShadowDOM: ",e)}}getPinShadowDOM(){return this.pinShadowDOM$.value}getPinDarkMode(){return this.pinDarkMode$.value}getPinDarkMode$(){return this.pinDarkMode$.asObservable()}getTextCommentToolDarkMode(){return this.textCommentToolDarkMode$.value}getTextCommentToolDarkMode$(){return this.textCommentToolDarkMode$.asObservable()}getTextCommentToolbarDarkMode(){return this.textCommentToolbarDarkMode$.value}getTextCommentToolbarDarkMode$(){return this.textCommentToolbarDarkMode$.asObservable()}getPinShadowDOM$(){return this.pinShadowDOM$.asObservable()}getTextCommentToolShadowDOM$(){return this.textCommentToolShadowDOM$.asObservable()}getTextCommentToolbarShadowDOM$(){return this.textCommentToolbarShadowDOM$.asObservable()}enableDialogShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogShadowDom:!0}}),this.dialogShadowDOM$.value===!0)return;this.dialogShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDialogShadowDOM: ",e)}}enableTextCommentToolbarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolbarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarShadowDom:!0}}),this.textCommentToolbarShadowDOM$.value===!0)return;this.textCommentToolbarShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolbarShadowDOM: ",e)}}disableTextCommentToolbarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolbarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarShadowDom:!1}}),this.textCommentToolbarShadowDOM$.value===!1)return;this.textCommentToolbarShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolbarShadowDOM: ",e)}}enableTextCommentToolShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolShadowDom:!0}}),this.textCommentToolShadowDOM$.value===!0)return;this.textCommentToolShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolShadowDOM: ",e)}}disableTextCommentToolShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolShadowDom:!1}}),this.textCommentToolShadowDOM$.value===!1)return;this.textCommentToolShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolShadowDOM: ",e)}}enableTextCommentToolDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolDarkMode:!0}}),this.textCommentToolDarkMode$.value===!0)return;this.textCommentToolDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolDarkMode: ",e)}}disableTextCommentToolDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolDarkMode:!1}}),this.textCommentToolDarkMode$.value===!1)return;this.textCommentToolDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolDarkMode: ",e)}}enableTextCommentToolbarDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolbarDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarDarkMode:!0}}),this.textCommentToolbarDarkMode$.value===!0)return;this.textCommentToolbarDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolbarDarkMode: ",e)}}disableTextCommentToolbarDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolbarDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarDarkMode:!1}}),this.textCommentToolbarDarkMode$.value===!1)return;this.textCommentToolbarDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolbarDarkMode: ",e)}}enablePinDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePinDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDarkMode:!0}}),this.pinDarkMode$.value===!0)return;this.pinDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinDarkMode: ",e)}}disablePinDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePinDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDarkMode:!1}}),this.pinDarkMode$.value===!1)return;this.pinDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinDarkMode: ",e)}}disableDialogShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogShadowDom:!1}}),this.dialogShadowDOM$.value===!1)return;this.dialogShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDialogShadowDOM: ",e)}}getDialogShadowDOM(){return this.dialogShadowDOM$.value}getDialogShadowDOM$(){return this.dialogShadowDOM$.asObservable()}setDialogShadowDOMExplicit(e){this.dialogShadowDOMExplicit$.next(e)}getDialogShadowDOMExplicit$(){return this.dialogShadowDOMExplicit$.asObservable()}enableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarShadowDOM:!0}}),this.sidebarShadowDOM$.value===!0)return;this.sidebarShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarShadowDOM: ",e)}}disableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarShadowDOM:!1}}),this.sidebarShadowDOM$.value===!1)return;this.sidebarShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarShadowDOM: ",e)}}getSidebarShadowDOM(){return this.sidebarShadowDOM$.value}getSidebarShadowDOM$(){return this.sidebarShadowDOM$.asObservable()}enableChangeDetectionInCommentMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{changeDetectionInCommentMode:!0}}),this.changeDetectionInCommentMode$.value===!0)return;this.changeDetectionInCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableChangeDetectionInCommentMode: ",e)}}disableChangeDetectionInCommentMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{changeDetectionInCommentMode:!1}}),this.changeDetectionInCommentMode$.value===!1)return;this.changeDetectionInCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableChangeDetectionInCommentMode: ",e)}}getChangeDetectionInCommentMode(){return this.changeDetectionInCommentMode$.value}getChangeDetectionInCommentMode$(){return this.changeDetectionInCommentMode$.asObservable()}showResolvedCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolvedCommentsOnDom:!0}}),this.resolvedCommentsOnDom$.value===!0)return;this.resolvedCommentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService showResolvedCommentsOnDom: ",e)}}hideResolvedCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolvedCommentsOnDom:!1}}),this.resolvedCommentsOnDom$.value===!1)return;this.resolvedCommentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService hideResolvedCommentsOnDom: ",e)}}getResolvedCommentsOnDom(){return this.resolvedCommentsOnDom$.value}getResolvedCommentsOnDom$(){return this.resolvedCommentsOnDom$.asObservable()}enableBubbleOnPin(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPin:!0}}),this.bubbleOnPinEnabled$.value===!0)return;this.bubbleOnPinEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableBubbleOnPin: ",e)}}disableBubbleOnPin(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPin:!1}}),this.bubbleOnPinEnabled$.value===!1)return;this.bubbleOnPinEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableBubbleOnPin: ",e)}}getBubbleOnPin(){return this.bubbleOnPinEnabled$.value}getBubbleOnPin$(){return this.bubbleOnPinEnabled$.asObservable()}enableBubbleOnPinHover(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPinHover:!0}}),this.bubbleOnPinHoverEnabled$.value===!0)return;this.bubbleOnPinHoverEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableBubbleOnPinHover: ",e)}}disableBubbleOnPinHover(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPinHover:!1}}),this.bubbleOnPinHoverEnabled$.value===!1)return;this.bubbleOnPinHoverEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableBubbleOnPinHover: ",e)}}getBubbleOnPinHover(){return this.bubbleOnPinHoverEnabled$.value}getBubbleOnPinHover$(){return this.bubbleOnPinHoverEnabled$.asObservable()}enablePinDrag(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDrag:!0}}),this.pinDragEnabled$.value===!0)return;this.pinDragEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinDrag: ",e)}}disablePinDrag(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDrag:!1}}),this.pinDragEnabled$.value===!1)return;this.pinDragEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinDrag: ",e)}}getPinDrag(){return this.pinDragEnabled$.value}getPinDrag$(){return this.pinDragEnabled$.asObservable()}setExcludeLocationIdsFromSidebar(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{excludeLocationIdsFromSidebar:e}}),this.excludeLocationIdsFromSidebar$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setExcludeLocationIdsFromSidebar: ",t)}}getExcludeLocationIdsFromSidebar(){return this.excludeLocationIdsFromSidebar$.value}getExcludeLocationIdsFromSidebar$(){return this.excludeLocationIdsFromSidebar$.asObservable()}enableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{multiThread:!1}}),this.multiThread$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableMultiThread: ",e)}}getMultiThread(){return this.multiThread$.value}getMultiThread$(){return this.multiThread$.asObservable()}enableGroupMatchedComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{groupMatchedComments:!0}}),this.groupMatchedComments$.value===!0)return;this.groupMatchedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGroupMatchedComments: ",e)}}disableGroupMatchedComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{groupMatchedComments:!1}}),this.groupMatchedComments$.value===!1)return;this.groupMatchedComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableGroupMatchedComments: ",e)}}getGroupMatchedComments(){return this.groupMatchedComments$.value}getGroupMatchedComments$(){return this.groupMatchedComments$.asObservable()}enableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{shortUserName:!0}}),this.shortUserName$.value===!0)return;this.shortUserName$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShortUserName: ",e)}}disableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{shortUserName:!1}}),this.shortUserName$.value===!1)return;this.shortUserName$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShortUserName: ",e)}}getShortUserName(){return this.shortUserName$.value}getShortUserName$(){return this.shortUserName$.asObservable()}enableRecordingCountdown(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingCountdown:!0}}),this.recorderService.enableRecordingCountdown()}catch(e){this.loggingService.catch("Error in CommentService enableRecordingCountdown: ",e)}}disableRecordingCountdown(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingCountdown:!1}}),this.recorderService.disableRecordingCountdown()}catch(e){this.loggingService.catch("Error in CommentService disableRecordingCountdown: ",e)}}setCommentSidebarFilters(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;"),this.commentSidebarFilters$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentSidebarFilters: ",t)}}getCommentSidebarFilters(){return this.commentSidebarFilters$.value??{}}getCommentSidebarFilters$(){return this.commentSidebarFilters$.asObservable()}setEffectiveSidebarFilters(e){try{this.effectiveSidebarFilters$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEffectiveSidebarFilters: ",t)}}getEffectiveSidebarFilters$(){return this.effectiveSidebarFilters$.asObservable()}setCommentSidebarSystemFiltersOperator(e){try{this.commentSidebarSystemFiltersOperator$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentSidebarSystemFiltersOperator: ",t)}}getCommentSidebarSystemFiltersOperator(){return this.commentSidebarSystemFiltersOperator$.value}getCommentSidebarSystemFiltersOperator$(){return this.commentSidebarSystemFiltersOperator$.asObservable()}enableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentPinHighlighter:!1}}),this.domService.disableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService disableCommentPinHighlighter: ",e)}}setCustomReactions(e){try{this.reactionService.setCustomReactions(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomReactions: ",t)}}onCommentSelectionChange$(){return this.commentSelectionChange$.asObservable()}onVisibilityOptionClicked$(){return this.visibilityOptionClicked$.asObservable()}emitVisibilityOptionClicked(e){this.visibilityOptionClicked$.next(e)}onCommentAdd$(){return this.commentAdded$.asObservable()}onCommentUpdate$(){return this.commentUpdated$.asObservable()}onCommentAnnotationDelete$(){return this.commentAnnotationDeleted$.asObservable()}onMultiThreadCommentAnnotationDelete$(){return this.multiThreadCommentAnnotationDeleted$.asObservable()}getCommentMode(){try{let e="freestyle";return this.getStreamMode()?e="stream":this.getPopoverMode()&&(e="popover"),e}catch(e){return this.loggingService.catch("Error in CommentService getCommentMode: ",e),"freestyle"}}getCommentType(e){try{return e.targetElement?"element":e.targetTextRange?"text":e.areaAnnotationId?"area":""}catch(t){return this.loggingService.catch("Error in CommentService getCommentType: ",t),""}}getCommentAnnotationAvailableOnXPath(e,t,i){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(a=>(!i&&t&&(i=ll(t,["id","data-id"])),de(y(h({},a),{element:i})))),ye(a=>this.getLocations$().pipe(ge(l=>y(h({},a),{locationIds:l})))),ge(({locationIds:a,element:l})=>{let c=[],d=this.docService.getDocumentPaths();if(d?.documentId){let g=this.docService.getAdditionalDocumentIdFromElement(l),u=g?this.docService.generateDocumentId(g):d?.documentId,_=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:d?.organizationId,documentId:u||""});if(_)for(let w of _)(t&&w?.targetElementId===t||w?.targetElement?.xpath===e)&&a?.includes(w?.locationId)&&c.push(w)}return c.length?c:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),de(null)}}getCommentAnnotationsByContext({context:e,contextOptions:t,element:i,clientDocumentId:a}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$()),ge(()=>{let l=null,c=this.docService.getDocumentPaths(),d=Ns(e),g=this.generateContextId(d);if(c?.documentId){let u=a||this.docService.getAdditionalDocumentIdFromElement(i??null),_=u?this.docService.generateDocumentId(u):c?.documentId,w=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:c?.organizationId,documentId:_||""});if(w){l=[];for(let A of w)t?.partialMatch?jF(A?.context,d)&&l.push(A):g&&A?.contextId===g&&l.push(A)}}return l}))}catch(l){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",l),de(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(ge(()=>this.getAnnotationById(e)),ye(t=>t?t?.iam?.accessMode===ya.PRIVATE?this.isPrivateCommentAllowed$().pipe(ge(i=>{if(i)return t})):de(t):de(t)),ye(t=>t?this.filterCommentsUsingSidebarSettings(t).pipe(ge(i=>{if(i)return i})):de(t)))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",t),de(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(ge(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let t=document.querySelector(`${F.TAGS.VELT_COMMENT_BUBBLE}[${F.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return t||(t=document.querySelector(`${F.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${F.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`)),t}catch(t){return this.loggingService.catch("Error in CommentService getCommentBubbleElement: ",t),null}}getCommentAnnotationsBySectionId(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,sectionId:e})))),ye(t=>{let i=ll(e,["id","data-id"]);if(i){let a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.genarateLocationId(a);return this.docService.getLocations$().pipe(ge(c=>{let g=Object.values(c||{}).find(u=>u.locationId===l||a?.id&&u.location.id===a.id);return y(h({},t),{additionalLocation:g,locationOnElement:!!a})}))}}return de(y(h({},t),{additionalLocation:null,element:i}))}),ye(t=>t?.locationOnElement?de(t):this.docService.getLocation$().pipe(ge(i=>y(h({},t),{location:i})))),ge(({documentPaths:t,location:i,additionalLocation:a,locationOnElement:l,element:c})=>{let d=null;if(this.authService.getUser()&&t?.documentId){let u=this.docService.getAdditionalDocumentIdFromElement(c),_=u?this.docService.generateDocumentId(u):t?.documentId,w=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:_||""});if(w){d=[];let A=sm(e);l?a?.location?.id?A=sm([a?.location?.id,e]):a?.locationId&&(A=sm([a?.locationId+"",e])):i&&(i?.location?.id?A=sm([i?.location?.id,e]):i?.locationId&&(A=sm([i?.locationId+"",e])));for(let M of w)M?.multiThreadAnnotationId===A?d.push(M):(M?.targetInlineCommentElementId===e||M?.targetElementId===e)&&(l?a&&E0({location:a?.location,locationId:a?.locationId},{location:M.location,locationId:M.locationId})&&d.push(M):i?E0({location:i?.location,locationId:i?.locationId},{location:M.location,locationId:M.locationId})&&d.push(M):M?.locationId||d.push(M))}}return d}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),de(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.multiThreadCommentAnnotationById$),ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,multiThreadAnnotationId:e})))),ge(({documentPaths:t,location:i,additionalLocation:a,locationOnElement:l})=>{let c=null;if(t?.documentId){let d=this.getMultiThreadAnnotationById(e),{documentId:g,organizationId:u}=d?.metadata||{documentId:t?.documentId,organizationId:t?.organizationId},_=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:u,documentId:g||""});if(_){c=[];for(let w of _)w?.multiThreadAnnotationId===e&&d?.commentAnnotations?.[w?.annotationId]&&c.push(w)}}return c}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),de(null)}}getCommentAnnotationsByAnnotationIds(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,annotationIds:e})))),ge(({documentPaths:t})=>{let i=null;if(t?.documentId){let a=this.commentAnnotationById$.value?Object.values(this.commentAnnotationById$.value):[],l=this.draftCommentAnnotationsByAnnotationId$.value?Object.values(this.draftCommentAnnotationsByAnnotationId$.value):[];if(a=[...a,...l],a){i=[];for(let c of a)e.includes(c?.annotationId)&&i.push(c)}}return i}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByAnnotationIds: ",t),de(null)}}getCommentAnnotationsByFolderId({folderId:e,veltFolderId:t}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$()),ge(()=>{e&&!t&&(t=Br(e));let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=null;if(i&&a?.documentId){this.commentAnnotationById$.value&&(l={},Object.values(this.commentAnnotationById$.value).forEach(d=>{d?.metadata?.folderId==e&&d?.metadata?.veltFolderId==t&&(l[d?.annotationId]=d)}));let c=this.draftCommentAnnotationsByAnnotationId$.value;c&&(l===null&&(l={}),Object.values(c).forEach(d=>{d?.metadata?.folderId==e&&d?.metadata?.veltFolderId==t&&!l[d?.annotationId]&&(l[d?.annotationId]=d)}))}return l?Object.values(l):null}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByFolderId: ",i),de(null)}}getCommentAnnotationsForCommentComponent(e){try{let{annotationId:t,folderId:i,veltFolderId:a,targetElementId:l,clientDocumentId:c,documentId:d,context:g,contextOptions:u,element:_,type:w,sectionId:A,locationId:M}=e||{};if(c&&!d&&(d=this.docService.generateDocumentId(c)),i&&!a&&(a=Br(i)),t)return this.getCommentAnnotationByAnnotationId(t).pipe(ge(q=>q?[q]:null));let j=[];if(l&&(w==="pin"||w==="tool"||w==="bubble")){let q=ll(l,["id","data-id"]);if(q){let ie=q,_e=this.domService.getXPath(q);j.push(this.getCommentAnnotationAvailableOnXPath(_e,l,ie))}}return A&&j.push(this.getCommentAnnotationsBySectionId(A)),g&&j.push(this.getCommentAnnotationsByContext({context:g,contextOptions:u,element:_,clientDocumentId:c})),d&&j.push(this.getCommentAnnotationsByDocumentId$({documentId:d})),i&&j.push(this.getCommentAnnotationsByFolderId({folderId:i,veltFolderId:a})),j.length===0?de(null):mn(j).pipe(ge(q=>{let ie=q.filter(ae=>ae!==null&&Array.isArray(ae));if(ie.length===0)return null;if(ie.length===1){let ae=ie[0];return M&&ae?.length?ae.filter(Ie=>Ie?.location?.id===M):ae}let _e=ie[0];for(let ae=1;ae<ie.length;ae++){let ue=ie[ae];_e=_e.filter(Ie=>ue.some(we=>we.annotationId===Ie.annotationId))}return M&&_e?.length&&(_e=_e.filter(ae=>ae?.location?.id===M)),_e}),bt(Zt))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsForCommentComponent: ",t),de(null)}}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.allowedElementIds$.value?.length||this.allowedElementClassNames$.value?.length||this.allowedElementQuerySelectors$.value?.length?!!(this.allowedElementIds$.value?.length&&this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)||this.allowedElementClassNames$.value?.length&&this.domService.isElementInsideListedElementClassNames(e,this.allowedElementClassNames$.value)||this.allowedElementQuerySelectors$.value?.length&&this.domService.isElementInsideListedElementQuerySelectors(e,this.allowedElementQuerySelectors$.value)):!0}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideAllowedElements: ",t),!1}}getNearestAllowedElement(e){try{let t=this.domService.getListedElements({elementIds:this.allowedElementIds$.value,elementClassNames:this.allowedElementClassNames$.value,elementQuerySelectors:this.allowedElementQuerySelectors$.value});if(t?.length){for(let i=0;i<t.length;i++){let a=t[i];if(e.contains(a))return a}return null}return null}catch(t){return this.loggingService.catch("Error in CommentService getNearestAllowedElement: ",t),null}}isElementInsideManualCommentContainer(e){try{return this.domService.isElementInsideParentWithAttribute(e,F.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",t),!1}}saveComment(e,t){return X(this,null,function*(){try{t?.annotation&&(e=t.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let i=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(i?.comments?.length){let u=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],i.comments?.forEach(_=>{let w=u.find(A=>A.commentId===_.commentId);w?e.comments.push(w):e.comments.push(_)})}e.comments||(e.comments=[]);let a=!1,l=!1,c;switch(t.type){case Tt.NEWLY_ADDED:case Tt.ADDED:if(!t.updatedComment)break;e?.comments?.length||(l=!0),e.comments.push(t.updatedComment);let u=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:t.type,otherFields:{assigned:u}};break;case Tt.APPROVED:e.approved=!0,c={commentAnnotation:e,targetComment:null,actionType:Tt.APPROVED};break;case Tt.ASSIGNED:{let ie=i?.assignedTo;e.assignedTo=t.assignedTo,c={commentAnnotation:e,targetComment:null,actionType:Tt.ASSIGNED,otherFields:{oldAssignedTo:ie,newAssignedTo:t.assignedTo}};break}case Tt.UPDATED:if(!t.updatedComment)break;let _=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);if(_>=0){let ie=e.comments[_]?.commentText;e.comments[_]=t.updatedComment,e.comments[_].status=Tt.UPDATED;let _e=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.UPDATED,otherFields:{assigned:_e,oldCommentText:ie}}}break;case Tt.REACTION_ADDED:if(!t.updatedComment)break;let w=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);w>=0&&(e.comments[w]=t.updatedComment,e.comments[w].status=Tt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.REACTION_ADDED});break;case Tt.REACTION_DELETED:if(!t.updatedComment)break;let A=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);A>=0&&(e.comments[A]=t.updatedComment,e.comments[A].status=Tt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.REACTION_DELETED});break;case Tt.STATUS_CHANGED:if(e.status.type==="terminal"){this.domService.resetSelectedAnnotationsMap(!1,"comment");let ie=this.authService.getUser();e.resolvedByUserId=ie?.userId,e.resolvedByUser=ie}c={commentAnnotation:e,targetComment:null,actionType:Tt.STATUS_CHANGED,otherFields:{oldStatus:t.oldStatus,newStatus:t.newStatus}};break;case Tt.PRIORITY_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.PRIORITY_CHANGED,otherFields:{oldPriority:t.oldPriority,newPriority:t.newPriority}};break;case Tt.ACCESS_MODE_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:t.oldAccessMode,newAccessMode:t.newAccessMode}};break;case Tt.CUSTOM_LIST_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:t.oldCustomList,newCustomList:t.newCustomList}};break;case Tt.SUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUBSCRIBED};break;case Tt.UNSUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Tt.UNSUBSCRIBED};break;case Tt.DELETED:if(!t.updatedComment)break;let M=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);if(M>=0){if((M===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!t.skipDeleteThreadConfirmation){let ae={};if(this.deleteReplyConfirmation$.value&&(M!==0||this.deleteThreadWithFirstComment$.value===!1)?ae={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply",type:"reply"}:ae={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"},!(yield this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:ae}).afterClosed().toPromise()))return}let ie=e.comments.splice(M,1),_e=e.metadata;ie?.length&&ie.forEach(ae=>{ae?.attachments&&ae.attachments.forEach(ue=>{let Ie={attachmentId:ue.attachmentId,organizationId:_e?.clientOrganizationId??_e?.organizationId??null,documentId:_e?.clientDocumentId??_e?.documentId??null,folderId:_e?.folderId??null,commentAnnotationId:e.annotationId,apiKey:_e?.apiKey??null};this.deleteAttachment({attachment:ue,metadata:Ie})}),ae?.reactionAnnotationIds&&ae.reactionAnnotationIds.forEach(ue=>{this.deleteReaction(ue)})})}e?.status?.type==="terminal"&&(e.status=this.customFilterService.defaultStatus),M===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments?.length===0?a=!0:(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_THREAD_DELETED,{annotationId:e.annotationId,commentThreadId:t.updatedComment.commentId,commentMode:this.getCommentMode()}),c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.DELETED});break;case Tt.ACCEPTED:let j={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Tt.ACCEPTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:this.getCommentAnnotationForClient(e)};this.commentAccepted$.next(j),c={commentAnnotation:e,targetComment:null,actionType:Tt.ACCEPTED};break;case Tt.REJECTED:let q={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Tt.REJECTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:this.getCommentAnnotationForClient(e)};this.commentRejected$.next(q),this.domService.resetSelectedAnnotationsMap(),c={commentAnnotation:e,targetComment:null,actionType:Tt.REJECTED};break;case Tt.SUGGESTION_ACCEPTED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUGGESTION_ACCEPTED,otherFields:{resolvedBy:e?.suggestion?.resolvedBy,resolvedAt:e?.suggestion?.resolvedAt}};break;case Tt.SUGGESTION_REJECTED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUGGESTION_REJECTED,otherFields:{rejectReason:e?.suggestion?.rejectReason,resolvedBy:e?.suggestion?.resolvedBy,resolvedAt:e?.suggestion?.resolvedAt}};break;default:break}if(e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null,e.resolvedByUser=null),t.visibility)try{let u=h({},t.visibility);if(u.type==="organizationPrivate"&&!u.organizationId){let w=this.docService.getOrganizationConfig();w?.clientOrganizationId&&(u.organizationId=w.clientOrganizationId)}let _=lp(u);_.length>0&&(e.context||(e.context={}),e.context._setAccessFields=_)}catch(u){this.loggingService.catch("Error building accessFields from visibility in saveComment:",u)}if(t?.updatedComment?.isDraft&&(c=void 0),a)this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment");else{if(l&&e.comments?.length&&this.enableAutoCategorize$?.value&&this.setCommentCategory(e),e.context?.access&&e.context?.accessFields&&t.updatedComment?.from?.userId&&!this.userPermissionService?.hasUserContextAccess({userId:t.updatedComment?.from?.userId,accessFields:e.context.accessFields})){this.loggingService.catch("User does not have context access to update comment annotation.",void 0,void 0,!0);return}this.updateComment(e,!1,!1,c,!0,t.updatedComment),e?.multiThreadAnnotationId&&(t.type===Tt.ADDED||t.type===Tt.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e])}let d=this.getCustomPinById(e.annotationId),g={type:t.type,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e.annotationId,targetCommentId:t.updatedComment?.commentId,updateContext:(u,_)=>{this.updateCommentAnnotationContext(e.annotationId,u,_)}};if(d!==void 0&&(g.element=d),delete g?.annotation?.pageInfo,delete g?.annotation?.targetElement,delete g?.annotation?.targetTextRange,g?.type===Tt.DELETED&&(e.comments?.length||(g.annotation=null)),a||this.commentUpdated$.next(g),t.type===Tt.NEWLY_ADDED&&!a&&e?.annotationId){let u=this.pendingAddCommentAnnotationData.get(e.annotationId);if(u){this.pendingAddCommentAnnotationData.delete(e.annotationId);let _=y(h({},u),{annotation:this.getCommentAnnotationForClient(e),targetCommentId:t.updatedComment?.commentId}),w=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(_);w&&this.commentActionsService?.triggerAddCommentAnnotationEvent(w),t.updatedComment&&(yield this.commentActionsService?.triggerAddCommentEvent({annotation:e,newComment:t.updatedComment}))}}t.type===Tt.ADDED&&t._dispatchAddCommentEvent&&!a&&e?.annotationId&&t.updatedComment&&(yield this.commentActionsService?.triggerAddCommentEvent({annotation:e,newComment:t.updatedComment}))}catch(i){this.loggingService.catch("Error in CommentService saveComment: ",i)}})}attachComment(e,t=[],i,a,l,c,d,g){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let u;if(e){let _=ll(e,t);_&&(u={targetElement:{xpath:this.domService.getXPath(_),topPercentage:50,leftPercentage:90},targetElementId:e})}(u||i||l)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,c,void 0,void 0,u,g,void 0,void 0,a,void 0,void 0,void 0,i,void 0,l,void 0,void 0,d)}catch(u){this.loggingService.catch("Error in CommentService attachComment: ",u)}}generateComponentIdFromObject(e){try{let t=Ns(e||{});return It(JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CommentService generateComponentIdFromObject: ",t);return}}updateNotificationsDatabase(e,t,i,a={}){try{let l=h({annotationData:e,targetAnnotationData:t,actionType:i,notificationSource:"comment"},a);this.notificationService.updateNotificationDatabase(l)}catch(l){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",l)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}getCustomUserContacts(){try{return this.contactService.getCustomUserContacts()}catch(e){return this.loggingService.catch("Error in CommentService getCustomUserContacts:",e),null}}getCustomUserContactsConfig(){try{return this.contactService.getCustomUserContactsConfig()}catch(e){this.loggingService.catch("Error in CommentService getCustomUserContactsConfig:",e);return}}getElementFromComment(e){try{let t=null;if(e?.ghostComment)!t&&e.ghostComment?.targetElement?.fXpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e.ghostComment?.targetElement?.cfXpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e.ghostComment?.targetElement?.xpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null));else{let i=!1,a=e?.targetElement?.anchor;if(!t&&a){let l=this.domService.resolveAnchorRecord(a);l?.element&&this.domService.isElementVisible(l.element)&&Xr(l.element)&&(t=l.element)}!t&&e?.targetElement?.xpath&&(i=this.domService.isXpathWithId(e?.targetElement?.xpath),t=this.domService.getElementFromXPath(e?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null)),i||(!t&&e?.targetElement?.cfXpath&&(t=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e?.targetElement?.fXpath&&(t=this.domService.getElementFromXPath(e?.targetElement?.fXpath),t&&!this.domService.isElementVisible(t)&&(t=null)))}return t&&!Xr(t)&&(t=null),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),null}}getElementFromComments(e){try{let t=[],i=null;if(e?.ghostComment)!i&&e.ghostComment?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.xpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null));else{let a=!1,l=e?.targetElement?.anchor;if(!i&&l){let c=this.domService.resolveAnchorRecord(l);c?.element&&this.domService.isElementVisible(c.element)&&Xr(c.element)&&(i=c.element)}!i&&e?.targetElement?.xpath&&(a=this.domService.isXpathWithId(e?.targetElement?.xpath),i=this.domService.getElementFromXPath(e?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null)),a||(!i&&e?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)))}return i&&!Xr(i)&&(i=null),e?.targetElementId&&(t=Array.from(Khe(e.targetElementId,["id","data-id"]))),i&&!t.includes(i)&&t.push(i),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),[]}}getGhostCommentTargetElement(e){try{let t=e.targetElement?.fXpath||e.targetElement?.xpath,i=null;if(t)for(;!i&&t;)i=this.domService.getElementFromXPath(t),i&&(!this.domService.isElementVisible(i)||!Xr(i))&&(i=null),i||(t=t.substring(0,t.lastIndexOf("/")));return t==="/"&&(t=""),t?{xpath:t,topPercentage:e?.targetElement?.topPercentage||0,leftPercentage:e?.targetElement?.leftPercentage||0}:null}catch(t){return this.loggingService.catch("Error in CommentService getGhostCommentTargetElement: ",t),null}}setGhostCommentMessage(e){try{if(e?.ghostComment){e.ghostComment.message="Original content not found.",e.ghostComment.type=As.ELEMENT_DELETED;let t=e?.pageInfo?.deviceInfo?.deviceType,i=new pr().getDeviceType();t&&t!==i&&(e.ghostComment.type=As.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${t}.`,[Gi.MOBILE,Gi.TABLET].includes(t)&&[Gi.MOBILE,Gi.TABLET].includes(i)||[Gi.DESKTOP,Gi.MONITOR].includes(t)&&[Gi.DESKTOP,Gi.MONITOR].includes(i)?e.ghostComment.isSameGroup=!0:e.ghostComment.isSameGroup=!1)}}catch(t){this.loggingService.catch("Error in CommentService setGhostCommentMessage: ",t)}}addAnnotationToGhostCommentAnnotationMap(e){try{let t=this.ghostCommentAnnotationMap$.value||{},i=t[e?.annotationId]||{};dr(e.ghostComment,i)||(t[e?.annotationId]=e.ghostComment,this.ghostCommentAnnotationMap$.next(t))}catch(t){this.loggingService.catch("Error in CommentService addAnnotationToGhostCommentAnnotationMap: ",t)}}removeAnnotationFromGhostCommentAnnotationMap(e){try{let t=this.ghostCommentAnnotationMap$.value||{};t[e?.annotationId]&&(delete t[e?.annotationId],this.ghostCommentAnnotationMap$.next(t))}catch(t){this.loggingService.catch("Error in CommentService removeAnnotationFromGhostCommentAnnotationMap: ",t)}}getGhostCommentAnnotationMap$(){return this.ghostCommentAnnotationMap$.asObservable()}getGhostCommentAnnotationMap(){return this.ghostCommentAnnotationMap$.value||{}}getUnreadCommentsMap$(){return this.unreadCommentsMap$.asObservable().pipe(bt(Zt))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>t?{count:t[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ge(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ge(e=>e?{count:Object.values(e).reduce((i,a)=>i+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>{if(t){let i=this.docService.getDocumentPaths(),a=[],l=0;return i?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId}),a&&Object.keys(t).forEach(c=>{a?.find(g=>g.annotationId===c)?.location?.id===e&&(l+=t[c])})),{count:l}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>{if(t){let i=this.docService.getDocumentPaths(),a=[],l=0;return i?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId}),Object.keys(t).forEach(c=>{t[c]&&a?.find(g=>g.annotationId===c)?.location?.id===e&&(l+=1)})),{count:l}}else return null}))}setCommentAnnotationsAsRead(e){try{for(let t of e)this.viewsService.setCommentAnnotationAsRead(t)}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsRead: ",t)}}setCommentAnnotationsAsResolved(e){try{let t=this.customFilterService.resolvedStatus,i=this.authService.getUser();if(t){for(let a of e)if(t?.id!==a?.status?.id){let l=JSON.parse(JSON.stringify(a||{}));a.status=this.customFilterService.resolvedStatus,a.statusUpdatedByUserId=i?.userId;let c={annotation:a,type:Tt.STATUS_CHANGED,oldStatus:l.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(a,c)}}}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsResolved: ",t)}}isCommentAnnotationUnread(e){try{let t=this.authService.getUser();return!(t?.userSnippylyId&&e?.viewedByUserIds?.length&&e?.viewedByUserIds?.includes(t?.userSnippylyId))}catch(t){return this.loggingService.catch("Error in CommentService isCommentAnnotationUnread: ",t),!1}}updateCommentDialogPosition(){try{this.updateCommentDialogPositionTriggerSubject$.next()}catch(e){this.loggingService.catch("Error in CommentService updateCommentDialogPosition: ",e)}}updateCommentDialogPositionTrigger$(){return this.updateCommentDialogPositionTriggerSubject$.asObservable()}enableAreaComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{areaComment:!0}}),this.areaCommentEnabled$.value===!0)return;this.areaCommentEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAreaComment: ",e)}}disableAreaComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{areaComment:!1}}),this.areaCommentEnabled$.value===!1)return;this.areaCommentEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAreaComment: ",e)}}getAreaCommentEnabled$(){return this.areaCommentEnabled$.asObservable()}getAreaCommentEnabled(){return this.areaCommentEnabled$.value}setPinCursorImage(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;"),e&&(e=`url(${e}) 0 31, auto`),this.commentPinCursorImage$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setPinCursorImage: ",t)}}getPinCursorImage$(){return this.commentPinCursorImage$.asObservable()}getPinCursorImage(){return this.commentPinCursorImage$.value}setCommentAnnotationsFromCommentsContainer(e){try{this.commentAnnotationsFromCommentsContainer$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsFromCommentsContainer: ",t)}}getCommentAnnotationsFromCommentsContainer$(){return this.commentAnnotationsFromCommentsContainer$.asObservable()}getCommentAnnotationsFromCommentsContainer(){return this.commentAnnotationsFromCommentsContainer$.value}addManualComment(e){return X(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addManualComment","color: green;"),new Promise((t,i)=>{let a=this.domService.getLastDocumentClick()?.target,l=e?.location||this.docService.getAdditionLocationFromElement(a);if(l?.id){let c=this.docService.getLocationByClientLocationId(l.id);c&&(l=c)}this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,l,void 0,e,void 0,void 0,void 0,c=>{t(c)}),this.addCommentMode$?.value&&!this.persistentCommentMode$?.value&&this.disableAddCommentMode()})}catch(t){return this.loggingService.catch("Error in CommentService addManualComment: ",t),null}})}getCommentUrl(e){try{return e?.pageInfo?.commentUrl?e.pageInfo.commentUrl:(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.commentUrl=this.generateCommentUrl(e),this.updateComment(e),e.pageInfo?.commentUrl)}catch(t){this.loggingService.catch("Error in CommentService getCommentUrl: ",t);return}}uploadFile(e,t){let i=`${F.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${F.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`;this.documentPaths?.organizationId&&(i=`${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${F.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`);let a={organizationId:t.metadata?.clientOrganizationId??this.documentPaths?.clientOrganizationId??null,documentId:t.metadata?.clientDocumentId??this.documentPaths?.clientDocumentId??null,commentAnnotationId:t.annotationId,apiKey:t.metadata?.apiKey??this.configService?.getApiKey()??null,folderId:t.metadata?.folderId??this.documentPaths?.folderId??null,attachmentId:null};return this.storageService.uploadFile({path:i,file:e,metadata:a,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}downloadAttachment(e){this.storageService.downloadAttachment(e)}deleteAttachment({attachment:e,metadata:t}){return this.storageService.deleteAttachment({attachment:e,metadata:t,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}deleteReaction(e){try{this.reactionService.deleteReactionPinAnnotation(e)}catch(t){this.loggingService.catch("Error in CommentService deleteReaction: ",t)}}generateCommentUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.COMMENT_ID),t.searchParams.append(F.URL_PARAMS.COMMENT_ID,e.annotationId),t.href}getCustomPinById(e){if(this.customPinsById.has(e))return this.customPinsById.get(e)}setCustomStatuses(e){try{if(e===void 0)return;this.customStatusesShown$.next(!0),this.customFilterService.setCustomStatusFilters(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomStatuses: ",t)}}getCustomStatusesShown$(){return this.customStatusesShown$.asObservable()}getCustomStatusesShown(){return this.customStatusesShown$.value}setCustomPriorities(e){try{if(e===void 0)return;this.customFilterService.setCustomPriorityFilters(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomPriorities: ",t)}}setCustomCategories(e){try{if(e===void 0)return;this.customFilterService.setCustomCategories(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomCategories: ",t)}}addCommentOnSelectedText(){try{let e=this.authService.getUser();if(this.textCommentMode$.value&&e&&!(e?.isReadOnly||e?.isAnonymous)&&this.authService.isFeatureAllowed(je.COMMENT)){let t=this.domService.getRange();if(window.getSelection()?.toString()&&!kO()&&t?.commonAncestorContainer&&this.isElementInsideAllowedElements(t.commonAncestorContainer)&&!Ag(t.commonAncestorContainer)){let i=t?this.domService.getTargetTextRangeFromSelectionRange(t):void 0;this.domService.clearTextSelection(),setTimeout(()=>{this.addComment(void 0,i)},100)}}}catch(e){this.loggingService.catch("Error in CommentService addCommentOnSelectedText: ",e)}}getInlineCommentSectionConfig(e){try{let t;if(e){let i=e?.closest(`[${F.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(i){let a=i.getAttribute(F.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(t={},t.targetInlineCommentElementId=a,i.getAttribute(F.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(t.config=JSON.parse(i.getAttribute(F.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)||"{}")))}}return t}catch(t){this.loggingService.catch("Error in CommentService getInlineCommentSectionConfig: ",t)}}createCustomListDataOnAnnotation(e){try{if(e===void 0)return;this.customChipDropdownData$.next(e)}catch(t){this.loggingService.catch("Error in CommentService createCustomListDataOnAnnotation: ",t)}}getCustomChipDropdownData$(){return this.customChipDropdownData$.asObservable()}getCustomChipDropdownData(){return this.customChipDropdownData$.value}setSubscribedUsersDataInCommentAnnotation(e){try{let t={},i=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(l=>{let c=e.subscribedUsers?.[l];c?.type==="manual"&&(t[l]=c)}),e?.assignedTo?.userId){let l=It(e?.assignedTo?.userId);i[l]||t[l]?.type!=="manual"&&(t[l]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(l=>!l?.isDraft)?.forEach(l=>{if(l?.from?.userId){let c=It(l?.from?.userId);i[c]||t[c]?.type!=="manual"&&(t[c]={user:l?.from,type:"auto"})}l?.to?.forEach(c=>{if(c?.userId){let d=It(c.userId);i[d]||t[d]?.type!=="manual"&&(t[d]={user:c,type:"auto"})}}),l?.toOrganizationUserGroup?.forEach(c=>{if(c?.groupId)a[c?.groupId]={type:"auto"};else if(c?.clientGroupId){let d=It(c.clientGroupId);a[d]={type:"auto"}}})}),e.subscribedUsers=t,e.unsubscribedUsers=i,e.subscribedGroups=a}catch(t){this.loggingService.catch("Error in CommentService setSubscribeUsersDataInCommentAnnotation: ",t)}}getCopyLink$(){return this.copyLink$.asObservable()}setCopyLink(e){try{this.copyLink$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCopyLink: ",t)}}getCommentAnnotationById(e){return this.commentAnnotationById$.pipe(ye(()=>{let{annotationId:t,documentId:i}=e;if(i){let a=tr(i).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(ge(l=>l.find(d=>d.annotationId===t)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let l=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(l){let c=l.find(d=>d.annotationId===t);return de(c||null)}}}return de(null)}),Gn(t=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",t),de(null))))}getDataCommentAnnotationsFromDocumentId(e){return this.configService?.getApiKey()?this.commonDbService.dbListener({feature:"allComments",properties:{documentId:e||this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,isCollection:!0}}).pipe(ge(t=>t?.data),ge(t=>{let i=[];return t&&(i=Object.values(t??{}).filter(a=>typeof a=="object")),i})):de([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{collapsedComments:!1}}),this.collapsedComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCollapsedComments: ",e)}}getCollapsedComments$(){return this.collapsedComments$.asObservable()}enableFullExpanded(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullExpanded:!0}}),this.fullExpanded$.value===!0)return;this.fullExpanded$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFullExpanded: ",e)}}disableFullExpanded(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullExpanded:!1}}),this.fullExpanded$.value===!1)return;this.fullExpanded$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFullExpanded: ",e)}}getFullExpanded$(){return this.fullExpanded$.asObservable()}getFullExpanded(){return this.fullExpanded$.value}setSidebarCustomActionEventData(e,t,i,a,l){try{this.sidebarCustomActionEventData$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l})}catch(c){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",c)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,t){try{let i=new Set;(e||[]).forEach(l=>{(l?.annotations||[]).forEach(c=>{c?.annotationId&&i.add(c.annotationId)})});let a=this.customSidebarDataAnnotationIds$.value;this.areAnnotationIdSetsEqual(a,i)||this.customSidebarDataAnnotationIds$.next(i),this.sidebarData$.next({data:e,options:t})}catch(i){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",i)}}areAnnotationIdSetsEqual(e,t){if(e===t)return!0;if(e===null||t===null||e.size!==t.size)return!1;for(let i of e)if(!t.has(i))return!1;return!0}getSidebarCustomData(){return this.sidebarData$.asObservable()}getCustomSidebarDataAnnotationIds$(){return this.customSidebarDataAnnotationIds$.asObservable()}getCustomSidebarDataAnnotationIds(){return this.customSidebarDataAnnotationIds$.value}setSidebarCustomActionEventDataAllChanges(e,t,i,a,l){return X(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l});let c=yield this.metadataService.getGlobalMetadata(),d={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:i,commentAnnotations:t,systemFilteredAnnotations:a,metadata:c,customFilters:l};this.commentActionsService?.triggerAction(er.COMMENT_SIDEBAR_DATA_UPDATE,d)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",c)}})}setSidebarCustomActionEventDataOnInit(e,t,i,a,l){return X(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l});let d={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:i,commentAnnotations:t,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()},customFilters:l};this.commentActionsService?.triggerAction(er.COMMENT_SIDEBAR_DATA_INIT,d)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataOnInit: ",c)}})}getSidebarCustomActionEventDataAllChanges(){return this.sidebarCustomActionEventDataAllChanges$.asObservable()}getSidebarCustomActionEventDataOnInit(){return this.sidebarCustomActionEventDataOnInit$.asObservable()}getSidebarCustomActionEventDataOnInitValue(){return this.sidebarCustomActionEventDataOnInit$.getValue()}setTransformContext(e){try{e?dr(this.transformContext$.value,e)||this.transformContext$.next(e):this.transformContext$.next(null)}catch(t){this.loggingService.catch("Error in CommentService setTransformContext: ",t)}}getTransformContext$(){return this.transformContext$.asObservable()}getTransformContext(){return this.transformContext$.value}enableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customActions:!0}}),this.customActions$.value===!0)return;this.customActions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarCustomActions: ",e)}}disableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customActions:!1}}),this.customActions$.value===!1)return;this.customActions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarCustomActions: ",e)}}getSidebarCustomActionsValue(){return this.customActions$.getValue()}enableQueryParamsComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{queryParamsComments:!0}}),this.queryParamsComments$.value===!0)return;this.queryParamsComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableQueryParamsComments: ",e)}}disableQueryParamsComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{queryParamsComments:!1}}),this.queryParamsComments$.value===!1)return;this.queryParamsComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableQueryParamsComments: ",e)}}getQueryParamsComments$(){return this.queryParamsComments$.asObservable()}getQueryParamsComments(){return this.queryParamsComments$.value}enableResolveStatusAccessAdminOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveStatusAccessAdminOnly:!0}}),this.resolveStatusAccessAdminOnly$.value===!0)return;this.resolveStatusAccessAdminOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableResolveStatusAccessAdminOnly: ",e)}}disableResolveStatusAccessAdminOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveStatusAccessAdminOnly:!1}}),this.resolveStatusAccessAdminOnly$.value===!1)return;this.resolveStatusAccessAdminOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableResolveStatusAccessAdminOnly: ",e)}}enableLinkCallback(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{linkCallback:!0}}),this.linkCallback$.value===!0)return;this.linkCallback$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableLinkCallback: ",e)}}disableLinkCallback(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{linkCallback:!1}}),this.linkCallback$.value===!1)return;this.linkCallback$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableLinkCallback: ",e)}}getResolveStatusAccessAdminOnly$(){return this.resolveStatusAccessAdminOnly$.asObservable()}getLinkCallback$(){return this.linkCallback$.asObservable()}getResolveStatusAccessAdminOnly(){return this.resolveStatusAccessAdminOnly$.value}getLinkCallback(){return this.linkCallback$.value}enableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{svgAsImg:!0}}),this.svgAsImg$.value===!0)return;this.svgAsImg$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSvgAsImg: ",e)}}disableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{svgAsImg:!1}}),this.svgAsImg$.value===!1)return;this.svgAsImg$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSvgAsImg: ",e)}}getSvgAsImg$(){return this.svgAsImg$.asObservable()}getSvgAsImg(){return this.svgAsImg$.value}enableCommentToNearestAllowedElement(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentToNearestAllowedElement:!0}}),this.commentToNearestAllowedElement$.value===!0)return;this.commentToNearestAllowedElement$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCommentToNearestAllowedElement: ",e)}}disableCommentToNearestAllowedElement(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentToNearestAllowedElement:!1}}),this.commentToNearestAllowedElement$.value===!1)return;this.commentToNearestAllowedElement$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCommentToNearestAllowedElement: ",e)}}getCommentToNearestAllowedElement$(){return this.commentToNearestAllowedElement$.asObservable()}getCommentToNearestAllowedElement(){return this.commentToNearestAllowedElement$.value}enableFilterCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterCommentsOnDom:!0}}),this.filterCommentsOnDom$.value===!0)return;this.filterCommentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFilterCommentsOnDom: ",e)}}disableFilterCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterCommentsOnDom:!1}}),this.filterCommentsOnDom$.value===!1)return;this.filterCommentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFilterCommentsOnDom: ",e)}}getFilterCommentsOnDom$(){return this.filterCommentsOnDom$.asObservable()}getFilterCommentsOnDom(){return this.filterCommentsOnDom$.value}setCommentsFromSidebarMap(e){try{let{comments:t,sidebarVisible:i}=e||{},a=null;t&&(a={},t.forEach(c=>{c?.annotationId&&a&&(a[c.annotationId]=c)}));let l={};t===void 0?l.data=this.commentsFromSidebarMap$.value?.data:l.data=a,i===void 0?l.sidebarVisible=this.commentsFromSidebarMap$.value?.sidebarVisible:l.sidebarVisible=i,dr(this.commentsFromSidebarMap$.value,l)||this.commentsFromSidebarMap$.next(l)}catch(t){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",t)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}hasActiveFilters(e){try{return e?!!(e.people?.length||e.assigned?.length||e.tagged?.length||e.involved?.length||e.priority?.length||e.status?.length||e.category?.length||e.location?.length||e.document?.length||e.version?.length||e.accessModes?.length||this.hasCustomContextFilters(e)):!1}catch(t){return this.loggingService.catch("Error in CommentService hasActiveFilters: ",t),!1}}hasCustomContextFilters(e){try{if(!e)return!1;let t=new Set(["people","assigned","tagged","involved","priority","status","category","version","document","location","accessModes"]);return Object.keys(e).some(i=>!t.has(i)&&Array.isArray(e[i])&&e[i]?.length>0)}catch(t){return this.loggingService.catch("Error in CommentService hasCustomContextFilters: ",t),!1}}applyDirectFilters(e,t){try{let i=this.commentSidebarSystemFiltersOperator$.value,a,l=!1,c=new Set;i===Qc.AND?a=e.slice():a=[];let d=g=>{i===Qc.AND?a=a.filter(u=>g.some(_=>_.annotationId===u.annotationId)):g.forEach(u=>c.add(u.annotationId)),l=!0};if(t.people?.length){let g=[];t.people.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByPeople({id:_,name:u.name},e)])}),d(g)}if(t.assigned?.length){let g=[];t.assigned.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByAssigned({id:_,name:u.name},e)])}),d(g)}if(t.tagged?.length){let g=[];t.tagged.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByTagged({id:_,name:u.name},e)])}),d(g)}if(t.involved?.length){let g=[];t.involved.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByInvolved({id:_,name:u.name},e)])}),d(g)}if(t.priority?.length){let g=[];t.priority.forEach(u=>g=[...g,...this.filterAnnotationsByPriority({id:u},e)]),d(g)}if(t.status?.length){let g=[];t.status.forEach(u=>g=[...g,...this.filterAnnotationsByStatus({id:u},e)]),d(g)}if(t.category?.length){let g=[];t.category.forEach(u=>g=[...g,...this.filterAnnotationsByCommentCategory({id:u},e)]),d(g)}if(t.version?.length){let g=[];t.version.forEach(u=>g=[...g,...this.filterAnnotationsByVersion(u,e)]),d(g)}if(t.document?.length){let g=[];t.document.forEach(u=>g=[...g,...this.filterAnnotationsByDocument(u,e)]),d(g)}if(t.location?.length){let g=[];t.location.forEach(u=>{u.id&&(g=[...g,...e.filter(_=>_.location?.id===u.id||_.documentParams?.id===u.id)])}),d(g)}if(t.accessModes?.length){let g=[];t.accessModes.forEach(u=>{u===ya.PRIVATE?g=[...g,...e.filter(_=>Pl(_))]:u===ya.PUBLIC&&(g=[...g,...e.filter(_=>!Pl(_))])}),d(g)}return this.getCustomContextFilterEntries(t).forEach(({key:g,values:u})=>{let _=this.matchAnnotationsByContext(e,g,u);d(_)}),i!==Qc.AND&&(l?a=e.filter(g=>c.has(g.annotationId)):a=e),a}catch(i){return this.loggingService.catch("Error in CommentService applyDirectFilters: ",i),e}}getCustomContextFilterEntries(e){try{if(!e)return[];let t=new Set(["people","assigned","tagged","involved","priority","status","category","version","document","location","accessModes"]),i=[];return Object.keys(e).forEach(a=>{if(t.has(a))return;let l=e[a];!Array.isArray(l)||!l.length||i.push({key:a,values:l})}),i}catch(t){return this.loggingService.catch("Error in CommentService getCustomContextFilterEntries: ",t),[]}}matchAnnotationsByContext(e,t,i){try{return e.filter(a=>{let l=a.context?.[t];return l==null?!1:i.some(c=>{let d=typeof c=="string"?c:c?.id;return l===d||l?.toString()===d})})}catch(a){return this.loggingService.catch("Error in CommentService matchAnnotationsByContext: ",a),[]}}filterAnnotationsByPeople(e,t){try{return e.id?t.filter(i=>i?.from?.userId===e.id||i?.from?.email===e.id):t}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByPeople: ",i),[]}}filterAnnotationsByTagged(e,t){try{return t.filter(i=>i?.comments?.some(a=>a.taggedUserContacts?.some(l=>l?.contact?.userId===e.id)))}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByTagged: ",i),[]}}filterAnnotationsByAssigned(e,t){try{return t.filter(i=>i?.assignedTo?.userId===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByAssigned: ",i),[]}}filterAnnotationsByInvolved(e,t){try{return t.filter(i=>{let a=i?.from?.userId===e.id||i?.from?.email===e.id,l=i?.assignedTo?.userId===e.id,c=i?.comments?.some(d=>d.taggedUserContacts?.some(g=>g?.contact?.userId===e.id));return a||l||c})}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByInvolved: ",i),[]}}filterAnnotationsByPriority(e,t){try{return e.id==="unset"?t.filter(i=>!i?.priority):t.filter(i=>i?.priority?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByPriority: ",i),[]}}filterAnnotationsByStatus(e,t){try{return t.filter(i=>i?.status?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByStatus: ",i),[]}}filterAnnotationsByCommentCategory(e,t){try{return e.id==="other"?t.filter(i=>!i?.commentCategories?.length||i?.commentCategories?.some(a=>a.id===e.id)):t.filter(i=>(i?.commentCategories||[]).some(a=>a.id===e.id))}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByCommentCategory: ",i),[]}}filterAnnotationsByVersion(e,t){try{return e.id==="unset"?t.filter(i=>!i?.location?.version):t.filter(i=>i?.location?.version?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByVersion: ",i),[]}}filterAnnotationsByDocument(e,t){try{return e?.id&&e.id!=="other"?t.filter(i=>i?.metadata?.clientDocumentId?.toString()===e.id):t.filter(i=>!i?.metadata?.clientDocumentId)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByDocument: ",i),[]}}setSidebarButtonCountType(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonCountType:e}}),this.sidebarButtonCountType$.value===e)return;this.sidebarButtonCountType$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setSidebarButtonCountType: ",t)}}getSidebarButtonCountType$(){return this.sidebarButtonCountType$.asObservable()}getSidebarButtonCountType(){return this.sidebarButtonCountType$.value}enableFilterGhostCommentsInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterGhostCommentsInSidebar:!0}}),this.filterGhostCommentsInSidebar$.value===!0)return;this.filterGhostCommentsInSidebar$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFilterGhostCommentsInSidebar: ",e)}}disableFilterGhostCommentsInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterGhostCommentsInSidebar:!1}}),this.filterGhostCommentsInSidebar$.value===!1)return;this.filterGhostCommentsInSidebar$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFilterGhostCommentsInSidebar: ",e)}}getFilterGhostCommentsInSidebar$(){return this.filterGhostCommentsInSidebar$.asObservable()}getFilterGhostCommentsInSidebar(){return this.filterGhostCommentsInSidebar$.value}filterCommentsUsingSidebarSettings(e){try{let t=Array.isArray(e),i;return t?i=e||[]:e?i=[e]:i=[],this.getFilterCommentsOnDom$().pipe(ye(a=>a?i.length===0?de(e):mn([this.effectiveSidebarFilters$,this.customSidebarDataAnnotationIds$]).pipe(ge(([l,c])=>{let d=i,g=!1;if(this.hasActiveFilters(l)){let u=this.applyDirectFilters(i,l),_=new Set(u.map(w=>w.annotationId));d=d.filter(w=>w?.isDraft||_.has(w.annotationId)),g=!0}return c&&(d=d.filter(u=>u?.isDraft||u?.annotationId&&c.has(u.annotationId)),g=!0),g?t?d:d.length>0?d[0]:null:e})):de(e)))}catch{return de(e)}}enableFocusedThreadMode(){try{if(this.focusedThreadMode$.value===!0)return;this.focusedThreadMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFocusedThreadMode: ",e)}}disableFocusedThreadMode(){try{if(this.focusedThreadMode$.value===!1)return;this.focusedThreadMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFocusedThreadMode: ",e)}}getFocusedThreadMode$(){return this.focusedThreadMode$.asObservable()}enableOpenAnnotationInFocusMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{openAnnotationInFocusMode:!0}}),this.openAnnotationInFocusMode$.value===!0)return;this.openAnnotationInFocusMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableOpenAnnotationInFocusMode: ",e)}}disableOpenAnnotationInFocusMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{openAnnotationInFocusMode:!1}}),this.openAnnotationInFocusMode$.value===!1)return;this.openAnnotationInFocusMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableOpenAnnotationInFocusMode: ",e)}}getOpenAnnotationInFocusMode$(){return this.openAnnotationInFocusMode$.asObservable()}getOpenAnnotationInFocusMode(){return this.openAnnotationInFocusMode$.value}enableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{readOnly:!0}}),this.readOnly$.value===!0)return;this.readOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReadOnly: ",e)}}disableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{readOnly:!1}}),this.readOnly$.value===!1)return;this.readOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReadOnly: ",e)}}getReadOnly$(){return this.readOnly$.asObservable()}getReadOnly(){return this.readOnly$.value}shouldEnableReadOnly(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentService FUNCTION: shouldEnableReadOnly","color: green;");let e=this.authService.getUser(),t=this.docService.getDocumentPaths()?.folderId,i=this.docService.getDocumentIds().map(a=>a.clientDocumentId);if(e){let a=this.userPermissionService.getCurrentUserPermissions();a?.[e.userId]?t&&a[e.userId]?.folders?.[t]?.accessRole==="viewer"?this.enableReadOnly():i.forEach(l=>{a[e.userId]?.documents?.[l]?.accessRole==="viewer"&&this.enableReadOnly()}):this.getReadOnly()||this.disableReadOnly()}}catch(e){this.loggingService.catch("Error in CommentService shouldEnableReadOnly:",e)}})}sanitizeCommentAnnotation(e){try{return e?.comments?.length&&e.comments.forEach(t=>{t?.commentHtml&&(t.commentHtml=this.domService.sanitizeHtml(t.commentHtml))}),e}catch(t){return this.loggingService.catch("Error in CommentService sanitizeCommentAnnotation: ",t),e}}enableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customAutocompleteSearch:!0}}),this.customAutocompleteSearch$.value===!0)return;this.customAutocompleteSearch$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCustomAutocompleteSearch: ",e)}}disableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customAutocompleteSearch:!1}}),this.customAutocompleteSearch$.value===!1)return;this.customAutocompleteSearch$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCustomAutocompleteSearch: ",e)}}getCustomAutocompleteSearch$(){return this.customAutocompleteSearch$.asObservable()}getCustomAutocompleteSearch(){return this.customAutocompleteSearch$.value}enableDeleteThreadWithFirstComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteThreadWithFirstComment:!0}}),this.deleteThreadWithFirstComment$.value===!0)return;this.deleteThreadWithFirstComment$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteThreadWithFirstComment: ",e)}}disableDeleteThreadWithFirstComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteThreadWithFirstComment:!1}}),this.deleteThreadWithFirstComment$.value===!1)return;this.deleteThreadWithFirstComment$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteThreadWithFirstComment: ",e)}}getDeleteThreadWithFirstComment$(){return this.deleteThreadWithFirstComment$.asObservable()}enableExpandMentionGroups(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{expandMentionGroups:!0}}),this.expandMentionGroups$.value===!0)return;this.expandMentionGroups$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableExpandMentionGroups: ",e)}}disableExpandMentionGroups(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{expandMentionGroups:!1}}),this.expandMentionGroups$.value===!1)return;this.expandMentionGroups$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableExpandMentionGroups: ",e)}}getExpandMentionGroups$(){return this.expandMentionGroups$.asObservable()}getExpandMentionGroups(){return this.expandMentionGroups$.value}enableShowMentionGroupsFirst(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsFirst:!0}}),this.showMentionGroupsFirst$.value===!0)return;this.showMentionGroupsFirst$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowMentionGroupsFirst: ",e)}}disableShowMentionGroupsFirst(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsFirst:!1}}),this.showMentionGroupsFirst$.value===!1)return;this.showMentionGroupsFirst$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowMentionGroupsFirst: ",e)}}getShowMentionGroupsFirst$(){return this.showMentionGroupsFirst$.asObservable()}getShowMentionGroupsFirst(){return this.showMentionGroupsFirst$.value}enableShowMentionGroupsOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsOnly:!0}}),this.showMentionGroupsOnly$.value===!0)return;this.showMentionGroupsOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowMentionGroupsOnly: ",e)}}disableShowMentionGroupsOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsOnly:!1}}),this.showMentionGroupsOnly$.value===!1)return;this.showMentionGroupsOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowMentionGroupsOnly: ",e)}}getShowMentionGroupsOnly$(){return this.showMentionGroupsOnly$.asObservable()}getShowMentionGroupsOnly(){return this.showMentionGroupsOnly$.value}setAnalyticsFeatureConfig({config:e,feature:t}){try{this.analyticsService.setFeatureConfig({feature:t||je.COMMENT,config:e})}catch(i){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",i)}}generateContextId(e){try{let t;if(e&&typeof e=="object"){let i=JSON.parse(JSON.stringify(e));if(delete i.accessFields,delete i.access,Object.keys(i).length){let a=Ns(i),l=JSON.stringify(a);t=It(l)}}return t}catch{return}}setMaxReplyAvatars(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{maxReplyAvatars:e}}),this.maxReplyAvatars$.value===e)return;this.maxReplyAvatars$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setMaxReplyAvatars: ",t)}}getMaxReplyAvatars$(){return this.maxReplyAvatars$.asObservable()}getMaxReplyAvatars(){return this.maxReplyAvatars$.value}enableReplyAvatars(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyAvatars:!0}}),this.replyAvatars$.value===!0)return;this.replyAvatars$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReplyAvatars: ",e)}}disableReplyAvatars(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyAvatars:!1}}),this.replyAvatars$.value===!1)return;this.replyAvatars$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReplyAvatars: ",e)}}getReplyAvatars$(){return this.replyAvatars$.asObservable()}getReplyAvatars(){return this.replyAvatars$.value}setCommentplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentplaceholder:e}}),this.commentplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentplaceholder: ",t)}}getCommentplaceholder$(){return this.commentplaceholder$.asObservable()}getCommentplaceholder(){return this.commentplaceholder$.value}setReplyplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyplaceholder:e}}),this.replyplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setReplyplaceholder: ",t)}}getReplyplaceholder$(){return this.replyplaceholder$.asObservable()}getReplyplaceholder(){return this.replyplaceholder$.value}setEditplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editplaceholder:e}}),this.editplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditplaceholder: ",t)}}getEditplaceholder$(){return this.editplaceholder$.asObservable()}getEditplaceholder(){return this.editplaceholder$.value}setEditcommentplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editcommentplaceholder:e}}),this.editcommentplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditcommentplaceholder: ",t)}}getEditcommentplaceholder$(){return this.editcommentplaceholder$.asObservable()}getEditcommentplaceholder(){return this.editcommentplaceholder$.value}setEditreplyplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editreplyplaceholder:e}}),this.editreplyplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditreplyplaceholder: ",t)}}getEditreplyplaceholder$(){return this.editreplyplaceholder$.asObservable()}getEditreplyplaceholder(){return this.editreplyplaceholder$.value}enableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{screenshotEnabled:!0}}),this.screenshotEnabled$.value===!0)return;this.screenshotEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableScreenshot: ",e)}}disableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{screenshotEnabled:!1}}),this.screenshotEnabled$.value===!1)return;this.screenshotEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableScreenshot: ",e)}}getScreenshotEnabled$(){return this.screenshotEnabled$.asObservable()}getScreenshotEnabled(){return this.screenshotEnabled$.value}getAnnotationNumber(e){try{let t=this.commentAnnotationById$.value||{},i=-1,a=Object.values(t).filter(l=>{let c=l.metadata?.documentId===e.metadata?.documentId;return c&&l.annotationNumber&&(i=Math.max(i,l.annotationNumber)),c});return i===-1?a.length+1:i+1}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationNumber: ",t),null}}enableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullScreen:!0}}),this.fullScreenInSidebar$.value===!0)return;this.fullScreenInSidebar$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFullScreenInSidebar: ",e)}}disableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullScreen:!1}}),this.fullScreenInSidebar$.value===!1)return;this.fullScreenInSidebar$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFullScreenInSidebar: ",e)}}getFullScreenInSidebar$(){return this.fullScreenInSidebar$.asObservable()}getFullScreenInSidebar(){return this.fullScreenInSidebar$.value}setComposerFileAttachments(e){try{this.composerFileAttachments$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setComposerFileAttachments: ",t)}}getComposerFileAttachments$(){return this.composerFileAttachments$.asObservable()}getComposerFileAttachments(){return this.composerFileAttachments$.value}clearComposerFileAttachments(){try{this.composerFileAttachments$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearComposerFileAttachments: ",e)}}enableAttachmentNameInMessage(){try{if(this.attachmentNameInMessage$.value===!0)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentNameInMessage:!0}}),this.attachmentNameInMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAttachmentNameInMessage: ",e)}}disableAttachmentNameInMessage(){try{if(this.attachmentNameInMessage$.value===!1)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentNameInMessage:!1}}),this.attachmentNameInMessage$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAttachmentNameInMessage: ",e)}}getAttachmentNameInMessage$(){return this.attachmentNameInMessage$.asObservable()}getAttachmentNameInMessage(){return this.attachmentNameInMessage$.value}setAllowedFileTypes(e){try{this.allowedFileTypes$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setAllowedFileTypes: ",t)}}getAllowedFileTypes$(){return this.allowedFileTypes$.asObservable()}getAllowedFileTypes(){return this.allowedFileTypes$.value}enableForceCloseAllOnEsc(){try{if(this.forceCloseAllOnEsc$.value===!0)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{forceCloseAllOnEsc:!0}}),this.forceCloseAllOnEsc$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableForceCloseAllOnEsc: ",e)}}disableForceCloseAllOnEsc(){try{if(this.forceCloseAllOnEsc$.value===!1)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{forceCloseAllOnEsc:!1}}),this.forceCloseAllOnEsc$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableForceCloseAllOnEsc: ",e)}}getForceCloseAllOnEsc$(){return this.forceCloseAllOnEsc$.asObservable()}getForceCloseAllOnEsc(){return this.forceCloseAllOnEsc$.value}markAsRead(e){return X(this,null,function*(){try{let t;e&&(t=this.getAnnotationById(e)),t&&(yield this.viewsService.setCommentAnnotationAsRead(t))}catch(t){this.loggingService.catch("Error in ViewsService markAsRead:",t)}})}markAsUnread(e){return X(this,null,function*(){try{let t;e&&(t=this.getAnnotationById(e)),t&&(yield this.viewsService.setCommentAnnotationAsUnread(t))}catch(t){this.loggingService.catch("Error in ViewsService markAsUnread:",t)}})}setAutoCompleteScrollConfig(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{autoCompleteScrollConfig:e}});let t=this.autoCompleteScrollConfig$.value,i={itemSize:e.itemSize??t.itemSize,minBufferPx:e.minBufferPx??t.minBufferPx,maxBufferPx:e.maxBufferPx??t.maxBufferPx,templateCacheSize:e.templateCacheSize??t.templateCacheSize};this.autoCompleteScrollConfig$.next(i)}catch(t){this.loggingService.catch("Error in CommentService setAutoCompleteScrollConfig: ",t)}}getAutoCompleteScrollConfig(){return this.autoCompleteScrollConfig$.value}getAutoCompleteScrollConfig$(){return this.autoCompleteScrollConfig$.asObservable()}submitComment(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: submitComment","color: green;"),this.submitComment$.next(e.targetComposerElementId)}catch(t){this.loggingService.catch("Error in CommentService submitComment: ",t)}}onSubmitComment$(){return this.submitComment$.asObservable()}clearComposer(e){try{this.clearComposer$.next(e.targetComposerElementId),this.composerDataMap.delete(e.targetComposerElementId)}catch(t){this.loggingService.catch("Error in CommentService clearComposer: ",t)}}onClearComposer$(){return this.clearComposer$.asObservable()}emitComposerTextChange(e,t,i){try{this.commentActionsService?.onComposerTextChange({text:e,annotation:t,targetComposerElementId:i})}catch(a){this.loggingService.catch("Error in CommentService emitComposerTextChange: ",a)}}setComposerData(e,t){try{this.composerDataMap.set(e,t)}catch(i){this.loggingService.catch("Error in CommentService setComposerData: ",i)}}clearComposerData(e){try{this.composerDataMap.delete(e)}catch(t){this.loggingService.catch("Error in CommentService clearComposerData: ",t)}}getComposerData(e){try{return this.composerDataMap.get(e.targetComposerElementId)||null}catch(t){return this.loggingService.catch("Error in CommentService getComposerData: ",t),null}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Cv),Z(kn),Z(Lt),Z(st),Z(Hn),Z(Ke),Z(Ve),Z(no),Z(_m),Z(un),Z($p),Z(Oo),Z(Vo),Z(Vn),Z(k),Z(cn),Z(ho),Z(qi),Z(R_e),Z(Un),Z(Ll),Z(jS),Z(ls),Z(bd),Z(as),Z(Oa),Z(fo))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var L_e=(()=>{let o=class o{constructor(e,t,i){this.commentService=e,this.reactionService=t,this.loggingService=i}getActivityForClient(e){try{let t=JSON.parse(JSON.stringify(e));return t.metadata&&(t.metadata=ai(t.metadata)),t.actionUser&&(t.actionUser=Bo(t.actionUser)),t.entityData&&(t.entityData=this.transformEntityData(t.featureType,t.entityData),t.entityData?.metadata&&(t.entityData.metadata=ai(t.entityData.metadata))),t.entityTargetData&&(t.entityTargetData=this.transformEntityTargetData(t.featureType,t.entityTargetData)),t.changes&&(t.changes=this.transformChanges(t.changes)),t.displayMessageTemplateData&&(t.displayMessageTemplateData=this.transformTemplateData(t.displayMessageTemplateData)),t}catch(t){return this.loggingService.catch("Error in ActivityActionsService getActivityForClient:",t),e}}transformEntityData(e,t){try{switch(e){case"comment":return this.commentService.getCommentAnnotationForClient(t);case"reaction":return this.reactionService.getReactionAnnotationForClient(t);case"recorder":return cfe(t);default:return t}}catch(i){return this.loggingService.catch("Error in ActivityActionsService transformEntityData:",i),t}}transformEntityTargetData(e,t){try{return t}catch(i){return this.loggingService.catch("Error in ActivityActionsService transformEntityTargetData:",i),t}}transformChanges(e){try{let t={};for(let i of Object.keys(e)){let a=e[i];if(!a){t[i]=a;continue}t[i]=h({},a),this.isUserObject(a.from)&&(t[i].from=Bo(a.from)),this.isUserObject(a.to)&&(t[i].to=Bo(a.to))}return t}catch(t){return this.loggingService.catch("Error in ActivityActionsService transformChanges:",t),e}}transformTemplateData(e){try{let t={};for(let i of Object.keys(e)){let a=e[i];this.isUserObject(a)?t[i]=Bo(a):t[i]=a}return t}catch(t){return this.loggingService.catch("Error in ActivityActionsService transformTemplateData:",t),e}}isUserObject(e){return!!e&&typeof e=="object"&&"userId"in e}};o.\u0275fac=function(t){return new(t||o)(Z(Re),Z(qi),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Gg=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j){this.activityResolverService=e,this.activityUtilsService=t,this.authService=i,this.commentAnnotationsResolverService=a,this.reactionAnnotationsResolverService=l,this.recorderAnnotationsResolverService=c,this.commonDbService=d,this.commonDbUtilsService=g,this.configService=u,this.docService=_,this.functions=w,this.loggingService=A,this.usersService=M,this.userPermissionService=j,this.isActivityFeatureEnabled$=new Se(!1),this.isActivityFeatureImmutable$=new Se(!1),this.allActivities$=new Se(null),this.subscriptions=new Map,this.fetchedEntityIds=new Set;try{this.commonDbService.setActivityService(this),this.authService.setActivityService(this),this.initializeService()}catch(q){this.loggingService.catch("Error in ActivityService constructor:",q)}}setActivityFeatureConfig(e){try{this.isActivityFeatureEnabled$.next(e?.isEnabled??!1),this.isActivityFeatureImmutable$.next(e?.immutable??!1)}catch(t){this.loggingService.catch("Error in setActivityFeatureConfig: ",t)}}getIsActivityFeatureEnabled(){return this.isActivityFeatureEnabled$.value}getIsActivityFeatureImmutable(){return this.isActivityFeatureImmutable$.value}getIsActivityFeatureEnabled$(){return this.isActivityFeatureEnabled$.asObservable().pipe(bt(Zt))}initializeService(){try{this.authSubscription=this.getIsActivityFeatureEnabled$().pipe(bt(),$e(e=>e===!0)).subscribe(()=>{this.subscriptions.size>0&&!this.triggerListenerSubscription&&this.rebuildTriggerListener()},e=>{this.loggingService.catch("Error in ActivityService feature flag subscription:",e)})}catch(e){this.loggingService.catch("Error in ActivityService initializeService:",e)}}subscribe(e){let t=lt(),i=new Se(null);try{let a={id:t,config:e??{},activities$:i};this.subscriptions.set(t,a),this.getIsActivityFeatureEnabled()&&this.rebuildTriggerListener(),this.allActivities$.getValue()!==null&&this.distributeActivitiesToSubscription(a)}catch(a){this.loggingService.catch("Error in ActivityService subscribe:",a)}return{getActivities$:()=>i.asObservable(),unsubscribe:()=>{try{this.subscriptions.delete(t),i.complete(),this.getIsActivityFeatureEnabled()&&this.rebuildTriggerListener()}catch(a){this.loggingService.catch("Error in ActivityService unsubscribe:",a)}}}}getActivities$(){return this.allActivities$.asObservable().pipe(bt(Zt))}getActivitiesForDocument$(e){return this.allActivities$.pipe(ge(t=>t===null?null:t.filter(i=>i.metadata?.documentId===e)),bt(Zt))}getActivitiesForEntity$(e){return this.allActivities$.pipe(ge(t=>t===null?null:t.filter(i=>i.targetEntityId===e)),bt(Zt))}fetchActivitiesForEntity(e){return X(this,null,function*(){try{if(!this.getIsActivityFeatureEnabled())return;let{targetEntityId:t,documentId:i,organizationId:a}=e;if(!t||!i||this.fetchedEntityIds.has(t))return;this.fetchedEntityIds.add(t);let l=this.authService.getUser();if(!l?.userId){this.fetchedEntityIds.delete(t);return}let c=a||this.docService.getOrganizationConfig()?.clientOrganizationId;if(!c){this.fetchedEntityIds.delete(t);return}let d=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()})),g=yield cl({methodName:"getActivitiesForEntity",data:{type:"getActivitiesForEntity",organizationId:c,documentId:i,targetEntityId:String(t),isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable()},getSdkProxy:d,userId:l.userId});if(g?.activities?.length){let u=g.activities;this.appendActivities(u),this.rehydrateActivities(u)}}catch(t){this.fetchedEntityIds.delete(e.targetEntityId),this.loggingService.catch("Error in ActivityService fetchActivitiesForEntity:",t)}})}createActivity(e){return X(this,null,function*(){try{if(!this.getIsActivityFeatureEnabled())return;let t=this.authService.getUser();if(!t?.userId){this.loggingService.warn("ActivityService createActivity: No user available");return}let i=this.docService.getBaseMetadata("activity");if(!i?.apiKey||!i?.organizationId){this.loggingService.warn("ActivityService createActivity: Missing metadata or organizationId");return}let a=this.getIsActivityFeatureImmutable(),l=lt(),c={id:l,featureType:e.featureType,actionType:e.actionType,eventType:e.eventType,actionUser:t,timestamp:this.commonDbService.getServerTimestamp(),metadata:i,targetEntityId:e.targetEntityId!=null?String(e.targetEntityId):void 0,targetSubEntityId:e.targetSubEntityId!=null?String(e.targetSubEntityId):void 0,changes:e.changes,entityData:e.entityData,entityTargetData:e.entityTargetData,actionIcon:e.actionIcon,displayMessageTemplate:e.displayMessageTemplate,displayMessageTemplateData:e.displayMessageTemplateData,immutable:a};this.appendActivities([c]);let{strippedActivity:d,activityResolverData:g}=yield this.activityUtilsService.stripActivityPII(c);g&&this.activityResolverService.activityDataProviderAvailable()&&this.activityResolverService.saveActivity({activity:{[g.id]:g},event:Io.ACTIVITY_SAVE});try{yield this.sendActivityToBackend(d)}catch{let u=this.allActivities$.getValue()??[];this.allActivities$.next(u.filter(_=>_.id!==l)),this.subscriptions.forEach(_=>this.distributeActivitiesToSubscription(_))}}catch(t){this.loggingService.catch("Error in ActivityService createActivity:",t)}})}rebuildTriggerListener(){try{if(this.triggerListenerSubscription&&(this.triggerListenerSubscription.unsubscribe(),this.triggerListenerSubscription=void 0),this.subscriptions.size===0)return;let e=this.getCombinedSubscriptionScope();this.triggerListenerSubscription=this.getLastActivityTimestamps$(e).pipe(yo(null),Lr(),ge(([t,i])=>{if(!i)return;if(i.length===0){this.allActivities$.getValue()===null&&!this.emptyStateTimeoutId&&(this.emptyStateTimeoutId=setTimeout(()=>{this.emptyStateTimeoutId=void 0,this.allActivities$.getValue()===null&&(this.allActivities$.next([]),this.subscriptions.forEach(d=>this.distributeActivitiesToSubscription(d)))},5e3));return}this.emptyStateTimeoutId&&(clearTimeout(this.emptyStateTimeoutId),this.emptyStateTimeoutId=void 0);let a=new Map;t?.forEach(d=>a.set(d.documentId,d.timestamp));let l=[],c=[];if(i.forEach(d=>{let g=a.get(d.documentId);g===void 0?l.push(d.documentId):g!==d.timestamp&&c.push({documentId:d.documentId,previousTimestamp:g})}),l.length>0){let d=this.getStartAtTimestamp(e.maxDays);this.fetchActivitiesForDocuments(l,e.organizationId,void 0,d)}c.length>0&&this.fetchActivitiesForDocuments(c.map(d=>d.documentId),e.organizationId,c)})).subscribe(()=>{},t=>this.loggingService.catch("Error in ActivityService trigger listener:",t))}catch(e){this.loggingService.catch("Error in ActivityService rebuildTriggerListener:",e)}}getLastActivityTimestamps$(e){try{return this.authService.getUser$().pipe($e(t=>!!t),ye(t=>this.docService.getOrganizationConfig$().pipe($e(i=>!!i),ge(i=>{let l=(e.organizationId?ka(e.organizationId):void 0)||i?.organizationId||t?.organizationId;return{user:t,organizationId:l}}))),ye(({user:t,organizationId:i})=>{if(!t||!i)return de(null);if(e.type===$g.CURRENT_DOCUMENT)return this.docService.getDocumentPaths$().pipe(ye(l=>{let c=l?.clientDocumentId;if(!c&&!e.documentIds?.length)return this.resetCurrentDocumentSubscriptions(),de(null);let d=new Set(e.documentIds??[]);c&&d.add(c);let g=Array.from(d).slice(0,30).map(u=>pi(u));return g.length===1?this.buildTriggerQuery(i,[ft("metadata.documentId","==",g[0])],e.maxDays):this.buildTriggerQuery(i,[ft("metadata.documentId","in",g)],e.maxDays)}));let a=[];if(e.type===$g.DOCUMENTS&&e.documentIds?.length){e.documentIds.length>30&&this.loggingService.catch("Error in ActivityService getLastActivityTimestamps$: Subscription includes more than 30 document IDs. Only the first 30 will be monitored.",new Error("Subscription includes more than 30 document IDs. Only the first 30 will be monitored."),void 0,!0);let l=e.documentIds.slice(0,30).map(c=>pi(c));a.push(ft("metadata.documentId","in",l))}return this.buildTriggerQuery(i,a,e.maxDays)}))}catch(t){return this.loggingService.catch("Error in ActivityService getLastActivityTimestamps$:",t),de(null)}}buildTriggerQuery(e,t,i=HU){try{let a=this.getStartAtTimestamp(i);t.push(ft("timestamp",">=",a));let c=[t.length>1?yr(...t):t[0],po("timestamp","desc")];return this.commonDbService.dbListener({feature:"allLastActivityTimestamp",properties:{organizationId:e,isCollection:!0,useQuery:!0,firestoreQuery:c}}).pipe(ge(d=>d?.data),ge(d=>{if(!d)return[];let g=[];return Object.keys(d).forEach(u=>{let _=this.commonDbService.shouldUseFirestore()?d[u]?.timestamp??0:d[u];g.push({documentId:u,timestamp:_})}),g}))}catch(a){return this.loggingService.catch("Error in ActivityService buildTriggerQuery:",a),de([])}}fetchActivitiesForDocuments(e,t,i,a){return X(this,null,function*(){try{if(!e.length)return;let l=this.authService.getUser();if(!l?.userId)return;let c=t||this.docService.getOrganizationConfig()?.clientOrganizationId;if(!c)return;let d=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()})),g={type:"getActivitiesForDocuments",organizationId:c,documentIds:e,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable()};a&&(g.startAtTimestamp=a),i?.length&&(g.documentTimestamps=i.map(_=>({documentId:_.documentId,timestamp:_.previousTimestamp})));let u=yield cl({methodName:"getActivitiesForDocuments",data:g,getSdkProxy:d,userId:l.userId});if(u?.activities?.length){let _=u.activities;this.appendActivities(_),this.rehydrateActivities(_)}else this.allActivities$.getValue()===null&&(this.allActivities$.next([]),this.subscriptions.forEach(_=>this.distributeActivitiesToSubscription(_)))}catch(l){this.loggingService.catch("Error in ActivityService fetchActivitiesForDocuments:",l)}})}sendActivityToBackend(e){return X(this,null,function*(){try{let t=this.authService.getUser();if(!t?.userId)return;let i=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()}));yield cl({methodName:"createActivity",data:{type:"createActivity",activityData:e},getSdkProxy:i,userId:t.userId})}catch(t){throw this.loggingService.catch("Error in ActivityService sendActivityToBackend:",t),t}})}rehydrateActivities(e){try{let t=this.usersService.userDataProviderAvailable(),i=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),a=this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable(),l=this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable(),c=this.activityResolverService.activityDataProviderAvailable(),d=Promise.resolve();t&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldAwait:!0,forceResolve:!0})).then(()=>{this.resolveAndUpdateActivities(e,"user")})),i&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldCommentAnnotationsResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"comment")})),a&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldReactionResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"reaction")})),l&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldRecorderResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"recorder")})),c&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldActivityResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"activity")}))}catch(t){this.loggingService.catch("Error in ActivityService rehydrateActivities:",t)}}resolveAndUpdateActivities(e,t){try{let i=this.allActivities$.getValue()??[],a=new Map(i.map(g=>[g.id,g])),l=e.map(g=>a.get(g.id)??g),c=JSON.parse(JSON.stringify(l)),d;switch(t){case"user":d=this.commonDbUtilsService.mergeUsersWithData({feature:"allActivities",data:c});break;case"comment":d=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allActivities",data:c});break;case"reaction":d=this.commonDbUtilsService.mergeReactionAnnotationsWithData({feature:"allActivities",data:c});break;case"recorder":d=this.commonDbUtilsService.mergeRecorderAnnotationsWithData({feature:"allActivities",data:c});break;case"activity":d=this.commonDbUtilsService.mergeActivityResolverWithData({feature:"allActivities",data:c});break}d?.length&&this.appendActivities(d)}catch(i){this.loggingService.catch("Error in ActivityService resolveAndUpdateActivities:",i)}}appendActivities(e){try{let t=this.allActivities$.getValue()??[],i=new Map;e.forEach(g=>{g.id&&i.set(g.id,g)});let a=t.map(g=>i.get(g.id)??g),l=new Set(t.map(g=>g.id)),d=[...e.filter(g=>!l.has(g.id)),...a].sort((g,u)=>(u.timestamp??0)-(g.timestamp??0));if(d.forEach(g=>{g.displayMessage=this.activityUtilsService.getActivityDisplayMessage(g)}),this.activitiesEqual(t,d))return;this.allActivities$.next(d),this.subscriptions.forEach(g=>{this.distributeActivitiesToSubscription(g)})}catch(t){this.loggingService.catch("Error in ActivityService appendActivities:",t)}}distributeActivitiesToSubscription(e){try{let t=this.allActivities$.getValue();if(t===null)return;let i=e.config,a;if(i.currentDocumentOnly){let c=this.docService.getDocumentPaths()?.documentId;a=c?t.filter(d=>d.metadata?.documentId===c):[]}else if(i.documentIds?.length){let c=new Set(i.documentIds.map(d=>pi(d)));a=t.filter(d=>d.metadata?.documentId&&c.has(d.metadata.documentId))}else a=t;if(i.featureTypes?.length){let c=new Set(i.featureTypes);a=a.filter(d=>c.has(d.featureType))}else if(i.excludeFeatureTypes?.length){let c=new Set(i.excludeFeatureTypes);a=a.filter(d=>!c.has(d.featureType))}if(i.actionTypes?.length){let c=new Set(i.actionTypes);a=a.filter(d=>c.has(d.actionType))}else if(i.excludeActionTypes?.length){let c=new Set(i.excludeActionTypes);a=a.filter(d=>!c.has(d.actionType))}if(i.userIds?.length){let c=new Set(i.userIds);a=a.filter(d=>d.actionUser?.userId&&c.has(d.actionUser.userId))}else if(i.excludeUserIds?.length){let c=new Set(i.excludeUserIds);a=a.filter(d=>!d.actionUser?.userId||!c.has(d.actionUser.userId))}let l=e.activities$.getValue();if(l!==null&&this.activitiesEqual(l,a))return;e.activities$.next(a)}catch(t){this.loggingService.catch("Error in ActivityService distributeActivitiesToSubscription:",t)}}resetCurrentDocumentSubscriptions(){try{this.subscriptions.forEach(e=>{e.config.currentDocumentOnly&&e.activities$.getValue()!==null&&e.activities$.next(null)})}catch(e){this.loggingService.catch("Error in ActivityService resetCurrentDocumentSubscriptions:",e)}}activitiesEqual(e,t){try{if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i].id!==t[i].id)return!1;return JSON.stringify(e)===JSON.stringify(t)}catch(i){return this.loggingService.catch("Error in ActivityService activitiesEqual:",i),!1}}getCombinedSubscriptionScope(){try{let e=!1,t=!1,i,a=new Set,l=HU;this.subscriptions.forEach(d=>{let g=d.config;g.organizationId&&(i=g.organizationId),g.currentDocumentOnly?t=!0:g.documentIds?.length?g.documentIds.forEach(u=>a.add(u)):e=!0,g.maxDays&&g.maxDays>l&&(l=g.maxDays)});let c={organizationId:i,maxDays:l};return e?h({type:$g.ORG_WIDE},c):t&&a.size>0?h({type:$g.CURRENT_DOCUMENT,documentIds:Array.from(a)},c):t?h({type:$g.CURRENT_DOCUMENT},c):a.size>0?h({type:$g.DOCUMENTS,documentIds:Array.from(a)},c):h({type:$g.ORG_WIDE},c)}catch(e){return this.loggingService.catch("Error in ActivityService getCombinedSubscriptionScope:",e),{type:$g.ORG_WIDE,organizationId:void 0,maxDays:HU}}}getStartAtTimestamp(e){try{let t=new Date,i=e>0?e:HU;return t.setDate(t.getDate()-i),t.getTime()}catch(t){return this.loggingService.catch("Error in ActivityService getStartAtTimestamp:",t),0}}cleanup(){try{this.triggerListenerSubscription?.unsubscribe(),this.triggerListenerSubscription=void 0,this.emptyStateTimeoutId&&(clearTimeout(this.emptyStateTimeoutId),this.emptyStateTimeoutId=void 0),this.subscriptions.forEach(e=>e.activities$.complete()),this.subscriptions.clear(),this.allActivities$.next(null),this.fetchedEntityIds.clear()}catch(e){this.loggingService.catch("Error in ActivityService cleanup:",e)}}destroy(){try{this.cleanup(),this.authSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in ActivityService destroy:",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(Vp),Z(LS),Z(Ke),Z(dl),Z(is),Z(vl),Z(kn),Z(bd),Z(Lt),Z(st),Z(Oo),Z(k),Z(Mn),Z(Oa))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})(),$g=(function(n){return n.ORG_WIDE="orgWide",n.DOCUMENTS="documents",n.CURRENT_DOCUMENT="currentDocument",n})($g||{}),HU=30;var fr=class{constructor(o){this.injector=o,this.hideAnalytics=!1}ha(o){try{this.hideAnalytics=o}catch{}}getService(o){return this.injector.get(o)}trackEvent(o,r={},e=!0){try{this.hideAnalytics||(r||(r={}),r=y(h({},r),{source:"external"}),this.getService(ct).trackAuthenticatedEvent(o,r,e))}catch(t){this.getService(k).catch("Error in _trackEvent: ",t);return}}};var zU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ActivityElement","color: blue;"),this.getAllActivities=this._getAllActivities,this.createActivity=this._createActivity}_getAllActivities(o){this.getService(k).log("%c[WB] Calling FUNCTION: getAllActivities","color: green;");try{let r=this.getService(L_e),e=this.getService(Gg).subscribe(o);return new Vt(t=>{let i=e.getActivities$().pipe(ge(a=>a?.map(l=>r.getActivityForClient(l))??null)).subscribe(t);return()=>{i.unsubscribe(),e.unsubscribe()}})}catch(r){return this.getService(k).catch("Error in _getAllActivities: ",r),de(null)}}_createActivity(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: createActivity","color: green;");try{yield this.getService(Gg).createActivity(o)}catch(r){this.getService(k).catch("Error in _createActivity: ",r)}})}};var WU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Cv).enableArea()}catch(o){this.getService(k).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Cv).disableArea()}catch(o){this.getService(k).catch("Error in _disableAreaComment: ",o)}}};var Tm=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A){this.analyticsService=e,this.configService=t,this.docService=i,this.databaseService=a,this.authService=l,this.domService=c,this.afAuth=d,this.iamService=g,this.dialog=u,this.loggingService=_,this.notificationService=w,this.commonDbService=A,this.arrowAnnotations$=new Se({}),this.arrowAnnotationsByDocumentId$=new Se({}),this.documentPaths=null,this.allowedElementIds$=new Se([]),this.addArrowMode$=new Se(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe($e(M=>!!M),ut(1)).subscribe(M=>{M&&this.getDocumentPaths()},M=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",M)}),this.domService.onWindowPointerMove$().subscribe(M=>{if(this.addArrowMode$.value){let j=!0,q=this.domService.getBackgroundElement(M.clientX,M.clientY);q&&(this.isElementInsideAllowedElements(q)?YF(M.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==q&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=q,this.domService.highlightElement(this.highlightElement,F.CURSOR.ARROW_PIN),j=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&j&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},M=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",M)}),this.domService.onWindowKeyupEsc$().subscribe(M=>{this.addArrowMode$.value&&this.disableAddArrowMode()},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",M)}),this.domService.onDocumentClick$().subscribe(M=>{if(M&&this.addArrowMode$.value){if(!YF(M.target)){let j=this.domService.getBackgroundElement(M.clientX,M.clientY);j&&this.isElementInsideAllowedElements(j)&&(M.preventDefault(),M.stopPropagation(),this.addArrow(M))}this.disableAddArrowMode()}},M=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",M)}),this.addArrowMode$.subscribe(M=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),M?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},M=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",M)}),this.domService.onWindowKeyupBackspace$().subscribe(M=>{this.deleteArrowPinAnnotations("keyupBackspace")},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",M)}),this.domService.onWindowKeyupDelete$().subscribe(M=>{this.deleteArrowPinAnnotations("keyupDelete")},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",M)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,l;try{if(e&&(l=tr(e)),t&&typeof t=="object"){let c=Ai(t);a=tr(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",c)}return _r(this.afAuth).pipe($e(c=>!!c),ye(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),ye(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(d=>(c.featureAllowed=d,c))):de(c)),ye(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(ge(d=>(c.featureAllowed=!d,c))):de(c)),ye(c=>c.featureAllowed?de(c).pipe(ye(d=>this.docService.getDocumentPaths$().pipe(ge(g=>(this.documentPaths=g,d.documentPaths=g,d)))),ye(d=>this.getDataFromDocumentId(l).pipe(ge(g=>(d.annotations=g||[],h({},d))))),ye(d=>this.docService.getLocation$().pipe(ge(g=>(d.location=g,d)))),ye(d=>this.docService.getLocations$().pipe(ge(g=>(d.customLocations=g,d)))),ge(d=>{if(d.filteredAnnotations=[],l&&!a)return d.filteredAnnotations=d.annotations?.slice(),d;{let g=[];return a?g.push(a):(g.push(d?.location?.locationId),g.push(...Object.values(d?.customLocations||[]).map(u=>u.locationId))),d.filteredAnnotations=this.filterAnnotationsByLocationIds(d?.annotations,g),d}}),ye(d=>i?de(d):d?.annotations?.length?this.domService.onWindowResize$().pipe(ge(()=>d)):de(d)),ye(d=>i?de(d):d?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(ge(()=>d)):de(d)),ge(d=>(d?.filteredAnnotations?.forEach(g=>{this.calculateArrowAnnotationPosition(g)}),d)),ye(d=>d?.filteredAnnotations?de(d?.filteredAnnotations||[]):de([]))):de([])),bt(Zt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.ARROW)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe($e(t=>!!t),ye(t=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:e??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ge(i=>({data:i?.data,operation:i?.operation})),ge(({data:i,operation:a})=>{let l=[];return i&&(l=Object.values(i).filter(c=>typeof c=="object")),{data:l,operation:a}}),Gn(i=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",i),de({data:[],operation:null}))),ge(({data:i,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let l=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(c=>{delete l?.[c]}),this.arrowAnnotationsByDocumentId$.next(l)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,i);return i})):de([])))}setArrowAnnotationsByDocumentId(e,t){try{if(e){let i=y(h({},this.arrowAnnotationsByDocumentId$.value),{[e]:t});this.arrowAnnotationsByDocumentId$.next(i)}}catch(i){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",i)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(i=>t.includes(i.locationId))}catch(i){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",i),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let i=t.iterateNext();if(i&&Xr(i)){let a=i.getBoundingClientRect();if(a&&a.width&&a.height){let{height:l,width:c}=vp(i);e.position={top:l*e.targetElement.topPercentage/100,left:c*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(t){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",t)}}addArrow(e){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let t=this.authService.getUser();if(t)if(t.isReadOnly||t.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let i=new IF;i.from=t,i.color=t?.color||F.DEFAULT_ANNOTATION_COLOR,i.lastUpdated=this.timestamp,i.props=new ud;let a=this.domService.getCurrentWindowSizeValue();if(i.props.screenWidth=a.screenWidth,i.props.screenHeight=a.screenHeight,i.props.screenScrollHeight=a.screenScrollHeight,i.props.viewportWidth=window.innerWidth,i.props.viewportHeight=window.innerHeight,i.props.arrowLength=F.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>F.VELT_MIN_ARROW_LENGTH?i.props.arrowAngle=135:i.props.arrowAngle=45,e&&(i.targetElement=this.domService.getTargetElementForCursorPosition(e)),i?.targetElement?.xpath){let l=this.domService.getXPath(i.targetElement.xpath);if(l){let c=l.iterateNext();c&&(Xr(c)||(i.targetElement=null))}}this.setLocationToArrowAnnotation(i),i.pageInfo=io(),i.pageInfo&&(i.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(i)}}catch(t){this.loggingService.catch("Error in ArrowService addArrow: ",t)}}setLocationToArrowAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{if(e.targetElement?.xpath){let i=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",t)}}saveArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(je.ARROW)&&this.docService.getDocumentPaths$().pipe($e(t=>!!t),ut(1),ye(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(i=>!!i),ut(1),ye(i=>{if(this.documentPaths?.arrow){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.arrowUrl=this.generateArrowUrl(e));let a=JSON.parse(JSON.stringify(e));return a.position=null,this.domService.toggleAnnotationSelection(a),this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:e.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}else return de(null)}))))).subscribe(()=>{},t=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",t)}}updateArrow(e,t=!1,i){try{i&&this.setLocationToArrowAnnotation(e),t&&this.updateNotificationsDatabase(e,SF.UPDATED),this.updateArrowToDb(e)}catch(a){this.loggingService.catch("Error in ArrowService updateArrow: ",a)}}updateArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(e?.targetElement?.xpath){let t=this.domService.getXPath(e.targetElement.xpath);if(t){let i=t.iterateNext();i&&(Xr(i)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(je.ARROW)&&this.docService.getDocumentPaths$().pipe($e(t=>!!t),ut(1),ye(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(i=>!!i),ut(1),ye(i=>{if(this.documentPaths?.arrow&&e?.annotationId){let a=JSON.parse(JSON.stringify(e));return a.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}else return de(null)}))))).subscribe(()=>{},t=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",t)}}deleteArrowPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),i=this.authService.getUser(),a=[];Object.keys(t).forEach(l=>X(this,null,function*(){let c=t[l];if(c.type==="arrow"){let d=i&&!i?.isAnonymous&&!i?.isGuest;i&&c.from&&(d||c.from.userId===i.userId)&&a.push(c)}})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(l=>l.annotationId).join()}),this.dialog.open(ml,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(ut(1)).subscribe(l=>{l&&(a.forEach(c=>X(this,null,function*(){yield this.deleteArrowPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(d=>{this.domService.removeHighlightFromElement(d)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(t){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",t)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(je.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,SF.DELETED),this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETED,{annotationId:e.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(je.ARROW)?(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let i={annotationData:e,actionType:t,notificationSource:"arrow"};this.notificationService.updateNotificationDatabase(i)}catch(i){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",i)}}getArrowUrl(e){try{return e?.pageInfo?.arrowUrl?e.pageInfo.arrowUrl:(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.arrowUrl=this.generateArrowUrl(e),this.updateArrow(e),e.pageInfo?.arrowUrl)}catch(t){this.loggingService.catch("Error in ArrowService getArrowUrl: ",t);return}}generateArrowUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.TAG_ID),t.searchParams.append(F.URL_PARAMS.TAG_ID,e.annotationId),t.href}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Lt),Z(st),Z(Hn),Z(Ke),Z(Ve),Z(no),Z(Vn),Z(Vo),Z(k),Z(cn),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var YU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(Tm).setAllowedElementIds(o)}catch(r){this.getService(k).catch("Error in allowedElementIds: ",r)}}};var Pc=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Se({}),this.onAutocompleteChipClick$=new it;try{this.loggingService.log("%c[WB] Creating CLASS: AutocompleteService","color: blue;"),this.create({hotkey:"@",type:"contact",data:[]})}catch(t){this.loggingService.catch("Error in AutocompleteService constructor: ",t)}}create(e){try{if(this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: create","color: green;"),e?.hotkey){let t=this.autocompleteDataMap$.value;t[e.hotkey]=e,this.autocompleteDataMap$.next(t)}}catch(t){this.loggingService.catch("Error in AutocompleteService create: ",t)}}remove(e){try{this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: remove","color: green;");let t=this.autocompleteDataMap$.value;delete t[e],this.autocompleteDataMap$.next(t)}catch(t){this.loggingService.catch("Error in AutocompleteService remove: ",t)}}getAutocompleteDataMap$(){return this.autocompleteDataMap$.asObservable()}getAutocompleteDataMap(){return this.autocompleteDataMap$.value}setOnAutocompleteChipClick(e){this.onAutocompleteChipClick$.next(e)}getOnAutocompleteChipClick$(){return this.onAutocompleteChipClick$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var KU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(k).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(Pc).create(o)}catch(r){this.getService(k).catch("Error in _create: ",r)}}_onAutocompleteChipClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(Pc).getOnAutocompleteChipClick$()}catch(o){return this.getService(k).catch("Error in _onAutocompleteChipClick: ",o),de(null)}}};var U_e=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g){this.authService=e,this.iamService=t,this.docService=i,this.configService=a,this.commonDbService=l,this.loggingService=c,this.commentService=d,this.userPermissionService=g,this.documentPaths=null,this.LISTENER_BATCH_SIZE=5}getAnnotationsCount(e){try{return this.authService.getUser$().pipe($e(t=>!!t),ye(t=>this.docService.getOrganizationConfig$().pipe($e(i=>!!i),ge(()=>t))),ye(t=>this.commentService.isFeatureAllowed({firebaseUser:t,annotations:[],filteredAnnotations:[]})),ye(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(i=>(t.featureAllowed=i,t))):de(t)),ye(t=>t.featureAllowed?this.processRequest(t,e):de(null)),ge(t=>t??{data:null}),bt(Zt))}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",t),de({data:null})}}processRequest(e,t){try{return de(e).pipe(ye(()=>this.initializeDocumentPaths(t,e)),ye(()=>this.getDocumentIds$(t)),ye(i=>{let a=this.authService.getUser()?.userSnippylyId,l=this.buildRequestContext(t,i);if(!this.validateRequestContext(l,t))return de({data:null,mode:l.mode,serverDocumentIds:l.serverDocumentIds});if(!l.organizationId)return de({data:null,mode:l.mode,serverDocumentIds:l.serverDocumentIds});let c=this.setupTriggers$(l.mode,l.organizationId,l.clientOrganizationId,l.veltFolderId,l.serverDocumentIds);if(this.shouldUseAggregateMode(l.mode))return this.handleAggregateCounts$({triggers$:c,serverDocumentIds:l.serverDocumentIds,request:t,userId:a,organizationId:l.organizationId,clientOrganizationId:l.clientOrganizationId,veltFolderId:l.veltFolderId,folderId:l.folderId,mode:l.mode}).pipe(ge(d=>({data:d,mode:l.mode,serverDocumentIds:l.serverDocumentIds})));if(l.mode.isBatchedGroupedMode){let d=t?.debounceMs??5e3;return this.handleBatchedGroupedCounts$({triggers$:c,documentIds:i,request:t,userId:a,organizationId:l.organizationId,veltFolderId:l.veltFolderId,debounceMs:d}).pipe(ge(g=>({data:g,mode:l.mode,serverDocumentIds:l.serverDocumentIds})))}else return this.handleGroupedCounts$(c,i,t,a,l.organizationId,l.veltFolderId).pipe(ge(d=>({data:d,mode:l.mode,serverDocumentIds:l.serverDocumentIds})))}),ye(i=>{if(!i?.data)return de(null);let{data:a,mode:l,serverDocumentIds:c}=i;return t?.filterGhostComments?this.filterGhostComments$(a,l,c):de(a)}),Gn(i=>(this.loggingService.catch("Error processing request: ",i),de(null))))}catch(i){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",i),de(null)}}initializeDocumentPaths(e,t){try{return e?de(t):this.docService.getDocumentPaths$().pipe($e(i=>!!i),dn(i=>{this.documentPaths=i,t.documentPaths=i}),ge(()=>{}))}catch(i){return this.loggingService.catch("Error in CommentService initializeDocumentPaths: ",i),de(t)}}buildRequestContext(e,t){try{let i=this.docService.getOrganizationConfig(),a=this.documentPaths?.organizationId??i?.organizationId,l=this.documentPaths?.clientOrganizationId??i?.clientOrganizationId,c,d,g;if(e?.allDocuments||e?.documentIds||e?.folderId||e?.organizationId||e?.locationIds){if(e.organizationId&&(a=ka(e.organizationId),l=e.organizationId),!a)throw new Error("organizationId is required for this request type");e.folderId&&(c=Br(e.folderId),d=e.folderId),e.allDocuments&&(g=!0)}else c=this.documentPaths?.veltFolderId,d=this.documentPaths?.folderId,g=this.documentPaths?.allDocuments;let u=this.determineMode(e,c,g,t),_=u.isOrgMode?[]:t.length>0?t.map(w=>w.documentId):[this.documentPaths?.documentId??""];return{organizationId:a,clientOrganizationId:l,veltFolderId:c,folderId:d,allDocuments:g,mode:u,serverDocumentIds:_}}catch(i){return this.loggingService.catch("Error in CommentService buildRequestContext: ",i),{organizationId:void 0,clientOrganizationId:void 0,veltFolderId:void 0,folderId:void 0,allDocuments:void 0,mode:{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1,isBatchedGroupedMode:!1},serverDocumentIds:[]}}}validateRequestContext(e,t){try{if(t?.aggregateDocuments&&!e.serverDocumentIds.length)throw this.loggingService.catch("Error in CommentService getAnnotationsCount: documentIds is required when aggregateDocuments is true"),new Error("documentIds is required when aggregateDocuments is true");return!(!e.organizationId||!(e.mode.isOrgMode||e.mode.isFolderMode)&&e.serverDocumentIds.some(i=>!i))}catch(i){return this.loggingService.catch("Error in CommentService validateRequestContext: ",i),!1}}shouldUseAggregateMode(e){try{return e.isFolderMode||e.isOrgMode||e.isBatchMode}catch(t){return this.loggingService.catch("Error in CommentService shouldUseAggregateMode: ",t),!1}}getDocumentIds$(e){try{return e?.documentIds?.length?de(e.documentIds.map(t=>({clientDocumentId:t,documentId:pi(t)}))):this.docService.getDocumentIds$().pipe(ge(t=>t.length>0?t:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIds: ",t),de([])}}determineMode(e,t,i,a){try{let l=!!e?.organizationId&&!e?.documentIds?.length&&!t&&!i,c=!!t&&!!i,d=!!e?.aggregateDocuments&&!i&&!!a?.length,g=(!!e?.batchedPerDocument||a.length>1)&&!!a?.length&&!e?.aggregateDocuments&&!i;return{isOrgMode:l,isFolderMode:c,isBatchMode:d,isBatchedGroupedMode:g}}catch(l){return this.loggingService.catch("Error in CommentService determineMode: ",l),{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1,isBatchedGroupedMode:!1}}}setupTriggers$(e,t,i,a,l){try{if(e.isOrgMode){let c=this.authService.getUser()?.userId??"";return[so(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:i})??Promise.resolve({})).pipe(ye(g=>c&&g?.[c]?.organization?.[i]?.errorCode===mr.PERMISSION_DENIED?(this.loggingService.log(`%c[WB] commentViews org listener skipped \u2014 user does not have access to organization: ${i}`,"color: orange;"),Ya):this.commonDbService.dbListener({feature:"organizationMetadata",properties:{useCollectionGroup:!1,isCollection:!1,organizationId:t}}))).pipe(ge(g=>g?.data?.commentViewsUpdatedAt??null),$e(g=>!!g),bt(Zt))]}else{if(e.isFolderMode)return[this.commonDbService.dbListener({feature:"folder",properties:{useCollectionGroup:!1,isCollection:!1,folderId:a,organizationId:t}}).pipe(ge(d=>d?.data?.commentViewsUpdatedAt??null),$e(d=>!!d),bt(Zt))];if(e.isBatchMode||e.isBatchedGroupedMode){let c=[];for(let d=0;d<l.length;d+=this.LISTENER_BATCH_SIZE)c.push(l.slice(d,d+this.LISTENER_BATCH_SIZE));return c.map(d=>this.commonDbService.dbListener({feature:"allDocuments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",t),ft("metadata.documentId","in",d))]}}).pipe(ge(u=>Object.values(u?.data||{}).map(w=>w?.commentViewsUpdatedAt??null).sort().join(",")),bt(Zt)))}else return l.map(c=>this.commonDbService.dbListener({feature:"documentMetadata",properties:{useCollectionGroup:!1,isCollection:!1,documentId:c,organizationId:t}}).pipe(ge(g=>g?.data?.commentViewsUpdatedAt??null),$e(g=>!!g),bt(Zt)))}}catch(c){return this.loggingService.catch("Error in CommentService setupTriggers: ",c),[]}}handleGroupedCounts$(e,t,i,a,l,c){try{let d=t.map((g,u)=>e[u].pipe(yo(void 0),ye(()=>so(this.getCountsForDocument$(g.documentId,g.clientDocumentId,i,a,l,c)))));return mn(d).pipe(ge(g=>{let u={};return g.forEach(_=>{_&&(u[_.clientDocumentId]={total:_.total,unread:_.unread})}),{data:u}}),Gn(g=>(this.loggingService.catch("Error in grouped counts: ",g),de(null))))}catch(d){return this.loggingService.catch("Error in CommentService handleGroupedCounts: ",d),de(null)}}handleBatchedGroupedCounts$(e){try{let{triggers$:t,documentIds:i,request:a,userId:l,organizationId:c,veltFolderId:d,debounceMs:g}=e,u=this.LISTENER_BATCH_SIZE,_=new Pd(1),w=t.map((q,ie)=>q.pipe(Bj(_),ge(()=>ie))),A=Lo(...w).pipe(to(g)),M=de(-1).pipe(ye(()=>so(this.fetchAllDocumentCounts$(i,a,l,c,d))),ge(q=>({batchIndex:-1,data:q?.data||{}})),dn(()=>{_.next()})),j=A.pipe(ye(q=>{let ie=q*u,_e=Math.min(ie+u,i.length),ae=i.slice(ie,_e);return so(this.fetchAllDocumentCounts$(ae,a,l,c,d)).pipe(ge(ue=>({batchIndex:q,data:ue?.data||{}})))}));return Lo(M,j).pipe(Pb((q,ie)=>({data:h(h({},q.data),ie.data)}),{data:{}}),Gn(q=>(this.loggingService.catch("Error in batched grouped counts: ",q),de(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleBatchedGroupedCounts: ",t),de(null)}}fetchAllDocumentCounts$(e,t,i,a,l){return X(this,null,function*(){try{let c=e.map(u=>this.getCountsForDocument$(u.documentId,u.clientDocumentId,t,i,a,l)),d=yield Promise.allSettled(c),g={};return d.forEach(u=>{if(u.status==="fulfilled"&&u.value){let{clientDocumentId:_,total:w,unread:A}=u.value;g[_]={total:w,unread:A}}}),{data:g}}catch(c){return this.loggingService.catch("Error in CommentService fetchAllDocumentCounts: ",c),null}})}handleAggregateCounts$(e){try{let{triggers$:t,serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}=e;return mn(t).pipe(ge(()=>{})).pipe(yo(void 0),ye(()=>so(this.getAggregateCounts({serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}))),Gn(A=>(this.loggingService.catch("Error in aggregate counts: ",A),de(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleAggregateCounts: ",t),de(null)}}getCountsForDocument$(e,t,i,a,l,c){return X(this,null,function*(){try{let d=this.configService?.getApiKey(),g={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},u=[ft("metadata.apiKey","==",d),ft("metadata.organizationId","==",l),ft("metadata.documentId","in",[e]),...c?[ft("metadata.veltFolderId","==",c)]:[],...i?.statusIds?.length?[ft("status.id","in",i.statusIds)]:[],...i?.locationIds?.length?[ft("location.id","in",i.locationIds)]:[],...i?.agentFields?.length?[ft("agent.agentFields","array-contains-any",i.agentFields)]:[]],_=[yr(...u),po("lastUpdated","desc"),po("createdAt","desc")],w=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},g),{firestoreQuery:_})}),A=0;if(!i?.agentFields?.length){let M=[...u,ft("viewedByUserIds","array-contains",a)],j=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];A=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},g),{firestoreQuery:j})})}return{clientDocumentId:t,total:w,unread:w-A}}catch(d){return this.loggingService.catch("Error in CommentService getCountsForDocument: ",d),null}})}getAggregateCounts(e){return X(this,null,function*(){try{let t="",{serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}=e,w=this.configService?.getApiKey(),A={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},M=[ft("metadata.apiKey","==",w),ft("metadata.organizationId","==",c),...a?.statusIds?.length?[ft("status.id","in",a.statusIds)]:[],...a?.locationIds?.length?[ft("location.id","in",a.locationIds)]:[],...a?.agentFields?.length?[ft("agent.agentFields","array-contains-any",a.agentFields)]:[]],j,q=0;if(_.isFolderMode){t=u??"",M.push(ft("metadata.veltFolderId","==",g));let ie=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];if(j=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ie})}),!a?.agentFields?.length){let _e=[...M,ft("viewedByUserIds","array-contains",l)],ae=[yr(..._e),po("lastUpdated","desc"),po("createdAt","desc")];q=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ae})})}}else if(_.isOrgMode){t=d??"";let ie=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];if(j=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ie})}),!a?.agentFields?.length){let _e=[...M,ft("viewedByUserIds","array-contains",l)],ae=[yr(..._e),po("lastUpdated","desc"),po("createdAt","desc")];q=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ae})})}}else{t="result";let ie=[];for(let ue=0;ue<i.length;ue+=this.LISTENER_BATCH_SIZE)ie.push(i.slice(ue,ue+this.LISTENER_BATCH_SIZE));let _e=ie.map(ue=>X(this,null,function*(){let Ie=[...M,ft("metadata.documentId","in",ue),...g?[ft("metadata.veltFolderId","==",g)]:[]],fe=[yr(...Ie),po("lastUpdated","desc"),po("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:fe})})}));if(j=(yield Promise.allSettled(_e)).reduce((ue,Ie)=>ue+(Ie.status==="fulfilled"&&Ie.value||0),0),!a?.agentFields?.length){let ue=ie.map(fe=>X(this,null,function*(){let we=[...M,ft("metadata.documentId","in",fe),...g?[ft("metadata.veltFolderId","==",g)]:[],ft("viewedByUserIds","array-contains",l)],Ae=[yr(...we),po("lastUpdated","desc"),po("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:Ae})})}));q=(yield Promise.allSettled(ue)).reduce((fe,we)=>fe+(we.status==="fulfilled"&&we.value||0),0)}}return{data:{[t]:{total:j,unread:j-q}}}}catch(t){return this.loggingService.catch("Error in CommentService getAggregateCounts: ",t),null}})}filterGhostComments$(e,t,i){try{return e?this.commentService.getGhostCommentAnnotationMap$().pipe(ge(a=>{if(!a)return e;let l=this.buildGhostCommentAnnotationMap(a),c=this.groupGhostCommentsByModeId(l,t,i);return this.adjustCountsForGhostComments(e,c),e})):de(null)}catch(a){return this.loggingService.catch("Error in CommentService filterGhostComments: ",a),de(null)}}buildGhostCommentAnnotationMap(e){let t={};return Object.keys(e).forEach(i=>{let a=this.commentService.getAnnotationById(i);a&&(t[i]=a)}),t}groupGhostCommentsByModeId(e,t,i){try{let a={};return Object.values(e).forEach(l=>{let c=this.getModeIdForAnnotation(l,t,i);c&&(a[c]||(a[c]=[]),a[c].push(l))}),a}catch(a){return this.loggingService.catch("Error in CommentService groupGhostCommentsByModeId: ",a),{}}}getModeIdForAnnotation(e,t,i){try{return t.isOrgMode?e?.metadata?.clientOrganizationId||null:t.isFolderMode?e?.metadata?.folderId||null:t.isBatchMode?i.includes(e?.metadata?.documentId??"")?"result":null:e?.metadata?.clientDocumentId||null}catch(a){return this.loggingService.catch("Error in CommentService getModeIdForAnnotation: ",a),null}}adjustCountsForGhostComments(e,t){try{if(typeof e?.data!="object")return;let a=this.authService.getUser()?.userSnippylyId;Object.keys(e.data||{}).forEach(l=>{let c=t[l];if(!(!c||!e?.data?.[l]?.total)&&(e.data[l].total=Math.max(0,e.data[l].total-c.length),a)){let d=c.filter(g=>g?.viewedByUserIds&&!g?.viewedByUserIds?.includes(a));d.length>0&&(e.data[l].unread=Math.max(0,e.data[l].unread-d.length))}})}catch(i){this.loggingService.catch("Error in CommentService adjustCountsForGhostComments: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(Ke),Z(Vn),Z(st),Z(Lt),Z(kn),Z(k),Z(Re),Z(Oa))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ZU=(()=>{let o=class o{constructor(e){this.loggingService=e,this.enabledSignal=De(!1),this.onTargetEditStart=null,this.onTargetEditCommit=null;try{this.enabled$=gde(this.enabledSignal).pipe(bt())}catch(t){this.loggingService.catch("Error in SuggestionModeService constructor: ",t),this.enabled$=new Vt}}enable(e){try{this.onTargetEditStart=e?.onTargetEditStart??null,this.onTargetEditCommit=e?.onTargetEditCommit??null,this.enabledSignal.set(!0)}catch(t){this.loggingService.catch("Error in SuggestionModeService enable: ",t)}}disable(){try{this.onTargetEditStart=null,this.onTargetEditCommit=null,this.enabledSignal.set(!1)}catch(e){this.loggingService.catch("Error in SuggestionModeService disable: ",e)}}isEnabled(){try{return this.enabledSignal()}catch(e){return this.loggingService.catch("Error in SuggestionModeService isEnabled: ",e),!1}}getOnTargetEditStart(){try{return this.onTargetEditStart}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditStart: ",e),null}}getOnTargetEditCommit(){try{return this.onTargetEditCommit}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditCommit: ",e),null}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var JU=(()=>{let o=class o{constructor(e){this.loggingService=e,this.snapshots=new Map}captureFromGetter(e,t){try{if(!e||typeof t!="function")return!1;let i;try{i=t()}catch(a){return dm()&&this.loggingService.catch(`[velt] Suggestion target "${e}" getter threw: `,a),!1}return this.captureValue(e,i)}catch(i){return this.loggingService.catch("Error in SuggestionSnapshotService captureFromGetter: ",i),!1}}captureValue(e,t){try{if(!e)return!1;let i;try{i=structuredClone(t)}catch(a){return dm()&&this.loggingService.catch(`[velt] Suggestion target "${e}" snapshot failed (value not cloneable). Cause: structuredClone rejected the value (cyclic refs, DOM nodes, or functions are common culprits). Fix: ensure your getter returns plain JSON-serializable data.`,a),!1}return this.snapshots.set(e,i),!0}catch(i){return this.loggingService.catch("Error in SuggestionSnapshotService captureValue: ",i),!1}}getSnapshot(e){try{return this.snapshots.has(e)?this.snapshots.get(e):void 0}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService getSnapshot: ",t);return}}hasSnapshot(e){try{return this.snapshots.has(e)}catch(t){return this.loggingService.catch("Error in SuggestionSnapshotService hasSnapshot: ",t),!1}}clearSnapshot(e){try{this.snapshots.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService clearSnapshot: ",t)}}clearAllSnapshots(){try{this.snapshots.clear()}catch(e){this.loggingService.catch("Error in SuggestionSnapshotService clearAllSnapshots: ",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var GS=(()=>{let o=class o{constructor(e,t,i){this.loggingService=e,this.modeService=t,this.snapshotService=i,this.registry=new Map,this.warnedUnstableIds=new Set,this.actionsService=null}registerTarget(e,t){try{if(!e||typeof t!="function")return;this.warnIfUnstableId(e);let i=this.registry.get(e)??{};i.getter=t,this.registry.set(e,i)}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService registerTarget: ",i)}}unregisterTarget(e){try{let t=this.registry.get(e);if(!t)return;delete t.getter,t.node||this.registry.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService unregisterTarget: ",t)}}getGetter(e){try{return this.registry.get(e)?.getter}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getGetter: ",t);return}}setActionsService(e){try{this.actionsService=e}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService setActionsService: ",t)}}getNode(e){try{if(!e)return;let t=this.registry.get(e)?.node;if(t&&t.isConnected)return t;let i=this.queryAll(e);if(i.length===0)return;i.length>1&&this.warnDuplicateId(e,i.length);let a=i[0],l=this.registry.get(e)??{};return l.node=a,this.registry.set(e,l),a}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getNode: ",t);return}}getFallbackValue(e){try{let t=this.getNode(e);if(!t)return{hasValue:!1};let i=t.textContent??"";return i.length>0?{hasValue:!0,value:i}:{hasValue:!1}}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService getFallbackValue: ",t),{hasValue:!1}}}isRegistered(e){try{return this.registry.get(e)?.getter?!0:!!this.getNode(e)}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isRegistered: ",t),!1}}countTaggedElements(e){try{let t=e??this.rootEl??document.body;return t?t.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).length:0}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService countTaggedElements: ",t),0}}startObserving(e=document.body){try{if(this.observer)return;this.rootEl=e,this.scanAndRefresh(e),this.observer=new MutationObserver(()=>{try{this.scanAndRefresh(this.rootEl??document.body)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService observer callback: ",t)}}),this.observer.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[F.ATTRIBUTES.VELT_SUGGESTION_TARGET]}),this.installDelegatedListeners(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService startObserving: ",t)}}stopObserving(){try{this.observer?.disconnect(),this.observer=void 0,this.rootEl&&this.removeDelegatedListeners(this.rootEl),this.rootEl=void 0}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService stopObserving: ",e)}}clear(){try{this.registry.clear(),this.warnedUnstableIds.clear()}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService clear: ",e)}}installDelegatedListeners(e){try{this.boundFocusIn=t=>this.handleFocusIn(t),this.boundChange=t=>this.handleChange(t),this.boundFocusOut=t=>this.handleFocusOut(t),e.addEventListener("focusin",this.boundFocusIn,!0),e.addEventListener("change",this.boundChange,!0),e.addEventListener("focusout",this.boundFocusOut,!0)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService installDelegatedListeners: ",t)}}removeDelegatedListeners(e){try{this.boundFocusIn&&e.removeEventListener("focusin",this.boundFocusIn,!0),this.boundChange&&e.removeEventListener("change",this.boundChange,!0),this.boundFocusOut&&e.removeEventListener("focusout",this.boundFocusOut,!0),this.boundFocusIn=void 0,this.boundChange=void 0,this.boundFocusOut=void 0}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService removeDelegatedListeners: ",t)}}handleFocusIn(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t)return;this.captureSnapshotForTarget(t.targetId,t.element);let i=this.snapshotService.getSnapshot(t.targetId),a={targetId:t.targetId,oldValue:i,newValue:i,element:t.element},l=this.modeService.getOnTargetEditStart();if(l)try{l(a)}catch(c){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditStart customer callback threw: ",c)}this.actionsService?.triggerAction(Tl.TARGET_EDIT_START,{details:a,timestamp:Date.now()})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusIn: ",t)}}handleChange(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||!this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleChange: ",t)}}handleFocusOut(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusOut: ",t)}}isAtomicCommitTarget(e){try{if(e instanceof HTMLSelectElement)return!0;if(e instanceof HTMLInputElement){let t=(e.type||"").toLowerCase();return t==="checkbox"||t==="radio"}return!1}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isAtomicCommitTarget: ",t),!1}}processCommit(e,t){try{let i=this.snapshotService.getSnapshot(e),a=this.readElementValue(e,t);if(dr(i,a))return;let l={targetId:e,oldValue:i,newValue:a,element:t},c=this.modeService.getOnTargetEditCommit(),d=!1;if(c){let u=null;try{u=c(l)}catch(_){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditCommit customer callback threw: ",_)}u&&(d=!0,this.invokeAutoCommit({targetId:e,newValue:a,summary:u.summary,metadata:u.metadata}))}let g=u=>X(this,null,function*(){return d?null:this.invokeAutoCommit({targetId:e,newValue:a,summary:u?.summary,metadata:u?.metadata})});this.actionsService?.triggerAction(Tl.TARGET_EDIT_COMMIT,{details:l,commitSuggestion:g,timestamp:Date.now()})}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService processCommit: ",i)}}invokeAutoCommit(e){try{return this.actionsService?this.actionsService.commitSuggestion(e).catch(t=>(dm()&&this.loggingService.catch(`[velt] auto-commit for "${e.targetId}" rejected: `,t),null)):(dm()&&this.loggingService.log("[velt] auto-commit skipped: actions service not wired. SuggestionActionsService constructor should call registry.setActionsService(this)."),Promise.resolve(null))}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService invokeAutoCommit: ",t),Promise.resolve(null)}}captureSnapshotForTarget(e,t){try{let i=this.registry.get(e);if(i?.getter){this.snapshotService.captureFromGetter(e,i.getter);return}let a=this.readElementValue(e,t);this.snapshotService.captureValue(e,a)}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService captureSnapshotForTarget: ",i)}}readElementValue(e,t){try{let i=this.registry.get(e);if(i?.getter)try{return i.getter()}catch{return}if(t instanceof HTMLInputElement){let a=(t.type||"").toLowerCase();return a==="checkbox"||a==="radio"?t.checked:a==="number"||a==="range"?Number.isNaN(t.valueAsNumber)?t.value:t.valueAsNumber:t.value}return t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t.value:(t instanceof HTMLElement&&t.isContentEditable,t.textContent??"")}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService readElementValue: ",i);return}}findTaggedAncestor(e){try{if(!(e instanceof Element))return null;let t=e.closest(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`);if(!t)return null;let i=t.getAttribute(F.ATTRIBUTES.VELT_SUGGESTION_TARGET);return i?{element:t,targetId:i}:null}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService findTaggedAncestor: ",t),null}}queryAll(e){try{let t=window.CSS?.escape?window.CSS.escape(e):e.replace(/"/g,'\\"');return Array.from(document.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}="${t}"]`))}catch{return[]}}scanAndRefresh(e){try{e.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).forEach(i=>{let a=i.getAttribute(F.ATTRIBUTES.VELT_SUGGESTION_TARGET);if(!a)return;let l=this.registry.get(a)??{};(!l.node||!l.node.isConnected)&&(l.node=i,this.registry.set(a,l))})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService scanAndRefresh: ",t)}}warnIfUnstableId(e){try{if(!dm()||this.warnedUnstableIds.has(e))return;let t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(e),i=/\d{10,}/.test(e);(t||i)&&(this.warnedUnstableIds.add(e),this.loggingService.catch(`[velt] Target id "${e}" appears unstable. Cause: contains a UUID or timestamp shape \u2014 these typically change across re-renders. Fix: use a stable customer-owned id (the same one you use in your state). Docs: velt.dev/docs/suggestions/target-ids`,new Error("UNSTABLE_TARGET_ID")))}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService warnIfUnstableId: ",t)}}warnDuplicateId(e,t){try{if(!dm())return;this.loggingService.catch(`[velt] Duplicate target id "${e}" \u2014 ${t} elements share this id. Cause: the same ${F.ATTRIBUTES.VELT_SUGGESTION_TARGET} appears on multiple DOM nodes. Fix: ensure each suggestable element has a unique id. Velt is using the first registered element. Docs: velt.dev/docs/suggestions/target-ids`,new Error("DUPLICATE_TARGET_ID"))}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService warnDuplicateId: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(k),Z(ZU),Z(JU))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var gl=(()=>{let o=class o{constructor(e,t,i,a,l,c){this.loggingService=e,this.modeService=t,this.snapshotService=i,this.targetRegistry=a,this.commentService=l,this.commonDbService=c,this.actionSubjects=new Map,this.observingActive=!1;try{this.targetRegistry.setActionsService(this)}catch(d){this.loggingService.catch("Error in SuggestionActionsService constructor: ",d)}}enableSuggestionMode(e){try{this.modeService.enable(e),this.startObservingIfNeeded(),this.warnIfNoTaggedElements()}catch(t){this.loggingService.catch("Error in SuggestionActionsService enableSuggestionMode: ",t)}}disableSuggestionMode(){try{this.modeService.disable(),this.stopObservingIfNeeded()}catch(e){this.loggingService.catch("Error in SuggestionActionsService disableSuggestionMode: ",e)}}isSuggestionModeEnabled(){try{return this.modeService.isEnabled()}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled: ",e),!1}}isSuggestionModeEnabled$(){try{return this.modeService.enabled$}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled$: ",e),new Vt}}registerTarget(e){try{if(!e?.targetId||typeof e?.getter!="function")return;this.targetRegistry.registerTarget(e.targetId,e.getter)}catch(t){this.loggingService.catch("Error in SuggestionActionsService registerTarget: ",t)}}unregisterTarget(e){try{this.targetRegistry.unregisterTarget(e)}catch(t){this.loggingService.catch("Error in SuggestionActionsService unregisterTarget: ",t)}}startSuggestion(e){try{let t=this.targetRegistry.getGetter(e);if(t){this.snapshotService.captureFromGetter(e,t);return}let i=this.targetRegistry.getFallbackValue(e);i.hasValue?this.snapshotService.captureValue(e,i.value):this.loggingService.warn(`[velt] startSuggestion: target "${e}" not registered. Cause: no getter via registerTarget() and no textContent fallback. Fix: tag the element with data-velt-suggestion-target and register a getter via registerTarget(). Docs: velt.dev/docs/suggestions/targets`)}catch(t){this.loggingService.catch("Error in SuggestionActionsService startSuggestion: ",t)}}commitSuggestion(e){return new Promise((t,i)=>{try{if(!e?.targetId){i(new Error("INVALID_CONFIG"));return}if(!this.modeService.isEnabled()){this.loggingService.warn("[velt] commitSuggestion called while suggestion mode is disabled. Cause: enableSuggestionMode() has not been called (or disableSuggestionMode() was called). Fix: call enableSuggestionMode() before commit, or branch on isSuggestionModeEnabled() in your onSave handler. Docs: velt.dev/docs/suggestions/mode"),i(new Error("MODE_NOT_SUGGESTING"));return}if(!this.targetRegistry.isRegistered(e.targetId)){this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" not registered. Cause: no element has data-velt-suggestion-target="${e.targetId}" and no registerTarget() call provided a getter. Fix: tag the element or register a getter at app boot. Docs: velt.dev/docs/suggestions/targets`),i(new Error("TARGET_NOT_REGISTERED"));return}if(!this.snapshotService.hasSnapshot(e.targetId)){let u=this.targetRegistry.getGetter(e.targetId);if(u){if(!this.snapshotService.captureFromGetter(e.targetId,u)){i(new Error("SNAPSHOT_FAILED"));return}}else{let _=this.targetRegistry.getFallbackValue(e.targetId);if(_.hasValue)this.snapshotService.captureValue(e.targetId,_.value);else{this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" requires registerTarget() for complex values. Cause: complex objects need a getter so the SDK can deep-clone the snapshot. Fix: call velt.getSuggestionElement().registerTarget("${e.targetId}", () => yourState.${e.targetId}) at app boot. Docs: velt.dev/docs/suggestions/getter`),i(new Error("NO_GETTER_FOR_COMPLEX"));return}}}let a=this.snapshotService.getSnapshot(e.targetId),l=e.newValue;if(dr(a,l)){this.loggingService.warn(`[velt] commitSuggestion: no change detected for target "${e.targetId}". Cause: oldValue and newValue are deeply equal. Fix: only call commitSuggestion when the customer actually changed the value. Docs: velt.dev/docs/suggestions/edge-cases`),i(new Error("NO_CHANGE_TO_SUGGEST"));return}let c=new Vr;c.type="suggestion",c.suggestion={status:"pending",targetId:e.targetId,targetType:"custom",oldValue:a,newValue:l,summary:e.summary??null,driftDetected:!1,rejectReason:null,resolvedBy:null,resolvedAt:null},c.metadata=e.metadata??{};let d=e.summary??`[${e.targetId}] changed`,g=new oc;g.commentText=d,g.commentHtml=`<p>${this.escapeHtml(d)}</p>`,c.comments=[g],this.commentService.addComment(void 0,void 0,void 0,void 0,!1,[],void 0,void 0,void 0,void 0,void 0,void 0,void 0,u=>{try{this.snapshotService.clearSnapshot(e.targetId),this.projectAndTrigger(Tl.SUGGESTION_CREATED,u.annotation),t({id:u.annotation.annotationId})}catch(_){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion callback: ",_),i(_)}},void 0,void 0,c,void 0,void 0,!0,void 0,void 0,"internal",void 0)}catch(a){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion: ",a),i(a)}})}getSuggestions(e){try{let t=this.commentService.getCommentAnnotationsOnCurrentOrganizationAndDocument()??[],i=[];for(let a of t){if(a.type!=="suggestion"||!a.suggestion)continue;let l=this.projectAnnotationToSuggestion(a);l&&this.matchesFilter(l,e)&&i.push(l)}return i}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions: ",t),[]}}getSuggestions$(e){try{return this.commentService.getCommentAnnotationsOnCurrentOrganizationAndDocument$().pipe(ge(t=>{let i=[];for(let a of t??[]){if(a.type!=="suggestion"||!a.suggestion)continue;let l=this.projectAnnotationToSuggestion(a);l&&this.matchesFilter(l,e)&&i.push(l)}return i}),bt(Zt))}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions$: ",t),new Vt}}getPendingSuggestion(e){try{if(!e)return null;let t=this.getSuggestions({targetId:e,status:"pending"});return t.length===0?null:t.sort((i,a)=>(a.createdAt??0)-(i.createdAt??0))[0]}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion: ",t),null}}getPendingSuggestion$(e){try{return e?this.getSuggestions$({targetId:e,status:"pending"}).pipe(ge(t=>t.length===0?null:t.sort((i,a)=>(a.createdAt??0)-(i.createdAt??0))[0]),bt(Zt)):new Vt}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion$: ",t),new Vt}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in SuggestionActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in SuggestionActionsService onAction: ",t),de(null)}}projectAndTrigger(e,t){try{if(!t||t.type!=="suggestion"||!t.suggestion)return;let i=this.projectAnnotationToSuggestion(t);if(!i)return;let a=this.timestamp;switch(e){case Tl.SUGGESTION_CREATED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_CREATED,l);break}case Tl.SUGGESTION_APPROVED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_APPROVED,l);break}case Tl.SUGGESTION_REJECTED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_REJECTED,l);break}case Tl.SUGGESTION_STALE:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_STALE,l);break}}}catch(i){this.loggingService.catch("Error in SuggestionActionsService projectAndTrigger: ",i)}}projectAnnotationToSuggestion(e){try{let t=e.suggestion;if(!t)return;let i={annotationId:e.annotationId,targetId:t.targetId,targetType:t.targetType,oldValue:t.oldValue,newValue:t.newValue,summary:t.summary,metadata:e.metadata??{},driftDetected:!!t.driftDetected,createdBy:e.from,createdAt:e.createdAt??0};switch(t.status){case"pending":return y(h({},i),{status:"pending",rejectReason:null,resolvedBy:null,resolvedAt:null});case"accepted":case"apply_failed":return y(h({},i),{status:t.status,rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp});case"rejected":return y(h({},i),{status:"rejected",rejectReason:t.rejectReason??null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp});case"stale":return y(h({},i),{status:"stale",rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt});default:return}}catch(t){this.loggingService.catch("Error in SuggestionActionsService projectAnnotationToSuggestion: ",t);return}}startObservingIfNeeded(){try{if(this.observingActive)return;this.observingActive=!0,this.targetRegistry.startObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService startObservingIfNeeded: ",e)}}stopObservingIfNeeded(){try{if(!this.observingActive)return;this.observingActive=!1,this.targetRegistry.stopObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService stopObservingIfNeeded: ",e)}}warnIfNoTaggedElements(){try{this.targetRegistry.countTaggedElements()===0&&this.loggingService.warn('[velt] No suggestable elements found on this page. Cause: no DOM elements have a data-velt-suggestion-target attribute. Fix: tag at least one element with data-velt-suggestion-target="your.id" before enabling suggestion mode. Docs: velt.dev/docs/suggestions/getting-started')}catch(e){this.loggingService.catch("Error in SuggestionActionsService warnIfNoTaggedElements: ",e)}}get timestamp(){return this.commonDbService.getServerTimestamp()}matchesFilter(e,t){try{return t?!(t.targetId&&e.targetId!==t.targetId||t.status&&!(Array.isArray(t.status)?t.status:[t.status]).includes(e.status)):!0}catch(i){return this.loggingService.catch("Error in SuggestionActionsService matchesFilter: ",i),!1}}escapeHtml(e){try{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}catch(t){return this.loggingService.catch("Error in SuggestionActionsService escapeHtml: ",t),""}}};o.\u0275fac=function(t){return new(t||o)(Z(k),Z(ZU),Z(JU),Z(GS),Z(Re),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Rn=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j){this.analyticsService=e,this.authService=t,this.commentService=i,this.commentViewsService=a,this.contactService=l,this.customFilterService=c,this.docService=d,this.iamService=g,this.loggingService=u,this.metadataService=_,this.reactionService=w,this.commonDbService=A,this.suggestionActions=M,this.targetRegistry=j,this.actionSubjects=new Map,this.defaultSource="internal",this.isUserAdmin=!1,this.subscriptions=[],this.loggingService.log("%c[WB] Creating CLASS: CommentActionsService","color: blue;");try{this.commentService.setCommentActionsService(this),this.iamService.isUserAdmin$().subscribe(q=>{this.isUserAdmin=q})}catch(q){this.loggingService.catch("Error in CommentActionsService constructor: ",q)}}addCommentAnnotation(l,c){return X(this,arguments,function*({annotation:e,options:t,visibility:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),i){if(i.type==="restricted"){let g=this.authService.getUser();g?.userId&&(i=ap(i,g.userId))}if(i.type==="organizationPrivate"&&!i.organizationId){let g=this.docService.getOrganizationConfig();g?.clientOrganizationId&&(i=y(h({},i),{organizationId:g.clientOrganizationId}))}let d=lp(i);d.length>0&&(e.context||(e.context={}),e.context._setAccessFields=d,e.visibilityConfig=h(h({type:i.type},i.organizationId&&{organizationId:i.organizationId}),i.userIds&&{userIds:i.userIds}))}return new Promise(d=>{this.commentService.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,g=>X(this,null,function*(){let u=yield this.getAddCommentAnnotationEventFromCommentAddEventData(g);d(u)}),void 0,void 0,e,void 0,void 0,void 0,void 0,void 0,a)})}catch(d){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",d),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return X(this,null,function*(){try{let t=yield this.metadataService.getGlobalMetadata();return{commentAnnotation:this.commentService.getCommentAnnotationForClient(e?.annotation),annotationId:e?.annotation?.annotationId,metadata:t,addContext:e?.addContext,elementRef:e?.elementRef}}catch(t){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",t),null}})}triggerAddCommentAnnotationEvent(e){try{this.triggerAction(er.ADD_COMMENT_ANNOTATION,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",t)}}getAddCommentAnnotationDraftEventFromCommentAddEventData(e){return X(this,null,function*(){try{return{metadata:yield this.metadataService.getGlobalMetadata(),addContext:e?.addContext}}catch(t){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",t),null}})}triggerAddCommentAnnotationDraftEvent(e){try{this.triggerAction(er.ADD_COMMENT_ANNOTATION_DRAFT,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationDraftEvent: ",t)}}triggerAddCommentDraftEventForAnnotation(e,t){return X(this,null,function*(){try{if(!e?.annotationId||!t)return;let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),comment:t,metadata:i};this.triggerAction(er.ADD_COMMENT_DRAFT,a)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAddCommentDraftEventForAnnotation: ",i)}})}triggerAnnotationNotFoundError(e){try{this.loggingService.catch("Annotation not found:","The annotation with the given id was not found.")}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAnnotationNotFoundError: ",t)}}deleteCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteCommentAnnotation","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let d=this.commentService.getAnnotationById(e,t);if(d){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===d?.from?.userId){this.commentService.deleteCommentPinAnnotation(d);let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:d.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:u};return this.triggerAction(er.DELETE_COMMENT_ANNOTATION,_),_}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete it.")}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteCommentAnnotation: ",c),null}})}updatePriority(l,c){return X(this,arguments,function*({annotationId:e,priority:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updatePriority","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g=JSON.parse(JSON.stringify(g));let u=g.priority?JSON.parse(JSON.stringify(g.priority)):null;u&&t&&u?.id===t?.id?g.priority=void 0:g.priority=t,this.commentService.saveComment(g,{type:Tt.PRIORITY_CHANGED,newPriority:t,oldPriority:u});let _=yield this.metadataService.getGlobalMetadata(),w={newPriority:t,oldPriority:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};return this.triggerAction(er.UPDATE_PRIORITY,w),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIORITY_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldPriority:g.priority,newPriority:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),w}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",d),null}})}updateStatus(l,c){return X(this,arguments,function*({annotationId:e,status:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateStatus","color: green;");let d=this.authService.getUser();if(!d)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g=JSON.parse(JSON.stringify(g));let u=g.status?JSON.parse(JSON.stringify(g.status)):null;g.status=t,g.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(g,{type:Tt.STATUS_CHANGED,newStatus:t,oldStatus:u});let _=yield this.metadataService.getGlobalMetadata(),w={newStatus:t,oldStatus:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};return this.triggerAction(er.UPDATE_STATUS,w),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldStatus:u,newStatus:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,commentAnnotationCreatedAt:g.createdAt}),w}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",d),null}})}updateAccess(l,c){return X(this,arguments,function*({annotationId:e,accessMode:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateAccess","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g)if(this.commentService.isPrivateCommentAllowed()){g=JSON.parse(JSON.stringify(g));let u=g.iam?.accessMode;g.iam.accessMode=t,this.commentService.saveComment(g,{type:Tt.ACCESS_MODE_CHANGED,newAccessMode:t,oldAccessMode:u});let _=yield this.metadataService.getGlobalMetadata(),w={newAccessMode:t,oldAccessMode:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};switch(this.triggerAction(er.UPDATE_ACCESS,w),t){case ya.PRIVATE:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:ya.PRIVATE,source:a??this.defaultSource});break;case ya.PUBLIC:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:ya.PUBLIC,source:a??this.defaultSource});break;default:break}return w}else this.loggingService.catch("Access Denied","You must be an admin to update the access mode of the comment.");else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updateAccess: ",d),null}})}resolveCommentAnnotation(i){return X(this,arguments,function*({annotationId:e,options:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: resolveCommentAnnotation","color: green;");let a=this.authService.getUser();if(!a)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let l=this.commentService.getAnnotationById(e,t);if(l){l=JSON.parse(JSON.stringify(l));let c=this.customFilterService.resolvedStatus,d=l.status?JSON.parse(JSON.stringify(l.status)):null;c&&(l.status=c,l.statusUpdatedByUserId=a?.userId,this.commentService.saveComment(l,{type:Tt.STATUS_CHANGED,newStatus:c,oldStatus:d}));let g=yield this.metadataService.getGlobalMetadata(),u={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(l),metadata:g};return this.triggerAction(er.RESOLVE_COMMENT,u),u}else this.triggerAnnotationNotFoundError(e);return null}catch(a){return this.loggingService.catch("Error in CommentActionsService resolveCommentAnnotation: ",a),null}})}getLink(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){let d=this.commentService.getCommentUrl(c)??null,g=yield this.metadataService.getGlobalMetadata();return{link:d,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:g}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService getLink: ",c),null}})}copyLink(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let c=yield this.getLink({annotationId:e,options:t},i);if(c?.link){ts(c.link),this.commentService.setCopyLink(c.link),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_LINK_COPIED,{annotationId:e,commentType:this.commentService.getCommentType(c.commentAnnotation),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource,link:c.link});let d=yield this.metadataService.getGlobalMetadata(),g={link:c.link,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c.commentAnnotation),metadata:d};return this.triggerAction(er.COPY_LINK,g),g}return null}catch(c){return this.loggingService.catch("Error in CommentActionsService copyLink: ",c),null}})}addComment(g,u){return X(this,arguments,function*({annotationId:e,comment:t,assignedTo:i,assigned:a,options:l,visibility:c},d){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let _=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_){let w=this.commentService.getAnnotationById(e,l),A=w?.comments?.length?Tt.ADDED:Tt.NEWLY_ADDED;if(w){w.status.type==="terminal"&&(w.status=this.customFilterService.defaultStatus);let M=new oc;M=h(h({},M),t),M.lastUpdated=new Date,M.attachments||(M.attachments=[]),M.attachments=M.attachments.filter(ae=>ae?.attachmentId),M.createdAt=this.timestamp,M.from=_,i&&(w.assignedTo=i),this.commentService.saveComment(w,{type:A,updatedComment:M,assigned:a,visibility:c,_dispatchAddCommentEvent:!0});let j=y(h({},w),{comments:[...w.comments||[],M]}),q=yield this.buildAddCommentEvent({annotation:j,newComment:M});if(!q)return null;let ie=t?.commentId,_e=this.calculateCommentThreadIndex(t,w);return this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:ie,commentThreadIndex:_e,commentType:this.commentService.getCommentType(w),commentMode:this.commentService.getCommentMode(),source:d??this.defaultSource,commentAnnotationCreatedAt:w.createdAt,taggedClientUserIds:M.taggedUserContacts?.map(ae=>ae.contact?.userId).filter(ae=>!!ae),taggedSnippylyUserIds:M.taggedUserContacts?.filter(ae=>!!w?.metadata?.apiKey&&!!ae.contact?.userId).map(ae=>hd(w.metadata.apiKey,ae.contact.userId))}),q}else this.triggerAnnotationNotFoundError(e)}return null}catch(_){return this.loggingService.catch("Error in CommentActionsService addComment: ",_),null}})}buildAddCommentEvent(i){return X(this,arguments,function*({annotation:e,newComment:t}){try{let a=yield this.metadataService.getGlobalMetadata();return{annotationId:e.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:a}}catch(a){return this.loggingService.catch("Error in CommentActionsService buildAddCommentEvent: ",a),null}})}triggerAddCommentEvent(i){return X(this,arguments,function*({annotation:e,newComment:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: triggerAddCommentEvent","color: green;");let a=yield this.buildAddCommentEvent({annotation:e,newComment:t});return a&&this.triggerAction(er.ADD_COMMENT,a),a}catch(a){return this.loggingService.catch("Error in CommentActionsService triggerAddCommentEvent: ",a),null}})}approveCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: approveCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){c.approved=!0,this.commentService.saveComment(c,{type:Tt.APPROVED}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource});let d=yield this.metadataService.getGlobalMetadata(),g={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:d};return this.triggerAction(er.APPROVE_COMMENT_ANNOTATION,g),g}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService approveComment: ",c),null}})}acceptCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=F.CommentAcceptStatus,c.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(c,{type:Tt.ACCEPTED,oldStatus:g,newStatus:F.CommentAcceptStatus});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:u,actionUser:d,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(er.ACCEPT_COMMENT_ANNOTATION,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",c),null}})}rejectCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=F.CommentRejectStatus,c.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(c,{type:Tt.REJECTED,oldStatus:g,newStatus:F.CommentRejectStatus});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:u,actionUser:d,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(er.REJECT_COMMENT_ANNOTATION,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",c),null}})}acceptSuggestion(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptSuggestion","color: green;");let c=this.authService.getUser();if(!c)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let d=this.commentService.getAnnotationById(e,t);if(!d)return this.triggerAnnotationNotFoundError(e),null;if(!(d.type==="suggestion"||d.commentType==="suggestion")||!d.suggestion||d.suggestion.status!=="pending")return null;let g=d.suggestion.targetId;if(g){if(!this.targetRegistry.getNode(g)){d.suggestion.status="stale",d.suggestion.resolvedBy=c,d.suggestion.resolvedAt=this.timestamp,d.statusUpdatedByUserId=c?.userId,this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"stale",targetId:g}),this.commentService.updateComment(d),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_STALE,d);let j=yield this.metadataService.getGlobalMetadata(),q={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:j,actionUser:c};return this.triggerAction(er.SUGGESTION_ACCEPTED,q),q}let A=this.targetRegistry.getGetter(g),M=!1;if(A)try{let j=A();M=!dr(j,d.suggestion.oldValue)}catch{M=!1}d.suggestion.driftDetected=M}d.suggestion.status="accepted",d.suggestion.resolvedBy=c,d.suggestion.resolvedAt=this.timestamp,d.statusUpdatedByUserId=c?.userId,d.type="comment",d?.agent?.agentFields&&typeof d.agent.agentFields=="object"&&Array.isArray(d.agent.agentFields)&&(d.agent.agentFields=d.agent.agentFields.filter(w=>w!=="status:suggestion"),d.agent.agentFields.includes("status:accepted")||d.agent.agentFields.push("status:accepted")),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"accepted",targetId:g,driftDetected:d.suggestion?.driftDetected}),this.commentService.saveComment(d,{type:Tt.SUGGESTION_ACCEPTED}),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_APPROVED,d),this.analyticsService.trackEvent(Y.Events.Comments.SUGGESTION_ACCEPTED,{annotationId:e});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:u,actionUser:c};return this.triggerAction(er.SUGGESTION_ACCEPTED,_),_}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptSuggestion: ",c),null}})}rejectSuggestion(l,c){return X(this,arguments,function*({annotationId:e,reason:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectSuggestion","color: green;");let d=this.authService.getUser();if(!d)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(!g)return this.triggerAnnotationNotFoundError(e),null;if(!(g.type==="suggestion"||g.commentType==="suggestion")||!g.suggestion||g.suggestion.status!=="pending")return null;g.suggestion.status="rejected",g.suggestion.rejectReason=t??null,g.suggestion.resolvedBy=d,g.suggestion.resolvedAt=this.timestamp,g.statusUpdatedByUserId=d?.userId,g.type="comment",g?.agent?.agentFields&&typeof g.agent.agentFields=="object"&&Array.isArray(g.agent.agentFields)&&(g.agent.agentFields=g.agent.agentFields.filter(w=>w!=="status:suggestion"),g.agent.agentFields.includes("status:rejected")||g.agent.agentFields.push("status:rejected")),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"rejected",targetId:g.suggestion.targetId}),this.commentService.saveComment(g,{type:Tt.SUGGESTION_REJECTED}),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_REJECTED,g),this.analyticsService.trackEvent(Y.Events.Comments.SUGGESTION_REJECTED,{annotationId:e});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:u,actionUser:d,rejectReason:t??null};return this.triggerAction(er.SUGGESTION_REJECTED,_),_}catch(d){return this.loggingService.catch("Error in CommentActionsService rejectSuggestion: ",d),null}})}toggleNotificationSubscription(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=It(d.userId);if(g){c.subscribedUsers||(c.subscribedUsers={}),c.unsubscribedUsers||(c.unsubscribedUsers={});let u,_=!1;if(c?.unsubscribedUsers?.[g])_=!1;else if(c?.subscribedUsers?.[g])_=!0;else{let M=this.contactService.getCurrentOrganizationUserIAM();if(M){let j=M.groups||{};Object.keys(j).forEach(q=>{c?.subscribedGroups?.[q]&&(_=!0)})}}if(i==="subscribe"||!i&&!_)delete c.unsubscribedUsers[g],c.subscribedUsers[g]={user:d,type:"manual"},u=Tt.SUBSCRIBED;else if(i==="unsubscribe"||!i&&_)delete c.subscribedUsers[g],c.unsubscribedUsers[g]={user:d,type:"manual"},u=Tt.UNSUBSCRIBED;else return null;this.commentService.saveComment(c,{type:u});let w=yield this.metadataService.getGlobalMetadata(),A={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:w};return u===Tt.SUBSCRIBED?this.triggerAction(er.SUBSCRIBE_COMMENT_ANNOTATION,A):this.triggerAction(er.UNSUBSCRIBE_COMMENT_ANNOTATION,A),A}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",c),null}})}assignUser(l,c){return X(this,arguments,function*({annotationId:e,assignedTo:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: assignUser","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g.assignedTo=t,this.commentService.saveComment(g,{type:Tt.ASSIGNED,assignedTo:t});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,assignedTo:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:u};return this.triggerAction(er.ASSIGN_USER,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ASSIGNED,{annotationId:e,commentType:this.commentService.getCommentType(g),commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,assignedToUserId:t?.userId}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService assignUser: ",d),null}})}getComment(i){return X(this,arguments,function*({annotationId:e,options:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getComment","color: green;");let a=this.commentService.getAnnotationById(e,t);return a?a.comments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(a){return this.loggingService.catch("Error in CommentActionsService getComment: ",a),[]}})}updateOrDeleteComment(e,t,i,a,l){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateOrDeleteComment","color: green;"),t?.commentText?.trim()||t?.attachments?.length||t?.recorders?.length){let c=this.authService.getUser();if(this.isUserAdmin||c?.userId===t?.from?.userId){t.lastUpdated=new Date,t.status=Tt.UPDATED,t.isEdited||(t.isEdited=!0,t.editedAt=new Date),this.commentService.saveComment(e,{type:Tt.UPDATED,updatedComment:t});let d=yield this.metadataService.getGlobalMetadata(),g={annotationId:e?.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:d};return this.triggerAction(er.UPDATE_COMMENT,g),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_EDITED,{annotationId:e?.annotationId,commentThreadId:t?.commentId,commentType:this.commentService.getCommentType(e),commentMode:this.commentService.getCommentMode(),source:l??this.defaultSource}),g}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to update it.")}else yield this.deleteComment({annotationId:e?.annotationId,commentId:t.commentId,skipDeleteThreadConfirmation:i,options:a});return null}catch(c){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",c),null}})}updateComment(d,g){return X(this,arguments,function*({annotationId:e,comment:t,skipDeleteThreadConfirmation:i,merge:a,options:l},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let u=this.commentService.getAnnotationById(e,l),_=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(u&&_){let w=t,A=u.comments?.find(M=>M.commentId===t.commentId);if(A){if(this.isUserAdmin||_?.userId===A?.from?.userId)return u?.status.type==="terminal"&&(u.status=this.customFilterService.defaultStatus),a&&(w=h(h({},A),t)),w.from=A.from,w.createdAt=A.createdAt,w.lastUpdated=new Date,yield this.updateOrDeleteComment(u,w,i,l,c);this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to update it.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(u){return this.loggingService.catch("Error in CommentActionsService updateComment: ",u),null}})}deleteComment(c,d){return X(this,arguments,function*({annotationId:e,commentId:t,skipDeleteThreadConfirmation:i,options:a},l){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let g=this.commentService.getAnnotationById(e,a),u=this.authService.getUser();if(!g)return this.triggerAnnotationNotFoundError(e),null;let _=g.comments?.find(q=>q?.commentId===t);if(!_)return null;if(!(this.isUserAdmin||u?.userId===_?.from?.userId))return this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete it."),null;let w=this.commentService.willDeleteWholeAnnotation(g,t),A=this.commentService.getCommentAnnotationForClient(g);if(!i&&!(yield this.commentService.confirmDeleteCommentIfRequired(g,_)))return null;this.commentService.saveComment(g,{type:Tt.DELETED,updatedComment:_,skipDeleteThreadConfirmation:!0});let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:e,commentId:t,commentAnnotation:A,comment:_,metadata:M};if(w){let q={annotationId:e,commentAnnotation:A,metadata:M};this.triggerAction(er.DELETE_COMMENT_ANNOTATION,q)}else this.triggerAction(er.DELETE_COMMENT,j);return j}catch(g){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",g),null}})}addAttachment(l,c){return X(this,arguments,function*({annotationId:e,files:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let d=[],g=this.commentService.getAnnotationById(e,i);if(g||a==="internal"){let w=[];t.forEach(A=>{let{valid:M,file:j,maxAllowedSize:q,error:ie}=this.validateFile(A);M&&j?w.push(this.uploadFile(j,g||{}).then(_e=>({valid:M,file:j,maxAllowedSize:q,error:ie,attachment:_e||void 0}))):w.push(Promise.resolve({valid:M,file:j,maxAllowedSize:q,error:ie,attachment:void 0}))}),d=yield Promise.all(w)}else this.triggerAnnotationNotFoundError(e);let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:g?this.commentService.getCommentAnnotationForClient(g):void 0,attachments:d,metadata:u};return this.triggerAction(er.ADD_ATTACHMENT,_),d}catch(d){return this.loggingService.catch("Error in CommentActionsService addAttachment: ",d),[]}})}validateFile(e){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: validateFile","color: green;");let t=100*1024*1024;(e?.type?.includes("image")||e?.type?.includes("pdf"))&&(t=15*1024*1024);let i=e.size<=t;return{valid:i,file:e,maxAllowedSize:t,maxAllowedSizeInMB:t/1024/1024,error:i?void 0:`File size should be less than ${t/1024/1024} MB`}}catch(t){return this.loggingService.catch("Error in CommentActionsService validateFile: ",t),{valid:!1,maxAllowedSize:0,maxAllowedSizeInMB:0,error:"Error in validating file"}}}deleteAttachment(l){return X(this,arguments,function*({annotationId:e,commentId:t,attachmentId:i,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let d=c.comments?.find(u=>u?.commentId===t),g=c.metadata;if(d){let u=this.authService.getUser();if(this.isUserAdmin||u?.userId===d?.from?.userId){let _=d.attachments?.find(w=>w?.attachmentId===i);if(_){d.attachments=d.attachments?.filter(j=>j?.attachmentId!==i);let w={attachmentId:_.attachmentId,organizationId:g?.clientOrganizationId??g?.organizationId??null,documentId:g?.clientDocumentId??g?.documentId??null,folderId:g?.folderId??null,commentAnnotationId:c.annotationId,apiKey:g?.apiKey??null};yield this.commentService.deleteAttachment({attachment:_,metadata:w});let A=yield this.metadataService.getGlobalMetadata(),M={attachment:_,annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:A};return this.triggerAction(er.DELETE_ATTACHMENT,M),this.updateComment({annotationId:e,comment:d,options:a}),M}}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete the attachment.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteAttachment: ",c),null}})}getAttachment(a){return X(this,arguments,function*({annotationId:e,commentId:t,options:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getAttachment","color: green;");let l=this.commentService.getAnnotationById(e,i);return l?l.comments?.find(d=>d?.commentId===t)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(l){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",l),[]}})}uploadFile(e,t){return X(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,t)}catch(i){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",i),null}})}getRecording(a){return X(this,arguments,function*({annotationId:e,commentId:t,options:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getRecording","color: green;");let l=this.commentService.getAnnotationById(e,i);return l?l.comments?.find(d=>d?.commentId===t)?.recorders||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(l){return this.loggingService.catch("Error in CommentActionsService getRecording: ",l),[]}})}deleteRecording(l){return X(this,arguments,function*({annotationId:e,commentId:t,recorderId:i,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let d=c.comments?.find(g=>g?.commentId===t);if(d){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===d?.from?.userId){let u=d.recorders?.find(_=>_?.id===i);if(u){d.recorders=d.recorders?.filter(A=>A?.id!==i);let _=yield this.metadataService.getGlobalMetadata(),w={annotationId:e,commentId:t,recording:u,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:_};return this.triggerAction(er.DELETE_RECORDING,w),this.updateComment({annotationId:e,comment:d,skipDeleteThreadConfirmation:!0,options:a}),w}}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete the recording.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteRecording: ",c),null}})}fetchCommentAnnotations(e){return X(this,null,function*(){try{let t=yield this.commentService.fetchCommentAnnotations(e),i;if(t?.hasMore){let l=t?.data[t?.data?.length-1];i=yield FZ(l?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=t?.data?.reduce((l,c)=>(l[c.metadata.clientDocumentId??c.metadata.documentId]=l[c.metadata.clientDocumentId??c.metadata.documentId]||[],l[c.metadata.clientDocumentId??c.metadata.documentId].push(this.commentService.getCommentAnnotationForClient(c)),l),{});return h({data:a},t?.hasMore?{nextPageToken:i}:{})}catch(t){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",t),{data:null}}})}toggleReaction(c,d){return X(this,arguments,function*({annotationId:e,commentId:t,reaction:i,options:a},l){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let g=this.commentService.getAnnotationById(e,a),u=this.authService.getUser();if(g&&u){let _=g.comments?.find(w=>w?.commentId===t);if(_){let w=yield this.reactionService.addOrUpdateReaction(i.reactionId,_?.reactionAnnotationIds||[],void 0,void 0,g?.annotationId,i.customReaction,l),A=Tt.REACTION_ADDED;if(w){w?.reactions?.find(q=>q.from?.userId===u?.userId)||(A=Tt.REACTION_DELETED),_.reactionAnnotationIds||(_.reactionAnnotationIds=[]),_.reactionAnnotationIds.includes(w.annotationId)||_.reactionAnnotationIds.push(w.annotationId),w?.reactions?.length||(_.reactionAnnotationIds=_.reactionAnnotationIds.filter(q=>q!==w.annotationId)),this.commentService.saveComment(g,{type:A,updatedComment:_});let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:e,commentId:t,reaction:w,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:M};return l==="add"?this.triggerAction(er.ADD_REACTION,j):l==="delete"?this.triggerAction(er.DELETE_REACTION,j):this.triggerAction(er.TOGGLE_REACTION,j),A===Tt.REACTION_ADDED?this.analyticsService.trackEvent(Y.Events.Comments.REACTION_ADDED,{annotationId:e,commentId:t,reactionId:i.reactionId,commentMode:this.commentService.getCommentMode()}):A===Tt.REACTION_DELETED&&this.analyticsService.trackEvent(Y.Events.Comments.REACTION_DELETED,{annotationId:e,commentId:t,reactionId:i.reactionId,commentMode:this.commentService.getCommentMode()}),j}}}else this.triggerAnnotationNotFoundError(e);return null}catch(g){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",g),null}})}onComposerClick(t){return X(this,arguments,function*({commentAnnotation:e}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onComposerClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={commentAnnotation:e?.annotationId?this.commentService.getCommentAnnotationForClient(e):void 0,metadata:i};this.triggerAction(er.COMPOSER_CLICKED,a)}catch(i){this.loggingService.catch("Error in CommentActionsService onComposerClick: ",i)}})}onComposerTextChange(e){return X(this,null,function*(){try{let t=yield this.metadataService.getGlobalMetadata(),i={text:e.text,annotation:e.annotation,targetComposerElementId:e.targetComposerElementId,metadata:t};this.commentService.setComposerData(e.targetComposerElementId,i),this.triggerAction(er.COMPOSER_TEXT_CHANGE,i)}catch(t){this.loggingService.catch("Error in CommentActionsService onComposerTextChange: ",t)}})}autocompleteSearch(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: autocompleteSearch","color: green;");let t=yield this.metadataService.getGlobalMetadata();e.metadata=t,this.triggerAction(er.AUTOCOMPLETE_SEARCH,e)}catch(t){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",t)}})}onCommentPinClick(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentPinClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),i={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(er.COMMENT_PIN_CLICKED,i),i}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentPinClick: ",t),null}})}onCommentBubbleClick(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentBubbleClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),i={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(er.COMMENT_BUBBLE_CLICKED,i),i}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentBubbleClick: ",t),null}})}onCommentToolClick(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentToolClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={context:e,targetElementId:t,metadata:i},l={context:e,targetElementId:t,metadata:i};return this.triggerAction(er.COMMENT_TOOL_CLICK,a),this.triggerAction(er.COMMENT_TOOL_CLICKED,l),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onCommentToolClick: ",i),null}})}onSidebarButtonClick(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onSidebarButtonClick","color: green;");let e=yield this.metadataService.getGlobalMetadata(),t={metadata:e},i={metadata:e};return this.triggerAction(er.SIDEBAR_BUTTON_CLICK,t),this.triggerAction(er.SIDEBAR_BUTTON_CLICKED,i),t}catch(e){return this.loggingService.catch("Error in CommentActionsService onSidebarButtonClick: ",e),null}})}onAttachmentDownloadClick(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onAttachmentDownloadClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),attachment:t,metadata:i};return this.triggerAction(er.ATTACHMENT_DOWNLOAD_CLICKED,a),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onAttachmentDownloadClick: ",i),null}})}onCommentSaveTriggered(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentSaveTriggered","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(t),metadata:i};return this.triggerAction(er.COMMENT_SAVE_TRIGGERED,a),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onCommentSaveTriggered: ",i),null}})}onVisibilityOptionClick(e,t,i){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onVisibilityOptionClick","color: green;");let a=yield this.metadataService.getGlobalMetadata(),l={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),visibility:t,users:i?.map(c=>Bo(c)).filter(Boolean),metadata:a};return this.triggerAction(er.VISIBILITY_OPTION_CLICKED,l),l}catch(a){return this.loggingService.catch("Error in CommentActionsService onVisibilityOptionClick: ",a),null}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:i}=this.docService.getServerId(e?.options);e.options=y(h({},e?.options),{documentId:t,organizationId:i})}return this}catch(t){return this.loggingService.catch("Error in CommentActionsService convert: ",t),this}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in CommentActionsService onAction: ",t),de(null)}}get timestamp(){return this.commonDbService.getServerTimestamp()}getCommentAnnotations(e){try{if(e){if(e?.allDocuments&&!e?.folderId)return this.loggingService.catch("folderId is required when allDocuments is true."),de({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),de({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(ge(t=>t?t.reduce((i,a)=>{let l=a.metadata?.clientDocumentId;return!l||e?.documentIds&&!e?.documentIds?.includes(l)||(i[l]||(i[l]=[]),i[l].push(a)),i},{}):null),ge(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),de({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentViewsService.getAnnotationsCount(e).pipe(ge(t=>t||{data:null}))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),de({data:null})}}updateVisibility(e){this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateVisibility","color: green;");try{let t=e.annotationId;if(!t)throw new Error("annotationId is required in visibility config");if(e.type==="restricted"){let l=this.authService.getUser();if(!l?.userId)throw new Error("Current user not found. Cannot set restricted visibility without userIds.");e=ap(e,l.userId)}if(e.type==="organizationPrivate"&&!e.organizationId){let l=this.docService.getOrganizationConfig();if(!l?.clientOrganizationId)throw new Error("No organizationId found. Cannot set organizationPrivate visibility without organizationId.");e=y(h({},e),{organizationId:l.clientOrganizationId})}this.analyticsService.trackEvent(Y.Events.Comments.UPDATE_VISIBILITY_TRIGGERED,{payload:{annotationId:t,visibility:e}});let i=lp(e),a=h(h({type:e.type},e.organizationId&&{organizationId:e.organizationId}),e.userIds&&{userIds:e.userIds});return this.commentService.updateCommentAnnotationContext(t,{_setAccessFields:i,_setVisibilityConfig:a},{merge:!0})}catch(t){return this.loggingService.catch("Error in updateVisibility: ",t),Promise.resolve()}}calculateCommentThreadIndex(e,t){try{let i=e?.commentId,a;return i&&(a=t?.comments?.findIndex(l=>l.commentId===i)),a===-1&&(a=t?.comments?.length),a}catch(i){this.loggingService.catch("Error in calculateCommentThreadIndex: ",i);return}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Ke),Z(Re),Z(U_e),Z(un),Z(ho),Z(st),Z(Vn),Z(k),Z(ls),Z(qi),Z(kn),Z(gl),Z(GS))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var XU=class extends fr{constructor(o){super(o),this._submitComment=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: submitComment","color: green;");try{this.trackEvent(Y.Events.Comments.SUBMIT_COMMENT_TRIGGERED,{payload:{referenceId:r.targetComposerElementId}}),this.getService(Re).submitComment(r)}catch(e){this.getService(k).catch("Error in _submitComment: ",e)}},this._clearComposer=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: clearComposer","color: green;");try{this.trackEvent(Y.Events.Comments.CLEAR_COMPOSER_TRIGGERED),this.getService(Re).clearComposer(r)}catch(e){this.getService(k).catch("Error in _clearComposer: ",e)}},this._enableFormatOptions=()=>{this.getService(k).log("%c[WB] Calling FUNCTION: enableFormatOptions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORMAT_OPTIONS_TRIGGERED),this.getService(Re).enableFormatOptions()}catch(r){this.getService(k).catch("Error in _enableFormatOptions: ",r)}},this._disableFormatOptions=()=>{this.getService(k).log("%c[WB] Calling FUNCTION: disableFormatOptions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORMAT_OPTIONS_TRIGGERED),this.getService(Re).disableFormatOptions()}catch(r){this.getService(k).catch("Error in _disableFormatOptions: ",r)}},this._setFormatConfig=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: setFormatConfig","color: green;");try{this.trackEvent(Y.Events.Comments.SET_FORMAT_CONFIG_TRIGGERED,{payload:{config:r}}),this.getService(Re).setFormatConfig(r)}catch(e){this.getService(k).catch("Error in _setFormatConfig: ",e)}},this._getComposerData=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: getComposerData","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMPOSER_DATA_TRIGGERED),this.getService(Re).getComposerData(r)}catch(e){return this.getService(k).catch("Error in _getComposerData: ",e),null}},this.getService(k).log("%c[WB] Creating CLASS: CommentElement","color: blue;"),this.getAllCommentAnnotations=this._getAllCommentAnnotations,this.deleteSelectedComment=this._deleteSelectedComment,this.enableTextComments=this._enableTextComments,this.disableTextComments=this._disableTextComments,this.allowedElementIds=this._allowedElementIds,this.allowedElementClassNames=this._allowedElementClassNames,this.allowedElementQuerySelectors=this._allowedElementQuerySelectors,this.disableFloatingCommentDialog=this._disableFloatingComments,this.enableFloatingCommentDialog=this._enableFloatingComments,this.attachComment=this._attachComment,this.openCommentSidebar=this._openCommentSidebar,this.closeCommentSidebar=this._closeCommentSidebar,this.toggleCommentSidebar=this._toggleCommentSidebar,this.enableModeratorMode=this._enableModeratorMode,this.disableModeratorMode=this._disableModeratorMode,this.enableStreamMode=this._enableStreamMode,this.disableStreamMode=this._disableStreamMode,this.enableSignInButton=this._enableSignInButton,this.disableSignInButton=this._disableSignInButton,this.enableUpgradeButton=this._enableUpgradeButton,this.disableUpgradeButton=this._disableUpgradeButton,this.onCommentModeChange=this._onCommentModeChange,this.enableAttachments=this._enableAttachment,this.disableAttachments=this._disableAttachment,this.enableAttachmentDownload=this._enableAttachmentDownload,this.disableAttachmentDownload=this._disableAttachmentDownload,this.isUserGlobalContact=this._isUserGlobalContact,this.enableDeviceInfo=this._enableDeviceInfo,this.disableDeviceInfo=this._disableDeviceInfo,this.enableCommentMode=this._enableCommentMode,this.disableCommentMode=this._disableCommentMode,this.enablePersistentCommentMode=this._enablePersistentCommentMode,this.disablePersistentCommentMode=this._disablePersistentCommentMode,this.enableCommentIndex=this._enableCommentIndex,this.disableCommentIndex=this._disableCommentIndex,this.enablePopoverMode=this._enablePopoverMode,this.disablePopoverMode=this._disablePopoverMode,this.enableDialogOnHover=this._enableDialogOnHover,this.enablePopoverTriangleComponent=this._enablePopoverTriangleComponent,this.disablePopoverTriangleComponent=this._disablePopoverTriangleComponent,this.disableDialogOnHover=this._disableDialogOnHover,this.enableDialogOnTargetElementClick=this._enableDialogOnTargetElementClick,this.disableDialogOnTargetElementClick=this._disableDialogOnTargetElementClick,this.enablePriority=this._enablePriority,this.disablePriority=this._disablePriority,this.enableStatus=this._enableStatus,this.disableStatus=this._disableStatus,this.enableVisibilityOptions=this._enableVisibilityOptions,this.disableVisibilityOptions=this._disableVisibilityOptions,this.enableResolveButton=this._enableResolveButton,this.disableResolveButton=this._disableResolveButton,this.enableGhostComments=this._enableGhostComments,this.disableGhostComments=this._disableGhostComments,this.enableGhostCommentsIndicator=this._enableGhostCommentsIndicator,this.disableGhostCommentsIndicator=this._disableGhostCommentsIndicator,this.setCustomStatus=this._setCustomStatus,this.setCustomPriority=this._setCustomPriority,this.setCustomCategory=this._setCustomCategory,this.enableInboxMode=this._enableInboxMode,this.disableInboxMode=this._disableInboxMode,this.enableAutoCategorize=this._enableAutoCategorize,this.disableAutoCategorize=this._disableAutoCategorize,this.enableDarkMode=this._enableDarkMode,this.disableDarkMode=this._disableDarkMode,this.setContextProvider=this._setContextProvider,this.enableSuggestionMode=this._enableSuggestionMode,this.disableSuggestionMode=this._disableSuggestionMode,this.enableMobileMode=this._enableMobileMode,this.disableMobileMode=this._disableMobileMode,this.enableInlineCommentMode=this._enableInlineCommentMode,this.disableInlineCommentMode=this._disableInlineCommentMode,this.enableMinimap=this._enableMinimap,this.disableMinimap=this._disableMinimap,this.showCommentsOnDom=this._showCommentsOnDom,this.hideCommentsOnDom=this._hideCommentsOnDom,this.enableCommentTool=this._enableCommentTool,this.disableCommentTool=this._disableCommentTool,this.setTotalMediaLength=this._setTotalMediaLength,this.onCommentAdd=this._onCommentAdd,this.onCommentUpdate=this._onCommentUpdate,this.addCommentOnSelectedText=this._addCommentOnSelectedText,this.enableSidebarUrlNavigation=this._enableSidebarUrlNavigation,this.disableSidebarUrlNavigation=this._disableSidebarUrlNavigation,this.setDStrategy=this._setDStrategy,this.enableSidebarButtonOnCommentDialog=this._enableSidebarButtonOnCommentDialog,this.disableSidebarButtonOnCommentDialog=this._disableSidebarButtonOnCommentDialog,this.onSidebarButtonOnCommentDialogClick=this._onSidebarButtonOnCommentDialogClick,this.enableReactions=this._enableReactions,this.disableReactions=this._disableReactions,this.enableAnonymousEmail=this._enableAnonymousEmail,this.disableAnonymousEmail=this._disableAnonymousEmail,this.setRecordings=this._setRecordings,this.addCommentOnElement=this._addCommentOnElement,this.enablePrivateCommentMode=this._enablePrivateCommentMode,this.disablePrivateCommentMode=this._disablePrivateCommentMode,this.enablePrivateMode=this._enablePrivateMode,this.disablePrivateMode=this._disablePrivateMode,this.enableScrollToComment=this._enableScrollToComment,this.disableScrollToComment=this._disableScrollToComment,this.enableUserMentions=this._enableUserMentions,this.disableUserMentions=this._disableUserMentions,this.setCommentSidebarFilters=this._setCommentSidebarFilters,this.setSystemFiltersOperator=this._setSystemFiltersOperator,this.enableCommentPinHighlighter=this._enableCommentPinHighlighter,this.disableCommentPinHighlighter=this._disableCommentPinHighlighter,this.enableDeleteOnBackspace=this._enableDeleteOnBackspace,this.disableDeleteOnBackspace=this._disableDeleteOnBackspace,this.enableHotkey=this._enableHotkey,this.disableHotkey=this._disableHotkey,this.enableDeviceIndicatorOnCommentPins=this._enableDeviceIndicatorOnCommentPins,this.disableDeviceIndicatorOnCommentPins=this._disableDeviceIndicatorOnCommentPins,this.getElementRefByAnnotationId=this._getElementRefByAnnotationId,this.scrollToCommentByAnnotationId=this._scrollToCommentByAnnotationId,this.selectCommentByAnnotationId=this._selectCommentByAnnotationId,this.enableRecordingSummary=this._enableRecordingSummary,this.disableRecordingSummary=this._disableRecordingSummary,this.enableRecordingTranscription=this._enableRecordingTranscription,this.disableRecordingTranscription=this._disableRecordingTranscription,this.enableRecordingCountdown=this._enableRecordingCountdown,this.disableRecordingCountdown=this._disableRecordingCountdown,this.setUnreadIndicatorMode=this._setUnreadIndicatorMode,this.enableEnterKeyToSubmit=this._enableEnterKeyToSubmit,this.disableEnterKeyToSubmit=this._disableEnterKeyToSubmit,this.enablePinShadowDOM=this._enablePinShadowDOM,this.disablePinShadowDOM=this._disablePinShadowDOM,this.enableDialogShadowDOM=this._enableDialogShadowDOM,this.disableDialogShadowDOM=this._disableDialogShadowDOM,this.enableSidebarShadowDOM=this._enableSidebarShadowDOM,this.disableSidebarShadowDOM=this._disableSidebarShadowDOM,this.enableChangeDetectionInCommentMode=this._enableChangeDetectionInCommentMode,this.disableChangeDetectionInCommentMode=this._disableChangeDetectionInCommentMode,this.showResolvedCommentsOnDom=this._showResolvedCommentsOnDom,this.hideResolvedCommentsOnDom=this._hideResolvedCommentsOnDom,this.setCustomReactions=this._setCustomReactions,this.onCommentSelectionChange=this._onCommentSelectionChange,this.getUnreadCommentCountByAnnotationId=this._getUnreadCommentCountByAnnotationId,this.getUnreadCommentAnnotationCountOnCurrentDocument=this._getUnreadCommentAnnotationCountOnCurrentDocument,this.getUnreadCommentCountOnCurrentDocument=this._getUnreadCommentCountOnCurrentDocument,this.getUnreadCommentAnnotationCountByLocationId=this._getUnreadCommentAnnotationCountByLocationId,this.getUnreadCommentCountByLocationId=this._getUnreadCommentCountByLocationId,this.updateCommentDialogPosition=this._updateCommentDialogPosition,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment,this.setPinCursorImage=this._setPinCursorImage,this.addManualComment=this._addManualComment,this.createCustomListDataOnAnnotation=this._createCustomListDataOnAnnotation,this.createCustomListDataOnComment=this._createCustomListDataOnComment,this.excludeLocationIdsFromSidebar=this._excludeLocationIdsFromSidebar,this.enableBubbleOnPin=this._enableBubbleOnPin,this.disableBubbleOnPin=this._disableBubbleOnPin,this.enableBubbleOnPinHover=this._enableBubbleOnPinHover,this.disableBubbleOnPinHover=this._disableBubbleOnPinHover,this.enablePinDrag=this._enablePinDrag,this.disablePinDrag=this._disablePinDrag,this.enableMultiThreadMode=this._enableMultiThread,this.disableMultiThreadMode=this._disableMultiThread,this.enableMultiThread=this._enableMultiThread,this.disableMultiThread=this._disableMultiThread,this.enableGroupMultipleMatch=this._enableGroupMatchedComments,this.disableGroupMultipleMatch=this._disableGroupMatchedComments,this.enableGroupMatchedComments=this._enableGroupMatchedComments,this.disableGroupMatchedComments=this._disableGroupMatchedComments,this.updateContext=this._updateContext,this.updateVisibility=this._updateVisibility,this.getSelectedComments=this._getSelectedComments,this.enableDeleteReplyConfirmation=this._enableDeleteReplyConfirmation,this.disableDeleteReplyConfirmation=this._disableDeleteReplyConfirmation,this.onCopyLink=this._onCopyLink,this.getCommentAnnotationById=this._getCommentAnnotationById,this.enableCollapsedComments=this._enableCollapsedComments,this.disableCollapsedComments=this._disableCollapsedComments,this.onCommentSidebarActionButtonClick=this._onCommentSidebarActionButtonClick,this.setCommentSidebarData=this._setCommentSidebarData,this.onCommentSidebarInit=this._onCommentSidebarInit,this.onCommentSidebarData=this._onCommentSidebarData,this.setCommentSidebarDefaultCustomActions=this._setCommentSidebarDefaultCustomActions,this.enableSidebarCustomActions=this._enableSidebarCustomActions,this.disableSidebarCustomActions=this._disableSidebarCustomActions,this.enableQueryParamsComments=this._enableQueryParamsComments,this.disableQueryParamsComments=this._disableQueryParamsComments,this.enableResolveStatusAccessAdminOnly=this._enableResolveStatusAccessAdminOnly,this.disableResolveStatusAccessAdminOnly=this._disableResolveStatusAccessAdminOnly,this.enableLinkCallback=this._enableLinkCallback,this.disableLinkCallback=this._disableLinkCallback,this.enableSeenByUsers=this._enableSeenByUsers,this.disableSeenByUsers=this._disableSeenByUsers,this.enableShortUserName=this._enableShortUserName,this.disableShortUserName=this._disableShortUserName,this.addCommentAnnotation=this._addCommentAnnotation,this.approveCommentAnnotation=this._approveCommentAnnotation,this.acceptCommentAnnotation=this._acceptCommentAnnotation,this.rejectCommentAnnotation=this._rejectCommentAnnotation,this.subscribeCommentAnnotation=this._subscribeCommentAnnotation,this.unsubscribeCommentAnnotation=this._unsubscribeCommentAnnotation,this.deleteCommentAnnotation=this._deleteCommentAnnotation,this.getCommentAnnotations=this._getCommentAnnotations,this.getCommentAnnotationsCount=this._getCommentAnnotationsCount,this.assignUser=this._assignUser,this.updatePriority=this._updatePriority,this.updateStatus=this._updateStatus,this.updateAccess=this._updateAccess,this.resolveCommentAnnotation=this._resolveCommentAnnotation,this.getLink=this._getLink,this.copyLink=this._copyLink,this.addComment=this._addComment,this.updateComment=this._updateComment,this.deleteComment=this._deleteComment,this.getComment=this._getComment,this.addAttachment=this._addAttachment,this.deleteAttachment=this._deleteAttachment,this.getAttachment=this._getAttachment,this.deleteRecording=this._deleteRecording,this.getRecording=this._getRecording,this.addReaction=this._addReaction,this.deleteReaction=this._deleteReaction,this.toggleReaction=this._toggleReaction,this.enableReadOnly=this._enableReadOnly,this.disableReadOnly=this._disableReadOnly,this.setAssignToType=this._setAssignToType,this.enableContextInPageModeComposer=this._enableContextInPageModeComposer,this.disableContextInPageModeComposer=this._disableContextInPageModeComposer,this.clearPageModeComposerContext=this._clearPageModeComposerContext,this.setContextInPageModeComposer=this._setContextInPageModeComposer,this.focusPageModeComposer=this._focusPageModeComposer,this.enableCustomAutocompleteSearch=this._enableCustomAutocompleteSearch,this.disableCustomAutocompleteSearch=this._disableCustomAutocompleteSearch,this.fetchCommentAnnotations=this._fetchCommentAnnotations,this.setTransformContext=this._setTransformContext,this.enableSvgAsImg=this._enableSvgAsImg,this.disableSvgAsImg=this._disableSvgAsImg,this.enableFullExpanded=this._enableFullExpanded,this.disableFullExpanded=this._disableFullExpanded,this.enableCommentToNearestAllowedElement=this._enableCommentToNearestAllowedElement,this.disableCommentToNearestAllowedElement=this._disableCommentToNearestAllowedElement,this.enableDraftMode=this._enableDraftMode,this.disableDraftMode=this._disableDraftMode,this.enableFilterCommentsOnDom=this._enableFilterCommentsOnDom,this.disableFilterCommentsOnDom=this._disableFilterCommentsOnDom,this.enableReplyAvatars=this._enableReplyAvatars,this.disableReplyAvatars=this._disableReplyAvatars,this.setMaxReplyAvatars=this._setMaxReplyAvatars,this.setSidebarButtonCountType=this._setSidebarButtonCountType,this.enableFilterGhostCommentsInSidebar=this._enableFilterGhostCommentsInSidebar,this.disableFilterGhostCommentsInSidebar=this._disableFilterGhostCommentsInSidebar,this.enableFullScreenInSidebar=this._enableFullScreenInSidebar,this.disableFullScreenInSidebar=this._disableFullScreenInSidebar,this.setComposerFileAttachments=this._setComposerFileAttachments,this.setAllowedFileTypes=this._setAllowedFileTypes,this.enableForceCloseAllOnEsc=this._enableForceCloseAllOnEsc,this.disableForceCloseAllOnEsc=this._disableForceCloseAllOnEsc,this.markAsRead=this._markAsRead,this.markAsUnread=this._markAsUnread,this.enableScreenshot=this._enableScreenshot,this.disableScreenshot=this._disableScreenshot,this.enablePaginatedContactList=this._enablePaginatedContactList,this.disablePaginatedContactList=this._disablePaginatedContactList,this.enableFormatOptions=this._enableFormatOptions,this.disableFormatOptions=this._disableFormatOptions,this.setFormatConfig=this._setFormatConfig,this.submitComment=this._submitComment,this.clearComposer=this._clearComposer,this.on=this._on,this.getComposerData=this._getComposerData}_getAllCommentAnnotations(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{documentId:o,location:r}}),this.getService(Re).getAllCommentAnnotations({customClientDocumentId:o,params:r,excludeDomChanges:!0,skipPositionCalculation:!0,addFilterCommentsOnDomCheck:!0}).pipe(ge(e=>e?.length?e?.map(t=>this.getService(Re).getCommentAnnotationForClient(t)):e))}catch(e){return this.getService(k).catch("Error in _getLiveCommentsOnCurrentDocument: ",e),de(null)}}_deleteSelectedComment(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteSelectedComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_SELECTED_COMMENT_TRIGGERED),this.getService(Re).deleteCommentPinAnnotations("commentElement")}catch(o){return this.getService(k).catch("Error in _deleteSelectedComment: ",o),Promise.resolve(null)}}_enableTextComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_TEXT_COMMENTS_TRIGGERED),this.getService(Re).enableTextComments()}catch(o){this.getService(k).catch("Error in _enableTextComments: ",o)}}_disableTextComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_TEXT_COMMENTS_TRIGGERED),this.getService(Re).disableTextComments()}catch(o){this.getService(k).catch("Error in _disableTextComments: ",o)}}_allowedElementIds(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(Re).setAllowedElementIds(o)}catch(r){this.getService(k).catch("Error in allowedElementIds: ",r)}}_allowedElementClassNames(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementClassNames","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_CLASS_NAMES_TRIGGERED,{payload:{classNames:o}}),this.getService(Re).setAllowedElementClassNames(o)}catch(r){this.getService(k).catch("Error in allowedElementClassNames: ",r)}}_allowedElementQuerySelectors(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementQuerySelectors","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_QUERY_SELECTORS_TRIGGERED,{payload:{querySelectors:o}}),this.getService(Re).setAllowedElementQuerySelectors(o)}catch(r){this.getService(k).catch("Error in allowedElementQuerySelectors: ",r)}}_disableFloatingComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableFloatingComments(!0)}catch(o){this.getService(k).catch("Error in _disableFloatingComments: ",o)}}_enableFloatingComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableFloatingComments(!1)}catch(o){this.getService(k).catch("Error in _enableFloatingComments: ",o)}}_attachComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: attachComment","color: green;");try{this.trackEvent(Y.Events.Comments.ATTACH_COMMENT_TRIGGERED,{payload:{elementId:o}}),this.getService(Re).attachComment(o,["id","data-id"])}catch(r){this.getService(k).catch("Error in _attachComment: ",r)}}_openCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: openCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.OPEN_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).setSidebarVisibility(!0,!0)}catch(o){this.getService(k).catch("Error in _openCommentSidebar: ",o)}}_closeCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: closeCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.CLOSE_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).setSidebarVisibility(!1,!0)}catch(o){this.getService(k).catch("Error in _closeCommentSidebar: ",o)}}_toggleCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: toggleCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.TOGGLE_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).toggleSidebarVisibility(!0)}catch(o){this.getService(k).catch("Error in _toggleCommentSidebar: ",o)}}_enableModeratorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MODERATOR_MODE_TRIGGERED),this.getService(Re).setModeratorMode(!0)}catch(o){this.getService(k).catch("Error in _enableModeratorMode: ",o)}}_disableModeratorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MODERATOR_MODE_TRIGGERED),this.getService(Re).setModeratorMode(!1)}catch(o){this.getService(k).catch("Error in _disableModeratorMode: ",o)}}_enableStreamMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STREAM_MODE_TRIGGERED),this.getService(Re).setStreamMode(!0)}catch(o){this.getService(k).catch("Error in _enableStreamMode: ",o)}}_disableStreamMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STREAM_MODE_TRIGGERED),this.getService(Re).setStreamMode(!1)}catch(o){this.getService(k).catch("Error in _disableStreamMode: ",o)}}_enableSignInButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(Re).enableSignInButton(!0)}catch(o){this.getService(k).catch("Error in _enableSignInButton: ",o)}}_disableSignInButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(Re).enableSignInButton(!1)}catch(o){this.getService(k).catch("Error in _disableSignInButton: ",o)}}_enableUpgradeButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(Re).enableUpgradeButton(!0)}catch(o){this.getService(k).catch("Error in _enableUpgradeButton: ",o)}}_disableUpgradeButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(Re).enableUpgradeButton(!1)}catch(o){this.getService(k).catch("Error in _disableUpgradeButton: ",o)}}_onCommentModeChange(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentModeChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_MODE_CHANGE_TRIGGERED),this.getService(Re).addCommentModeChange()}catch(o){return this.getService(k).catch("Error in _onCommentModeChange: ",o),de(!1)}}_enableAttachment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENTS_TRIGGERED),this.getService(Re).enableAttachment(!0)}catch(o){this.getService(k).catch("Error in _enableAttachment: ",o)}}_disableAttachment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENTS_TRIGGERED),this.getService(Re).enableAttachment(!1)}catch(o){this.getService(k).catch("Error in _disableAttachment: ",o)}}_enableAttachmentDownload(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAttachmentDownload","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENT_DOWNLOAD_TRIGGERED),this.getService(Re).enableAttachmentDownload()}catch(o){this.getService(k).catch("Error in _enableAttachmentDownload: ",o)}}_disableAttachmentDownload(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAttachmentDownload","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENT_DOWNLOAD_TRIGGERED),this.getService(Re).disableAttachmentDownload()}catch(o){this.getService(k).catch("Error in _disableAttachmentDownload: ",o)}}_isUserGlobalContact(){this.getService(k).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Comments.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(Re).isUserGlobalContact$()}catch(o){return this.getService(k).catch("Error in _isUserGlobalContact: ",o),de(!1)}}_enableDeviceInfo(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INFO_TRIGGERED),this.getService(Re).showScreenSizeInfo(!0)}catch(o){this.getService(k).catch("Error in _enableDeviceInfo: ",o)}}_disableDeviceInfo(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INFO_TRIGGERED),this.getService(Re).showScreenSizeInfo(!1)}catch(o){this.getService(k).catch("Error in _disableDeviceInfo: ",o)}}_enableCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_MODE_TRIGGERED),this.getService(Re).enableAddCommentMode()}catch(o){this.getService(k).catch("Error in _enableCommentMode: ",o)}}_disableCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_MODE_TRIGGERED),this.getService(Re).disableAddCommentMode()}catch(o){this.getService(k).catch("Error in _disableCommentMode: ",o)}}_enablePersistentCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(Re).enablePersistentCommentMode()}catch(o){this.getService(k).catch("Error in _enablePersistentCommentMode: ",o)}}_disablePersistentCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(Re).disablePersistentCommentMode()}catch(o){this.getService(k).catch("Error in _disablePersistentCommentMode: ",o)}}_showCommentIndex(o){this.getService(k).log("%c[WB] Calling FUNCTION: showCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENT_INDEX_TRIGGERED,{payload:{show:o}}),this.getService(Re).showCommentIndex(o)}catch(r){this.getService(k).catch("Error in _showCommentIndex: ",r)}}_enableCommentIndex(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_INDEX_TRIGGERED),this.getService(Re).showCommentIndex(!0)}catch(o){this.getService(k).catch("Error in _enableCommentIndex: ",o)}}_disableCommentIndex(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_INDEX_TRIGGERED),this.getService(Re).showCommentIndex(!1)}catch(o){this.getService(k).catch("Error in _disableCommentIndex: ",o)}}_enablePopoverMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_MODE_TRIGGERED),this.getService(Re).enablePopoverMode()}catch(o){this.getService(k).catch("Error in _enablePopoverMode: ",o)}}_disablePopoverMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_MODE_TRIGGERED),this.getService(Re).disablePopoverMode()}catch(o){this.getService(k).catch("Error in _disablePopoverMode: ",o)}}_enableDialogOnHover(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(Re).setEnableDialogOnHover(!0)}catch(o){this.getService(k).catch("Error in _enableDialogOnHover: ",o)}}_disableDialogOnHover(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(Re).setEnableDialogOnHover(!1)}catch(o){this.getService(k).catch("Error in _disableDialogOnHover: ",o)}}_enablePopoverTriangleComponent(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(Re).enablePopoverTriangleComponent()}catch(o){this.getService(k).catch("Error in _enablePopoverTriangleComponent: ",o)}}_disablePopoverTriangleComponent(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(Re).disablePopoverTriangleComponent()}catch(o){this.getService(k).catch("Error in _disablePopoverTriangleComponent: ",o)}}_enableDialogOnTargetElementClick(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(Re).setEnableDialogOnTargetElementClick(!0)}catch(o){this.getService(k).catch("Error in _enableDialogOnTargetElementClick: ",o)}}_disableDialogOnTargetElementClick(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(Re).setEnableDialogOnTargetElementClick(!1)}catch(o){this.getService(k).catch("Error in _disableDialogOnTargetElementClick: ",o)}}_enablePriority(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIORITY_TRIGGERED),this.getService(Re).setEnablePriority(!0)}catch(o){this.getService(k).catch("Error in _enablePriority: ",o)}}_disablePriority(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIORITY_TRIGGERED),this.getService(Re).setEnablePriority(!1)}catch(o){this.getService(k).catch("Error in _disablePriority: ",o)}}_enableStatus(){this.getService(k).log("%c[WB] Calling FUNCTION: enableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STATUS_TRIGGERED),this.getService(Re).setEnableStatus(!0)}catch(o){this.getService(k).catch("Error in _enableStatus: ",o)}}_disableStatus(){this.getService(k).log("%c[WB] Calling FUNCTION: disableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STATUS_TRIGGERED),this.getService(Re).setEnableStatus(!1)}catch(o){this.getService(k).catch("Error in _disableStatus: ",o)}}_enableVisibilityOptions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableVisibilityOptions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_VISIBILITY_OPTIONS_TRIGGERED),this.getService(Re).setEnableVisibilityOptions(!0)}catch(o){this.getService(k).catch("Error in _enableVisibilityOptions: ",o)}}_disableVisibilityOptions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableVisibilityOptions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_VISIBILITY_OPTIONS_TRIGGERED),this.getService(Re).setEnableVisibilityOptions(!1)}catch(o){this.getService(k).catch("Error in _disableVisibilityOptions: ",o)}}_enableResolveButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(Re).setEnableResolve(!0)}catch(o){this.getService(k).catch("Error in _enableResolveButton: ",o)}}_disableResolveButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(Re).setEnableResolve(!1)}catch(o){this.getService(k).catch("Error in _disableResolveButton: ",o)}}_enableGhostComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_TRIGGERED),this.getService(Re).enableGhostComments()}catch(o){this.getService(k).catch("Error in _enableGhostCommentsInDOM: ",o)}}_disableGhostComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_TRIGGERED),this.getService(Re).disableGhostComments()}catch(o){this.getService(k).catch("Error in _disableGhostComments: ",o)}}_enableGhostCommentsIndicator(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(Re).enableGhostCommentsMessage()}catch(o){this.getService(k).catch("Error in _enableGhostCommentsIndicator: ",o)}}_disableGhostCommentsIndicator(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(Re).disableGhostCommentsMessage()}catch(o){this.getService(k).catch("Error in _disableGhostCommentsIndicator: ",o)}}_setCustomStatus(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomStatus","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_STATUS_TRIGGERED,{payload:{customStatuses:o}}),this.getService(Re).setCustomStatuses(o)}catch(r){this.getService(k).catch("Error in _setCustomStatus: ",r)}}_enableInboxMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INBOX_MODE_TRIGGERED),this.getService(Re).enableInboxMode()}catch(o){this.getService(k).catch("Error in _enableInboxMode: ",o)}}_setCustomPriority(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomPriority","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_PRIORITY_TRIGGERED,{payload:{customPriorities:o}}),this.getService(Re).setCustomPriorities(o)}catch(r){this.getService(k).catch("Error in _setCustomPriority: ",r)}}_setCustomCategory(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomCategory","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_CATEGORY_TRIGGERED,{payload:{customCategories:o}}),this.getService(Re).setCustomCategories(o)}catch(r){this.getService(k).catch("Error in _setCustomCategory: ",r)}}_disableInboxMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INBOX_MODE_TRIGGERED),this.getService(Re).disableInboxMode()}catch(o){this.getService(k).catch("Error in _disableInboxMode: ",o)}}_enableAutoCategorize(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(Re).setEnableAutoCategorize(!0)}catch(o){this.getService(k).catch("Error in _enableAutoCategorize: ",o)}}_disableAutoCategorize(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(Re).setEnableAutoCategorize(!1)}catch(o){this.getService(k).catch("Error in _disableAutoCategorize: ",o)}}_enableDarkMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DARK_MODE_TRIGGERED),this.getService(Re).setCommentContainerDarkMode(!0)}catch(o){this.getService(k).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DARK_MODE_TRIGGERED),this.getService(Re).setCommentContainerDarkMode(!1)}catch(o){this.getService(k).catch("Error in _disableDarkMode: ",o)}}_setContextProvider(o){try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_PROVIDER_TRIGGERED,{payload:{}}),this.getService(Re).setContextProvider(o)}catch(r){this.getService(k).catch("Error in _setContextProvider: ",r)}}_enableSuggestionMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SUGGESTION_MODE_TRIGGERED),this.getService(Re).setSuggestionMode(!0)}catch(o){this.getService(k).catch("Error in _enableSuggestionMode: ",o)}}_disableSuggestionMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SUGGESTION_MODE_TRIGGERED),this.getService(Re).setSuggestionMode(!1)}catch(o){this.getService(k).catch("Error in _disableSuggestionMode: ",o)}}_enableMobileMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MOBILE_MODE_TRIGGERED),this.getService(Re).setMobileMode(!0)}catch(o){this.getService(k).catch("Error in _enableMobileMode: ",o)}}_disableMobileMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MOBILE_MODE_TRIGGERED),this.getService(Re).setMobileMode(!1)}catch(o){this.getService(k).catch("Error in _disableMobileMode: ",o)}}_enableInlineCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(Re).enableInlineCommentMode()}catch(o){this.getService(k).catch("Error in _enableInlineCommentMode: ",o)}}_disableInlineCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(Re).disableInlineCommentMode()}catch(o){this.getService(k).catch("Error in _disableInlineCommentMode: ",o)}}_enableMinimap(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MINIMAP_TRIGGERED),this.getService(Re).enableMinimap()}catch(o){this.getService(k).catch("Error in _enableMinimap: ",o)}}_disableMinimap(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MINIMAP_TRIGGERED),this.getService(Re).disableMinimap()}catch(o){this.getService(k).catch("Error in _disableMinimap: ",o)}}_showCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: showCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).showCommentsOnDom()}catch(o){this.getService(k).catch("Error in _showCommentsOnDom: ",o)}}_hideCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: hideCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).hideCommentsOnDom()}catch(o){this.getService(k).catch("Error in _hideCommentsOnDom: ",o)}}_enableCommentTool(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TOOL_TRIGGERED),this.getService(Re).enableCommentTool()}catch(o){this.getService(k).catch("Error in _enableCommentTool: ",o)}}_disableCommentTool(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TOOL_TRIGGERED),this.getService(Re).disableCommentTool()}catch(o){this.getService(k).catch("Error in _disableCommentTool: ",o)}}_setTotalMediaLength(o){this.getService(k).log("%c[WB] Calling FUNCTION: setTotalMediaLength","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TOTAL_MEDIA_LENGTH_TRIGGERED,{payload:{length:o}}),this.getService(Re).setTotalMediaLength(o)}catch(r){this.getService(k).catch("Error in _setTotalMediaLength: ",r)}}_onCommentAdd(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentAdd","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_ADD_TRIGGERED),this.getService(Re).onCommentAdd$()}catch(o){return this.getService(k).catch("Error in _onCommentAdd: ",o),de()}}_onCommentUpdate(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentUpdate","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_UPDATE_TRIGGERED),this.getService(Re).onCommentUpdate$()}catch(o){return this.getService(k).catch("Error in _onCommentUpdate: ",o),de()}}_addCommentOnSelectedText(){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentOnSelectedText","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_SELECTED_TEXT_TRIGGERED),this.getService(Re).addCommentOnSelectedText()}catch(o){this.getService(k).catch("Error in _addCommentOnSelectedText: ",o)}}_enableSidebarUrlNavigation(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(Re).enableSidebarUrlNavigation()}catch(o){this.getService(k).catch("Error in _enableSidebarUrlNavigation: ",o)}}_disableSidebarUrlNavigation(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(Re).disableSidebarUrlNavigation()}catch(o){this.getService(k).catch("Error in _disableSidebarUrlNavigation: ",o)}}_setDStrategy(o){this.getService(k).log("%c[WB] Calling FUNCTION: setDStrategy","color: green;");try{this.trackEvent(Y.Events.Comments.SET_D_STRATEGY_TRIGGERED,{payload:{strategy:o}}),this.getService(Re).setDetectionStrategy(o)}catch(r){this.getService(k).catch("Error in _setDStrategy: ",r)}}_enableSidebarButtonOnCommentDialog(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(Re).enableSidebarButtonOnCommentDialog()}catch(o){this.getService(k).catch("Error in _enableSidebarButtonOnCommentDialog: ",o)}}_disableSidebarButtonOnCommentDialog(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableSidebarButtonOnCommentDialog()}catch(o){this.getService(k).catch("Error in _disableSidebarButtonOnCommentDialog: ",o)}}_onSidebarButtonOnCommentDialogClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onSidebarButtonOnCommentDialogClick","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_CLICK_TRIGGERED),this.getService(Re).getSidebarButtonOnCommentDialogClick$()}catch(o){return this.getService(k).catch("Error in _onSidebarButtonOnCommentDialogClick: ",o),de(null)}}_enableReactions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REACTIONS_TRIGGERED),this.getService(Re).enableReactions()}catch(o){this.getService(k).catch("Error in _enableReactions: ",o)}}_disableReactions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REACTIONS_TRIGGERED),this.getService(Re).disableReactions()}catch(o){this.getService(k).catch("Error in _disableReactions: ",o)}}_enableAnonymousEmail(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAnonymousEmail","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ANONYMOUS_EMAIL_TRIGGERED),this.getService(Re).enableAnonymousEmail()}catch(o){this.getService(k).catch("Error in _enableAnonymousEmail: ",o)}}_disableAnonymousEmail(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAnonymousEmail","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ANONYMOUS_EMAIL_TRIGGERED),this.getService(Re).disableAnonymousEmail()}catch(o){this.getService(k).catch("Error in _disableAnonymousEmail: ",o)}}_setRecordings(o){this.getService(k).log("%c[WB] Calling FUNCTION: setRecordings","color: green;");try{this.trackEvent(Y.Events.Comments.SET_RECORDINGS_TRIGGERED,{payload:{allowedRecordings:o}}),typeof o=="string"&&(o=o?.split(",")?.map(r=>r.trim())),this.getService(Re).setAllowedRecordings(o)}catch(r){this.getService(k).catch("Error in _setRecordings: ",r)}}_addCommentOnElement(o){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentOnElement","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_ELEMENT_TRIGGERED,{payload:{data:o}}),this.getService(Re).addCommentOnElement(o)}catch(r){this.getService(k).catch("Error in _addCommentOnElement: ",r)}}_enablePrivateCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(Re).enablePrivateCommentMode()}catch(o){this.getService(k).catch("Error in _enablePrivateCommentMode: ",o)}}_disablePrivateCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(Re).disablePrivateCommentMode()}catch(o){this.getService(k).catch("Error in _disablePrivateCommentMode: ",o)}}_enablePrivateMode(o){this.getService(k).log("%c[WB] Calling FUNCTION: enablePrivateMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_MODE_TRIGGERED,{payload:{config:o}}),this.getService(Re).enablePrivateMode(o)}catch(r){this.getService(k).catch("Error in _enablePrivateMode: ",r)}}_disablePrivateMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePrivateMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_MODE_TRIGGERED),this.getService(Re).disablePrivateMode()}catch(o){this.getService(k).catch("Error in _disablePrivateMode: ",o)}}_enableScrollToComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(Re).enableScrollToComment()}catch(o){this.getService(k).catch("Error in _enableScrollToComment: ",o)}}_disableScrollToComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(Re).disableScrollToComment()}catch(o){this.getService(k).catch("Error in _disableScrollToComment: ",o)}}_enableUserMentions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_USER_MENTIONS_TRIGGERED),this.getService(Re).enableUserMentions()}catch(o){this.getService(k).catch("Error in _enableUserMentions: ",o)}}_disableUserMentions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_USER_MENTIONS_TRIGGERED),this.getService(Re).disableUserMentions()}catch(o){this.getService(k).catch("Error in _disableUserMentions: ",o)}}_setCommentSidebarFilters(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_FILTERS_TRIGGERED,{payload:{filters:o}}),this.getService(Re).setCommentSidebarFilters(o)}catch(r){this.getService(k).catch("Error in _setCommentSidebarFilters: ",r)}}_setSystemFiltersOperator(o){this.getService(k).log("%c[WB] Calling FUNCTION: setSystemFiltersOperator","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SYSTEM_FILTERS_OPERATOR_TRIGGERED,{payload:{operator:o}}),this.getService(Re).setCommentSidebarSystemFiltersOperator(o)}catch(r){this.getService(k).catch("Error in _setSystemFiltersOperator: ",r)}}_enableCommentPinHighlighter(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(Re).enableCommentPinHighlighter()}catch(o){this.getService(k).catch("Error in _enableCommentPinHighlighter: ",o)}}_disableCommentPinHighlighter(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(Re).disableCommentPinHighlighter()}catch(o){this.getService(k).catch("Error in _disableCommentPinHighlighter: ",o)}}_enableDeleteOnBackspace(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(Re).enableDeleteOnBackspace()}catch(o){this.getService(k).catch("Error in _enableDeleteOnBackspace: ",o)}}_disableDeleteOnBackspace(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(Re).disableDeleteOnBackspace()}catch(o){this.getService(k).catch("Error in _disableDeleteOnBackspace: ",o)}}_enableHotkey(){this.getService(k).log("%c[WB] Calling FUNCTION: enableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_HOTKEY_TRIGGERED),this.getService(Re).enableHotkey()}catch(o){this.getService(k).catch("Error in _enableHotkey: ",o)}}_disableHotkey(){this.getService(k).log("%c[WB] Calling FUNCTION: disableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_HOTKEY_TRIGGERED),this.getService(Re).disableHotkey()}catch(o){this.getService(k).catch("Error in _disableHotkey: ",o)}}_enableDeviceIndicatorOnCommentPins(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(Re).enableDeviceIndicatorOnCommentPins()}catch(o){this.getService(k).catch("Error in _enableDeviceIndicatorOnCommentPins: ",o)}}_disableDeviceIndicatorOnCommentPins(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(Re).disableDeviceIndicatorOnCommentPins()}catch(o){this.getService(k).catch("Error in _disableDeviceIndicatorOnCommentPins: ",o)}}_getElementRefByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getElementRefByAnnotationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ELEMENT_REF_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).getElementRefByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _getElementRefByAnnotationId: ",r);return}}_scrollToCommentByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: scrollToCommentByAnnotationId","color: green;");try{this.trackEvent(Y.Events.Comments.SCROLL_TO_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).scrollToCommentByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _scrollToCommentByAnnotationId: ",r)}}_selectCommentByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");try{this.trackEvent(Y.Events.Comments.SELECT_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).selectCommentByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _selectCommentByAnnotationId: ",r)}}_enableRecordingSummary(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(Re).enableRecordingSummary()}catch(o){this.getService(k).catch("Error in _enableRecordingSummary: ",o)}}_disableRecordingSummary(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(Re).disableRecordingSummary()}catch(o){this.getService(k).catch("Error in _disableRecordingSummary: ",o)}}_enableRecordingTranscription(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(fo).enableRecordingTranscription()}catch(o){this.getService(k).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(fo).disableRecordingTranscription()}catch(o){this.getService(k).catch("Error in _disableRecordingTranscription: ",o)}}_enableRecordingCountdown(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(Re).enableRecordingCountdown()}catch(o){this.getService(k).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(Re).disableRecordingCountdown()}catch(o){this.getService(k).catch("Error in _disableRecordingCountdown: ",o)}}_setUnreadIndicatorMode(o){this.getService(k).log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;");try{this.trackEvent(Y.Events.Comments.SET_UNREAD_INDICATOR_MODE_TRIGGERED,{payload:{mode:o}}),this.getService(Re).setUnreadIndicatorMode(o)}catch(r){this.getService(k).catch("Error in _setUnreadIndicatorMode: ",r)}}_enableEnterKeyToSubmit(){this.getService(k).log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(Re).enableEnterKeyToSubmit()}catch(o){this.getService(k).catch("Error in _enableEnterKeyToSubmit: ",o)}}_disableEnterKeyToSubmit(){this.getService(k).log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(Re).disableEnterKeyToSubmit()}catch(o){this.getService(k).catch("Error in _disableEnterKeyToSubmit: ",o)}}_enablePinShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(Re).enablePinShadowDOM()}catch(o){this.getService(k).catch("Error in _enablePinShadowDOM: ",o)}}_disablePinShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(Re).disablePinShadowDOM()}catch(o){this.getService(k).catch("Error in _disablePinShadowDOM: ",o)}}_enableDialogShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(Re).enableDialogShadowDOM()}catch(o){this.getService(k).catch("Error in _enableDialogShadowDOM: ",o)}}_disableDialogShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(Re).disableDialogShadowDOM()}catch(o){this.getService(k).catch("Error in _disableDialogShadowDOM: ",o)}}_enableSidebarShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(Re).enableSidebarShadowDOM()}catch(o){this.getService(k).catch("Error in _enableSidebarShadowDOM: ",o)}}_disableSidebarShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(Re).disableSidebarShadowDOM()}catch(o){this.getService(k).catch("Error in _disableSidebarShadowDOM: ",o)}}_enableChangeDetectionInCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(Re).enableChangeDetectionInCommentMode()}catch(o){this.getService(k).catch("Error in _enableChangeDetectionInCommentMode: ",o)}}_disableChangeDetectionInCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(Re).disableChangeDetectionInCommentMode()}catch(o){this.getService(k).catch("Error in _disableChangeDetectionInCommentMode: ",o)}}_showResolvedCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: showResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).showResolvedCommentsOnDom()}catch(o){this.getService(k).catch("Error in _showResolvedCommentsOnDom: ",o)}}_hideResolvedCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: hideResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).hideResolvedCommentsOnDom()}catch(o){this.getService(k).catch("Error in _hideResolvedCommentsOnDom: ",o)}}_setCustomReactions(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(Re).setCustomReactions(o)}catch(r){this.getService(k).catch("Error in _setCustomReactions: ",r)}}_onCommentSelectionChange(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSelectionChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SELECTION_CHANGE_TRIGGERED),this.getService(Re).onCommentSelectionChange$()}catch(o){return this.getService(k).catch("Error in _onCommentSelectionChange: ",o),de(null)}}_getUnreadCommentCountByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByAnnotationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_ANNOTATION_ID_TRIGGERED,{payload:{commentAnnotationId:o}}),this.getService(Re).getUnreadCommentCountByAnnotationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentCountByAnnotationId: ",r),de(null)}}_getUnreadCommentAnnotationCountOnCurrentDocument(){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(Re).getUnreadCommentAnnotationCountOnCurrentDocument$()}catch(o){return this.getService(k).catch("Error in _getUnreadCommentAnnotationCountOnCurrentDocument: ",o),de(null)}}_getUnreadCommentCountOnCurrentDocument(){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(Re).getUnreadCommentCountOnCurrentDocument$()}catch(o){return this.getService(k).catch("Error in _getUnreadCommentCountOnCurrentDocument: ",o),de(null)}}_getUnreadCommentAnnotationCountByLocationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountByLocationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(Re).getUnreadCommentAnnotationCountByLocationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentAnnotationCountByLocationId: ",r),de(null)}}_getUnreadCommentCountByLocationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByLocationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(Re).getUnreadCommentCountByLocationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentCountByLocationId: ",r),de(null)}}_updateCommentDialogPosition(){this.getService(k).log("%c[WB] Calling FUNCTION: updateCommentDialogPosition","color: green;");try{this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_DIALOG_POSITION_TRIGGERED),this.getService(Re).updateCommentDialogPosition()}catch(o){this.getService(k).catch("Error in _updateCommentDialogPosition: ",o)}}_enableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Re).enableAreaComment()}catch(o){this.getService(k).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Re).disableAreaComment()}catch(o){this.getService(k).catch("Error in _disableAreaComment: ",o)}}_setPinCursorImage(o){this.getService(k).log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;");try{this.trackEvent(Y.Events.Comments.SET_PIN_CURSOR_IMAGE_TRIGGERED,{payload:{image:o}}),this.getService(Re).setPinCursorImage(o)}catch(r){this.getService(k).catch("Error in _setPinCursorImage: ",r)}}_addManualComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: addManualComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_MANUAL_COMMENT_TRIGGERED,{payload:{config:o}}),this.getService(Re).addManualComment(o)}catch(r){return this.getService(k).catch("Error in _addManualComment: ",r),Promise.resolve()}}_createCustomListDataOnAnnotation(o){this.getService(k).log("%c[WB] Calling FUNCTION: createCustomListDataOnAnnotation","color: green;");try{this.trackEvent(Y.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_ANNOTATION_TRIGGERED,{payload:{data:o}}),this.getService(Re).createCustomListDataOnAnnotation(o)}catch(r){this.getService(k).catch("Error in _createCustomListDataOnAnnotation: ",r)}}_createCustomListDataOnComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: createCustomListDataOnComment","color: green;");try{return this.trackEvent(Y.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_COMMENT_TRIGGERED,{payload:{data:o}}),this.getService(Pc).create(o)}catch(r){this.getService(k).catch("Error in _createCustomListDataOnComment: ",r)}}_excludeLocationIdsFromSidebar(o){this.getService(k).log("%c[WB] Calling FUNCTION: excludeLocationIdsFromSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.EXCLUDE_LOCATION_IDS_FROM_SIDEBAR_TRIGGERED,{payload:{locationIds:o}}),this.getService(Re).setExcludeLocationIdsFromSidebar(o)}catch(r){this.getService(k).catch("Error in _excludeLocationIdsFromSidebar: ",r)}}_enableBubbleOnPin(){this.getService(k).log("%c[WB] Calling FUNCTION: enableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(Re).enableBubbleOnPin()}catch(o){this.getService(k).catch("Error in _enableBubbleOnPin: ",o)}}_disableBubbleOnPin(){this.getService(k).log("%c[WB] Calling FUNCTION: disableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(Re).disableBubbleOnPin()}catch(o){this.getService(k).catch("Error in _disableBubbleOnPin: ",o)}}_enableBubbleOnPinHover(){this.getService(k).log("%c[WB] Calling FUNCTION: enableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(Re).enableBubbleOnPinHover()}catch(o){this.getService(k).catch("Error in _enableBubbleOnPinHover: ",o)}}_disableBubbleOnPinHover(){this.getService(k).log("%c[WB] Calling FUNCTION: disableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(Re).disableBubbleOnPinHover()}catch(o){this.getService(k).catch("Error in _disableBubbleOnPinHover: ",o)}}_enablePinDrag(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePinDrag","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_DRAG_TRIGGERED),this.getService(Re).enablePinDrag()}catch(o){this.getService(k).catch("Error in _enablePinDrag: ",o)}}_disablePinDrag(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePinDrag","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_DRAG_TRIGGERED),this.getService(Re).disablePinDrag()}catch(o){this.getService(k).catch("Error in _disablePinDrag: ",o)}}_enableMultiThread(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MULTI_THREAD_TRIGGERED),this.getService(Re).enableMultiThread()}catch(o){this.getService(k).catch("Error in _enableMultiThread: ",o)}}_disableMultiThread(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MULTI_THREAD_TRIGGERED),this.getService(Re).disableMultiThread()}catch(o){this.getService(k).catch("Error in _disableMultiThread: ",o)}}_enableGroupMatchedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(Re).enableGroupMatchedComments()}catch(o){this.getService(k).catch("Error in _enableGroupMatchedComments: ",o)}}_disableGroupMatchedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(Re).disableGroupMatchedComments()}catch(o){this.getService(k).catch("Error in _disableGroupMatchedComments: ",o)}}_updateContext(o,r,e){this.getService(k).log("%c[WB] Calling FUNCTION: updateContext","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_CONTEXT_TRIGGERED,{payload:{annotationId:o,context:r,config:e}}),this.getService(Re).updateCommentAnnotationContext(o,r,e)}catch(t){return this.getService(k).catch("Error in _updateContext: ",t),Promise.resolve()}}_updateVisibility(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateVisibility","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_VISIBILITY_TRIGGERED,{payload:{visibility:o}}),this.getService(Rn).updateVisibility(o)}catch(r){return this.getService(k).catch("Error in _updateVisibility: ",r),Promise.resolve()}}_getSelectedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: getSelectedComments","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_SELECTED_COMMENTS_TRIGGERED),this.getService(Ve).getSelectedComments$()}catch(o){return this.getService(k).catch("Error in _getSelectedComments: ",o),de([])}}_enableDeleteReplyConfirmation(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(Re).enableDeleteReplyConfirmation()}catch(o){this.getService(k).catch("Error in _enableDeleteReplyConfirmation: ",o)}}_disableDeleteReplyConfirmation(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(Re).disableDeleteReplyConfirmation()}catch(o){this.getService(k).catch("Error in _disableDeleteReplyConfirmation: ",o)}}_onCopyLink(){this.getService(k).log("%c[WB] Calling FUNCTION: onCopyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COPY_LINK_TRIGGERED),this.getService(Re).getCopyLink$()}catch(o){return this.getService(k).catch("Error in _onCopyLink: ",o),de("")}}_getCommentAnnotationById(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotationById","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATION_BY_ID_TRIGGERED,{payload:{config:o}}),this.getService(Re).getCommentAnnotationById(o)}catch(r){return this.getService(k).catch("Error in _getCommentAnnotationById: ",r),de(null)}}_enableCollapsedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(Re).enableCollapsedComments()}catch(o){this.getService(k).catch("Error in _enableCollapsedComments: ",o)}}_disableCollapsedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(Re).disableCollapsedComments()}catch(o){this.getService(k).catch("Error in _disableCollapsedComments: ",o)}}_onCommentSidebarActionButtonClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarActionButtonClick","color: green;");try{return this.getService(Re).getSidebarCustomActionEventData()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarActionButtonClick: ",o),de(null)}}_setCommentSidebarData(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarData","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DATA_TRIGGERED,{payload:{data:o,options:r}}),this.getService(Re).setCommentSidebarData(o,r)}catch(e){this.getService(k).catch("Error in _setCommentSidebarData: ",e)}}_onCommentSidebarInit(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarInit","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_INIT_TRIGGERED),this.getService(Re).getSidebarCustomActionEventDataOnInit()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarInit: ",o),de(null)}}_onCommentSidebarData(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarData","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_DATA_TRIGGERED),this.getService(Re).getSidebarCustomActionEventDataAllChanges()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarData: ",o),de(null)}}_setCommentSidebarDefaultCustomActions(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarDefaultCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DEFAULT_CUSTOM_ACTIONS_TRIGGERED,{payload:{actions:o}}),this.getService(Re).setSidebarCustomActionEventData(o,[],{},[],{})}catch(r){this.getService(k).catch("Error in _setCommentSidebarDefaultCustomActions: ",r)}}_enableSidebarCustomActions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(Re).enableSidebarCustomActions()}catch(o){this.getService(k).catch("Error in _enableSidebarCustomActions: ",o)}}_disableSidebarCustomActions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(Re).disableSidebarCustomActions()}catch(o){this.getService(k).catch("Error in _disableSidebarCustomActions: ",o)}}_enableQueryParamsComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(Re).enableQueryParamsComments()}catch(o){this.getService(k).catch("Error in _enableQueryParamsComments: ",o)}}_disableQueryParamsComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(Re).disableQueryParamsComments()}catch(o){this.getService(k).catch("Error in _disableQueryParamsComments: ",o)}}_enableResolveStatusAccessAdminOnly(){this.getService(k).log("%c[WB] Calling FUNCTION: enableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(Re).enableResolveStatusAccessAdminOnly()}catch(o){this.getService(k).catch("Error in _enableResolveStatusAccessAdminOnly: ",o)}}_disableResolveStatusAccessAdminOnly(){this.getService(k).log("%c[WB] Calling FUNCTION: disableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(Re).disableResolveStatusAccessAdminOnly()}catch(o){this.getService(k).catch("Error in _disableResolveStatusAccessAdminOnly: ",o)}}_enableLinkCallback(){this.getService(k).log("%c[WB] Calling FUNCTION: enableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_LINK_CALLBACK_TRIGGERED),this.getService(Re).enableLinkCallback()}catch(o){this.getService(k).catch("Error in _enableLinkCallback: ",o)}}_disableLinkCallback(){this.getService(k).log("%c[WB] Calling FUNCTION: disableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_LINK_CALLBACK_TRIGGERED),this.getService(Re).disableLinkCallback()}catch(o){this.getService(k).catch("Error in _disableLinkCallback: ",o)}}_enableSeenByUsers(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SEEN_BY_USERS_TRIGGERED),this.getService(Re).enableSeenByUsers()}catch(o){this.getService(k).catch("Error in _enableSeenByUsers: ",o)}}_disableSeenByUsers(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SEEN_BY_USERS_TRIGGERED),this.getService(Re).disableSeenByUsers()}catch(o){this.getService(k).catch("Error in _disableSeenByUsers: ",o)}}_enableShortUserName(){this.getService(k).log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SHORT_USER_NAME_TRIGGERED),this.getService(Re).enableShortUserName()}catch(o){this.getService(k).catch("Error in _enableShortUserName: ",o)}}_disableShortUserName(){this.getService(k).log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SHORT_USER_NAME_TRIGGERED),this.getService(Re).disableShortUserName()}catch(o){this.getService(k).catch("Error in _disableShortUserName: ",o)}}_addCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_ANNOTATION_TRIGGERED,{payload:{addCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).addCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _addCommentAnnotation: ",r),null}})}_approveCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: approveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.APPROVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{approveCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).approveCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _approveCommentAnnotation: ",r),null}})}_acceptCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: acceptCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ACCEPT_COMMENT_ANNOTATION_TRIGGERED,{payload:{acceptCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).acceptCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _acceptCommentAnnotation: ",r),null}})}_rejectCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: rejectCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.REJECT_COMMENT_ANNOTATION_TRIGGERED,{payload:{rejectCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).rejectCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _rejectCommentAnnotation: ",r),null}})}_subscribeCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: subscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.SUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{subscribeCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).toggleNotificationSubscription(o,"subscribe")}catch(r){return this.getService(k).catch("Error in _subscribeCommentAnnotation: ",r),null}})}_unsubscribeCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: unsubscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.UNSUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{unsubscribeCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).toggleNotificationSubscription(o,"unsubscribe")}catch(r){return this.getService(k).catch("Error in _unsubscribeCommentAnnotation: ",r),null}})}_deleteCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_ANNOTATION_TRIGGERED,{payload:{deleteCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).deleteCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _deleteCommentAnnotation: ",r),null}})}_getCommentAnnotations(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{query:o}}),this.getService(Rn).getCommentAnnotations(o).pipe(ge(r=>(r.data&&Object.keys(r.data).forEach(e=>{if(r.data?.[e]?.length){let t=r.data[e];r.data[e]=t?.map(i=>this.getService(Re).getCommentAnnotationForClient(i))}}),r)))}catch(r){return this.getService(k).catch("Error in _getCommentAnnotations: ",r),de({data:null})}}_getCommentAnnotationsCount(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotationsCount","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_COUNT_TRIGGERED,{payload:{query:o}}),this.getService(Rn).getCommentAnnotationsCount$(o)}catch(r){return this.getService(k).catch("Error in _getCommentAnnotationsCount: ",r),de({data:null})}}_assignUser(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: assignUser","color: green;");try{return this.trackEvent(Y.Events.Comments.ASSIGN_USER_TRIGGERED,{payload:{assignUserRequest:o}}),this.getService(Rn).convert(o).assignUser(o,"external")}catch(r){return this.getService(k).catch("Error in _assignUser: ",r),null}})}_updatePriority(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updatePriority","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_PRIORITY_TRIGGERED,{payload:{updatePriorityRequest:o}}),this.getService(Rn).convert(o).updatePriority(o,"external")}catch(r){return this.getService(k).catch("Error in _updatePriority: ",r),null}})}_updateStatus(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateStatus","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_STATUS_TRIGGERED,{payload:{updateStatusRequest:o}}),this.getService(Rn).convert(o).updateStatus(o,"external")}catch(r){return this.getService(k).catch("Error in _updateStatus: ",r),null}})}_updateAccess(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateAccess","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_ACCESS_TRIGGERED,{payload:{updateAccessRequest:o}}),this.getService(Rn).convert(o).updateAccess(o,"external")}catch(r){return this.getService(k).catch("Error in _updateAccess: ",r),null}})}_resolveCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: resolveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.RESOLVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{resolveCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).resolveCommentAnnotation(o)}catch(r){return this.getService(k).catch("Error in _resolveCommentAnnotation: ",r),null}})}_getLink(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getLink","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_LINK_TRIGGERED,{payload:{getLinkRequest:o}}),this.getService(Rn).convert(o).getLink(o,"external")}catch(r){return this.getService(k).catch("Error in _getLink: ",r),null}})}_copyLink(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: copyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.COPY_LINK_TRIGGERED,{payload:{copyLinkRequest:o}}),this.getService(Rn).convert(o).copyLink(o,"external")}catch(r){return this.getService(k).catch("Error in _copyLink: ",r),null}})}_addComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_TRIGGERED,{payload:{addCommentRequest:o}}),this.getService(Rn).convert(o).addComment(o,"external")}catch(r){return this.getService(k).catch("Error in _addComment: ",r),null}})}_updateComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_TRIGGERED,{payload:{updateCommentRequest:o}}),this.getService(Rn).convert(o).updateComment(o,"external")}catch(r){return this.getService(k).catch("Error in _updateComment: ",r),null}})}_deleteComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_TRIGGERED,{payload:{deleteCommentRequest:o}}),this.getService(Rn).convert(o).deleteComment(o,"external")}catch(r){return this.getService(k).catch("Error in _deleteComment: ",r),null}})}_getComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getComment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_TRIGGERED,{payload:{getCommentRequest:o}}),this.getService(Rn).convert(o).getComment(o)}catch(r){return this.getService(k).catch("Error in _getComment: ",r),[]}})}_addAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_ATTACHMENT_TRIGGERED,{payload:{addAttachmentRequest:o}}),this.getService(Rn).convert(o).addAttachment(o)}catch(r){return this.getService(k).catch("Error in _addAttachment: ",r),Promise.resolve([])}})}_deleteAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_ATTACHMENT_TRIGGERED,{payload:{deleteAttachmentRequest:o}}),this.getService(Rn).convert(o).deleteAttachment(o)}catch(r){return this.getService(k).catch("Error in _deleteAttachment: ",r),null}})}_getAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ATTACHMENT_TRIGGERED,{payload:{getAttachmentRequest:o}}),this.getService(Rn).convert(o).getAttachment(o)}catch(r){return this.getService(k).catch("Error in _getAttachment: ",r),[]}})}_getRecording(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_RECORDING_TRIGGERED,{payload:{getRecordingRequest:o}}),this.getService(Rn).convert(o).getRecording(o)}catch(r){return this.getService(k).catch("Error in _getRecording: ",r),[]}})}_deleteRecording(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_RECORDING_TRIGGERED,{payload:{deleteRecordingRequest:o}}),this.getService(Rn).convert(o).deleteRecording(o)}catch(r){return this.getService(k).catch("Error in _deleteRecording: ",r),null}})}_fetchCommentAnnotations(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: fetchCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.FETCH_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{fetchCommentAnnotationsRequest:o}}),this.getService(Rn).fetchCommentAnnotations(o)}catch(r){return this.getService(k).catch("Error in _fetchCommentAnnotations: ",r),{data:null}}})}_addReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_REACTION_TRIGGERED,{payload:{addReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o,"add")}catch(r){return this.getService(k).catch("Error in _addReaction: ",r),null}})}_deleteReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_REACTION_TRIGGERED,{payload:{deleteReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o,"delete")}catch(r){return this.getService(k).catch("Error in _deleteReaction: ",r),null}})}_toggleReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: toggleReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.TOGGLE_REACTION_TRIGGERED,{payload:{toggleReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o)}catch(r){return this.getService(k).catch("Error in _toggleReaction: ",r),null}})}_on(o){this.getService(k).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(Rn).onAction(o)}catch(r){return this.getService(k).catch("Error in _on: ",r),de(null)}}_enableReadOnly(){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.ENABLE_READ_ONLY_TRIGGERED),this.getService(Re).enableReadOnly()}catch(o){this.getService(k).catch("Error in _toggleReaction: ",o);return}})}_disableReadOnly(){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.DISABLE_READ_ONLY_TRIGGERED),this.getService(Re).disableReadOnly()}catch(o){this.getService(k).catch("Error in _disableReadOnly: ",o);return}})}_setAssignToType(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAssignToType","color: green;");try{this.trackEvent(Y.Events.Comments.SET_ASSIGN_TO_TYPE_TRIGGERED,{payload:{type:o.type}}),this.getService(Re).setAssignToType(o)}catch(r){this.getService(k).catch("Error in _setAssignToType: ",r)}}_enableContextInPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: enableContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).enableContextInPageModeComposer()}catch(o){this.getService(k).catch("Error in _enableContextInPageModeComposer: ",o)}}_disableContextInPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: disableContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).disableContextInPageModeComposer()}catch(o){this.getService(k).catch("Error in _disableContextInPageModeComposer: ",o)}}_clearPageModeComposerContext(){this.getService(k).log("%c[WB] Calling FUNCTION: clearPageModeComposerContext","color: green;");try{this.trackEvent(Y.Events.Comments.CLEAR_PAGE_MODE_COMPOSER_CONTEXT_TRIGGERED),this.getService(Re).clearPageModeComposerContext()}catch(o){this.getService(k).catch("Error in _clearPageModeComposerContext: ",o)}}_setContextInPageModeComposer(o){this.getService(k).log("%c[WB] Calling FUNCTION: setContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).setPageModeComposerContext(o)}catch(r){this.getService(k).catch("Error in _setContextInPageModeComposer: ",r)}}_focusPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: focusPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.FOCUS_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).focusPageModeComposer()}catch(o){this.getService(k).catch("Error in _focusPageModeComposer: ",o)}}_enableCustomAutocompleteSearch(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(Re).enableCustomAutocompleteSearch()}catch(o){this.getService(k).catch("Error in _enableCustomAutocompleteSearch: ",o);return}}_disableCustomAutocompleteSearch(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(Re).disableCustomAutocompleteSearch()}catch(o){this.getService(k).catch("Error in _disableCustomAutocompleteSearch: ",o);return}}_setTransformContext(o){this.getService(k).log("%c[WB] Calling FUNCTION: setTransformContext","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TRANSFORM_CONTEXT_TRIGGERED,{payload:{transformContext:o}}),this.getService(Re).setTransformContext(o)}catch(r){this.getService(k).catch("Error in _setTransformContext: ",r);return}}_enableSvgAsImg(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SVG_AS_IMG_TRIGGERED),this.getService(Re).enableSvgAsImg()}catch(o){this.getService(k).catch("Error in _enableSvgAsImg: ",o);return}}_disableSvgAsImg(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SVG_AS_IMG_TRIGGERED),this.getService(Re).disableSvgAsImg()}catch(o){this.getService(k).catch("Error in _disableSvgAsImg: ",o);return}}_enableFullExpanded(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_EXPANDED_TRIGGERED),this.getService(Re).enableFullExpanded()}catch(o){this.getService(k).catch("Error in _enableFullExpanded: ",o);return}}_disableFullExpanded(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_EXPANDED_TRIGGERED),this.getService(Re).disableFullExpanded()}catch(o){this.getService(k).catch("Error in _disableFullExpanded: ",o);return}}_enableCommentToNearestAllowedElement(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(Re).enableCommentToNearestAllowedElement()}catch(o){this.getService(k).catch("Error in _enableCommentToNearestAllowedElement: ",o);return}}_disableCommentToNearestAllowedElement(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(Re).disableCommentToNearestAllowedElement()}catch(o){this.getService(k).catch("Error in _disableCommentToNearestAllowedElement: ",o);return}}_enableDraftMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DRAFT_MODE_TRIGGERED),this.getService(Re).enableDraftMode()}catch(o){this.getService(k).catch("Error in _enableDraftMode: ",o);return}}_disableDraftMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DRAFT_MODE_TRIGGERED),this.getService(Re).disableDraftMode()}catch(o){this.getService(k).catch("Error in _disableDraftMode: ",o);return}}_enableFilterCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).enableFilterCommentsOnDom()}catch(o){this.getService(k).catch("Error in _enableFilterCommentsOnDom: ",o);return}}_disableFilterCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).disableFilterCommentsOnDom()}catch(o){this.getService(k).catch("Error in _disableFilterCommentsOnDom: ",o);return}}_enableReplyAvatars(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REPLY_AVATARS_TRIGGERED),this.getService(Re).enableReplyAvatars()}catch(o){this.getService(k).catch("Error in _enableReplyAvatars: ",o);return}}_disableReplyAvatars(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REPLY_AVATARS_TRIGGERED),this.getService(Re).disableReplyAvatars()}catch(o){this.getService(k).catch("Error in _disableReplyAvatars: ",o);return}}_setMaxReplyAvatars(o){this.getService(k).log("%c[WB] Calling FUNCTION: setMaxReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.SET_MAX_REPLY_AVATARS_TRIGGERED,{payload:{maxReplyAvatars:o}}),this.getService(Re).setMaxReplyAvatars(o)}catch(r){this.getService(k).catch("Error in _setMaxReplyAvatars: ",r);return}}_setSidebarButtonCountType(o){this.getService(k).log("%c[WB] Calling FUNCTION: setSidebarButtonCountType","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SIDEBAR_BUTTON_COUNT_TYPE_TRIGGERED,{payload:{type:o}}),this.getService(Re).setSidebarButtonCountType(o)}catch(r){this.getService(k).catch("Error in _setSidebarButtonCountType: ",r);return}}_enableFilterGhostCommentsInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(Re).enableFilterGhostCommentsInSidebar()}catch(o){this.getService(k).catch("Error in _enableFilterGhostCommentsInSidebar: ",o);return}}_disableFilterGhostCommentsInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(Re).disableFilterGhostCommentsInSidebar()}catch(o){this.getService(k).catch("Error in _disableFilterGhostCommentsInSidebar: ",o);return}}_enableFullScreenInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(Re).enableFullScreenInSidebar()}catch(o){this.getService(k).catch("Error in _enableFullScreenInSidebar: ",o);return}}_disableFullScreenInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(Re).disableFullScreenInSidebar()}catch(o){this.getService(k).catch("Error in _disableFullScreenInSidebar: ",o);return}}_setComposerFileAttachments(o){this.getService(k).log("%c[WB] Calling FUNCTION: setComposerFileAttachments","color: green;");try{this.getService(Re).setComposerFileAttachments(o),this.trackEvent(Y.Events.Comments.SET_COMPOSER_FILE_ATTACHMENTS_TRIGGERED,{payload:{data:o}})}catch(r){this.getService(k).catch("Error in _setComposerFileAttachments: ",r);return}}_setAllowedFileTypes(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAllowedFileTypes","color: green;");try{this.trackEvent(Y.Events.Comments.COMMENT_ATTACHMENT_SET_ALLOWED_FILE_TYPES_TRIGGERED,{payload:{allowedFileTypes:o}}),this.getService(Re).setAllowedFileTypes(o)}catch(r){this.getService(k).catch("Error in _setAllowedFileTypes: ",r);return}}_enableForceCloseAllOnEsc(){this.getService(k).log("%c[WB] Calling FUNCTION: enableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(Re).enableForceCloseAllOnEsc()}catch(o){this.getService(k).catch("Error in _enableForceCloseAllOnEsc: ",o);return}}_disableForceCloseAllOnEsc(){this.getService(k).log("%c[WB] Calling FUNCTION: disableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(Re).disableForceCloseAllOnEsc()}catch(o){this.getService(k).catch("Error in _disableForceCloseAllOnEsc: ",o);return}}_markAsRead(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: markAsRead","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_READ_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(Re).markAsRead(o);return}catch(r){this.getService(k).catch("Error in _markAsRead: ",r);return}})}_markAsUnread(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: markAsUnread","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_UNREAD_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(Re).markAsUnread(o)}catch(r){this.getService(k).catch("Error in _markAsUnread: ",r);return}})}_enableScreenshot(){this.getService(k).log("%c[WB] Calling FUNCTION: enableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCREENSHOT_TRIGGERED),this.getService(Re).enableScreenshot()}catch(o){this.getService(k).catch("Error in _enableScreenshot: ",o);return}}_disableScreenshot(){this.getService(k).log("%c[WB] Calling FUNCTION: disableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCREENSHOT_TRIGGERED),this.getService(Re).disableScreenshot()}catch(o){this.getService(k).catch("Error in _disableScreenshot: ",o);return}}_enablePaginatedContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(Re).enablePaginatedContactList()}catch(o){this.getService(k).catch("Error in _enablePaginatedContactList: ",o);return}}_disablePaginatedContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(Re).disablePaginatedContactList()}catch(o){this.getService(k).catch("Error in _disablePaginatedContactList: ",o);return}}};var QU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ContactElement","color: blue;"),this.isUserGlobalContact=this._isUserGlobalContact,this.onContactSelected=this._onContactSelected,this.enableAtHere=this._enableAtHere,this.setAtHereLabel=this._setAtHereLabel,this.setAtHereDescription=this._setAtHereDescription,this.disableAtHere=this._disableAtHere,this.updateContactListScopeForOrganizationUsers=this._updateContactListScopeForOrganizationUsers,this.updateContactList=this._updateContactList,this.getContactList=this._getContactList}_isUserGlobalContact(){this.getService(k).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Contact.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(un).isUserGlobalContact$()}catch(o){return this.getService(k).catch("Error in _isUserGlobalContact: ",o),de(!1)}}_onContactSelected(){this.getService(k).log("%c[WB] Calling FUNCTION: onContactSelected","color: green;");try{return this.trackEvent(Y.Events.Contact.ON_CONTACT_SELECTED_TRIGGERED),this.getService(un).onContactSelected$()}catch(o){return this.getService(k).catch("Error in _onContactSelected: ",o),de(null)}}_enableAtHere(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.ENABLE_AT_HERE_TRIGGERED),this.getService(un).enableAtHere()}catch(o){this.getService(k).catch("Error in _enableAtHere: ",o)}}_setAtHereLabel(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAtHereLabel","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_LABEL_TRIGGERED,{payload:{label:o}}),this.getService(un).setAtHereLabel(o)}catch(r){this.getService(k).catch("Error in setAtHereLabel: ",r)}}_setAtHereDescription(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAtHereDescription","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_DESCRIPTION_TRIGGERED,{payload:{description:o}}),this.getService(un).setAtHereDescription(o)}catch(r){this.getService(k).catch("Error in setAtHereDescription: ",r)}}_disableAtHere(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.DISABLE_AT_HERE_TRIGGERED),this.getService(un).disableAtHere()}catch(o){this.getService(k).catch("Error in _disableAtHere: ",o)}}_updateContactListScopeForOrganizationUsers(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateContactListScopeForOrganizationUsers","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_SCOPE_FOR_ORGANIZATION_USERS_TRIGGERED,{payload:{scope:o}}),this.getService(un).updateContactListScopeForOrganizationUsers(o)}catch(r){this.getService(k).catch("Error in _updateContactListScopeForOrganizationUsers: ",r)}}_updateContactList(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: _updateContactList","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{payload:{userContacts:o,config:r}}),typeof o=="object"&&o instanceof Array&&(!r||r&&typeof r=="object")&&(o=JSON.parse(JSON.stringify(o)),this.getService(un).convert(r).updateContactList(o,r))}catch(e){this.getService(k).catch("Error in _updateContactList: ",e)}}_getContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: getContactList","color: green;");try{return this.trackEvent(Y.Events.Contact.GET_CONTACT_LIST_TRIGGERED),this.getService(un).getContactList$()}catch(o){return this.getService(k).catch("Error in _getContactList: ",o),de(null)}}};var eV=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map,this.subscriptions=[]}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in CrdtActionsService triggerAction: ",i)}}onAction(e){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it);let t=this.actionSubjects.get(e);return t?t.asObservable():de(null)}catch(t){return this.loggingService.catch("Error in CrdtActionsService onAction: ",t),de(null)}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Gs=(()=>{let o=class o{static generateKey(){return X(this,null,function*(){try{return yield window.crypto.subtle.generateKey({name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"])}catch(e){return at.catch("Failed to generate key: ",e),null}})}static deriveKeyFromPassword(e,t){return X(this,null,function*(){try{if(!t){let c=yield window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));t=new Uint8Array(c).slice(0,this.SALT_LENGTH)}let i=new TextEncoder().encode(e),a=yield window.crypto.subtle.importKey("raw",i,"PBKDF2",!1,["deriveBits","deriveKey"]);return{key:yield window.crypto.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:this.PBKDF2_ITERATIONS,hash:"SHA-256"},a,{name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"]),salt:t}}catch(i){return at.catch("Failed to derive key from password: ",i),null}})}static resolveKey(e){return X(this,null,function*(){try{if(e.customKey){if(e.customKey instanceof CryptoKey)return{key:e.customKey};if(typeof e.customKey=="string"){let i=yield this.deriveKeyFromPassword(e.customKey,e.customSalt);if(!i)return at.catch("Failed to derive key from password"),null;let{key:a,salt:l}=i;return{key:a,salt:l}}}let t=yield this.generateKey();return t?{key:t}:(at.catch("Failed to generate key"),null)}catch(t){return at.catch("Failed to resolve key: ",t),null}})}static encrypt(i){return X(this,arguments,function*(e,t={}){try{if(t.customEncryptCallback)try{return yield t.customEncryptCallback(e)}catch(_){return at.catch("Custom encryption callback failed: ",_),""}let a=yield this.resolveKey(t);if(!a)return at.catch("Failed to resolve key"),"";let{key:l,salt:c}=a,d;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return at.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";d=t.customIV}else d=window.crypto.getRandomValues(new Uint8Array(this.IV_LENGTH));let g=new TextEncoder().encode(e),u={name:"AES-GCM",iv:d,tagLength:128};t.additionalData&&(u.additionalData=t.additionalData);try{let _=yield window.crypto.subtle.encrypt(u,l,g),w=new Uint8Array(d.length+_.byteLength);w.set(d,0),w.set(new Uint8Array(_),d.length);let A=8192,M=[];for(let j=0;j<w.length;j+=A){let q=w.slice(j,Math.min(j+A,w.length)),ie="";for(let _e=0;_e<q.length;_e++)ie+=String.fromCharCode(q[_e]);M.push(ie)}return btoa(M.join(""))}catch(_){return at.catch("Encryption failed: ",_),""}}catch(a){return at.catch("Failed to encrypt: ",a),null}})}static decrypt(i){return X(this,arguments,function*(e,t={}){try{if(t.customDecryptCallback)try{return yield t.customDecryptCallback(e)}catch(_){return at.catch("Custom decryption callback failed: ",_),""}let a=yield this.resolveKey(t);if(!a)return at.catch("Failed to resolve key"),"";let{key:l}=a,c=new Uint8Array(atob(e).split("").map(_=>_.charCodeAt(0)));if(c.length<this.IV_LENGTH)return at.catch("Invalid encrypted data: Too short"),"";let d;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return at.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";d=t.customIV}else d=c.slice(0,this.IV_LENGTH);let g=c.slice(this.IV_LENGTH),u={name:"AES-GCM",iv:d,tagLength:128};t.additionalData&&(u.additionalData=t.additionalData);try{let _=yield window.crypto.subtle.decrypt(u,l,g);return new TextDecoder().decode(_)}catch(_){return at.catch("Decryption failed: ",_),""}}catch(a){return at.catch("Failed to decrypt: ",a),""}})}static encryptData(i){return X(this,arguments,function*(e,t={}){try{let a=JSON.stringify(e);return(yield this.encrypt(a,t))??""}catch(a){return at.catch("Failed to encrypt data: ",a),""}})}static decryptData(i){return X(this,arguments,function*(e,t={}){try{let a=yield this.decrypt(e,t);return JSON.parse(a)}catch(a){return at.catch("Failed to decrypt data: ",a),null}})}};o.IV_LENGTH=12,o.SALT_LENGTH=16,o.PBKDF2_ITERATIONS=1e5,o.KEY_LENGTH=256;let n=o;return n})();var Ri=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w){this.activityService=e,this.analyticsService=t,this.authService=i,this.commonDbService=a,this.commonDbUtilsService=l,this.configService=c,this.crdtActionsService=d,this.docService=g,this.domService=u,this.loggingService=_,this.notificationService=w,this.MIN_WEBHOOK_DEBOUNCE_TIME=5*1e3,this.webhookDebounceTime=this.MIN_WEBHOOK_DEBOUNCE_TIME,this.updateDataWebhookTrigger$=new it,this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null,this.webhookEnabled$=new Se(!1),this.lastCrdtDataUpdatedId=null,this.MIN_ACTIVITY_DEBOUNCE_TIME=10*1e3,this.activityDebounceTime=600*1e3,this.editorEditTrackers=new Map;try{this.loggingService.log("%c[WB] Creating CLASS: CrdtService","color: blue;"),this.authService.setCrdtService(this),this.setupUpdateDataWebhookDebounce(),this.docService.addPreDocumentIdChangeFunction("crdt-service",()=>(this.lastCrdtDataUpdatedId=null,Promise.resolve())),this.authService.addPreSignOutFuction("crdt-service",()=>(this.lastCrdtDataUpdatedId=null,Promise.resolve()))}catch(A){this.loggingService.catch("Error in CrdtService constructor: ",A)}}trackCrdtDataUpdated(e){try{if(this.lastCrdtDataUpdatedId===e)return;this.lastCrdtDataUpdatedId=e,this.analyticsService.trackEvent(Y.Events.Crdt.CRDT_DATA_UPDATED,{id:e})}catch(t){this.loggingService.catch("Error in CrdtService trackCrdtDataUpdated: ",t)}}setupUpdateDataWebhookDebounce(){try{this.updateDataWebhookDebounceSubscription&&(this.updateDataWebhookDebounceSubscription.unsubscribe(),this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null),this.updateDataWebhookDebounceSubscription=this.updateDataWebhookTrigger$.pipe(dn(e=>{this.pendingWebhookEvent=e}),to(this.webhookDebounceTime)).subscribe(e=>{this.pendingWebhookEvent=null,this.webhookEnabled$.value&&e&&this.triggerUpdateDataWebhook(e)},e=>{this.loggingService.catch("Error in CrdtService setupUpdateDataWebhookDebounce subscription: ",e)})}catch(e){this.loggingService.catch("Error in CrdtService setupUpdateDataWebhookDebounce: ",e)}}setWebhookDebounceTime(e){try{e<this.MIN_WEBHOOK_DEBOUNCE_TIME&&(this.loggingService.catch("Error in CrdtService setWebhookDebounceTime: Value must be at least "+this.MIN_WEBHOOK_DEBOUNCE_TIME/1e3+" seconds ("+this.MIN_WEBHOOK_DEBOUNCE_TIME+"ms). Using minimum value."),e=this.MIN_WEBHOOK_DEBOUNCE_TIME),this.pendingWebhookEvent&&this.webhookEnabled$.value&&(this.triggerUpdateDataWebhook(this.pendingWebhookEvent),this.pendingWebhookEvent=null),this.webhookDebounceTime=e,this.setupUpdateDataWebhookDebounce()}catch(t){this.loggingService.catch("Error in CrdtService setWebhookDebounceTime: ",t)}}updateData(a){return X(this,arguments,function*({id:e,state:t,data:i}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateData","color: green;");let l=this.docService.getDocumentPaths(),c=this.authService.getUser(),d=this.domService.getTabId();if(c?.userId&&l){let g=It(e),u=c.userId,_=It(c.userId),w=new Date().toISOString(),A=null,M=this.configService.getEncryptionProvider();if(M?.encrypt&&typeof M.encrypt=="function")A=yield M.encrypt({data:t});else{let _e={};_e.customKey=g,A=yield Gs.encryptData(t,_e)}let j={id:e,veltId:g,encryptedState:A,lastUpdate:w,lastUpdatedBy:u,lastUpdatedByVeltUserId:_,sessionId:d},q={methodName:BF.UPDATE_DATA,uniqueId:lt(),timestamp:new Date().getTime(),source:VF.INTERNAL,payload:{id:e,data:i,lastUpdatedBy:u,sessionId:d,lastUpdate:w}},ie=yield this.commonDbService.updateData({feature:"crdtData",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:g,skipFirestore:!0},data:j});return this.crdtActionsService.triggerAction(wZ.UPDATE_DATA,q),this.trackCrdtDataUpdated(e),this.updateDataWebhookTrigger$.next(q?.payload),this.trackEditForActivity(e),ie}return Promise.resolve(null)}catch(l){return this.loggingService.catch("Error in CrdtService updateData: ",l),Promise.resolve(null)}})}triggerUpdateDataWebhook(e){try{this.updateNotificationsDatabase(e,DZ.UPDATE_DATA)}catch(t){this.loggingService.catch("Error in CrdtService triggerUpdateDataWebhook: ",t)}}onDataChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onDataChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"crdtData",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(ye(c=>X(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.data.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.data.encryptedState,u)}c.data.state=d,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c?.encryptedState}return c}}catch(d){return this.loggingService.catch("Error in CrdtService onDataChange subscription: ",d),null}}))):de(null))).subscribe(l=>{l&&(l.data?t(l.data):t(l))});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onDataChange: ",i),()=>{}}}getData(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getData","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtData",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}});if(l?.encryptedState){let c=null,d=this.configService.getEncryptionProvider();if(d?.decrypt&&typeof d.decrypt=="function")c=yield d.decrypt({data:l.encryptedState});else{let g={};g.customKey=a,c=yield Gs.decryptData(l.encryptedState,g)}l.state=c,delete l?.encryptedState}return l}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getData: ",i),Promise.resolve(null)}})}onStateChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onStateChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"crdtSyncState",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(ye(c=>X(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.data.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.data.encryptedState,u)}c.data.state=d,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c?.encryptedState}return c}}catch(d){return this.loggingService.catch("Error in CrdtService onStateChange subscription: ",d),null}}))):de(null))).subscribe(l=>{l&&(l.data?t(l.data):t(l))});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onStateChange: ",i),()=>{}}}updateState(i){return X(this,arguments,function*({id:e,state:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateState","color: green;");let a=this.docService.getDocumentPaths(),l=this.authService.getUser(),c=this.domService.getTabId();if(l?.userId&&a){let d=It(e),g=l.userId,u=It(g),_=null,w=this.configService.getEncryptionProvider();if(w?.encrypt&&typeof w.encrypt=="function")_=yield w.encrypt({data:t});else{let A={};A.customKey=d,_=yield Gs.encryptData(t,A)}return this.commonDbService.setData({feature:"crdtSyncState",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:d,skipFirestore:!0},data:{id:e,veltId:d,encryptedState:_,lastUpdate:new Date().toISOString(),lastUpdatedBy:g,lastUpdatedByVeltUserId:u,sessionId:c}})}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService updateState: ",a),Promise.resolve(null)}})}registerSyncUser(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: registerSyncUser","color: green;");let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=this.configService.getApiKey(),c=It(e),d=this.domService.getTabId();if(i?.userId&&a&&l){let g=i.userId,u=It(g),_={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:u,apiKey:l,skipFirestore:!0},w={userId:g,veltUserId:u,status:"online",lastSeen:Date.now(),sessionId:d};yield this.commonDbService.setData({feature:"crdtSyncPresence",properties:_,data:w});let A=this.commonDbUtilsService.getDocumentPath({feature:"crdtSyncPresence",properties:_,defaultDocumentPaths:a,apiKey:l});A&&(yield this.commonDbService.setupOnDisconnect(A,{status:"offline",lastSeen:new Date().getTime(),sessionId:d}))}}catch(i){this.loggingService.catch("Error in CrdtService registerSyncUser: ",i)}})}onRegisteredUserChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onRegisteredUserChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"allCrdtSyncPresence",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(dn(c=>{try{c?.data?t(c.data):t(c)}catch(d){this.loggingService.catch("Error in CrdtService onRegisteredUserChange subscription: ",d)}})):de(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onRegisteredUserChange: ",i),()=>{}}}setPresence(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: setPresence","color: green;");let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=this.configService.getApiKey(),c=It(e),d=this.domService.getTabId();if(i?.userId&&a&&l){let g=i.userId,u=It(g),_={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:u,apiKey:l,skipFirestore:!0},w={userId:g,veltUserId:u,status:"online",lastSeen:Date.now(),sessionId:d};yield this.commonDbService.setData({feature:"crdtPresence",properties:_,data:w});let A=this.commonDbUtilsService.getDocumentPath({feature:"crdtPresence",properties:_,defaultDocumentPaths:a,apiKey:l});A&&(yield this.commonDbService.setupOnDisconnect(A,{status:"offline",lastSeen:new Date().getTime(),sessionId:d}))}}catch(i){this.loggingService.catch("Error in CrdtService setPresence: ",i)}})}onPresenceChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onPresenceChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"allCrdtPresence",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(dn(c=>{try{c?.data?t(c.data):t(c)}catch(d){this.loggingService.catch("Error in CrdtService onPresenceChange subscription: ",d)}})):de(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onPresenceChange: ",i),()=>{}}}saveVersion(l){return X(this,arguments,function*({id:e,versionId:t,versionName:i,state:a}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveVersion","color: green;");let c=this.docService.getDocumentPaths();if(c){let d=It(e),g="",u=this.configService.getEncryptionProvider();if(u?.encrypt&&typeof u.encrypt=="function")g=yield u.encrypt({data:a});else{let w={};w.customKey=d,g=yield Gs.encryptData(a,w)}let _={versionId:t,versionName:i,encryptedState:g,timestamp:new Date().getTime()};return this.commonDbService.setData({feature:"crdtVersion",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:d,versionId:t,skipFirestore:!0},data:h({id:e},_)})}return Promise.resolve(null)}catch(c){return this.loggingService.catch("Error in CrdtService saveVersion: ",c),Promise.resolve(null)}})}getVersion(i){return X(this,arguments,function*({id:e,versionId:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersion","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtVersion",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,versionId:t,skipFirestore:!0}});if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=l,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c.encryptedState}return c}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService getVersion: ",a),Promise.resolve(null)}})}getVersions(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersions","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtVersions",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}}),c=null;if(l){c=[];for(let d of Object.values(l))if(d?.encryptedState){let g=null,u=this.configService.getEncryptionProvider();if(u?.decrypt&&typeof u.decrypt=="function")g=yield u.decrypt({data:d.encryptedState});else{let w={};w.customKey=a,g=yield Gs.decryptData(d.encryptedState,w)}let _=y(h({},d),{state:g});delete _?.encryptedState,c.push(_)}else c.push(d)}return c}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getVersions: ",i),Promise.resolve(null)}})}encryptCrdtData(e,t){return X(this,null,function*(){try{let i=this.configService.getEncryptionProvider();if(i?.encrypt&&typeof i.encrypt=="function")return yield i.encrypt({data:e});let a={};return a.customKey=t,yield Gs.encryptData(e,a)}catch(i){return this.loggingService.catch("Error in CrdtService encryptCrdtData: ",i),null}})}decryptCrdtData(e,t){return X(this,null,function*(){try{let i=this.configService.getEncryptionProvider();if(i?.decrypt&&typeof i.decrypt=="function")return yield i.decrypt({data:e});let a={};return a.customKey=t,yield Gs.decryptData(e,a)}catch(i){return this.loggingService.catch("Error in CrdtService decryptCrdtData: ",i),null}})}pushMessage(u){return X(this,arguments,function*({id:e,data:t,yjsClientId:i,messageType:a,eventData:l,type:c,contentKey:d,source:g}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: pushMessage","color: green;");let _=this.docService.getDocumentPaths(),w=this.authService.getUser();if(w?.userId&&_){let A=It(e),M=yield this.encryptCrdtData(t,A);if(M==null)return;let j=w.userId,q=It(w.userId),ie=this.domService.getTabId();if(yield this.commonDbService.pushData({feature:"crdtMessages",properties:{documentId:_?.documentId??"",organizationId:_?.organizationId??"",id:A,skipFirestore:!0},data:{id:e,veltId:A,encryptedData:M,yjsClientId:i,messageType:a??null,type:c??null,contentKey:d??null,source:g??"unknown",updatedByUserId:j,updatedByVeltUserId:q,sessionId:ie,timestamp:this.commonDbService.getServerTimestamp()}}),a==="sync"){let _e=new Date().toISOString(),ae={methodName:BF.UPDATE_DATA,uniqueId:lt(),timestamp:new Date().getTime(),source:VF.INTERNAL,payload:{id:e,data:l,lastUpdatedBy:j,sessionId:ie,lastUpdate:_e}};this.crdtActionsService.triggerAction(wZ.UPDATE_DATA,ae),this.trackCrdtDataUpdated(e),this.updateDataWebhookTrigger$.next(ae?.payload),this.trackEditForActivity(e)}}}catch(_){this.loggingService.catch("Error in CrdtService pushMessage: ",_)}})}onMessage({id:e,callback:t,afterTs:i}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onMessage","color: green;");let a=It(e),l=this.docService.getDocumentPaths$().pipe(ye(c=>c?this.commonDbService.streamChildAdded({feature:"crdtMessages",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:a,skipFirestore:!0},afterTs:i}):de(null))).pipe($e(c=>!!c),ST(c=>X(this,null,function*(){try{if(c.encryptedData){let d=yield this.decryptCrdtData(c.encryptedData,a);if(d==null)return null;c.data=d,delete c.encryptedData}else if(!c.data)return null;return c}catch(d){return this.loggingService.catch("Error in CrdtService onMessage decryption: ",d),null}})),$e(c=>!!c)).subscribe(c=>{try{t(c)}catch(d){this.loggingService.catch("Error in CrdtService onMessage subscription: ",d)}});return()=>l.unsubscribe()}catch(a){return this.loggingService.catch("Error in CrdtService onMessage: ",a),()=>{}}}getMessages(i){return X(this,arguments,function*({id:e,afterTs:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getMessages","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtMessages",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,skipFirestore:!0}});if(!c||typeof c!="object"||c?.errorCode)return[];let d=[];for(let g of Object.keys(c)){let u=c[g];if(!(!u||typeof u!="object")&&!(t!=null&&u.timestamp!=null&&u.timestamp<=t))if(u.encryptedData){let _=yield this.decryptCrdtData(u.encryptedData,l);if(_==null)continue;d.push({data:_,yjsClientId:u.yjsClientId,timestamp:u.timestamp})}else u.data&&d.push({data:u.data,yjsClientId:u.yjsClientId,timestamp:u.timestamp})}return d.sort((g,u)=>g.timestamp-u.timestamp),d}return[]}catch(a){return this.loggingService.catch("Error in CrdtService getMessages: ",a),[]}})}getSnapshot(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getSnapshot","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtSnapshot",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}});if(!l||typeof l!="object"||Object.keys(l).length===0||l?.errorCode)return null;if(l?.encryptedState){let c=yield this.decryptCrdtData(l.encryptedState,a);if(c==null)return null;l.state=c,delete l?.encryptedState}if(l?.encryptedVector){let c=yield this.decryptCrdtData(l.encryptedVector,a);if(c==null)return null;l.vector=c,delete l?.encryptedVector}return l}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getSnapshot: ",i),Promise.resolve(null)}})}saveSnapshot(d){return X(this,arguments,function*({id:e,state:t,vector:i,type:a,contentKey:l,source:c}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveSnapshot","color: green;");let g=this.docService.getDocumentPaths(),u=this.authService.getUser();if(u?.userId&&g){let _=It(e),w=yield this.encryptCrdtData(t,_),A=yield this.encryptCrdtData(i,_);if(w==null||A==null)return;let M=u.userId,j=It(u.userId),q=this.domService.getTabId();yield this.commonDbService.setData({feature:"crdtSnapshot",properties:{documentId:g?.documentId??"",organizationId:g?.organizationId??"",id:_,skipFirestore:!0},data:{id:e,veltId:_,encryptedState:w,encryptedVector:A,type:a??null,contentKey:l??null,source:c??"unknown",updatedByUserId:M,updatedByVeltUserId:j,sessionId:q,timestamp:this.commonDbService.getServerTimestamp()}})}}catch(g){this.loggingService.catch("Error in CrdtService saveSnapshot: ",g)}})}pruneMessages(i){return X(this,arguments,function*({id:e,beforeTs:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: pruneMessages","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtMessages",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,skipFirestore:!0}});if(c&&typeof c=="object"&&!c?.errorCode){let d=[];for(let g of Object.keys(c)){let u=c[g];u?.timestamp!=null&&u.timestamp<t&&d.push(this.commonDbService.deleteData({feature:"crdtMessage",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,messageId:g,skipFirestore:!0}}))}yield Promise.all(d)}}}catch(a){this.loggingService.catch("Error in CrdtService pruneMessages: ",a)}})}updateNotificationsDatabase(e,t,i={}){try{let a=h({crdtData:e,actionType:t,notificationSource:"crdt"},i);this.notificationService.updateNotificationDatabase(a)}catch(a){this.loggingService.catch("Error in CrdtService updateNotificationsDatabase: ",a)}}enableWebhook(){try{if(this.webhookEnabled$.value===!0)return;this.webhookEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CrdtService enableWebhook: ",e)}}disableWebhook(){try{if(this.webhookEnabled$.value===!1)return;this.webhookEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CrdtService disableWebhook: ",e)}}trackEditForActivity(e){try{let t=this.editorEditTrackers.get(e);if(!t){let i=new it,a=i.pipe(to(this.activityDebounceTime)).subscribe(()=>{this.flushEditorActivity(e)});t={count:0,subject$:i,subscription:a},this.editorEditTrackers.set(e,t)}t.count++,t.subject$.next()}catch(t){this.loggingService.catch("Error in CrdtService trackEditForActivity: ",t)}}flushEditorActivity(e){try{let t=this.editorEditTrackers.get(e);if(!t||t.count===0)return;let i=t.count;t.count=0;let a={featureType:"crdt",actionType:Rhe.EDITOR_EDIT,targetEntityId:e,entityData:{editCount:i}};this.activityService.createActivity(a)}catch(t){this.loggingService.catch("Error in CrdtService flushEditorActivity: ",t)}}setActivityDebounceTime(e){try{e<this.MIN_ACTIVITY_DEBOUNCE_TIME&&(this.loggingService.catch("Error in CrdtService setActivityDebounceTime: Value must be at least "+this.MIN_ACTIVITY_DEBOUNCE_TIME/1e3+" seconds ("+this.MIN_ACTIVITY_DEBOUNCE_TIME+"ms). Using minimum value."),e=this.MIN_ACTIVITY_DEBOUNCE_TIME),this.flushAllEditorActivities(),this.activityDebounceTime=e}catch(t){this.loggingService.catch("Error in CrdtService setActivityDebounceTime: ",t)}}flushAllEditorActivities(){try{for(let[e,t]of this.editorEditTrackers)t.count>0&&this.flushEditorActivity(e),t.subject$.complete(),t.subscription.unsubscribe();this.editorEditTrackers.clear()}catch(e){this.loggingService.catch("Error in CrdtService flushAllEditorActivities: ",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(Gg),Z(ct),Z(Ke),Z(kn),Z(bd),Z(Lt),Z(eV),Z(st),Z(Ve),Z(k),Z(cn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var tV=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: CrdtElement","color: blue;"),this.updateData=this._updateData,this.onDataChange=this._onDataChange,this.getData=this._getData,this.onStateChange=this._onStateChange,this.updateState=this._updateState,this.registerSyncUser=this._registerSyncUser,this.onRegisteredUserChange=this._onRegisteredUserChange,this.setPresence=this._setPresence,this.onPresenceChange=this._onPresenceChange,this.saveVersion=this._saveVersion,this.getVersion=this._getVersion,this.getVersions=this._getVersions,this.pushMessage=this._pushMessage,this.onMessage=this._onMessage,this.getMessages=this._getMessages,this.getSnapshot=this._getSnapshot,this.saveSnapshot=this._saveSnapshot,this.pruneMessages=this._pruneMessages,this.enableWebhook=this._enableWebhook,this.disableWebhook=this._disableWebhook,this.setWebhookDebounceTime=this._setWebhookDebounceTime,this.setActivityDebounceTime=this._setActivityDebounceTime,this.on=this._on}_updateData(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateData","color: green;");try{return this.getService(Ri).updateData(o)}catch(r){return this.getService(k).catch("Error in updateData: ",r),Promise.resolve(null)}}_onDataChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onDataChange","color: green;");try{return this.getService(Ri).onDataChange(o)}catch(r){return this.getService(k).catch("Error in onDataChange: ",r),()=>{}}}_getData(o){this.getService(k).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.getService(Ri).getData(o)}catch(r){return this.getService(k).catch("Error in getData: ",r),Promise.resolve(null)}}_onStateChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onStateChange","color: green;");try{return this.getService(Ri).onStateChange(o)}catch(r){return this.getService(k).catch("Error in onStateChange: ",r),()=>{}}}_updateState(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateState","color: green;");try{return this.getService(Ri).updateState(o)}catch(r){return this.getService(k).catch("Error in updateState: ",r),Promise.resolve(null)}}_registerSyncUser(o){this.getService(k).log("%c[WB] Calling FUNCTION: registerSyncUser","color: green;");try{return this.getService(Ri).registerSyncUser(o)}catch(r){return this.getService(k).catch("Error in registerSyncUser: ",r),Promise.resolve()}}_onRegisteredUserChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onRegisteredUserChange","color: green;");try{return this.getService(Ri).onRegisteredUserChange(o)}catch(r){return this.getService(k).catch("Error in onRegisteredUserChange: ",r),()=>{}}}_setPresence(o){this.getService(k).log("%c[WB] Calling FUNCTION: setPresence","color: green;");try{return this.getService(Ri).setPresence(o)}catch(r){return this.getService(k).catch("Error in setPresence: ",r),Promise.resolve()}}_onPresenceChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onPresenceChange","color: green;");try{return this.getService(Ri).onPresenceChange(o)}catch(r){return this.getService(k).catch("Error in onPresenceChange: ",r),()=>{}}}_saveVersion(o){this.getService(k).log("%c[WB] Calling FUNCTION: saveVersion","color: green;");try{return this.getService(Ri).saveVersion(o)}catch(r){return this.getService(k).catch("Error in saveVersion: ",r),Promise.resolve(null)}}_getVersion(o){this.getService(k).log("%c[WB] Calling FUNCTION: getVersion","color: green;");try{return this.getService(Ri).getVersion(o)}catch(r){return this.getService(k).catch("Error in getVersion: ",r),Promise.resolve(null)}}_getVersions(o){this.getService(k).log("%c[WB] Calling FUNCTION: getVersions","color: green;");try{return this.getService(Ri).getVersions(o)}catch(r){return this.getService(k).catch("Error in getVersions: ",r),Promise.resolve(null)}}_pushMessage(o){this.getService(k).log("%c[WB] Calling FUNCTION: pushMessage","color: green;");try{return this.getService(Ri).pushMessage(o)}catch(r){return this.getService(k).catch("Error in pushMessage: ",r),Promise.resolve()}}_onMessage(o){this.getService(k).log("%c[WB] Calling FUNCTION: onMessage","color: green;");try{return this.getService(Ri).onMessage(o)}catch(r){return this.getService(k).catch("Error in onMessage: ",r),()=>{}}}_getMessages(o){this.getService(k).log("%c[WB] Calling FUNCTION: getMessages","color: green;");try{return this.getService(Ri).getMessages(o)}catch(r){return this.getService(k).catch("Error in getMessages: ",r),Promise.resolve([])}}_getSnapshot(o){this.getService(k).log("%c[WB] Calling FUNCTION: getSnapshot","color: green;");try{return this.getService(Ri).getSnapshot(o)}catch(r){return this.getService(k).catch("Error in getSnapshot: ",r),Promise.resolve(null)}}_saveSnapshot(o){this.getService(k).log("%c[WB] Calling FUNCTION: saveSnapshot","color: green;");try{return this.getService(Ri).saveSnapshot(o)}catch(r){return this.getService(k).catch("Error in saveSnapshot: ",r),Promise.resolve()}}_pruneMessages(o){this.getService(k).log("%c[WB] Calling FUNCTION: pruneMessages","color: green;");try{return this.getService(Ri).pruneMessages(o)}catch(r){return this.getService(k).catch("Error in pruneMessages: ",r),Promise.resolve()}}_enableWebhook(){this.getService(k).log("%c[WB] Calling FUNCTION: enableWebhook","color: green;");try{return this.getService(Ri).enableWebhook()}catch(o){this.getService(k).catch("Error in enableWebhook: ",o);return}}_disableWebhook(){this.getService(k).log("%c[WB] Calling FUNCTION: disableWebhook","color: green;");try{return this.getService(Ri).disableWebhook()}catch(o){this.getService(k).catch("Error in disableWebhook: ",o);return}}_setWebhookDebounceTime(o){this.getService(k).log("%c[WB] Calling FUNCTION: setWebhookDebounceTime","color: green;");try{!isNaN(o)&&o>0?this.getService(Ri).setWebhookDebounceTime(o):this.getService(k).catch("Error in setWebhookDebounceTime: ","Provided value must be a positive number greater than zero.")}catch(r){this.getService(k).catch("Error in setWebhookDebounceTime: ",r)}}_setActivityDebounceTime(o){this.getService(k).log("%c[WB] Calling FUNCTION: setActivityDebounceTime","color: green;");try{!isNaN(o)&&o>=1e4?this.getService(Ri).setActivityDebounceTime(o):this.getService(k).catch("Error in setActivityDebounceTime: ","Provided value must be a number >= 10000ms (10 seconds).")}catch(r){this.getService(k).catch("Error in setActivityDebounceTime: ",r)}}_on(o){this.getService(k).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(eV).onAction(o)}catch(r){return this.getService(k).catch("Error in on: ",r),de(null)}}};var Rc=(function(n){return n.CLICK="click",n.HOVER="hover",n.SCROLL="scroll",n.NAVIGATE="navigate",n})(Rc||{}),Hg=class{constructor(){this.type=Rc.HOVER,this.data=null,this.pageInfo=io(),this.timestamp=Date.now()}},nV=class{constructor(o,r){this.targetXpath=o,this.xpath=r}};var rV=class{constructor(){this.sessionId=null,this.isLeader=!1,this.lastProcessedActionTimestamp=null}};var tC=class{constructor(o){this.snippylyId=o,this.joinTimestamp=Date.now()}};var oV=class{constructor(o,r,e){this.followers=[],this.actionStack=[],this.id=lt(),this.leaderId=o,this.leaderName=r,this.followers.push(new tC(e))}};var $_e=(()=>{let o=class o{constructor(e,t,i,a,l){this.databaseService=e,this.docService=t,this.loggingService=i,this.authService=a,this.commonDbService=l,this.currentUser$=new Se(null),this.currentSession$=new Se(null);try{this.databaseService.getDb().pipe($e(c=>!!c),ut(1)).subscribe(c=>{c&&(this.db=c)},c=>{this.loggingService.catch("Error in FlockSessionService getDb subscription: ",c)}),this.authService.getUser$().subscribe(c=>{c&&c.userSnippylyId&&(this.user=c)})}catch(c){this.loggingService.catch("Error in FlockSessionService constructor: ",c)}}startCurrentFlockUserSubscription(e){try{this.currentUserSub?.unsubscribe(),e&&e.userSnippylyId&&(this.user=e,this.subscribeToCurrentFlockUser(e?.userSnippylyId))}catch(t){this.loggingService.catch("Error in FlockSessionService startCurrentFlockUserSubscription: ",t)}}stopCurrentFlockUserSubscription(){try{this.currentUserSub?.unsubscribe()}catch(e){this.loggingService.catch("Error in FlockSessionService stopCurrentFlockUserSubscription: ",e)}}provisionFlockSession(e,t,i){try{let a=this.docService.getDocumentPaths();a&&this.db&&this.commonDbService.dbListener({feature:"flockUser",properties:{documentId:a?.documentId,organizationId:a?.organizationId,id:e,skipFirestore:!0}}).pipe(ut(1)).subscribe(l=>{l?.data&&l?.data?.sessionId?this.subscribeToCurrentSession(l?.data?.sessionId,i):this.createFlockSession(e,t,i)})}catch(a){this.loggingService.catch("Error in FlockSessionService provisionFlockSession: ",a)}return null}swapLeader(e,t,i){try{if(this.updateRemoteFlockUser(e,{isLeader:!1}),this.updateRemoteFlockUser(t,{isLeader:!0}),this.currentSession){this.currentSession.leaderId=t,this.currentSession.leaderName=i,this.currentSession.followers.push(new tC(e));let a=this.currentSession.followers.findIndex(l=>l.snippylyId===t);a>-1&&this.currentSession.followers.splice(a,1),this.updateSession(this.currentSession.id,this.currentSession)}}catch(a){this.loggingService.catch("Error in FlockSessionService swapLeader: ",a)}}createFlockSession(e,t,i){try{let a=new oV(e,t,i);return this.updateRemoteFlockUser(e,{snippylyId:e,sessionId:a.id,isLeader:!0}),this.updateSession(a.id,a),this.subscribeToCurrentSession(a.id),a.id}catch(a){this.loggingService.catch("Error in FlockSessionService createFlockSession: ",a)}return null}removeFollowerFromCurrentSession(e){try{if(this.currentSession){this.updateRemoteFlockUser(e,{sessionId:null,lastProcessedActionTimestamp:null});let t=this.currentSession.followers.findIndex(i=>i.snippylyId===e);if(t>-1){if(this.currentSession.followers.splice(t,1),this.currentSession.followers.length===0){this.deleteSession(this.currentSession.id);return}this.updateSession(this.currentSession.id,this.currentSession),this.user&&this.user.userSnippylyId&&this.user.userSnippylyId===e&&(this.sessionSub?.unsubscribe(),this.currentSession=void 0,this.currentSession$?.next(null))}}}catch(t){this.loggingService.catch("Error in FlockSessionService removeFollowerFromSession: ",t)}}updateRemoteFlockUser(e,t={}){try{if(!e)return;let i=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];i&&this.db&&this.commonDbService.updateData({feature:"flockUser",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(i){this.loggingService.catch("Error in FlockSessionService updateRemoteFlockUser: ",i)}}subscribeToCurrentSession(e,t=void 0){try{let i=this.docService.getDocumentPaths();i&&this.db&&(this.sessionSub&&this.sessionSub.unsubscribe(),this.sessionSub=this.commonDbService.dbListener({feature:"flockSession",properties:{documentId:i?.documentId,organizationId:i?.organizationId,id:e,skipFirestore:!0}}).subscribe(a=>{a?.data&&typeof a?.data=="object"&&Object.keys(a?.data)?.length>0?(this.currentSession=a?.data,t!==void 0&&this.currentSession?.followers.findIndex(l=>l.snippylyId===t)===-1&&(this.currentSession.followers.push(new tC(t)),this.updateSession(this.currentSession.id,this.currentSession)),this.currentSession$.next(this.currentSession??null)):(this.currentSession=void 0,this.currentSession$.next(null))}))}catch(i){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentSession: ",i)}}subscribeToCurrentFlockUser(e){try{let t=this.docService.getDocumentPaths();t&&this.db&&(this.currentUserSub&&this.currentUserSub.unsubscribe(),this.currentUserSub=this.commonDbService.dbListener({feature:"flockUser",properties:{documentId:t?.documentId,organizationId:t?.organizationId,id:e,skipFirestore:!0}}).pipe(Gn(i=>(this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",i),de(null)))).subscribe(i=>{i?.data&&typeof i?.data=="object"&&Object.keys(i?.data)?.length>0&&(this.currentUser$.next(i?.data),i?.data?.sessionId&&this.subscribeToCurrentSession(i?.data?.sessionId))},i=>{this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser subscription: ",i)}))}catch(t){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",t)}}updateSession(e,t={}){try{if(!e)return;let i=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];i&&this.db&&this.commonDbService.updateData({feature:"flockSession",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(i){this.loggingService.catch("Error in FlockSessionService updateSession: ",i)}}deleteSession(e){try{let t=this.docService.getDocumentPaths();t&&this.db&&(this.commonDbService.deleteData({feature:"flockSession",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:e,skipFirestore:!0}}),this.currentSession&&e===this.currentSession.id&&(this.updateRemoteFlockUser(this.currentSession.leaderId,{sessionId:null,isLeader:!1,lastProcessedActionTimestamp:null}),this.currentSession.followers.forEach(i=>{this.updateRemoteFlockUser(i.snippylyId,{sessionId:null,lastProcessedActionTimestamp:null})}),this.currentSession=void 0,this.currentSession$.next(null),this.sessionSub?.unsubscribe()))}catch(t){this.loggingService.catch("Error in FlockSessionService deleteSession: ",t)}}addActionToStack(e,t){try{t=t&&JSON.parse(JSON.stringify(t));let i=this.docService.getDocumentPaths();if(i&&this.db&&e){let a=Hr(this.db,`${i.flock}/sessions/${e}/actionStack`);c0(a,l=>l?(l.unshift(t),l.slice(0,5)):[t]),t.type===Rc.NAVIGATE&&this.updateSession(e,{pageInfo:t.pageInfo})}}catch(i){this.loggingService.catch("Error in FlockSessionService addActionToStack: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(Hn),Z(st),Z(k),Z(Ke),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();function OYe(n,o){if(n&1&&(f(0,"span",6),oe(1),R(2,"translate"),S()),n&2){let r=s(2).ngIf;v(),na("",N(2,2,"You are following")," ",r.leaderName)}}function AYe(n,o){n&1&&(f(0,"span",6),oe(1),R(2,"translate"),S()),n&2&&(v(),Ye(N(2,1,"You are leading.")))}function MYe(n,o){if(n&1){let r=K();f(0,"div",2),z("click",function(){L(r);let t=s().ngIf,i=s();return U(t.type==="following"?i.closeOverlay():void 0)}),f(1,"div",3),p(2,OYe,3,4,"span",4)(3,AYe,3,3,"span",4),f(4,"button",5),z("click",function(){L(r);let t=s(2);return U(t.closeOverlay())}),oe(5),R(6,"translate"),R(7,"translate"),S()()()}if(n&2){let r=s().ngIf;he("no-pointer",r.type==="leading"),v(2),m("ngIf",r.type==="following"),v(),m("ngIf",r.type==="leading"),v(2),na("",N(6,6,"Stop")," ",N(7,8,r.type))}}function PYe(n,o){if(n&1&&(C(0),p(1,MYe,8,10,"div",1),b()),n&2){let r=o.ngIf;v(),m("ngIf",r.leaderName!==""||r.type==="leading")}}var MA=(()=>{let o=class o extends Mt{closeOverlay(){this.closeOverlayEvent.emit()}constructor(e,t,i,a){super(t,i),this.loggingService=e,this.elementRef=t,this.themeService=i,this.domService=a,this.closeOverlayEvent=new Ue,this.componentConfigSignal=De({leaderName:"",type:"following"})}ngOnInit(){}ngAfterViewInit(){try{this.customCssSubscription=this.domService.subscribeInjectCustomCss(this.elementRef)}catch(e){this.loggingService.catch("Error in FollowOverlayComponent ngAfterViewInit: ",e)}}setLeaderName(e){try{this.componentConfigSignal.update(t=>(t=y(h({},t),{leaderName:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setLeaderName: ",t)}}getLeaderName(){return this.componentConfigSignal().leaderName}setType(e){try{this.componentConfigSignal.update(t=>(t=y(h({},t),{type:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setType: ",t)}}ngOnDestroy(){try{super.ngOnDestroy(),this.customCssSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in FollowOverlayComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(x(k),x(Q),x(yt),x(Ve))},o.\u0275cmp=O({type:o,selectors:[["snippyly-follow-overlay"]],outputs:{closeOverlayEvent:"closeOverlayEvent"},standalone:!1,features:[P],decls:1,vars:1,consts:[[4,"ngIf"],["data-velt-ignore","","class","follow-overlay-container",3,"no-pointer","click",4,"ngIf"],["data-velt-ignore","",1,"follow-overlay-container",3,"click"],["data-velt-ignore","",1,"follow-dialog"],["data-velt-ignore","","class","follow-text",4,"ngIf"],["data-velt-ignore","",1,"follow-btn",3,"click"],["data-velt-ignore","",1,"follow-text"]],template:function(t,i){t&1&&p(0,PYe,2,1,"ng-container",0),t&2&&m("ngIf",i.componentConfigSignal())},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}.follow-overlay-container{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:var(--velt-follow-mode-overlay-z-index);display:flex;justify-content:center;align-items:flex-end}.follow-overlay-container .follow-dialog{background-color:var(--legacy-velt-follow-overlay-bg-color);color:var(--legacy-velt-follow-overlay-text-color);font-size:12px;display:flex;justify-content:center;align-items:center;gap:calc((1.2rem + 0px) * var(--velt-base-rem-unit));padding:calc((.9rem + 0px) * var(--velt-base-rem-unit)) calc((1.1rem + 0px) * var(--velt-base-rem-unit));border-radius:90px;margin-bottom:calc((2rem + 0px) * var(--velt-base-rem-unit));box-shadow:0 8px 16px -8px #0f0f0f1a;border:1px solid var(--legacy-velt-follow-overlay-border-color)}.follow-overlay-container .follow-dialog .follow-btn{background-color:var(--legacy-velt-follow-overlay-btn-color);padding:8px 12px;border-radius:90px;display:inline-flex;justify-content:center;align-items:center;border:none;font-weight:600;font-size:14px;cursor:pointer;pointer-events:all}.follow-overlay-container .follow-dialog .follow-btn:hover{transition:background-color .5s;background-color:var(--legacy-velt-follow-overlay-btn-hover-color)}.follow-overlay-container.no-pointer{pointer-events:none}
|
|
501
|
+
`);for(var t=0;t<d.length;t++)if(d[t].indexOf("-->")!==-1){var i=d[t].split(" --> ")[0],a=d[t].split(" --> ")[1],l=d[t+1];c.push({startTime:i,endTime:a,startTimeInSeconds:this.getTimeInSecondsFromVttTime(i),endTimeInSeconds:this.getTimeInSecondsFromVttTime(a),text:l})}return c}catch(c){return this.loggingService.catch("Error in TranscriptionService getVttFileTextToArray: ",c),[]}}getTimeInSecondsFromVttTime(e){try{let t=e.split(":"),i=0;t.length===3&&(i=parseInt(t[0]),t.shift());let a=parseInt(t[0]),l=parseInt(t[1].split(".")[0]),c=parseInt(t[1].split(".")[1]);return((i*60*60+a*60+l)*1e3+c)/1e3}catch(t){return this.loggingService.catch("Error in TranscriptionService getTimeInSecondsFromVttTime: ",t),0}}};o.\u0275fac=function(t){return new(t||o)(Z(L8),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var fo=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we){this.analyticsService=e,this.configService=t,this.docService=i,this.databaseService=a,this.commonDbService=l,this.authService=c,this.domService=d,this.afAuth=g,this.iamService=u,this.functions=_,this.avatarService=w,this.contactService=A,this.storageService=M,this.dialog=j,this.loggingService=q,this.notificationService=ie,this.transcriptionService=_e,this.recorderService=ae,this.recorderUtilsService=ue,this.userPermissionService=Ie,this.recorderAnnotationsResolverService=fe,this.attachmentResolverService=we,this.recorderAnnotationById$=new Se({}),this.documentPaths=null,this.allowedElementIds$=new Se([]),this.addRecorderMode$=new Se(!1),this.recorderContainerDarkMode$=new Se(!1),this.recordingTranscriptionEnabled$=new Se(!0),this.draftRecordings$=new Se([]),this.recorderNotesFound$=new Se(!1),this.recordedData=null,this.videoEditorAutoOpen$=new Se({}),this.commentService=null,this.getAllRecorderAnnotations().subscribe(Ae=>{}),this.loggingService.log("%c[WB] Creating CLASS: RecorderAnnotationService","color: blue;"),this.analyticsService.setRecorderAnnotationService(this),this.authService.setRecorderAnnotationService(this),this.databaseService.getDb().pipe($e(Ae=>!!Ae),ut(1)).subscribe(Ae=>{Ae&&this.getDocumentPaths()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",Ae)}),this.domService.onWindowPointerMove$().subscribe(Ae=>{if(this.addRecorderMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let Pe=this.domService.getBackgroundElement(Ae.clientX,Ae.clientY);Pe&&(this.isElementInsideAllowedElements(Pe)?ZF(Ae.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=Pe):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowPointerMove$ subscription: ",Ae)}),this.domService.onWindowKeyupEsc$().subscribe(Ae=>{this.addRecorderMode$.value&&this.disableAddRecorderMode()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupEsc$ subscription: ",Ae)}),this.domService.onDocumentClick$().subscribe(Ae=>{if(Ae&&this.addRecorderMode$.value){if(Ae.preventDefault(),Ae.stopPropagation(),!ZF(Ae.target)){let Pe=this.domService.getBackgroundElement(Ae.clientX,Ae.clientY);Pe&&this.isElementInsideAllowedElements(Pe)}this.disableAddRecorderMode()}},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onDocumentClick$ subscription: ",Ae)}),this.addRecorderMode$.subscribe(Ae=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),Ae?this.domService.addClassToElement(document.body,"snippyly-add-recorder-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-recorder-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService addRecorderMode$ subscription: ",Ae)}),this.domService.onWindowKeyupBackspace$().subscribe(Ae=>{this.deleteRecorderPinAnnotations()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupBackspace$ subscription: ",Ae)}),this.domService.onWindowKeyupDelete$().subscribe(Ae=>{this.deleteRecorderPinAnnotations()},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Ae)}),this.recorderService.onRecordedData().subscribe(Ae=>{this.recordedData=Ae},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onRecordedData subscription: ",Ae)}),this.domService.getDeleteCommmentAnnotations$().subscribe(Ae=>{Ae?.length&&Ae.forEach(Pe=>X(this,null,function*(){}))},Ae=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Ae)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in RecorderAnnotationService","color: green;");try{this.recorderAnnotationById$.next({}),this.documentPaths=null,this.allowedElementIds$.next([]),this.addRecorderMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in RecorderAnnotationService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getDocumentPaths: ",e)}}setCommentService(e){this.loggingService.log("%c[WB] Calling FUNCTION: setCommentService","color: green;");try{this.commentService=e}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setCommentService: ",t)}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getDraftRecordings$(){return this.draftRecordings$.asObservable()}getRecorderDataByRecorderId(e){try{return this.recorderAnnotationById$.pipe(ge(()=>this.getAnnotationById(e)),ye(t=>X(this,null,function*(){return t?yield this.createRecorderData(t,!0):void 0})))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderId: ",t),de(void 0)}}getRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t={};return yield Promise.all(e.recorderIds.map(i=>X(this,null,function*(){let a=this.getAnnotationById(i);if(!a)return;let l=yield this.createRecorderData(a,!0);l&&(t[i]=l)}))),{data:Object.keys(t).length>0?t:null}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderIds: ",t),{data:null}}})}fetchRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t=this.recorderAnnotationById$.value,i=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(l=>e.recorderIds.includes(l.annotationId))),a.length===0?[]:(yield Promise.all(a.map(l=>X(this,null,function*(){if(!l)return;let c=yield this.createRecorderData(l,!0);c&&i.push(c)}))),i)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService fetchRecorderDataByRecorderIds: ",t),[]}})}deleteRecorderDataByRecorderIds(e){return X(this,null,function*(){try{let t=this.recorderAnnotationById$.value,i=[],a=Object.values(t),l=[];return e?.recorderIds?.length&&(l=a.filter(c=>e.recorderIds.includes(c.annotationId))),l.length===0?[]:(yield Promise.all(l.map(c=>X(this,null,function*(){if(!c)return;let d=yield this.createRecorderData(c,!0);yield this.deleteRecorderPinAnnotation(c),d&&i.push(d)}))),i)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderDataByRecorderIds: ",t),[]}})}getRecordings(e){try{return this.recorderAnnotationById$.pipe(ye(t=>X(this,null,function*(){let i=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(l=>e.recorderIds.includes(l.annotationId))),a.length===0?[]:(yield Promise.all(a.map(l=>X(this,null,function*(){if(!l)return;let c=yield this.createRecorderData(l,!0);c&&i.push(c)}))),i)})),Gn(t=>(this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),de([]))))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),de([])}}setRecorderActionsService(e){try{this.recorderActionsService=e}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",t)}}getVttFileTextToArray(e){try{return this.transcriptionService.getVttFileTextToArray(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getVttFileTextToArray: ",t)}}getAllRecorderAnnotations(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: getAllRecorderAnnotations","color: green;");let a,l;try{if(e&&(l=tr(e)),t&&typeof t=="object"){let c=Ai(t);a=tr(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in RecorderAnnotationService getAllRecorderAnnotations: ",c)}return _r(this.afAuth).pipe($e(c=>!!c),ye(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),ye(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(d=>(c.featureAllowed=d,c))):de(c)),ye(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(ge(d=>(c.featureAllowed=!d,c))):de(c)),ye(c=>c.featureAllowed?de(c).pipe(ye(d=>this.docService.getDocumentPaths$().pipe(ge(g=>(this.documentPaths=g,d.documentPaths=g,d)))),ye(d=>l?this.getDataFromDocumentIds([l]).pipe(ge(g=>(d.annotations=g||[],h({},d)))):this.docService.getDocumentIds$().pipe(ye(g=>{let u=g?.length>0?g.map(_=>_.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(u).pipe(ge(_=>(d.annotations=_||[],h({},d))))}))),ye(d=>this.docService.getLocation$().pipe(ge(g=>(d.location=g,d)))),ye(d=>this.docService.getLocations$().pipe(ge(g=>(d.customLocations=g,d)))),ge(d=>{if(d.filteredAnnotations=[],l&&!a)return d.filteredAnnotations=d.annotations?.slice(),d;{let g=[];return a?g.push(a):(g.push(d?.location?.locationId),g.push(...Object.values(d?.customLocations||[]).map(u=>u.locationId))),d.filteredAnnotations=this.filterAnnotationsByLocationIds(d?.annotations,g),d}}),ye(d=>i?de(d):d?.annotations?.length?this.domService.onWindowResize$().pipe(ge(()=>d)):de(d)),ye(d=>i?de(d):d?.annotations?.length?this.domService.onDomChange$("RecorderAnnotationService getAllRecorderAnnotations").pipe(ge(()=>d)):de(d)),ge(d=>{let g=[];return d?.filteredAnnotations?.forEach(u=>{this.calculateRecorderAnnotationPosition(u),u?.targetElement||g.push(u)}),this.draftRecordings$.next(g),d}),ye(d=>d?.filteredAnnotations?de(d?.filteredAnnotations||[]):de([]))):de([])),bt(Zt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.RECORDER)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Recorder feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:i}=e;if(t?.some(d=>!d)||!this.documentPaths)return de([]);let a=this.docService.getDocumentPaths()?.veltFolderId,l=de([]),c={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(c.documentId=t?.length?t[0]:void 0,c.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let d=[F.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let u=0;u<(d?.length??0);u+=F.LISTENER_CONTEXT_BATCH_SIZE)g.push(d?.slice(u,u+F.LISTENER_CONTEXT_BATCH_SIZE)??[]);l=mn(g.map(u=>this.commonDbService.dbListener({feature:"allRecorders",properties:y(h({},c),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",t),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[ft("metadata.veltFolderId","==",a)]:[],...u?.length?[ft("context.accessFields","array-contains-any",u)]:[])]})}).pipe(va()))).pipe(ge(u=>ja(u)))}else{let d=[];for(let g=0;g<(t?.length??0);g+=F.LISTENER_BATCH_SIZE)d.push(t?.slice(g,g+F.LISTENER_BATCH_SIZE)??[]);l=mn(d.map(g=>this.commonDbService.dbListener({feature:"allRecorders",properties:y(h({},c),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.documentId","in",g),ft("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[ft("metadata.veltFolderId","==",a)]:[])]})}).pipe(va()))).pipe(ge(g=>ja(g)))}return l.pipe(ge(d=>({data:d?.data,operation:d?.operation})),ge(({data:d,operation:g})=>{let u=[];return d&&(u=Object.values(d).filter(_=>typeof _=="object")),{data:u,operation:g}}),ge(({data:d,operation:g})=>{if(!t)return{data:d,documentMap:{},operation:g};let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});return{data:d,documentMap:u,operation:g}}),ge(({data:d,documentMap:g,operation:u})=>{if(!i)if(u?.type==="removed"){if(u?.ids?.length){let _=this.recorderAnnotationById$.value;u?.ids?.forEach(w=>{delete _?.[w]}),this.recorderAnnotationById$.next(_)}}else Object.entries(g).forEach(([_,w])=>{this.setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,annotations:w})});return d}),Gn(d=>(this.loggingService.catch("Error in RecorderAnnotationService getDataFromDocumentId: ",d),de([]))))}else return de([])}setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i?.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.recorderAnnotationById$.value),l);this.recorderAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in RecorderAnnotationService setRecorderAnnotationsByOrganizationIdAndDocumentId:",l)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(i=>t.includes(i.locationId))}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService filterAnnotationsByLocations:",i),[]}}calculateRecorderAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let i=t.iterateNext();if(i&&Xr(i)){let a=i.getBoundingClientRect();if(a&&a.width&&a.height){let{height:l,width:c}=vp(i);e.position={top:l*e.targetElement.topPercentage/100,left:c*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService calculateRecorderAnnotationPosition:",t)}}getAnnotationById(e,t){try{let i=this.recorderAnnotationById$.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in RecorderAnnotationService getAnnotationById: ",i);return}}getBaseMetadataFromRecorderAnnotationId(e){try{let t=this.recorderAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getBaseMetadataFromRecorderAnnotationId: ",t)}}getRecorderAnnotationById(e,t){return this.recorderAnnotationById$.pipe(ye(()=>{let i=this.getAnnotationById(e,t);return i?de(i):de(null)}),Gn(i=>(this.loggingService.catch("Error in RecorderAnnotationService getCommentAnnotationById: ",i),de(null))))}getRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i={};return Object.values(this.recorderAnnotationById$.value).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(i[a?.annotationId]=a)}),Object.values(i)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderAnnotationsByOrganizationIdAndDocumentId:",i),[]}}setLocationToRecorderAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{if(e.targetElement?.xpath){let i=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setLocationToRecorderAnnotation:",t)}}addRecorder(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: addRecorder","color: green;");try{let a=this.authService.getUser();if(a){if(a.isReadOnly||a.isAnonymous)return this.loggingService.catch("Anonymous/Readonly users cannot add recorders."),de(null);{t.from=a,t.color=F.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:l,topPositionY:c}=this.domService.getTopLeftPosition();t.positionX=l,t.positionY=c;let d=this.domService.getCurrentWindowSizeValue();if(t.screenWidth=d.screenWidth,t.screenHeight=d.screenHeight,t.screenScrollHeight=d.screenScrollHeight,t.recorderedElementPath="",e&&(t.targetElement=this.domService.getTargetElementForCursorPosition(e)),t?.targetElement?.xpath){let g=this.domService.getXPath(t.targetElement.xpath);if(g){let u=g.iterateNext();u&&(Xr(u)||(t.targetElement=null))}}return this.setLocationToRecorderAnnotation(t),t.pageInfo=io(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveRecorderToDb(t,i)}}else return de(null)}catch(a){return this.loggingService.catch("Error in RecorderAnnotationService addRecorder: ",a),de(null)}}saveRecorderToDb(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: saveRecorderToDb","color: green;");try{return this.authService.getUser()&&this.authService.isFeatureAllowed(je.RECORDER)?this.docService.getDocumentPaths$().pipe($e(i=>!!i),ut(1),ye(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(a=>!!a),ut(1),ye(a=>X(this,null,function*(){if(this.documentPaths?.recorder){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.recorderUrl=this.generateRecorderUrl(e));let l=JSON.parse(JSON.stringify(e));if(l.position=null,this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||delete l?.isUrlAvailable,!l?.metadata?.documentId){l?.metadata||(l.metadata={});let u=this.docService.getBaseMetadata("recorder",{commentAnnotationId:e.commentAnnotationId});l.metadata=h(h({},l?.metadata),u)}let{documentId:c,organizationId:d}=l?.metadata||{};if(e.commentAnnotationId){let u=this.commentService?.getAnnotationById(e.commentAnnotationId??"");if(u?.context?.access&&u?.context?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:e.from?.userId,accessFields:u.context.accessFields}))return this.loggingService.catch("User does not have context access to add recorder annotation.",void 0,void 0,!0),null;l.context={access:u.context.access,accessFields:u.context.accessFields}}}let g={annotationData:l,actionType:rc.ADDED,notificationSource:"recorder"};if(yield new Promise((u,_)=>X(this,null,function*(){yield this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:d},data:JSON.parse(JSON.stringify(l)),extraData:g,callback:()=>{u(!0)},errorCallback:w=>{_(w)}})})),this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_ADDED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderTime:e?.recordedTime?.duration,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e?.attachment?.size,sourceFeature:t||"recording"}),this.setVideoEditorAutoOpen({[e.annotationId]:!0}),t==="recording"){let u=yield this.createRecorderData(l,!1);u&&this.recorderActionsService?.onRecordingDoneLocal(u)}return this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||this.processRecording(e,"recording","merge"),this.updateNotificationsDatabase(e,rc.ADDED),e}else return null})))))):de(null)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService saveRecorderToDb: ",i),de(null)}}processRecording(e,t,i){return X(this,null,function*(){try{let a=qr(this.functions,Kr({url:Dn?.cloudFunction?.processRecording,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),l=this.docService.getDocumentPaths();e?.metadata?.documentId&&(l=new xm({apiKey:this.configService.getApiKey(),clientDocumentId:e.metadata.clientDocumentId,clientOrganizationId:e.metadata.clientOrganizationId,documentId:e.metadata.documentId,organizationId:e.metadata.organizationId}));let c={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:l?.recorder+e?.annotationId,fromUser:this.authService.getUser(),clientOrganizationId:l?.clientOrganizationId,clientDocumentId:l?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:l?.recorder,annotationId:e?.annotationId,sourceFeature:t||"recording",annotationData:e,skipMerge:!0,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:i,returnType:"transcription",generatePreviewImages:this.recorderService.getVideoEditor()&&this.recorderService.getVideoEditorTimelinePreview()};if(c?.useFirestore){let M=yield this.recorderUtilsService.encryptRecorderAnnotation(e);c.annotationData=M}let d=this.documentPaths?.organizationId,g=this.documentPaths?.documentId;e?.metadata?.documentId&&(g=e.metadata.documentId,d=e.metadata.organizationId);let u=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;d&&(u=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${d}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),c.bucketPath=u;let _;try{_=yield a(c)}catch(M){M?.details?.type==="recording"&&this.recorderActionsService?.onError({type:"recordingFailed",message:"Recording failed",recorderId:M.details.recorderId}),M?.details?.type==="transcription"&&this.recorderActionsService?.onError({type:"transcriptionFailed",message:"Transcription failed",recorderId:M.details.recorderId}),this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",M)}let w=this.getAnnotationById(e?.annotationId);if(!w)return;let A=yield this.createRecorderData(w,!1);if(A){if(_?.data?.transcriptedText&&(A.transcription.contentSummary=_.data.transcriptedText),_?.data?.vttUrl)try{let M=yield this.transcriptionService.getFileContent(_.data.vttUrl).toPromise();M&&(A.transcription.transcriptSegments=this.getVttFileTextToArray(M),A.transcription.vttFileUrl=_.data.vttUrl),A?.assets?.length&&A.assets.forEach(j=>{j.transcription=A.transcription}),A?.assetsAllVersions?.length&&(A.assetsAllVersions[0].transcription=A.transcription),this.recorderActionsService?.onTranscriptionDone(A)}catch(M){this.loggingService.catch("Error fetching VTT content: ",M)}w?.attachments?.length&&this.recordedData&&(this.recordedData.videoUrl=w.attachments[0].url),t==="recording"&&this.recorderActionsService?.onRecordingDone(A)}this.recordedData&&this.recorderService.setRecordedData(this.recordedData)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",a)}})}getDocumentIdAndOrganizationIdFromRecorderAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getDocumentIdAndOrganizationIdFromRecorderAnnotation: ",t),{}}}createRecorderData(e,t=!1){return X(this,null,function*(){try{if(!e)return null;let i=ai(e.metadata||{}),a=Bo(e.from),l={recorderId:e.annotationId||"",from:a,assets:[],metadata:i,assetsAllVersions:[],transcription:{transcriptSegments:[],vttFileUrl:"",contentSummary:""}},c=e;e.latestVersion&&e.recordingEditVersions?.[e.latestVersion]&&(c=e.recordingEditVersions[e.latestVersion]);let d=u=>X(this,null,function*(){let _={transcriptSegments:[],vttFileUrl:"",contentSummary:u?.transcription?.transcriptedText||""};if(t&&u?.transcription?.vttUrl)try{let w=yield this.transcriptionService.getFileContent(u.transcription.vttUrl).toPromise();w&&(_.transcriptSegments=this.getVttFileTextToArray(w),_.vttFileUrl=u.transcription.vttUrl)}catch(w){this.loggingService.catch("Error fetching VTT content: ",w)}return _}),g=yield d(c);if(l.transcription=g,c?.attachments?.length)for(let u of c.attachments)u?.url&&l.assets.push({version:e.latestVersion||1,url:u.url,mimeType:u.mimeType,fileName:u.name,fileSizeInBytes:u.size,fileFormat:u.type,transcription:h({},g),thumbnailUrl:e.attachments?.[0]?.thumbnail});if(e.recordingEditVersions){let u=Object.entries(e.recordingEditVersions).map(M=>X(this,[M],function*([w,A]){let j=parseInt(w),q=yield d(A),ie=A?.attachments?.[0]||A?.attachment;return{version:j,url:ie?.url,mimeType:ie?.mimeType,fileName:ie?.name,fileSizeInBytes:ie?.size,fileFormat:ie?.type,transcription:q,thumbnailUrl:A?.attachments?.[0]?.thumbnail}})),_=yield Promise.all(u);l.assetsAllVersions=_.filter(w=>w.url)}else l.assetsAllVersions=[...l.assets];return l}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService createRecorderData: ",i),null}})}updateRecorder(e,t=!1,i){try{i&&this.setLocationToRecorderAnnotation(e),t&&this.updateNotificationsDatabase(e,rc.UPDATED),this.updateRecorderToDb(e)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateRecorder: ",a)}}resolveRecorder(e){try{this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(e,rc.RESOLVED),this.updateRecorderToDb(e),this.domService.updateSelectedAnnotationInMap([e])}catch(t){this.loggingService.catch("Error in RecorderAnnotationService resolveRecorder: ",t)}}updateRecorderToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateRecorderToDb","color: green;");try{if(e?.targetElement?.xpath){let t=this.domService.getXPath(e.targetElement.xpath);if(t){let i=t.iterateNext();i&&(Xr(i)||(e.targetElement=null))}}if(e.annotationId){let t=this.recorderAnnotationById$.value;this.recorderAnnotationById$.next(y(h({},t),{[e.annotationId]:h({},e)}))}if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(je.RECORDER)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||delete t?.isUrlAvailable,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let l=this.docService.getBaseMetadata("recorder");t.metadata=h(h({},t?.metadata),l)}let{documentId:i,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:i,organizationId:a},data:JSON.parse(JSON.stringify(t)),extraData:{actionType:rc.UPDATED}})}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService updateRecorderToDb: ",t)}}deleteRecorderPinAnnotations(){try{let e=this.domService.getSelectedAnnotationsMap(),t=this.authService.getUser(),i=[];Object.keys(e).forEach(a=>X(this,null,function*(){let l=e[a];l.type==="recorder"&&t&&l.from&&(t?.isAdmin||l.from.userId===t.userId)&&i.push(l)})),i?.length&&(this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETE_TRIGGERED,{annotationId:i.map(a=>a.annotationId).join()}),this.dialog.open(ml,{panelClass:"velt-mat-dialog-container",data:{title:"Delete recording?",message:"This selected recording will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.recorderContainerDarkMode$.value,variant:"recorder"}}).afterClosed().pipe(ut(1)).subscribe(a=>{a&&(i.forEach(l=>X(this,null,function*(){yield this.deleteRecorderPinAnnotation(l)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(c=>{this.domService.removeHighlightFromElement(c)})},100))}),this.domService.resetSelectedAnnotationsMap(!0,"recorder"))}catch(e){this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotations: ",e)}}deleteRecorderPinAnnotation(e,t){if(this.authService.isFeatureAllowed(je.RECORDER)&&this.documentPaths?.recorder&&e?.annotationId){this.updateNotificationsDatabase(e,rc.DELETED);let i=this.attachmentResolverService.attachmentDataProviderAvailable("recorder"),a=this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()?this.recorderUtilsService.mergeStrippedDataWithRecorderAnnotation(h({},e)):e,l=ai(e?.metadata??{});if(a?.attachments?.length)a.attachments.forEach(_=>{let w={organizationId:l?.organizationId??null,documentId:l?.documentId??null,folderId:l?.folderId??null,attachmentId:_.attachmentId,commentAnnotationId:null,apiKey:l?.apiKey??null};this.storageService.deleteAttachment({attachment:_,metadata:w,useAttachmentResolver:i,attachmentScope:"recorder"}).catch(A=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete attachment: ",A)})});else if(a?.attachment){let _={organizationId:l?.organizationId??null,documentId:l?.documentId??null,folderId:l?.folderId??null,attachmentId:a.attachment.attachmentId,commentAnnotationId:null,apiKey:l?.apiKey??null};this.storageService.deleteAttachment({attachment:a.attachment,metadata:_,useAttachmentResolver:i,attachmentScope:"recorder"})}e?.transcription&&!this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()&&(e?.transcription?.srtBucketPath&&this.storageService.deleteFileFromPath(e.transcription.srtBucketPath).catch(_=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete srt file: ",_)}),e?.transcription?.vttBucketPath&&this.storageService.deleteFileFromPath(e.transcription.vttBucketPath).catch(_=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete vtt file: ",_)})),this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderTime:e?.recordedTime?.duration,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e.attachment?.size,sourceFeature:t||"recording"});let{documentId:c,organizationId:d}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e),g={annotationData:e,actionType:rc.DELETED,notificationSource:"recorder"},u={apiKey:this.configService.getApiKey(),organizationId:d,documentId:c,veltFolderId:e?.metadata?.veltFolderId};return this.commonDbService.deleteData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:d,metadata:u},extraData:g}).then(_=>X(this,null,function*(){let w=yield this.createRecorderData(e,!0);w&&this.recorderActionsService?.onDeleteRecording(w)}))}else return Promise.resolve()}enableAddRecorderMode(){this.authService.isFeatureAllowed(je.RECORDER)?this.addRecorderMode$.next(!0):this.loggingService.catch("Error in RecorderAnnotationService enableAddRecorderMode: ","Recorder feature is not enabled.")}disableAddRecorderMode(){this.addRecorderMode$.next(!1)}addRecorderModeChange(){return this.addRecorderMode$.asObservable()}setRecorderContainerDarkMode(e){try{if(this.recorderContainerDarkMode$.value===e)return;this.recorderContainerDarkMode$.next(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderContainerDarkMode: ",t)}}getRecorderContainerDarkMode(){return this.recorderContainerDarkMode$.asObservable()}enableRecordingTranscription(){try{if(this.analyticsService.setFeatureConfig({feature:je.RECORDER,config:{recordingTranscription:!0}}),this.recordingTranscriptionEnabled$.value===!0)return;this.recordingTranscriptionEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RecorderAnnotationService enableRecordingTranscription: ",e)}}disableRecordingTranscription(){try{if(this.analyticsService.setFeatureConfig({feature:je.RECORDER,config:{recordingTranscription:!1}}),this.recordingTranscriptionEnabled$.value===!1)return;this.recordingTranscriptionEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RecorderAnnotationService disableRecordingTranscription: ",e)}}getRecordingTranscriptionEnabled(){return this.recordingTranscriptionEnabled$.value}getRecordingTranscriptionEnabled$(){return this.recordingTranscriptionEnabled$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService isElementInsideAllowedElements: ",t),!1}}attachRecorder(e){let t=document.getElementById(e);if(t){let i=this.domService.getXPath(t),a=this.getRecorderPinAnnotationObject();a&&(a.targetElement={xpath:i,topPercentage:50,leftPercentage:90},this.saveRecorderToDb(a))}}getRecorderPinAnnotationObject(){let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add recorders.");else{let t=new op;t.from=e,t.color=F.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:i,topPositionY:a}=this.domService.getTopLeftPosition();t.positionX=i,t.positionY=a;let l=this.domService.getCurrentWindowSizeValue();t.screenWidth=l.screenWidth,t.screenHeight=l.screenHeight,t.screenScrollHeight=l.screenScrollHeight,t.recorderedElementPath="";let c=this.docService.getLocation();return c&&(t.locationId=c.locationId,t.location=c.location),t}return null}updateNotificationsDatabase(e,t,i={}){try{let a=e;this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()&&(a=JSON.parse(JSON.stringify(e)),a?.from?.userId&&(a.from={userId:a.from.userId}),delete a.transcription,a?.attachments?.length&&(a.attachments=a.attachments.map(c=>({attachmentId:c?.attachmentId,name:c?.name}))),a.attachment=null,a?.chunkUrls&&(a.chunkUrls={}));let l=h({annotationData:a,actionType:t,notificationSource:"recorder",recordingType:e?.recordingType},i);this.notificationService.updateNotificationDatabase(l)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateNotificationsDatabase: ",a)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}getRecorderUrl(e){try{return e?.pageInfo?.recorderUrl?e.pageInfo.recorderUrl:e?.annotationId?(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.recorderUrl=this.generateRecorderUrl(e),this.updateRecorder(e),e.pageInfo?.recorderUrl):""}catch(t){this.loggingService.catch("Error in RecorderAnnotationService getRecorderUrl: ",t);return}}uploadFile(e,t){let i=this.documentPaths?.organizationId,a=this.documentPaths?.documentId;t?.metadata?.documentId&&(a=t.metadata.documentId,i=t.metadata.organizationId);let l=`${F.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;if(i&&(l=`${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${i}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),this.attachmentResolverService.attachmentDataProviderAvailable("recorder")){let c=this.docService.getBaseMetadata("recorder",{commentAnnotationId:t.commentAnnotationId});return this.storageService.uploadFile({path:l,file:e,useAttachmentResolver:!0,metadata:c,attachmentScope:"recorder"})}return this.storageService.uploadFile({path:l,file:e})}uploadFullRecordingAndUpdateAnnotation(e,t){try{if(!t?.annotationId)return;this.uploadFile(e,t).then(i=>{if(!i?.url)return;let l=this.getAnnotationById(t.annotationId)||t;l.attachments?.length&&(l.attachments[0].url=i.url,l.attachments[0].attachmentId=i.attachmentId,i.bucketPath&&(l.attachments[0].bucketPath=i.bucketPath)),l.attachment=l.attachments?.[0]??null,l.lastUpdated=new Date().getTime(),l.isUrlAvailable=!0,this.updateRecorder(l)}).catch(i=>{this.loggingService.catch("Error uploading full recording: ",i)})}catch(i){this.loggingService.catch("Error in RecorderAnnotationService uploadFullRecordingAndUpdateAnnotation: ",i)}}downloadAttachment(e){this.storageService.downloadAttachment(e)}deleteAttachment(e){return this.storageService.deleteAttachment({attachment:e})}generateRecorderUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.RECORDER_ID),t.searchParams.append(F.URL_PARAMS.RECORDER_ID,e.annotationId),t.href}setRecorderNotesFound(e){try{this.recorderNotesFound$.next(e)}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setRecorderNotesFound: ",t)}}getRecorderNotesFound$(){try{return this.recorderNotesFound$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),de(!1)}}getRecorderNotesFound(){try{return this.recorderNotesFound$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),!1}}editVideoRecording(e,t,i,a,l,c){return X(this,null,function*(){try{let d=qr(this.functions,Kr({url:Dn?.cloudFunction?.videoBackend,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),g=this.docService.getDocumentPaths();i?.metadata?.documentId&&(g=new xm({apiKey:this.configService.getApiKey(),clientDocumentId:i.metadata.clientDocumentId,clientOrganizationId:i.metadata.clientOrganizationId,documentId:i.metadata.documentId,organizationId:i.metadata.organizationId}));let u={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:g?.recorder+(i?.annotationId||""),fromUser:this.authService.getUser(),clientOrganizationId:g?.clientOrganizationId,clientDocumentId:g?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:g?.recorder,annotationId:i?.annotationId,annotationData:i,videoUrl:e,segments:t,zoomOptions:a,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:l,backendUpload:!0};if(c){let j=yield c.arrayBuffer(),q=new Uint8Array(j),ie="";for(let ae=0;ae<q.length;ae++)ie+=String.fromCharCode(q[ae]);let _e=btoa(ie);u.videoBlobData=_e,u.videoBlobType=c.type,u.videoBlobSize=c.size}if(u?.useFirestore&&i){let j=yield this.recorderUtilsService.encryptRecorderAnnotation(i);u.annotationData=j}let _=this.documentPaths?.organizationId,w=this.documentPaths?.documentId;i?.metadata?.documentId&&(w=i.metadata.documentId,_=i.metadata.organizationId);let A=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${w}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`;_&&(A=`${this.configService.getApiKey()}/${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${_}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${w}/${F.FIREBASE_PARTIAL_PATH_RECORDER}`),u.bucketPath=A;let M=yield d(u);if(l==="standalone"){let j=M?.data;if(j&&j?.videoData){let q=atob(j.videoData),ie=new ArrayBuffer(q.length),_e=new Uint8Array(ie);for(let Ie=0;Ie<q.length;Ie++)_e[Ie]=q.charCodeAt(Ie);let ae=new Blob([_e],{type:j.mimeType||"video/mp4"}),ue=document.createElement("a");ue.href=URL.createObjectURL(ae),ue.download="edited-video.mp4",document.body.appendChild(ue),ue.click(),document.body.removeChild(ue)}}return M}catch(d){throw this.loggingService.catch("Error in RecorderAnnotationService editVideoRecording: ",d),d}})}setVideoEditorAutoOpen(e){try{this.videoEditorAutoOpen$.next(h(h({},this.videoEditorAutoOpen$.value),e))}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setVideoEditorAutoOpen: ",t)}}getVideoEditorAutoOpen$(){try{return this.videoEditorAutoOpen$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),de({})}}getVideoEditorAutoOpen(){try{return this.videoEditorAutoOpen$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),{}}}downloadLatestVideo(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: downloadLatestVideo","color: green;");let t=this.getAnnotationById(e);if(!t)return this.loggingService.catch("Recording not found with ID: "+e),!1;let i,a,l=t.latestVersion;if(l&&t.recordingEditVersions?.[l]?(i=t.recordingEditVersions[l].attachments?.[0]?.url,a=t.recordingEditVersions[l].attachments?.[0]?.name):(i=t.attachments?.[0]?.url||t.attachment?.url,a=t.attachments?.[0]?.name||t.attachment?.name),!i)return this.loggingService.catch("No video URL found for recording: "+e),!1;let c=yield fetch(i);if(!c.ok)return this.loggingService.catch("Failed to fetch video: "+c.statusText),!1;let d=yield c.blob(),g=document.createElement("a");return g.href=URL.createObjectURL(d),g.download=a||`recording-${e}.mp4`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(g.href),this.loggingService.log("Successfully downloaded video: "+a),!0}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService downloadLatestVideo: ",t),!1}})}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Lt),Z(st),Z(Hn),Z(kn),Z(Ke),Z(Ve),Z(no),Z(Vn),Z(Oo),Z(_m),Z(un),Z($p),Z(Vo),Z(k),Z(cn),Z($S),Z(Un),Z(Up),Z(Oa),Z(vl),Z(as))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var IYe=["access","accessFields"];function EYe(n){return n?Object.keys(n).length>0:!1}var Re=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we,Ae,Pe,ze,He,qe,En){this.analyticsService=e,this.areaService=t,this.commonDbService=i,this.configService=a,this.docService=l,this.databaseService=c,this.authService=d,this.domService=g,this.afAuth=u,this.avatarService=_,this.contactService=w,this.storageService=A,this.functions=M,this.dialog=j,this.iamService=q,this.loggingService=ie,this.notificationService=_e,this.customFilterService=ae,this.reactionService=ue,this.hotkeyService=Ie,this.recorderService=fe,this.viewsService=we,this.buttonService=Ae,this.metadataService=Pe,this.commonDbUtilsService=ze,this.attachmentResolverService=He,this.userPermissionService=qe,this.recorderAnnotationService=En,this.customPinsById=new Map,this.commentAdded$=new it,this.commentUpdated$=new it,this.commentAccepted$=new it,this.commentRejected$=new it,this.commentAnnotationDeleted$=new it,this.multiThreadCommentAnnotationDeleted$=new it,this.commentAnnotationById$=new Se(null),this.multiThreadCommentAnnotationById$=new Se(null),this.ghostCommentAnnotationMap$=new Se({}),this.unreadCommentsMap$=new Se(null),this.documentPaths=null,this.user=null,this.customCategoryMap=F.CommentCategoryMap,this.allowedElementIds$=new Se([]),this.allowedElementClassNames$=new Se([]),this.allowedElementQuerySelectors$=new Se([]),this.addCommentMode$=new Se(!1),this.persistentCommentMode$=new Se(!1),this.seenByUsers$=new Se(!0),this.deleteReplyConfirmation$=new Se(!1),this.persistentModeBanner$=new Se(!0),this.commentAddedEmitter=null,this.commentContextProvider=null,this.textCommentMode$=new Se(!0),this.sidebarVisible$=new Se(!1),this.sidebarOpenedByCustomTrigger$=new Se(!1),this.floatingCommentsEnabled$=new Se(!0),this.moderatorMode$=new Se(!1),this.streamMode$=new Se(!1),this.enableSignInButton$=new Se(!1),this.enableUpgradeButton$=new Se(!1),this.onSignInClick$=new it,this.onUpgradeClick$=new it,this.enableAttachment$=new Se(!0),this.enableAttachmentDownload$=new Se(!0),this.enableReactions$=new Se(!0),this.enableAnonymousEmail$=new Se(!0),this.enableFormatOptions$=new Se(!1),this.formatConfig$=new Se({bold:{enable:!0},italic:{enable:!0},underline:{enable:!0},strikethrough:{enable:!0}}),this.allowedRecordings$=new Se(["audio","video","screen"]),this.openSidebar$=new it,this.showScreenSizeInfo$=new Se(!1),this.showCommentIndex$=new Se(!1),this.popoverMode$=new Se(!1),this.popoverTriangleComponent$=new Se(!0),this.draftMode$=new Se(!0),this.enableDialogOnHover$=new Se(!0),this.enableDialogOnTargetElementClick$=new Se(!1),this.enablePriority$=new Se(!1),this.enableStatus$=new Se(!0),this.visibilityOptions$=new Se(!1),this.enableResolve$=new Se(!0),this.enableGhostComments$=new Se(!1),this.enableGhostCommentsMessage$=new Se(!0),this.inboxMode$=new Se(!1),this.enableAutoCategorize$=new Se(!1),this.commentContainerDarkMode$=new Se(!1),this.suggestionMode$=new Se(!1),this.mobileMode$=new Se(!0),this.inlineCommentMode$=new Se(!1),this.minimap$=new Se(!1),this.commentsOnDom$=new Se(!0),this.commentToolEnabled$=new Se(!0),this.totalMediaLength$=new Se(0),this.sidebarUrlNavigationEnabled$=new Se(!1),this.detectionStrategy$=new Se(kF.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Se(!1),this.sidebarButtonOnCommentDialogClick$=new it,this.commentNavigationButtonClick$=new it,this.deviceIndicatorOnCommentPins$=new Se(!1),this.sidebarCommentClick$=new it,this.privateCommentMode$=new Se(!1),this.privateCommentAllowed$=new Se(!1),this.privateModeConfig$=new Se(null),this.scrollToComment$=new Se(!0),this.userMentions$=new Se(!0),this.paginatedContactList$=new Se(!1),this.deleteOnBackspace$=new Se(!0),this.hotkeyEnabled$=new Se(!1),this.recordingSummaryEnabled$=new Se(!0),this.unreadIndicatorMode$=new Se(y0.MINIMAL),this.composerMode$=new Se(AZ.DEFAULT),this.enterKeyToSubmit$=new Se(!1),this.resolvedCommentsOnDom$=new Se(!1),this.bubbleOnPinEnabled$=new Se(!1),this.bubbleOnPinHoverEnabled$=new Se(!0),this.pinDragEnabled$=new Se(!0),this.excludeLocationIdsFromSidebar$=new Se([]),this.multiThread$=new Se(!1),this.groupMatchedComments$=new Se(!1),this.shortUserName$=new Se(!0),this.collapsedComments$=new Se(!1),this.fullExpanded$=new Se(!1),this.queryParamsComments$=new Se(!1),this.resolveStatusAccessAdminOnly$=new Se(!1),this.linkCallback$=new Se(!1),this.svgAsImg$=new Se(!1),this.commentToNearestAllowedElement$=new Se(!1),this.filterCommentsOnDom$=new Se(!1),this.maxReplyAvatars$=new Se(3),this.replyAvatars$=new Se(!1),this.commentplaceholder$=new Se(void 0),this.replyplaceholder$=new Se(void 0),this.editplaceholder$=new Se(void 0),this.editcommentplaceholder$=new Se(void 0),this.editreplyplaceholder$=new Se(void 0),this.screenshotEnabled$=new Se(!1),this.pinShadowDOM$=new Se(!0),this.dialogShadowDOM$=new Se(!0),this.dialogShadowDOMExplicit$=new Se(void 0),this.textCommentToolShadowDOM$=new Se(!0),this.pinDarkMode$=new Se(null),this.textCommentToolDarkMode$=new Se(null),this.textCommentToolbarDarkMode$=new Se(null),this.textCommentToolbarShadowDOM$=new Se(!0),this.sidebarShadowDOM$=new Se(!0),this.changeDetectionInCommentMode$=new Se(!1),this.commentSelectionChange$=new it,this.visibilityOptionClicked$=new it,this.submitComment$=new it,this.clearComposer$=new it,this.composerDataMap=new Map,this.commentsFromSidebarMap$=new Se(null),this.sidebarButtonCountType$=new Se("default"),this.filterGhostCommentsInSidebar$=new Se(!1),this.commentSidebarFilters$=new Se(null),this.effectiveSidebarFilters$=new Se({}),this.customSidebarDataAnnotationIds$=new Se(null),this.commentSidebarSystemFiltersOperator$=new Se(Qc.AND),this.bubbleCommentAnnotationIds$=new Se([]),this.updateCommentDialogPositionTriggerSubject$=new Se(void 0),this.areaCommentEnabled$=new Se(!0),this.commentPinCursorImage$=new Se(""),this.commentAnnotationsFromCommentsContainer$=new Se([]),this.customChipDropdownData$=new Se(null),this.originalCommentAnnotationsByDocumentId$=new Se({}),this.draftCommentAnnotationsByAnnotationId$=new Se(null),this.draftMultiThreadCommentAnnotationsByAnnotationId$=new Se({}),this.pendingAddCommentAnnotationData=new Map,this.copyLink$=new Se(""),this.addCommentDragMode=!1,this.dragSubscriptions=[],this.hotkeySubscriptions=[],this.sidebarData$=new Se(null),this.sidebarCustomActionEventData$=new Se(null),this.sidebarCustomActionEventDataAllChanges$=new Se(null),this.sidebarCustomActionEventDataOnInit$=new Se(null),this.customActions$=new Se(!1),this.focusedThreadMode$=new Se(!1),this.openAnnotationInFocusMode$=new Se(!1),this.customStatusesShown$=new Se(!1),this.readOnly$=new Se(!1),this.customAutocompleteSearch$=new Se(!1),this.deleteThreadWithFirstComment$=new Se(!0),this.assignToType$=new Se("dropdown"),this.pageModeComposerContext$=new Se(null),this.contextInPageModeComposer$=new Se(!1),this.focusPageModeComposer$=new it,this.transformContext$=new Se(null),this.expandMentionGroups$=new Se(!1),this.showMentionGroupsFirst$=new Se(!1),this.showMentionGroupsOnly$=new Se(!1),this.fullScreenInSidebar$=new Se(!1),this.composerFileAttachments$=new Se(null),this.attachmentNameInMessage$=new Se(!1),this.allowedFileTypes$=new Se([]),this.forceCloseAllOnEsc$=new Se(!1),this.autoCompleteScrollConfig$=new Se({itemSize:55,minBufferPx:350,maxBufferPx:600,templateCacheSize:350}),this.commentAnnotationContextDraft=null,this.getCommentAnnotationForClient=tt=>{try{let xt=["commentCategories","color","resolved","inProgress","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","screenScrollTop","taggedElementPath","taggedElementRect","targetElement","position","documentParamsId","documentParams","ghostComment","areaAnnotationId","iam","commentSource","involvedUserIds","mentionedUserIds","viewedByUserIds","views"],Je=JSON.parse(JSON.stringify(tt)),$t={};Object.keys(Je).forEach(Xn=>{xt.includes(Xn)||($t[Xn]=Je[Xn])}),$t?.comments?.forEach(Xn=>{let Ii=[];Xn?.reactionAnnotationIds&&Xn?.reactionAnnotationIds?.forEach(No=>{let eo=this.reactionService.getAnnotationById(No);if(eo){let Bn=this.reactionService.getReactionAnnotationForClient(eo);Ii.push(Bn)}}),Xn.reactionAnnotations=Ii}),Je?.viewedByUserIds?.forEach(Xn=>{let Ii=this.contactService.getUserBySnippylyId(Xn);Ii&&($t.viewedBy||($t.viewedBy=[]),$t.viewedBy.push(Ii))}),this.user?.userSnippylyId&&($t.unread=!Je?.viewedByUserIds?.includes(this.user.userSnippylyId));let sn=Je?.targetElement?.anchor?.fXPath||Je?.targetElement?.fXpath;return sn&&($t.basicAnchorData={xpath:sn,topPercentage:Je?.targetElement?.topPercentage||0,leftPercentage:Je?.targetElement?.leftPercentage||0}),JSON.parse(JSON.stringify($t))}catch{return null}},this.loggingService.log("%c[WB] Creating CLASS: CommentService","color: blue;"),this.analyticsService.setCommentService(this),this.contactService.setCommentService(this),this.notificationService.setCommentService(this),this.docService.setCommentService(this),this.authService.setCommentService(this),this.viewsService.setCommentService(this),this.reactionService.setCommentService(this),this.recorderAnnotationService.setCommentService(this),this.domService.getSelectedAnnotationsMap$().pipe(to(100),Lr()).subscribe(([tt,xt])=>{try{if(this.draftCommentAnnotationsByAnnotationId$.value){let Je=Object.keys(this.draftCommentAnnotationsByAnnotationId$.value||{}),$t=[];Object.keys(tt||{}).forEach(Xn=>{!xt?.[Xn]&&Je.includes(Xn)&&$t.push(Xn)});let sn=JSON.parse(JSON.stringify(this.draftCommentAnnotationsByAnnotationId$.value||{}));$t.forEach(Xn=>{delete sn[Xn]}),dr(sn,this.draftCommentAnnotationsByAnnotationId$.value)||this.draftCommentAnnotationsByAnnotationId$.next(sn)}}catch{}}),this.docService.getDocumentPaths$().pipe(Lr()).subscribe(([tt,xt])=>{tt?.documentId!==xt?.documentId&&this.unreadCommentsMap$.next(null),xt&&this.shouldEnableReadOnly()},tt=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",tt)}),this.draftCommentAnnotationsByAnnotationId$.pipe(Lr()).subscribe(([tt,xt])=>{try{if(this.pendingAddCommentAnnotationData.size===0)return;let Je=Object.keys(tt||{});if(Je.length===0)return;let $t=new Set(Object.keys(xt||{}));Je.forEach(sn=>{!$t.has(sn)&&this.pendingAddCommentAnnotationData.has(sn)&&this.pendingAddCommentAnnotationData.delete(sn)})}catch(Je){this.loggingService.catch("Error in CommentService pendingAddCommentAnnotationData reconcile: ",Je)}}),this.authService.getUser$().subscribe(tt=>{tt||this.resetCacheData()},tt=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",tt)}),this.authService.getUser$().pipe(ye(tt=>tt?mn([this.iamService.isUserAdmin$(),this.contactService.getUserOrganizationContacts$()]).pipe(ge(([xt,Je])=>{let $t=!1;return Je?.find(sn=>sn.userId===tt?.userId)&&($t=!0),{isUserAdmin:xt,isOrgUser:$t}})):de({isUserAdmin:!1,isOrgUser:!1}))).subscribe(({isUserAdmin:tt,isOrgUser:xt})=>{let Je=tt||xt;Je!==this.privateCommentAllowed$.value&&this.privateCommentAllowed$.next(Je)}),this.databaseService.getDb().pipe($e(tt=>!!tt),ut(1)).subscribe(tt=>{tt&&this.getDocumentPaths()},tt=>{this.loggingService.catch("Error in CommentService getDb subscription: ",tt)}),this.domService.onWindowPointerMove$().subscribe(tt=>{if(this.addCommentMode$.value){let xt=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let Je=this.domService.getBackgroundElement(tt.clientX,tt.clientY,!0,!0);if(Je&&gfe(Je,{x:tt.clientX,y:tt.clientY})&&(Je=Je?.parentElement),Je)if(this.isElementInsideAllowedElements(Je))if(Ag(tt.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==Je&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=Je;let $t=this.domService.getSelectedAnnotationsMap("comment")||{},sn=this.commentPinCursorImage$.value||F.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,sn,!!Object.keys($t)?.length),xt=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&xt&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},tt=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",tt)}),this.domService.onWindowKeyupEsc$().subscribe(tt=>{if(this.addCommentMode$.value){let xt=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(xt)?.length&&this.domService.resetSelectedAnnotationsMap(),this.disableAddCommentMode()}},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",tt)}),this.domService.onDocumentClick$().subscribe(tt=>{if(tt&&!WF(tt)){let xt=this.domService.getSelectedAnnotationsMap("comment")||{};if(xt=h(h({},xt),this.domService.getSelectedAnnotationsMap("multiThread")||{}),xt=h(h({},xt),this.domService.getSelectedAnnotationsMap("suggestion")||{}),Object.keys(xt)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),tt.preventDefault(),tt.stopPropagation();return}}if(tt&&this.addCommentMode$.value&&!Ag(tt.target)){let xt=!1;if(this.addCommentDragMode)tt.preventDefault(),tt.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let Je=this.domService.getBackgroundElement(tt.clientX,tt.clientY);if((this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(tt.clientX,tt.clientY)||tt&&WF(tt))&&(Je=null),Je&&(this.isElementInsideAllowedElements(Je)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement(Je))&&(xt=this.isElementInsideManualCommentContainer(Je),!xt)){tt.preventDefault(),tt.stopPropagation();let $t=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(tt,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,$t)}}this.persistentCommentMode$?.value?this.detectToAddAreaComment():xt||this.disableAddCommentMode()}},tt=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",tt)}),this.addCommentMode$.subscribe(tt=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),tt?(this.domService.addClassToElement(document.body,"snippyly-add-comment-mode"),this.detectToAddAreaComment(),this.addIframeContainerStaticAttribute()):(this.removeIframeContainerStaticAttribute(),this.domService.removeClassFromElement(document.body,"snippyly-add-comment-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"),this.dragSubscriptions.forEach(xt=>xt.unsubscribe()),this.clearFreeStyleCommentContext())},tt=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",tt)}),this.domService.onWindowKeyupBackspace$().subscribe(tt=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",tt)}),this.domService.onWindowKeyupDelete$().subscribe(tt=>{this.deleteCommentPinAnnotations("keyupDelete")},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",tt)}),this.domService.getDeleteCommmentAnnotations$().subscribe(tt=>{tt?.length&&(tt?.filter(Je=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes(Je.type))).forEach(Je=>X(this,null,function*(){yield this.deleteCommentPinAnnotation(Je)}))},tt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",tt)}),this.getPopoverMode$().subscribe(tt=>{tt?document?.body?.setAttribute(F.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(F.ATTRIBUTES.VELT_POPOVER_MODE)},tt=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",tt)}),this.customFilterService.customCategoryMap$.subscribe(tt=>{this.customCategoryMap=tt},tt=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",tt)}),this.hotkeyEnabled$.subscribe(tt=>{tt?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},tt=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",tt)}),this.domService.getSelectedAnnotationsMap$().pipe(Lr()).subscribe(([tt,xt])=>{try{let Je=Object.values(tt||{}).filter(sn=>!["tag","recorder","rewriter","arrow","area"].includes(sn.type)),$t=Object.values(xt||{}).filter(sn=>!["tag","recorder","rewriter","arrow","area"].includes(sn.type));Je?.forEach(sn=>{$t?.find(Xn=>Xn.annotationId===sn.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(sn),selected:!1})}),$t?.forEach(sn=>{Je?.find(Xn=>Xn.annotationId===sn.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(sn),selected:!0})})}catch(Je){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",Je)}},tt=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",tt)})}clearCache(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in CommentService","color: green;"),this.commentAnnotationById$.next(null),this.draftCommentAnnotationsByAnnotationId$.next(null),this.multiThreadCommentAnnotationById$.next({}),this.draftMultiThreadCommentAnnotationsByAnnotationId$.next({}),this.pendingAddCommentAnnotationData.clear(),this.customAutocompleteSearch$.next(!1),this.hightlightElement=null,this.addCommentMode$.next(!1),this.unreadCommentsMap$.next(null),this.documentPaths=null,this.commentsFromSidebarMap$.next(null),this.customSidebarDataAnnotationIds$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearCache: ",e)}}setCommentActionsService(e){try{this.commentActionsService=e}catch(t){this.loggingService.catch("Error in CommentService setCommentActionsService: ",t)}}detectToAddAreaComment(){try{let e=this.areaService.getAreaEnabled(),t=this.getAreaCommentEnabled();if(e&&t){let i,a,l,c=null,d=null;this.dragSubscriptions.forEach(g=>g.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe($e(g=>!(g&&WF(g))),ut(1)).subscribe(g=>{c=null,d=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(u=>{if(c===null){let _=u?.startPoint?.event?.target,w=Po(_),A=Ag(_),M=this.isElementInsideAllowedElements(_);c=!w&&!A&&M}if(c){this.addCommentDragMode=!0,i=u.startPoint,a=u.curPoint;let _=u?.curPoint?.event?.target,w=Po(_),A=Ag(_),M=this.isElementInsideAllowedElements(_);d=!w&&!A&&M,d?l=this.domService.drawRectangle(i,a):l?.remove()}})),this.domService.onWindowPointerUp$().pipe(Rd(1),ut(1)).subscribe(u=>{if(a={x:u.clientX,y:u.clientY},i&&a&&(l?.remove(),c&&d)){let _=[{x:i.x-window.scrollX,y:i.y-window.scrollY},{x:a.x,y:a.y}],w=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(u,void 0,_,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,w)}this.dragSubscriptions.forEach(_=>_.unsubscribe())})}))}}catch(e){this.loggingService.catch("Error in CommentService detectToAddAreaComment: ",e)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling CommentService FUNCTION: resetCacheData","color: green;"),this.commentAnnotationById$.next(null),this.draftCommentAnnotationsByAnnotationId$.next(null),this.multiThreadCommentAnnotationById$.next({}),this.draftMultiThreadCommentAnnotationsByAnnotationId$.next({}),this.pendingAddCommentAnnotationData.clear()}catch(e){this.loggingService.catch("Error in CommentService resetCacheData: ",e)}}addAreaContainerTag(){try{if(!(document.querySelector(F.TAGS.VELT_AREAS)||document.querySelector(F.TAGS.SNIPPYLY_AREAS))){let t=document.createElement(F.TAGS.VELT_AREAS);document.body.appendChild(t)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${F.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(t=>{window.getComputedStyle(t).position==="static"&&t.setAttribute(F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(t=>{t.removeAttribute(F.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC)})}catch(e){this.loggingService.catch("Error in CommentService removeIframeContainerStaticAttribute: ",e)}}subscribeHotkeyEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: subscribeHotkeyEvents","color: green;"),this.unsubscribeHotkeyEvents(),this.hotkeySubscriptions.push(this.hotkeyService.getKeyPressEvent("c").subscribe(e=>{e&&!this.addCommentMode$.value&&this.enableAddCommentMode()},e=>{this.loggingService.catch("Error in CommentService hotkeyService.getKeyPressEvent subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CommentService subscribeHotkeyEvents: ",e)}}unsubscribeHotkeyEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribeHotkeyEvents","color: green;"),this.hotkeySubscriptions.forEach(e=>e?.unsubscribe())}catch(e){this.loggingService.catch("Error in CommentService unsubscribeHotkeyEvents: ",e)}}setCommentAddedEmitter(e){try{this.commentAddedEmitter=e}catch(t){this.loggingService.catch("Error in CommentService setCommentAddedEmitter: ",t)}}setContextProvider(e){try{this.commentContextProvider=e}catch(t){this.loggingService.catch("Error in CommentService setContextProvider: ",t)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}setAllowedElementIds(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementIds:e}}),this.allowedElementIds$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementIds: ",t)}}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}setAllowedElementClassNames(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementClassNames:e}}),this.allowedElementClassNames$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementClassNames: ",t)}}getAllowedElementClassNames(){return this.allowedElementClassNames$.asObservable()}setAllowedElementQuerySelectors(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{allowedElementQuerySelectors:e}}),this.allowedElementQuerySelectors$.next(e||[])}catch(t){this.loggingService.catch("Error in CommentService setAllowedElementQuerySelectors: ",t)}}getAllowedElementQuerySelectors(){return this.allowedElementQuerySelectors$.asObservable()}getAllCommentAnnotations({customClientDocumentId:e,params:t,excludeDomChanges:i,detectGhostComments:a,skipPositionCalculation:l,query:c,fromCommentSidebar:d,analytics:g,addFilterCommentsOnDomCheck:u}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let _,w,A;g?.enabled&&this.analyticsService.trackEvent(g?.eventName||Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,g?.properties);try{if(e&&(A=`${tr(e)}`),t&&typeof t=="object"){let M=Ai(t);w=M?.id,_=tr(JSON.stringify(M))}}catch(M){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",M)}return _r(this.afAuth).pipe($e(M=>!!M),ye(M=>this.isFeatureAllowed({firebaseUser:M,annotations:[],filteredAnnotations:[]})),ye(M=>M.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(j=>(M.featureAllowed=j,M))):de(M)),ye(M=>M.featureAllowed?de(M).pipe(ye(j=>this.docService.getDocumentPaths$().pipe(ge(q=>(this.documentPaths=q,j.documentPaths=q,j)))),ye(j=>c?.documentIds?.length||A?this.getDataFromDocumentIds({documentIds:A?[A]:c?.documentIds?.map(q=>`${tr(q)}`),organizationId:this.documentPaths?.organizationId,query:c}).pipe(ge(q=>({res:j,data:q}))):this.docService.getDocumentIds$().pipe(ye(q=>{let ie=q?.length>0?q.map(_e=>_e.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ie.length>0?ie:[A??""],organizationId:this.documentPaths?.organizationId,query:c}).pipe(ge(_e=>({res:j,data:_e})))}))),ye(j=>j?.data?(j.res.annotations=j.data||[],de(j.res).pipe(ye(q=>this.docService.getLocation$().pipe(ge(ie=>(q.location=ie,q)))),ye(q=>this.docService.getLocations$().pipe(ge(ie=>(q.customLocations=ie,q)))),ye(q=>this.docService.getExcludedLocationIds$().pipe(ge(ie=>(q.excludedLocationIds=ie,q)))),ge(q=>{if(q.filteredAnnotations=[],c)return q.filteredAnnotations=q.annotations?.slice(),q;if(A&&!_||d)return q.filteredAnnotations=q.annotations?.slice(),q?.excludedLocationIds?.length&&(q.filteredAnnotations=q.filteredAnnotations?.filter(ie=>ie?.location?.id?!q.excludedLocationIds.includes(ie.location.id):!0)),q;{let ie=[],_e=[];return _?(ie.push(_),w&&_e.push(w)):(ie.push(q?.location?.locationId),ie.push(...Object.values(q?.customLocations||[]).map(ae=>ae.locationId)),q?.location?.location?.id&&_e.push(q?.location?.location?.id),_e.push(...Object.values(q?.customLocations||{}).map(ae=>ae.location?.id).filter(ae=>!!ae))),q.filteredAnnotations=this.filterAnnotationsByLocationIds(q?.annotations,ie,_e),q?.excludedLocationIds?.length&&(q.filteredAnnotations=q.filteredAnnotations?.filter(ae=>ae?.location?.id?!q.excludedLocationIds.includes(ae.location.id):!0)),q}}),ye(q=>this.isPrivateCommentAllowed$().pipe(ge(ie=>(ie||(q.filteredAnnotations=q.filteredAnnotations?.filter(_e=>!Pl(_e))),q)))),ye(q=>this.draftCommentAnnotationsByAnnotationId$.pipe(ge(ie=>(q.filteredAnnotations=q.filteredAnnotations?.filter(_e=>!_e.isDraft),ie&&q.filteredAnnotations.push(...Object.values(ie)),q)))),ye(q=>i?de(q):q?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ge(()=>q)):de(q)),ye(q=>i?de(q):this.addCommentMode$.pipe(ye(ie=>ie&&!this.getChangeDetectionInCommentMode()?de(q):q?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(ge(()=>q)):de(q)))),ge(q=>{if(!l){(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(q.filteredAnnotations=q.filteredAnnotations?.map(_e=>{let ae=Object.assign({},_e);return this.calculateCommentAnnotationPosition(ae,a),ae}));let ie={};q.filteredAnnotations?.forEach(_e=>{if(_e?.targetTextRange){let ae=this.domService.getElementFromTargetTextRange(_e?.targetTextRange);ie[_e.annotationId]=!!ae}}),q.textAnnotationsElementMap=ie}return q}),ye(q=>q?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(ge(ie=>(this.updateUnreadAnnotationsMap(q?.annotations,ie),q))):(EYe(this.unreadCommentsMap$.value)&&this.unreadCommentsMap$.next({}),de(q))))):de(null))):de(null)),ge(M=>{try{return typeof M=="object"&&M?JSON.parse(JSON.stringify(M)):M}catch{return M}}),bt((M,j)=>Zt(M?.filteredAnnotations,j?.filteredAnnotations)&&Zt(M?.textAnnotationsElementMap,j?.textAnnotationsElementMap)),ye(M=>M?M?.filteredAnnotations?de(M?.filteredAnnotations||[]):de([]):de(null)),ye(M=>u?this.filterCommentsUsingSidebarSettings(M):de(M)))}getAllMultiThreadCommentAnnotations(e,t,i,a,l,c){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let d,g;try{if(e&&(g=tr(e)),t&&typeof t=="object"){let u=Ai(t);d=tr(JSON.stringify(u))}}catch(u){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",u)}return _r(this.afAuth).pipe($e(u=>!!u),ye(u=>this.isFeatureAllowed({firebaseUser:u,annotations:[],filteredAnnotations:[]})),ye(u=>u.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(_=>(u.featureAllowed=_,u))):de(u)),ye(u=>u.featureAllowed?de(u).pipe(ye(_=>this.docService.getDocumentPaths$().pipe(ge(w=>(this.documentPaths=w,_.documentPaths=w,_)))),ye(_=>g?this.getMultiThreadDataFromDocumentIds([g]).pipe(ge(w=>({res:_,data:w}))):this.docService.getDocumentIds$().pipe(ye(w=>{let A=w?.length>0?w.map(M=>M.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(A.length>0?A:[`${g}`]).pipe(ge(M=>({res:_,data:M})))}))),ye(({res:_,data:w})=>w?(_.annotations=w||[],de(_).pipe(ye(A=>this.docService.getLocation$().pipe(ge(M=>(A.location=M,A)))),ye(A=>this.docService.getLocations$().pipe(ge(M=>(A.customLocations=M,A)))),ye(A=>this.docService.getExcludedLocationIds$().pipe(ge(M=>(A.excludedLocationIds=M,A)))),ge(A=>{if(A.filteredAnnotations=[],g&&!d)return A.filteredAnnotations=A.annotations?.slice(),A?.excludedLocationIds?.length&&(A.filteredAnnotations=A.filteredAnnotations?.filter(M=>M?.location?.id?!A.excludedLocationIds.includes(M.location.id):!0)),A;{let M=[],j=[];return d?M.push(d):(M.push(A?.location?.locationId),M.push(...Object.values(A?.customLocations||[]).map(q=>q.locationId)),A?.location?.location?.id&&j.push(A?.location?.location?.id),j.push(...Object.values(A?.customLocations||{}).map(q=>q.location?.id).filter(q=>!!q))),A.filteredAnnotations=this.filterAnnotationsByLocationIds(A?.annotations,M,j),A?.excludedLocationIds?.length&&(A.filteredAnnotations=A.filteredAnnotations?.filter(q=>q?.location?.id?!A.excludedLocationIds.includes(q.location.id):!0)),A}}),ye(A=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ge(M=>(A.filteredAnnotations=A.filteredAnnotations?.filter(j=>!j.isDraft),M&&A.filteredAnnotations.push(...Object.values(M)),A)))),ye(A=>i?de(A):A?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ge(()=>A)):de(A)),ye(A=>i?de(A):this.addCommentMode$.pipe(ye(M=>M&&!this.getChangeDetectionInCommentMode()?de(A):A?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(ge(()=>A)):de(A)))),ge(A=>(l||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(A.filteredAnnotations=A.filteredAnnotations?.map(M=>{let j=Object.assign({},M);return this.calculateCommentAnnotationPosition(j,a),j})),A)),ye(A=>A?.filteredAnnotations?de(A?.filteredAnnotations||[]):de([])))):de(null))):de(null)),bt(Zt),ye(u=>c?this.filterCommentsUsingSidebarSettings(u):de(u)))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>(this.user=i,y(h({},t),{user:i}))))),ye(t=>Mo(t.config,t.user,je.COMMENT)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}buildVisibilityTokens(e,t,i){try{let a=It(t),l=[F.DEFAULT_VELT_CONTEXT,`${F.VISIBILITY_SELF_PREFIX}${a}`],c=e?.[t];return i&&c?.organization?.[i]?.accessRole&&l.push(`organizationPrivate:${i}`),l}catch(a){return this.loggingService.catch("Error in CommentService buildVisibilityTokens: ",a),[F.DEFAULT_VELT_CONTEXT]}}getDataFromDocuments(e){let{documentIds:t,organizationId:i,query:a}=e;if(!this.configService?.getApiKey())return de(null);if(t?.some(A=>!A)||!this.documentPaths)return de(null);let l,c,d=[];if(a)a?.folderId&&(l=Br(a?.folderId)),a?.locationId&&(d=[...d,a?.locationId]),a?.locationIds?.length&&(d=[...d,...a?.locationIds]),c=a?.statusIds;else{l=this.docService.getDocumentPaths()?.veltFolderId;let A=this.docService.getDocumentPaths()?.locationId;A&&(d=[...d,A])}let g={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(g.documentId=t?.length?t[0]:void 0,g.organizationId=this.documentPaths?.organizationId);let u=this.authService.getUser()?.userId;if(!u)return de(null);let _=this.authService.getIsPrivateCommentsEnabled();return(_?this.userPermissionService.getCurrentUserPermissionsWithServerIds$().pipe($e(A=>A!==null&&!!A[u])):de(null)).pipe(ye(A=>{let M=_?this.buildVisibilityTokens(A,u,i??this.documentPaths?.organizationId):[F.DEFAULT_VELT_CONTEXT],j=this.userPermissionService?.getIsContextEnabled()?this.docService.getProcessedDocContext():[],q=[...M,...j],ie=this.userPermissionService?.getIsContextEnabled(),_e;if(ie){let ae=[];for(let ue=0;ue<q.length;ue+=F.LISTENER_CONTEXT_BATCH_SIZE)ae.push(q.slice(ue,ue+F.LISTENER_CONTEXT_BATCH_SIZE));this.loggingService.logContext("[CONTEXT] getDataFromDocuments called with accessFields:",JSON.parse(JSON.stringify(q??"nil"))),_e=mn(ae.map(ue=>this.commonDbService.dbListener({feature:"allComments",properties:y(h({},g),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",i??this.documentPaths?.organizationId),ft("metadata.documentId","in",t),...c?.length?[ft("status.id","in",c)]:[],...l?[ft("metadata.veltFolderId","==",l)]:[],...d?.length?[ft("location.id","in",d)]:[],...ue?.length?[ft("context.accessFields","array-contains-any",ue)]:[]),po("lastUpdated","desc"),po("createdAt","desc")]})}).pipe(va()))).pipe(ge(ue=>ja(JSON.parse(JSON.stringify(ue)))))}else{let ae=[];for(let ue=0;ue<(t?.length??0);ue+=F.LISTENER_BATCH_SIZE)ae.push(t?.slice(ue,ue+F.LISTENER_BATCH_SIZE)??[]);_e=mn(ae.map(ue=>this.commonDbService.dbListener({feature:"allComments",properties:y(h({},g),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",i??this.documentPaths?.organizationId),ft("metadata.documentId","in",ue),...c?.length?[ft("status.id","in",c)]:[],...l?[ft("metadata.veltFolderId","==",l)]:[],...d?.length?[ft("location.id","in",d)]:[],...q?.length&&_?[ft("context.accessFields","array-contains-any",q)]:[]),po("lastUpdated","desc"),po("createdAt","desc")]})}).pipe(va()))).pipe(ge(ue=>ja(JSON.parse(JSON.stringify(ue)))))}return _e.pipe(ye(ae=>ae?.data?de(ae).pipe(ye(ue=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:ue,feature:"allComments"}).pipe(ge(Ie=>({data:Object.values(Ie?.data||{}).filter(fe=>typeof fe=="object"),operation:Ie?.operation})))),ge(({data:ue,operation:Ie})=>{let fe=ue.reduce((we,Ae)=>{let Pe=Ae.metadata?.documentId;return Pe&&(we[Pe]||(we[Pe]=[]),we[Pe].push(Ae)),we},{});return{data:ue,documentMap:fe,operation:Ie}}),ge(({data:ue,documentMap:Ie,operation:fe})=>c?{data:ue,documentMap:Ie,operation:fe}:(ue?.length&&(ue?.forEach(we=>{this.sanitizeCommentAnnotation(we)}),this.setAnnotationIndex(ue),this.updateAnnotationsForSelectAllContentMode(ue),ue.forEach(we=>{this.customFilterService.convertLegacyAnnotationStatus(we),this.customFilterService.convertLegacyPriority(we),this.customFilterService.convertLegacyCategory(we)})),{data:ue,documentMap:Ie,operation:fe})),Gn(ue=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",ue),de([]))),dn(({documentMap:ue})=>{c||Object.entries(ue??{}).forEach(([Ie,fe])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(fe)))})}),ge(({data:ue,documentMap:Ie,operation:fe})=>({data:this.filterUserDraftComments(ue),documentMap:Ie,operation:fe})),ge(({data:ue,documentMap:Ie,operation:fe})=>({data:this.removeDraftFlags(ue),documentMap:Ie,operation:fe})),ye(({data:ue,documentMap:Ie,operation:fe})=>c?de({data:ue,documentMap:Ie,operation:fe}):this.mergeDraftAnnotations(ue).pipe(ge(we=>({data:we,documentMap:Ie,operation:fe})))),ge(({data:ue,documentMap:Ie,operation:fe})=>{if(!c)if(fe?.type==="removed"){if(fe?.ids?.length){let we=this.commentAnnotationById$.value??{};fe?.ids?.forEach(Ae=>{delete we?.[Ae]}),this.commentAnnotationById$.next(we)}}else Object.entries(Ie??{}).length?Object.entries(Ie??{}).forEach(([Ae,Pe])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:Ae,annotations:Pe})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return ue})):de(null)))}))}fetchCommentAnnotations(e){return X(this,null,function*(){try{let t=this.authService.getUser();if(!t)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),{data:[],hasMore:!1};let i=this.configService?.getApiKey(),a=e?.organizationId??t?.clientOrganizationId,l=ka(a??""),c=[];e?.allDocuments||(c=e?.documentIds?.map(M=>pi(M??""))??this.docService.getDocumentIds()?.map(M=>M.documentId));let d=[];if(d.push(ft("metadata.organizationId","==",l)),d.push(ft("metadata.apiKey","==",i)),e?.folderId){let M=Br(e?.folderId);d.push(ft("metadata.veltFolderId","==",M))}if(e?.locationId&&d.push(ft("location.id","==",e?.locationId)),c?.length&&d.push(ft("metadata.documentId","in",c)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");d.push(ft("resolvedByUserId","==",e?.resolvedBy))}if(e?.mentionedUserIds?.length){if(e?.order==="asc")throw new Error("Order by mentionedUserIds is not supported in ascending order.");d.push(ft("mentionedUserIds","array-contains-any",e?.mentionedUserIds))}if(e?.userIds?.length){if(e?.order==="asc")throw new Error("Order by userIds is not supported in ascending order.");d.push(ft("from.userId","in",e?.userIds))}if(e?.statusIds?.length){if(e?.order==="asc")throw new Error("Order by status id is not supported in ascending order.");d.push(ft("status.id","in",e?.statusIds))}let g=new Date().getTime();if(e?.createdAfter&&d.push(ft("createdAt",">=",e?.createdAfter)),e?.createdBefore&&d.push(ft("createdAt","<=",e?.createdBefore??g)),e?.updatedAfter&&d.push(ft("lastUpdated",">=",e?.updatedAfter??g)),e?.updatedBefore&&d.push(ft("lastUpdated","<=",e?.updatedBefore??g)),d.push(po("lastUpdated",e?.order??"desc"),po("createdAt",e?.order??"desc")),e?.pageToken){let M=yield LZ(e?.pageToken??"","veltencrypttoken","veltencrypttoken");d.push(Xbe(parseInt(M,10),"lastUpdated"))}let u=e?.pageSize??100;d.push(bm(u+1));let _=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:d,apiKey:i??"",organizationId:l}}),w=_.length>u;_=_.slice(0,u);let A=_?.reduce((M,j)=>(M[j?.annotationId]=j,M),{});return A=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:A,shouldAwait:!0}),A=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:A}),{data:Object.values(A??{}),hasMore:w}}catch(t){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",t),t}})}filterUserDraftComments(e){let t=this.authService.getUser();return e.filter(i=>(i.comments=i?.comments?.filter(a=>a?.from?.userId===t?.userId||!a?.isDraft),!!i?.comments?.length))}removeDraftFlags(e){return e.forEach(t=>delete t.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(ge(t=>{let i=t||{};return e?.filter(a=>{i?.[a?.annotationId]&&delete i[a?.annotationId]}),i}),ge(t=>{if(t){let i=e.slice();return i.push(...Object.values(t)),i}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:t,query:i}){return this.getDataFromDocuments({documentIds:e,organizationId:t,query:i})}getMultiThreadDataFromDocumentIds(e){return this.getMultiThreadDataFromDocuments({documentIds:e})}getMultiThreadDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t}=e;if(t?.some(c=>!c)||!this.documentPaths)return de(null);let i=this.docService.getDocumentPaths()?.veltFolderId,a=de([]),l={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(l.documentId=t?.length?t[0]:void 0,l.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let c=[F.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],d=[];for(let g=0;g<(c?.length??0);g+=F.LISTENER_CONTEXT_BATCH_SIZE)d.push(c?.slice(g,g+F.LISTENER_CONTEXT_BATCH_SIZE)??[]);a=mn(d.map(g=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:y(h({},l),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",this.documentPaths?.organizationId),ft("metadata.documentId","in",t),...i?[ft("metadata.veltFolderId","==",i)]:[],...g?.length?[ft("context.accessFields","array-contains-any",g)]:[])]})}).pipe(va()))).pipe(ge(g=>ja(g)))}else{let c=[];for(let d=0;d<(t?.length??0);d+=F.LISTENER_BATCH_SIZE)c.push(t?.slice(d,d+F.LISTENER_BATCH_SIZE)??[]);a=mn(c.map(d=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:y(h({},l),{firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",this.documentPaths?.organizationId),ft("metadata.documentId","in",d),...i?[ft("metadata.veltFolderId","==",i)]:[])]})}).pipe(va()))).pipe(ge(d=>ja(d)))}return a.pipe(ye(c=>c?.data?de(c).pipe(ge(d=>({data:d?.data,operation:d?.operation})),ge(({data:d,operation:g})=>{let u=[];return d&&(u=Object.values(d??{}).filter(_=>typeof _=="object")),{data:u,operation:g}}),Gn(d=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",d),de({data:[],operation:null}))),ge(({data:d,operation:g})=>{d.forEach(_=>{delete _.isDraft});let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});return{data:d,documentMap:u,operation:g}}),ye(({data:d,documentMap:g,operation:u})=>{let _=[];return this.commentAnnotationById$.pipe(ye(()=>this.domService.getSelectedAnnotationsMap$().pipe(ge(w=>({selectedAnnotationsMap:w})))),ge(({selectedAnnotationsMap:w})=>{let A={};return Object.keys(g??{}).forEach(M=>{let j=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:M});j&&j?.forEach(q=>{A[q?.annotationId]=q})}),_=d.filter(M=>{let j=!1;if(M?.commentAnnotations){for(let q in M?.commentAnnotations)if(A?.[q]&&A?.[q]?.status?.id!==this.customFilterService.resolvedStatus.id){j=!0;break}}return j}),_.forEach(M=>{Object.keys(M?.commentAnnotations||{}).forEach(j=>{M.commentAnnotationsMap||(M.commentAnnotationsMap={}),M.commentAnnotationsMap[j]=A?.[j]})}),{data:_,operation:u}}))}),ye(({data:d,operation:g})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ge(u=>{let _=u||{};return d?.filter(w=>{_?.[w?.annotationId]&&delete _[w?.annotationId]}),_}),ge(u=>{if(u){let _=d.slice();return _.push(...Object.values(u)),{data:_,operation:g}}return{data:d,operation:g}}))),ge(({data:d,operation:g})=>{let u=d.reduce((_,w)=>{let A=w.metadata?.documentId;return A&&(_[A]||(_[A]=[]),_[A].push(w)),_},{});if(g?.type==="removed"){if(g?.ids?.length){let _=this.multiThreadCommentAnnotationById$.value;g?.ids?.forEach(w=>{delete _?.[w]}),this.multiThreadCommentAnnotationById$.next(_)}}else Object.keys(u??{}).forEach(_=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,annotations:u[_]})});return d})):de(null)))}else return de(null)}updateUnreadAnnotationsMap(e,t){try{let i=new Date(F.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(l=>l?.lastUpdated>i);if(t){let l={},c=!1;a.forEach(d=>{let g=0,u=t?.[d?.annotationId];if(u){let _=u?.comments;_&&d?.comments?.forEach(w=>{_?.[w?.commentId]?.views?.[this.user?.userSnippylyId]||g++})}g?g!==l?.[d?.annotationId]&&(l[d?.annotationId]=g,c=!0):l?.[d?.annotationId]&&(delete l[d?.annotationId],c=!0)}),this.unreadCommentsMap$.next(l)}}catch(i){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",i)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(t=>{if(t?.selectAllContent&&t?.targetElementId){let i=ll(t.targetElementId,["id","data-id"]);if(i){let a=i.textContent;a&&(t.targetTextRange={commonAncestorContainer:this.domService.getXPath(i),text:a,occurrence:1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(i)??void 0},delete t?.targetElement)}}})}catch(t){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",t)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i?.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.commentAnnotationById$.value??{}),l);this.commentAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ge(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",i),de([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i=null;this.commentAnnotationById$.value&&(i={},Object.values(this.commentAnnotationById$.value).forEach(l=>{l?.metadata?.documentId==t&&l?.metadata?.organizationId==e&&(i[l?.annotationId]=l)}));let a=this.draftCommentAnnotationsByAnnotationId$.value;return a&&(i===null&&(i={}),Object.values(a).forEach(l=>{l?.metadata?.documentId===t&&l?.metadata?.organizationId===e&&!i[l?.annotationId]&&(i[l?.annotationId]=l)})),i?Object.values(i):null}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId:",i),[]}}getCommentAnnotationsByDocumentId$({clientDocumentId:e,documentId:t}){try{return e&&!t&&(t=this.docService.generateDocumentId(e)),t?this.docService.getDocumentPaths$().pipe(ye(i=>this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:i?.organizationId,documentId:t}))):de(null)}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByDocumentId$:",i),de(null)}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(ye(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):de([])))}getCommentAnnotationsOnCurrentOrganizationAndDocument(){try{let e=this.docService.getDocumentPaths();return e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e?.organizationId,documentId:e?.documentId}):[]}catch(e){return this.loggingService.catch("Error in CommentService getCommentAnnotationsOnCurrentOrganizationAndDocument:",e),[]}}setOriginalCommentAnnotationsByAnnotationId(e){try{let t={};e?.forEach(i=>{i?.annotationId&&(t[i?.annotationId]=i)}),this.originalCommentAnnotationsByDocumentId$.next(h(h({},this.originalCommentAnnotationsByDocumentId$.value),t))}catch(t){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",t)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:i,queryHash:a}){try{if(t){e||(e=F.NO_ORGANIZATION_ID),a||(a=F.DEFAULT_QUERY_HASH);let l={};i.forEach(d=>{d?.annotationId&&(l[d?.annotationId]=d)});let c=h(h({},this.multiThreadCommentAnnotationById$.value),l);this.multiThreadCommentAnnotationById$.next(c)}}catch(l){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",l)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){return this.multiThreadCommentAnnotationById$.pipe(ge(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let i={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(l=>{l?.metadata?.documentId==t&&l?.metadata?.organizationId==e&&(i[l?.annotationId]=l)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(l=>{l?.metadata?.documentId===t&&l?.metadata?.organizationId===e&&!i[l?.annotationId]&&(i[l?.annotationId]=l)}),Object.values(i)}catch(i){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",i),[]}}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(ye(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):de([])))}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument(){try{let e=this.docService.getDocumentPaths();return this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e?.organizationId,documentId:e?.documentId})}catch(e){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument:",e),[]}}getLocations$(){return this.docService.getLocation$().pipe(ye(e=>this.docService.getLocations$().pipe(ge(t=>({location:e,locations:t})))),ge(e=>{let t=[];return t.push(e?.location?.locationId),t.push(...Object.values(e.locations||[]).map(i=>i.locationId)),t||[]}))}filterAnnotationsByLocationIds(e,t,i){try{return e.filter(a=>t.includes(a.locationId)||i?.includes(a?.location?.id)||t?.find(l=>l==a?.location?.id)||i?.find(l=>l==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in CommentService filterAnnotationsByLocations:",a),[]}}setAnnotationIndex(e){try{e.forEach((t,i)=>{t?.annotationId&&(t.annotationIndex=i+1)})}catch(t){this.loggingService.catch("Error in CommentService setAnnotationIndex:",t)}}calculateCommentAnnotationPosition(e,t){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let i=ll(e.targetElementId,["id","data-id"]);if(i&&this.domService.isElementVisible(i)){let a=i.getAttribute(F.ATTRIBUTES.VELT_COMMENT_TYPE),l=!0;if(a)a==="popover"?l=!0:l=!1;else{let c=document.querySelector(`${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${F.TAGS.VELT_INLINE_COMMENTS_SECTION}[${F.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);c&&i?.contains(c)&&(l=!1)}l?e.targetElement={xpath:this.domService.getXPath(i),fXpath:this.domService.getXPath(i,!0),cfXpath:this.domService.getXPath(i,!0,!0),topPercentage:e.targetElement?.topPercentage||50,leftPercentage:e.targetElement?.leftPercentage||90}:e.targetElement=null}else e.targetElement=null}if(e.targetElement){e.position=null,e.ghostComment=null;let i=e.targetElement?.xpath,a=null,l=e?.targetElement?.anchor;if(l){let d=this.domService.resolveAnchorRecord(l);d?.element&&this.domService.isElementVisible(d.element)&&Xr(d.element)&&(a=d.element)}else i&&(a=this.domService.getElementFromXPath(i),this.domService.isXpathWithId(i)||((!a||!this.domService.isElementVisible(a))&&e.targetElement?.cfXpath&&(i=e.targetElement?.cfXpath,a=this.domService.getElementFromXPath(i)),this.getDetectionStrategy()===kF.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(i=e.targetElement?.fXpath,i&&(a=this.domService.getElementFromXPath(i)))));(!a||!this.domService.isElementVisible(a))&&t&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=this.getGhostCommentTargetElement(e),e?.ghostComment?.targetElement?.xpath&&(a=this.domService.getElementFromXPath(e?.ghostComment?.targetElement?.xpath)));let c=!1;if(e?.locationId){let d=this.docService.getLocation();if(!E0({location:d?.location,locationId:d?.locationId},{location:e?.location,locationId:e?.locationId})){let g=this.docService.getAdditionLocationFromElement(a),u=g?this.docService.genarateLocationId(g):void 0;e?.location?.id&&e?.location?.id===g?.id||u&&u===e?.locationId?c=!1:c=!0}}if(c&&(e.ghostComment=null),!c&&a&&Xr(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let g=this.popoverMode$?.value?0:e.targetElement?.topPercentage,u=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:_,width:w}=vp(a);e.position={top:_*(g||0)/100,left:w*(u||0)/100};let A=window.getComputedStyle(a).transform;if(A&&A!=="none")try{let M=new DOMMatrixReadOnly(A),j=Math.sqrt(M.a*M.a+M.b*M.b)||1,q=Math.sqrt(M.c*M.c+M.d*M.d)||1;(Math.abs(j-1)>.01||Math.abs(q-1)>.01)&&(e.position.parentScaleX=j,e.position.parentScaleY=q)}catch{}if(this.transformContext$.value){let{containerSelector:M,transforms:j}=this.transformContext$.value,q=document.querySelector(M);q&&q.contains(a)&&(e.position.transformContext=j)}}!c&&t&&!e?.position&&!e?.ghostComment&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=e.targetElement)}t&&(e.ghostComment?this.addAnnotationToGhostCommentAnnotationMap(e):this.removeAnnotationFromGhostCommentAnnotationMap(e))}catch(i){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",i)}}addComment(ze,He,qe,En,tt){return X(this,arguments,function*(e,t,i,a,l,c=[],d,g,u,_,w,A,M,j,q,ie,_e,ae,ue,Ie,fe,we,Ae,Pe){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let xt=this.authService.getUser();if(xt)if(xt.isReadOnly||xt.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{yield this.triggerAddCommentAnnotationDraftEvent();let Je=new Vr;_e&&(Je=h(h({},Je),_e)),Je.comments=[],_e?.comments?.length&&(Je.comments=_e.comments.map(ln=>{let Sn=new oc;return Sn=h(h({},Sn),ln),Sn.from=xt,Sn.lastUpdated=new Date,Sn.createdAt=this.timestamp,Sn})),Je.from=xt,Je.color=Je?.color||F.DEFAULT_ANNOTATION_COLOR,Je.lastUpdated=this.timestamp,Je.createdAt=this.timestamp,Je.sourceId=q,Je.assignedTo=_e?.assignedTo||ie,Je.customList=_e?.customList||[],we&&(Je.targetElementId=we);let{topPositionX:$t,topPositionY:sn}=this.domService.getTopLeftPosition();Je.positionX=$t,Je.positionY=sn;let Xn=this.domService.getCurrentWindowSizeValue();if(Je.screenWidth=Xn.screenWidth,Je.screenHeight=Xn.screenHeight,Je.screenScrollHeight=Xn.screenScrollHeight,Je.taggedElementPath="",e&&(Je.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,ln=>{if(this.getSvgAsImg()){let Sn=ln?.closest(`[${F.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);Sn&&Sn instanceof HTMLElement&&(ln=Sn)}if(this.getPopoverMode()){let Sn=ln?.closest(`[${F.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(Sn&&Sn instanceof HTMLElement)return Sn}return ln}),this.getCommentToNearestAllowedElement()&&Je.targetElement?.xpath)){let ln=this.domService.getElementFromXPath(Je.targetElement.xpath);if(ln&&!this.isElementInsideAllowedElements(ln)){let Sn=this.getNearestAllowedElement(ln);if(Sn)Je.targetElement.xpath=this.domService.getXPath(Sn),Je.targetElement.fXpath=this.domService.getXPath(Sn,!0),Je.targetElement.cfXpath=this.domService.getXPath(Sn,!0,!0),Je.targetElement.anchor=this.domService.generateAnchorRecord(Sn);else return}}if(t&&(Je.targetTextRange=t),Je?.targetElement?.xpath){let ln=this.domService.getXPath(Je.targetElement.xpath);if(ln){let Sn=ln.iterateNext();Sn&&(Xr(Sn)||(Je.targetElement=null))}}this.customFilterService.defaultStatus&&!_e?.status&&(Je.status=this.customFilterService.defaultStatus),Je.pageInfo=io(),Je.pageInfo&&(Je.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let Ii=this.docService.getClientDocumentId(),No=this.docService.getLocation()?.location;if(ue&&(Je.context=ue&&Ns(ue),Je.contextId=this.generateContextId(Je.context)),this.commentContextProvider!==null){let ln=this.commentContextProvider(Ii,No),Sn=ln instanceof Promise?yield ln:ln;Sn&&(Je.context=Sn&&Ns(Sn),Je.contextId=this.generateContextId(Je.context),Sn?.commentType==="manual"&&(Je.commentType="manual",delete Je.targetElement))}if(a){Je.sourceId=a?.sourceId;let ln=a?.targetElement,Sn=a?.commentData;if(ln?.targetText)Je.targetTextRange={commonAncestorContainer:"/html/body",text:ln.targetText,occurrence:ln?.occurrence||1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(document.body)??void 0};else if(ln?.elementId)if(Je.targetElementId=ln.elementId,ln?.selectAllContent)Je.selectAllContent=!!ln?.selectAllContent;else{let Co=ll(ln.elementId,["id","data-id"]);Co?Je.targetElement={xpath:this.domService.getXPath(Co),fXpath:this.domService.getXPath(Co,!0),cfXpath:this.domService.getXPath(Co,!0,!0),anchor:this.domService.generateAnchorRecord(Co),topPercentage:50,leftPercentage:90}:Je.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",anchor:this.domService.generateAnchorRecord(document.body),topPercentage:50,leftPercentage:90}}a?.status&&(Je.status=a.status),a?.context&&(Je.context=a.context?Ns(a.context):a.context,Je.contextId=this.generateContextId(Je.context)),Je.comments||(Je.comments=[]);let Ir=this.authService.getUser();Sn?.forEach(Co=>{let Zi=new oc;Zi.commentText=Co.commentText,Zi.commentHtml=Co.commentHtml,Zi.replaceContentHtml=Co.replaceContentHtml,Zi.replaceContentText=Co.replaceContentText,Zi.from=Ir,Je.comments.push(Zi)})}if(l&&(Je.isPageAnnotation=!0),c?.length&&(Je.comments=c),d&&(Je.commentType="chart",Je.metadata=d),u?.sourceId&&(Je.sourceId=u.sourceId),Je?.targetElement?.xpath&&!u){let ln=this.domService.getElementFromXPath(Je.targetElement.xpath);ln&&(u=this.getInlineCommentSectionConfig(ln))}u?.targetInlineCommentElementId&&(Je.targetInlineCommentElementId=u?.targetInlineCommentElementId,Je.targetElementId=u.targetInlineCommentElementId,u?.config?.id&&(Je.inlineCommentSectionConfig=u?.config));let eo=!Je?.comments?.length,Bn=!!(a?.openComment===!1||Ie);this.getPrivateCommentMode()&&(Je?.iam||(Je.iam=new gO),Je.iam.accessMode=ya.PRIVATE),_&&(Je.context=_.context?Ns(_.context):_.context,Je.commentType="manual",delete Je.targetElement,Je.contextId=this.generateContextId(Je.context)),w&&(Je.targetElementId=w.targetElementId,Je.targetElement=w.targetElement);let fc=this.getPrivateModeConfig();if(fc)try{let ln=h({},fc);if(ln.type==="restricted"){let Ir=this.authService.getUser();Ir?.userId&&(ln=ap(ln,Ir.userId))}if(ln.type==="organizationPrivate"&&!ln.organizationId){let Ir=this.docService.getOrganizationConfig();Ir?.clientOrganizationId&&(ln.organizationId=Ir.clientOrganizationId)}let Sn=lp(ln);Je.context||(Je.context={}),Je.context._setAccessFields=Sn,Je.visibilityConfig=h(h({type:ln.type},ln.organizationId&&{organizationId:ln.organizationId}),ln.userIds&&{userIds:ln.userIds})}catch(ln){this.loggingService.catch("Error building accessFields from privateModeConfig: ",ln)}this.saveCommentToDb(Je,i,eo,Bn,g,A,M,ae,j,fe,Ae,Pe)}}catch(xt){this.loggingService.catch("Error in CommentService addComment: ",xt)}})}triggerAddCommentAnnotationDraftEvent(){return X(this,null,function*(){try{this.commentAnnotationContextDraft=null;let e={addContext:i=>{this.commentAnnotationContextDraft=i}},t=yield this.commentActionsService?.getAddCommentAnnotationDraftEventFromCommentAddEventData(e);t&&this.commentActionsService?.triggerAddCommentAnnotationDraftEvent(t)}catch(e){this.loggingService.catch("Error in CommentService triggerAddCommentAnnotationDraftEvent: ",e)}})}triggerAddCommentDraftEventOnAbandon(e,t){return X(this,null,function*(){try{if(!e||!t)return;let i=this.getAnnotationById(e),a=!!i?.comments?.some(l=>l&&!l.isDraft);i&&a&&(yield this.commentActionsService?.triggerAddCommentDraftEventForAnnotation(i,t))}catch(i){this.loggingService.catch("Error in CommentService triggerAddCommentDraftEventOnAbandon: ",i)}})}willDeleteWholeAnnotation(e,t){try{if(!e?.comments?.length)return!1;let i=e.comments.findIndex(a=>a?.commentId===t);return i<0?!1:i===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments.length===1}catch(i){return this.loggingService.catch("Error in CommentService willDeleteWholeAnnotation: ",i),!1}}confirmDeleteCommentIfRequired(e,t){return X(this,null,function*(){try{if(!e?.comments?.length||!t)return!0;let i=e.comments.findIndex(d=>d?.commentId===t?.commentId);if(i<0||!(i===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value))return!0;let l;return this.deleteReplyConfirmation$.value&&(i!==0||this.deleteThreadWithFirstComment$.value===!1)?l={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply",type:"reply"}:l={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"},!!(yield this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:l}).afterClosed().toPromise())}catch(i){return this.loggingService.catch("Error in CommentService confirmDeleteCommentIfRequired: ",i),!1}})}setLocationToCommentAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{let i;e.targetElement?i=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?i=ll(e.targetElementId,["id","data-id"]):e.targetTextRange&&(i=this.domService.getElementFromTargetTextRange(e.targetTextRange));let a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}catch{}}catch(t){this.loggingService.catch("Error in CommentService setLocationToCommentAnnotation:",t)}}getElementForCommentAnnotation(e){try{let t;return e.targetElement?t=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?t=ll(e.targetElementId,["id","data-id"]):e.targetTextRange&&(t=this.domService.getElementFromTargetTextRange(e.targetTextRange)),t}catch(t){return this.loggingService.catch("Error in CommentService getElementForCommentAnnotation: ",t),null}}saveCommentToDb(e,t,i=!1,a=!1,l,c,d,g,u,_,w,A){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(je.COMMENT)&&this.docService.getDocumentPaths$().pipe($e(M=>!!M),ut(1),ye(M=>(this.documentPaths=M,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(j=>!!j),ut(1),ye(j=>X(this,null,function*(){if(this.documentPaths?.comment){e.annotationId=this.commonDbService.generateDocumentId();let q=this.docService.getClientDocumentId(),ie=this.docService.getLocation()?.location;if(d)e.multiThreadAnnotationId=d;else if(this.getMultiThread()){let Pe=sm();e.targetElementId&&(Pe=sm(e.targetElementId),e?.location?.id?Pe=sm([e?.location?.id,e.targetElementId]):e?.locationId&&(Pe=sm([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=Pe}let _e={addContext:Pe=>{Pe.access&&(Pe.accessFields=xO(Pe)),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:Pe}),e.context=Pe&&Ns(Pe),e.contextId=this.generateContextId(e.context),Pe?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&setTimeout(()=>{this.updateCommentAnnotationContext(e.annotationId,Pe)},200)},documentId:q,location:ie,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?_e.elementRef={xpath:e.targetElement.xpath}:_e.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(_e),this.commentAdded$.next(_e),u&&u(_e),_e?.annotation?.annotationId&&this.pendingAddCommentAnnotationData.set(_e.annotation.annotationId,_e),this.setLocationToCommentAnnotation(e);let ae=this.getElementForCommentAnnotation(e),ue=this.docService.getBaseMetadata("comment",{element:ae,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!ue?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=h(h({},e.metadata),ue),_&&(e.metadata=h(h({},e.metadata),_)),l&&typeof l=="object"&&(e.locationId=g||this.docService.genarateLocationId(l),e.location=l,A||this.docService.addLocation({location:l})),i)window.localStorage.setItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let Pe=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);Pe&&JSON.parse(Pe).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let Ie=e.comments,fe=JSON.parse(JSON.stringify(e));if(this.commentAnnotationContextDraft){let Pe=this.commentAnnotationContextDraft;this.commentAnnotationContextDraft=null,Pe.access&&(Pe.accessFields=xO(Pe)),fe.context=Pe&&Ns(Pe)}if(!this.handleDirectAccessFieldsAssignment(fe?.context)&&!fe?.context?.access&&(fe?.context||(fe.context={}),fe.context.access={default:"velt"},fe.context.accessFields=[...fe.context.accessFields||[],F.DEFAULT_VELT_CONTEXT]),fe.visibilityConfig||(fe.visibilityConfig={type:"public"}),fe.position=null,t){fe.targetElement=null,fe.targetTextRange=null;let Pe={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?je.MULTI_THREAD:je.COMMENT},ze=yield this.areaService.generateAreaAnnotationId();fe.areaAnnotationId=ze;let He=this.areaService.addArea(void 0,t,Pe,ze,{locationId:fe.locationId,location:fe.location},fe.context);He&&(fe.metadata=h(h({},fe.metadata),He?.metadata||{}))}!a&&!fe?.targetInlineCommentElementId&&!fe?.isPageAnnotation&&this.domService.toggleAnnotationSelection(fe,c),e.targetTextRange&&sessionStorage.setItem(F.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),fe?.comments?.length?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e.annotationId,commentThreadId:fe?.comments[0]?.commentId,commentThreadIndex:0,commentType:this.getCommentType(fe),commentMode:this.getCommentMode(),source:w??"internal",commentAnnotationCreatedAt:e.createdAt,taggedClientUserIds:fe?.comments[0]?.taggedUserContacts?.map(Pe=>Pe.contact?.userId).filter(Pe=>!!Pe),taggedSnippylyUserIds:fe?.comments[0]?.taggedUserContacts?.filter(Pe=>!!fe?.metadata?.apiKey&&!!Pe.contact?.userId).map(Pe=>hd(fe.metadata.apiKey,Pe.contact.userId))}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(fe),commentMode:this.getCommentMode()});let Ae=this.getAnnotationNumber(e);Ae&&(fe.annotationNumber=Ae),fe?.comments?.length?fe.comments=[]:fe.isDraft=!0,fe?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(fe),fe?.context&&(fe.contextId=this.generateContextId(fe.context),fe.context?.commentType==="manual"&&(fe.commentType="manual",delete fe.targetElement)),Ie?.length?this.saveComment(fe,{type:Tt.NEWLY_ADDED,updatedComment:Ie[0]}):this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:fe}))}})))))).subscribe(()=>{},M=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",M)})}catch(M){this.loggingService.catch("Error in CommentService saveCommentToDb: ",M)}}saveMultiThreadCommentAnnotation(e){return X(this,null,function*(){try{if(e?.multiThreadAnnotationId){let t=this.docService.getDocumentPaths();if(this.databaseService.getDbValue()&&t?.multiThread){let i={annotationId:e.multiThreadAnnotationId,targetElement:e.targetElement,targetElementId:e.targetElementId,targetInlineCommentElementId:e.targetInlineCommentElementId,inlineCommentSectionConfig:e.inlineCommentSectionConfig,areaAnnotationId:e.areaAnnotationId,targetTextRange:e.targetTextRange,from:e.from,locationId:e.locationId,location:e.location,sourceId:e.sourceId,type:"multiThread",metadata:e.metadata,context:e.context};delete e?.targetElement,delete e?.areaAnnotationId,delete e?.targetTextRange;let a=this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:t?.documentId})?.find(l=>l.annotationId===e.multiThreadAnnotationId);if(a||(a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:e.multiThreadAnnotationId}})),a&&(a=JSON.parse(JSON.stringify(a)),delete a.from,i=h(h({},a),i)),i?.commentAnnotations||(i.commentAnnotations={}),i.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(y(h({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[i.annotationId]:y(h({},i),{isDraft:!0})}));else{let c=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[i.annotationId];if(c&&(i=h(h({},i),c)),delete i.isDraft,i.commentAnnotationsMap={},!i?.metadata?.documentId){i?.metadata||(i.metadata={});let u=this.docService.getBaseMetadata("multiThread");i.metadata=h(h({},i?.metadata),u)}let{documentId:d,organizationId:g}=i?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:i.annotationId,documentId:d,organizationId:g},data:JSON.parse(JSON.stringify(i)),callback:()=>{let u=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;u[e.annotationId]&&(delete u[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(u))}})}return i}}return null}catch(t){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",t),null}})}setCommentCategory(e){return X(this,null,function*(){try{if(e?.comments?.length){let t=e.comments[0].commentText?.trim();if(t){let i=yield this.getCommentCategory(t).toPromise();if(i){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let l=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(c=>c.annotationId===e.annotationId);if(l||(l=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:e.annotationId}})),l?.annotationId){let c=l;c.commentCategories=[i];let{documentId:d,organizationId:g}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:d,organizationId:g,metadata:{apiKey:this.configService.getApiKey(),organizationId:g,veltFolderId:c?.metadata?.veltFolderId,documentId:d}},data:JSON.parse(JSON.stringify(c))})}}}}}}catch(t){this.loggingService.catch("Error in CommentService setCommentCategory: ",t)}})}getCommentCategory(e){try{let t=qr(this.functions,Kr({url:Dn.cloudFunction.chatgptCompletion,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a=[{role:"system",content:`Identify category of this sentence from these categories, ${Object.keys(this.customCategoryMap)?.join(", ")}:`},{role:"user",content:e}];return so(t({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:al(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(ge(l=>{if(l?.data){let c=l.data,d=c?.length?c[0]?.content?.trim():void 0;return d&&Object.keys(this.customCategoryMap).includes(d)?this.customCategoryMap[d]:void 0}else return}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentCategory: ",t),de(void 0)}}handleDirectAccessFieldsAssignment(e){try{if(!e||typeof e!="object")return!1;if("_setAccessFields"in e||"_replaceAccessFields"in e){let t=e._setAccessFields??e._replaceAccessFields;return delete e.access,delete e.accessFields,Array.isArray(t)&&t.length>0?e.accessFields=t:t==null&&delete e.accessFields,delete e._setAccessFields,delete e._replaceAccessFields,!0}return!1}catch(t){return this.loggingService.catch("Error in CommentService handleDirectAccessFieldsAssignment: ",t),!1}}updateCommentAnnotationContext(e,t,i){return X(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:t,merge:i?.merge});let a=this.authService.getUser(),l=this.docService.getDocumentPaths();if(a&&l?.comment&&e){let c=this.getAnnotationById(e);if(typeof c=="object"&&(c=JSON.parse(JSON.stringify(c))),c||(c=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:e}})),c?.annotationId){let d=t,g=JSON.parse(JSON.stringify(c.context||{}));i?.merge&&(d=h(h({},g),t));let u=this.handleDirectAccessFieldsAssignment(d);if(d&&"_setVisibilityConfig"in d&&(c.visibilityConfig=d._setVisibilityConfig,delete d._setVisibilityConfig),d&&typeof d=="object"&&!u)if("access"in t)t.access!==null&&t.access!==void 0?d.accessFields=xO(d):(delete d.access,delete d.accessFields);else{if(!i?.merge)for(let A of IYe)!(A in t)&&g?.[A]!==void 0&&(d[A]=g[A]);d.access!==null&&d.access!==void 0&&(d.accessFields=xO(d))}let _={context:JSON.parse(JSON.stringify(d||{}))},w=!1;if(_?.context?.commentType==="manual"&&(_.commentType="manual",_.targetElement=null,c?.targetElement&&(c.targetElement=null,w=!0)),c.context=_.context?Ns(_.context):_.context,c.contextId=this.generateContextId(c.context),dr(g,d)&&!w)return Promise.resolve("Comment annotation context is already updated.");if(c?.comments?.length){c.lastUpdated=this.timestamp;let{documentId:A,organizationId:M}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);return this.commonDbService.setData({feature:"comment",properties:{id:e,documentId:A,organizationId:M,metadata:{apiKey:this.configService.getApiKey(),organizationId:M,veltFolderId:c?.metadata?.veltFolderId,documentId:A}},data:JSON.parse(JSON.stringify(c)),callback:()=>{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:_?.context,merge:i?.merge})}})}else return this.draftCommentAnnotationsByAnnotationId$.value?.[e]?(this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e]:c})),Promise.resolve("Draft comment annotation context updated.")):(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:t,merge:i?.merge,error:"Draft comment annotation not found."}),Promise.resolve("Draft comment annotation not found."))}else return this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:t,merge:i?.merge,error:"Comment annotation not found in database."}),Promise.resolve("Comment annotation not found in database.")}}catch(a){return this.loggingService.catch("Error in CommentService updateCommentAnnotationContext: ",a),Promise.resolve("Error in CommentService updateCommentAnnotationContext.")}})}updateComment(e,t,i,a,l,c){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(je.COMMENT)){if(t&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let d=this.domService.getXPath(e.targetElement.xpath);if(d){let g=d.iterateNext();g&&(Xr(g)||(e.targetElement=null))}}if(e?.type==="multiThread"){let d=JSON.parse(JSON.stringify(e));if(d.position=null,d.ghostComment=null,d?.context&&this.handleDirectAccessFieldsAssignment(d.context),!d?.metadata?.documentId){d?.metadata||(d.metadata={});let _=this.docService.getBaseMetadata("multiThread");d.metadata=h(h({},d?.metadata),_)}let{documentId:g,organizationId:u}=d?.metadata||{};i?this.commonDbService.updateData({feature:"multiThread",properties:{id:d.annotationId,documentId:g,organizationId:u},data:JSON.parse(JSON.stringify(d))}):this.commonDbService.setData({feature:"multiThread",properties:{id:d.annotationId,documentId:g,organizationId:u},data:JSON.parse(JSON.stringify(d))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let d=JSON.parse(JSON.stringify(e));if(d.position=null,d.ghostComment=null,d.lastUpdated=this.timestamp,d.status||(d.status=this.customFilterService.defaultStatus),delete d.resolved,delete d.inProgress,this.setLocationFromDocumentParams(d),d?.context&&this.handleDirectAccessFieldsAssignment(d.context),d?.annotationId?.startsWith("TEMP_COMPOSER_"))return;let g=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(g&&JSON.parse(g).annotationId===d.annotationId&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),d?.multiThreadAnnotationId&&!l&&this.saveMultiThreadCommentAnnotation(d).then(u=>{}),d?.comments?.length){if(delete d?.isDraft,d?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[d?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(d),!d?.metadata?.documentId){d?.metadata||(d.metadata={});let A=this.docService.getBaseMetadata("comment");d.metadata=h(h({},d?.metadata),A)}let{documentId:u,organizationId:_}=d?.metadata||{},w=a?h({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;this.viewsService.updateCommentAnnotationViews(d),this.commonDbService.setData({feature:"comment",properties:{id:d.annotationId,documentId:u,targetCommentId:c?.commentId,organizationId:_,metadata:{apiKey:this.configService.getApiKey(),organizationId:_,veltFolderId:d?.metadata?.veltFolderId,documentId:u}},extraData:w,data:JSON.parse(JSON.stringify(d)),callback:A=>X(this,null,function*(){if(a&&!A?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{}),this.getScreenshotEnabled()&&a?.actionType===Tt.NEWLY_ADDED&&this.captureScreenshot(e),a?.actionType===Tt.NEWLY_ADDED||a?.actionType===Tt.ADDED)try{let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:d.annotationId,commentAnnotation:this.getCommentAnnotationForClient(d),metadata:M};this.commentActionsService?.triggerAction(er.COMMENT_SAVED,j)}catch(M){this.loggingService.catch("Error triggering commentSaved event: ",M)}})})}else this.draftCommentAnnotationsByAnnotationId$.next(y(h({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:d}))}}}catch(d){this.loggingService.catch("Error in CommentService updateComment: ",d)}}captureScreenshot(e){return X(this,null,function*(){try{if(this.getScreenshotEnabled()){let i=qr(this.functions,Kr({url:Dn.cloudFunction.screenshot,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a,l={source:"velt",sourceData:{commentAnnotation:e},eventType:"screenshot"};e?.areaAnnotationId&&(a=this.areaService.getAnnotationById(e?.areaAnnotationId),a&&(l.sourceData||(l.sourceData={}),l.sourceData.areaAnnotation=a));let c=yield Fs(l,this.authService.getUser()?.userId??"");yield i({veltData:c})}}catch(t){this.loggingService.catch("Error in CommentService captureScreenshot: ",t)}})}getDocumentIdAndOrganizationIdFromCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromCommentAnnotation: ",t),{}}}getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation: ",t),{}}}setLocationFromDocumentParams(e){e?.documentParams&&(e.location=e.documentParams,delete e.documentParams),e?.documentParamsId&&(e.locationId=e.documentParamsId,delete e.documentParamsId)}deleteCommentPinAnnotations(e){return new Promise((t,i)=>X(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),l=this.authService.getUser(),c=[];Object.keys(a).forEach(d=>{let g=a[d];["tag","recorder","rewriter","arrow","area","multiThread"].includes(g.type)||l&&g.from&&(l?.isAdmin||g.from.userId===l.userId)&&c.push(g)}),c?.length?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:c.map(d=>d.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:{title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"}}).afterClosed().pipe(ut(1)).subscribe(d=>{try{d?(c.forEach(g=>X(this,null,function*(){yield this.deleteCommentPinAnnotation(g)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(u=>{this.domService.removeHighlightFromElement(u)}),t()},100)):t()}catch(g){i(g)}},d=>{i(d)})):t(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),i(a)}}))}deleteCommentPinAnnotation(e,t){return X(this,null,function*(){try{if(setTimeout(()=>{if(this.draftCommentAnnotationsByAnnotationId$?.value?.[e.annotationId]){let i=this.draftCommentAnnotationsByAnnotationId$.value;delete i[e.annotationId],this.draftCommentAnnotationsByAnnotationId$.next(i)}},50),e?.annotationId&&this.pendingAddCommentAnnotationData.delete(e.annotationId),this.authService.isFeatureAllowed(je.COMMENT))if((t||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Tt.DELETED),e.comments?.forEach(i=>{i.reactionAnnotationIds&&i.reactionAnnotationIds.forEach(a=>{this.deleteReaction(a)})}),e?.annotationId){this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode()});let i=window.localStorage.getItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);i&&JSON.parse(i).annotationId===e.annotationId&&window.localStorage.removeItem(F.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),this.areaService.onDeleteTargetAnnotation(e?.annotationId,e?.areaAnnotationId);let a={type:"delete",annotation:null,targetAnnotationId:e.annotationId};this.commentUpdated$.next(a),e?.multiThreadAnnotationId&&(yield this.removeCommentAnnotationFromMultiThread(e)),this.commentAnnotationDeleted$.next(e);let{documentId:l,organizationId:c}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);if(e?.isDraft)return Promise.resolve();{let d={annotationData:e,targetAnnotationData:null,actionType:Tt.DELETED,notificationSource:"comment",isAnnotationDelete:!0};return this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:l,organizationId:c,metadata:{apiKey:this.configService.getApiKey(),organizationId:c,veltFolderId:e?.metadata?.veltFolderId,documentId:l}},extraData:d})}}else return Promise.resolve();return Promise.resolve()}catch(i){return this.loggingService.catch("Error in CommentService deleteCommentPinAnnotation: ",i),Promise.resolve()}})}removeCommentAnnotationFromMultiThread(e){return X(this,null,function*(){try{let t=e?.multiThreadAnnotationId;if(t){let i=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(t);if(!a){let g=e?.metadata?.documentId||i?.documentId,u=e?.metadata?.organizationId||i?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:g,organizationId:u,id:t}})}let l=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t];a&&delete a?.commentAnnotations?.[e.annotationId],l&&(delete l?.commentAnnotations?.[e.annotationId],Object.keys(l?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:c,organizationId:d}=this.getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(a);return Object.keys(a?.commentAnnotations||{}).length===0?(this.areaService.onDeleteTargetAnnotation(a?.annotationId,a?.areaAnnotationId),this.multiThreadCommentAnnotationDeleted$.next(a),this.commonDbService.deleteData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:d}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:d},data:JSON.parse(JSON.stringify(a))})}}catch(t){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",t)}})}getAnnotationById(e,t){try{let i=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in CommentService getAnnotationById: ",i);return}}getBaseMetadataFromCommentAnnotationId(e){try{let t=this.commentAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in CommentService getBaseMetadataFromCommentAnnotationId: ",t)}}getMultiThreadAnnotationById(e,t){try{let i=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(i){let{documentId:a,organizationId:l}=t||{};if(a&&i.metadata?.documentId!==a||l&&i.metadata?.organizationId!==l)return}return i}catch(i){this.loggingService.catch("Error in CommentService getAnnotationById: ",i);return}}getBaseMetadataFromMultiThreadCommentAnnotationId(e){try{let t=this.multiThreadCommentAnnotationById$.value?.[e];if(t)return t.metadata}catch(t){this.loggingService.catch("Error in CommentService getBaseMetadataFromMultiThreadCommentAnnotationId: ",t)}}getElementRefByAnnotationId(e){try{let t=this.getAnnotationById(e);if(t){let i=t?.targetElement?.xpath;if(i)return{xpath:i}}return}catch(t){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",t);return}}scrollToCommentByAnnotationId(e){try{let t=this.getAnnotationById(e),i=document.getElementById(`comment-pin-container-${e}`);i||(i=document.querySelector(`[data-velt-id='${e}']`)),i||(i=document.querySelector(`${F.TAGS.VELT_COMMENT_TEXT}[${F.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),i&&(i.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),t&&(this.domService.getSelectedAnnotationsMap()[e]||this.domService.toggleAnnotationSelection(t)))}catch(t){this.loggingService.catch("Error in CommentService scrollToCommentByAnnotationId: ",t)}}selectCommentByAnnotationId(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");let i=e?this.getAnnotationById(e):void 0;i?this.domService.toggleAnnotationSelection(i,void 0,void 0,!0):this.domService.resetSelectedAnnotationsMap()}catch(i){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",i)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(je.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([Xo.ADMIN,Xo.COMMENTER])?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_MODE_ENABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!0)):this.loggingService.catch("Error in CommentService enableAddCommentMode: ","User is not allowed to add comment."):this.loggingService.catch("Error in CommentService enableAddCommentMode: ","Comment feature is not enabled.")}catch(e){this.loggingService.catch("Error in CommentService enableAddCommentMode: ",e)}}disableAddCommentMode(){this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!1)}addCommentModeChange(){return this.addCommentMode$.asObservable()}setFreeStyleCommentContext(e){try{this.freeStyleCommentContext=e}catch(t){this.loggingService.catch("Error in CommentService setFreeStyleCommentContext: ",t)}}clearFreeStyleCommentContext(){try{this.freeStyleCommentContext=void 0}catch(e){this.loggingService.catch("Error in CommentService resetFreeStyleCommentContext: ",e)}}enablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteReplyConfirmation:!0}}),this.deleteReplyConfirmation$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteReplyConfirmation: ",e)}}enableSeenByUsers(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{seenByUsers:!0}}),this.seenByUsers$.value===!0)return;this.seenByUsers$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSeenByUsers: ",e)}}disableSeenByUsers(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{seenByUsers:!1}}),this.seenByUsers$.value===!1)return;this.seenByUsers$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSeenByUsers: ",e)}}getSeenByUsers$(){return this.seenByUsers$.asObservable()}disableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{persistentCommentMode:!1}}),this.persistentCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePersistentCommentMode: ",e)}}persistentCommentModeChange(){return this.persistentCommentMode$.asObservable()}enablePersistentModeBanner(){this.persistentModeBanner$.next(!0)}disablePersistentModeBanner(){this.persistentModeBanner$.next(!1)}persistentModeBannerChange(){return this.persistentModeBanner$.asObservable()}setAssignToType(e){try{this.assignToType$.next(e.type)}catch(t){this.loggingService.catch("Error in CommentService setAssignToType: ",t)}}getAssignToType$(){return this.assignToType$.asObservable()}getAssignToType(){return this.assignToType$.value}setPageModeComposerContext(e){try{this.pageModeComposerContext$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setPageModeComposerContext: ",t)}}clearPageModeComposerContext(){try{this.pageModeComposerContext$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearPageModeComposerContext: ",e)}}getPageModeComposerContext$(){return this.pageModeComposerContext$.asObservable()}getPageModeComposerContext(){return this.pageModeComposerContext$.value}enableContextInPageModeComposer(){try{this.contextInPageModeComposer$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableContextInPageModeComposer: ",e)}}disableContextInPageModeComposer(){try{this.contextInPageModeComposer$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableContextInPageModeComposer: ",e)}}getContextInPageModeComposer$(){return this.contextInPageModeComposer$.asObservable()}getContextInPageModeComposer(){return this.contextInPageModeComposer$.value}focusPageModeComposer(){try{this.focusPageModeComposer$.next()}catch(e){this.loggingService.catch("Error in CommentService focusPageModeComposer: ",e)}}getFocusPageModeComposer$(){return this.focusPageModeComposer$.asObservable()}showCommentIndex(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentIndex:e}}),this.showCommentIndex$.value===e)return;this.showCommentIndex$.next(e)}catch(t){this.loggingService.catch("Error in CommentService showCommentIndex: ",t)}}getShowCommentIndex(){return this.showCommentIndex$.asObservable()}enablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverMode:!0}}),this.popoverMode$.value===!0)return;this.popoverMode$.next(!0),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_POPOVER_MODE_ENABLED,{commentMode:this.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentService enablePopoverMode: ",e)}}disablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverMode:!1}}),this.popoverMode$.value===!1)return;this.popoverMode$.next(!1),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_POPOVER_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentService disablePopoverMode: ",e)}}getPopoverMode(){try{return this.popoverMode$.value}catch(e){return this.loggingService.catch("Error in CommentService getPopoverMode: ",e),!1}}getPopoverMode$(){return this.popoverMode$.asObservable()}enablePopoverTriangleComponent(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverTriangleComponent:!0}}),this.popoverTriangleComponent$.value===!0)return;this.popoverTriangleComponent$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePopoverTriangleComponent: ",e)}}disablePopoverTriangleComponent(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{popoverTriangleComponent:!1}}),this.popoverTriangleComponent$.value===!1)return;this.popoverTriangleComponent$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePopoverTriangleComponent: ",e)}}getPopoverTriangleComponent(){try{return this.popoverTriangleComponent$.value}catch(e){return this.loggingService.catch("Error in CommentService getPopoverTriangleComponent: ",e),!1}}getPopoverTriangleComponent$(){return this.popoverTriangleComponent$.asObservable()}enableDraftMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{draftMode:!0}}),this.draftMode$.value===!0)return;this.draftMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDraftMode: ",e)}}disableDraftMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{draftMode:!1}}),this.draftMode$.value===!1)return;this.draftMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDraftMode: ",e)}}getDraftMode$(){return this.draftMode$.asObservable()}getDraftMode(){return this.draftMode$.value}enableTextComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textMode:!0}}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_TEXT_MODE_ENABLED,{commentMode:this.getCommentMode()}),this.textCommentMode$.value===!0)return;this.textCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextComments: ",e)}}disableTextComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textMode:!1}}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_TEXT_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.textCommentMode$.value===!1)return;this.textCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextComments: ",e)}}getTextCommentMode$(){return this.textCommentMode$.asObservable()}isUserGlobalContact$(){return this.contactService.isUserGlobalContact$()}isSidebarOpenedByCustomTrigger(){try{return this.sidebarOpenedByCustomTrigger$.value}catch(e){return this.loggingService.catch("Error in CommentService isSidebarOpenedByCustomTrigger: ",e),!1}}setSidebarVisibility(e,t=!1,i=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR_V2)||document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(F.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> or <${F.TAGS.VELT_COMMENTS_SIDEBAR_V2}> tag is not added.`),t&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||t||i)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1),this.clearPageModeComposerContext()),e?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_OPENED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_CLOSED,{commentMode:this.getCommentMode()})}catch{this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}toggleSidebarVisibility(e=!1,t=!1){try{this.domService.resetSelectedAnnotationsMap(),this.sidebarVisible$.value?(!this.sidebarOpenedByCustomTrigger$.value||e||t)&&(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarOpenedByCustomTrigger$.next(!1),this.sidebarVisible$.value||this.clearPageModeComposerContext()):(document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR_V2)||document.querySelector(F.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(F.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarVisible$.value?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"closed"}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"opened"})):this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> or <${F.TAGS.VELT_COMMENTS_SIDEBAR_V2}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${F.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{floatingCommentDialog:!e}}),this.floatingCommentsEnabled$.value===!e)return;this.floatingCommentsEnabled$.next(!e)}catch(t){this.loggingService.catch("Error in CommentService disableFloatingComments: ",t)}}showFloatingComments$(){return this.floatingCommentsEnabled$.asObservable()}showFloatingComments(){return this.floatingCommentsEnabled$.value}setModeratorMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{moderatorMode:e}}),this.moderatorMode$.value===e)return;this.moderatorMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setModeratorMode: ",t)}}getModeratorMode(){return this.moderatorMode$.value}getModeratorMode$(){return this.moderatorMode$.asObservable()}setStreamMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{streamMode:e}}),this.streamMode$.value===e)return;this.streamMode$.next(e),e?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STREAM_MODE_ENABLED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STREAM_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(t){this.loggingService.catch("Error in CommentService setStreamMode: ",t)}}getStreamMode(){return this.streamMode$.value}getStreamMode$(){return this.streamMode$.asObservable()}getEnableDialogOnHover(){return this.enableDialogOnHover$.value}getEnableDialogOnHover$(){return this.enableDialogOnHover$.asObservable()}setEnableDialogOnHover(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogOnHover:e}}),this.enableDialogOnHover$.value===e)return;this.enableDialogOnHover$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableDialogOnHover: ",t)}}getEnableDialogOnTargetElementClick(){return this.enableDialogOnTargetElementClick$.value}getEnableDialogOnTargetElementClick$(){return this.enableDialogOnTargetElementClick$.asObservable()}setEnableDialogOnTargetElementClick(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogOnTargetElementClick:e}}),this.enableDialogOnTargetElementClick$.value===e)return;this.enableDialogOnTargetElementClick$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableDialogOnTargetElementClick: ",t)}}getEnablePriority(){return this.enablePriority$.value}getEnablePriority$(){return this.enablePriority$.asObservable()}setEnablePriority(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{priority:e}}),this.enablePriority$.value===e)return;this.enablePriority$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnablePriority: ",t)}}getEnableStatus(){return this.enableStatus$.value}getEnableStatus$(){return this.enableStatus$.asObservable()}setEnableStatus(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableStatus: ",t)}}getEnableVisibilityOptions(){return this.visibilityOptions$.value}getEnableVisibilityOptions$(){return this.visibilityOptions$.asObservable()}setEnableVisibilityOptions(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{visibilityOptions:e}}),this.visibilityOptions$.value===e)return;this.visibilityOptions$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableVisibilityOptions: ",t)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveButton:e}}),this.getEnableResolve()===e)return;this.enableResolve$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableResolve: ",t)}}getEnableGhostComments(){return this.enableGhostComments$.value}getEnableGhostComments$(){return this.enableGhostComments$.asObservable()}enableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostComments:!1}}),this.enableGhostComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableGhostComments: ",e)}}getEnableGhostCommentsMessage(){return this.enableGhostCommentsMessage$.value}getEnableGhostCommentsMessage$(){return this.enableGhostCommentsMessage$.asObservable()}enableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{ghostCommentsIndicator:!1}}),this.enableGhostCommentsMessage$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowGhostCommentsMessage: ",e)}}enableInboxMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inboxMode:!0}}),this.inboxMode$.value===!0)return;this.inboxMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableInboxMode: ",e)}}disableInboxMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inboxMode:!1}}),this.inboxMode$.value===!1)return;this.inboxMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableInboxMode: ",e)}}getInboxMode(){return this.inboxMode$.value}getInboxMode$(){return this.inboxMode$.asObservable()}setEnableAutoCategorize(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{autoCategorize:e}}),this.enableAutoCategorize$.value===e)return;this.enableAutoCategorize$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableAutoCategorize: ",t)}}getEnableAutoCategorize(){return this.enableAutoCategorize$.value}getEnableAutoCategorize$(){return this.enableAutoCategorize$.asObservable()}setCommentContainerDarkMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{darkMode:e}}),this.commentContainerDarkMode$.value===e)return;this.commentContainerDarkMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentContainerDarkMode: ",t)}}getCommentContainerDarkMode(){return this.commentContainerDarkMode$.asObservable()}getSuggestionMode(){return this.suggestionMode$.value}getSuggestionMode$(){return this.suggestionMode$.asObservable()}setSuggestionMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{suggestionMode:e}}),this.getSuggestionMode()===e)return;this.suggestionMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setSuggestionMode: ",t)}}getMobileMode(){return this.mobileMode$.value}getMobileMode$(){return this.mobileMode$.asObservable()}setMobileMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{mobileMode:e}}),this.getMobileMode()===e)return;this.mobileMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setMobileMode: ",t)}}enableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inlineCommentMode:!0}}),this.inlineCommentMode$.value===!0)return;this.inlineCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableInlineCommentMode: ",e)}}disableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{inlineCommentMode:!1}}),this.inlineCommentMode$.value===!1)return;this.inlineCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableInlineCommentMode: ",e)}}getInlineCommentMode(){return this.inlineCommentMode$.value}getInlineCommentMode$(){return this.inlineCommentMode$.asObservable()}enableMinimap(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{minimap:!0}}),this.minimap$.value===!0)return;this.minimap$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMinimap: ",e)}}disableMinimap(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{minimap:!1}}),this.minimap$.value===!1)return;this.minimap$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableMinimap: ",e)}}getMinimap(){return this.minimap$.value}getMinimap$(){return this.minimap$.asObservable()}showCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentsOnDom:!0}}),this.commentsOnDom$.value===!0)return;this.commentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService showCommentsOnDom: ",e)}}hideCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentsOnDom:!1}}),this.commentsOnDom$.value===!1)return;this.commentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService hideCommentsOnDom: ",e)}}getCommentsOnDom(){return this.commentsOnDom$.value}getCommentsOnDom$(){return this.commentsOnDom$.asObservable()}enableCommentTool(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentTool:!0}}),this.commentToolEnabled$.value===!0)return;this.commentToolEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCommentTool: ",e)}}disableCommentTool(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentTool:!1}}),this.commentToolEnabled$.value===!1)return;this.commentToolEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCommentTool: ",e)}}getCommentTool(){return this.commentToolEnabled$.value}getCommentTool$(){return this.commentToolEnabled$.asObservable()}setTotalMediaLength(e){try{if(this.totalMediaLength$.value===e)return;this.totalMediaLength$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setTotalMediaLength: ",t)}}getTotalMediaLength(){return this.totalMediaLength$.value}getTotalMediaLength$(){return this.totalMediaLength$.asObservable()}enableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarUrlNavigation:!0}}),this.sidebarUrlNavigationEnabled$.value===!0)return;this.sidebarUrlNavigationEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarUrlNavigation: ",e)}}disableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarUrlNavigation:!1}}),this.sidebarUrlNavigationEnabled$.value===!1)return;this.sidebarUrlNavigationEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarUrlNavigation: ",e)}}getSidebarUrlNavigation(){return this.sidebarUrlNavigationEnabled$.value}getSidebarUrlNavigation$(){return this.sidebarUrlNavigationEnabled$.asObservable()}setDetectionStrategy(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{detectionStrategy:e}}),this.detectionStrategy$.value===e)return;this.detectionStrategy$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setDetectionStrategy: ",t)}}getDetectionStrategy(){return this.detectionStrategy$.value}getDetectionStrategy$(){return this.detectionStrategy$.asObservable()}enableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonOnCommentDialog:!0}}),this.sidebarButtonOnCommentDialogVisible$.value===!0)return;this.sidebarButtonOnCommentDialogVisible$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarButtonOnCommentDialog: ",e)}}disableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonOnCommentDialog:!1}}),this.sidebarButtonOnCommentDialogVisible$.value===!1)return;this.sidebarButtonOnCommentDialogVisible$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarButtonOnCommentDialog: ",e)}}getSidebarButtonOnCommentDialogVisibility(){return this.sidebarButtonOnCommentDialogVisible$.value}getSidebarButtonOnCommentDialogVisibility$(){return this.sidebarButtonOnCommentDialogVisible$.asObservable()}onSidebarButtonOnCommentDialogClick(){this.sidebarButtonOnCommentDialogClick$.next()}getSidebarButtonOnCommentDialogClick$(){return this.sidebarButtonOnCommentDialogClick$.asObservable()}enableDeviceIndicatorOnCommentPins(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceIndicatorOnCommentPins:!0}}),this.deviceIndicatorOnCommentPins$.value===!0)return;this.deviceIndicatorOnCommentPins$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeviceIndicatorOnCommentPins: ",e)}}disableDeviceIndicatorOnCommentPins(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceIndicatorOnCommentPins:!1}}),this.deviceIndicatorOnCommentPins$.value===!1)return;this.deviceIndicatorOnCommentPins$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeviceIndicatorOnCommentPins: ",e)}}getDeviceIndicatorOnCommentPins(){return this.deviceIndicatorOnCommentPins$.value}getDeviceIndicatorOnCommentPins$(){return this.deviceIndicatorOnCommentPins$.asObservable()}onSidebarCommentClick(e){this.sidebarCommentClick$.next(e)}getSidebarCommentClick$(){return this.sidebarCommentClick$.asObservable()}onCommentNavigationButtonClick(e){this.commentNavigationButtonClick$.next(e)}getCommentNavigationButtonClick$(){return this.commentNavigationButtonClick$.asObservable()}addBubbleCommentAnnotationIds(e){try{let i=[...this.bubbleCommentAnnotationIds$.value||[],...e],a=[...new Set(i)];this.bubbleCommentAnnotationIds$.next(a)}catch(t){this.loggingService.catch("Error in CommentService addBubbleCommentAnnotationIds: ",t)}}getBubbleCommentAnnotationIds(){return this.bubbleCommentAnnotationIds$.value}getBubbleCommentAnnotationIds$(){return this.bubbleCommentAnnotationIds$.asObservable()}removeBubbleCommentAnnotationIds(e){try{let i=(this.bubbleCommentAnnotationIds$.value||[]).filter(a=>!e.includes(a));this.bubbleCommentAnnotationIds$.next(i)}catch(t){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",t)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{signInButton:e}}),this.enableSignInButton$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableSignInButton: ",t)}}getSignInButton(){return this.enableSignInButton$.value}getSignInButton$(){return this.enableSignInButton$.asObservable()}onSignInClick(){this.onSignInClick$.next()}getSignInButtonClick$(){return this.onSignInClick$.asObservable()}enableUpgradeButton(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{upgradeButton:e}}),this.enableUpgradeButton$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableUpgradeButton: ",t)}}getUpgradeButton(){return this.enableUpgradeButton$.value}getUpgradeButton$(){return this.enableUpgradeButton$.asObservable()}onUpgradeClick(){this.onUpgradeClick$.next()}getUpgradeButtonClick$(){return this.onUpgradeClick$.asObservable()}openSidebar(){this.openSidebar$.next()}getOpenSidebar$(){return this.openSidebar$.asObservable()}enableAttachment(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachments:e}}),this.enableAttachment$.value===e)return;this.enableAttachment$.next(e)}catch(t){this.loggingService.catch("Error in CommentService enableAttachment: ",t)}}getEnableAttachment$(){return this.enableAttachment$.asObservable()}enableAttachmentDownload(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentDownload:!0}}),this.enableAttachmentDownload$.value===!0)return;this.enableAttachmentDownload$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAttachmentDownload: ",e)}}disableAttachmentDownload(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentDownload:!1}}),this.enableAttachmentDownload$.value===!1)return;this.enableAttachmentDownload$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAttachmentDownload: ",e)}}getEnableAttachmentDownload$(){return this.enableAttachmentDownload$.asObservable()}getEnableAttachmentDownload(){return this.enableAttachmentDownload$.value}enableFormatOptions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatOptions:!0}}),this.enableFormatOptions$.value===!0)return;this.enableFormatOptions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFormatOptions: ",e)}}disableFormatOptions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatOptions:!1}}),this.enableFormatOptions$.value===!1)return;this.enableFormatOptions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFormatOptions: ",e)}}getEnableFormatOptions$(){return this.enableFormatOptions$.asObservable()}setFormatConfig(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{formatConfig:e}}),this.formatConfig$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setFormatConfig: ",t)}}getFormatConfig$(){return this.formatConfig$.asObservable()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordings:e}}),e?.includes("all")?this.allowedRecordings$.next(["audio","video","screen"]):e?.includes("none")?this.allowedRecordings$.next([]):this.allowedRecordings$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setAllowedRecordings: ",t)}}getAllowedRecordings(){return this.allowedRecordings$.value}getAllowedRecordings$(){return this.allowedRecordings$.asObservable()}enableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{reactions:!0}}),this.enableReactions$.value===!0)return;this.enableReactions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReactions: ",e)}}disableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{reactions:!1}}),this.enableReactions$.value===!1)return;this.enableReactions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReactions: ",e)}}getEnableReactions(){return this.enableReactions$.value}getEnableReactions$(){return this.enableReactions$.asObservable()}enableAnonymousEmail(){try{if(this.enableAnonymousEmail$.value===!0)return;this.enableAnonymousEmail$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAnonymousEmail: ",e)}}disableAnonymousEmail(){try{if(this.enableAnonymousEmail$.value===!1)return;this.enableAnonymousEmail$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAnonymousEmail: ",e)}}getEnableAnonymousEmail(){return this.enableAnonymousEmail$.value}getEnableAnonymousEmail$(){return this.enableAnonymousEmail$.asObservable()}addCommentOnElement(e){this.addComment(void 0,void 0,void 0,e)}enablePrivateCommentMode(){return X(this,null,function*(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.isPrivateCommentAllowed$().pipe(ut(1)).subscribe(e=>{e?(this.privateCommentMode$.next(!0),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIVATE_COMMENT_MODE_ENABLED)):this.loggingService.logsEnabled&&console.warn("You are not allowed to enable private comment mode.")})}catch(e){this.loggingService.catch("Error in CommentService enablePrivateCommentMode: ",e)}})}disablePrivateCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateCommentMode:!1}}),this.privateCommentMode$.value===!1)return;this.privateCommentMode$.next(!1),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIVATE_COMMENT_MODE_DISABLED)}catch(e){this.loggingService.catch("Error in CommentService disablePrivateCommentMode: ",e)}}getPrivateCommentMode(){return this.privateCommentMode$.value}getPrivateCommentMode$(){return this.privateCommentMode$.asObservable()}isPrivateCommentAllowed(){return this.privateCommentAllowed$.value}isPrivateCommentAllowed$(){return this.privateCommentAllowed$.asObservable()}enablePrivateMode(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateModeConfig:e}}),!e?.type){this.loggingService.catch("enablePrivateMode: type is required in config");return}let t=h({},e);if(t.type==="restricted"){let i=this.authService.getUser();if(!i?.userId){this.loggingService.catch("enablePrivateMode: Current user not found. Cannot set restricted visibility without userIds.");return}t=ap(t,i.userId)}this.privateModeConfig$.next(t)}catch(t){this.loggingService.catch("Error in CommentService enablePrivateMode: ",t)}}disablePrivateMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{privateModeConfig:null}}),this.privateModeConfig$.value===null)return;this.privateModeConfig$.next(null)}catch(e){this.loggingService.catch("Error in CommentService disablePrivateMode: ",e)}}getPrivateModeConfig(){return this.privateModeConfig$.value}getPrivateModeConfig$(){return this.privateModeConfig$.asObservable()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{scrollToComment:!0}}),this.scrollToComment$.value===!0)return;this.scrollToComment$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableScrollToComment: ",e)}}disableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{scrollToComment:!1}}),this.scrollToComment$.value===!1)return;this.scrollToComment$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableScrollToComment: ",e)}}getScrollToComment(){return this.scrollToComment$.value}getScrollToComment$(){return this.scrollToComment$.asObservable()}showScreenSizeInfo(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deviceInfo:e}}),this.showScreenSizeInfo$.value===e)return;this.showScreenSizeInfo$.next(e)}catch(t){this.loggingService.catch("Error in CommentService showScreenSizeInfo: ",t)}}getShowScreenSizeInfo$(){return this.showScreenSizeInfo$.asObservable()}enableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{userMentions:!0}}),this.userMentions$.value===!0)return;this.userMentions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableUserMentions: ",e)}}disableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{userMentions:!1}}),this.userMentions$.value===!1)return;this.userMentions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableUserMentions: ",e)}}getUserMentions(){return this.userMentions$.value}getUserMentions$(){return this.userMentions$.asObservable()}enablePaginatedContactList(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;"),this.paginatedContactList$.value===!0)return;this.paginatedContactList$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePaginatedContactList: ",e)}}disablePaginatedContactList(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;"),this.paginatedContactList$.value===!1)return;this.paginatedContactList$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePaginatedContactList: ",e)}}getPaginatedContactList(){return this.paginatedContactList$.value}getPaginatedContactList$(){return this.paginatedContactList$.asObservable()}enableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteOnBackspace:!0}}),this.deleteOnBackspace$.value===!0)return;this.deleteOnBackspace$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteOnBackspace: ",e)}}disableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteOnBackspace:!1}}),this.deleteOnBackspace$.value===!1)return;this.deleteOnBackspace$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteOnBackspace: ",e)}}getDeleteOnBackspace(){return this.deleteOnBackspace$.value}getDeleteOnBackspace$(){return this.deleteOnBackspace$.asObservable()}enableHotkey(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableHotkey","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{hotkey:!0}}),this.hotkeyEnabled$.value===!0)return;this.hotkeyEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableHotkey: ",e)}}disableHotkey(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableHotkey","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{hotkey:!1}}),this.hotkeyEnabled$.value===!1)return;this.hotkeyEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableHotkey: ",e)}}enableRecordingSummary(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingSummary:!0}}),this.recordingSummaryEnabled$.value===!0)return;this.recordingSummaryEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableRecordingSummary: ",e)}}disableRecordingSummary(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingSummary:!1}}),this.recordingSummaryEnabled$.value===!1)return;this.recordingSummaryEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableRecordingSummary: ",e)}}getRecordingSummaryEnabled(){return this.recordingSummaryEnabled$.value}getRecordingSummaryEnabled$(){return this.recordingSummaryEnabled$.asObservable()}setUnreadIndicatorMode(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{unreadIndicatorMode:e}}),this.unreadIndicatorMode$.value===e)return;this.unreadIndicatorMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setUnreadIndicatorMode: ",t)}}getUnreadIndicatorMode(){return this.unreadIndicatorMode$.value}getUnreadIndicatorMode$(){return this.unreadIndicatorMode$.asObservable()}setComposerMode(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setComposerMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{composerMode:e}}),this.composerMode$.value===e)return;this.composerMode$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setComposerMode: ",t)}}getComposerMode(){return this.composerMode$.value}getComposerMode$(){return this.composerMode$.asObservable()}enableEnterKeyToSubmit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{enterKeyToSubmit:!0}}),this.enterKeyToSubmit$.value===!0)return;this.enterKeyToSubmit$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableEnterKeyToSubmit: ",e)}}disableEnterKeyToSubmit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{enterKeyToSubmit:!1}}),this.enterKeyToSubmit$.value===!1)return;this.enterKeyToSubmit$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableEnterKeyToSubmit: ",e)}}getEnterKeyToSubmit(){return this.enterKeyToSubmit$.value}getEnterKeyToSubmit$(){return this.enterKeyToSubmit$.asObservable()}enablePinShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinShadowDom:!0}}),this.pinShadowDOM$.value===!0)return;this.pinShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinShadowDOM: ",e)}}disablePinShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinShadowDom:!1}}),this.pinShadowDOM$.value===!1)return;this.pinShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinShadowDOM: ",e)}}getPinShadowDOM(){return this.pinShadowDOM$.value}getPinDarkMode(){return this.pinDarkMode$.value}getPinDarkMode$(){return this.pinDarkMode$.asObservable()}getTextCommentToolDarkMode(){return this.textCommentToolDarkMode$.value}getTextCommentToolDarkMode$(){return this.textCommentToolDarkMode$.asObservable()}getTextCommentToolbarDarkMode(){return this.textCommentToolbarDarkMode$.value}getTextCommentToolbarDarkMode$(){return this.textCommentToolbarDarkMode$.asObservable()}getPinShadowDOM$(){return this.pinShadowDOM$.asObservable()}getTextCommentToolShadowDOM$(){return this.textCommentToolShadowDOM$.asObservable()}getTextCommentToolbarShadowDOM$(){return this.textCommentToolbarShadowDOM$.asObservable()}enableDialogShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogShadowDom:!0}}),this.dialogShadowDOM$.value===!0)return;this.dialogShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDialogShadowDOM: ",e)}}enableTextCommentToolbarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolbarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarShadowDom:!0}}),this.textCommentToolbarShadowDOM$.value===!0)return;this.textCommentToolbarShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolbarShadowDOM: ",e)}}disableTextCommentToolbarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolbarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarShadowDom:!1}}),this.textCommentToolbarShadowDOM$.value===!1)return;this.textCommentToolbarShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolbarShadowDOM: ",e)}}enableTextCommentToolShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolShadowDom:!0}}),this.textCommentToolShadowDOM$.value===!0)return;this.textCommentToolShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolShadowDOM: ",e)}}disableTextCommentToolShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolShadowDom:!1}}),this.textCommentToolShadowDOM$.value===!1)return;this.textCommentToolShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolShadowDOM: ",e)}}enableTextCommentToolDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolDarkMode:!0}}),this.textCommentToolDarkMode$.value===!0)return;this.textCommentToolDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolDarkMode: ",e)}}disableTextCommentToolDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolDarkMode:!1}}),this.textCommentToolDarkMode$.value===!1)return;this.textCommentToolDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolDarkMode: ",e)}}enableTextCommentToolbarDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableTextCommentToolbarDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarDarkMode:!0}}),this.textCommentToolbarDarkMode$.value===!0)return;this.textCommentToolbarDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableTextCommentToolbarDarkMode: ",e)}}disableTextCommentToolbarDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableTextCommentToolbarDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{textCommentToolbarDarkMode:!1}}),this.textCommentToolbarDarkMode$.value===!1)return;this.textCommentToolbarDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableTextCommentToolbarDarkMode: ",e)}}enablePinDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enablePinDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDarkMode:!0}}),this.pinDarkMode$.value===!0)return;this.pinDarkMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinDarkMode: ",e)}}disablePinDarkMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disablePinDarkMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDarkMode:!1}}),this.pinDarkMode$.value===!1)return;this.pinDarkMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinDarkMode: ",e)}}disableDialogShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{dialogShadowDom:!1}}),this.dialogShadowDOM$.value===!1)return;this.dialogShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDialogShadowDOM: ",e)}}getDialogShadowDOM(){return this.dialogShadowDOM$.value}getDialogShadowDOM$(){return this.dialogShadowDOM$.asObservable()}setDialogShadowDOMExplicit(e){this.dialogShadowDOMExplicit$.next(e)}getDialogShadowDOMExplicit$(){return this.dialogShadowDOMExplicit$.asObservable()}enableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarShadowDOM:!0}}),this.sidebarShadowDOM$.value===!0)return;this.sidebarShadowDOM$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarShadowDOM: ",e)}}disableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarShadowDOM:!1}}),this.sidebarShadowDOM$.value===!1)return;this.sidebarShadowDOM$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarShadowDOM: ",e)}}getSidebarShadowDOM(){return this.sidebarShadowDOM$.value}getSidebarShadowDOM$(){return this.sidebarShadowDOM$.asObservable()}enableChangeDetectionInCommentMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{changeDetectionInCommentMode:!0}}),this.changeDetectionInCommentMode$.value===!0)return;this.changeDetectionInCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableChangeDetectionInCommentMode: ",e)}}disableChangeDetectionInCommentMode(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{changeDetectionInCommentMode:!1}}),this.changeDetectionInCommentMode$.value===!1)return;this.changeDetectionInCommentMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableChangeDetectionInCommentMode: ",e)}}getChangeDetectionInCommentMode(){return this.changeDetectionInCommentMode$.value}getChangeDetectionInCommentMode$(){return this.changeDetectionInCommentMode$.asObservable()}showResolvedCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolvedCommentsOnDom:!0}}),this.resolvedCommentsOnDom$.value===!0)return;this.resolvedCommentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService showResolvedCommentsOnDom: ",e)}}hideResolvedCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolvedCommentsOnDom:!1}}),this.resolvedCommentsOnDom$.value===!1)return;this.resolvedCommentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService hideResolvedCommentsOnDom: ",e)}}getResolvedCommentsOnDom(){return this.resolvedCommentsOnDom$.value}getResolvedCommentsOnDom$(){return this.resolvedCommentsOnDom$.asObservable()}enableBubbleOnPin(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPin:!0}}),this.bubbleOnPinEnabled$.value===!0)return;this.bubbleOnPinEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableBubbleOnPin: ",e)}}disableBubbleOnPin(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPin:!1}}),this.bubbleOnPinEnabled$.value===!1)return;this.bubbleOnPinEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableBubbleOnPin: ",e)}}getBubbleOnPin(){return this.bubbleOnPinEnabled$.value}getBubbleOnPin$(){return this.bubbleOnPinEnabled$.asObservable()}enableBubbleOnPinHover(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPinHover:!0}}),this.bubbleOnPinHoverEnabled$.value===!0)return;this.bubbleOnPinHoverEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableBubbleOnPinHover: ",e)}}disableBubbleOnPinHover(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{bubbleOnPinHover:!1}}),this.bubbleOnPinHoverEnabled$.value===!1)return;this.bubbleOnPinHoverEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableBubbleOnPinHover: ",e)}}getBubbleOnPinHover(){return this.bubbleOnPinHoverEnabled$.value}getBubbleOnPinHover$(){return this.bubbleOnPinHoverEnabled$.asObservable()}enablePinDrag(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDrag:!0}}),this.pinDragEnabled$.value===!0)return;this.pinDragEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePinDrag: ",e)}}disablePinDrag(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{pinDrag:!1}}),this.pinDragEnabled$.value===!1)return;this.pinDragEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disablePinDrag: ",e)}}getPinDrag(){return this.pinDragEnabled$.value}getPinDrag$(){return this.pinDragEnabled$.asObservable()}setExcludeLocationIdsFromSidebar(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{excludeLocationIdsFromSidebar:e}}),this.excludeLocationIdsFromSidebar$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setExcludeLocationIdsFromSidebar: ",t)}}getExcludeLocationIdsFromSidebar(){return this.excludeLocationIdsFromSidebar$.value}getExcludeLocationIdsFromSidebar$(){return this.excludeLocationIdsFromSidebar$.asObservable()}enableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{multiThread:!1}}),this.multiThread$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableMultiThread: ",e)}}getMultiThread(){return this.multiThread$.value}getMultiThread$(){return this.multiThread$.asObservable()}enableGroupMatchedComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{groupMatchedComments:!0}}),this.groupMatchedComments$.value===!0)return;this.groupMatchedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGroupMatchedComments: ",e)}}disableGroupMatchedComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{groupMatchedComments:!1}}),this.groupMatchedComments$.value===!1)return;this.groupMatchedComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableGroupMatchedComments: ",e)}}getGroupMatchedComments(){return this.groupMatchedComments$.value}getGroupMatchedComments$(){return this.groupMatchedComments$.asObservable()}enableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{shortUserName:!0}}),this.shortUserName$.value===!0)return;this.shortUserName$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShortUserName: ",e)}}disableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{shortUserName:!1}}),this.shortUserName$.value===!1)return;this.shortUserName$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShortUserName: ",e)}}getShortUserName(){return this.shortUserName$.value}getShortUserName$(){return this.shortUserName$.asObservable()}enableRecordingCountdown(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingCountdown:!0}}),this.recorderService.enableRecordingCountdown()}catch(e){this.loggingService.catch("Error in CommentService enableRecordingCountdown: ",e)}}disableRecordingCountdown(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;"),this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{recordingCountdown:!1}}),this.recorderService.disableRecordingCountdown()}catch(e){this.loggingService.catch("Error in CommentService disableRecordingCountdown: ",e)}}setCommentSidebarFilters(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;"),this.commentSidebarFilters$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentSidebarFilters: ",t)}}getCommentSidebarFilters(){return this.commentSidebarFilters$.value??{}}getCommentSidebarFilters$(){return this.commentSidebarFilters$.asObservable()}setEffectiveSidebarFilters(e){try{this.effectiveSidebarFilters$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEffectiveSidebarFilters: ",t)}}getEffectiveSidebarFilters$(){return this.effectiveSidebarFilters$.asObservable()}setCommentSidebarSystemFiltersOperator(e){try{this.commentSidebarSystemFiltersOperator$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentSidebarSystemFiltersOperator: ",t)}}getCommentSidebarSystemFiltersOperator(){return this.commentSidebarSystemFiltersOperator$.value}getCommentSidebarSystemFiltersOperator$(){return this.commentSidebarSystemFiltersOperator$.asObservable()}enableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentPinHighlighter:!1}}),this.domService.disableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService disableCommentPinHighlighter: ",e)}}setCustomReactions(e){try{this.reactionService.setCustomReactions(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomReactions: ",t)}}onCommentSelectionChange$(){return this.commentSelectionChange$.asObservable()}onVisibilityOptionClicked$(){return this.visibilityOptionClicked$.asObservable()}emitVisibilityOptionClicked(e){this.visibilityOptionClicked$.next(e)}onCommentAdd$(){return this.commentAdded$.asObservable()}onCommentUpdate$(){return this.commentUpdated$.asObservable()}onCommentAnnotationDelete$(){return this.commentAnnotationDeleted$.asObservable()}onMultiThreadCommentAnnotationDelete$(){return this.multiThreadCommentAnnotationDeleted$.asObservable()}getCommentMode(){try{let e="freestyle";return this.getStreamMode()?e="stream":this.getPopoverMode()&&(e="popover"),e}catch(e){return this.loggingService.catch("Error in CommentService getCommentMode: ",e),"freestyle"}}getCommentType(e){try{return e.targetElement?"element":e.targetTextRange?"text":e.areaAnnotationId?"area":""}catch(t){return this.loggingService.catch("Error in CommentService getCommentType: ",t),""}}getCommentAnnotationAvailableOnXPath(e,t,i){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(a=>(!i&&t&&(i=ll(t,["id","data-id"])),de(y(h({},a),{element:i})))),ye(a=>this.getLocations$().pipe(ge(l=>y(h({},a),{locationIds:l})))),ge(({locationIds:a,element:l})=>{let c=[],d=this.docService.getDocumentPaths();if(d?.documentId){let g=this.docService.getAdditionalDocumentIdFromElement(l),u=g?this.docService.generateDocumentId(g):d?.documentId,_=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:d?.organizationId,documentId:u||""});if(_)for(let w of _)(t&&w?.targetElementId===t||w?.targetElement?.xpath===e)&&a?.includes(w?.locationId)&&c.push(w)}return c.length?c:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),de(null)}}getCommentAnnotationsByContext({context:e,contextOptions:t,element:i,clientDocumentId:a}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$()),ge(()=>{let l=null,c=this.docService.getDocumentPaths(),d=Ns(e),g=this.generateContextId(d);if(c?.documentId){let u=a||this.docService.getAdditionalDocumentIdFromElement(i??null),_=u?this.docService.generateDocumentId(u):c?.documentId,w=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:c?.organizationId,documentId:_||""});if(w){l=[];for(let A of w)t?.partialMatch?jF(A?.context,d)&&l.push(A):g&&A?.contextId===g&&l.push(A)}}return l}))}catch(l){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",l),de(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(ge(()=>this.getAnnotationById(e)),ye(t=>t?t?.iam?.accessMode===ya.PRIVATE?this.isPrivateCommentAllowed$().pipe(ge(i=>{if(i)return t})):de(t):de(t)),ye(t=>t?this.filterCommentsUsingSidebarSettings(t).pipe(ge(i=>{if(i)return i})):de(t)))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",t),de(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(ge(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let t=document.querySelector(`${F.TAGS.VELT_COMMENT_BUBBLE}[${F.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return t||(t=document.querySelector(`${F.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${F.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`)),t}catch(t){return this.loggingService.catch("Error in CommentService getCommentBubbleElement: ",t),null}}getCommentAnnotationsBySectionId(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,sectionId:e})))),ye(t=>{let i=ll(e,["id","data-id"]);if(i){let a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.genarateLocationId(a);return this.docService.getLocations$().pipe(ge(c=>{let g=Object.values(c||{}).find(u=>u.locationId===l||a?.id&&u.location.id===a.id);return y(h({},t),{additionalLocation:g,locationOnElement:!!a})}))}}return de(y(h({},t),{additionalLocation:null,element:i}))}),ye(t=>t?.locationOnElement?de(t):this.docService.getLocation$().pipe(ge(i=>y(h({},t),{location:i})))),ge(({documentPaths:t,location:i,additionalLocation:a,locationOnElement:l,element:c})=>{let d=null;if(this.authService.getUser()&&t?.documentId){let u=this.docService.getAdditionalDocumentIdFromElement(c),_=u?this.docService.generateDocumentId(u):t?.documentId,w=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:_||""});if(w){d=[];let A=sm(e);l?a?.location?.id?A=sm([a?.location?.id,e]):a?.locationId&&(A=sm([a?.locationId+"",e])):i&&(i?.location?.id?A=sm([i?.location?.id,e]):i?.locationId&&(A=sm([i?.locationId+"",e])));for(let M of w)M?.multiThreadAnnotationId===A?d.push(M):(M?.targetInlineCommentElementId===e||M?.targetElementId===e)&&(l?a&&E0({location:a?.location,locationId:a?.locationId},{location:M.location,locationId:M.locationId})&&d.push(M):i?E0({location:i?.location,locationId:i?.locationId},{location:M.location,locationId:M.locationId})&&d.push(M):M?.locationId||d.push(M))}}return d}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),de(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.multiThreadCommentAnnotationById$),ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,multiThreadAnnotationId:e})))),ge(({documentPaths:t,location:i,additionalLocation:a,locationOnElement:l})=>{let c=null;if(t?.documentId){let d=this.getMultiThreadAnnotationById(e),{documentId:g,organizationId:u}=d?.metadata||{documentId:t?.documentId,organizationId:t?.organizationId},_=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:u,documentId:g||""});if(_){c=[];for(let w of _)w?.multiThreadAnnotationId===e&&d?.commentAnnotations?.[w?.annotationId]&&c.push(w)}}return c}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),de(null)}}getCommentAnnotationsByAnnotationIds(e){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$().pipe(ge(t=>({documentPaths:t,annotationIds:e})))),ge(({documentPaths:t})=>{let i=null;if(t?.documentId){let a=this.commentAnnotationById$.value?Object.values(this.commentAnnotationById$.value):[],l=this.draftCommentAnnotationsByAnnotationId$.value?Object.values(this.draftCommentAnnotationsByAnnotationId$.value):[];if(a=[...a,...l],a){i=[];for(let c of a)e.includes(c?.annotationId)&&i.push(c)}}return i}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByAnnotationIds: ",t),de(null)}}getCommentAnnotationsByFolderId({folderId:e,veltFolderId:t}){try{return this.commentAnnotationById$.pipe(ye(()=>this.draftCommentAnnotationsByAnnotationId$),ye(()=>this.docService.getDocumentPaths$()),ge(()=>{e&&!t&&(t=Br(e));let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=null;if(i&&a?.documentId){this.commentAnnotationById$.value&&(l={},Object.values(this.commentAnnotationById$.value).forEach(d=>{d?.metadata?.folderId==e&&d?.metadata?.veltFolderId==t&&(l[d?.annotationId]=d)}));let c=this.draftCommentAnnotationsByAnnotationId$.value;c&&(l===null&&(l={}),Object.values(c).forEach(d=>{d?.metadata?.folderId==e&&d?.metadata?.veltFolderId==t&&!l[d?.annotationId]&&(l[d?.annotationId]=d)}))}return l?Object.values(l):null}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByFolderId: ",i),de(null)}}getCommentAnnotationsForCommentComponent(e){try{let{annotationId:t,folderId:i,veltFolderId:a,targetElementId:l,clientDocumentId:c,documentId:d,context:g,contextOptions:u,element:_,type:w,sectionId:A,locationId:M}=e||{};if(c&&!d&&(d=this.docService.generateDocumentId(c)),i&&!a&&(a=Br(i)),t)return this.getCommentAnnotationByAnnotationId(t).pipe(ge(q=>q?[q]:null));let j=[];if(l&&(w==="pin"||w==="tool"||w==="bubble")){let q=ll(l,["id","data-id"]);if(q){let ie=q,_e=this.domService.getXPath(q);j.push(this.getCommentAnnotationAvailableOnXPath(_e,l,ie))}}return A&&j.push(this.getCommentAnnotationsBySectionId(A)),g&&j.push(this.getCommentAnnotationsByContext({context:g,contextOptions:u,element:_,clientDocumentId:c})),d&&j.push(this.getCommentAnnotationsByDocumentId$({documentId:d})),i&&j.push(this.getCommentAnnotationsByFolderId({folderId:i,veltFolderId:a})),j.length===0?de(null):mn(j).pipe(ge(q=>{let ie=q.filter(ae=>ae!==null&&Array.isArray(ae));if(ie.length===0)return null;if(ie.length===1){let ae=ie[0];return M&&ae?.length?ae.filter(Ie=>Ie?.location?.id===M):ae}let _e=ie[0];for(let ae=1;ae<ie.length;ae++){let ue=ie[ae];_e=_e.filter(Ie=>ue.some(we=>we.annotationId===Ie.annotationId))}return M&&_e?.length&&(_e=_e.filter(ae=>ae?.location?.id===M)),_e}),bt(Zt))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsForCommentComponent: ",t),de(null)}}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.allowedElementIds$.value?.length||this.allowedElementClassNames$.value?.length||this.allowedElementQuerySelectors$.value?.length?!!(this.allowedElementIds$.value?.length&&this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)||this.allowedElementClassNames$.value?.length&&this.domService.isElementInsideListedElementClassNames(e,this.allowedElementClassNames$.value)||this.allowedElementQuerySelectors$.value?.length&&this.domService.isElementInsideListedElementQuerySelectors(e,this.allowedElementQuerySelectors$.value)):!0}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideAllowedElements: ",t),!1}}getNearestAllowedElement(e){try{let t=this.domService.getListedElements({elementIds:this.allowedElementIds$.value,elementClassNames:this.allowedElementClassNames$.value,elementQuerySelectors:this.allowedElementQuerySelectors$.value});if(t?.length){for(let i=0;i<t.length;i++){let a=t[i];if(e.contains(a))return a}return null}return null}catch(t){return this.loggingService.catch("Error in CommentService getNearestAllowedElement: ",t),null}}isElementInsideManualCommentContainer(e){try{return this.domService.isElementInsideParentWithAttribute(e,F.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",t),!1}}saveComment(e,t){return X(this,null,function*(){try{t?.annotation&&(e=t.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let i=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(i?.comments?.length){let u=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],i.comments?.forEach(_=>{let w=u.find(A=>A.commentId===_.commentId);w?e.comments.push(w):e.comments.push(_)})}e.comments||(e.comments=[]);let a=!1,l=!1,c;switch(t.type){case Tt.NEWLY_ADDED:case Tt.ADDED:if(!t.updatedComment)break;e?.comments?.length||(l=!0),e.comments.push(t.updatedComment);let u=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:t.type,otherFields:{assigned:u}};break;case Tt.APPROVED:e.approved=!0,c={commentAnnotation:e,targetComment:null,actionType:Tt.APPROVED};break;case Tt.ASSIGNED:{let ie=i?.assignedTo;e.assignedTo=t.assignedTo,c={commentAnnotation:e,targetComment:null,actionType:Tt.ASSIGNED,otherFields:{oldAssignedTo:ie,newAssignedTo:t.assignedTo}};break}case Tt.UPDATED:if(!t.updatedComment)break;let _=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);if(_>=0){let ie=e.comments[_]?.commentText;e.comments[_]=t.updatedComment,e.comments[_].status=Tt.UPDATED;let _e=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.UPDATED,otherFields:{assigned:_e,oldCommentText:ie}}}break;case Tt.REACTION_ADDED:if(!t.updatedComment)break;let w=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);w>=0&&(e.comments[w]=t.updatedComment,e.comments[w].status=Tt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.REACTION_ADDED});break;case Tt.REACTION_DELETED:if(!t.updatedComment)break;let A=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);A>=0&&(e.comments[A]=t.updatedComment,e.comments[A].status=Tt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.REACTION_DELETED});break;case Tt.STATUS_CHANGED:if(e.status.type==="terminal"){this.domService.resetSelectedAnnotationsMap(!1,"comment");let ie=this.authService.getUser();e.resolvedByUserId=ie?.userId,e.resolvedByUser=ie}c={commentAnnotation:e,targetComment:null,actionType:Tt.STATUS_CHANGED,otherFields:{oldStatus:t.oldStatus,newStatus:t.newStatus}};break;case Tt.PRIORITY_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.PRIORITY_CHANGED,otherFields:{oldPriority:t.oldPriority,newPriority:t.newPriority}};break;case Tt.ACCESS_MODE_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:t.oldAccessMode,newAccessMode:t.newAccessMode}};break;case Tt.CUSTOM_LIST_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Tt.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:t.oldCustomList,newCustomList:t.newCustomList}};break;case Tt.SUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUBSCRIBED};break;case Tt.UNSUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Tt.UNSUBSCRIBED};break;case Tt.DELETED:if(!t.updatedComment)break;let M=e.comments.findIndex(ie=>ie.commentId===t.updatedComment.commentId);if(M>=0){if((M===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!t.skipDeleteThreadConfirmation){let ae={};if(this.deleteReplyConfirmation$.value&&(M!==0||this.deleteThreadWithFirstComment$.value===!1)?ae={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply",type:"reply"}:ae={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment",type:"comment"},!(yield this.dialog.open(ml,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:ae}).afterClosed().toPromise()))return}let ie=e.comments.splice(M,1),_e=e.metadata;ie?.length&&ie.forEach(ae=>{ae?.attachments&&ae.attachments.forEach(ue=>{let Ie={attachmentId:ue.attachmentId,organizationId:_e?.clientOrganizationId??_e?.organizationId??null,documentId:_e?.clientDocumentId??_e?.documentId??null,folderId:_e?.folderId??null,commentAnnotationId:e.annotationId,apiKey:_e?.apiKey??null};this.deleteAttachment({attachment:ue,metadata:Ie})}),ae?.reactionAnnotationIds&&ae.reactionAnnotationIds.forEach(ue=>{this.deleteReaction(ue)})})}e?.status?.type==="terminal"&&(e.status=this.customFilterService.defaultStatus),M===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments?.length===0?a=!0:(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_THREAD_DELETED,{annotationId:e.annotationId,commentThreadId:t.updatedComment.commentId,commentMode:this.getCommentMode()}),c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Tt.DELETED});break;case Tt.ACCEPTED:let j={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Tt.ACCEPTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:this.getCommentAnnotationForClient(e)};this.commentAccepted$.next(j),c={commentAnnotation:e,targetComment:null,actionType:Tt.ACCEPTED};break;case Tt.REJECTED:let q={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Tt.REJECTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:this.getCommentAnnotationForClient(e)};this.commentRejected$.next(q),this.domService.resetSelectedAnnotationsMap(),c={commentAnnotation:e,targetComment:null,actionType:Tt.REJECTED};break;case Tt.SUGGESTION_ACCEPTED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUGGESTION_ACCEPTED,otherFields:{resolvedBy:e?.suggestion?.resolvedBy,resolvedAt:e?.suggestion?.resolvedAt}};break;case Tt.SUGGESTION_REJECTED:c={commentAnnotation:e,targetComment:null,actionType:Tt.SUGGESTION_REJECTED,otherFields:{rejectReason:e?.suggestion?.rejectReason,resolvedBy:e?.suggestion?.resolvedBy,resolvedAt:e?.suggestion?.resolvedAt}};break;default:break}if(e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null,e.resolvedByUser=null),t.visibility)try{let u=h({},t.visibility);if(u.type==="organizationPrivate"&&!u.organizationId){let w=this.docService.getOrganizationConfig();w?.clientOrganizationId&&(u.organizationId=w.clientOrganizationId)}let _=lp(u);_.length>0&&(e.context||(e.context={}),e.context._setAccessFields=_)}catch(u){this.loggingService.catch("Error building accessFields from visibility in saveComment:",u)}if(t?.updatedComment?.isDraft&&(c=void 0),a)this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment");else{if(l&&e.comments?.length&&this.enableAutoCategorize$?.value&&this.setCommentCategory(e),e.context?.access&&e.context?.accessFields&&t.updatedComment?.from?.userId&&!this.userPermissionService?.hasUserContextAccess({userId:t.updatedComment?.from?.userId,accessFields:e.context.accessFields})){this.loggingService.catch("User does not have context access to update comment annotation.",void 0,void 0,!0);return}this.updateComment(e,!1,!1,c,!0,t.updatedComment),e?.multiThreadAnnotationId&&(t.type===Tt.ADDED||t.type===Tt.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e])}let d=this.getCustomPinById(e.annotationId),g={type:t.type,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e.annotationId,targetCommentId:t.updatedComment?.commentId,updateContext:(u,_)=>{this.updateCommentAnnotationContext(e.annotationId,u,_)}};if(d!==void 0&&(g.element=d),delete g?.annotation?.pageInfo,delete g?.annotation?.targetElement,delete g?.annotation?.targetTextRange,g?.type===Tt.DELETED&&(e.comments?.length||(g.annotation=null)),a||this.commentUpdated$.next(g),t.type===Tt.NEWLY_ADDED&&!a&&e?.annotationId){let u=this.pendingAddCommentAnnotationData.get(e.annotationId);if(u){this.pendingAddCommentAnnotationData.delete(e.annotationId);let _=y(h({},u),{annotation:this.getCommentAnnotationForClient(e),targetCommentId:t.updatedComment?.commentId}),w=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(_);w&&this.commentActionsService?.triggerAddCommentAnnotationEvent(w),t.updatedComment&&(yield this.commentActionsService?.triggerAddCommentEvent({annotation:e,newComment:t.updatedComment}))}}t.type===Tt.ADDED&&t._dispatchAddCommentEvent&&!a&&e?.annotationId&&t.updatedComment&&(yield this.commentActionsService?.triggerAddCommentEvent({annotation:e,newComment:t.updatedComment}))}catch(i){this.loggingService.catch("Error in CommentService saveComment: ",i)}})}attachComment(e,t=[],i,a,l,c,d,g){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let u;if(e){let _=ll(e,t);_&&(u={targetElement:{xpath:this.domService.getXPath(_),topPercentage:50,leftPercentage:90},targetElementId:e})}(u||i||l)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,c,void 0,void 0,u,g,void 0,void 0,a,void 0,void 0,void 0,i,void 0,l,void 0,void 0,d)}catch(u){this.loggingService.catch("Error in CommentService attachComment: ",u)}}generateComponentIdFromObject(e){try{let t=Ns(e||{});return It(JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CommentService generateComponentIdFromObject: ",t);return}}updateNotificationsDatabase(e,t,i,a={}){try{let l=h({annotationData:e,targetAnnotationData:t,actionType:i,notificationSource:"comment"},a);this.notificationService.updateNotificationDatabase(l)}catch(l){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",l)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}getCustomUserContacts(){try{return this.contactService.getCustomUserContacts()}catch(e){return this.loggingService.catch("Error in CommentService getCustomUserContacts:",e),null}}getCustomUserContactsConfig(){try{return this.contactService.getCustomUserContactsConfig()}catch(e){this.loggingService.catch("Error in CommentService getCustomUserContactsConfig:",e);return}}getElementFromComment(e){try{let t=null;if(e?.ghostComment)!t&&e.ghostComment?.targetElement?.fXpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e.ghostComment?.targetElement?.cfXpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e.ghostComment?.targetElement?.xpath&&(t=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null));else{let i=!1,a=e?.targetElement?.anchor;if(!t&&a){let l=this.domService.resolveAnchorRecord(a);l?.element&&this.domService.isElementVisible(l.element)&&Xr(l.element)&&(t=l.element)}!t&&e?.targetElement?.xpath&&(i=this.domService.isXpathWithId(e?.targetElement?.xpath),t=this.domService.getElementFromXPath(e?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null)),i||(!t&&e?.targetElement?.cfXpath&&(t=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),t&&!this.domService.isElementVisible(t)&&(t=null)),!t&&e?.targetElement?.fXpath&&(t=this.domService.getElementFromXPath(e?.targetElement?.fXpath),t&&!this.domService.isElementVisible(t)&&(t=null)))}return t&&!Xr(t)&&(t=null),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),null}}getElementFromComments(e){try{let t=[],i=null;if(e?.ghostComment)!i&&e.ghostComment?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.xpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null));else{let a=!1,l=e?.targetElement?.anchor;if(!i&&l){let c=this.domService.resolveAnchorRecord(l);c?.element&&this.domService.isElementVisible(c.element)&&Xr(c.element)&&(i=c.element)}!i&&e?.targetElement?.xpath&&(a=this.domService.isXpathWithId(e?.targetElement?.xpath),i=this.domService.getElementFromXPath(e?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null)),a||(!i&&e?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)))}return i&&!Xr(i)&&(i=null),e?.targetElementId&&(t=Array.from(Khe(e.targetElementId,["id","data-id"]))),i&&!t.includes(i)&&t.push(i),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),[]}}getGhostCommentTargetElement(e){try{let t=e.targetElement?.fXpath||e.targetElement?.xpath,i=null;if(t)for(;!i&&t;)i=this.domService.getElementFromXPath(t),i&&(!this.domService.isElementVisible(i)||!Xr(i))&&(i=null),i||(t=t.substring(0,t.lastIndexOf("/")));return t==="/"&&(t=""),t?{xpath:t,topPercentage:e?.targetElement?.topPercentage||0,leftPercentage:e?.targetElement?.leftPercentage||0}:null}catch(t){return this.loggingService.catch("Error in CommentService getGhostCommentTargetElement: ",t),null}}setGhostCommentMessage(e){try{if(e?.ghostComment){e.ghostComment.message="Original content not found.",e.ghostComment.type=As.ELEMENT_DELETED;let t=e?.pageInfo?.deviceInfo?.deviceType,i=new pr().getDeviceType();t&&t!==i&&(e.ghostComment.type=As.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${t}.`,[Gi.MOBILE,Gi.TABLET].includes(t)&&[Gi.MOBILE,Gi.TABLET].includes(i)||[Gi.DESKTOP,Gi.MONITOR].includes(t)&&[Gi.DESKTOP,Gi.MONITOR].includes(i)?e.ghostComment.isSameGroup=!0:e.ghostComment.isSameGroup=!1)}}catch(t){this.loggingService.catch("Error in CommentService setGhostCommentMessage: ",t)}}addAnnotationToGhostCommentAnnotationMap(e){try{let t=this.ghostCommentAnnotationMap$.value||{},i=t[e?.annotationId]||{};dr(e.ghostComment,i)||(t[e?.annotationId]=e.ghostComment,this.ghostCommentAnnotationMap$.next(t))}catch(t){this.loggingService.catch("Error in CommentService addAnnotationToGhostCommentAnnotationMap: ",t)}}removeAnnotationFromGhostCommentAnnotationMap(e){try{let t=this.ghostCommentAnnotationMap$.value||{};t[e?.annotationId]&&(delete t[e?.annotationId],this.ghostCommentAnnotationMap$.next(t))}catch(t){this.loggingService.catch("Error in CommentService removeAnnotationFromGhostCommentAnnotationMap: ",t)}}getGhostCommentAnnotationMap$(){return this.ghostCommentAnnotationMap$.asObservable()}getGhostCommentAnnotationMap(){return this.ghostCommentAnnotationMap$.value||{}}getUnreadCommentsMap$(){return this.unreadCommentsMap$.asObservable().pipe(bt(Zt))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>t?{count:t[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ge(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ge(e=>e?{count:Object.values(e).reduce((i,a)=>i+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>{if(t){let i=this.docService.getDocumentPaths(),a=[],l=0;return i?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId}),a&&Object.keys(t).forEach(c=>{a?.find(g=>g.annotationId===c)?.location?.id===e&&(l+=t[c])})),{count:l}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ge(t=>{if(t){let i=this.docService.getDocumentPaths(),a=[],l=0;return i?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId}),Object.keys(t).forEach(c=>{t[c]&&a?.find(g=>g.annotationId===c)?.location?.id===e&&(l+=1)})),{count:l}}else return null}))}setCommentAnnotationsAsRead(e){try{for(let t of e)this.viewsService.setCommentAnnotationAsRead(t)}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsRead: ",t)}}setCommentAnnotationsAsResolved(e){try{let t=this.customFilterService.resolvedStatus,i=this.authService.getUser();if(t){for(let a of e)if(t?.id!==a?.status?.id){let l=JSON.parse(JSON.stringify(a||{}));a.status=this.customFilterService.resolvedStatus,a.statusUpdatedByUserId=i?.userId;let c={annotation:a,type:Tt.STATUS_CHANGED,oldStatus:l.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(a,c)}}}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsResolved: ",t)}}isCommentAnnotationUnread(e){try{let t=this.authService.getUser();return!(t?.userSnippylyId&&e?.viewedByUserIds?.length&&e?.viewedByUserIds?.includes(t?.userSnippylyId))}catch(t){return this.loggingService.catch("Error in CommentService isCommentAnnotationUnread: ",t),!1}}updateCommentDialogPosition(){try{this.updateCommentDialogPositionTriggerSubject$.next()}catch(e){this.loggingService.catch("Error in CommentService updateCommentDialogPosition: ",e)}}updateCommentDialogPositionTrigger$(){return this.updateCommentDialogPositionTriggerSubject$.asObservable()}enableAreaComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{areaComment:!0}}),this.areaCommentEnabled$.value===!0)return;this.areaCommentEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAreaComment: ",e)}}disableAreaComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{areaComment:!1}}),this.areaCommentEnabled$.value===!1)return;this.areaCommentEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAreaComment: ",e)}}getAreaCommentEnabled$(){return this.areaCommentEnabled$.asObservable()}getAreaCommentEnabled(){return this.areaCommentEnabled$.value}setPinCursorImage(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;"),e&&(e=`url(${e}) 0 31, auto`),this.commentPinCursorImage$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setPinCursorImage: ",t)}}getPinCursorImage$(){return this.commentPinCursorImage$.asObservable()}getPinCursorImage(){return this.commentPinCursorImage$.value}setCommentAnnotationsFromCommentsContainer(e){try{this.commentAnnotationsFromCommentsContainer$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentAnnotationsFromCommentsContainer: ",t)}}getCommentAnnotationsFromCommentsContainer$(){return this.commentAnnotationsFromCommentsContainer$.asObservable()}getCommentAnnotationsFromCommentsContainer(){return this.commentAnnotationsFromCommentsContainer$.value}addManualComment(e){return X(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addManualComment","color: green;"),new Promise((t,i)=>{let a=this.domService.getLastDocumentClick()?.target,l=e?.location||this.docService.getAdditionLocationFromElement(a);if(l?.id){let c=this.docService.getLocationByClientLocationId(l.id);c&&(l=c)}this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,l,void 0,e,void 0,void 0,void 0,c=>{t(c)}),this.addCommentMode$?.value&&!this.persistentCommentMode$?.value&&this.disableAddCommentMode()})}catch(t){return this.loggingService.catch("Error in CommentService addManualComment: ",t),null}})}getCommentUrl(e){try{return e?.pageInfo?.commentUrl?e.pageInfo.commentUrl:(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.commentUrl=this.generateCommentUrl(e),this.updateComment(e),e.pageInfo?.commentUrl)}catch(t){this.loggingService.catch("Error in CommentService getCommentUrl: ",t);return}}uploadFile(e,t){let i=`${F.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${F.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`;this.documentPaths?.organizationId&&(i=`${F.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${F.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${F.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`);let a={organizationId:t.metadata?.clientOrganizationId??this.documentPaths?.clientOrganizationId??null,documentId:t.metadata?.clientDocumentId??this.documentPaths?.clientDocumentId??null,commentAnnotationId:t.annotationId,apiKey:t.metadata?.apiKey??this.configService?.getApiKey()??null,folderId:t.metadata?.folderId??this.documentPaths?.folderId??null,attachmentId:null};return this.storageService.uploadFile({path:i,file:e,metadata:a,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}downloadAttachment(e){this.storageService.downloadAttachment(e)}deleteAttachment({attachment:e,metadata:t}){return this.storageService.deleteAttachment({attachment:e,metadata:t,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}deleteReaction(e){try{this.reactionService.deleteReactionPinAnnotation(e)}catch(t){this.loggingService.catch("Error in CommentService deleteReaction: ",t)}}generateCommentUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.COMMENT_ID),t.searchParams.append(F.URL_PARAMS.COMMENT_ID,e.annotationId),t.href}getCustomPinById(e){if(this.customPinsById.has(e))return this.customPinsById.get(e)}setCustomStatuses(e){try{if(e===void 0)return;this.customStatusesShown$.next(!0),this.customFilterService.setCustomStatusFilters(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomStatuses: ",t)}}getCustomStatusesShown$(){return this.customStatusesShown$.asObservable()}getCustomStatusesShown(){return this.customStatusesShown$.value}setCustomPriorities(e){try{if(e===void 0)return;this.customFilterService.setCustomPriorityFilters(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomPriorities: ",t)}}setCustomCategories(e){try{if(e===void 0)return;this.customFilterService.setCustomCategories(e)}catch(t){this.loggingService.catch("Error in CommentService setCustomCategories: ",t)}}addCommentOnSelectedText(){try{let e=this.authService.getUser();if(this.textCommentMode$.value&&e&&!(e?.isReadOnly||e?.isAnonymous)&&this.authService.isFeatureAllowed(je.COMMENT)){let t=this.domService.getRange();if(window.getSelection()?.toString()&&!kO()&&t?.commonAncestorContainer&&this.isElementInsideAllowedElements(t.commonAncestorContainer)&&!Ag(t.commonAncestorContainer)){let i=t?this.domService.getTargetTextRangeFromSelectionRange(t):void 0;this.domService.clearTextSelection(),setTimeout(()=>{this.addComment(void 0,i)},100)}}}catch(e){this.loggingService.catch("Error in CommentService addCommentOnSelectedText: ",e)}}getInlineCommentSectionConfig(e){try{let t;if(e){let i=e?.closest(`[${F.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(i){let a=i.getAttribute(F.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(t={},t.targetInlineCommentElementId=a,i.getAttribute(F.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(t.config=JSON.parse(i.getAttribute(F.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)||"{}")))}}return t}catch(t){this.loggingService.catch("Error in CommentService getInlineCommentSectionConfig: ",t)}}createCustomListDataOnAnnotation(e){try{if(e===void 0)return;this.customChipDropdownData$.next(e)}catch(t){this.loggingService.catch("Error in CommentService createCustomListDataOnAnnotation: ",t)}}getCustomChipDropdownData$(){return this.customChipDropdownData$.asObservable()}getCustomChipDropdownData(){return this.customChipDropdownData$.value}setSubscribedUsersDataInCommentAnnotation(e){try{let t={},i=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(l=>{let c=e.subscribedUsers?.[l];c?.type==="manual"&&(t[l]=c)}),e?.assignedTo?.userId){let l=It(e?.assignedTo?.userId);i[l]||t[l]?.type!=="manual"&&(t[l]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(l=>!l?.isDraft)?.forEach(l=>{if(l?.from?.userId){let c=It(l?.from?.userId);i[c]||t[c]?.type!=="manual"&&(t[c]={user:l?.from,type:"auto"})}l?.to?.forEach(c=>{if(c?.userId){let d=It(c.userId);i[d]||t[d]?.type!=="manual"&&(t[d]={user:c,type:"auto"})}}),l?.toOrganizationUserGroup?.forEach(c=>{if(c?.groupId)a[c?.groupId]={type:"auto"};else if(c?.clientGroupId){let d=It(c.clientGroupId);a[d]={type:"auto"}}})}),e.subscribedUsers=t,e.unsubscribedUsers=i,e.subscribedGroups=a}catch(t){this.loggingService.catch("Error in CommentService setSubscribeUsersDataInCommentAnnotation: ",t)}}getCopyLink$(){return this.copyLink$.asObservable()}setCopyLink(e){try{this.copyLink$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCopyLink: ",t)}}getCommentAnnotationById(e){return this.commentAnnotationById$.pipe(ye(()=>{let{annotationId:t,documentId:i}=e;if(i){let a=tr(i).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(ge(l=>l.find(d=>d.annotationId===t)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let l=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(l){let c=l.find(d=>d.annotationId===t);return de(c||null)}}}return de(null)}),Gn(t=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",t),de(null))))}getDataCommentAnnotationsFromDocumentId(e){return this.configService?.getApiKey()?this.commonDbService.dbListener({feature:"allComments",properties:{documentId:e||this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,isCollection:!0}}).pipe(ge(t=>t?.data),ge(t=>{let i=[];return t&&(i=Object.values(t??{}).filter(a=>typeof a=="object")),i})):de([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{collapsedComments:!1}}),this.collapsedComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCollapsedComments: ",e)}}getCollapsedComments$(){return this.collapsedComments$.asObservable()}enableFullExpanded(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullExpanded:!0}}),this.fullExpanded$.value===!0)return;this.fullExpanded$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFullExpanded: ",e)}}disableFullExpanded(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullExpanded:!1}}),this.fullExpanded$.value===!1)return;this.fullExpanded$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFullExpanded: ",e)}}getFullExpanded$(){return this.fullExpanded$.asObservable()}getFullExpanded(){return this.fullExpanded$.value}setSidebarCustomActionEventData(e,t,i,a,l){try{this.sidebarCustomActionEventData$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l})}catch(c){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",c)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,t){try{let i=new Set;(e||[]).forEach(l=>{(l?.annotations||[]).forEach(c=>{c?.annotationId&&i.add(c.annotationId)})});let a=this.customSidebarDataAnnotationIds$.value;this.areAnnotationIdSetsEqual(a,i)||this.customSidebarDataAnnotationIds$.next(i),this.sidebarData$.next({data:e,options:t})}catch(i){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",i)}}areAnnotationIdSetsEqual(e,t){if(e===t)return!0;if(e===null||t===null||e.size!==t.size)return!1;for(let i of e)if(!t.has(i))return!1;return!0}getSidebarCustomData(){return this.sidebarData$.asObservable()}getCustomSidebarDataAnnotationIds$(){return this.customSidebarDataAnnotationIds$.asObservable()}getCustomSidebarDataAnnotationIds(){return this.customSidebarDataAnnotationIds$.value}setSidebarCustomActionEventDataAllChanges(e,t,i,a,l){return X(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l});let c=yield this.metadataService.getGlobalMetadata(),d={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:i,commentAnnotations:t,systemFilteredAnnotations:a,metadata:c,customFilters:l};this.commentActionsService?.triggerAction(er.COMMENT_SIDEBAR_DATA_UPDATE,d)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",c)}})}setSidebarCustomActionEventDataOnInit(e,t,i,a,l){return X(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:t,unreadDataMap:i,systemFilteredData:a,customFilters:l});let d={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:i,commentAnnotations:t,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()},customFilters:l};this.commentActionsService?.triggerAction(er.COMMENT_SIDEBAR_DATA_INIT,d)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataOnInit: ",c)}})}getSidebarCustomActionEventDataAllChanges(){return this.sidebarCustomActionEventDataAllChanges$.asObservable()}getSidebarCustomActionEventDataOnInit(){return this.sidebarCustomActionEventDataOnInit$.asObservable()}getSidebarCustomActionEventDataOnInitValue(){return this.sidebarCustomActionEventDataOnInit$.getValue()}setTransformContext(e){try{e?dr(this.transformContext$.value,e)||this.transformContext$.next(e):this.transformContext$.next(null)}catch(t){this.loggingService.catch("Error in CommentService setTransformContext: ",t)}}getTransformContext$(){return this.transformContext$.asObservable()}getTransformContext(){return this.transformContext$.value}enableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customActions:!0}}),this.customActions$.value===!0)return;this.customActions$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSidebarCustomActions: ",e)}}disableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customActions:!1}}),this.customActions$.value===!1)return;this.customActions$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSidebarCustomActions: ",e)}}getSidebarCustomActionsValue(){return this.customActions$.getValue()}enableQueryParamsComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{queryParamsComments:!0}}),this.queryParamsComments$.value===!0)return;this.queryParamsComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableQueryParamsComments: ",e)}}disableQueryParamsComments(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{queryParamsComments:!1}}),this.queryParamsComments$.value===!1)return;this.queryParamsComments$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableQueryParamsComments: ",e)}}getQueryParamsComments$(){return this.queryParamsComments$.asObservable()}getQueryParamsComments(){return this.queryParamsComments$.value}enableResolveStatusAccessAdminOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveStatusAccessAdminOnly:!0}}),this.resolveStatusAccessAdminOnly$.value===!0)return;this.resolveStatusAccessAdminOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableResolveStatusAccessAdminOnly: ",e)}}disableResolveStatusAccessAdminOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{resolveStatusAccessAdminOnly:!1}}),this.resolveStatusAccessAdminOnly$.value===!1)return;this.resolveStatusAccessAdminOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableResolveStatusAccessAdminOnly: ",e)}}enableLinkCallback(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{linkCallback:!0}}),this.linkCallback$.value===!0)return;this.linkCallback$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableLinkCallback: ",e)}}disableLinkCallback(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{linkCallback:!1}}),this.linkCallback$.value===!1)return;this.linkCallback$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableLinkCallback: ",e)}}getResolveStatusAccessAdminOnly$(){return this.resolveStatusAccessAdminOnly$.asObservable()}getLinkCallback$(){return this.linkCallback$.asObservable()}getResolveStatusAccessAdminOnly(){return this.resolveStatusAccessAdminOnly$.value}getLinkCallback(){return this.linkCallback$.value}enableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{svgAsImg:!0}}),this.svgAsImg$.value===!0)return;this.svgAsImg$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableSvgAsImg: ",e)}}disableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{svgAsImg:!1}}),this.svgAsImg$.value===!1)return;this.svgAsImg$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableSvgAsImg: ",e)}}getSvgAsImg$(){return this.svgAsImg$.asObservable()}getSvgAsImg(){return this.svgAsImg$.value}enableCommentToNearestAllowedElement(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentToNearestAllowedElement:!0}}),this.commentToNearestAllowedElement$.value===!0)return;this.commentToNearestAllowedElement$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCommentToNearestAllowedElement: ",e)}}disableCommentToNearestAllowedElement(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentToNearestAllowedElement:!1}}),this.commentToNearestAllowedElement$.value===!1)return;this.commentToNearestAllowedElement$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCommentToNearestAllowedElement: ",e)}}getCommentToNearestAllowedElement$(){return this.commentToNearestAllowedElement$.asObservable()}getCommentToNearestAllowedElement(){return this.commentToNearestAllowedElement$.value}enableFilterCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterCommentsOnDom:!0}}),this.filterCommentsOnDom$.value===!0)return;this.filterCommentsOnDom$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFilterCommentsOnDom: ",e)}}disableFilterCommentsOnDom(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterCommentsOnDom:!1}}),this.filterCommentsOnDom$.value===!1)return;this.filterCommentsOnDom$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFilterCommentsOnDom: ",e)}}getFilterCommentsOnDom$(){return this.filterCommentsOnDom$.asObservable()}getFilterCommentsOnDom(){return this.filterCommentsOnDom$.value}setCommentsFromSidebarMap(e){try{let{comments:t,sidebarVisible:i}=e||{},a=null;t&&(a={},t.forEach(c=>{c?.annotationId&&a&&(a[c.annotationId]=c)}));let l={};t===void 0?l.data=this.commentsFromSidebarMap$.value?.data:l.data=a,i===void 0?l.sidebarVisible=this.commentsFromSidebarMap$.value?.sidebarVisible:l.sidebarVisible=i,dr(this.commentsFromSidebarMap$.value,l)||this.commentsFromSidebarMap$.next(l)}catch(t){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",t)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}hasActiveFilters(e){try{return e?!!(e.people?.length||e.assigned?.length||e.tagged?.length||e.involved?.length||e.priority?.length||e.status?.length||e.category?.length||e.location?.length||e.document?.length||e.version?.length||e.accessModes?.length||this.hasCustomContextFilters(e)):!1}catch(t){return this.loggingService.catch("Error in CommentService hasActiveFilters: ",t),!1}}hasCustomContextFilters(e){try{if(!e)return!1;let t=new Set(["people","assigned","tagged","involved","priority","status","category","version","document","location","accessModes"]);return Object.keys(e).some(i=>!t.has(i)&&Array.isArray(e[i])&&e[i]?.length>0)}catch(t){return this.loggingService.catch("Error in CommentService hasCustomContextFilters: ",t),!1}}applyDirectFilters(e,t){try{let i=this.commentSidebarSystemFiltersOperator$.value,a,l=!1,c=new Set;i===Qc.AND?a=e.slice():a=[];let d=g=>{i===Qc.AND?a=a.filter(u=>g.some(_=>_.annotationId===u.annotationId)):g.forEach(u=>c.add(u.annotationId)),l=!0};if(t.people?.length){let g=[];t.people.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByPeople({id:_,name:u.name},e)])}),d(g)}if(t.assigned?.length){let g=[];t.assigned.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByAssigned({id:_,name:u.name},e)])}),d(g)}if(t.tagged?.length){let g=[];t.tagged.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByTagged({id:_,name:u.name},e)])}),d(g)}if(t.involved?.length){let g=[];t.involved.forEach(u=>{let _=u.userId||u.email;_&&(g=[...g,...this.filterAnnotationsByInvolved({id:_,name:u.name},e)])}),d(g)}if(t.priority?.length){let g=[];t.priority.forEach(u=>g=[...g,...this.filterAnnotationsByPriority({id:u},e)]),d(g)}if(t.status?.length){let g=[];t.status.forEach(u=>g=[...g,...this.filterAnnotationsByStatus({id:u},e)]),d(g)}if(t.category?.length){let g=[];t.category.forEach(u=>g=[...g,...this.filterAnnotationsByCommentCategory({id:u},e)]),d(g)}if(t.version?.length){let g=[];t.version.forEach(u=>g=[...g,...this.filterAnnotationsByVersion(u,e)]),d(g)}if(t.document?.length){let g=[];t.document.forEach(u=>g=[...g,...this.filterAnnotationsByDocument(u,e)]),d(g)}if(t.location?.length){let g=[];t.location.forEach(u=>{u.id&&(g=[...g,...e.filter(_=>_.location?.id===u.id||_.documentParams?.id===u.id)])}),d(g)}if(t.accessModes?.length){let g=[];t.accessModes.forEach(u=>{u===ya.PRIVATE?g=[...g,...e.filter(_=>Pl(_))]:u===ya.PUBLIC&&(g=[...g,...e.filter(_=>!Pl(_))])}),d(g)}return this.getCustomContextFilterEntries(t).forEach(({key:g,values:u})=>{let _=this.matchAnnotationsByContext(e,g,u);d(_)}),i!==Qc.AND&&(l?a=e.filter(g=>c.has(g.annotationId)):a=e),a}catch(i){return this.loggingService.catch("Error in CommentService applyDirectFilters: ",i),e}}getCustomContextFilterEntries(e){try{if(!e)return[];let t=new Set(["people","assigned","tagged","involved","priority","status","category","version","document","location","accessModes"]),i=[];return Object.keys(e).forEach(a=>{if(t.has(a))return;let l=e[a];!Array.isArray(l)||!l.length||i.push({key:a,values:l})}),i}catch(t){return this.loggingService.catch("Error in CommentService getCustomContextFilterEntries: ",t),[]}}matchAnnotationsByContext(e,t,i){try{return e.filter(a=>{let l=a.context?.[t];return l==null?!1:i.some(c=>{let d=typeof c=="string"?c:c?.id;return l===d||l?.toString()===d})})}catch(a){return this.loggingService.catch("Error in CommentService matchAnnotationsByContext: ",a),[]}}filterAnnotationsByPeople(e,t){try{return e.id?t.filter(i=>i?.from?.userId===e.id||i?.from?.email===e.id):t}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByPeople: ",i),[]}}filterAnnotationsByTagged(e,t){try{return t.filter(i=>i?.comments?.some(a=>a.taggedUserContacts?.some(l=>l?.contact?.userId===e.id)))}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByTagged: ",i),[]}}filterAnnotationsByAssigned(e,t){try{return t.filter(i=>i?.assignedTo?.userId===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByAssigned: ",i),[]}}filterAnnotationsByInvolved(e,t){try{return t.filter(i=>{let a=i?.from?.userId===e.id||i?.from?.email===e.id,l=i?.assignedTo?.userId===e.id,c=i?.comments?.some(d=>d.taggedUserContacts?.some(g=>g?.contact?.userId===e.id));return a||l||c})}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByInvolved: ",i),[]}}filterAnnotationsByPriority(e,t){try{return e.id==="unset"?t.filter(i=>!i?.priority):t.filter(i=>i?.priority?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByPriority: ",i),[]}}filterAnnotationsByStatus(e,t){try{return t.filter(i=>i?.status?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByStatus: ",i),[]}}filterAnnotationsByCommentCategory(e,t){try{return e.id==="other"?t.filter(i=>!i?.commentCategories?.length||i?.commentCategories?.some(a=>a.id===e.id)):t.filter(i=>(i?.commentCategories||[]).some(a=>a.id===e.id))}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByCommentCategory: ",i),[]}}filterAnnotationsByVersion(e,t){try{return e.id==="unset"?t.filter(i=>!i?.location?.version):t.filter(i=>i?.location?.version?.id===e.id)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByVersion: ",i),[]}}filterAnnotationsByDocument(e,t){try{return e?.id&&e.id!=="other"?t.filter(i=>i?.metadata?.clientDocumentId?.toString()===e.id):t.filter(i=>!i?.metadata?.clientDocumentId)}catch(i){return this.loggingService.catch("Error in CommentService filterAnnotationsByDocument: ",i),[]}}setSidebarButtonCountType(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{sidebarButtonCountType:e}}),this.sidebarButtonCountType$.value===e)return;this.sidebarButtonCountType$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setSidebarButtonCountType: ",t)}}getSidebarButtonCountType$(){return this.sidebarButtonCountType$.asObservable()}getSidebarButtonCountType(){return this.sidebarButtonCountType$.value}enableFilterGhostCommentsInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterGhostCommentsInSidebar:!0}}),this.filterGhostCommentsInSidebar$.value===!0)return;this.filterGhostCommentsInSidebar$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFilterGhostCommentsInSidebar: ",e)}}disableFilterGhostCommentsInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{filterGhostCommentsInSidebar:!1}}),this.filterGhostCommentsInSidebar$.value===!1)return;this.filterGhostCommentsInSidebar$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFilterGhostCommentsInSidebar: ",e)}}getFilterGhostCommentsInSidebar$(){return this.filterGhostCommentsInSidebar$.asObservable()}getFilterGhostCommentsInSidebar(){return this.filterGhostCommentsInSidebar$.value}filterCommentsUsingSidebarSettings(e){try{let t=Array.isArray(e),i;return t?i=e||[]:e?i=[e]:i=[],this.getFilterCommentsOnDom$().pipe(ye(a=>a?i.length===0?de(e):mn([this.effectiveSidebarFilters$,this.customSidebarDataAnnotationIds$]).pipe(ge(([l,c])=>{let d=i,g=!1;if(this.hasActiveFilters(l)){let u=this.applyDirectFilters(i,l),_=new Set(u.map(w=>w.annotationId));d=d.filter(w=>w?.isDraft||_.has(w.annotationId)),g=!0}return c&&(d=d.filter(u=>u?.isDraft||u?.annotationId&&c.has(u.annotationId)),g=!0),g?t?d:d.length>0?d[0]:null:e})):de(e)))}catch{return de(e)}}enableFocusedThreadMode(){try{if(this.focusedThreadMode$.value===!0)return;this.focusedThreadMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFocusedThreadMode: ",e)}}disableFocusedThreadMode(){try{if(this.focusedThreadMode$.value===!1)return;this.focusedThreadMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFocusedThreadMode: ",e)}}getFocusedThreadMode$(){return this.focusedThreadMode$.asObservable()}enableOpenAnnotationInFocusMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{openAnnotationInFocusMode:!0}}),this.openAnnotationInFocusMode$.value===!0)return;this.openAnnotationInFocusMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableOpenAnnotationInFocusMode: ",e)}}disableOpenAnnotationInFocusMode(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{openAnnotationInFocusMode:!1}}),this.openAnnotationInFocusMode$.value===!1)return;this.openAnnotationInFocusMode$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableOpenAnnotationInFocusMode: ",e)}}getOpenAnnotationInFocusMode$(){return this.openAnnotationInFocusMode$.asObservable()}getOpenAnnotationInFocusMode(){return this.openAnnotationInFocusMode$.value}enableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{readOnly:!0}}),this.readOnly$.value===!0)return;this.readOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReadOnly: ",e)}}disableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{readOnly:!1}}),this.readOnly$.value===!1)return;this.readOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReadOnly: ",e)}}getReadOnly$(){return this.readOnly$.asObservable()}getReadOnly(){return this.readOnly$.value}shouldEnableReadOnly(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentService FUNCTION: shouldEnableReadOnly","color: green;");let e=this.authService.getUser(),t=this.docService.getDocumentPaths()?.folderId,i=this.docService.getDocumentIds().map(a=>a.clientDocumentId);if(e){let a=this.userPermissionService.getCurrentUserPermissions();a?.[e.userId]?t&&a[e.userId]?.folders?.[t]?.accessRole==="viewer"?this.enableReadOnly():i.forEach(l=>{a[e.userId]?.documents?.[l]?.accessRole==="viewer"&&this.enableReadOnly()}):this.getReadOnly()||this.disableReadOnly()}}catch(e){this.loggingService.catch("Error in CommentService shouldEnableReadOnly:",e)}})}sanitizeCommentAnnotation(e){try{return e?.comments?.length&&e.comments.forEach(t=>{t?.commentHtml&&(t.commentHtml=this.domService.sanitizeHtml(t.commentHtml))}),e}catch(t){return this.loggingService.catch("Error in CommentService sanitizeCommentAnnotation: ",t),e}}enableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customAutocompleteSearch:!0}}),this.customAutocompleteSearch$.value===!0)return;this.customAutocompleteSearch$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCustomAutocompleteSearch: ",e)}}disableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{customAutocompleteSearch:!1}}),this.customAutocompleteSearch$.value===!1)return;this.customAutocompleteSearch$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableCustomAutocompleteSearch: ",e)}}getCustomAutocompleteSearch$(){return this.customAutocompleteSearch$.asObservable()}getCustomAutocompleteSearch(){return this.customAutocompleteSearch$.value}enableDeleteThreadWithFirstComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteThreadWithFirstComment:!0}}),this.deleteThreadWithFirstComment$.value===!0)return;this.deleteThreadWithFirstComment$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableDeleteThreadWithFirstComment: ",e)}}disableDeleteThreadWithFirstComment(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{deleteThreadWithFirstComment:!1}}),this.deleteThreadWithFirstComment$.value===!1)return;this.deleteThreadWithFirstComment$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteThreadWithFirstComment: ",e)}}getDeleteThreadWithFirstComment$(){return this.deleteThreadWithFirstComment$.asObservable()}enableExpandMentionGroups(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{expandMentionGroups:!0}}),this.expandMentionGroups$.value===!0)return;this.expandMentionGroups$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableExpandMentionGroups: ",e)}}disableExpandMentionGroups(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{expandMentionGroups:!1}}),this.expandMentionGroups$.value===!1)return;this.expandMentionGroups$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableExpandMentionGroups: ",e)}}getExpandMentionGroups$(){return this.expandMentionGroups$.asObservable()}getExpandMentionGroups(){return this.expandMentionGroups$.value}enableShowMentionGroupsFirst(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsFirst:!0}}),this.showMentionGroupsFirst$.value===!0)return;this.showMentionGroupsFirst$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowMentionGroupsFirst: ",e)}}disableShowMentionGroupsFirst(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsFirst:!1}}),this.showMentionGroupsFirst$.value===!1)return;this.showMentionGroupsFirst$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowMentionGroupsFirst: ",e)}}getShowMentionGroupsFirst$(){return this.showMentionGroupsFirst$.asObservable()}getShowMentionGroupsFirst(){return this.showMentionGroupsFirst$.value}enableShowMentionGroupsOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsOnly:!0}}),this.showMentionGroupsOnly$.value===!0)return;this.showMentionGroupsOnly$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowMentionGroupsOnly: ",e)}}disableShowMentionGroupsOnly(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{showMentionGroupsOnly:!1}}),this.showMentionGroupsOnly$.value===!1)return;this.showMentionGroupsOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableShowMentionGroupsOnly: ",e)}}getShowMentionGroupsOnly$(){return this.showMentionGroupsOnly$.asObservable()}getShowMentionGroupsOnly(){return this.showMentionGroupsOnly$.value}setAnalyticsFeatureConfig({config:e,feature:t}){try{this.analyticsService.setFeatureConfig({feature:t||je.COMMENT,config:e})}catch(i){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",i)}}generateContextId(e){try{let t;if(e&&typeof e=="object"){let i=JSON.parse(JSON.stringify(e));if(delete i.accessFields,delete i.access,Object.keys(i).length){let a=Ns(i),l=JSON.stringify(a);t=It(l)}}return t}catch{return}}setMaxReplyAvatars(e){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{maxReplyAvatars:e}}),this.maxReplyAvatars$.value===e)return;this.maxReplyAvatars$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setMaxReplyAvatars: ",t)}}getMaxReplyAvatars$(){return this.maxReplyAvatars$.asObservable()}getMaxReplyAvatars(){return this.maxReplyAvatars$.value}enableReplyAvatars(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyAvatars:!0}}),this.replyAvatars$.value===!0)return;this.replyAvatars$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableReplyAvatars: ",e)}}disableReplyAvatars(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyAvatars:!1}}),this.replyAvatars$.value===!1)return;this.replyAvatars$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableReplyAvatars: ",e)}}getReplyAvatars$(){return this.replyAvatars$.asObservable()}getReplyAvatars(){return this.replyAvatars$.value}setCommentplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{commentplaceholder:e}}),this.commentplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setCommentplaceholder: ",t)}}getCommentplaceholder$(){return this.commentplaceholder$.asObservable()}getCommentplaceholder(){return this.commentplaceholder$.value}setReplyplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{replyplaceholder:e}}),this.replyplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setReplyplaceholder: ",t)}}getReplyplaceholder$(){return this.replyplaceholder$.asObservable()}getReplyplaceholder(){return this.replyplaceholder$.value}setEditplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editplaceholder:e}}),this.editplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditplaceholder: ",t)}}getEditplaceholder$(){return this.editplaceholder$.asObservable()}getEditplaceholder(){return this.editplaceholder$.value}setEditcommentplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editcommentplaceholder:e}}),this.editcommentplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditcommentplaceholder: ",t)}}getEditcommentplaceholder$(){return this.editcommentplaceholder$.asObservable()}getEditcommentplaceholder(){return this.editcommentplaceholder$.value}setEditreplyplaceholder(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{editreplyplaceholder:e}}),this.editreplyplaceholder$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEditreplyplaceholder: ",t)}}getEditreplyplaceholder$(){return this.editreplyplaceholder$.asObservable()}getEditreplyplaceholder(){return this.editreplyplaceholder$.value}enableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{screenshotEnabled:!0}}),this.screenshotEnabled$.value===!0)return;this.screenshotEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableScreenshot: ",e)}}disableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{screenshotEnabled:!1}}),this.screenshotEnabled$.value===!1)return;this.screenshotEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableScreenshot: ",e)}}getScreenshotEnabled$(){return this.screenshotEnabled$.asObservable()}getScreenshotEnabled(){return this.screenshotEnabled$.value}getAnnotationNumber(e){try{let t=this.commentAnnotationById$.value||{},i=-1,a=Object.values(t).filter(l=>{let c=l.metadata?.documentId===e.metadata?.documentId;return c&&l.annotationNumber&&(i=Math.max(i,l.annotationNumber)),c});return i===-1?a.length+1:i+1}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationNumber: ",t),null}}enableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullScreen:!0}}),this.fullScreenInSidebar$.value===!0)return;this.fullScreenInSidebar$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableFullScreenInSidebar: ",e)}}disableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{fullScreen:!1}}),this.fullScreenInSidebar$.value===!1)return;this.fullScreenInSidebar$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableFullScreenInSidebar: ",e)}}getFullScreenInSidebar$(){return this.fullScreenInSidebar$.asObservable()}getFullScreenInSidebar(){return this.fullScreenInSidebar$.value}setComposerFileAttachments(e){try{this.composerFileAttachments$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setComposerFileAttachments: ",t)}}getComposerFileAttachments$(){return this.composerFileAttachments$.asObservable()}getComposerFileAttachments(){return this.composerFileAttachments$.value}clearComposerFileAttachments(){try{this.composerFileAttachments$.next(null)}catch(e){this.loggingService.catch("Error in CommentService clearComposerFileAttachments: ",e)}}enableAttachmentNameInMessage(){try{if(this.attachmentNameInMessage$.value===!0)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentNameInMessage:!0}}),this.attachmentNameInMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableAttachmentNameInMessage: ",e)}}disableAttachmentNameInMessage(){try{if(this.attachmentNameInMessage$.value===!1)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{attachmentNameInMessage:!1}}),this.attachmentNameInMessage$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableAttachmentNameInMessage: ",e)}}getAttachmentNameInMessage$(){return this.attachmentNameInMessage$.asObservable()}getAttachmentNameInMessage(){return this.attachmentNameInMessage$.value}setAllowedFileTypes(e){try{this.allowedFileTypes$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setAllowedFileTypes: ",t)}}getAllowedFileTypes$(){return this.allowedFileTypes$.asObservable()}getAllowedFileTypes(){return this.allowedFileTypes$.value}enableForceCloseAllOnEsc(){try{if(this.forceCloseAllOnEsc$.value===!0)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{forceCloseAllOnEsc:!0}}),this.forceCloseAllOnEsc$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableForceCloseAllOnEsc: ",e)}}disableForceCloseAllOnEsc(){try{if(this.forceCloseAllOnEsc$.value===!1)return;this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{forceCloseAllOnEsc:!1}}),this.forceCloseAllOnEsc$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableForceCloseAllOnEsc: ",e)}}getForceCloseAllOnEsc$(){return this.forceCloseAllOnEsc$.asObservable()}getForceCloseAllOnEsc(){return this.forceCloseAllOnEsc$.value}markAsRead(e){return X(this,null,function*(){try{let t;e&&(t=this.getAnnotationById(e)),t&&(yield this.viewsService.setCommentAnnotationAsRead(t))}catch(t){this.loggingService.catch("Error in ViewsService markAsRead:",t)}})}markAsUnread(e){return X(this,null,function*(){try{let t;e&&(t=this.getAnnotationById(e)),t&&(yield this.viewsService.setCommentAnnotationAsUnread(t))}catch(t){this.loggingService.catch("Error in ViewsService markAsUnread:",t)}})}setAutoCompleteScrollConfig(e){try{this.analyticsService.setFeatureConfig({feature:je.COMMENT,config:{autoCompleteScrollConfig:e}});let t=this.autoCompleteScrollConfig$.value,i={itemSize:e.itemSize??t.itemSize,minBufferPx:e.minBufferPx??t.minBufferPx,maxBufferPx:e.maxBufferPx??t.maxBufferPx,templateCacheSize:e.templateCacheSize??t.templateCacheSize};this.autoCompleteScrollConfig$.next(i)}catch(t){this.loggingService.catch("Error in CommentService setAutoCompleteScrollConfig: ",t)}}getAutoCompleteScrollConfig(){return this.autoCompleteScrollConfig$.value}getAutoCompleteScrollConfig$(){return this.autoCompleteScrollConfig$.asObservable()}submitComment(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: submitComment","color: green;"),this.submitComment$.next(e.targetComposerElementId)}catch(t){this.loggingService.catch("Error in CommentService submitComment: ",t)}}onSubmitComment$(){return this.submitComment$.asObservable()}clearComposer(e){try{this.clearComposer$.next(e.targetComposerElementId),this.composerDataMap.delete(e.targetComposerElementId)}catch(t){this.loggingService.catch("Error in CommentService clearComposer: ",t)}}onClearComposer$(){return this.clearComposer$.asObservable()}emitComposerTextChange(e,t,i){try{this.commentActionsService?.onComposerTextChange({text:e,annotation:t,targetComposerElementId:i})}catch(a){this.loggingService.catch("Error in CommentService emitComposerTextChange: ",a)}}setComposerData(e,t){try{this.composerDataMap.set(e,t)}catch(i){this.loggingService.catch("Error in CommentService setComposerData: ",i)}}clearComposerData(e){try{this.composerDataMap.delete(e)}catch(t){this.loggingService.catch("Error in CommentService clearComposerData: ",t)}}getComposerData(e){try{return this.composerDataMap.get(e.targetComposerElementId)||null}catch(t){return this.loggingService.catch("Error in CommentService getComposerData: ",t),null}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Cv),Z(kn),Z(Lt),Z(st),Z(Hn),Z(Ke),Z(Ve),Z(no),Z(_m),Z(un),Z($p),Z(Oo),Z(Vo),Z(Vn),Z(k),Z(cn),Z(ho),Z(qi),Z(R_e),Z(Un),Z(Ll),Z(jS),Z(ls),Z(bd),Z(as),Z(Oa),Z(fo))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var L_e=(()=>{let o=class o{constructor(e,t,i){this.commentService=e,this.reactionService=t,this.loggingService=i}getActivityForClient(e){try{let t=JSON.parse(JSON.stringify(e));return t.metadata&&(t.metadata=ai(t.metadata)),t.actionUser&&(t.actionUser=Bo(t.actionUser)),t.entityData&&(t.entityData=this.transformEntityData(t.featureType,t.entityData),t.entityData?.metadata&&(t.entityData.metadata=ai(t.entityData.metadata))),t.entityTargetData&&(t.entityTargetData=this.transformEntityTargetData(t.featureType,t.entityTargetData)),t.changes&&(t.changes=this.transformChanges(t.changes)),t.displayMessageTemplateData&&(t.displayMessageTemplateData=this.transformTemplateData(t.displayMessageTemplateData)),t}catch(t){return this.loggingService.catch("Error in ActivityActionsService getActivityForClient:",t),e}}transformEntityData(e,t){try{switch(e){case"comment":return this.commentService.getCommentAnnotationForClient(t);case"reaction":return this.reactionService.getReactionAnnotationForClient(t);case"recorder":return cfe(t);default:return t}}catch(i){return this.loggingService.catch("Error in ActivityActionsService transformEntityData:",i),t}}transformEntityTargetData(e,t){try{return t}catch(i){return this.loggingService.catch("Error in ActivityActionsService transformEntityTargetData:",i),t}}transformChanges(e){try{let t={};for(let i of Object.keys(e)){let a=e[i];if(!a){t[i]=a;continue}t[i]=h({},a),this.isUserObject(a.from)&&(t[i].from=Bo(a.from)),this.isUserObject(a.to)&&(t[i].to=Bo(a.to))}return t}catch(t){return this.loggingService.catch("Error in ActivityActionsService transformChanges:",t),e}}transformTemplateData(e){try{let t={};for(let i of Object.keys(e)){let a=e[i];this.isUserObject(a)?t[i]=Bo(a):t[i]=a}return t}catch(t){return this.loggingService.catch("Error in ActivityActionsService transformTemplateData:",t),e}}isUserObject(e){return!!e&&typeof e=="object"&&"userId"in e}};o.\u0275fac=function(t){return new(t||o)(Z(Re),Z(qi),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Gg=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j){this.activityResolverService=e,this.activityUtilsService=t,this.authService=i,this.commentAnnotationsResolverService=a,this.reactionAnnotationsResolverService=l,this.recorderAnnotationsResolverService=c,this.commonDbService=d,this.commonDbUtilsService=g,this.configService=u,this.docService=_,this.functions=w,this.loggingService=A,this.usersService=M,this.userPermissionService=j,this.isActivityFeatureEnabled$=new Se(!1),this.isActivityFeatureImmutable$=new Se(!1),this.allActivities$=new Se(null),this.subscriptions=new Map,this.fetchedEntityIds=new Set;try{this.commonDbService.setActivityService(this),this.authService.setActivityService(this),this.initializeService()}catch(q){this.loggingService.catch("Error in ActivityService constructor:",q)}}setActivityFeatureConfig(e){try{this.isActivityFeatureEnabled$.next(e?.isEnabled??!1),this.isActivityFeatureImmutable$.next(e?.immutable??!1)}catch(t){this.loggingService.catch("Error in setActivityFeatureConfig: ",t)}}getIsActivityFeatureEnabled(){return this.isActivityFeatureEnabled$.value}getIsActivityFeatureImmutable(){return this.isActivityFeatureImmutable$.value}getIsActivityFeatureEnabled$(){return this.isActivityFeatureEnabled$.asObservable().pipe(bt(Zt))}initializeService(){try{this.authSubscription=this.getIsActivityFeatureEnabled$().pipe(bt(),$e(e=>e===!0)).subscribe(()=>{this.subscriptions.size>0&&!this.triggerListenerSubscription&&this.rebuildTriggerListener()},e=>{this.loggingService.catch("Error in ActivityService feature flag subscription:",e)})}catch(e){this.loggingService.catch("Error in ActivityService initializeService:",e)}}subscribe(e){let t=lt(),i=new Se(null);try{let a={id:t,config:e??{},activities$:i};this.subscriptions.set(t,a),this.getIsActivityFeatureEnabled()&&this.rebuildTriggerListener(),this.allActivities$.getValue()!==null&&this.distributeActivitiesToSubscription(a)}catch(a){this.loggingService.catch("Error in ActivityService subscribe:",a)}return{getActivities$:()=>i.asObservable(),unsubscribe:()=>{try{this.subscriptions.delete(t),i.complete(),this.getIsActivityFeatureEnabled()&&this.rebuildTriggerListener()}catch(a){this.loggingService.catch("Error in ActivityService unsubscribe:",a)}}}}getActivities$(){return this.allActivities$.asObservable().pipe(bt(Zt))}getActivitiesForDocument$(e){return this.allActivities$.pipe(ge(t=>t===null?null:t.filter(i=>i.metadata?.documentId===e)),bt(Zt))}getActivitiesForEntity$(e){return this.allActivities$.pipe(ge(t=>t===null?null:t.filter(i=>i.targetEntityId===e)),bt(Zt))}fetchActivitiesForEntity(e){return X(this,null,function*(){try{if(!this.getIsActivityFeatureEnabled())return;let{targetEntityId:t,documentId:i,organizationId:a}=e;if(!t||!i||this.fetchedEntityIds.has(t))return;this.fetchedEntityIds.add(t);let l=this.authService.getUser();if(!l?.userId){this.fetchedEntityIds.delete(t);return}let c=a||this.docService.getOrganizationConfig()?.clientOrganizationId;if(!c){this.fetchedEntityIds.delete(t);return}let d=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()})),g=yield cl({methodName:"getActivitiesForEntity",data:{type:"getActivitiesForEntity",organizationId:c,documentId:i,targetEntityId:String(t),isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable()},getSdkProxy:d,userId:l.userId});if(g?.activities?.length){let u=g.activities;this.appendActivities(u),this.rehydrateActivities(u)}}catch(t){this.fetchedEntityIds.delete(e.targetEntityId),this.loggingService.catch("Error in ActivityService fetchActivitiesForEntity:",t)}})}createActivity(e){return X(this,null,function*(){try{if(!this.getIsActivityFeatureEnabled())return;let t=this.authService.getUser();if(!t?.userId){this.loggingService.warn("ActivityService createActivity: No user available");return}let i=this.docService.getBaseMetadata("activity");if(!i?.apiKey||!i?.organizationId){this.loggingService.warn("ActivityService createActivity: Missing metadata or organizationId");return}let a=this.getIsActivityFeatureImmutable(),l=lt(),c={id:l,featureType:e.featureType,actionType:e.actionType,eventType:e.eventType,actionUser:t,timestamp:this.commonDbService.getServerTimestamp(),metadata:i,targetEntityId:e.targetEntityId!=null?String(e.targetEntityId):void 0,targetSubEntityId:e.targetSubEntityId!=null?String(e.targetSubEntityId):void 0,changes:e.changes,entityData:e.entityData,entityTargetData:e.entityTargetData,actionIcon:e.actionIcon,displayMessageTemplate:e.displayMessageTemplate,displayMessageTemplateData:e.displayMessageTemplateData,immutable:a};this.appendActivities([c]);let{strippedActivity:d,activityResolverData:g}=yield this.activityUtilsService.stripActivityPII(c);g&&this.activityResolverService.activityDataProviderAvailable()&&this.activityResolverService.saveActivity({activity:{[g.id]:g},event:Io.ACTIVITY_SAVE});try{yield this.sendActivityToBackend(d)}catch{let u=this.allActivities$.getValue()??[];this.allActivities$.next(u.filter(_=>_.id!==l)),this.subscriptions.forEach(_=>this.distributeActivitiesToSubscription(_))}}catch(t){this.loggingService.catch("Error in ActivityService createActivity:",t)}})}rebuildTriggerListener(){try{if(this.triggerListenerSubscription&&(this.triggerListenerSubscription.unsubscribe(),this.triggerListenerSubscription=void 0),this.subscriptions.size===0)return;let e=this.getCombinedSubscriptionScope();this.triggerListenerSubscription=this.getLastActivityTimestamps$(e).pipe(yo(null),Lr(),ge(([t,i])=>{if(!i)return;if(i.length===0){this.allActivities$.getValue()===null&&!this.emptyStateTimeoutId&&(this.emptyStateTimeoutId=setTimeout(()=>{this.emptyStateTimeoutId=void 0,this.allActivities$.getValue()===null&&(this.allActivities$.next([]),this.subscriptions.forEach(d=>this.distributeActivitiesToSubscription(d)))},5e3));return}this.emptyStateTimeoutId&&(clearTimeout(this.emptyStateTimeoutId),this.emptyStateTimeoutId=void 0);let a=new Map;t?.forEach(d=>a.set(d.documentId,d.timestamp));let l=[],c=[];if(i.forEach(d=>{let g=a.get(d.documentId);g===void 0?l.push(d.documentId):g!==d.timestamp&&c.push({documentId:d.documentId,previousTimestamp:g})}),l.length>0){let d=this.getStartAtTimestamp(e.maxDays);this.fetchActivitiesForDocuments(l,e.organizationId,void 0,d)}c.length>0&&this.fetchActivitiesForDocuments(c.map(d=>d.documentId),e.organizationId,c)})).subscribe(()=>{},t=>this.loggingService.catch("Error in ActivityService trigger listener:",t))}catch(e){this.loggingService.catch("Error in ActivityService rebuildTriggerListener:",e)}}getLastActivityTimestamps$(e){try{return this.authService.getUser$().pipe($e(t=>!!t),ye(t=>this.docService.getOrganizationConfig$().pipe($e(i=>!!i),ge(i=>{let l=(e.organizationId?ka(e.organizationId):void 0)||i?.organizationId||t?.organizationId;return{user:t,organizationId:l}}))),ye(({user:t,organizationId:i})=>{if(!t||!i)return de(null);if(e.type===$g.CURRENT_DOCUMENT)return this.docService.getDocumentPaths$().pipe(ye(l=>{let c=l?.clientDocumentId;if(!c&&!e.documentIds?.length)return this.resetCurrentDocumentSubscriptions(),de(null);let d=new Set(e.documentIds??[]);c&&d.add(c);let g=Array.from(d).slice(0,30).map(u=>pi(u));return g.length===1?this.buildTriggerQuery(i,[ft("metadata.documentId","==",g[0])],e.maxDays):this.buildTriggerQuery(i,[ft("metadata.documentId","in",g)],e.maxDays)}));let a=[];if(e.type===$g.DOCUMENTS&&e.documentIds?.length){e.documentIds.length>30&&this.loggingService.catch("Error in ActivityService getLastActivityTimestamps$: Subscription includes more than 30 document IDs. Only the first 30 will be monitored.",new Error("Subscription includes more than 30 document IDs. Only the first 30 will be monitored."),void 0,!0);let l=e.documentIds.slice(0,30).map(c=>pi(c));a.push(ft("metadata.documentId","in",l))}return this.buildTriggerQuery(i,a,e.maxDays)}))}catch(t){return this.loggingService.catch("Error in ActivityService getLastActivityTimestamps$:",t),de(null)}}buildTriggerQuery(e,t,i=HU){try{let a=this.getStartAtTimestamp(i);t.push(ft("timestamp",">=",a));let c=[t.length>1?yr(...t):t[0],po("timestamp","desc")];return this.commonDbService.dbListener({feature:"allLastActivityTimestamp",properties:{organizationId:e,isCollection:!0,useQuery:!0,firestoreQuery:c}}).pipe(ge(d=>d?.data),ge(d=>{if(!d)return[];let g=[];return Object.keys(d).forEach(u=>{let _=this.commonDbService.shouldUseFirestore()?d[u]?.timestamp??0:d[u];g.push({documentId:u,timestamp:_})}),g}))}catch(a){return this.loggingService.catch("Error in ActivityService buildTriggerQuery:",a),de([])}}fetchActivitiesForDocuments(e,t,i,a){return X(this,null,function*(){try{if(!e.length)return;let l=this.authService.getUser();if(!l?.userId)return;let c=t||this.docService.getOrganizationConfig()?.clientOrganizationId;if(!c)return;let d=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()})),g={type:"getActivitiesForDocuments",organizationId:c,documentIds:e,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable()};a&&(g.startAtTimestamp=a),i?.length&&(g.documentTimestamps=i.map(_=>({documentId:_.documentId,timestamp:_.previousTimestamp})));let u=yield cl({methodName:"getActivitiesForDocuments",data:g,getSdkProxy:d,userId:l.userId});if(u?.activities?.length){let _=u.activities;this.appendActivities(_),this.rehydrateActivities(_)}else this.allActivities$.getValue()===null&&(this.allActivities$.next([]),this.subscriptions.forEach(_=>this.distributeActivitiesToSubscription(_)))}catch(l){this.loggingService.catch("Error in ActivityService fetchActivitiesForDocuments:",l)}})}sendActivityToBackend(e){return X(this,null,function*(){try{let t=this.authService.getUser();if(!t?.userId)return;let i=qr(this.functions,Kr({url:Dn.cloudFunction.sdkProxy,apiProxyDomain:this.configService.getApiProxyDomain()}));yield cl({methodName:"createActivity",data:{type:"createActivity",activityData:e},getSdkProxy:i,userId:t.userId})}catch(t){throw this.loggingService.catch("Error in ActivityService sendActivityToBackend:",t),t}})}rehydrateActivities(e){try{let t=this.usersService.userDataProviderAvailable(),i=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),a=this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable(),l=this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable(),c=this.activityResolverService.activityDataProviderAvailable(),d=Promise.resolve();t&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldAwait:!0,forceResolve:!0})).then(()=>{this.resolveAndUpdateActivities(e,"user")})),i&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldCommentAnnotationsResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"comment")})),a&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldReactionResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"reaction")})),l&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldRecorderResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"recorder")})),c&&(d=d.then(()=>this.commonDbUtilsService.formatResponse({feature:"allActivities",data:e,shouldActivityResolverAwait:!0})).then(()=>{this.resolveAndUpdateActivities(e,"activity")}))}catch(t){this.loggingService.catch("Error in ActivityService rehydrateActivities:",t)}}resolveAndUpdateActivities(e,t){try{let i=this.allActivities$.getValue()??[],a=new Map(i.map(g=>[g.id,g])),l=e.map(g=>a.get(g.id)??g),c=JSON.parse(JSON.stringify(l)),d;switch(t){case"user":d=this.commonDbUtilsService.mergeUsersWithData({feature:"allActivities",data:c});break;case"comment":d=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allActivities",data:c});break;case"reaction":d=this.commonDbUtilsService.mergeReactionAnnotationsWithData({feature:"allActivities",data:c});break;case"recorder":d=this.commonDbUtilsService.mergeRecorderAnnotationsWithData({feature:"allActivities",data:c});break;case"activity":d=this.commonDbUtilsService.mergeActivityResolverWithData({feature:"allActivities",data:c});break}d?.length&&this.appendActivities(d)}catch(i){this.loggingService.catch("Error in ActivityService resolveAndUpdateActivities:",i)}}appendActivities(e){try{let t=this.allActivities$.getValue()??[],i=new Map;e.forEach(g=>{g.id&&i.set(g.id,g)});let a=t.map(g=>i.get(g.id)??g),l=new Set(t.map(g=>g.id)),d=[...e.filter(g=>!l.has(g.id)),...a].sort((g,u)=>(u.timestamp??0)-(g.timestamp??0));if(d.forEach(g=>{g.displayMessage=this.activityUtilsService.getActivityDisplayMessage(g)}),this.activitiesEqual(t,d))return;this.allActivities$.next(d),this.subscriptions.forEach(g=>{this.distributeActivitiesToSubscription(g)})}catch(t){this.loggingService.catch("Error in ActivityService appendActivities:",t)}}distributeActivitiesToSubscription(e){try{let t=this.allActivities$.getValue();if(t===null)return;let i=e.config,a;if(i.currentDocumentOnly){let c=this.docService.getDocumentPaths()?.documentId;a=c?t.filter(d=>d.metadata?.documentId===c):[]}else if(i.documentIds?.length){let c=new Set(i.documentIds.map(d=>pi(d)));a=t.filter(d=>d.metadata?.documentId&&c.has(d.metadata.documentId))}else a=t;if(i.featureTypes?.length){let c=new Set(i.featureTypes);a=a.filter(d=>c.has(d.featureType))}else if(i.excludeFeatureTypes?.length){let c=new Set(i.excludeFeatureTypes);a=a.filter(d=>!c.has(d.featureType))}if(i.actionTypes?.length){let c=new Set(i.actionTypes);a=a.filter(d=>c.has(d.actionType))}else if(i.excludeActionTypes?.length){let c=new Set(i.excludeActionTypes);a=a.filter(d=>!c.has(d.actionType))}if(i.userIds?.length){let c=new Set(i.userIds);a=a.filter(d=>d.actionUser?.userId&&c.has(d.actionUser.userId))}else if(i.excludeUserIds?.length){let c=new Set(i.excludeUserIds);a=a.filter(d=>!d.actionUser?.userId||!c.has(d.actionUser.userId))}let l=e.activities$.getValue();if(l!==null&&this.activitiesEqual(l,a))return;e.activities$.next(a)}catch(t){this.loggingService.catch("Error in ActivityService distributeActivitiesToSubscription:",t)}}resetCurrentDocumentSubscriptions(){try{this.subscriptions.forEach(e=>{e.config.currentDocumentOnly&&e.activities$.getValue()!==null&&e.activities$.next(null)})}catch(e){this.loggingService.catch("Error in ActivityService resetCurrentDocumentSubscriptions:",e)}}activitiesEqual(e,t){try{if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i].id!==t[i].id)return!1;return JSON.stringify(e)===JSON.stringify(t)}catch(i){return this.loggingService.catch("Error in ActivityService activitiesEqual:",i),!1}}getCombinedSubscriptionScope(){try{let e=!1,t=!1,i,a=new Set,l=HU;this.subscriptions.forEach(d=>{let g=d.config;g.organizationId&&(i=g.organizationId),g.currentDocumentOnly?t=!0:g.documentIds?.length?g.documentIds.forEach(u=>a.add(u)):e=!0,g.maxDays&&g.maxDays>l&&(l=g.maxDays)});let c={organizationId:i,maxDays:l};return e?h({type:$g.ORG_WIDE},c):t&&a.size>0?h({type:$g.CURRENT_DOCUMENT,documentIds:Array.from(a)},c):t?h({type:$g.CURRENT_DOCUMENT},c):a.size>0?h({type:$g.DOCUMENTS,documentIds:Array.from(a)},c):h({type:$g.ORG_WIDE},c)}catch(e){return this.loggingService.catch("Error in ActivityService getCombinedSubscriptionScope:",e),{type:$g.ORG_WIDE,organizationId:void 0,maxDays:HU}}}getStartAtTimestamp(e){try{let t=new Date,i=e>0?e:HU;return t.setDate(t.getDate()-i),t.getTime()}catch(t){return this.loggingService.catch("Error in ActivityService getStartAtTimestamp:",t),0}}cleanup(){try{this.triggerListenerSubscription?.unsubscribe(),this.triggerListenerSubscription=void 0,this.emptyStateTimeoutId&&(clearTimeout(this.emptyStateTimeoutId),this.emptyStateTimeoutId=void 0),this.subscriptions.forEach(e=>e.activities$.complete()),this.subscriptions.clear(),this.allActivities$.next(null),this.fetchedEntityIds.clear()}catch(e){this.loggingService.catch("Error in ActivityService cleanup:",e)}}destroy(){try{this.cleanup(),this.authSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in ActivityService destroy:",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(Vp),Z(LS),Z(Ke),Z(dl),Z(is),Z(vl),Z(kn),Z(bd),Z(Lt),Z(st),Z(Oo),Z(k),Z(Mn),Z(Oa))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})(),$g=(function(n){return n.ORG_WIDE="orgWide",n.DOCUMENTS="documents",n.CURRENT_DOCUMENT="currentDocument",n})($g||{}),HU=30;var fr=class{constructor(o){this.injector=o,this.hideAnalytics=!1}ha(o){try{this.hideAnalytics=o}catch{}}getService(o){return this.injector.get(o)}trackEvent(o,r={},e=!0){try{this.hideAnalytics||(r||(r={}),r=y(h({},r),{source:"external"}),this.getService(ct).trackAuthenticatedEvent(o,r,e))}catch(t){this.getService(k).catch("Error in _trackEvent: ",t);return}}};var zU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ActivityElement","color: blue;"),this.getAllActivities=this._getAllActivities,this.createActivity=this._createActivity}_getAllActivities(o){this.getService(k).log("%c[WB] Calling FUNCTION: getAllActivities","color: green;");try{let r=this.getService(L_e),e=this.getService(Gg).subscribe(o);return new Vt(t=>{let i=e.getActivities$().pipe(ge(a=>a?.map(l=>r.getActivityForClient(l))??null)).subscribe(t);return()=>{i.unsubscribe(),e.unsubscribe()}})}catch(r){return this.getService(k).catch("Error in _getAllActivities: ",r),de(null)}}_createActivity(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: createActivity","color: green;");try{yield this.getService(Gg).createActivity(o)}catch(r){this.getService(k).catch("Error in _createActivity: ",r)}})}};var WU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Cv).enableArea()}catch(o){this.getService(k).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Cv).disableArea()}catch(o){this.getService(k).catch("Error in _disableAreaComment: ",o)}}};var Tm=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A){this.analyticsService=e,this.configService=t,this.docService=i,this.databaseService=a,this.authService=l,this.domService=c,this.afAuth=d,this.iamService=g,this.dialog=u,this.loggingService=_,this.notificationService=w,this.commonDbService=A,this.arrowAnnotations$=new Se({}),this.arrowAnnotationsByDocumentId$=new Se({}),this.documentPaths=null,this.allowedElementIds$=new Se([]),this.addArrowMode$=new Se(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe($e(M=>!!M),ut(1)).subscribe(M=>{M&&this.getDocumentPaths()},M=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",M)}),this.domService.onWindowPointerMove$().subscribe(M=>{if(this.addArrowMode$.value){let j=!0,q=this.domService.getBackgroundElement(M.clientX,M.clientY);q&&(this.isElementInsideAllowedElements(q)?YF(M.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==q&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=q,this.domService.highlightElement(this.highlightElement,F.CURSOR.ARROW_PIN),j=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&j&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},M=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",M)}),this.domService.onWindowKeyupEsc$().subscribe(M=>{this.addArrowMode$.value&&this.disableAddArrowMode()},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",M)}),this.domService.onDocumentClick$().subscribe(M=>{if(M&&this.addArrowMode$.value){if(!YF(M.target)){let j=this.domService.getBackgroundElement(M.clientX,M.clientY);j&&this.isElementInsideAllowedElements(j)&&(M.preventDefault(),M.stopPropagation(),this.addArrow(M))}this.disableAddArrowMode()}},M=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",M)}),this.addArrowMode$.subscribe(M=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),M?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},M=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",M)}),this.domService.onWindowKeyupBackspace$().subscribe(M=>{this.deleteArrowPinAnnotations("keyupBackspace")},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",M)}),this.domService.onWindowKeyupDelete$().subscribe(M=>{this.deleteArrowPinAnnotations("keyupDelete")},M=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",M)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(e,t,i){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,l;try{if(e&&(l=tr(e)),t&&typeof t=="object"){let c=Ai(t);a=tr(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",c)}return _r(this.afAuth).pipe($e(c=>!!c),ye(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),ye(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(d=>(c.featureAllowed=d,c))):de(c)),ye(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(ge(d=>(c.featureAllowed=!d,c))):de(c)),ye(c=>c.featureAllowed?de(c).pipe(ye(d=>this.docService.getDocumentPaths$().pipe(ge(g=>(this.documentPaths=g,d.documentPaths=g,d)))),ye(d=>this.getDataFromDocumentId(l).pipe(ge(g=>(d.annotations=g||[],h({},d))))),ye(d=>this.docService.getLocation$().pipe(ge(g=>(d.location=g,d)))),ye(d=>this.docService.getLocations$().pipe(ge(g=>(d.customLocations=g,d)))),ge(d=>{if(d.filteredAnnotations=[],l&&!a)return d.filteredAnnotations=d.annotations?.slice(),d;{let g=[];return a?g.push(a):(g.push(d?.location?.locationId),g.push(...Object.values(d?.customLocations||[]).map(u=>u.locationId))),d.filteredAnnotations=this.filterAnnotationsByLocationIds(d?.annotations,g),d}}),ye(d=>i?de(d):d?.annotations?.length?this.domService.onWindowResize$().pipe(ge(()=>d)):de(d)),ye(d=>i?de(d):d?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(ge(()=>d)):de(d)),ge(d=>(d?.filteredAnnotations?.forEach(g=>{this.calculateArrowAnnotationPosition(g)}),d)),ye(d=>d?.filteredAnnotations?de(d?.filteredAnnotations||[]):de([]))):de([])),bt(Zt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.ARROW)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe($e(t=>!!t),ye(t=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:e??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ge(i=>({data:i?.data,operation:i?.operation})),ge(({data:i,operation:a})=>{let l=[];return i&&(l=Object.values(i).filter(c=>typeof c=="object")),{data:l,operation:a}}),Gn(i=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",i),de({data:[],operation:null}))),ge(({data:i,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let l=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(c=>{delete l?.[c]}),this.arrowAnnotationsByDocumentId$.next(l)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,i);return i})):de([])))}setArrowAnnotationsByDocumentId(e,t){try{if(e){let i=y(h({},this.arrowAnnotationsByDocumentId$.value),{[e]:t});this.arrowAnnotationsByDocumentId$.next(i)}}catch(i){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",i)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(i=>t.includes(i.locationId))}catch(i){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",i),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let i=t.iterateNext();if(i&&Xr(i)){let a=i.getBoundingClientRect();if(a&&a.width&&a.height){let{height:l,width:c}=vp(i);e.position={top:l*e.targetElement.topPercentage/100,left:c*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(t){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",t)}}addArrow(e){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let t=this.authService.getUser();if(t)if(t.isReadOnly||t.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let i=new IF;i.from=t,i.color=t?.color||F.DEFAULT_ANNOTATION_COLOR,i.lastUpdated=this.timestamp,i.props=new ud;let a=this.domService.getCurrentWindowSizeValue();if(i.props.screenWidth=a.screenWidth,i.props.screenHeight=a.screenHeight,i.props.screenScrollHeight=a.screenScrollHeight,i.props.viewportWidth=window.innerWidth,i.props.viewportHeight=window.innerHeight,i.props.arrowLength=F.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>F.VELT_MIN_ARROW_LENGTH?i.props.arrowAngle=135:i.props.arrowAngle=45,e&&(i.targetElement=this.domService.getTargetElementForCursorPosition(e)),i?.targetElement?.xpath){let l=this.domService.getXPath(i.targetElement.xpath);if(l){let c=l.iterateNext();c&&(Xr(c)||(i.targetElement=null))}}this.setLocationToArrowAnnotation(i),i.pageInfo=io(),i.pageInfo&&(i.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(i)}}catch(t){this.loggingService.catch("Error in ArrowService addArrow: ",t)}}setLocationToArrowAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location);try{if(e.targetElement?.xpath){let i=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(i);if(a){let l=this.docService.addLocation({location:a,source:"internal"});l?.[0]&&(e.locationId=l[0].locationId,e.location=l[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",t)}}saveArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(je.ARROW)&&this.docService.getDocumentPaths$().pipe($e(t=>!!t),ut(1),ye(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(i=>!!i),ut(1),ye(i=>{if(this.documentPaths?.arrow){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.arrowUrl=this.generateArrowUrl(e));let a=JSON.parse(JSON.stringify(e));return a.position=null,this.domService.toggleAnnotationSelection(a),this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:e.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}else return de(null)}))))).subscribe(()=>{},t=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",t)}}updateArrow(e,t=!1,i){try{i&&this.setLocationToArrowAnnotation(e),t&&this.updateNotificationsDatabase(e,SF.UPDATED),this.updateArrowToDb(e)}catch(a){this.loggingService.catch("Error in ArrowService updateArrow: ",a)}}updateArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(e?.targetElement?.xpath){let t=this.domService.getXPath(e.targetElement.xpath);if(t){let i=t.iterateNext();i&&(Xr(i)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(je.ARROW)&&this.docService.getDocumentPaths$().pipe($e(t=>!!t),ut(1),ye(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe($e(i=>!!i),ut(1),ye(i=>{if(this.documentPaths?.arrow&&e?.annotationId){let a=JSON.parse(JSON.stringify(e));return a.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}else return de(null)}))))).subscribe(()=>{},t=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",t)}}deleteArrowPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),i=this.authService.getUser(),a=[];Object.keys(t).forEach(l=>X(this,null,function*(){let c=t[l];if(c.type==="arrow"){let d=i&&!i?.isAnonymous&&!i?.isGuest;i&&c.from&&(d||c.from.userId===i.userId)&&a.push(c)}})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(l=>l.annotationId).join()}),this.dialog.open(ml,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(ut(1)).subscribe(l=>{l&&(a.forEach(c=>X(this,null,function*(){yield this.deleteArrowPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${F.SNIPPYLY_HIGHLIGHT}]`).forEach(d=>{this.domService.removeHighlightFromElement(d)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(t){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",t)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(je.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,SF.DELETED),this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETED,{annotationId:e.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(je.ARROW)?(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let i={annotationData:e,actionType:t,notificationSource:"arrow"};this.notificationService.updateNotificationDatabase(i)}catch(i){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",i)}}getArrowUrl(e){try{return e?.pageInfo?.arrowUrl?e.pageInfo.arrowUrl:(e?.pageInfo||(e.pageInfo=io(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.arrowUrl=this.generateArrowUrl(e),this.updateArrow(e),e.pageInfo?.arrowUrl)}catch(t){this.loggingService.catch("Error in ArrowService getArrowUrl: ",t);return}}generateArrowUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(F.URL_PARAMS.TAG_ID),t.searchParams.append(F.URL_PARAMS.TAG_ID,e.annotationId),t.href}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Lt),Z(st),Z(Hn),Z(Ke),Z(Ve),Z(no),Z(Vn),Z(Vo),Z(k),Z(cn),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var YU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(Tm).setAllowedElementIds(o)}catch(r){this.getService(k).catch("Error in allowedElementIds: ",r)}}};var Pc=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Se({}),this.onAutocompleteChipClick$=new it;try{this.loggingService.log("%c[WB] Creating CLASS: AutocompleteService","color: blue;"),this.create({hotkey:"@",type:"contact",data:[]})}catch(t){this.loggingService.catch("Error in AutocompleteService constructor: ",t)}}create(e){try{if(this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: create","color: green;"),e?.hotkey){let t=this.autocompleteDataMap$.value;t[e.hotkey]=e,this.autocompleteDataMap$.next(t)}}catch(t){this.loggingService.catch("Error in AutocompleteService create: ",t)}}remove(e){try{this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: remove","color: green;");let t=this.autocompleteDataMap$.value;delete t[e],this.autocompleteDataMap$.next(t)}catch(t){this.loggingService.catch("Error in AutocompleteService remove: ",t)}}getAutocompleteDataMap$(){return this.autocompleteDataMap$.asObservable()}getAutocompleteDataMap(){return this.autocompleteDataMap$.value}setOnAutocompleteChipClick(e){this.onAutocompleteChipClick$.next(e)}getOnAutocompleteChipClick$(){return this.onAutocompleteChipClick$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var KU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(k).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(Pc).create(o)}catch(r){this.getService(k).catch("Error in _create: ",r)}}_onAutocompleteChipClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(Pc).getOnAutocompleteChipClick$()}catch(o){return this.getService(k).catch("Error in _onAutocompleteChipClick: ",o),de(null)}}};var U_e=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g){this.authService=e,this.iamService=t,this.docService=i,this.configService=a,this.commonDbService=l,this.loggingService=c,this.commentService=d,this.userPermissionService=g,this.documentPaths=null,this.LISTENER_BATCH_SIZE=5}getAnnotationsCount(e){try{return this.authService.getUser$().pipe($e(t=>!!t),ye(t=>this.docService.getOrganizationConfig$().pipe($e(i=>!!i),ge(()=>t))),ye(t=>this.commentService.isFeatureAllowed({firebaseUser:t,annotations:[],filteredAnnotations:[]})),ye(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(i=>(t.featureAllowed=i,t))):de(t)),ye(t=>t.featureAllowed?this.processRequest(t,e):de(null)),ge(t=>t??{data:null}),bt(Zt))}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",t),de({data:null})}}processRequest(e,t){try{return de(e).pipe(ye(()=>this.initializeDocumentPaths(t,e)),ye(()=>this.getDocumentIds$(t)),ye(i=>{let a=this.authService.getUser()?.userSnippylyId,l=this.buildRequestContext(t,i);if(!this.validateRequestContext(l,t))return de({data:null,mode:l.mode,serverDocumentIds:l.serverDocumentIds});if(!l.organizationId)return de({data:null,mode:l.mode,serverDocumentIds:l.serverDocumentIds});let c=this.setupTriggers$(l.mode,l.organizationId,l.clientOrganizationId,l.veltFolderId,l.serverDocumentIds);if(this.shouldUseAggregateMode(l.mode))return this.handleAggregateCounts$({triggers$:c,serverDocumentIds:l.serverDocumentIds,request:t,userId:a,organizationId:l.organizationId,clientOrganizationId:l.clientOrganizationId,veltFolderId:l.veltFolderId,folderId:l.folderId,mode:l.mode}).pipe(ge(d=>({data:d,mode:l.mode,serverDocumentIds:l.serverDocumentIds})));if(l.mode.isBatchedGroupedMode){let d=t?.debounceMs??5e3;return this.handleBatchedGroupedCounts$({triggers$:c,documentIds:i,request:t,userId:a,organizationId:l.organizationId,veltFolderId:l.veltFolderId,debounceMs:d}).pipe(ge(g=>({data:g,mode:l.mode,serverDocumentIds:l.serverDocumentIds})))}else return this.handleGroupedCounts$(c,i,t,a,l.organizationId,l.veltFolderId).pipe(ge(d=>({data:d,mode:l.mode,serverDocumentIds:l.serverDocumentIds})))}),ye(i=>{if(!i?.data)return de(null);let{data:a,mode:l,serverDocumentIds:c}=i;return t?.filterGhostComments?this.filterGhostComments$(a,l,c):de(a)}),Gn(i=>(this.loggingService.catch("Error processing request: ",i),de(null))))}catch(i){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",i),de(null)}}initializeDocumentPaths(e,t){try{return e?de(t):this.docService.getDocumentPaths$().pipe($e(i=>!!i),dn(i=>{this.documentPaths=i,t.documentPaths=i}),ge(()=>{}))}catch(i){return this.loggingService.catch("Error in CommentService initializeDocumentPaths: ",i),de(t)}}buildRequestContext(e,t){try{let i=this.docService.getOrganizationConfig(),a=this.documentPaths?.organizationId??i?.organizationId,l=this.documentPaths?.clientOrganizationId??i?.clientOrganizationId,c,d,g;if(e?.allDocuments||e?.documentIds||e?.folderId||e?.organizationId||e?.locationIds){if(e.organizationId&&(a=ka(e.organizationId),l=e.organizationId),!a)throw new Error("organizationId is required for this request type");e.folderId&&(c=Br(e.folderId),d=e.folderId),e.allDocuments&&(g=!0)}else c=this.documentPaths?.veltFolderId,d=this.documentPaths?.folderId,g=this.documentPaths?.allDocuments;let u=this.determineMode(e,c,g,t),_=u.isOrgMode?[]:t.length>0?t.map(w=>w.documentId):[this.documentPaths?.documentId??""];return{organizationId:a,clientOrganizationId:l,veltFolderId:c,folderId:d,allDocuments:g,mode:u,serverDocumentIds:_}}catch(i){return this.loggingService.catch("Error in CommentService buildRequestContext: ",i),{organizationId:void 0,clientOrganizationId:void 0,veltFolderId:void 0,folderId:void 0,allDocuments:void 0,mode:{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1,isBatchedGroupedMode:!1},serverDocumentIds:[]}}}validateRequestContext(e,t){try{if(t?.aggregateDocuments&&!e.serverDocumentIds.length)throw this.loggingService.catch("Error in CommentService getAnnotationsCount: documentIds is required when aggregateDocuments is true"),new Error("documentIds is required when aggregateDocuments is true");return!(!e.organizationId||!(e.mode.isOrgMode||e.mode.isFolderMode)&&e.serverDocumentIds.some(i=>!i))}catch(i){return this.loggingService.catch("Error in CommentService validateRequestContext: ",i),!1}}shouldUseAggregateMode(e){try{return e.isFolderMode||e.isOrgMode||e.isBatchMode}catch(t){return this.loggingService.catch("Error in CommentService shouldUseAggregateMode: ",t),!1}}getDocumentIds$(e){try{return e?.documentIds?.length?de(e.documentIds.map(t=>({clientDocumentId:t,documentId:pi(t)}))):this.docService.getDocumentIds$().pipe(ge(t=>t.length>0?t:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIds: ",t),de([])}}determineMode(e,t,i,a){try{let l=!!e?.organizationId&&!e?.documentIds?.length&&!t&&!i,c=!!t&&!!i,d=!!e?.aggregateDocuments&&!i&&!!a?.length,g=(!!e?.batchedPerDocument||a.length>1)&&!!a?.length&&!e?.aggregateDocuments&&!i;return{isOrgMode:l,isFolderMode:c,isBatchMode:d,isBatchedGroupedMode:g}}catch(l){return this.loggingService.catch("Error in CommentService determineMode: ",l),{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1,isBatchedGroupedMode:!1}}}setupTriggers$(e,t,i,a,l){try{if(e.isOrgMode){let c=this.authService.getUser()?.userId??"";return[so(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:i})??Promise.resolve({})).pipe(ye(g=>c&&g?.[c]?.organization?.[i]?.errorCode===mr.PERMISSION_DENIED?(this.loggingService.log(`%c[WB] commentViews org listener skipped \u2014 user does not have access to organization: ${i}`,"color: orange;"),Ya):this.commonDbService.dbListener({feature:"organizationMetadata",properties:{useCollectionGroup:!1,isCollection:!1,organizationId:t}}))).pipe(ge(g=>g?.data?.commentViewsUpdatedAt??null),$e(g=>!!g),bt(Zt))]}else{if(e.isFolderMode)return[this.commonDbService.dbListener({feature:"folder",properties:{useCollectionGroup:!1,isCollection:!1,folderId:a,organizationId:t}}).pipe(ge(d=>d?.data?.commentViewsUpdatedAt??null),$e(d=>!!d),bt(Zt))];if(e.isBatchMode||e.isBatchedGroupedMode){let c=[];for(let d=0;d<l.length;d+=this.LISTENER_BATCH_SIZE)c.push(l.slice(d,d+this.LISTENER_BATCH_SIZE));return c.map(d=>this.commonDbService.dbListener({feature:"allDocuments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:[yr(ft("metadata.apiKey","==",this.configService?.getApiKey()),ft("metadata.organizationId","==",t),ft("metadata.documentId","in",d))]}}).pipe(ge(u=>Object.values(u?.data||{}).map(w=>w?.commentViewsUpdatedAt??null).sort().join(",")),bt(Zt)))}else return l.map(c=>this.commonDbService.dbListener({feature:"documentMetadata",properties:{useCollectionGroup:!1,isCollection:!1,documentId:c,organizationId:t}}).pipe(ge(g=>g?.data?.commentViewsUpdatedAt??null),$e(g=>!!g),bt(Zt)))}}catch(c){return this.loggingService.catch("Error in CommentService setupTriggers: ",c),[]}}handleGroupedCounts$(e,t,i,a,l,c){try{let d=t.map((g,u)=>e[u].pipe(yo(void 0),ye(()=>so(this.getCountsForDocument$(g.documentId,g.clientDocumentId,i,a,l,c)))));return mn(d).pipe(ge(g=>{let u={};return g.forEach(_=>{_&&(u[_.clientDocumentId]={total:_.total,unread:_.unread})}),{data:u}}),Gn(g=>(this.loggingService.catch("Error in grouped counts: ",g),de(null))))}catch(d){return this.loggingService.catch("Error in CommentService handleGroupedCounts: ",d),de(null)}}handleBatchedGroupedCounts$(e){try{let{triggers$:t,documentIds:i,request:a,userId:l,organizationId:c,veltFolderId:d,debounceMs:g}=e,u=this.LISTENER_BATCH_SIZE,_=new Pd(1),w=t.map((q,ie)=>q.pipe(Bj(_),ge(()=>ie))),A=Lo(...w).pipe(to(g)),M=de(-1).pipe(ye(()=>so(this.fetchAllDocumentCounts$(i,a,l,c,d))),ge(q=>({batchIndex:-1,data:q?.data||{}})),dn(()=>{_.next()})),j=A.pipe(ye(q=>{let ie=q*u,_e=Math.min(ie+u,i.length),ae=i.slice(ie,_e);return so(this.fetchAllDocumentCounts$(ae,a,l,c,d)).pipe(ge(ue=>({batchIndex:q,data:ue?.data||{}})))}));return Lo(M,j).pipe(Pb((q,ie)=>({data:h(h({},q.data),ie.data)}),{data:{}}),Gn(q=>(this.loggingService.catch("Error in batched grouped counts: ",q),de(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleBatchedGroupedCounts: ",t),de(null)}}fetchAllDocumentCounts$(e,t,i,a,l){return X(this,null,function*(){try{let c=e.map(u=>this.getCountsForDocument$(u.documentId,u.clientDocumentId,t,i,a,l)),d=yield Promise.allSettled(c),g={};return d.forEach(u=>{if(u.status==="fulfilled"&&u.value){let{clientDocumentId:_,total:w,unread:A}=u.value;g[_]={total:w,unread:A}}}),{data:g}}catch(c){return this.loggingService.catch("Error in CommentService fetchAllDocumentCounts: ",c),null}})}handleAggregateCounts$(e){try{let{triggers$:t,serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}=e;return mn(t).pipe(ge(()=>{})).pipe(yo(void 0),ye(()=>so(this.getAggregateCounts({serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}))),Gn(A=>(this.loggingService.catch("Error in aggregate counts: ",A),de(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleAggregateCounts: ",t),de(null)}}getCountsForDocument$(e,t,i,a,l,c){return X(this,null,function*(){try{let d=this.configService?.getApiKey(),g={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},u=[ft("metadata.apiKey","==",d),ft("metadata.organizationId","==",l),ft("metadata.documentId","in",[e]),...c?[ft("metadata.veltFolderId","==",c)]:[],...i?.statusIds?.length?[ft("status.id","in",i.statusIds)]:[],...i?.locationIds?.length?[ft("location.id","in",i.locationIds)]:[],...i?.agentFields?.length?[ft("agent.agentFields","array-contains-any",i.agentFields)]:[]],_=[yr(...u),po("lastUpdated","desc"),po("createdAt","desc")],w=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},g),{firestoreQuery:_})}),A=0;if(!i?.agentFields?.length){let M=[...u,ft("viewedByUserIds","array-contains",a)],j=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];A=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},g),{firestoreQuery:j})})}return{clientDocumentId:t,total:w,unread:w-A}}catch(d){return this.loggingService.catch("Error in CommentService getCountsForDocument: ",d),null}})}getAggregateCounts(e){return X(this,null,function*(){try{let t="",{serverDocumentIds:i,request:a,userId:l,organizationId:c,clientOrganizationId:d,veltFolderId:g,folderId:u,mode:_}=e,w=this.configService?.getApiKey(),A={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},M=[ft("metadata.apiKey","==",w),ft("metadata.organizationId","==",c),...a?.statusIds?.length?[ft("status.id","in",a.statusIds)]:[],...a?.locationIds?.length?[ft("location.id","in",a.locationIds)]:[],...a?.agentFields?.length?[ft("agent.agentFields","array-contains-any",a.agentFields)]:[]],j,q=0;if(_.isFolderMode){t=u??"",M.push(ft("metadata.veltFolderId","==",g));let ie=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];if(j=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ie})}),!a?.agentFields?.length){let _e=[...M,ft("viewedByUserIds","array-contains",l)],ae=[yr(..._e),po("lastUpdated","desc"),po("createdAt","desc")];q=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ae})})}}else if(_.isOrgMode){t=d??"";let ie=[yr(...M),po("lastUpdated","desc"),po("createdAt","desc")];if(j=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ie})}),!a?.agentFields?.length){let _e=[...M,ft("viewedByUserIds","array-contains",l)],ae=[yr(..._e),po("lastUpdated","desc"),po("createdAt","desc")];q=yield this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:ae})})}}else{t="result";let ie=[];for(let ue=0;ue<i.length;ue+=this.LISTENER_BATCH_SIZE)ie.push(i.slice(ue,ue+this.LISTENER_BATCH_SIZE));let _e=ie.map(ue=>X(this,null,function*(){let Ie=[...M,ft("metadata.documentId","in",ue),...g?[ft("metadata.veltFolderId","==",g)]:[]],fe=[yr(...Ie),po("lastUpdated","desc"),po("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:fe})})}));if(j=(yield Promise.allSettled(_e)).reduce((ue,Ie)=>ue+(Ie.status==="fulfilled"&&Ie.value||0),0),!a?.agentFields?.length){let ue=ie.map(fe=>X(this,null,function*(){let we=[...M,ft("metadata.documentId","in",fe),...g?[ft("metadata.veltFolderId","==",g)]:[],ft("viewedByUserIds","array-contains",l)],Ae=[yr(...we),po("lastUpdated","desc"),po("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:y(h({},A),{firestoreQuery:Ae})})}));q=(yield Promise.allSettled(ue)).reduce((fe,we)=>fe+(we.status==="fulfilled"&&we.value||0),0)}}return{data:{[t]:{total:j,unread:j-q}}}}catch(t){return this.loggingService.catch("Error in CommentService getAggregateCounts: ",t),null}})}filterGhostComments$(e,t,i){try{return e?this.commentService.getGhostCommentAnnotationMap$().pipe(ge(a=>{if(!a)return e;let l=this.buildGhostCommentAnnotationMap(a),c=this.groupGhostCommentsByModeId(l,t,i);return this.adjustCountsForGhostComments(e,c),e})):de(null)}catch(a){return this.loggingService.catch("Error in CommentService filterGhostComments: ",a),de(null)}}buildGhostCommentAnnotationMap(e){let t={};return Object.keys(e).forEach(i=>{let a=this.commentService.getAnnotationById(i);a&&(t[i]=a)}),t}groupGhostCommentsByModeId(e,t,i){try{let a={};return Object.values(e).forEach(l=>{let c=this.getModeIdForAnnotation(l,t,i);c&&(a[c]||(a[c]=[]),a[c].push(l))}),a}catch(a){return this.loggingService.catch("Error in CommentService groupGhostCommentsByModeId: ",a),{}}}getModeIdForAnnotation(e,t,i){try{return t.isOrgMode?e?.metadata?.clientOrganizationId||null:t.isFolderMode?e?.metadata?.folderId||null:t.isBatchMode?i.includes(e?.metadata?.documentId??"")?"result":null:e?.metadata?.clientDocumentId||null}catch(a){return this.loggingService.catch("Error in CommentService getModeIdForAnnotation: ",a),null}}adjustCountsForGhostComments(e,t){try{if(typeof e?.data!="object")return;let a=this.authService.getUser()?.userSnippylyId;Object.keys(e.data||{}).forEach(l=>{let c=t[l];if(!(!c||!e?.data?.[l]?.total)&&(e.data[l].total=Math.max(0,e.data[l].total-c.length),a)){let d=c.filter(g=>g?.viewedByUserIds&&!g?.viewedByUserIds?.includes(a));d.length>0&&(e.data[l].unread=Math.max(0,e.data[l].unread-d.length))}})}catch(i){this.loggingService.catch("Error in CommentService adjustCountsForGhostComments: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(Ke),Z(Vn),Z(st),Z(Lt),Z(kn),Z(k),Z(Re),Z(Oa))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ZU=(()=>{let o=class o{constructor(e){this.loggingService=e,this.enabledSignal=De(!1),this.onTargetEditStart=null,this.onTargetEditCommit=null;try{this.enabled$=gde(this.enabledSignal).pipe(bt())}catch(t){this.loggingService.catch("Error in SuggestionModeService constructor: ",t),this.enabled$=new Vt}}enable(e){try{this.onTargetEditStart=e?.onTargetEditStart??null,this.onTargetEditCommit=e?.onTargetEditCommit??null,this.enabledSignal.set(!0)}catch(t){this.loggingService.catch("Error in SuggestionModeService enable: ",t)}}disable(){try{this.onTargetEditStart=null,this.onTargetEditCommit=null,this.enabledSignal.set(!1)}catch(e){this.loggingService.catch("Error in SuggestionModeService disable: ",e)}}isEnabled(){try{return this.enabledSignal()}catch(e){return this.loggingService.catch("Error in SuggestionModeService isEnabled: ",e),!1}}getOnTargetEditStart(){try{return this.onTargetEditStart}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditStart: ",e),null}}getOnTargetEditCommit(){try{return this.onTargetEditCommit}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditCommit: ",e),null}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var JU=(()=>{let o=class o{constructor(e){this.loggingService=e,this.snapshots=new Map}captureFromGetter(e,t){try{if(!e||typeof t!="function")return!1;let i;try{i=t()}catch(a){return dm()&&this.loggingService.catch(`[velt] Suggestion target "${e}" getter threw: `,a),!1}return this.captureValue(e,i)}catch(i){return this.loggingService.catch("Error in SuggestionSnapshotService captureFromGetter: ",i),!1}}captureValue(e,t){try{if(!e)return!1;let i;try{i=structuredClone(t)}catch(a){return dm()&&this.loggingService.catch(`[velt] Suggestion target "${e}" snapshot failed (value not cloneable). Cause: structuredClone rejected the value (cyclic refs, DOM nodes, or functions are common culprits). Fix: ensure your getter returns plain JSON-serializable data.`,a),!1}return this.snapshots.set(e,i),!0}catch(i){return this.loggingService.catch("Error in SuggestionSnapshotService captureValue: ",i),!1}}getSnapshot(e){try{return this.snapshots.has(e)?this.snapshots.get(e):void 0}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService getSnapshot: ",t);return}}hasSnapshot(e){try{return this.snapshots.has(e)}catch(t){return this.loggingService.catch("Error in SuggestionSnapshotService hasSnapshot: ",t),!1}}clearSnapshot(e){try{this.snapshots.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService clearSnapshot: ",t)}}clearAllSnapshots(){try{this.snapshots.clear()}catch(e){this.loggingService.catch("Error in SuggestionSnapshotService clearAllSnapshots: ",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var GS=(()=>{let o=class o{constructor(e,t,i){this.loggingService=e,this.modeService=t,this.snapshotService=i,this.registry=new Map,this.warnedUnstableIds=new Set,this.actionsService=null}registerTarget(e,t){try{if(!e||typeof t!="function")return;this.warnIfUnstableId(e);let i=this.registry.get(e)??{};i.getter=t,this.registry.set(e,i)}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService registerTarget: ",i)}}unregisterTarget(e){try{let t=this.registry.get(e);if(!t)return;delete t.getter,t.node||this.registry.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService unregisterTarget: ",t)}}getGetter(e){try{return this.registry.get(e)?.getter}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getGetter: ",t);return}}setActionsService(e){try{this.actionsService=e}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService setActionsService: ",t)}}getNode(e){try{if(!e)return;let t=this.registry.get(e)?.node;if(t&&t.isConnected)return t;let i=this.queryAll(e);if(i.length===0)return;i.length>1&&this.warnDuplicateId(e,i.length);let a=i[0],l=this.registry.get(e)??{};return l.node=a,this.registry.set(e,l),a}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getNode: ",t);return}}getFallbackValue(e){try{let t=this.getNode(e);if(!t)return{hasValue:!1};let i=t.textContent??"";return i.length>0?{hasValue:!0,value:i}:{hasValue:!1}}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService getFallbackValue: ",t),{hasValue:!1}}}isRegistered(e){try{return this.registry.get(e)?.getter?!0:!!this.getNode(e)}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isRegistered: ",t),!1}}countTaggedElements(e){try{let t=e??this.rootEl??document.body;return t?t.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).length:0}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService countTaggedElements: ",t),0}}startObserving(e=document.body){try{if(this.observer)return;this.rootEl=e,this.scanAndRefresh(e),this.observer=new MutationObserver(()=>{try{this.scanAndRefresh(this.rootEl??document.body)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService observer callback: ",t)}}),this.observer.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[F.ATTRIBUTES.VELT_SUGGESTION_TARGET]}),this.installDelegatedListeners(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService startObserving: ",t)}}stopObserving(){try{this.observer?.disconnect(),this.observer=void 0,this.rootEl&&this.removeDelegatedListeners(this.rootEl),this.rootEl=void 0}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService stopObserving: ",e)}}clear(){try{this.registry.clear(),this.warnedUnstableIds.clear()}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService clear: ",e)}}installDelegatedListeners(e){try{this.boundFocusIn=t=>this.handleFocusIn(t),this.boundChange=t=>this.handleChange(t),this.boundFocusOut=t=>this.handleFocusOut(t),e.addEventListener("focusin",this.boundFocusIn,!0),e.addEventListener("change",this.boundChange,!0),e.addEventListener("focusout",this.boundFocusOut,!0)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService installDelegatedListeners: ",t)}}removeDelegatedListeners(e){try{this.boundFocusIn&&e.removeEventListener("focusin",this.boundFocusIn,!0),this.boundChange&&e.removeEventListener("change",this.boundChange,!0),this.boundFocusOut&&e.removeEventListener("focusout",this.boundFocusOut,!0),this.boundFocusIn=void 0,this.boundChange=void 0,this.boundFocusOut=void 0}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService removeDelegatedListeners: ",t)}}handleFocusIn(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t)return;this.captureSnapshotForTarget(t.targetId,t.element);let i=this.snapshotService.getSnapshot(t.targetId),a={targetId:t.targetId,oldValue:i,newValue:i,element:t.element},l=this.modeService.getOnTargetEditStart();if(l)try{l(a)}catch(c){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditStart customer callback threw: ",c)}this.actionsService?.triggerAction(Tl.TARGET_EDIT_START,{details:a,timestamp:Date.now()})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusIn: ",t)}}handleChange(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||!this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleChange: ",t)}}handleFocusOut(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusOut: ",t)}}isAtomicCommitTarget(e){try{if(e instanceof HTMLSelectElement)return!0;if(e instanceof HTMLInputElement){let t=(e.type||"").toLowerCase();return t==="checkbox"||t==="radio"}return!1}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isAtomicCommitTarget: ",t),!1}}processCommit(e,t){try{let i=this.snapshotService.getSnapshot(e),a=this.readElementValue(e,t);if(dr(i,a))return;let l={targetId:e,oldValue:i,newValue:a,element:t},c=this.modeService.getOnTargetEditCommit(),d=!1;if(c){let u=null;try{u=c(l)}catch(_){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditCommit customer callback threw: ",_)}u&&(d=!0,this.invokeAutoCommit({targetId:e,newValue:a,summary:u.summary,metadata:u.metadata}))}let g=u=>X(this,null,function*(){return d?null:this.invokeAutoCommit({targetId:e,newValue:a,summary:u?.summary,metadata:u?.metadata})});this.actionsService?.triggerAction(Tl.TARGET_EDIT_COMMIT,{details:l,commitSuggestion:g,timestamp:Date.now()})}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService processCommit: ",i)}}invokeAutoCommit(e){try{return this.actionsService?this.actionsService.commitSuggestion(e).catch(t=>(dm()&&this.loggingService.catch(`[velt] auto-commit for "${e.targetId}" rejected: `,t),null)):(dm()&&this.loggingService.log("[velt] auto-commit skipped: actions service not wired. SuggestionActionsService constructor should call registry.setActionsService(this)."),Promise.resolve(null))}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService invokeAutoCommit: ",t),Promise.resolve(null)}}captureSnapshotForTarget(e,t){try{let i=this.registry.get(e);if(i?.getter){this.snapshotService.captureFromGetter(e,i.getter);return}let a=this.readElementValue(e,t);this.snapshotService.captureValue(e,a)}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService captureSnapshotForTarget: ",i)}}readElementValue(e,t){try{let i=this.registry.get(e);if(i?.getter)try{return i.getter()}catch{return}if(t instanceof HTMLInputElement){let a=(t.type||"").toLowerCase();return a==="checkbox"||a==="radio"?t.checked:a==="number"||a==="range"?Number.isNaN(t.valueAsNumber)?t.value:t.valueAsNumber:t.value}return t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t.value:(t instanceof HTMLElement&&t.isContentEditable,t.textContent??"")}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService readElementValue: ",i);return}}findTaggedAncestor(e){try{if(!(e instanceof Element))return null;let t=e.closest(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`);if(!t)return null;let i=t.getAttribute(F.ATTRIBUTES.VELT_SUGGESTION_TARGET);return i?{element:t,targetId:i}:null}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService findTaggedAncestor: ",t),null}}queryAll(e){try{let t=window.CSS?.escape?window.CSS.escape(e):e.replace(/"/g,'\\"');return Array.from(document.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}="${t}"]`))}catch{return[]}}scanAndRefresh(e){try{e.querySelectorAll(`[${F.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).forEach(i=>{let a=i.getAttribute(F.ATTRIBUTES.VELT_SUGGESTION_TARGET);if(!a)return;let l=this.registry.get(a)??{};(!l.node||!l.node.isConnected)&&(l.node=i,this.registry.set(a,l))})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService scanAndRefresh: ",t)}}warnIfUnstableId(e){try{if(!dm()||this.warnedUnstableIds.has(e))return;let t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(e),i=/\d{10,}/.test(e);(t||i)&&(this.warnedUnstableIds.add(e),this.loggingService.catch(`[velt] Target id "${e}" appears unstable. Cause: contains a UUID or timestamp shape \u2014 these typically change across re-renders. Fix: use a stable customer-owned id (the same one you use in your state). Docs: velt.dev/docs/suggestions/target-ids`,new Error("UNSTABLE_TARGET_ID")))}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService warnIfUnstableId: ",t)}}warnDuplicateId(e,t){try{if(!dm())return;this.loggingService.catch(`[velt] Duplicate target id "${e}" \u2014 ${t} elements share this id. Cause: the same ${F.ATTRIBUTES.VELT_SUGGESTION_TARGET} appears on multiple DOM nodes. Fix: ensure each suggestable element has a unique id. Velt is using the first registered element. Docs: velt.dev/docs/suggestions/target-ids`,new Error("DUPLICATE_TARGET_ID"))}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService warnDuplicateId: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(k),Z(ZU),Z(JU))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var gl=(()=>{let o=class o{constructor(e,t,i,a,l,c){this.loggingService=e,this.modeService=t,this.snapshotService=i,this.targetRegistry=a,this.commentService=l,this.commonDbService=c,this.actionSubjects=new Map,this.observingActive=!1;try{this.targetRegistry.setActionsService(this)}catch(d){this.loggingService.catch("Error in SuggestionActionsService constructor: ",d)}}enableSuggestionMode(e){try{this.modeService.enable(e),this.startObservingIfNeeded(),this.warnIfNoTaggedElements()}catch(t){this.loggingService.catch("Error in SuggestionActionsService enableSuggestionMode: ",t)}}disableSuggestionMode(){try{this.modeService.disable(),this.stopObservingIfNeeded()}catch(e){this.loggingService.catch("Error in SuggestionActionsService disableSuggestionMode: ",e)}}isSuggestionModeEnabled(){try{return this.modeService.isEnabled()}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled: ",e),!1}}isSuggestionModeEnabled$(){try{return this.modeService.enabled$}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled$: ",e),new Vt}}registerTarget(e){try{if(!e?.targetId||typeof e?.getter!="function")return;this.targetRegistry.registerTarget(e.targetId,e.getter)}catch(t){this.loggingService.catch("Error in SuggestionActionsService registerTarget: ",t)}}unregisterTarget(e){try{this.targetRegistry.unregisterTarget(e)}catch(t){this.loggingService.catch("Error in SuggestionActionsService unregisterTarget: ",t)}}startSuggestion(e){try{let t=this.targetRegistry.getGetter(e);if(t){this.snapshotService.captureFromGetter(e,t);return}let i=this.targetRegistry.getFallbackValue(e);i.hasValue?this.snapshotService.captureValue(e,i.value):this.loggingService.warn(`[velt] startSuggestion: target "${e}" not registered. Cause: no getter via registerTarget() and no textContent fallback. Fix: tag the element with data-velt-suggestion-target and register a getter via registerTarget(). Docs: velt.dev/docs/suggestions/targets`)}catch(t){this.loggingService.catch("Error in SuggestionActionsService startSuggestion: ",t)}}commitSuggestion(e){return new Promise((t,i)=>{try{if(!e?.targetId){i(new Error("INVALID_CONFIG"));return}if(!this.modeService.isEnabled()){this.loggingService.warn("[velt] commitSuggestion called while suggestion mode is disabled. Cause: enableSuggestionMode() has not been called (or disableSuggestionMode() was called). Fix: call enableSuggestionMode() before commit, or branch on isSuggestionModeEnabled() in your onSave handler. Docs: velt.dev/docs/suggestions/mode"),i(new Error("MODE_NOT_SUGGESTING"));return}if(!this.targetRegistry.isRegistered(e.targetId)){this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" not registered. Cause: no element has data-velt-suggestion-target="${e.targetId}" and no registerTarget() call provided a getter. Fix: tag the element or register a getter at app boot. Docs: velt.dev/docs/suggestions/targets`),i(new Error("TARGET_NOT_REGISTERED"));return}if(!this.snapshotService.hasSnapshot(e.targetId)){let u=this.targetRegistry.getGetter(e.targetId);if(u){if(!this.snapshotService.captureFromGetter(e.targetId,u)){i(new Error("SNAPSHOT_FAILED"));return}}else{let _=this.targetRegistry.getFallbackValue(e.targetId);if(_.hasValue)this.snapshotService.captureValue(e.targetId,_.value);else{this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" requires registerTarget() for complex values. Cause: complex objects need a getter so the SDK can deep-clone the snapshot. Fix: call velt.getSuggestionElement().registerTarget("${e.targetId}", () => yourState.${e.targetId}) at app boot. Docs: velt.dev/docs/suggestions/getter`),i(new Error("NO_GETTER_FOR_COMPLEX"));return}}}let a=this.snapshotService.getSnapshot(e.targetId),l=e.newValue;if(dr(a,l)){this.loggingService.warn(`[velt] commitSuggestion: no change detected for target "${e.targetId}". Cause: oldValue and newValue are deeply equal. Fix: only call commitSuggestion when the customer actually changed the value. Docs: velt.dev/docs/suggestions/edge-cases`),i(new Error("NO_CHANGE_TO_SUGGEST"));return}let c=new Vr;c.type="suggestion",c.suggestion={status:"pending",targetId:e.targetId,targetType:"custom",oldValue:a,newValue:l,summary:e.summary??null,driftDetected:!1,rejectReason:null,resolvedBy:null,resolvedAt:null},c.metadata=e.metadata??{};let d=e.summary??`[${e.targetId}] changed`,g=new oc;g.commentText=d,g.commentHtml=`<p>${this.escapeHtml(d)}</p>`,c.comments=[g],this.commentService.addComment(void 0,void 0,void 0,void 0,!1,[],void 0,void 0,void 0,void 0,void 0,void 0,void 0,u=>{try{this.snapshotService.clearSnapshot(e.targetId),this.projectAndTrigger(Tl.SUGGESTION_CREATED,u.annotation),t({id:u.annotation.annotationId})}catch(_){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion callback: ",_),i(_)}},void 0,void 0,c,void 0,void 0,!0,void 0,void 0,"internal",void 0)}catch(a){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion: ",a),i(a)}})}getSuggestions(e){try{let t=this.commentService.getCommentAnnotationsOnCurrentOrganizationAndDocument()??[],i=[];for(let a of t){if(a.type!=="suggestion"||!a.suggestion)continue;let l=this.projectAnnotationToSuggestion(a);l&&this.matchesFilter(l,e)&&i.push(l)}return i}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions: ",t),[]}}getSuggestions$(e){try{return this.commentService.getCommentAnnotationsOnCurrentOrganizationAndDocument$().pipe(ge(t=>{let i=[];for(let a of t??[]){if(a.type!=="suggestion"||!a.suggestion)continue;let l=this.projectAnnotationToSuggestion(a);l&&this.matchesFilter(l,e)&&i.push(l)}return i}),bt(Zt))}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions$: ",t),new Vt}}getPendingSuggestion(e){try{if(!e)return null;let t=this.getSuggestions({targetId:e,status:"pending"});return t.length===0?null:t.sort((i,a)=>(a.createdAt??0)-(i.createdAt??0))[0]}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion: ",t),null}}getPendingSuggestion$(e){try{return e?this.getSuggestions$({targetId:e,status:"pending"}).pipe(ge(t=>t.length===0?null:t.sort((i,a)=>(a.createdAt??0)-(i.createdAt??0))[0]),bt(Zt)):new Vt}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion$: ",t),new Vt}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in SuggestionActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in SuggestionActionsService onAction: ",t),de(null)}}projectAndTrigger(e,t){try{if(!t||t.type!=="suggestion"||!t.suggestion)return;let i=this.projectAnnotationToSuggestion(t);if(!i)return;let a=this.timestamp;switch(e){case Tl.SUGGESTION_CREATED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_CREATED,l);break}case Tl.SUGGESTION_APPROVED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_APPROVED,l);break}case Tl.SUGGESTION_REJECTED:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_REJECTED,l);break}case Tl.SUGGESTION_STALE:{let l={suggestion:i,timestamp:a};this.triggerAction(Tl.SUGGESTION_STALE,l);break}}}catch(i){this.loggingService.catch("Error in SuggestionActionsService projectAndTrigger: ",i)}}projectAnnotationToSuggestion(e){try{let t=e.suggestion;if(!t)return;let i={annotationId:e.annotationId,targetId:t.targetId,targetType:t.targetType,oldValue:t.oldValue,newValue:t.newValue,summary:t.summary,metadata:e.metadata??{},driftDetected:!!t.driftDetected,createdBy:e.from,createdAt:e.createdAt??0};switch(t.status){case"pending":return y(h({},i),{status:"pending",rejectReason:null,resolvedBy:null,resolvedAt:null});case"accepted":case"apply_failed":return y(h({},i),{status:t.status,rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp});case"rejected":return y(h({},i),{status:"rejected",rejectReason:t.rejectReason??null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp});case"stale":return y(h({},i),{status:"stale",rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt});default:return}}catch(t){this.loggingService.catch("Error in SuggestionActionsService projectAnnotationToSuggestion: ",t);return}}startObservingIfNeeded(){try{if(this.observingActive)return;this.observingActive=!0,this.targetRegistry.startObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService startObservingIfNeeded: ",e)}}stopObservingIfNeeded(){try{if(!this.observingActive)return;this.observingActive=!1,this.targetRegistry.stopObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService stopObservingIfNeeded: ",e)}}warnIfNoTaggedElements(){try{this.targetRegistry.countTaggedElements()===0&&this.loggingService.warn('[velt] No suggestable elements found on this page. Cause: no DOM elements have a data-velt-suggestion-target attribute. Fix: tag at least one element with data-velt-suggestion-target="your.id" before enabling suggestion mode. Docs: velt.dev/docs/suggestions/getting-started')}catch(e){this.loggingService.catch("Error in SuggestionActionsService warnIfNoTaggedElements: ",e)}}get timestamp(){return this.commonDbService.getServerTimestamp()}matchesFilter(e,t){try{return t?!(t.targetId&&e.targetId!==t.targetId||t.status&&!(Array.isArray(t.status)?t.status:[t.status]).includes(e.status)):!0}catch(i){return this.loggingService.catch("Error in SuggestionActionsService matchesFilter: ",i),!1}}escapeHtml(e){try{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}catch(t){return this.loggingService.catch("Error in SuggestionActionsService escapeHtml: ",t),""}}};o.\u0275fac=function(t){return new(t||o)(Z(k),Z(ZU),Z(JU),Z(GS),Z(Re),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Rn=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M,j){this.analyticsService=e,this.authService=t,this.commentService=i,this.commentViewsService=a,this.contactService=l,this.customFilterService=c,this.docService=d,this.iamService=g,this.loggingService=u,this.metadataService=_,this.reactionService=w,this.commonDbService=A,this.suggestionActions=M,this.targetRegistry=j,this.actionSubjects=new Map,this.defaultSource="internal",this.isUserAdmin=!1,this.subscriptions=[],this.loggingService.log("%c[WB] Creating CLASS: CommentActionsService","color: blue;");try{this.commentService.setCommentActionsService(this),this.iamService.isUserAdmin$().subscribe(q=>{this.isUserAdmin=q})}catch(q){this.loggingService.catch("Error in CommentActionsService constructor: ",q)}}addCommentAnnotation(l,c){return X(this,arguments,function*({annotation:e,options:t,visibility:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),i){if(i.type==="restricted"){let g=this.authService.getUser();g?.userId&&(i=ap(i,g.userId))}if(i.type==="organizationPrivate"&&!i.organizationId){let g=this.docService.getOrganizationConfig();g?.clientOrganizationId&&(i=y(h({},i),{organizationId:g.clientOrganizationId}))}let d=lp(i);d.length>0&&(e.context||(e.context={}),e.context._setAccessFields=d,e.visibilityConfig=h(h({type:i.type},i.organizationId&&{organizationId:i.organizationId}),i.userIds&&{userIds:i.userIds}))}return new Promise(d=>{this.commentService.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,g=>X(this,null,function*(){let u=yield this.getAddCommentAnnotationEventFromCommentAddEventData(g);d(u)}),void 0,void 0,e,void 0,void 0,void 0,void 0,void 0,a)})}catch(d){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",d),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return X(this,null,function*(){try{let t=yield this.metadataService.getGlobalMetadata();return{commentAnnotation:this.commentService.getCommentAnnotationForClient(e?.annotation),annotationId:e?.annotation?.annotationId,metadata:t,addContext:e?.addContext,elementRef:e?.elementRef}}catch(t){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",t),null}})}triggerAddCommentAnnotationEvent(e){try{this.triggerAction(er.ADD_COMMENT_ANNOTATION,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",t)}}getAddCommentAnnotationDraftEventFromCommentAddEventData(e){return X(this,null,function*(){try{return{metadata:yield this.metadataService.getGlobalMetadata(),addContext:e?.addContext}}catch(t){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",t),null}})}triggerAddCommentAnnotationDraftEvent(e){try{this.triggerAction(er.ADD_COMMENT_ANNOTATION_DRAFT,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationDraftEvent: ",t)}}triggerAddCommentDraftEventForAnnotation(e,t){return X(this,null,function*(){try{if(!e?.annotationId||!t)return;let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),comment:t,metadata:i};this.triggerAction(er.ADD_COMMENT_DRAFT,a)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAddCommentDraftEventForAnnotation: ",i)}})}triggerAnnotationNotFoundError(e){try{this.loggingService.catch("Annotation not found:","The annotation with the given id was not found.")}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAnnotationNotFoundError: ",t)}}deleteCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteCommentAnnotation","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let d=this.commentService.getAnnotationById(e,t);if(d){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===d?.from?.userId){this.commentService.deleteCommentPinAnnotation(d);let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:d.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:u};return this.triggerAction(er.DELETE_COMMENT_ANNOTATION,_),_}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete it.")}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteCommentAnnotation: ",c),null}})}updatePriority(l,c){return X(this,arguments,function*({annotationId:e,priority:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updatePriority","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g=JSON.parse(JSON.stringify(g));let u=g.priority?JSON.parse(JSON.stringify(g.priority)):null;u&&t&&u?.id===t?.id?g.priority=void 0:g.priority=t,this.commentService.saveComment(g,{type:Tt.PRIORITY_CHANGED,newPriority:t,oldPriority:u});let _=yield this.metadataService.getGlobalMetadata(),w={newPriority:t,oldPriority:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};return this.triggerAction(er.UPDATE_PRIORITY,w),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PRIORITY_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldPriority:g.priority,newPriority:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),w}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",d),null}})}updateStatus(l,c){return X(this,arguments,function*({annotationId:e,status:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateStatus","color: green;");let d=this.authService.getUser();if(!d)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g=JSON.parse(JSON.stringify(g));let u=g.status?JSON.parse(JSON.stringify(g.status)):null;g.status=t,g.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(g,{type:Tt.STATUS_CHANGED,newStatus:t,oldStatus:u});let _=yield this.metadataService.getGlobalMetadata(),w={newStatus:t,oldStatus:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};return this.triggerAction(er.UPDATE_STATUS,w),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldStatus:u,newStatus:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,commentAnnotationCreatedAt:g.createdAt}),w}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",d),null}})}updateAccess(l,c){return X(this,arguments,function*({annotationId:e,accessMode:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateAccess","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g)if(this.commentService.isPrivateCommentAllowed()){g=JSON.parse(JSON.stringify(g));let u=g.iam?.accessMode;g.iam.accessMode=t,this.commentService.saveComment(g,{type:Tt.ACCESS_MODE_CHANGED,newAccessMode:t,oldAccessMode:u});let _=yield this.metadataService.getGlobalMetadata(),w={newAccessMode:t,oldAccessMode:u,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:_};switch(this.triggerAction(er.UPDATE_ACCESS,w),t){case ya.PRIVATE:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:ya.PRIVATE,source:a??this.defaultSource});break;case ya.PUBLIC:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:ya.PUBLIC,source:a??this.defaultSource});break;default:break}return w}else this.loggingService.catch("Access Denied","You must be an admin to update the access mode of the comment.");else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService updateAccess: ",d),null}})}resolveCommentAnnotation(i){return X(this,arguments,function*({annotationId:e,options:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: resolveCommentAnnotation","color: green;");let a=this.authService.getUser();if(!a)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let l=this.commentService.getAnnotationById(e,t);if(l){l=JSON.parse(JSON.stringify(l));let c=this.customFilterService.resolvedStatus,d=l.status?JSON.parse(JSON.stringify(l.status)):null;c&&(l.status=c,l.statusUpdatedByUserId=a?.userId,this.commentService.saveComment(l,{type:Tt.STATUS_CHANGED,newStatus:c,oldStatus:d}));let g=yield this.metadataService.getGlobalMetadata(),u={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(l),metadata:g};return this.triggerAction(er.RESOLVE_COMMENT,u),u}else this.triggerAnnotationNotFoundError(e);return null}catch(a){return this.loggingService.catch("Error in CommentActionsService resolveCommentAnnotation: ",a),null}})}getLink(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){let d=this.commentService.getCommentUrl(c)??null,g=yield this.metadataService.getGlobalMetadata();return{link:d,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:g}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService getLink: ",c),null}})}copyLink(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let c=yield this.getLink({annotationId:e,options:t},i);if(c?.link){ts(c.link),this.commentService.setCopyLink(c.link),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_LINK_COPIED,{annotationId:e,commentType:this.commentService.getCommentType(c.commentAnnotation),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource,link:c.link});let d=yield this.metadataService.getGlobalMetadata(),g={link:c.link,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c.commentAnnotation),metadata:d};return this.triggerAction(er.COPY_LINK,g),g}return null}catch(c){return this.loggingService.catch("Error in CommentActionsService copyLink: ",c),null}})}addComment(g,u){return X(this,arguments,function*({annotationId:e,comment:t,assignedTo:i,assigned:a,options:l,visibility:c},d){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let _=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_){let w=this.commentService.getAnnotationById(e,l),A=w?.comments?.length?Tt.ADDED:Tt.NEWLY_ADDED;if(w){w.status.type==="terminal"&&(w.status=this.customFilterService.defaultStatus);let M=new oc;M=h(h({},M),t),M.lastUpdated=new Date,M.attachments||(M.attachments=[]),M.attachments=M.attachments.filter(ae=>ae?.attachmentId),M.createdAt=this.timestamp,M.from=_,i&&(w.assignedTo=i),this.commentService.saveComment(w,{type:A,updatedComment:M,assigned:a,visibility:c,_dispatchAddCommentEvent:!0});let j=y(h({},w),{comments:[...w.comments||[],M]}),q=yield this.buildAddCommentEvent({annotation:j,newComment:M});if(!q)return null;let ie=t?.commentId,_e=this.calculateCommentThreadIndex(t,w);return this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:ie,commentThreadIndex:_e,commentType:this.commentService.getCommentType(w),commentMode:this.commentService.getCommentMode(),source:d??this.defaultSource,commentAnnotationCreatedAt:w.createdAt,taggedClientUserIds:M.taggedUserContacts?.map(ae=>ae.contact?.userId).filter(ae=>!!ae),taggedSnippylyUserIds:M.taggedUserContacts?.filter(ae=>!!w?.metadata?.apiKey&&!!ae.contact?.userId).map(ae=>hd(w.metadata.apiKey,ae.contact.userId))}),q}else this.triggerAnnotationNotFoundError(e)}return null}catch(_){return this.loggingService.catch("Error in CommentActionsService addComment: ",_),null}})}buildAddCommentEvent(i){return X(this,arguments,function*({annotation:e,newComment:t}){try{let a=yield this.metadataService.getGlobalMetadata();return{annotationId:e.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:a}}catch(a){return this.loggingService.catch("Error in CommentActionsService buildAddCommentEvent: ",a),null}})}triggerAddCommentEvent(i){return X(this,arguments,function*({annotation:e,newComment:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: triggerAddCommentEvent","color: green;");let a=yield this.buildAddCommentEvent({annotation:e,newComment:t});return a&&this.triggerAction(er.ADD_COMMENT,a),a}catch(a){return this.loggingService.catch("Error in CommentActionsService triggerAddCommentEvent: ",a),null}})}approveCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: approveCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){c.approved=!0,this.commentService.saveComment(c,{type:Tt.APPROVED}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource});let d=yield this.metadataService.getGlobalMetadata(),g={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:d};return this.triggerAction(er.APPROVE_COMMENT_ANNOTATION,g),g}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService approveComment: ",c),null}})}acceptCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=F.CommentAcceptStatus,c.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(c,{type:Tt.ACCEPTED,oldStatus:g,newStatus:F.CommentAcceptStatus});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:u,actionUser:d,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(er.ACCEPT_COMMENT_ANNOTATION,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",c),null}})}rejectCommentAnnotation(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=F.CommentRejectStatus,c.statusUpdatedByUserId=d?.userId,this.commentService.saveComment(c,{type:Tt.REJECTED,oldStatus:g,newStatus:F.CommentRejectStatus});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:u,actionUser:d,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(er.REJECT_COMMENT_ANNOTATION,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:i??this.defaultSource}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",c),null}})}ensureAgentSuggestion(e){try{if(!e||e?.suggestion||!(!!e?.agent&&(e?.type==="suggestion"||e?.commentType==="suggestion")))return;e.suggestion={status:"pending",targetId:"",targetType:"custom",oldValue:null,newValue:null,summary:null,driftDetected:!1,rejectReason:null,resolvedBy:null,resolvedAt:null}}catch(t){this.loggingService.catch("Error in CommentActionsService ensureAgentSuggestion: ",t)}}acceptSuggestion(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptSuggestion","color: green;");let c=this.authService.getUser();if(!c)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let d=this.commentService.getAnnotationById(e,t);if(!d)return this.triggerAnnotationNotFoundError(e),null;if(this.ensureAgentSuggestion(d),!(d.type==="suggestion"||d.commentType==="suggestion")||!d.suggestion||d.suggestion.status!=="pending")return null;let g=d.suggestion.targetId;if(g){if(!this.targetRegistry.getNode(g)){d.suggestion.status="stale",d.suggestion.resolvedBy=c,d.suggestion.resolvedAt=this.timestamp,d.statusUpdatedByUserId=c?.userId,this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"stale",targetId:g}),this.commentService.updateComment(d),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_STALE,d);let j=yield this.metadataService.getGlobalMetadata(),q={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:j,actionUser:c};return this.triggerAction(er.SUGGESTION_ACCEPTED,q),q}let A=this.targetRegistry.getGetter(g),M=!1;if(A)try{let j=A();M=!dr(j,d.suggestion.oldValue)}catch{M=!1}d.suggestion.driftDetected=M}d.suggestion.status="accepted",d.suggestion.resolvedBy=c,d.suggestion.resolvedAt=this.timestamp,d.statusUpdatedByUserId=c?.userId,d.type="comment",d?.agent?.agentFields&&typeof d.agent.agentFields=="object"&&Array.isArray(d.agent.agentFields)&&(d.agent.agentFields=d.agent.agentFields.filter(w=>w!=="status:suggestion"),d.agent.agentFields.includes("status:accepted")||d.agent.agentFields.push("status:accepted")),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"accepted",targetId:g,driftDetected:d.suggestion?.driftDetected}),this.commentService.saveComment(d,{type:Tt.SUGGESTION_ACCEPTED}),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_APPROVED,d),this.analyticsService.trackEvent(Y.Events.Comments.SUGGESTION_ACCEPTED,{annotationId:e});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(d),metadata:u,actionUser:c};return this.triggerAction(er.SUGGESTION_ACCEPTED,_),_}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptSuggestion: ",c),null}})}rejectSuggestion(l,c){return X(this,arguments,function*({annotationId:e,reason:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectSuggestion","color: green;");let d=this.authService.getUser();if(!d)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(!g)return this.triggerAnnotationNotFoundError(e),null;if(this.ensureAgentSuggestion(g),!(g.type==="suggestion"||g.commentType==="suggestion")||!g.suggestion||g.suggestion.status!=="pending")return null;g.suggestion.status="rejected",g.suggestion.rejectReason=t??null,g.suggestion.resolvedBy=d,g.suggestion.resolvedAt=this.timestamp,g.statusUpdatedByUserId=d?.userId,g.type="comment",g?.agent?.agentFields&&typeof g.agent.agentFields=="object"&&Array.isArray(g.agent.agentFields)&&(g.agent.agentFields=g.agent.agentFields.filter(w=>w!=="status:suggestion"),g.agent.agentFields.includes("status:rejected")||g.agent.agentFields.push("status:rejected")),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECT_BUTTON_CLICKED,{annotationId:e,commentType:"suggestion",suggestionOutcome:"rejected",targetId:g.suggestion.targetId}),this.commentService.saveComment(g,{type:Tt.SUGGESTION_REJECTED}),this.suggestionActions.projectAndTrigger(Tl.SUGGESTION_REJECTED,g),this.analyticsService.trackEvent(Y.Events.Comments.SUGGESTION_REJECTED,{annotationId:e});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:u,actionUser:d,rejectReason:t??null};return this.triggerAction(er.SUGGESTION_REJECTED,_),_}catch(d){return this.loggingService.catch("Error in CommentActionsService rejectSuggestion: ",d),null}})}toggleNotificationSubscription(a,l){return X(this,arguments,function*({annotationId:e,options:t},i){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let c=this.commentService.getAnnotationById(e,t),d=this.authService.getUser();if(c&&d){let g=It(d.userId);if(g){c.subscribedUsers||(c.subscribedUsers={}),c.unsubscribedUsers||(c.unsubscribedUsers={});let u,_=!1;if(c?.unsubscribedUsers?.[g])_=!1;else if(c?.subscribedUsers?.[g])_=!0;else{let M=this.contactService.getCurrentOrganizationUserIAM();if(M){let j=M.groups||{};Object.keys(j).forEach(q=>{c?.subscribedGroups?.[q]&&(_=!0)})}}if(i==="subscribe"||!i&&!_)delete c.unsubscribedUsers[g],c.subscribedUsers[g]={user:d,type:"manual"},u=Tt.SUBSCRIBED;else if(i==="unsubscribe"||!i&&_)delete c.subscribedUsers[g],c.unsubscribedUsers[g]={user:d,type:"manual"},u=Tt.UNSUBSCRIBED;else return null;this.commentService.saveComment(c,{type:u});let w=yield this.metadataService.getGlobalMetadata(),A={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:w};return u===Tt.SUBSCRIBED?this.triggerAction(er.SUBSCRIBE_COMMENT_ANNOTATION,A):this.triggerAction(er.UNSUBSCRIBE_COMMENT_ANNOTATION,A),A}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",c),null}})}assignUser(l,c){return X(this,arguments,function*({annotationId:e,assignedTo:t,options:i},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: assignUser","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let g=this.commentService.getAnnotationById(e,i);if(g){g.assignedTo=t,this.commentService.saveComment(g,{type:Tt.ASSIGNED,assignedTo:t});let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,assignedTo:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:u};return this.triggerAction(er.ASSIGN_USER,_),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ASSIGNED,{annotationId:e,commentType:this.commentService.getCommentType(g),commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,assignedToUserId:t?.userId}),_}else this.triggerAnnotationNotFoundError(e);return null}catch(d){return this.loggingService.catch("Error in CommentActionsService assignUser: ",d),null}})}getComment(i){return X(this,arguments,function*({annotationId:e,options:t}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getComment","color: green;");let a=this.commentService.getAnnotationById(e,t);return a?a.comments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(a){return this.loggingService.catch("Error in CommentActionsService getComment: ",a),[]}})}updateOrDeleteComment(e,t,i,a,l){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateOrDeleteComment","color: green;"),t?.commentText?.trim()||t?.attachments?.length||t?.recorders?.length){let c=this.authService.getUser();if(this.isUserAdmin||c?.userId===t?.from?.userId){t.lastUpdated=new Date,t.status=Tt.UPDATED,t.isEdited||(t.isEdited=!0,t.editedAt=new Date),this.commentService.saveComment(e,{type:Tt.UPDATED,updatedComment:t});let d=yield this.metadataService.getGlobalMetadata(),g={annotationId:e?.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:d};return this.triggerAction(er.UPDATE_COMMENT,g),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_EDITED,{annotationId:e?.annotationId,commentThreadId:t?.commentId,commentType:this.commentService.getCommentType(e),commentMode:this.commentService.getCommentMode(),source:l??this.defaultSource}),g}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to update it.")}else yield this.deleteComment({annotationId:e?.annotationId,commentId:t.commentId,skipDeleteThreadConfirmation:i,options:a});return null}catch(c){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",c),null}})}updateComment(d,g){return X(this,arguments,function*({annotationId:e,comment:t,skipDeleteThreadConfirmation:i,merge:a,options:l},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let u=this.commentService.getAnnotationById(e,l),_=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(u&&_){let w=t,A=u.comments?.find(M=>M.commentId===t.commentId);if(A){if(this.isUserAdmin||_?.userId===A?.from?.userId)return u?.status.type==="terminal"&&(u.status=this.customFilterService.defaultStatus),a&&(w=h(h({},A),t)),w.from=A.from,w.createdAt=A.createdAt,w.lastUpdated=new Date,yield this.updateOrDeleteComment(u,w,i,l,c);this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to update it.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(u){return this.loggingService.catch("Error in CommentActionsService updateComment: ",u),null}})}deleteComment(c,d){return X(this,arguments,function*({annotationId:e,commentId:t,skipDeleteThreadConfirmation:i,options:a},l){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let g=this.commentService.getAnnotationById(e,a),u=this.authService.getUser();if(!g)return this.triggerAnnotationNotFoundError(e),null;let _=g.comments?.find(q=>q?.commentId===t);if(!_)return null;if(!(this.isUserAdmin||u?.userId===_?.from?.userId))return this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete it."),null;let w=this.commentService.willDeleteWholeAnnotation(g,t),A=this.commentService.getCommentAnnotationForClient(g);if(!i&&!(yield this.commentService.confirmDeleteCommentIfRequired(g,_)))return null;this.commentService.saveComment(g,{type:Tt.DELETED,updatedComment:_,skipDeleteThreadConfirmation:!0});let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:e,commentId:t,commentAnnotation:A,comment:_,metadata:M};if(w){let q={annotationId:e,commentAnnotation:A,metadata:M};this.triggerAction(er.DELETE_COMMENT_ANNOTATION,q)}else this.triggerAction(er.DELETE_COMMENT,j);return j}catch(g){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",g),null}})}addAttachment(l,c){return X(this,arguments,function*({annotationId:e,files:t,options:i},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let d=[],g=this.commentService.getAnnotationById(e,i);if(g||a==="internal"){let w=[];t.forEach(A=>{let{valid:M,file:j,maxAllowedSize:q,error:ie}=this.validateFile(A);M&&j?w.push(this.uploadFile(j,g||{}).then(_e=>({valid:M,file:j,maxAllowedSize:q,error:ie,attachment:_e||void 0}))):w.push(Promise.resolve({valid:M,file:j,maxAllowedSize:q,error:ie,attachment:void 0}))}),d=yield Promise.all(w)}else this.triggerAnnotationNotFoundError(e);let u=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:g?this.commentService.getCommentAnnotationForClient(g):void 0,attachments:d,metadata:u};return this.triggerAction(er.ADD_ATTACHMENT,_),d}catch(d){return this.loggingService.catch("Error in CommentActionsService addAttachment: ",d),[]}})}validateFile(e){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: validateFile","color: green;");let t=100*1024*1024;(e?.type?.includes("image")||e?.type?.includes("pdf"))&&(t=15*1024*1024);let i=e.size<=t;return{valid:i,file:e,maxAllowedSize:t,maxAllowedSizeInMB:t/1024/1024,error:i?void 0:`File size should be less than ${t/1024/1024} MB`}}catch(t){return this.loggingService.catch("Error in CommentActionsService validateFile: ",t),{valid:!1,maxAllowedSize:0,maxAllowedSizeInMB:0,error:"Error in validating file"}}}deleteAttachment(l){return X(this,arguments,function*({annotationId:e,commentId:t,attachmentId:i,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let d=c.comments?.find(u=>u?.commentId===t),g=c.metadata;if(d){let u=this.authService.getUser();if(this.isUserAdmin||u?.userId===d?.from?.userId){let _=d.attachments?.find(w=>w?.attachmentId===i);if(_){d.attachments=d.attachments?.filter(j=>j?.attachmentId!==i);let w={attachmentId:_.attachmentId,organizationId:g?.clientOrganizationId??g?.organizationId??null,documentId:g?.clientDocumentId??g?.documentId??null,folderId:g?.folderId??null,commentAnnotationId:c.annotationId,apiKey:g?.apiKey??null};yield this.commentService.deleteAttachment({attachment:_,metadata:w});let A=yield this.metadataService.getGlobalMetadata(),M={attachment:_,annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:A};return this.triggerAction(er.DELETE_ATTACHMENT,M),this.updateComment({annotationId:e,comment:d,options:a}),M}}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete the attachment.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteAttachment: ",c),null}})}getAttachment(a){return X(this,arguments,function*({annotationId:e,commentId:t,options:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getAttachment","color: green;");let l=this.commentService.getAnnotationById(e,i);return l?l.comments?.find(d=>d?.commentId===t)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(l){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",l),[]}})}uploadFile(e,t){return X(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,t)}catch(i){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",i),null}})}getRecording(a){return X(this,arguments,function*({annotationId:e,commentId:t,options:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getRecording","color: green;");let l=this.commentService.getAnnotationById(e,i);return l?l.comments?.find(d=>d?.commentId===t)?.recorders||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(l){return this.loggingService.catch("Error in CommentActionsService getRecording: ",l),[]}})}deleteRecording(l){return X(this,arguments,function*({annotationId:e,commentId:t,recorderId:i,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let d=c.comments?.find(g=>g?.commentId===t);if(d){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===d?.from?.userId){let u=d.recorders?.find(_=>_?.id===i);if(u){d.recorders=d.recorders?.filter(A=>A?.id!==i);let _=yield this.metadataService.getGlobalMetadata(),w={annotationId:e,commentId:t,recording:u,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:_};return this.triggerAction(er.DELETE_RECORDING,w),this.updateComment({annotationId:e,comment:d,skipDeleteThreadConfirmation:!0,options:a}),w}}else this.loggingService.catch("Access Denied","You must be the author of the comment or an admin to delete the recording.")}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService deleteRecording: ",c),null}})}fetchCommentAnnotations(e){return X(this,null,function*(){try{let t=yield this.commentService.fetchCommentAnnotations(e),i;if(t?.hasMore){let l=t?.data[t?.data?.length-1];i=yield FZ(l?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=t?.data?.reduce((l,c)=>(l[c.metadata.clientDocumentId??c.metadata.documentId]=l[c.metadata.clientDocumentId??c.metadata.documentId]||[],l[c.metadata.clientDocumentId??c.metadata.documentId].push(this.commentService.getCommentAnnotationForClient(c)),l),{});return h({data:a},t?.hasMore?{nextPageToken:i}:{})}catch(t){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",t),{data:null}}})}toggleReaction(c,d){return X(this,arguments,function*({annotationId:e,commentId:t,reaction:i,options:a},l){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let g=this.commentService.getAnnotationById(e,a),u=this.authService.getUser();if(g&&u){let _=g.comments?.find(w=>w?.commentId===t);if(_){let w=yield this.reactionService.addOrUpdateReaction(i.reactionId,_?.reactionAnnotationIds||[],void 0,void 0,g?.annotationId,i.customReaction,l),A=Tt.REACTION_ADDED;if(w){w?.reactions?.find(q=>q.from?.userId===u?.userId)||(A=Tt.REACTION_DELETED),_.reactionAnnotationIds||(_.reactionAnnotationIds=[]),_.reactionAnnotationIds.includes(w.annotationId)||_.reactionAnnotationIds.push(w.annotationId),w?.reactions?.length||(_.reactionAnnotationIds=_.reactionAnnotationIds.filter(q=>q!==w.annotationId)),this.commentService.saveComment(g,{type:A,updatedComment:_});let M=yield this.metadataService.getGlobalMetadata(),j={annotationId:e,commentId:t,reaction:w,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:M};return l==="add"?this.triggerAction(er.ADD_REACTION,j):l==="delete"?this.triggerAction(er.DELETE_REACTION,j):this.triggerAction(er.TOGGLE_REACTION,j),A===Tt.REACTION_ADDED?this.analyticsService.trackEvent(Y.Events.Comments.REACTION_ADDED,{annotationId:e,commentId:t,reactionId:i.reactionId,commentMode:this.commentService.getCommentMode()}):A===Tt.REACTION_DELETED&&this.analyticsService.trackEvent(Y.Events.Comments.REACTION_DELETED,{annotationId:e,commentId:t,reactionId:i.reactionId,commentMode:this.commentService.getCommentMode()}),j}}}else this.triggerAnnotationNotFoundError(e);return null}catch(g){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",g),null}})}onComposerClick(t){return X(this,arguments,function*({commentAnnotation:e}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onComposerClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={commentAnnotation:e?.annotationId?this.commentService.getCommentAnnotationForClient(e):void 0,metadata:i};this.triggerAction(er.COMPOSER_CLICKED,a)}catch(i){this.loggingService.catch("Error in CommentActionsService onComposerClick: ",i)}})}onComposerTextChange(e){return X(this,null,function*(){try{let t=yield this.metadataService.getGlobalMetadata(),i={text:e.text,annotation:e.annotation,targetComposerElementId:e.targetComposerElementId,metadata:t};this.commentService.setComposerData(e.targetComposerElementId,i),this.triggerAction(er.COMPOSER_TEXT_CHANGE,i)}catch(t){this.loggingService.catch("Error in CommentActionsService onComposerTextChange: ",t)}})}autocompleteSearch(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: autocompleteSearch","color: green;");let t=yield this.metadataService.getGlobalMetadata();e.metadata=t,this.triggerAction(er.AUTOCOMPLETE_SEARCH,e)}catch(t){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",t)}})}onCommentPinClick(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentPinClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),i={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(er.COMMENT_PIN_CLICKED,i),i}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentPinClick: ",t),null}})}onCommentBubbleClick(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentBubbleClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),i={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(er.COMMENT_BUBBLE_CLICKED,i),i}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentBubbleClick: ",t),null}})}onCommentToolClick(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentToolClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={context:e,targetElementId:t,metadata:i},l={context:e,targetElementId:t,metadata:i};return this.triggerAction(er.COMMENT_TOOL_CLICK,a),this.triggerAction(er.COMMENT_TOOL_CLICKED,l),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onCommentToolClick: ",i),null}})}onSidebarButtonClick(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onSidebarButtonClick","color: green;");let e=yield this.metadataService.getGlobalMetadata(),t={metadata:e},i={metadata:e};return this.triggerAction(er.SIDEBAR_BUTTON_CLICK,t),this.triggerAction(er.SIDEBAR_BUTTON_CLICKED,i),t}catch(e){return this.loggingService.catch("Error in CommentActionsService onSidebarButtonClick: ",e),null}})}onAttachmentDownloadClick(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onAttachmentDownloadClick","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),attachment:t,metadata:i};return this.triggerAction(er.ATTACHMENT_DOWNLOAD_CLICKED,a),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onAttachmentDownloadClick: ",i),null}})}onCommentSaveTriggered(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentSaveTriggered","color: green;");let i=yield this.metadataService.getGlobalMetadata(),a={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(t),metadata:i};return this.triggerAction(er.COMMENT_SAVE_TRIGGERED,a),a}catch(i){return this.loggingService.catch("Error in CommentActionsService onCommentSaveTriggered: ",i),null}})}onVisibilityOptionClick(e,t,i){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onVisibilityOptionClick","color: green;");let a=yield this.metadataService.getGlobalMetadata(),l={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),visibility:t,users:i?.map(c=>Bo(c)).filter(Boolean),metadata:a};return this.triggerAction(er.VISIBILITY_OPTION_CLICKED,l),l}catch(a){return this.loggingService.catch("Error in CommentActionsService onVisibilityOptionClick: ",a),null}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:i}=this.docService.getServerId(e?.options);e.options=y(h({},e?.options),{documentId:t,organizationId:i})}return this}catch(t){return this.loggingService.catch("Error in CommentActionsService convert: ",t),this}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in CommentActionsService onAction: ",t),de(null)}}get timestamp(){return this.commonDbService.getServerTimestamp()}getCommentAnnotations(e){try{if(e){if(e?.allDocuments&&!e?.folderId)return this.loggingService.catch("folderId is required when allDocuments is true."),de({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),de({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(ge(t=>t?t.reduce((i,a)=>{let l=a.metadata?.clientDocumentId;return!l||e?.documentIds&&!e?.documentIds?.includes(l)||(i[l]||(i[l]=[]),i[l].push(a)),i},{}):null),ge(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),de({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentViewsService.getAnnotationsCount(e).pipe(ge(t=>t||{data:null}))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),de({data:null})}}updateVisibility(e){this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateVisibility","color: green;");try{let t=e.annotationId;if(!t)throw new Error("annotationId is required in visibility config");if(e.type==="restricted"){let l=this.authService.getUser();if(!l?.userId)throw new Error("Current user not found. Cannot set restricted visibility without userIds.");e=ap(e,l.userId)}if(e.type==="organizationPrivate"&&!e.organizationId){let l=this.docService.getOrganizationConfig();if(!l?.clientOrganizationId)throw new Error("No organizationId found. Cannot set organizationPrivate visibility without organizationId.");e=y(h({},e),{organizationId:l.clientOrganizationId})}this.analyticsService.trackEvent(Y.Events.Comments.UPDATE_VISIBILITY_TRIGGERED,{payload:{annotationId:t,visibility:e}});let i=lp(e),a=h(h({type:e.type},e.organizationId&&{organizationId:e.organizationId}),e.userIds&&{userIds:e.userIds});return this.commentService.updateCommentAnnotationContext(t,{_setAccessFields:i,_setVisibilityConfig:a},{merge:!0})}catch(t){return this.loggingService.catch("Error in updateVisibility: ",t),Promise.resolve()}}calculateCommentThreadIndex(e,t){try{let i=e?.commentId,a;return i&&(a=t?.comments?.findIndex(l=>l.commentId===i)),a===-1&&(a=t?.comments?.length),a}catch(i){this.loggingService.catch("Error in calculateCommentThreadIndex: ",i);return}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Ke),Z(Re),Z(U_e),Z(un),Z(ho),Z(st),Z(Vn),Z(k),Z(ls),Z(qi),Z(kn),Z(gl),Z(GS))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var XU=class extends fr{constructor(o){super(o),this._submitComment=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: submitComment","color: green;");try{this.trackEvent(Y.Events.Comments.SUBMIT_COMMENT_TRIGGERED,{payload:{referenceId:r.targetComposerElementId}}),this.getService(Re).submitComment(r)}catch(e){this.getService(k).catch("Error in _submitComment: ",e)}},this._clearComposer=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: clearComposer","color: green;");try{this.trackEvent(Y.Events.Comments.CLEAR_COMPOSER_TRIGGERED),this.getService(Re).clearComposer(r)}catch(e){this.getService(k).catch("Error in _clearComposer: ",e)}},this._enableFormatOptions=()=>{this.getService(k).log("%c[WB] Calling FUNCTION: enableFormatOptions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORMAT_OPTIONS_TRIGGERED),this.getService(Re).enableFormatOptions()}catch(r){this.getService(k).catch("Error in _enableFormatOptions: ",r)}},this._disableFormatOptions=()=>{this.getService(k).log("%c[WB] Calling FUNCTION: disableFormatOptions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORMAT_OPTIONS_TRIGGERED),this.getService(Re).disableFormatOptions()}catch(r){this.getService(k).catch("Error in _disableFormatOptions: ",r)}},this._setFormatConfig=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: setFormatConfig","color: green;");try{this.trackEvent(Y.Events.Comments.SET_FORMAT_CONFIG_TRIGGERED,{payload:{config:r}}),this.getService(Re).setFormatConfig(r)}catch(e){this.getService(k).catch("Error in _setFormatConfig: ",e)}},this._getComposerData=r=>{this.getService(k).log("%c[WB] Calling FUNCTION: getComposerData","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMPOSER_DATA_TRIGGERED),this.getService(Re).getComposerData(r)}catch(e){return this.getService(k).catch("Error in _getComposerData: ",e),null}},this.getService(k).log("%c[WB] Creating CLASS: CommentElement","color: blue;"),this.getAllCommentAnnotations=this._getAllCommentAnnotations,this.deleteSelectedComment=this._deleteSelectedComment,this.enableTextComments=this._enableTextComments,this.disableTextComments=this._disableTextComments,this.allowedElementIds=this._allowedElementIds,this.allowedElementClassNames=this._allowedElementClassNames,this.allowedElementQuerySelectors=this._allowedElementQuerySelectors,this.disableFloatingCommentDialog=this._disableFloatingComments,this.enableFloatingCommentDialog=this._enableFloatingComments,this.attachComment=this._attachComment,this.openCommentSidebar=this._openCommentSidebar,this.closeCommentSidebar=this._closeCommentSidebar,this.toggleCommentSidebar=this._toggleCommentSidebar,this.enableModeratorMode=this._enableModeratorMode,this.disableModeratorMode=this._disableModeratorMode,this.enableStreamMode=this._enableStreamMode,this.disableStreamMode=this._disableStreamMode,this.enableSignInButton=this._enableSignInButton,this.disableSignInButton=this._disableSignInButton,this.enableUpgradeButton=this._enableUpgradeButton,this.disableUpgradeButton=this._disableUpgradeButton,this.onCommentModeChange=this._onCommentModeChange,this.enableAttachments=this._enableAttachment,this.disableAttachments=this._disableAttachment,this.enableAttachmentDownload=this._enableAttachmentDownload,this.disableAttachmentDownload=this._disableAttachmentDownload,this.isUserGlobalContact=this._isUserGlobalContact,this.enableDeviceInfo=this._enableDeviceInfo,this.disableDeviceInfo=this._disableDeviceInfo,this.enableCommentMode=this._enableCommentMode,this.disableCommentMode=this._disableCommentMode,this.enablePersistentCommentMode=this._enablePersistentCommentMode,this.disablePersistentCommentMode=this._disablePersistentCommentMode,this.enableCommentIndex=this._enableCommentIndex,this.disableCommentIndex=this._disableCommentIndex,this.enablePopoverMode=this._enablePopoverMode,this.disablePopoverMode=this._disablePopoverMode,this.enableDialogOnHover=this._enableDialogOnHover,this.enablePopoverTriangleComponent=this._enablePopoverTriangleComponent,this.disablePopoverTriangleComponent=this._disablePopoverTriangleComponent,this.disableDialogOnHover=this._disableDialogOnHover,this.enableDialogOnTargetElementClick=this._enableDialogOnTargetElementClick,this.disableDialogOnTargetElementClick=this._disableDialogOnTargetElementClick,this.enablePriority=this._enablePriority,this.disablePriority=this._disablePriority,this.enableStatus=this._enableStatus,this.disableStatus=this._disableStatus,this.enableVisibilityOptions=this._enableVisibilityOptions,this.disableVisibilityOptions=this._disableVisibilityOptions,this.enableResolveButton=this._enableResolveButton,this.disableResolveButton=this._disableResolveButton,this.enableGhostComments=this._enableGhostComments,this.disableGhostComments=this._disableGhostComments,this.enableGhostCommentsIndicator=this._enableGhostCommentsIndicator,this.disableGhostCommentsIndicator=this._disableGhostCommentsIndicator,this.setCustomStatus=this._setCustomStatus,this.setCustomPriority=this._setCustomPriority,this.setCustomCategory=this._setCustomCategory,this.enableInboxMode=this._enableInboxMode,this.disableInboxMode=this._disableInboxMode,this.enableAutoCategorize=this._enableAutoCategorize,this.disableAutoCategorize=this._disableAutoCategorize,this.enableDarkMode=this._enableDarkMode,this.disableDarkMode=this._disableDarkMode,this.setContextProvider=this._setContextProvider,this.enableSuggestionMode=this._enableSuggestionMode,this.disableSuggestionMode=this._disableSuggestionMode,this.enableMobileMode=this._enableMobileMode,this.disableMobileMode=this._disableMobileMode,this.enableInlineCommentMode=this._enableInlineCommentMode,this.disableInlineCommentMode=this._disableInlineCommentMode,this.enableMinimap=this._enableMinimap,this.disableMinimap=this._disableMinimap,this.showCommentsOnDom=this._showCommentsOnDom,this.hideCommentsOnDom=this._hideCommentsOnDom,this.enableCommentTool=this._enableCommentTool,this.disableCommentTool=this._disableCommentTool,this.setTotalMediaLength=this._setTotalMediaLength,this.onCommentAdd=this._onCommentAdd,this.onCommentUpdate=this._onCommentUpdate,this.addCommentOnSelectedText=this._addCommentOnSelectedText,this.enableSidebarUrlNavigation=this._enableSidebarUrlNavigation,this.disableSidebarUrlNavigation=this._disableSidebarUrlNavigation,this.setDStrategy=this._setDStrategy,this.enableSidebarButtonOnCommentDialog=this._enableSidebarButtonOnCommentDialog,this.disableSidebarButtonOnCommentDialog=this._disableSidebarButtonOnCommentDialog,this.onSidebarButtonOnCommentDialogClick=this._onSidebarButtonOnCommentDialogClick,this.enableReactions=this._enableReactions,this.disableReactions=this._disableReactions,this.enableAnonymousEmail=this._enableAnonymousEmail,this.disableAnonymousEmail=this._disableAnonymousEmail,this.setRecordings=this._setRecordings,this.addCommentOnElement=this._addCommentOnElement,this.enablePrivateCommentMode=this._enablePrivateCommentMode,this.disablePrivateCommentMode=this._disablePrivateCommentMode,this.enablePrivateMode=this._enablePrivateMode,this.disablePrivateMode=this._disablePrivateMode,this.enableScrollToComment=this._enableScrollToComment,this.disableScrollToComment=this._disableScrollToComment,this.enableUserMentions=this._enableUserMentions,this.disableUserMentions=this._disableUserMentions,this.setCommentSidebarFilters=this._setCommentSidebarFilters,this.setSystemFiltersOperator=this._setSystemFiltersOperator,this.enableCommentPinHighlighter=this._enableCommentPinHighlighter,this.disableCommentPinHighlighter=this._disableCommentPinHighlighter,this.enableDeleteOnBackspace=this._enableDeleteOnBackspace,this.disableDeleteOnBackspace=this._disableDeleteOnBackspace,this.enableHotkey=this._enableHotkey,this.disableHotkey=this._disableHotkey,this.enableDeviceIndicatorOnCommentPins=this._enableDeviceIndicatorOnCommentPins,this.disableDeviceIndicatorOnCommentPins=this._disableDeviceIndicatorOnCommentPins,this.getElementRefByAnnotationId=this._getElementRefByAnnotationId,this.scrollToCommentByAnnotationId=this._scrollToCommentByAnnotationId,this.selectCommentByAnnotationId=this._selectCommentByAnnotationId,this.enableRecordingSummary=this._enableRecordingSummary,this.disableRecordingSummary=this._disableRecordingSummary,this.enableRecordingTranscription=this._enableRecordingTranscription,this.disableRecordingTranscription=this._disableRecordingTranscription,this.enableRecordingCountdown=this._enableRecordingCountdown,this.disableRecordingCountdown=this._disableRecordingCountdown,this.setUnreadIndicatorMode=this._setUnreadIndicatorMode,this.enableEnterKeyToSubmit=this._enableEnterKeyToSubmit,this.disableEnterKeyToSubmit=this._disableEnterKeyToSubmit,this.enablePinShadowDOM=this._enablePinShadowDOM,this.disablePinShadowDOM=this._disablePinShadowDOM,this.enableDialogShadowDOM=this._enableDialogShadowDOM,this.disableDialogShadowDOM=this._disableDialogShadowDOM,this.enableSidebarShadowDOM=this._enableSidebarShadowDOM,this.disableSidebarShadowDOM=this._disableSidebarShadowDOM,this.enableChangeDetectionInCommentMode=this._enableChangeDetectionInCommentMode,this.disableChangeDetectionInCommentMode=this._disableChangeDetectionInCommentMode,this.showResolvedCommentsOnDom=this._showResolvedCommentsOnDom,this.hideResolvedCommentsOnDom=this._hideResolvedCommentsOnDom,this.setCustomReactions=this._setCustomReactions,this.onCommentSelectionChange=this._onCommentSelectionChange,this.getUnreadCommentCountByAnnotationId=this._getUnreadCommentCountByAnnotationId,this.getUnreadCommentAnnotationCountOnCurrentDocument=this._getUnreadCommentAnnotationCountOnCurrentDocument,this.getUnreadCommentCountOnCurrentDocument=this._getUnreadCommentCountOnCurrentDocument,this.getUnreadCommentAnnotationCountByLocationId=this._getUnreadCommentAnnotationCountByLocationId,this.getUnreadCommentCountByLocationId=this._getUnreadCommentCountByLocationId,this.updateCommentDialogPosition=this._updateCommentDialogPosition,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment,this.setPinCursorImage=this._setPinCursorImage,this.addManualComment=this._addManualComment,this.createCustomListDataOnAnnotation=this._createCustomListDataOnAnnotation,this.createCustomListDataOnComment=this._createCustomListDataOnComment,this.excludeLocationIdsFromSidebar=this._excludeLocationIdsFromSidebar,this.enableBubbleOnPin=this._enableBubbleOnPin,this.disableBubbleOnPin=this._disableBubbleOnPin,this.enableBubbleOnPinHover=this._enableBubbleOnPinHover,this.disableBubbleOnPinHover=this._disableBubbleOnPinHover,this.enablePinDrag=this._enablePinDrag,this.disablePinDrag=this._disablePinDrag,this.enableMultiThreadMode=this._enableMultiThread,this.disableMultiThreadMode=this._disableMultiThread,this.enableMultiThread=this._enableMultiThread,this.disableMultiThread=this._disableMultiThread,this.enableGroupMultipleMatch=this._enableGroupMatchedComments,this.disableGroupMultipleMatch=this._disableGroupMatchedComments,this.enableGroupMatchedComments=this._enableGroupMatchedComments,this.disableGroupMatchedComments=this._disableGroupMatchedComments,this.updateContext=this._updateContext,this.updateVisibility=this._updateVisibility,this.getSelectedComments=this._getSelectedComments,this.enableDeleteReplyConfirmation=this._enableDeleteReplyConfirmation,this.disableDeleteReplyConfirmation=this._disableDeleteReplyConfirmation,this.onCopyLink=this._onCopyLink,this.getCommentAnnotationById=this._getCommentAnnotationById,this.enableCollapsedComments=this._enableCollapsedComments,this.disableCollapsedComments=this._disableCollapsedComments,this.onCommentSidebarActionButtonClick=this._onCommentSidebarActionButtonClick,this.setCommentSidebarData=this._setCommentSidebarData,this.onCommentSidebarInit=this._onCommentSidebarInit,this.onCommentSidebarData=this._onCommentSidebarData,this.setCommentSidebarDefaultCustomActions=this._setCommentSidebarDefaultCustomActions,this.enableSidebarCustomActions=this._enableSidebarCustomActions,this.disableSidebarCustomActions=this._disableSidebarCustomActions,this.enableQueryParamsComments=this._enableQueryParamsComments,this.disableQueryParamsComments=this._disableQueryParamsComments,this.enableResolveStatusAccessAdminOnly=this._enableResolveStatusAccessAdminOnly,this.disableResolveStatusAccessAdminOnly=this._disableResolveStatusAccessAdminOnly,this.enableLinkCallback=this._enableLinkCallback,this.disableLinkCallback=this._disableLinkCallback,this.enableSeenByUsers=this._enableSeenByUsers,this.disableSeenByUsers=this._disableSeenByUsers,this.enableShortUserName=this._enableShortUserName,this.disableShortUserName=this._disableShortUserName,this.addCommentAnnotation=this._addCommentAnnotation,this.approveCommentAnnotation=this._approveCommentAnnotation,this.acceptCommentAnnotation=this._acceptCommentAnnotation,this.rejectCommentAnnotation=this._rejectCommentAnnotation,this.subscribeCommentAnnotation=this._subscribeCommentAnnotation,this.unsubscribeCommentAnnotation=this._unsubscribeCommentAnnotation,this.deleteCommentAnnotation=this._deleteCommentAnnotation,this.getCommentAnnotations=this._getCommentAnnotations,this.getCommentAnnotationsCount=this._getCommentAnnotationsCount,this.assignUser=this._assignUser,this.updatePriority=this._updatePriority,this.updateStatus=this._updateStatus,this.updateAccess=this._updateAccess,this.resolveCommentAnnotation=this._resolveCommentAnnotation,this.getLink=this._getLink,this.copyLink=this._copyLink,this.addComment=this._addComment,this.updateComment=this._updateComment,this.deleteComment=this._deleteComment,this.getComment=this._getComment,this.addAttachment=this._addAttachment,this.deleteAttachment=this._deleteAttachment,this.getAttachment=this._getAttachment,this.deleteRecording=this._deleteRecording,this.getRecording=this._getRecording,this.addReaction=this._addReaction,this.deleteReaction=this._deleteReaction,this.toggleReaction=this._toggleReaction,this.enableReadOnly=this._enableReadOnly,this.disableReadOnly=this._disableReadOnly,this.setAssignToType=this._setAssignToType,this.enableContextInPageModeComposer=this._enableContextInPageModeComposer,this.disableContextInPageModeComposer=this._disableContextInPageModeComposer,this.clearPageModeComposerContext=this._clearPageModeComposerContext,this.setContextInPageModeComposer=this._setContextInPageModeComposer,this.focusPageModeComposer=this._focusPageModeComposer,this.enableCustomAutocompleteSearch=this._enableCustomAutocompleteSearch,this.disableCustomAutocompleteSearch=this._disableCustomAutocompleteSearch,this.fetchCommentAnnotations=this._fetchCommentAnnotations,this.setTransformContext=this._setTransformContext,this.enableSvgAsImg=this._enableSvgAsImg,this.disableSvgAsImg=this._disableSvgAsImg,this.enableFullExpanded=this._enableFullExpanded,this.disableFullExpanded=this._disableFullExpanded,this.enableCommentToNearestAllowedElement=this._enableCommentToNearestAllowedElement,this.disableCommentToNearestAllowedElement=this._disableCommentToNearestAllowedElement,this.enableDraftMode=this._enableDraftMode,this.disableDraftMode=this._disableDraftMode,this.enableFilterCommentsOnDom=this._enableFilterCommentsOnDom,this.disableFilterCommentsOnDom=this._disableFilterCommentsOnDom,this.enableReplyAvatars=this._enableReplyAvatars,this.disableReplyAvatars=this._disableReplyAvatars,this.setMaxReplyAvatars=this._setMaxReplyAvatars,this.setSidebarButtonCountType=this._setSidebarButtonCountType,this.enableFilterGhostCommentsInSidebar=this._enableFilterGhostCommentsInSidebar,this.disableFilterGhostCommentsInSidebar=this._disableFilterGhostCommentsInSidebar,this.enableFullScreenInSidebar=this._enableFullScreenInSidebar,this.disableFullScreenInSidebar=this._disableFullScreenInSidebar,this.setComposerFileAttachments=this._setComposerFileAttachments,this.setAllowedFileTypes=this._setAllowedFileTypes,this.enableForceCloseAllOnEsc=this._enableForceCloseAllOnEsc,this.disableForceCloseAllOnEsc=this._disableForceCloseAllOnEsc,this.markAsRead=this._markAsRead,this.markAsUnread=this._markAsUnread,this.enableScreenshot=this._enableScreenshot,this.disableScreenshot=this._disableScreenshot,this.enablePaginatedContactList=this._enablePaginatedContactList,this.disablePaginatedContactList=this._disablePaginatedContactList,this.enableFormatOptions=this._enableFormatOptions,this.disableFormatOptions=this._disableFormatOptions,this.setFormatConfig=this._setFormatConfig,this.submitComment=this._submitComment,this.clearComposer=this._clearComposer,this.on=this._on,this.getComposerData=this._getComposerData}_getAllCommentAnnotations(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{documentId:o,location:r}}),this.getService(Re).getAllCommentAnnotations({customClientDocumentId:o,params:r,excludeDomChanges:!0,skipPositionCalculation:!0,addFilterCommentsOnDomCheck:!0}).pipe(ge(e=>e?.length?e?.map(t=>this.getService(Re).getCommentAnnotationForClient(t)):e))}catch(e){return this.getService(k).catch("Error in _getLiveCommentsOnCurrentDocument: ",e),de(null)}}_deleteSelectedComment(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteSelectedComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_SELECTED_COMMENT_TRIGGERED),this.getService(Re).deleteCommentPinAnnotations("commentElement")}catch(o){return this.getService(k).catch("Error in _deleteSelectedComment: ",o),Promise.resolve(null)}}_enableTextComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_TEXT_COMMENTS_TRIGGERED),this.getService(Re).enableTextComments()}catch(o){this.getService(k).catch("Error in _enableTextComments: ",o)}}_disableTextComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_TEXT_COMMENTS_TRIGGERED),this.getService(Re).disableTextComments()}catch(o){this.getService(k).catch("Error in _disableTextComments: ",o)}}_allowedElementIds(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(Re).setAllowedElementIds(o)}catch(r){this.getService(k).catch("Error in allowedElementIds: ",r)}}_allowedElementClassNames(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementClassNames","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_CLASS_NAMES_TRIGGERED,{payload:{classNames:o}}),this.getService(Re).setAllowedElementClassNames(o)}catch(r){this.getService(k).catch("Error in allowedElementClassNames: ",r)}}_allowedElementQuerySelectors(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementQuerySelectors","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_QUERY_SELECTORS_TRIGGERED,{payload:{querySelectors:o}}),this.getService(Re).setAllowedElementQuerySelectors(o)}catch(r){this.getService(k).catch("Error in allowedElementQuerySelectors: ",r)}}_disableFloatingComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableFloatingComments(!0)}catch(o){this.getService(k).catch("Error in _disableFloatingComments: ",o)}}_enableFloatingComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableFloatingComments(!1)}catch(o){this.getService(k).catch("Error in _enableFloatingComments: ",o)}}_attachComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: attachComment","color: green;");try{this.trackEvent(Y.Events.Comments.ATTACH_COMMENT_TRIGGERED,{payload:{elementId:o}}),this.getService(Re).attachComment(o,["id","data-id"])}catch(r){this.getService(k).catch("Error in _attachComment: ",r)}}_openCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: openCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.OPEN_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).setSidebarVisibility(!0,!0)}catch(o){this.getService(k).catch("Error in _openCommentSidebar: ",o)}}_closeCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: closeCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.CLOSE_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).setSidebarVisibility(!1,!0)}catch(o){this.getService(k).catch("Error in _closeCommentSidebar: ",o)}}_toggleCommentSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: toggleCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.TOGGLE_COMMENT_SIDEBAR_TRIGGERED),this.getService(Re).toggleSidebarVisibility(!0)}catch(o){this.getService(k).catch("Error in _toggleCommentSidebar: ",o)}}_enableModeratorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MODERATOR_MODE_TRIGGERED),this.getService(Re).setModeratorMode(!0)}catch(o){this.getService(k).catch("Error in _enableModeratorMode: ",o)}}_disableModeratorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MODERATOR_MODE_TRIGGERED),this.getService(Re).setModeratorMode(!1)}catch(o){this.getService(k).catch("Error in _disableModeratorMode: ",o)}}_enableStreamMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STREAM_MODE_TRIGGERED),this.getService(Re).setStreamMode(!0)}catch(o){this.getService(k).catch("Error in _enableStreamMode: ",o)}}_disableStreamMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STREAM_MODE_TRIGGERED),this.getService(Re).setStreamMode(!1)}catch(o){this.getService(k).catch("Error in _disableStreamMode: ",o)}}_enableSignInButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(Re).enableSignInButton(!0)}catch(o){this.getService(k).catch("Error in _enableSignInButton: ",o)}}_disableSignInButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(Re).enableSignInButton(!1)}catch(o){this.getService(k).catch("Error in _disableSignInButton: ",o)}}_enableUpgradeButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(Re).enableUpgradeButton(!0)}catch(o){this.getService(k).catch("Error in _enableUpgradeButton: ",o)}}_disableUpgradeButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(Re).enableUpgradeButton(!1)}catch(o){this.getService(k).catch("Error in _disableUpgradeButton: ",o)}}_onCommentModeChange(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentModeChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_MODE_CHANGE_TRIGGERED),this.getService(Re).addCommentModeChange()}catch(o){return this.getService(k).catch("Error in _onCommentModeChange: ",o),de(!1)}}_enableAttachment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENTS_TRIGGERED),this.getService(Re).enableAttachment(!0)}catch(o){this.getService(k).catch("Error in _enableAttachment: ",o)}}_disableAttachment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENTS_TRIGGERED),this.getService(Re).enableAttachment(!1)}catch(o){this.getService(k).catch("Error in _disableAttachment: ",o)}}_enableAttachmentDownload(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAttachmentDownload","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENT_DOWNLOAD_TRIGGERED),this.getService(Re).enableAttachmentDownload()}catch(o){this.getService(k).catch("Error in _enableAttachmentDownload: ",o)}}_disableAttachmentDownload(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAttachmentDownload","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENT_DOWNLOAD_TRIGGERED),this.getService(Re).disableAttachmentDownload()}catch(o){this.getService(k).catch("Error in _disableAttachmentDownload: ",o)}}_isUserGlobalContact(){this.getService(k).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Comments.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(Re).isUserGlobalContact$()}catch(o){return this.getService(k).catch("Error in _isUserGlobalContact: ",o),de(!1)}}_enableDeviceInfo(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INFO_TRIGGERED),this.getService(Re).showScreenSizeInfo(!0)}catch(o){this.getService(k).catch("Error in _enableDeviceInfo: ",o)}}_disableDeviceInfo(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INFO_TRIGGERED),this.getService(Re).showScreenSizeInfo(!1)}catch(o){this.getService(k).catch("Error in _disableDeviceInfo: ",o)}}_enableCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_MODE_TRIGGERED),this.getService(Re).enableAddCommentMode()}catch(o){this.getService(k).catch("Error in _enableCommentMode: ",o)}}_disableCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_MODE_TRIGGERED),this.getService(Re).disableAddCommentMode()}catch(o){this.getService(k).catch("Error in _disableCommentMode: ",o)}}_enablePersistentCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(Re).enablePersistentCommentMode()}catch(o){this.getService(k).catch("Error in _enablePersistentCommentMode: ",o)}}_disablePersistentCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(Re).disablePersistentCommentMode()}catch(o){this.getService(k).catch("Error in _disablePersistentCommentMode: ",o)}}_showCommentIndex(o){this.getService(k).log("%c[WB] Calling FUNCTION: showCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENT_INDEX_TRIGGERED,{payload:{show:o}}),this.getService(Re).showCommentIndex(o)}catch(r){this.getService(k).catch("Error in _showCommentIndex: ",r)}}_enableCommentIndex(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_INDEX_TRIGGERED),this.getService(Re).showCommentIndex(!0)}catch(o){this.getService(k).catch("Error in _enableCommentIndex: ",o)}}_disableCommentIndex(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_INDEX_TRIGGERED),this.getService(Re).showCommentIndex(!1)}catch(o){this.getService(k).catch("Error in _disableCommentIndex: ",o)}}_enablePopoverMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_MODE_TRIGGERED),this.getService(Re).enablePopoverMode()}catch(o){this.getService(k).catch("Error in _enablePopoverMode: ",o)}}_disablePopoverMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_MODE_TRIGGERED),this.getService(Re).disablePopoverMode()}catch(o){this.getService(k).catch("Error in _disablePopoverMode: ",o)}}_enableDialogOnHover(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(Re).setEnableDialogOnHover(!0)}catch(o){this.getService(k).catch("Error in _enableDialogOnHover: ",o)}}_disableDialogOnHover(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(Re).setEnableDialogOnHover(!1)}catch(o){this.getService(k).catch("Error in _disableDialogOnHover: ",o)}}_enablePopoverTriangleComponent(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(Re).enablePopoverTriangleComponent()}catch(o){this.getService(k).catch("Error in _enablePopoverTriangleComponent: ",o)}}_disablePopoverTriangleComponent(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(Re).disablePopoverTriangleComponent()}catch(o){this.getService(k).catch("Error in _disablePopoverTriangleComponent: ",o)}}_enableDialogOnTargetElementClick(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(Re).setEnableDialogOnTargetElementClick(!0)}catch(o){this.getService(k).catch("Error in _enableDialogOnTargetElementClick: ",o)}}_disableDialogOnTargetElementClick(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(Re).setEnableDialogOnTargetElementClick(!1)}catch(o){this.getService(k).catch("Error in _disableDialogOnTargetElementClick: ",o)}}_enablePriority(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIORITY_TRIGGERED),this.getService(Re).setEnablePriority(!0)}catch(o){this.getService(k).catch("Error in _enablePriority: ",o)}}_disablePriority(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIORITY_TRIGGERED),this.getService(Re).setEnablePriority(!1)}catch(o){this.getService(k).catch("Error in _disablePriority: ",o)}}_enableStatus(){this.getService(k).log("%c[WB] Calling FUNCTION: enableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STATUS_TRIGGERED),this.getService(Re).setEnableStatus(!0)}catch(o){this.getService(k).catch("Error in _enableStatus: ",o)}}_disableStatus(){this.getService(k).log("%c[WB] Calling FUNCTION: disableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STATUS_TRIGGERED),this.getService(Re).setEnableStatus(!1)}catch(o){this.getService(k).catch("Error in _disableStatus: ",o)}}_enableVisibilityOptions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableVisibilityOptions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_VISIBILITY_OPTIONS_TRIGGERED),this.getService(Re).setEnableVisibilityOptions(!0)}catch(o){this.getService(k).catch("Error in _enableVisibilityOptions: ",o)}}_disableVisibilityOptions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableVisibilityOptions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_VISIBILITY_OPTIONS_TRIGGERED),this.getService(Re).setEnableVisibilityOptions(!1)}catch(o){this.getService(k).catch("Error in _disableVisibilityOptions: ",o)}}_enableResolveButton(){this.getService(k).log("%c[WB] Calling FUNCTION: enableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(Re).setEnableResolve(!0)}catch(o){this.getService(k).catch("Error in _enableResolveButton: ",o)}}_disableResolveButton(){this.getService(k).log("%c[WB] Calling FUNCTION: disableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(Re).setEnableResolve(!1)}catch(o){this.getService(k).catch("Error in _disableResolveButton: ",o)}}_enableGhostComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_TRIGGERED),this.getService(Re).enableGhostComments()}catch(o){this.getService(k).catch("Error in _enableGhostCommentsInDOM: ",o)}}_disableGhostComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_TRIGGERED),this.getService(Re).disableGhostComments()}catch(o){this.getService(k).catch("Error in _disableGhostComments: ",o)}}_enableGhostCommentsIndicator(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(Re).enableGhostCommentsMessage()}catch(o){this.getService(k).catch("Error in _enableGhostCommentsIndicator: ",o)}}_disableGhostCommentsIndicator(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(Re).disableGhostCommentsMessage()}catch(o){this.getService(k).catch("Error in _disableGhostCommentsIndicator: ",o)}}_setCustomStatus(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomStatus","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_STATUS_TRIGGERED,{payload:{customStatuses:o}}),this.getService(Re).setCustomStatuses(o)}catch(r){this.getService(k).catch("Error in _setCustomStatus: ",r)}}_enableInboxMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INBOX_MODE_TRIGGERED),this.getService(Re).enableInboxMode()}catch(o){this.getService(k).catch("Error in _enableInboxMode: ",o)}}_setCustomPriority(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomPriority","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_PRIORITY_TRIGGERED,{payload:{customPriorities:o}}),this.getService(Re).setCustomPriorities(o)}catch(r){this.getService(k).catch("Error in _setCustomPriority: ",r)}}_setCustomCategory(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomCategory","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_CATEGORY_TRIGGERED,{payload:{customCategories:o}}),this.getService(Re).setCustomCategories(o)}catch(r){this.getService(k).catch("Error in _setCustomCategory: ",r)}}_disableInboxMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INBOX_MODE_TRIGGERED),this.getService(Re).disableInboxMode()}catch(o){this.getService(k).catch("Error in _disableInboxMode: ",o)}}_enableAutoCategorize(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(Re).setEnableAutoCategorize(!0)}catch(o){this.getService(k).catch("Error in _enableAutoCategorize: ",o)}}_disableAutoCategorize(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(Re).setEnableAutoCategorize(!1)}catch(o){this.getService(k).catch("Error in _disableAutoCategorize: ",o)}}_enableDarkMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DARK_MODE_TRIGGERED),this.getService(Re).setCommentContainerDarkMode(!0)}catch(o){this.getService(k).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DARK_MODE_TRIGGERED),this.getService(Re).setCommentContainerDarkMode(!1)}catch(o){this.getService(k).catch("Error in _disableDarkMode: ",o)}}_setContextProvider(o){try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_PROVIDER_TRIGGERED,{payload:{}}),this.getService(Re).setContextProvider(o)}catch(r){this.getService(k).catch("Error in _setContextProvider: ",r)}}_enableSuggestionMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SUGGESTION_MODE_TRIGGERED),this.getService(Re).setSuggestionMode(!0)}catch(o){this.getService(k).catch("Error in _enableSuggestionMode: ",o)}}_disableSuggestionMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SUGGESTION_MODE_TRIGGERED),this.getService(Re).setSuggestionMode(!1)}catch(o){this.getService(k).catch("Error in _disableSuggestionMode: ",o)}}_enableMobileMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MOBILE_MODE_TRIGGERED),this.getService(Re).setMobileMode(!0)}catch(o){this.getService(k).catch("Error in _enableMobileMode: ",o)}}_disableMobileMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MOBILE_MODE_TRIGGERED),this.getService(Re).setMobileMode(!1)}catch(o){this.getService(k).catch("Error in _disableMobileMode: ",o)}}_enableInlineCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(Re).enableInlineCommentMode()}catch(o){this.getService(k).catch("Error in _enableInlineCommentMode: ",o)}}_disableInlineCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(Re).disableInlineCommentMode()}catch(o){this.getService(k).catch("Error in _disableInlineCommentMode: ",o)}}_enableMinimap(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MINIMAP_TRIGGERED),this.getService(Re).enableMinimap()}catch(o){this.getService(k).catch("Error in _enableMinimap: ",o)}}_disableMinimap(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MINIMAP_TRIGGERED),this.getService(Re).disableMinimap()}catch(o){this.getService(k).catch("Error in _disableMinimap: ",o)}}_showCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: showCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).showCommentsOnDom()}catch(o){this.getService(k).catch("Error in _showCommentsOnDom: ",o)}}_hideCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: hideCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).hideCommentsOnDom()}catch(o){this.getService(k).catch("Error in _hideCommentsOnDom: ",o)}}_enableCommentTool(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TOOL_TRIGGERED),this.getService(Re).enableCommentTool()}catch(o){this.getService(k).catch("Error in _enableCommentTool: ",o)}}_disableCommentTool(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TOOL_TRIGGERED),this.getService(Re).disableCommentTool()}catch(o){this.getService(k).catch("Error in _disableCommentTool: ",o)}}_setTotalMediaLength(o){this.getService(k).log("%c[WB] Calling FUNCTION: setTotalMediaLength","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TOTAL_MEDIA_LENGTH_TRIGGERED,{payload:{length:o}}),this.getService(Re).setTotalMediaLength(o)}catch(r){this.getService(k).catch("Error in _setTotalMediaLength: ",r)}}_onCommentAdd(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentAdd","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_ADD_TRIGGERED),this.getService(Re).onCommentAdd$()}catch(o){return this.getService(k).catch("Error in _onCommentAdd: ",o),de()}}_onCommentUpdate(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentUpdate","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_UPDATE_TRIGGERED),this.getService(Re).onCommentUpdate$()}catch(o){return this.getService(k).catch("Error in _onCommentUpdate: ",o),de()}}_addCommentOnSelectedText(){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentOnSelectedText","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_SELECTED_TEXT_TRIGGERED),this.getService(Re).addCommentOnSelectedText()}catch(o){this.getService(k).catch("Error in _addCommentOnSelectedText: ",o)}}_enableSidebarUrlNavigation(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(Re).enableSidebarUrlNavigation()}catch(o){this.getService(k).catch("Error in _enableSidebarUrlNavigation: ",o)}}_disableSidebarUrlNavigation(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(Re).disableSidebarUrlNavigation()}catch(o){this.getService(k).catch("Error in _disableSidebarUrlNavigation: ",o)}}_setDStrategy(o){this.getService(k).log("%c[WB] Calling FUNCTION: setDStrategy","color: green;");try{this.trackEvent(Y.Events.Comments.SET_D_STRATEGY_TRIGGERED,{payload:{strategy:o}}),this.getService(Re).setDetectionStrategy(o)}catch(r){this.getService(k).catch("Error in _setDStrategy: ",r)}}_enableSidebarButtonOnCommentDialog(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(Re).enableSidebarButtonOnCommentDialog()}catch(o){this.getService(k).catch("Error in _enableSidebarButtonOnCommentDialog: ",o)}}_disableSidebarButtonOnCommentDialog(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(Re).disableSidebarButtonOnCommentDialog()}catch(o){this.getService(k).catch("Error in _disableSidebarButtonOnCommentDialog: ",o)}}_onSidebarButtonOnCommentDialogClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onSidebarButtonOnCommentDialogClick","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_CLICK_TRIGGERED),this.getService(Re).getSidebarButtonOnCommentDialogClick$()}catch(o){return this.getService(k).catch("Error in _onSidebarButtonOnCommentDialogClick: ",o),de(null)}}_enableReactions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REACTIONS_TRIGGERED),this.getService(Re).enableReactions()}catch(o){this.getService(k).catch("Error in _enableReactions: ",o)}}_disableReactions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REACTIONS_TRIGGERED),this.getService(Re).disableReactions()}catch(o){this.getService(k).catch("Error in _disableReactions: ",o)}}_enableAnonymousEmail(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAnonymousEmail","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ANONYMOUS_EMAIL_TRIGGERED),this.getService(Re).enableAnonymousEmail()}catch(o){this.getService(k).catch("Error in _enableAnonymousEmail: ",o)}}_disableAnonymousEmail(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAnonymousEmail","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ANONYMOUS_EMAIL_TRIGGERED),this.getService(Re).disableAnonymousEmail()}catch(o){this.getService(k).catch("Error in _disableAnonymousEmail: ",o)}}_setRecordings(o){this.getService(k).log("%c[WB] Calling FUNCTION: setRecordings","color: green;");try{this.trackEvent(Y.Events.Comments.SET_RECORDINGS_TRIGGERED,{payload:{allowedRecordings:o}}),typeof o=="string"&&(o=o?.split(",")?.map(r=>r.trim())),this.getService(Re).setAllowedRecordings(o)}catch(r){this.getService(k).catch("Error in _setRecordings: ",r)}}_addCommentOnElement(o){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentOnElement","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_ELEMENT_TRIGGERED,{payload:{data:o}}),this.getService(Re).addCommentOnElement(o)}catch(r){this.getService(k).catch("Error in _addCommentOnElement: ",r)}}_enablePrivateCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(Re).enablePrivateCommentMode()}catch(o){this.getService(k).catch("Error in _enablePrivateCommentMode: ",o)}}_disablePrivateCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(Re).disablePrivateCommentMode()}catch(o){this.getService(k).catch("Error in _disablePrivateCommentMode: ",o)}}_enablePrivateMode(o){this.getService(k).log("%c[WB] Calling FUNCTION: enablePrivateMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_MODE_TRIGGERED,{payload:{config:o}}),this.getService(Re).enablePrivateMode(o)}catch(r){this.getService(k).catch("Error in _enablePrivateMode: ",r)}}_disablePrivateMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePrivateMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_MODE_TRIGGERED),this.getService(Re).disablePrivateMode()}catch(o){this.getService(k).catch("Error in _disablePrivateMode: ",o)}}_enableScrollToComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(Re).enableScrollToComment()}catch(o){this.getService(k).catch("Error in _enableScrollToComment: ",o)}}_disableScrollToComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(Re).disableScrollToComment()}catch(o){this.getService(k).catch("Error in _disableScrollToComment: ",o)}}_enableUserMentions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_USER_MENTIONS_TRIGGERED),this.getService(Re).enableUserMentions()}catch(o){this.getService(k).catch("Error in _enableUserMentions: ",o)}}_disableUserMentions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_USER_MENTIONS_TRIGGERED),this.getService(Re).disableUserMentions()}catch(o){this.getService(k).catch("Error in _disableUserMentions: ",o)}}_setCommentSidebarFilters(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_FILTERS_TRIGGERED,{payload:{filters:o}}),this.getService(Re).setCommentSidebarFilters(o)}catch(r){this.getService(k).catch("Error in _setCommentSidebarFilters: ",r)}}_setSystemFiltersOperator(o){this.getService(k).log("%c[WB] Calling FUNCTION: setSystemFiltersOperator","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SYSTEM_FILTERS_OPERATOR_TRIGGERED,{payload:{operator:o}}),this.getService(Re).setCommentSidebarSystemFiltersOperator(o)}catch(r){this.getService(k).catch("Error in _setSystemFiltersOperator: ",r)}}_enableCommentPinHighlighter(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(Re).enableCommentPinHighlighter()}catch(o){this.getService(k).catch("Error in _enableCommentPinHighlighter: ",o)}}_disableCommentPinHighlighter(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(Re).disableCommentPinHighlighter()}catch(o){this.getService(k).catch("Error in _disableCommentPinHighlighter: ",o)}}_enableDeleteOnBackspace(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(Re).enableDeleteOnBackspace()}catch(o){this.getService(k).catch("Error in _enableDeleteOnBackspace: ",o)}}_disableDeleteOnBackspace(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(Re).disableDeleteOnBackspace()}catch(o){this.getService(k).catch("Error in _disableDeleteOnBackspace: ",o)}}_enableHotkey(){this.getService(k).log("%c[WB] Calling FUNCTION: enableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_HOTKEY_TRIGGERED),this.getService(Re).enableHotkey()}catch(o){this.getService(k).catch("Error in _enableHotkey: ",o)}}_disableHotkey(){this.getService(k).log("%c[WB] Calling FUNCTION: disableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_HOTKEY_TRIGGERED),this.getService(Re).disableHotkey()}catch(o){this.getService(k).catch("Error in _disableHotkey: ",o)}}_enableDeviceIndicatorOnCommentPins(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(Re).enableDeviceIndicatorOnCommentPins()}catch(o){this.getService(k).catch("Error in _enableDeviceIndicatorOnCommentPins: ",o)}}_disableDeviceIndicatorOnCommentPins(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(Re).disableDeviceIndicatorOnCommentPins()}catch(o){this.getService(k).catch("Error in _disableDeviceIndicatorOnCommentPins: ",o)}}_getElementRefByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getElementRefByAnnotationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ELEMENT_REF_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).getElementRefByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _getElementRefByAnnotationId: ",r);return}}_scrollToCommentByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: scrollToCommentByAnnotationId","color: green;");try{this.trackEvent(Y.Events.Comments.SCROLL_TO_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).scrollToCommentByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _scrollToCommentByAnnotationId: ",r)}}_selectCommentByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");try{this.trackEvent(Y.Events.Comments.SELECT_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(Re).selectCommentByAnnotationId(o)}catch(r){this.getService(k).catch("Error in _selectCommentByAnnotationId: ",r)}}_enableRecordingSummary(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(Re).enableRecordingSummary()}catch(o){this.getService(k).catch("Error in _enableRecordingSummary: ",o)}}_disableRecordingSummary(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(Re).disableRecordingSummary()}catch(o){this.getService(k).catch("Error in _disableRecordingSummary: ",o)}}_enableRecordingTranscription(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(fo).enableRecordingTranscription()}catch(o){this.getService(k).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(fo).disableRecordingTranscription()}catch(o){this.getService(k).catch("Error in _disableRecordingTranscription: ",o)}}_enableRecordingCountdown(){this.getService(k).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(Re).enableRecordingCountdown()}catch(o){this.getService(k).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(k).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(Re).disableRecordingCountdown()}catch(o){this.getService(k).catch("Error in _disableRecordingCountdown: ",o)}}_setUnreadIndicatorMode(o){this.getService(k).log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;");try{this.trackEvent(Y.Events.Comments.SET_UNREAD_INDICATOR_MODE_TRIGGERED,{payload:{mode:o}}),this.getService(Re).setUnreadIndicatorMode(o)}catch(r){this.getService(k).catch("Error in _setUnreadIndicatorMode: ",r)}}_enableEnterKeyToSubmit(){this.getService(k).log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(Re).enableEnterKeyToSubmit()}catch(o){this.getService(k).catch("Error in _enableEnterKeyToSubmit: ",o)}}_disableEnterKeyToSubmit(){this.getService(k).log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(Re).disableEnterKeyToSubmit()}catch(o){this.getService(k).catch("Error in _disableEnterKeyToSubmit: ",o)}}_enablePinShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(Re).enablePinShadowDOM()}catch(o){this.getService(k).catch("Error in _enablePinShadowDOM: ",o)}}_disablePinShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(Re).disablePinShadowDOM()}catch(o){this.getService(k).catch("Error in _disablePinShadowDOM: ",o)}}_enableDialogShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(Re).enableDialogShadowDOM()}catch(o){this.getService(k).catch("Error in _enableDialogShadowDOM: ",o)}}_disableDialogShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(Re).disableDialogShadowDOM()}catch(o){this.getService(k).catch("Error in _disableDialogShadowDOM: ",o)}}_enableSidebarShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(Re).enableSidebarShadowDOM()}catch(o){this.getService(k).catch("Error in _enableSidebarShadowDOM: ",o)}}_disableSidebarShadowDOM(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(Re).disableSidebarShadowDOM()}catch(o){this.getService(k).catch("Error in _disableSidebarShadowDOM: ",o)}}_enableChangeDetectionInCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(Re).enableChangeDetectionInCommentMode()}catch(o){this.getService(k).catch("Error in _enableChangeDetectionInCommentMode: ",o)}}_disableChangeDetectionInCommentMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(Re).disableChangeDetectionInCommentMode()}catch(o){this.getService(k).catch("Error in _disableChangeDetectionInCommentMode: ",o)}}_showResolvedCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: showResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).showResolvedCommentsOnDom()}catch(o){this.getService(k).catch("Error in _showResolvedCommentsOnDom: ",o)}}_hideResolvedCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: hideResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).hideResolvedCommentsOnDom()}catch(o){this.getService(k).catch("Error in _hideResolvedCommentsOnDom: ",o)}}_setCustomReactions(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(Re).setCustomReactions(o)}catch(r){this.getService(k).catch("Error in _setCustomReactions: ",r)}}_onCommentSelectionChange(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSelectionChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SELECTION_CHANGE_TRIGGERED),this.getService(Re).onCommentSelectionChange$()}catch(o){return this.getService(k).catch("Error in _onCommentSelectionChange: ",o),de(null)}}_getUnreadCommentCountByAnnotationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByAnnotationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_ANNOTATION_ID_TRIGGERED,{payload:{commentAnnotationId:o}}),this.getService(Re).getUnreadCommentCountByAnnotationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentCountByAnnotationId: ",r),de(null)}}_getUnreadCommentAnnotationCountOnCurrentDocument(){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(Re).getUnreadCommentAnnotationCountOnCurrentDocument$()}catch(o){return this.getService(k).catch("Error in _getUnreadCommentAnnotationCountOnCurrentDocument: ",o),de(null)}}_getUnreadCommentCountOnCurrentDocument(){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(Re).getUnreadCommentCountOnCurrentDocument$()}catch(o){return this.getService(k).catch("Error in _getUnreadCommentCountOnCurrentDocument: ",o),de(null)}}_getUnreadCommentAnnotationCountByLocationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountByLocationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(Re).getUnreadCommentAnnotationCountByLocationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentAnnotationCountByLocationId: ",r),de(null)}}_getUnreadCommentCountByLocationId(o){this.getService(k).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByLocationId","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(Re).getUnreadCommentCountByLocationId$(o)}catch(r){return this.getService(k).catch("Error in _getUnreadCommentCountByLocationId: ",r),de(null)}}_updateCommentDialogPosition(){this.getService(k).log("%c[WB] Calling FUNCTION: updateCommentDialogPosition","color: green;");try{this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_DIALOG_POSITION_TRIGGERED),this.getService(Re).updateCommentDialogPosition()}catch(o){this.getService(k).catch("Error in _updateCommentDialogPosition: ",o)}}_enableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Re).enableAreaComment()}catch(o){this.getService(k).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Re).disableAreaComment()}catch(o){this.getService(k).catch("Error in _disableAreaComment: ",o)}}_setPinCursorImage(o){this.getService(k).log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;");try{this.trackEvent(Y.Events.Comments.SET_PIN_CURSOR_IMAGE_TRIGGERED,{payload:{image:o}}),this.getService(Re).setPinCursorImage(o)}catch(r){this.getService(k).catch("Error in _setPinCursorImage: ",r)}}_addManualComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: addManualComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_MANUAL_COMMENT_TRIGGERED,{payload:{config:o}}),this.getService(Re).addManualComment(o)}catch(r){return this.getService(k).catch("Error in _addManualComment: ",r),Promise.resolve()}}_createCustomListDataOnAnnotation(o){this.getService(k).log("%c[WB] Calling FUNCTION: createCustomListDataOnAnnotation","color: green;");try{this.trackEvent(Y.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_ANNOTATION_TRIGGERED,{payload:{data:o}}),this.getService(Re).createCustomListDataOnAnnotation(o)}catch(r){this.getService(k).catch("Error in _createCustomListDataOnAnnotation: ",r)}}_createCustomListDataOnComment(o){this.getService(k).log("%c[WB] Calling FUNCTION: createCustomListDataOnComment","color: green;");try{return this.trackEvent(Y.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_COMMENT_TRIGGERED,{payload:{data:o}}),this.getService(Pc).create(o)}catch(r){this.getService(k).catch("Error in _createCustomListDataOnComment: ",r)}}_excludeLocationIdsFromSidebar(o){this.getService(k).log("%c[WB] Calling FUNCTION: excludeLocationIdsFromSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.EXCLUDE_LOCATION_IDS_FROM_SIDEBAR_TRIGGERED,{payload:{locationIds:o}}),this.getService(Re).setExcludeLocationIdsFromSidebar(o)}catch(r){this.getService(k).catch("Error in _excludeLocationIdsFromSidebar: ",r)}}_enableBubbleOnPin(){this.getService(k).log("%c[WB] Calling FUNCTION: enableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(Re).enableBubbleOnPin()}catch(o){this.getService(k).catch("Error in _enableBubbleOnPin: ",o)}}_disableBubbleOnPin(){this.getService(k).log("%c[WB] Calling FUNCTION: disableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(Re).disableBubbleOnPin()}catch(o){this.getService(k).catch("Error in _disableBubbleOnPin: ",o)}}_enableBubbleOnPinHover(){this.getService(k).log("%c[WB] Calling FUNCTION: enableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(Re).enableBubbleOnPinHover()}catch(o){this.getService(k).catch("Error in _enableBubbleOnPinHover: ",o)}}_disableBubbleOnPinHover(){this.getService(k).log("%c[WB] Calling FUNCTION: disableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(Re).disableBubbleOnPinHover()}catch(o){this.getService(k).catch("Error in _disableBubbleOnPinHover: ",o)}}_enablePinDrag(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePinDrag","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_DRAG_TRIGGERED),this.getService(Re).enablePinDrag()}catch(o){this.getService(k).catch("Error in _enablePinDrag: ",o)}}_disablePinDrag(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePinDrag","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_DRAG_TRIGGERED),this.getService(Re).disablePinDrag()}catch(o){this.getService(k).catch("Error in _disablePinDrag: ",o)}}_enableMultiThread(){this.getService(k).log("%c[WB] Calling FUNCTION: enableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MULTI_THREAD_TRIGGERED),this.getService(Re).enableMultiThread()}catch(o){this.getService(k).catch("Error in _enableMultiThread: ",o)}}_disableMultiThread(){this.getService(k).log("%c[WB] Calling FUNCTION: disableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MULTI_THREAD_TRIGGERED),this.getService(Re).disableMultiThread()}catch(o){this.getService(k).catch("Error in _disableMultiThread: ",o)}}_enableGroupMatchedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(Re).enableGroupMatchedComments()}catch(o){this.getService(k).catch("Error in _enableGroupMatchedComments: ",o)}}_disableGroupMatchedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(Re).disableGroupMatchedComments()}catch(o){this.getService(k).catch("Error in _disableGroupMatchedComments: ",o)}}_updateContext(o,r,e){this.getService(k).log("%c[WB] Calling FUNCTION: updateContext","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_CONTEXT_TRIGGERED,{payload:{annotationId:o,context:r,config:e}}),this.getService(Re).updateCommentAnnotationContext(o,r,e)}catch(t){return this.getService(k).catch("Error in _updateContext: ",t),Promise.resolve()}}_updateVisibility(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateVisibility","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_VISIBILITY_TRIGGERED,{payload:{visibility:o}}),this.getService(Rn).updateVisibility(o)}catch(r){return this.getService(k).catch("Error in _updateVisibility: ",r),Promise.resolve()}}_getSelectedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: getSelectedComments","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_SELECTED_COMMENTS_TRIGGERED),this.getService(Ve).getSelectedComments$()}catch(o){return this.getService(k).catch("Error in _getSelectedComments: ",o),de([])}}_enableDeleteReplyConfirmation(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(Re).enableDeleteReplyConfirmation()}catch(o){this.getService(k).catch("Error in _enableDeleteReplyConfirmation: ",o)}}_disableDeleteReplyConfirmation(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(Re).disableDeleteReplyConfirmation()}catch(o){this.getService(k).catch("Error in _disableDeleteReplyConfirmation: ",o)}}_onCopyLink(){this.getService(k).log("%c[WB] Calling FUNCTION: onCopyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COPY_LINK_TRIGGERED),this.getService(Re).getCopyLink$()}catch(o){return this.getService(k).catch("Error in _onCopyLink: ",o),de("")}}_getCommentAnnotationById(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotationById","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATION_BY_ID_TRIGGERED,{payload:{config:o}}),this.getService(Re).getCommentAnnotationById(o)}catch(r){return this.getService(k).catch("Error in _getCommentAnnotationById: ",r),de(null)}}_enableCollapsedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(Re).enableCollapsedComments()}catch(o){this.getService(k).catch("Error in _enableCollapsedComments: ",o)}}_disableCollapsedComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(Re).disableCollapsedComments()}catch(o){this.getService(k).catch("Error in _disableCollapsedComments: ",o)}}_onCommentSidebarActionButtonClick(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarActionButtonClick","color: green;");try{return this.getService(Re).getSidebarCustomActionEventData()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarActionButtonClick: ",o),de(null)}}_setCommentSidebarData(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarData","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DATA_TRIGGERED,{payload:{data:o,options:r}}),this.getService(Re).setCommentSidebarData(o,r)}catch(e){this.getService(k).catch("Error in _setCommentSidebarData: ",e)}}_onCommentSidebarInit(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarInit","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_INIT_TRIGGERED),this.getService(Re).getSidebarCustomActionEventDataOnInit()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarInit: ",o),de(null)}}_onCommentSidebarData(){this.getService(k).log("%c[WB] Calling FUNCTION: onCommentSidebarData","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_DATA_TRIGGERED),this.getService(Re).getSidebarCustomActionEventDataAllChanges()}catch(o){return this.getService(k).catch("Error in _onCommentSidebarData: ",o),de(null)}}_setCommentSidebarDefaultCustomActions(o){this.getService(k).log("%c[WB] Calling FUNCTION: setCommentSidebarDefaultCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DEFAULT_CUSTOM_ACTIONS_TRIGGERED,{payload:{actions:o}}),this.getService(Re).setSidebarCustomActionEventData(o,[],{},[],{})}catch(r){this.getService(k).catch("Error in _setCommentSidebarDefaultCustomActions: ",r)}}_enableSidebarCustomActions(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(Re).enableSidebarCustomActions()}catch(o){this.getService(k).catch("Error in _enableSidebarCustomActions: ",o)}}_disableSidebarCustomActions(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(Re).disableSidebarCustomActions()}catch(o){this.getService(k).catch("Error in _disableSidebarCustomActions: ",o)}}_enableQueryParamsComments(){this.getService(k).log("%c[WB] Calling FUNCTION: enableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(Re).enableQueryParamsComments()}catch(o){this.getService(k).catch("Error in _enableQueryParamsComments: ",o)}}_disableQueryParamsComments(){this.getService(k).log("%c[WB] Calling FUNCTION: disableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(Re).disableQueryParamsComments()}catch(o){this.getService(k).catch("Error in _disableQueryParamsComments: ",o)}}_enableResolveStatusAccessAdminOnly(){this.getService(k).log("%c[WB] Calling FUNCTION: enableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(Re).enableResolveStatusAccessAdminOnly()}catch(o){this.getService(k).catch("Error in _enableResolveStatusAccessAdminOnly: ",o)}}_disableResolveStatusAccessAdminOnly(){this.getService(k).log("%c[WB] Calling FUNCTION: disableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(Re).disableResolveStatusAccessAdminOnly()}catch(o){this.getService(k).catch("Error in _disableResolveStatusAccessAdminOnly: ",o)}}_enableLinkCallback(){this.getService(k).log("%c[WB] Calling FUNCTION: enableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_LINK_CALLBACK_TRIGGERED),this.getService(Re).enableLinkCallback()}catch(o){this.getService(k).catch("Error in _enableLinkCallback: ",o)}}_disableLinkCallback(){this.getService(k).log("%c[WB] Calling FUNCTION: disableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_LINK_CALLBACK_TRIGGERED),this.getService(Re).disableLinkCallback()}catch(o){this.getService(k).catch("Error in _disableLinkCallback: ",o)}}_enableSeenByUsers(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SEEN_BY_USERS_TRIGGERED),this.getService(Re).enableSeenByUsers()}catch(o){this.getService(k).catch("Error in _enableSeenByUsers: ",o)}}_disableSeenByUsers(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SEEN_BY_USERS_TRIGGERED),this.getService(Re).disableSeenByUsers()}catch(o){this.getService(k).catch("Error in _disableSeenByUsers: ",o)}}_enableShortUserName(){this.getService(k).log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SHORT_USER_NAME_TRIGGERED),this.getService(Re).enableShortUserName()}catch(o){this.getService(k).catch("Error in _enableShortUserName: ",o)}}_disableShortUserName(){this.getService(k).log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SHORT_USER_NAME_TRIGGERED),this.getService(Re).disableShortUserName()}catch(o){this.getService(k).catch("Error in _disableShortUserName: ",o)}}_addCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_ANNOTATION_TRIGGERED,{payload:{addCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).addCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _addCommentAnnotation: ",r),null}})}_approveCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: approveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.APPROVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{approveCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).approveCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _approveCommentAnnotation: ",r),null}})}_acceptCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: acceptCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ACCEPT_COMMENT_ANNOTATION_TRIGGERED,{payload:{acceptCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).acceptCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _acceptCommentAnnotation: ",r),null}})}_rejectCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: rejectCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.REJECT_COMMENT_ANNOTATION_TRIGGERED,{payload:{rejectCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).rejectCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _rejectCommentAnnotation: ",r),null}})}_subscribeCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: subscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.SUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{subscribeCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).toggleNotificationSubscription(o,"subscribe")}catch(r){return this.getService(k).catch("Error in _subscribeCommentAnnotation: ",r),null}})}_unsubscribeCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: unsubscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.UNSUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{unsubscribeCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).toggleNotificationSubscription(o,"unsubscribe")}catch(r){return this.getService(k).catch("Error in _unsubscribeCommentAnnotation: ",r),null}})}_deleteCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_ANNOTATION_TRIGGERED,{payload:{deleteCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).deleteCommentAnnotation(o,"external")}catch(r){return this.getService(k).catch("Error in _deleteCommentAnnotation: ",r),null}})}_getCommentAnnotations(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{query:o}}),this.getService(Rn).getCommentAnnotations(o).pipe(ge(r=>(r.data&&Object.keys(r.data).forEach(e=>{if(r.data?.[e]?.length){let t=r.data[e];r.data[e]=t?.map(i=>this.getService(Re).getCommentAnnotationForClient(i))}}),r)))}catch(r){return this.getService(k).catch("Error in _getCommentAnnotations: ",r),de({data:null})}}_getCommentAnnotationsCount(o){this.getService(k).log("%c[WB] Calling FUNCTION: getCommentAnnotationsCount","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_COUNT_TRIGGERED,{payload:{query:o}}),this.getService(Rn).getCommentAnnotationsCount$(o)}catch(r){return this.getService(k).catch("Error in _getCommentAnnotationsCount: ",r),de({data:null})}}_assignUser(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: assignUser","color: green;");try{return this.trackEvent(Y.Events.Comments.ASSIGN_USER_TRIGGERED,{payload:{assignUserRequest:o}}),this.getService(Rn).convert(o).assignUser(o,"external")}catch(r){return this.getService(k).catch("Error in _assignUser: ",r),null}})}_updatePriority(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updatePriority","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_PRIORITY_TRIGGERED,{payload:{updatePriorityRequest:o}}),this.getService(Rn).convert(o).updatePriority(o,"external")}catch(r){return this.getService(k).catch("Error in _updatePriority: ",r),null}})}_updateStatus(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateStatus","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_STATUS_TRIGGERED,{payload:{updateStatusRequest:o}}),this.getService(Rn).convert(o).updateStatus(o,"external")}catch(r){return this.getService(k).catch("Error in _updateStatus: ",r),null}})}_updateAccess(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateAccess","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_ACCESS_TRIGGERED,{payload:{updateAccessRequest:o}}),this.getService(Rn).convert(o).updateAccess(o,"external")}catch(r){return this.getService(k).catch("Error in _updateAccess: ",r),null}})}_resolveCommentAnnotation(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: resolveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.RESOLVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{resolveCommentAnnotationRequest:o}}),this.getService(Rn).convert(o).resolveCommentAnnotation(o)}catch(r){return this.getService(k).catch("Error in _resolveCommentAnnotation: ",r),null}})}_getLink(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getLink","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_LINK_TRIGGERED,{payload:{getLinkRequest:o}}),this.getService(Rn).convert(o).getLink(o,"external")}catch(r){return this.getService(k).catch("Error in _getLink: ",r),null}})}_copyLink(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: copyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.COPY_LINK_TRIGGERED,{payload:{copyLinkRequest:o}}),this.getService(Rn).convert(o).copyLink(o,"external")}catch(r){return this.getService(k).catch("Error in _copyLink: ",r),null}})}_addComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_TRIGGERED,{payload:{addCommentRequest:o}}),this.getService(Rn).convert(o).addComment(o,"external")}catch(r){return this.getService(k).catch("Error in _addComment: ",r),null}})}_updateComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_TRIGGERED,{payload:{updateCommentRequest:o}}),this.getService(Rn).convert(o).updateComment(o,"external")}catch(r){return this.getService(k).catch("Error in _updateComment: ",r),null}})}_deleteComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_TRIGGERED,{payload:{deleteCommentRequest:o}}),this.getService(Rn).convert(o).deleteComment(o,"external")}catch(r){return this.getService(k).catch("Error in _deleteComment: ",r),null}})}_getComment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getComment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_TRIGGERED,{payload:{getCommentRequest:o}}),this.getService(Rn).convert(o).getComment(o)}catch(r){return this.getService(k).catch("Error in _getComment: ",r),[]}})}_addAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_ATTACHMENT_TRIGGERED,{payload:{addAttachmentRequest:o}}),this.getService(Rn).convert(o).addAttachment(o)}catch(r){return this.getService(k).catch("Error in _addAttachment: ",r),Promise.resolve([])}})}_deleteAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_ATTACHMENT_TRIGGERED,{payload:{deleteAttachmentRequest:o}}),this.getService(Rn).convert(o).deleteAttachment(o)}catch(r){return this.getService(k).catch("Error in _deleteAttachment: ",r),null}})}_getAttachment(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ATTACHMENT_TRIGGERED,{payload:{getAttachmentRequest:o}}),this.getService(Rn).convert(o).getAttachment(o)}catch(r){return this.getService(k).catch("Error in _getAttachment: ",r),[]}})}_getRecording(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: getRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_RECORDING_TRIGGERED,{payload:{getRecordingRequest:o}}),this.getService(Rn).convert(o).getRecording(o)}catch(r){return this.getService(k).catch("Error in _getRecording: ",r),[]}})}_deleteRecording(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_RECORDING_TRIGGERED,{payload:{deleteRecordingRequest:o}}),this.getService(Rn).convert(o).deleteRecording(o)}catch(r){return this.getService(k).catch("Error in _deleteRecording: ",r),null}})}_fetchCommentAnnotations(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: fetchCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.FETCH_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{fetchCommentAnnotationsRequest:o}}),this.getService(Rn).fetchCommentAnnotations(o)}catch(r){return this.getService(k).catch("Error in _fetchCommentAnnotations: ",r),{data:null}}})}_addReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_REACTION_TRIGGERED,{payload:{addReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o,"add")}catch(r){return this.getService(k).catch("Error in _addReaction: ",r),null}})}_deleteReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: deleteReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_REACTION_TRIGGERED,{payload:{deleteReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o,"delete")}catch(r){return this.getService(k).catch("Error in _deleteReaction: ",r),null}})}_toggleReaction(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: toggleReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.TOGGLE_REACTION_TRIGGERED,{payload:{toggleReactionRequest:o}}),this.getService(Rn).convert(o).toggleReaction(o)}catch(r){return this.getService(k).catch("Error in _toggleReaction: ",r),null}})}_on(o){this.getService(k).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(Rn).onAction(o)}catch(r){return this.getService(k).catch("Error in _on: ",r),de(null)}}_enableReadOnly(){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.ENABLE_READ_ONLY_TRIGGERED),this.getService(Re).enableReadOnly()}catch(o){this.getService(k).catch("Error in _toggleReaction: ",o);return}})}_disableReadOnly(){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.DISABLE_READ_ONLY_TRIGGERED),this.getService(Re).disableReadOnly()}catch(o){this.getService(k).catch("Error in _disableReadOnly: ",o);return}})}_setAssignToType(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAssignToType","color: green;");try{this.trackEvent(Y.Events.Comments.SET_ASSIGN_TO_TYPE_TRIGGERED,{payload:{type:o.type}}),this.getService(Re).setAssignToType(o)}catch(r){this.getService(k).catch("Error in _setAssignToType: ",r)}}_enableContextInPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: enableContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).enableContextInPageModeComposer()}catch(o){this.getService(k).catch("Error in _enableContextInPageModeComposer: ",o)}}_disableContextInPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: disableContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).disableContextInPageModeComposer()}catch(o){this.getService(k).catch("Error in _disableContextInPageModeComposer: ",o)}}_clearPageModeComposerContext(){this.getService(k).log("%c[WB] Calling FUNCTION: clearPageModeComposerContext","color: green;");try{this.trackEvent(Y.Events.Comments.CLEAR_PAGE_MODE_COMPOSER_CONTEXT_TRIGGERED),this.getService(Re).clearPageModeComposerContext()}catch(o){this.getService(k).catch("Error in _clearPageModeComposerContext: ",o)}}_setContextInPageModeComposer(o){this.getService(k).log("%c[WB] Calling FUNCTION: setContextInPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_IN_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).setPageModeComposerContext(o)}catch(r){this.getService(k).catch("Error in _setContextInPageModeComposer: ",r)}}_focusPageModeComposer(){this.getService(k).log("%c[WB] Calling FUNCTION: focusPageModeComposer","color: green;");try{this.trackEvent(Y.Events.Comments.FOCUS_PAGE_MODE_COMPOSER_TRIGGERED),this.getService(Re).focusPageModeComposer()}catch(o){this.getService(k).catch("Error in _focusPageModeComposer: ",o)}}_enableCustomAutocompleteSearch(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(Re).enableCustomAutocompleteSearch()}catch(o){this.getService(k).catch("Error in _enableCustomAutocompleteSearch: ",o);return}}_disableCustomAutocompleteSearch(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(Re).disableCustomAutocompleteSearch()}catch(o){this.getService(k).catch("Error in _disableCustomAutocompleteSearch: ",o);return}}_setTransformContext(o){this.getService(k).log("%c[WB] Calling FUNCTION: setTransformContext","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TRANSFORM_CONTEXT_TRIGGERED,{payload:{transformContext:o}}),this.getService(Re).setTransformContext(o)}catch(r){this.getService(k).catch("Error in _setTransformContext: ",r);return}}_enableSvgAsImg(){this.getService(k).log("%c[WB] Calling FUNCTION: enableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SVG_AS_IMG_TRIGGERED),this.getService(Re).enableSvgAsImg()}catch(o){this.getService(k).catch("Error in _enableSvgAsImg: ",o);return}}_disableSvgAsImg(){this.getService(k).log("%c[WB] Calling FUNCTION: disableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SVG_AS_IMG_TRIGGERED),this.getService(Re).disableSvgAsImg()}catch(o){this.getService(k).catch("Error in _disableSvgAsImg: ",o);return}}_enableFullExpanded(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_EXPANDED_TRIGGERED),this.getService(Re).enableFullExpanded()}catch(o){this.getService(k).catch("Error in _enableFullExpanded: ",o);return}}_disableFullExpanded(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_EXPANDED_TRIGGERED),this.getService(Re).disableFullExpanded()}catch(o){this.getService(k).catch("Error in _disableFullExpanded: ",o);return}}_enableCommentToNearestAllowedElement(){this.getService(k).log("%c[WB] Calling FUNCTION: enableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(Re).enableCommentToNearestAllowedElement()}catch(o){this.getService(k).catch("Error in _enableCommentToNearestAllowedElement: ",o);return}}_disableCommentToNearestAllowedElement(){this.getService(k).log("%c[WB] Calling FUNCTION: disableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(Re).disableCommentToNearestAllowedElement()}catch(o){this.getService(k).catch("Error in _disableCommentToNearestAllowedElement: ",o);return}}_enableDraftMode(){this.getService(k).log("%c[WB] Calling FUNCTION: enableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DRAFT_MODE_TRIGGERED),this.getService(Re).enableDraftMode()}catch(o){this.getService(k).catch("Error in _enableDraftMode: ",o);return}}_disableDraftMode(){this.getService(k).log("%c[WB] Calling FUNCTION: disableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DRAFT_MODE_TRIGGERED),this.getService(Re).disableDraftMode()}catch(o){this.getService(k).catch("Error in _disableDraftMode: ",o);return}}_enableFilterCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).enableFilterCommentsOnDom()}catch(o){this.getService(k).catch("Error in _enableFilterCommentsOnDom: ",o);return}}_disableFilterCommentsOnDom(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(Re).disableFilterCommentsOnDom()}catch(o){this.getService(k).catch("Error in _disableFilterCommentsOnDom: ",o);return}}_enableReplyAvatars(){this.getService(k).log("%c[WB] Calling FUNCTION: enableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REPLY_AVATARS_TRIGGERED),this.getService(Re).enableReplyAvatars()}catch(o){this.getService(k).catch("Error in _enableReplyAvatars: ",o);return}}_disableReplyAvatars(){this.getService(k).log("%c[WB] Calling FUNCTION: disableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REPLY_AVATARS_TRIGGERED),this.getService(Re).disableReplyAvatars()}catch(o){this.getService(k).catch("Error in _disableReplyAvatars: ",o);return}}_setMaxReplyAvatars(o){this.getService(k).log("%c[WB] Calling FUNCTION: setMaxReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.SET_MAX_REPLY_AVATARS_TRIGGERED,{payload:{maxReplyAvatars:o}}),this.getService(Re).setMaxReplyAvatars(o)}catch(r){this.getService(k).catch("Error in _setMaxReplyAvatars: ",r);return}}_setSidebarButtonCountType(o){this.getService(k).log("%c[WB] Calling FUNCTION: setSidebarButtonCountType","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SIDEBAR_BUTTON_COUNT_TYPE_TRIGGERED,{payload:{type:o}}),this.getService(Re).setSidebarButtonCountType(o)}catch(r){this.getService(k).catch("Error in _setSidebarButtonCountType: ",r);return}}_enableFilterGhostCommentsInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(Re).enableFilterGhostCommentsInSidebar()}catch(o){this.getService(k).catch("Error in _enableFilterGhostCommentsInSidebar: ",o);return}}_disableFilterGhostCommentsInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(Re).disableFilterGhostCommentsInSidebar()}catch(o){this.getService(k).catch("Error in _disableFilterGhostCommentsInSidebar: ",o);return}}_enableFullScreenInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: enableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(Re).enableFullScreenInSidebar()}catch(o){this.getService(k).catch("Error in _enableFullScreenInSidebar: ",o);return}}_disableFullScreenInSidebar(){this.getService(k).log("%c[WB] Calling FUNCTION: disableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(Re).disableFullScreenInSidebar()}catch(o){this.getService(k).catch("Error in _disableFullScreenInSidebar: ",o);return}}_setComposerFileAttachments(o){this.getService(k).log("%c[WB] Calling FUNCTION: setComposerFileAttachments","color: green;");try{this.getService(Re).setComposerFileAttachments(o),this.trackEvent(Y.Events.Comments.SET_COMPOSER_FILE_ATTACHMENTS_TRIGGERED,{payload:{data:o}})}catch(r){this.getService(k).catch("Error in _setComposerFileAttachments: ",r);return}}_setAllowedFileTypes(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAllowedFileTypes","color: green;");try{this.trackEvent(Y.Events.Comments.COMMENT_ATTACHMENT_SET_ALLOWED_FILE_TYPES_TRIGGERED,{payload:{allowedFileTypes:o}}),this.getService(Re).setAllowedFileTypes(o)}catch(r){this.getService(k).catch("Error in _setAllowedFileTypes: ",r);return}}_enableForceCloseAllOnEsc(){this.getService(k).log("%c[WB] Calling FUNCTION: enableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(Re).enableForceCloseAllOnEsc()}catch(o){this.getService(k).catch("Error in _enableForceCloseAllOnEsc: ",o);return}}_disableForceCloseAllOnEsc(){this.getService(k).log("%c[WB] Calling FUNCTION: disableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(Re).disableForceCloseAllOnEsc()}catch(o){this.getService(k).catch("Error in _disableForceCloseAllOnEsc: ",o);return}}_markAsRead(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: markAsRead","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_READ_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(Re).markAsRead(o);return}catch(r){this.getService(k).catch("Error in _markAsRead: ",r);return}})}_markAsUnread(o){return X(this,null,function*(){this.getService(k).log("%c[WB] Calling FUNCTION: markAsUnread","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_UNREAD_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(Re).markAsUnread(o)}catch(r){this.getService(k).catch("Error in _markAsUnread: ",r);return}})}_enableScreenshot(){this.getService(k).log("%c[WB] Calling FUNCTION: enableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCREENSHOT_TRIGGERED),this.getService(Re).enableScreenshot()}catch(o){this.getService(k).catch("Error in _enableScreenshot: ",o);return}}_disableScreenshot(){this.getService(k).log("%c[WB] Calling FUNCTION: disableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCREENSHOT_TRIGGERED),this.getService(Re).disableScreenshot()}catch(o){this.getService(k).catch("Error in _disableScreenshot: ",o);return}}_enablePaginatedContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(Re).enablePaginatedContactList()}catch(o){this.getService(k).catch("Error in _enablePaginatedContactList: ",o);return}}_disablePaginatedContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(Re).disablePaginatedContactList()}catch(o){this.getService(k).catch("Error in _disablePaginatedContactList: ",o);return}}};var QU=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: ContactElement","color: blue;"),this.isUserGlobalContact=this._isUserGlobalContact,this.onContactSelected=this._onContactSelected,this.enableAtHere=this._enableAtHere,this.setAtHereLabel=this._setAtHereLabel,this.setAtHereDescription=this._setAtHereDescription,this.disableAtHere=this._disableAtHere,this.updateContactListScopeForOrganizationUsers=this._updateContactListScopeForOrganizationUsers,this.updateContactList=this._updateContactList,this.getContactList=this._getContactList}_isUserGlobalContact(){this.getService(k).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Contact.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(un).isUserGlobalContact$()}catch(o){return this.getService(k).catch("Error in _isUserGlobalContact: ",o),de(!1)}}_onContactSelected(){this.getService(k).log("%c[WB] Calling FUNCTION: onContactSelected","color: green;");try{return this.trackEvent(Y.Events.Contact.ON_CONTACT_SELECTED_TRIGGERED),this.getService(un).onContactSelected$()}catch(o){return this.getService(k).catch("Error in _onContactSelected: ",o),de(null)}}_enableAtHere(){this.getService(k).log("%c[WB] Calling FUNCTION: enableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.ENABLE_AT_HERE_TRIGGERED),this.getService(un).enableAtHere()}catch(o){this.getService(k).catch("Error in _enableAtHere: ",o)}}_setAtHereLabel(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAtHereLabel","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_LABEL_TRIGGERED,{payload:{label:o}}),this.getService(un).setAtHereLabel(o)}catch(r){this.getService(k).catch("Error in setAtHereLabel: ",r)}}_setAtHereDescription(o){this.getService(k).log("%c[WB] Calling FUNCTION: setAtHereDescription","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_DESCRIPTION_TRIGGERED,{payload:{description:o}}),this.getService(un).setAtHereDescription(o)}catch(r){this.getService(k).catch("Error in setAtHereDescription: ",r)}}_disableAtHere(){this.getService(k).log("%c[WB] Calling FUNCTION: disableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.DISABLE_AT_HERE_TRIGGERED),this.getService(un).disableAtHere()}catch(o){this.getService(k).catch("Error in _disableAtHere: ",o)}}_updateContactListScopeForOrganizationUsers(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateContactListScopeForOrganizationUsers","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_SCOPE_FOR_ORGANIZATION_USERS_TRIGGERED,{payload:{scope:o}}),this.getService(un).updateContactListScopeForOrganizationUsers(o)}catch(r){this.getService(k).catch("Error in _updateContactListScopeForOrganizationUsers: ",r)}}_updateContactList(o,r){this.getService(k).log("%c[WB] Calling FUNCTION: _updateContactList","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{payload:{userContacts:o,config:r}}),typeof o=="object"&&o instanceof Array&&(!r||r&&typeof r=="object")&&(o=JSON.parse(JSON.stringify(o)),this.getService(un).convert(r).updateContactList(o,r))}catch(e){this.getService(k).catch("Error in _updateContactList: ",e)}}_getContactList(){this.getService(k).log("%c[WB] Calling FUNCTION: getContactList","color: green;");try{return this.trackEvent(Y.Events.Contact.GET_CONTACT_LIST_TRIGGERED),this.getService(un).getContactList$()}catch(o){return this.getService(k).catch("Error in _getContactList: ",o),de(null)}}};var eV=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map,this.subscriptions=[]}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in CrdtActionsService triggerAction: ",i)}}onAction(e){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it);let t=this.actionSubjects.get(e);return t?t.asObservable():de(null)}catch(t){return this.loggingService.catch("Error in CrdtActionsService onAction: ",t),de(null)}}};o.\u0275fac=function(t){return new(t||o)(Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Gs=(()=>{let o=class o{static generateKey(){return X(this,null,function*(){try{return yield window.crypto.subtle.generateKey({name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"])}catch(e){return at.catch("Failed to generate key: ",e),null}})}static deriveKeyFromPassword(e,t){return X(this,null,function*(){try{if(!t){let c=yield window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));t=new Uint8Array(c).slice(0,this.SALT_LENGTH)}let i=new TextEncoder().encode(e),a=yield window.crypto.subtle.importKey("raw",i,"PBKDF2",!1,["deriveBits","deriveKey"]);return{key:yield window.crypto.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:this.PBKDF2_ITERATIONS,hash:"SHA-256"},a,{name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"]),salt:t}}catch(i){return at.catch("Failed to derive key from password: ",i),null}})}static resolveKey(e){return X(this,null,function*(){try{if(e.customKey){if(e.customKey instanceof CryptoKey)return{key:e.customKey};if(typeof e.customKey=="string"){let i=yield this.deriveKeyFromPassword(e.customKey,e.customSalt);if(!i)return at.catch("Failed to derive key from password"),null;let{key:a,salt:l}=i;return{key:a,salt:l}}}let t=yield this.generateKey();return t?{key:t}:(at.catch("Failed to generate key"),null)}catch(t){return at.catch("Failed to resolve key: ",t),null}})}static encrypt(i){return X(this,arguments,function*(e,t={}){try{if(t.customEncryptCallback)try{return yield t.customEncryptCallback(e)}catch(_){return at.catch("Custom encryption callback failed: ",_),""}let a=yield this.resolveKey(t);if(!a)return at.catch("Failed to resolve key"),"";let{key:l,salt:c}=a,d;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return at.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";d=t.customIV}else d=window.crypto.getRandomValues(new Uint8Array(this.IV_LENGTH));let g=new TextEncoder().encode(e),u={name:"AES-GCM",iv:d,tagLength:128};t.additionalData&&(u.additionalData=t.additionalData);try{let _=yield window.crypto.subtle.encrypt(u,l,g),w=new Uint8Array(d.length+_.byteLength);w.set(d,0),w.set(new Uint8Array(_),d.length);let A=8192,M=[];for(let j=0;j<w.length;j+=A){let q=w.slice(j,Math.min(j+A,w.length)),ie="";for(let _e=0;_e<q.length;_e++)ie+=String.fromCharCode(q[_e]);M.push(ie)}return btoa(M.join(""))}catch(_){return at.catch("Encryption failed: ",_),""}}catch(a){return at.catch("Failed to encrypt: ",a),null}})}static decrypt(i){return X(this,arguments,function*(e,t={}){try{if(t.customDecryptCallback)try{return yield t.customDecryptCallback(e)}catch(_){return at.catch("Custom decryption callback failed: ",_),""}let a=yield this.resolveKey(t);if(!a)return at.catch("Failed to resolve key"),"";let{key:l}=a,c=new Uint8Array(atob(e).split("").map(_=>_.charCodeAt(0)));if(c.length<this.IV_LENGTH)return at.catch("Invalid encrypted data: Too short"),"";let d;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return at.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";d=t.customIV}else d=c.slice(0,this.IV_LENGTH);let g=c.slice(this.IV_LENGTH),u={name:"AES-GCM",iv:d,tagLength:128};t.additionalData&&(u.additionalData=t.additionalData);try{let _=yield window.crypto.subtle.decrypt(u,l,g);return new TextDecoder().decode(_)}catch(_){return at.catch("Decryption failed: ",_),""}}catch(a){return at.catch("Failed to decrypt: ",a),""}})}static encryptData(i){return X(this,arguments,function*(e,t={}){try{let a=JSON.stringify(e);return(yield this.encrypt(a,t))??""}catch(a){return at.catch("Failed to encrypt data: ",a),""}})}static decryptData(i){return X(this,arguments,function*(e,t={}){try{let a=yield this.decrypt(e,t);return JSON.parse(a)}catch(a){return at.catch("Failed to decrypt data: ",a),null}})}};o.IV_LENGTH=12,o.SALT_LENGTH=16,o.PBKDF2_ITERATIONS=1e5,o.KEY_LENGTH=256;let n=o;return n})();var Ri=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w){this.activityService=e,this.analyticsService=t,this.authService=i,this.commonDbService=a,this.commonDbUtilsService=l,this.configService=c,this.crdtActionsService=d,this.docService=g,this.domService=u,this.loggingService=_,this.notificationService=w,this.MIN_WEBHOOK_DEBOUNCE_TIME=5*1e3,this.webhookDebounceTime=this.MIN_WEBHOOK_DEBOUNCE_TIME,this.updateDataWebhookTrigger$=new it,this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null,this.webhookEnabled$=new Se(!1),this.lastCrdtDataUpdatedId=null,this.MIN_ACTIVITY_DEBOUNCE_TIME=10*1e3,this.activityDebounceTime=600*1e3,this.editorEditTrackers=new Map;try{this.loggingService.log("%c[WB] Creating CLASS: CrdtService","color: blue;"),this.authService.setCrdtService(this),this.setupUpdateDataWebhookDebounce(),this.docService.addPreDocumentIdChangeFunction("crdt-service",()=>(this.lastCrdtDataUpdatedId=null,Promise.resolve())),this.authService.addPreSignOutFuction("crdt-service",()=>(this.lastCrdtDataUpdatedId=null,Promise.resolve()))}catch(A){this.loggingService.catch("Error in CrdtService constructor: ",A)}}trackCrdtDataUpdated(e){try{if(this.lastCrdtDataUpdatedId===e)return;this.lastCrdtDataUpdatedId=e,this.analyticsService.trackEvent(Y.Events.Crdt.CRDT_DATA_UPDATED,{id:e})}catch(t){this.loggingService.catch("Error in CrdtService trackCrdtDataUpdated: ",t)}}setupUpdateDataWebhookDebounce(){try{this.updateDataWebhookDebounceSubscription&&(this.updateDataWebhookDebounceSubscription.unsubscribe(),this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null),this.updateDataWebhookDebounceSubscription=this.updateDataWebhookTrigger$.pipe(dn(e=>{this.pendingWebhookEvent=e}),to(this.webhookDebounceTime)).subscribe(e=>{this.pendingWebhookEvent=null,this.webhookEnabled$.value&&e&&this.triggerUpdateDataWebhook(e)},e=>{this.loggingService.catch("Error in CrdtService setupUpdateDataWebhookDebounce subscription: ",e)})}catch(e){this.loggingService.catch("Error in CrdtService setupUpdateDataWebhookDebounce: ",e)}}setWebhookDebounceTime(e){try{e<this.MIN_WEBHOOK_DEBOUNCE_TIME&&(this.loggingService.catch("Error in CrdtService setWebhookDebounceTime: Value must be at least "+this.MIN_WEBHOOK_DEBOUNCE_TIME/1e3+" seconds ("+this.MIN_WEBHOOK_DEBOUNCE_TIME+"ms). Using minimum value."),e=this.MIN_WEBHOOK_DEBOUNCE_TIME),this.pendingWebhookEvent&&this.webhookEnabled$.value&&(this.triggerUpdateDataWebhook(this.pendingWebhookEvent),this.pendingWebhookEvent=null),this.webhookDebounceTime=e,this.setupUpdateDataWebhookDebounce()}catch(t){this.loggingService.catch("Error in CrdtService setWebhookDebounceTime: ",t)}}updateData(a){return X(this,arguments,function*({id:e,state:t,data:i}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateData","color: green;");let l=this.docService.getDocumentPaths(),c=this.authService.getUser(),d=this.domService.getTabId();if(c?.userId&&l){let g=It(e),u=c.userId,_=It(c.userId),w=new Date().toISOString(),A=null,M=this.configService.getEncryptionProvider();if(M?.encrypt&&typeof M.encrypt=="function")A=yield M.encrypt({data:t});else{let _e={};_e.customKey=g,A=yield Gs.encryptData(t,_e)}let j={id:e,veltId:g,encryptedState:A,lastUpdate:w,lastUpdatedBy:u,lastUpdatedByVeltUserId:_,sessionId:d},q={methodName:BF.UPDATE_DATA,uniqueId:lt(),timestamp:new Date().getTime(),source:VF.INTERNAL,payload:{id:e,data:i,lastUpdatedBy:u,sessionId:d,lastUpdate:w}},ie=yield this.commonDbService.updateData({feature:"crdtData",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:g,skipFirestore:!0},data:j});return this.crdtActionsService.triggerAction(wZ.UPDATE_DATA,q),this.trackCrdtDataUpdated(e),this.updateDataWebhookTrigger$.next(q?.payload),this.trackEditForActivity(e),ie}return Promise.resolve(null)}catch(l){return this.loggingService.catch("Error in CrdtService updateData: ",l),Promise.resolve(null)}})}triggerUpdateDataWebhook(e){try{this.updateNotificationsDatabase(e,DZ.UPDATE_DATA)}catch(t){this.loggingService.catch("Error in CrdtService triggerUpdateDataWebhook: ",t)}}onDataChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onDataChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"crdtData",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(ye(c=>X(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.data.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.data.encryptedState,u)}c.data.state=d,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c?.encryptedState}return c}}catch(d){return this.loggingService.catch("Error in CrdtService onDataChange subscription: ",d),null}}))):de(null))).subscribe(l=>{l&&(l.data?t(l.data):t(l))});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onDataChange: ",i),()=>{}}}getData(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getData","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtData",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}});if(l?.encryptedState){let c=null,d=this.configService.getEncryptionProvider();if(d?.decrypt&&typeof d.decrypt=="function")c=yield d.decrypt({data:l.encryptedState});else{let g={};g.customKey=a,c=yield Gs.decryptData(l.encryptedState,g)}l.state=c,delete l?.encryptedState}return l}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getData: ",i),Promise.resolve(null)}})}onStateChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onStateChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"crdtSyncState",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(ye(c=>X(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.data.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.data.encryptedState,u)}c.data.state=d,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=i,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c?.encryptedState}return c}}catch(d){return this.loggingService.catch("Error in CrdtService onStateChange subscription: ",d),null}}))):de(null))).subscribe(l=>{l&&(l.data?t(l.data):t(l))});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onStateChange: ",i),()=>{}}}updateState(i){return X(this,arguments,function*({id:e,state:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateState","color: green;");let a=this.docService.getDocumentPaths(),l=this.authService.getUser(),c=this.domService.getTabId();if(l?.userId&&a){let d=It(e),g=l.userId,u=It(g),_=null,w=this.configService.getEncryptionProvider();if(w?.encrypt&&typeof w.encrypt=="function")_=yield w.encrypt({data:t});else{let A={};A.customKey=d,_=yield Gs.encryptData(t,A)}return this.commonDbService.setData({feature:"crdtSyncState",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:d,skipFirestore:!0},data:{id:e,veltId:d,encryptedState:_,lastUpdate:new Date().toISOString(),lastUpdatedBy:g,lastUpdatedByVeltUserId:u,sessionId:c}})}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService updateState: ",a),Promise.resolve(null)}})}registerSyncUser(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: registerSyncUser","color: green;");let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=this.configService.getApiKey(),c=It(e),d=this.domService.getTabId();if(i?.userId&&a&&l){let g=i.userId,u=It(g),_={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:u,apiKey:l,skipFirestore:!0},w={userId:g,veltUserId:u,status:"online",lastSeen:Date.now(),sessionId:d};yield this.commonDbService.setData({feature:"crdtSyncPresence",properties:_,data:w});let A=this.commonDbUtilsService.getDocumentPath({feature:"crdtSyncPresence",properties:_,defaultDocumentPaths:a,apiKey:l});A&&(yield this.commonDbService.setupOnDisconnect(A,{status:"offline",lastSeen:new Date().getTime(),sessionId:d}))}}catch(i){this.loggingService.catch("Error in CrdtService registerSyncUser: ",i)}})}onRegisteredUserChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onRegisteredUserChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"allCrdtSyncPresence",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(dn(c=>{try{c?.data?t(c.data):t(c)}catch(d){this.loggingService.catch("Error in CrdtService onRegisteredUserChange subscription: ",d)}})):de(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onRegisteredUserChange: ",i),()=>{}}}setPresence(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: setPresence","color: green;");let i=this.authService.getUser(),a=this.docService.getDocumentPaths(),l=this.configService.getApiKey(),c=It(e),d=this.domService.getTabId();if(i?.userId&&a&&l){let g=i.userId,u=It(g),_={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:u,apiKey:l,skipFirestore:!0},w={userId:g,veltUserId:u,status:"online",lastSeen:Date.now(),sessionId:d};yield this.commonDbService.setData({feature:"crdtPresence",properties:_,data:w});let A=this.commonDbUtilsService.getDocumentPath({feature:"crdtPresence",properties:_,defaultDocumentPaths:a,apiKey:l});A&&(yield this.commonDbService.setupOnDisconnect(A,{status:"offline",lastSeen:new Date().getTime(),sessionId:d}))}}catch(i){this.loggingService.catch("Error in CrdtService setPresence: ",i)}})}onPresenceChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onPresenceChange","color: green;");let i=It(e),a=this.docService.getDocumentPaths$().pipe(ye(l=>l?this.commonDbService.dbListener({feature:"allCrdtPresence",properties:{documentId:l?.documentId??"",organizationId:l?.organizationId??"",id:i,skipFirestore:!0}}).pipe(dn(c=>{try{c?.data?t(c.data):t(c)}catch(d){this.loggingService.catch("Error in CrdtService onPresenceChange subscription: ",d)}})):de(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(i){return this.loggingService.catch("Error in CrdtService onPresenceChange: ",i),()=>{}}}saveVersion(l){return X(this,arguments,function*({id:e,versionId:t,versionName:i,state:a}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveVersion","color: green;");let c=this.docService.getDocumentPaths();if(c){let d=It(e),g="",u=this.configService.getEncryptionProvider();if(u?.encrypt&&typeof u.encrypt=="function")g=yield u.encrypt({data:a});else{let w={};w.customKey=d,g=yield Gs.encryptData(a,w)}let _={versionId:t,versionName:i,encryptedState:g,timestamp:new Date().getTime()};return this.commonDbService.setData({feature:"crdtVersion",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:d,versionId:t,skipFirestore:!0},data:h({id:e},_)})}return Promise.resolve(null)}catch(c){return this.loggingService.catch("Error in CrdtService saveVersion: ",c),Promise.resolve(null)}})}getVersion(i){return X(this,arguments,function*({id:e,versionId:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersion","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtVersion",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,versionId:t,skipFirestore:!0}});if(c?.encryptedState){let d=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")d=yield g.decrypt({data:c.encryptedState});else{let u={};u.customKey=l,d=yield Gs.decryptData(c.encryptedState,u)}c.state=d,delete c.encryptedState}return c}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService getVersion: ",a),Promise.resolve(null)}})}getVersions(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersions","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtVersions",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}}),c=null;if(l){c=[];for(let d of Object.values(l))if(d?.encryptedState){let g=null,u=this.configService.getEncryptionProvider();if(u?.decrypt&&typeof u.decrypt=="function")g=yield u.decrypt({data:d.encryptedState});else{let w={};w.customKey=a,g=yield Gs.decryptData(d.encryptedState,w)}let _=y(h({},d),{state:g});delete _?.encryptedState,c.push(_)}else c.push(d)}return c}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getVersions: ",i),Promise.resolve(null)}})}encryptCrdtData(e,t){return X(this,null,function*(){try{let i=this.configService.getEncryptionProvider();if(i?.encrypt&&typeof i.encrypt=="function")return yield i.encrypt({data:e});let a={};return a.customKey=t,yield Gs.encryptData(e,a)}catch(i){return this.loggingService.catch("Error in CrdtService encryptCrdtData: ",i),null}})}decryptCrdtData(e,t){return X(this,null,function*(){try{let i=this.configService.getEncryptionProvider();if(i?.decrypt&&typeof i.decrypt=="function")return yield i.decrypt({data:e});let a={};return a.customKey=t,yield Gs.decryptData(e,a)}catch(i){return this.loggingService.catch("Error in CrdtService decryptCrdtData: ",i),null}})}pushMessage(u){return X(this,arguments,function*({id:e,data:t,yjsClientId:i,messageType:a,eventData:l,type:c,contentKey:d,source:g}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: pushMessage","color: green;");let _=this.docService.getDocumentPaths(),w=this.authService.getUser();if(w?.userId&&_){let A=It(e),M=yield this.encryptCrdtData(t,A);if(M==null)return;let j=w.userId,q=It(w.userId),ie=this.domService.getTabId();if(yield this.commonDbService.pushData({feature:"crdtMessages",properties:{documentId:_?.documentId??"",organizationId:_?.organizationId??"",id:A,skipFirestore:!0},data:{id:e,veltId:A,encryptedData:M,yjsClientId:i,messageType:a??null,type:c??null,contentKey:d??null,source:g??"unknown",updatedByUserId:j,updatedByVeltUserId:q,sessionId:ie,timestamp:this.commonDbService.getServerTimestamp()}}),a==="sync"){let _e=new Date().toISOString(),ae={methodName:BF.UPDATE_DATA,uniqueId:lt(),timestamp:new Date().getTime(),source:VF.INTERNAL,payload:{id:e,data:l,lastUpdatedBy:j,sessionId:ie,lastUpdate:_e}};this.crdtActionsService.triggerAction(wZ.UPDATE_DATA,ae),this.trackCrdtDataUpdated(e),this.updateDataWebhookTrigger$.next(ae?.payload),this.trackEditForActivity(e)}}}catch(_){this.loggingService.catch("Error in CrdtService pushMessage: ",_)}})}onMessage({id:e,callback:t,afterTs:i}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onMessage","color: green;");let a=It(e),l=this.docService.getDocumentPaths$().pipe(ye(c=>c?this.commonDbService.streamChildAdded({feature:"crdtMessages",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:a,skipFirestore:!0},afterTs:i}):de(null))).pipe($e(c=>!!c),ST(c=>X(this,null,function*(){try{if(c.encryptedData){let d=yield this.decryptCrdtData(c.encryptedData,a);if(d==null)return null;c.data=d,delete c.encryptedData}else if(!c.data)return null;return c}catch(d){return this.loggingService.catch("Error in CrdtService onMessage decryption: ",d),null}})),$e(c=>!!c)).subscribe(c=>{try{t(c)}catch(d){this.loggingService.catch("Error in CrdtService onMessage subscription: ",d)}});return()=>l.unsubscribe()}catch(a){return this.loggingService.catch("Error in CrdtService onMessage: ",a),()=>{}}}getMessages(i){return X(this,arguments,function*({id:e,afterTs:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getMessages","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtMessages",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,skipFirestore:!0}});if(!c||typeof c!="object"||c?.errorCode)return[];let d=[];for(let g of Object.keys(c)){let u=c[g];if(!(!u||typeof u!="object")&&!(t!=null&&u.timestamp!=null&&u.timestamp<=t))if(u.encryptedData){let _=yield this.decryptCrdtData(u.encryptedData,l);if(_==null)continue;d.push({data:_,yjsClientId:u.yjsClientId,timestamp:u.timestamp})}else u.data&&d.push({data:u.data,yjsClientId:u.yjsClientId,timestamp:u.timestamp})}return d.sort((g,u)=>g.timestamp-u.timestamp),d}return[]}catch(a){return this.loggingService.catch("Error in CrdtService getMessages: ",a),[]}})}getSnapshot(t){return X(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getSnapshot","color: green;");let i=this.docService.getDocumentPaths();if(i){let a=It(e),l=yield this.commonDbService.getData({feature:"crdtSnapshot",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:a,skipFirestore:!0}});if(!l||typeof l!="object"||Object.keys(l).length===0||l?.errorCode)return null;if(l?.encryptedState){let c=yield this.decryptCrdtData(l.encryptedState,a);if(c==null)return null;l.state=c,delete l?.encryptedState}if(l?.encryptedVector){let c=yield this.decryptCrdtData(l.encryptedVector,a);if(c==null)return null;l.vector=c,delete l?.encryptedVector}return l}return Promise.resolve(null)}catch(i){return this.loggingService.catch("Error in CrdtService getSnapshot: ",i),Promise.resolve(null)}})}saveSnapshot(d){return X(this,arguments,function*({id:e,state:t,vector:i,type:a,contentKey:l,source:c}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveSnapshot","color: green;");let g=this.docService.getDocumentPaths(),u=this.authService.getUser();if(u?.userId&&g){let _=It(e),w=yield this.encryptCrdtData(t,_),A=yield this.encryptCrdtData(i,_);if(w==null||A==null)return;let M=u.userId,j=It(u.userId),q=this.domService.getTabId();yield this.commonDbService.setData({feature:"crdtSnapshot",properties:{documentId:g?.documentId??"",organizationId:g?.organizationId??"",id:_,skipFirestore:!0},data:{id:e,veltId:_,encryptedState:w,encryptedVector:A,type:a??null,contentKey:l??null,source:c??"unknown",updatedByUserId:M,updatedByVeltUserId:j,sessionId:q,timestamp:this.commonDbService.getServerTimestamp()}})}}catch(g){this.loggingService.catch("Error in CrdtService saveSnapshot: ",g)}})}pruneMessages(i){return X(this,arguments,function*({id:e,beforeTs:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: pruneMessages","color: green;");let a=this.docService.getDocumentPaths();if(a){let l=It(e),c=yield this.commonDbService.getData({feature:"crdtMessages",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,skipFirestore:!0}});if(c&&typeof c=="object"&&!c?.errorCode){let d=[];for(let g of Object.keys(c)){let u=c[g];u?.timestamp!=null&&u.timestamp<t&&d.push(this.commonDbService.deleteData({feature:"crdtMessage",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:l,messageId:g,skipFirestore:!0}}))}yield Promise.all(d)}}}catch(a){this.loggingService.catch("Error in CrdtService pruneMessages: ",a)}})}updateNotificationsDatabase(e,t,i={}){try{let a=h({crdtData:e,actionType:t,notificationSource:"crdt"},i);this.notificationService.updateNotificationDatabase(a)}catch(a){this.loggingService.catch("Error in CrdtService updateNotificationsDatabase: ",a)}}enableWebhook(){try{if(this.webhookEnabled$.value===!0)return;this.webhookEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in CrdtService enableWebhook: ",e)}}disableWebhook(){try{if(this.webhookEnabled$.value===!1)return;this.webhookEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in CrdtService disableWebhook: ",e)}}trackEditForActivity(e){try{let t=this.editorEditTrackers.get(e);if(!t){let i=new it,a=i.pipe(to(this.activityDebounceTime)).subscribe(()=>{this.flushEditorActivity(e)});t={count:0,subject$:i,subscription:a},this.editorEditTrackers.set(e,t)}t.count++,t.subject$.next()}catch(t){this.loggingService.catch("Error in CrdtService trackEditForActivity: ",t)}}flushEditorActivity(e){try{let t=this.editorEditTrackers.get(e);if(!t||t.count===0)return;let i=t.count;t.count=0;let a={featureType:"crdt",actionType:Rhe.EDITOR_EDIT,targetEntityId:e,entityData:{editCount:i}};this.activityService.createActivity(a)}catch(t){this.loggingService.catch("Error in CrdtService flushEditorActivity: ",t)}}setActivityDebounceTime(e){try{e<this.MIN_ACTIVITY_DEBOUNCE_TIME&&(this.loggingService.catch("Error in CrdtService setActivityDebounceTime: Value must be at least "+this.MIN_ACTIVITY_DEBOUNCE_TIME/1e3+" seconds ("+this.MIN_ACTIVITY_DEBOUNCE_TIME+"ms). Using minimum value."),e=this.MIN_ACTIVITY_DEBOUNCE_TIME),this.flushAllEditorActivities(),this.activityDebounceTime=e}catch(t){this.loggingService.catch("Error in CrdtService setActivityDebounceTime: ",t)}}flushAllEditorActivities(){try{for(let[e,t]of this.editorEditTrackers)t.count>0&&this.flushEditorActivity(e),t.subject$.complete(),t.subscription.unsubscribe();this.editorEditTrackers.clear()}catch(e){this.loggingService.catch("Error in CrdtService flushAllEditorActivities: ",e)}}};o.\u0275fac=function(t){return new(t||o)(Z(Gg),Z(ct),Z(Ke),Z(kn),Z(bd),Z(Lt),Z(eV),Z(st),Z(Ve),Z(k),Z(cn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var tV=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: CrdtElement","color: blue;"),this.updateData=this._updateData,this.onDataChange=this._onDataChange,this.getData=this._getData,this.onStateChange=this._onStateChange,this.updateState=this._updateState,this.registerSyncUser=this._registerSyncUser,this.onRegisteredUserChange=this._onRegisteredUserChange,this.setPresence=this._setPresence,this.onPresenceChange=this._onPresenceChange,this.saveVersion=this._saveVersion,this.getVersion=this._getVersion,this.getVersions=this._getVersions,this.pushMessage=this._pushMessage,this.onMessage=this._onMessage,this.getMessages=this._getMessages,this.getSnapshot=this._getSnapshot,this.saveSnapshot=this._saveSnapshot,this.pruneMessages=this._pruneMessages,this.enableWebhook=this._enableWebhook,this.disableWebhook=this._disableWebhook,this.setWebhookDebounceTime=this._setWebhookDebounceTime,this.setActivityDebounceTime=this._setActivityDebounceTime,this.on=this._on}_updateData(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateData","color: green;");try{return this.getService(Ri).updateData(o)}catch(r){return this.getService(k).catch("Error in updateData: ",r),Promise.resolve(null)}}_onDataChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onDataChange","color: green;");try{return this.getService(Ri).onDataChange(o)}catch(r){return this.getService(k).catch("Error in onDataChange: ",r),()=>{}}}_getData(o){this.getService(k).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.getService(Ri).getData(o)}catch(r){return this.getService(k).catch("Error in getData: ",r),Promise.resolve(null)}}_onStateChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onStateChange","color: green;");try{return this.getService(Ri).onStateChange(o)}catch(r){return this.getService(k).catch("Error in onStateChange: ",r),()=>{}}}_updateState(o){this.getService(k).log("%c[WB] Calling FUNCTION: updateState","color: green;");try{return this.getService(Ri).updateState(o)}catch(r){return this.getService(k).catch("Error in updateState: ",r),Promise.resolve(null)}}_registerSyncUser(o){this.getService(k).log("%c[WB] Calling FUNCTION: registerSyncUser","color: green;");try{return this.getService(Ri).registerSyncUser(o)}catch(r){return this.getService(k).catch("Error in registerSyncUser: ",r),Promise.resolve()}}_onRegisteredUserChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onRegisteredUserChange","color: green;");try{return this.getService(Ri).onRegisteredUserChange(o)}catch(r){return this.getService(k).catch("Error in onRegisteredUserChange: ",r),()=>{}}}_setPresence(o){this.getService(k).log("%c[WB] Calling FUNCTION: setPresence","color: green;");try{return this.getService(Ri).setPresence(o)}catch(r){return this.getService(k).catch("Error in setPresence: ",r),Promise.resolve()}}_onPresenceChange(o){this.getService(k).log("%c[WB] Calling FUNCTION: onPresenceChange","color: green;");try{return this.getService(Ri).onPresenceChange(o)}catch(r){return this.getService(k).catch("Error in onPresenceChange: ",r),()=>{}}}_saveVersion(o){this.getService(k).log("%c[WB] Calling FUNCTION: saveVersion","color: green;");try{return this.getService(Ri).saveVersion(o)}catch(r){return this.getService(k).catch("Error in saveVersion: ",r),Promise.resolve(null)}}_getVersion(o){this.getService(k).log("%c[WB] Calling FUNCTION: getVersion","color: green;");try{return this.getService(Ri).getVersion(o)}catch(r){return this.getService(k).catch("Error in getVersion: ",r),Promise.resolve(null)}}_getVersions(o){this.getService(k).log("%c[WB] Calling FUNCTION: getVersions","color: green;");try{return this.getService(Ri).getVersions(o)}catch(r){return this.getService(k).catch("Error in getVersions: ",r),Promise.resolve(null)}}_pushMessage(o){this.getService(k).log("%c[WB] Calling FUNCTION: pushMessage","color: green;");try{return this.getService(Ri).pushMessage(o)}catch(r){return this.getService(k).catch("Error in pushMessage: ",r),Promise.resolve()}}_onMessage(o){this.getService(k).log("%c[WB] Calling FUNCTION: onMessage","color: green;");try{return this.getService(Ri).onMessage(o)}catch(r){return this.getService(k).catch("Error in onMessage: ",r),()=>{}}}_getMessages(o){this.getService(k).log("%c[WB] Calling FUNCTION: getMessages","color: green;");try{return this.getService(Ri).getMessages(o)}catch(r){return this.getService(k).catch("Error in getMessages: ",r),Promise.resolve([])}}_getSnapshot(o){this.getService(k).log("%c[WB] Calling FUNCTION: getSnapshot","color: green;");try{return this.getService(Ri).getSnapshot(o)}catch(r){return this.getService(k).catch("Error in getSnapshot: ",r),Promise.resolve(null)}}_saveSnapshot(o){this.getService(k).log("%c[WB] Calling FUNCTION: saveSnapshot","color: green;");try{return this.getService(Ri).saveSnapshot(o)}catch(r){return this.getService(k).catch("Error in saveSnapshot: ",r),Promise.resolve()}}_pruneMessages(o){this.getService(k).log("%c[WB] Calling FUNCTION: pruneMessages","color: green;");try{return this.getService(Ri).pruneMessages(o)}catch(r){return this.getService(k).catch("Error in pruneMessages: ",r),Promise.resolve()}}_enableWebhook(){this.getService(k).log("%c[WB] Calling FUNCTION: enableWebhook","color: green;");try{return this.getService(Ri).enableWebhook()}catch(o){this.getService(k).catch("Error in enableWebhook: ",o);return}}_disableWebhook(){this.getService(k).log("%c[WB] Calling FUNCTION: disableWebhook","color: green;");try{return this.getService(Ri).disableWebhook()}catch(o){this.getService(k).catch("Error in disableWebhook: ",o);return}}_setWebhookDebounceTime(o){this.getService(k).log("%c[WB] Calling FUNCTION: setWebhookDebounceTime","color: green;");try{!isNaN(o)&&o>0?this.getService(Ri).setWebhookDebounceTime(o):this.getService(k).catch("Error in setWebhookDebounceTime: ","Provided value must be a positive number greater than zero.")}catch(r){this.getService(k).catch("Error in setWebhookDebounceTime: ",r)}}_setActivityDebounceTime(o){this.getService(k).log("%c[WB] Calling FUNCTION: setActivityDebounceTime","color: green;");try{!isNaN(o)&&o>=1e4?this.getService(Ri).setActivityDebounceTime(o):this.getService(k).catch("Error in setActivityDebounceTime: ","Provided value must be a number >= 10000ms (10 seconds).")}catch(r){this.getService(k).catch("Error in setActivityDebounceTime: ",r)}}_on(o){this.getService(k).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(eV).onAction(o)}catch(r){return this.getService(k).catch("Error in on: ",r),de(null)}}};var Rc=(function(n){return n.CLICK="click",n.HOVER="hover",n.SCROLL="scroll",n.NAVIGATE="navigate",n})(Rc||{}),Hg=class{constructor(){this.type=Rc.HOVER,this.data=null,this.pageInfo=io(),this.timestamp=Date.now()}},nV=class{constructor(o,r){this.targetXpath=o,this.xpath=r}};var rV=class{constructor(){this.sessionId=null,this.isLeader=!1,this.lastProcessedActionTimestamp=null}};var tC=class{constructor(o){this.snippylyId=o,this.joinTimestamp=Date.now()}};var oV=class{constructor(o,r,e){this.followers=[],this.actionStack=[],this.id=lt(),this.leaderId=o,this.leaderName=r,this.followers.push(new tC(e))}};var $_e=(()=>{let o=class o{constructor(e,t,i,a,l){this.databaseService=e,this.docService=t,this.loggingService=i,this.authService=a,this.commonDbService=l,this.currentUser$=new Se(null),this.currentSession$=new Se(null);try{this.databaseService.getDb().pipe($e(c=>!!c),ut(1)).subscribe(c=>{c&&(this.db=c)},c=>{this.loggingService.catch("Error in FlockSessionService getDb subscription: ",c)}),this.authService.getUser$().subscribe(c=>{c&&c.userSnippylyId&&(this.user=c)})}catch(c){this.loggingService.catch("Error in FlockSessionService constructor: ",c)}}startCurrentFlockUserSubscription(e){try{this.currentUserSub?.unsubscribe(),e&&e.userSnippylyId&&(this.user=e,this.subscribeToCurrentFlockUser(e?.userSnippylyId))}catch(t){this.loggingService.catch("Error in FlockSessionService startCurrentFlockUserSubscription: ",t)}}stopCurrentFlockUserSubscription(){try{this.currentUserSub?.unsubscribe()}catch(e){this.loggingService.catch("Error in FlockSessionService stopCurrentFlockUserSubscription: ",e)}}provisionFlockSession(e,t,i){try{let a=this.docService.getDocumentPaths();a&&this.db&&this.commonDbService.dbListener({feature:"flockUser",properties:{documentId:a?.documentId,organizationId:a?.organizationId,id:e,skipFirestore:!0}}).pipe(ut(1)).subscribe(l=>{l?.data&&l?.data?.sessionId?this.subscribeToCurrentSession(l?.data?.sessionId,i):this.createFlockSession(e,t,i)})}catch(a){this.loggingService.catch("Error in FlockSessionService provisionFlockSession: ",a)}return null}swapLeader(e,t,i){try{if(this.updateRemoteFlockUser(e,{isLeader:!1}),this.updateRemoteFlockUser(t,{isLeader:!0}),this.currentSession){this.currentSession.leaderId=t,this.currentSession.leaderName=i,this.currentSession.followers.push(new tC(e));let a=this.currentSession.followers.findIndex(l=>l.snippylyId===t);a>-1&&this.currentSession.followers.splice(a,1),this.updateSession(this.currentSession.id,this.currentSession)}}catch(a){this.loggingService.catch("Error in FlockSessionService swapLeader: ",a)}}createFlockSession(e,t,i){try{let a=new oV(e,t,i);return this.updateRemoteFlockUser(e,{snippylyId:e,sessionId:a.id,isLeader:!0}),this.updateSession(a.id,a),this.subscribeToCurrentSession(a.id),a.id}catch(a){this.loggingService.catch("Error in FlockSessionService createFlockSession: ",a)}return null}removeFollowerFromCurrentSession(e){try{if(this.currentSession){this.updateRemoteFlockUser(e,{sessionId:null,lastProcessedActionTimestamp:null});let t=this.currentSession.followers.findIndex(i=>i.snippylyId===e);if(t>-1){if(this.currentSession.followers.splice(t,1),this.currentSession.followers.length===0){this.deleteSession(this.currentSession.id);return}this.updateSession(this.currentSession.id,this.currentSession),this.user&&this.user.userSnippylyId&&this.user.userSnippylyId===e&&(this.sessionSub?.unsubscribe(),this.currentSession=void 0,this.currentSession$?.next(null))}}}catch(t){this.loggingService.catch("Error in FlockSessionService removeFollowerFromSession: ",t)}}updateRemoteFlockUser(e,t={}){try{if(!e)return;let i=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];i&&this.db&&this.commonDbService.updateData({feature:"flockUser",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(i){this.loggingService.catch("Error in FlockSessionService updateRemoteFlockUser: ",i)}}subscribeToCurrentSession(e,t=void 0){try{let i=this.docService.getDocumentPaths();i&&this.db&&(this.sessionSub&&this.sessionSub.unsubscribe(),this.sessionSub=this.commonDbService.dbListener({feature:"flockSession",properties:{documentId:i?.documentId,organizationId:i?.organizationId,id:e,skipFirestore:!0}}).subscribe(a=>{a?.data&&typeof a?.data=="object"&&Object.keys(a?.data)?.length>0?(this.currentSession=a?.data,t!==void 0&&this.currentSession?.followers.findIndex(l=>l.snippylyId===t)===-1&&(this.currentSession.followers.push(new tC(t)),this.updateSession(this.currentSession.id,this.currentSession)),this.currentSession$.next(this.currentSession??null)):(this.currentSession=void 0,this.currentSession$.next(null))}))}catch(i){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentSession: ",i)}}subscribeToCurrentFlockUser(e){try{let t=this.docService.getDocumentPaths();t&&this.db&&(this.currentUserSub&&this.currentUserSub.unsubscribe(),this.currentUserSub=this.commonDbService.dbListener({feature:"flockUser",properties:{documentId:t?.documentId,organizationId:t?.organizationId,id:e,skipFirestore:!0}}).pipe(Gn(i=>(this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",i),de(null)))).subscribe(i=>{i?.data&&typeof i?.data=="object"&&Object.keys(i?.data)?.length>0&&(this.currentUser$.next(i?.data),i?.data?.sessionId&&this.subscribeToCurrentSession(i?.data?.sessionId))},i=>{this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser subscription: ",i)}))}catch(t){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",t)}}updateSession(e,t={}){try{if(!e)return;let i=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];i&&this.db&&this.commonDbService.updateData({feature:"flockSession",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(i){this.loggingService.catch("Error in FlockSessionService updateSession: ",i)}}deleteSession(e){try{let t=this.docService.getDocumentPaths();t&&this.db&&(this.commonDbService.deleteData({feature:"flockSession",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:e,skipFirestore:!0}}),this.currentSession&&e===this.currentSession.id&&(this.updateRemoteFlockUser(this.currentSession.leaderId,{sessionId:null,isLeader:!1,lastProcessedActionTimestamp:null}),this.currentSession.followers.forEach(i=>{this.updateRemoteFlockUser(i.snippylyId,{sessionId:null,lastProcessedActionTimestamp:null})}),this.currentSession=void 0,this.currentSession$.next(null),this.sessionSub?.unsubscribe()))}catch(t){this.loggingService.catch("Error in FlockSessionService deleteSession: ",t)}}addActionToStack(e,t){try{t=t&&JSON.parse(JSON.stringify(t));let i=this.docService.getDocumentPaths();if(i&&this.db&&e){let a=Hr(this.db,`${i.flock}/sessions/${e}/actionStack`);c0(a,l=>l?(l.unshift(t),l.slice(0,5)):[t]),t.type===Rc.NAVIGATE&&this.updateSession(e,{pageInfo:t.pageInfo})}}catch(i){this.loggingService.catch("Error in FlockSessionService addActionToStack: ",i)}}};o.\u0275fac=function(t){return new(t||o)(Z(Hn),Z(st),Z(k),Z(Ke),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();function OYe(n,o){if(n&1&&(f(0,"span",6),oe(1),R(2,"translate"),S()),n&2){let r=s(2).ngIf;v(),na("",N(2,2,"You are following")," ",r.leaderName)}}function AYe(n,o){n&1&&(f(0,"span",6),oe(1),R(2,"translate"),S()),n&2&&(v(),Ye(N(2,1,"You are leading.")))}function MYe(n,o){if(n&1){let r=K();f(0,"div",2),z("click",function(){L(r);let t=s().ngIf,i=s();return U(t.type==="following"?i.closeOverlay():void 0)}),f(1,"div",3),p(2,OYe,3,4,"span",4)(3,AYe,3,3,"span",4),f(4,"button",5),z("click",function(){L(r);let t=s(2);return U(t.closeOverlay())}),oe(5),R(6,"translate"),R(7,"translate"),S()()()}if(n&2){let r=s().ngIf;he("no-pointer",r.type==="leading"),v(2),m("ngIf",r.type==="following"),v(),m("ngIf",r.type==="leading"),v(2),na("",N(6,6,"Stop")," ",N(7,8,r.type))}}function PYe(n,o){if(n&1&&(C(0),p(1,MYe,8,10,"div",1),b()),n&2){let r=o.ngIf;v(),m("ngIf",r.leaderName!==""||r.type==="leading")}}var MA=(()=>{let o=class o extends Mt{closeOverlay(){this.closeOverlayEvent.emit()}constructor(e,t,i,a){super(t,i),this.loggingService=e,this.elementRef=t,this.themeService=i,this.domService=a,this.closeOverlayEvent=new Ue,this.componentConfigSignal=De({leaderName:"",type:"following"})}ngOnInit(){}ngAfterViewInit(){try{this.customCssSubscription=this.domService.subscribeInjectCustomCss(this.elementRef)}catch(e){this.loggingService.catch("Error in FollowOverlayComponent ngAfterViewInit: ",e)}}setLeaderName(e){try{this.componentConfigSignal.update(t=>(t=y(h({},t),{leaderName:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setLeaderName: ",t)}}getLeaderName(){return this.componentConfigSignal().leaderName}setType(e){try{this.componentConfigSignal.update(t=>(t=y(h({},t),{type:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setType: ",t)}}ngOnDestroy(){try{super.ngOnDestroy(),this.customCssSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in FollowOverlayComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(x(k),x(Q),x(yt),x(Ve))},o.\u0275cmp=O({type:o,selectors:[["snippyly-follow-overlay"]],outputs:{closeOverlayEvent:"closeOverlayEvent"},standalone:!1,features:[P],decls:1,vars:1,consts:[[4,"ngIf"],["data-velt-ignore","","class","follow-overlay-container",3,"no-pointer","click",4,"ngIf"],["data-velt-ignore","",1,"follow-overlay-container",3,"click"],["data-velt-ignore","",1,"follow-dialog"],["data-velt-ignore","","class","follow-text",4,"ngIf"],["data-velt-ignore","",1,"follow-btn",3,"click"],["data-velt-ignore","",1,"follow-text"]],template:function(t,i){t&1&&p(0,PYe,2,1,"ng-container",0),t&2&&m("ngIf",i.componentConfigSignal())},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}.follow-overlay-container{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:var(--velt-follow-mode-overlay-z-index);display:flex;justify-content:center;align-items:flex-end}.follow-overlay-container .follow-dialog{background-color:var(--legacy-velt-follow-overlay-bg-color);color:var(--legacy-velt-follow-overlay-text-color);font-size:12px;display:flex;justify-content:center;align-items:center;gap:calc((1.2rem + 0px) * var(--velt-base-rem-unit));padding:calc((.9rem + 0px) * var(--velt-base-rem-unit)) calc((1.1rem + 0px) * var(--velt-base-rem-unit));border-radius:90px;margin-bottom:calc((2rem + 0px) * var(--velt-base-rem-unit));box-shadow:0 8px 16px -8px #0f0f0f1a;border:1px solid var(--legacy-velt-follow-overlay-border-color)}.follow-overlay-container .follow-dialog .follow-btn{background-color:var(--legacy-velt-follow-overlay-btn-color);padding:8px 12px;border-radius:90px;display:inline-flex;justify-content:center;align-items:center;border:none;font-weight:600;font-size:14px;cursor:pointer;pointer-events:all}.follow-overlay-container .follow-dialog .follow-btn:hover{transition:background-color .5s;background-color:var(--legacy-velt-follow-overlay-btn-hover-color)}.follow-overlay-container.no-pointer{pointer-events:none}
|
|
502
502
|
`],encapsulation:3,changeDetection:0});let n=o;return n})();var G_e=(()=>{let o=class o{constructor(e,t,i,a){this.componentFactoryResolver=e,this.applicationRef=t,this.injector=i,this.loggingService=a,this.darkMode=!1}createFollowOverlay(e,t){try{let a=this.componentFactoryResolver.resolveComponentFactory(MA).create(this.injector);a.instance.setLeaderName(e),a.instance.closeOverlayEvent.pipe(ut(1)).subscribe(()=>{this.removeOverlay(),t()}),this.applicationRef.attachView(a.hostView),this.overlayRef=a,this.overlayRef.instance.darkMode=this.darkMode;let l=this.overlayRef.location.nativeElement;l.id="snippyly-follow-overlay",l.setAttribute(F.ATTRIBUTES.VELT_IGNORE,""),document.body.appendChild(l)}catch(i){this.loggingService.catch("Error in FlockOverlayService createFollowOverlay: ",i)}}createLeaderOverlay(e){let i=this.componentFactoryResolver.resolveComponentFactory(MA).create(this.injector);i.instance.setType("leading"),i.instance.closeOverlayEvent.pipe(ut(1)).subscribe(()=>{this.removeOverlay(),e()}),this.applicationRef.attachView(i.hostView),this.overlayRef=i,this.overlayRef.instance.darkMode=this.darkMode;let a=this.overlayRef.location.nativeElement;a.id="snippyly-follow-overlay",a.setAttribute(F.ATTRIBUTES.VELT_IGNORE,""),document.body.appendChild(a)}changeLeaderName(e){this.overlayRef&&this.overlayRef.instance.setLeaderName(e)}getLeaderName(){return this.overlayRef?this.overlayRef.instance.getLeaderName():null}removeOverlay(){if(this.overlayRef){let e=this.overlayRef.location.nativeElement;this.applicationRef.detachView(this.overlayRef.hostView),this.overlayRef.destroy(),e.shadowRoot&&e.shadowRoot.removeChild(e.shadowRoot.childNodes[0]),e.remove(),this.overlayRef=void 0}}setDarkMode(e){try{this.darkMode=e,this.overlayRef&&(this.overlayRef.instance.darkMode=e)}catch(t){this.loggingService.catch("Error in FlockOverlayService setDarkMode: ",t)}}};o.\u0275fac=function(t){return new(t||o)(Z(ti),Z(Tr),Z(At),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var _v=(()=>{let o=class o{constructor(e,t,i,a,l){this.authService=e,this.domService=t,this.loggingService=i,this.flockSessionService=a,this.flockOverlayService=l,this.flockLeader$=new Se({userId:"",name:""}),this.flockMode$=new Se(!1),this.currentFlockUser=null,this.localScrollData=[],this.domSubscriptions=[],this.followOverlayCreated=!1,this.leaderOverlayCreated=!1,this.windowFocused=!0,this.tabFocused=!0,this.useHistoryAPI=!0,this.disableDefaultNavigation=!1;try{this.flockLeader$.subscribe(c=>{let{userId:d,name:g}=c,u=d;if(this.provisionFollowUser(),u&&this.currentFlockUser&&this.currentFlockUser.snippylyId)if(this.currentFlockUser.sessionId){if(this.currentFlockUser.snippylyId&&this.currentFlockUser.isLeader){this.flockSessionService.swapLeader(this.currentFlockUser.snippylyId,u,g);return}this.removeCurrentUserFromSession()}else this.flockSessionService.provisionFlockSession(u,g,this.currentFlockUser.snippylyId)},c=>{this.loggingService.catch("Error in FlockService flockLeader$ subscription: ",c)}),this.flockSessionService.currentSession$.subscribe(c=>{if(c!==null){if(this.currentFlockUser&&(this.currentFlockUser.sessionId===null||this.currentFlockUser.sessionId===void 0)&&this.currentFlockUser.snippylyId&&(this.currentFlockUser.sessionId=c.id,this.flockSessionService.updateRemoteFlockUser(this.currentFlockUser.snippylyId,this.currentFlockUser)),this.currentFlockUser&&!this.currentFlockUser.isLeader&&!this.followOverlayCreated&&(this.leaderOverlayCreated&&(this.flockOverlayService.removeOverlay(),this.leaderOverlayCreated=!1),this.followOverlayCreated=!0,this.flockOverlayService.createFollowOverlay(c.leaderName,()=>{this.removeCurrentUserFromSession(),this.followOverlayCreated=!1})),this.currentFlockUser&&this.currentFlockUser.isLeader&&!this.leaderOverlayCreated&&(this.followOverlayCreated&&(this.flockOverlayService.removeOverlay(),this.followOverlayCreated=!1),this.leaderOverlayCreated=!0,this.flockOverlayService.createLeaderOverlay(()=>{this.removeCurrentUserFromSession(),this.leaderOverlayCreated=!1})),this.currentFlockUser&&!this.currentFlockUser.isLeader&&c.actionStack){let d=c.actionStack[0];d&&this.currentFlockUser.lastProcessedActionTimestamp!==d.timestamp&&this.processAction(d)}if(this.currentFlockUser&&!this.currentFlockUser.isLeader&&this.followOverlayCreated&&this.flockOverlayService.getLeaderName()!==null&&c.leaderName!==this.flockOverlayService.getLeaderName()&&this.flockOverlayService.changeLeaderName(c.leaderName),this.currentFlockUser&&this.currentFlockUser.isLeader){let d=io();if(c.pageInfo){if(d&&d.url!==c.pageInfo.url){let g=new Hg;g.type=Rc.NAVIGATE,this.flockSessionService.addActionToStack(c.id,g)}}else{this.flockSessionService.updateSession(c.id,{pageInfo:d});let g=new Hg;g.type=Rc.NAVIGATE,this.flockSessionService.addActionToStack(c.id,g)}}}else this.currentFlockUser&&this.leaderOverlayCreated&&(this.flockOverlayService.removeOverlay(),this.leaderOverlayCreated=!1),this.currentFlockUser&&this.followOverlayCreated&&(this.flockOverlayService.removeOverlay(),this.followOverlayCreated=!1)}),this.flockSessionService.currentUser$.subscribe(c=>{if(c!==null&&(this.currentFlockUser&&this.currentFlockUser.isLeader!==c.isLeader&&(this.domSubscriptions.forEach(d=>d.unsubscribe()),this.domSubscriptions=[]),this.currentFlockUser=c,c.sessionId&&this.domSubscriptions.length===0))if(c.isLeader){if(!this.tabFocused||!this.windowFocused)return;this.subscribeToLeaderDOMEvents()}else this.subscribeToFollowerDOMEvents()}),mn([this.authService.getUser$(),this.getFlockMode$()]).subscribe(([c,d])=>{c&&c.userSnippylyId&&d?this.flockSessionService.startCurrentFlockUserSubscription(c):this.flockSessionService.stopCurrentFlockUserSubscription()})}catch(c){this.loggingService.catch("Error in FlockService constructor: ",c)}}provisionFollowUser(){try{if(this.currentFlockUser===null){let e=this.authService.getUser();e&&e.userSnippylyId&&(this.currentFlockUser=new rV,this.currentFlockUser.snippylyId=e.userSnippylyId)}}catch(e){this.loggingService.catch("Error in FlockService provisionFollowUser: ",e)}}startFollowingUser(e,t){try{if(this.provisionFollowUser(),e&&this.currentFlockUser&&this.currentFlockUser.snippylyId){if(this.currentFlockUser.sessionId){if(this.currentFlockUser.snippylyId&&this.currentFlockUser.isLeader){this.flockSessionService.swapLeader(this.currentFlockUser.snippylyId,e,t);return}this.removeCurrentUserFromSession()}this.flockSessionService.provisionFlockSession(e,t,this.currentFlockUser.snippylyId)}}catch(i){this.loggingService.catch("Error in FlockService startFollowingUser: ",i)}}stopFollowingUser(){try{this.removeCurrentUserFromSession()}catch(e){this.loggingService.catch("Error in FlockService stopFollowingUser: ",e)}}subscribeToUrlChanges(){try{if(this.useHistoryAPI){let e=window.history.pushState,t=window.history.replaceState;window.history.pushState=(...i)=>{e.apply(window.history,i),this.onUrlChange()},window.history.replaceState=(...i)=>{t.apply(window.history,i),this.onUrlChange()},this.domSubscriptions.push({unsubscribe:()=>{window.history.pushState=e,window.history.replaceState=t}}),this.domSubscriptions.push(wr(window,"popstate").subscribe(()=>{this.onUrlChange()}))}}catch(e){this.loggingService.catch("Error in FlockService subscribeToUrlChanges: ",e)}}onUrlChange(){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId&&this.currentFlockUser.isLeader){let e=new Hg;e.type=Rc.NAVIGATE,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,e)}}catch(e){this.loggingService.catch("Error in FlockService onUrlChange: ",e)}}processAction(e){try{switch(e.type){case Rc.CLICK:this.clickUserElement(e.data);break;case Rc.HOVER:this.scrollToHoveredElement(e.data);break;case Rc.SCROLL:this.scrollToFollowedUser(e.data);break;case Rc.NAVIGATE:this.checkMatchingUrl(e.pageInfo);break}this.currentFlockUser&&this.currentFlockUser.snippylyId&&this.flockSessionService.updateRemoteFlockUser(this.currentFlockUser.snippylyId,{lastProcessedActionTimestamp:e.timestamp})}catch(t){this.loggingService.catch("Error in FlockService processAction: ",t)}}subscribeToLeaderDOMEvents(){try{this.domSubscriptions.length>0&&(this.domSubscriptions.forEach(e=>e.unsubscribe()),this.domSubscriptions=[]),this.domSubscriptions.push(wr(window,"mouseover").pipe(to(500)).subscribe(e=>{let t=e?.target;if(t){let i=window.getComputedStyle(t);if(i.position==="fixed"||i.position==="sticky"||t.hasAttribute(F.ATTRIBUTES.VELT_IGNORE))return;t=$Z(t,{x:e.clientX,y:e.clientY}),this.updateHoveredElement(t)}})),this.domSubscriptions.push(this.domService.onWindowClick$().subscribe(e=>{let t=e?.target;if(t){if(t.hasAttribute(F.ATTRIBUTES.VELT_IGNORE))return;this.updateClickedElement(t)}})),this.subscribeToUrlChanges(),this.subscribeToScrollables()}catch(e){this.loggingService.catch("Error in FlockService subscribeToLeaderDOMEvents: ",e)}}subscribeToFollowerDOMEvents(){}updateClickedElement(e){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId){let t=this.domService.getXPath(e),i=R1(e),a=this.domService.getXPath(i),l={id:Math.random().toString(36).substring(2),xpath:t,parentXpath:a},c=new Hg;c.type=Rc.CLICK,c.data=l,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,c)}}catch(t){this.loggingService.catch("Error in FlockService updateClickedElement: ",t)}}updateHoveredElement(e){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId){let t=this.domService.getXPath(e),i=R1(e),a=this.domService.getXPath(i),l={id:Math.random().toString(36).substring(2),xpath:t,parentXpath:a},c=new Hg;c.type=Rc.HOVER,c.data=l,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,c)}}catch(t){this.loggingService.catch("Error in FlockService updateHoveredElement: ",t)}}subscribeToScrollables(){try{let e=efe();e.push(document),e?.forEach(t=>{this.domSubscriptions.push(wr(t,"scroll").pipe(to(100)).subscribe(i=>{this.currentFlockUser&&this.currentFlockUser.sessionId&&this.currentFlockUser.isLeader&&this.updateScrollPositionOfElement(t)}))})}catch(e){this.loggingService.catch("Error in FlockService getScrollableElements: ",e)}}updateScrollPositionOfElement(e){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId){let t=new nV("","");if(e===document){let l=rfe();if(l){let c=$Z(l);c&&(t.targetXpath=this.domService.getXPath(c))}t.xpath=""}else{let l=nfe(e);t.targetXpath=this.domService.getXPath(l),t.xpath=this.domService.getXPath(e)}let i=!1,a=!1;if(this.localScrollData.forEach((l,c)=>{l.xpath===l.xpath&&(t.targetXpath!==l.targetXpath&&(i=!0),this.localScrollData[c]=Object.assign(l,t),a=!0)}),a||this.localScrollData.push(t),i||!a){let l=new Hg;l.type=Rc.SCROLL,l.data=t,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,l)}}}catch(t){this.loggingService.catch("Error in FlockService calculateScrollPositionOfAnElement: ",t)}}enableFlockMode(e){try{if(this.flockMode$.next(!0),e){let{useHistoryAPI:t,onNavigate:i,disableDefaultNavigation:a,darkMode:l}=e;t!==void 0&&(this.useHistoryAPI=t),i!==void 0&&typeof i=="function"&&(this.onNavigate=i),a!==void 0&&(this.disableDefaultNavigation=a),this.flockOverlayService.setDarkMode(l)}}catch(t){this.loggingService.catch("Error in FlockService enableFlockMode: ",t)}}disableFlockMode(){try{this.flockMode$.next(!1),this.onNavigateEmitter=void 0,this.useHistoryAPI=!0,this.onNavigate=void 0}catch(e){this.loggingService.catch("Error in FlockService disableFlockMode: ",e)}}setDisableFlockNavigation(e){try{this.disableDefaultNavigation=e}catch(t){this.loggingService.catch("Error in FlockService setDisableFlockNavigation: ",t)}}getFlockMode$(){return this.flockMode$.asObservable()}getFlockMode(){return this.flockMode$.value}setNavigateEmitter(e){try{this.onNavigateEmitter=e}catch(t){this.loggingService.catch("Error in FlockService setNavigateEmitter: ",t)}}setTabFocused(e){try{if(this.tabFocused=e,!this.currentFlockUser)return;this.currentFlockUser.isLeader&&this.currentFlockUser.sessionId&&(this.tabFocused&&this.domSubscriptions.length===0?this.subscribeToLeaderDOMEvents():!this.tabFocused&&this.domSubscriptions.length>0&&(this.domSubscriptions.forEach(i=>{i.unsubscribe()}),this.domSubscriptions=[]))}catch(t){this.loggingService.catch("Error in FlockService setTabFocused: ",t)}}setWindowFocused(e){try{if(this.windowFocused=e,!this.currentFlockUser)return;this.currentFlockUser.isLeader&&this.currentFlockUser.sessionId&&(this.windowFocused&&this.domSubscriptions.length===0?this.subscribeToLeaderDOMEvents():!this.windowFocused&&this.domSubscriptions.length>0&&(this.domSubscriptions.forEach(i=>{i.unsubscribe()}),this.domSubscriptions=[]))}catch(t){this.loggingService.catch("Error in FlockService setWindowFocused: ",t)}}setFlockLeader(e,t){try{this.flockLeader$.next({userId:e,name:t})}catch(i){this.loggingService.catch("Error in FlockService setFlockLeader: ",i)}}isInSession(){try{return!!(this.currentFlockUser&&this.currentFlockUser.sessionId)}catch(e){this.loggingService.catch("Error in FlockService isFollowing: ",e)}return!1}removeCurrentUserFromSession(){try{this.domSubscriptions.forEach(e=>e.unsubscribe()),this.domSubscriptions=[],this.currentFlockUser&&(this.currentFlockUser.isLeader?this.currentFlockUser.sessionId&&this.flockSessionService.deleteSession(this.currentFlockUser.sessionId):this.currentFlockUser.snippylyId&&this.flockSessionService.removeFollowerFromCurrentSession(this.currentFlockUser.snippylyId))}catch(e){this.loggingService.catch("Error in FlockService removeCurrentUserFromSession: ",e)}}checkMatchingUrl(e){try{let i=io()?.url,a=e.url;if(i!==a&&a!==void 0){let{url:l,path:c,baseUrl:d}=e;if(this.onNavigate!==void 0&&typeof this.onNavigate=="function"){this.onNavigate({url:l,path:c,baseUrl:d});return}if(this.onNavigateEmitter&&this.onNavigateEmitter.emit({url:l,path:c,baseUrl:d}),this.disableDefaultNavigation)return;window.location.href=a}}catch(t){this.loggingService.catch("Error in FlockService checkMatchingUrl: ",t)}}scrollToFollowedUser(e){try{if(e.xpath===""){let t=this.domService.getElementFromXPath(e.targetXpath);t&&tL(t)}else{let t=this.domService.getElementFromXPath(e.xpath),i=this.domService.getElementFromXPath(e.targetXpath);t&&i&&(tL(t),GZ(t,i))}}catch(t){this.loggingService.catch("Error in FlockService scrollToFollowedUser: ",t)}}clickUserElement(e){try{let t=this.domService.getElementFromXPath(e.xpath);t&&this.lastClickedElement?.id!==e.id&&(t?.click(),this.lastClickedElement=e)}catch(t){this.loggingService.catch("Error in FlockService clickUserElement: ",t)}}scrollToHoveredElement(e){try{let t=this.domService.getElementFromXPath(e.xpath);if(t&&e.parentXpath)if(e.parentXpath==="/html")tL(t);else{let i=this.domService.getElementFromXPath(e.parentXpath);i&&GZ(i,t,!0)}}catch(t){this.loggingService.catch("Error in FlockService clickUserElement: ",t)}}};o.\u0275fac=function(t){return new(t||o)(Z(Ke),Z(Ve),Z(k),Z($_e),Z(G_e))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var mc=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A){this.analyticsService=e,this.docService=t,this.domService=i,this.authService=a,this.afAuth=l,this.iamService=c,this.databaseService=d,this.configService=g,this.avatarService=u,this.loggingService=_,this.flockService=w,this.commonDbService=A,this.db=null,this.presenceUser$=new Se(new uO),this.documentPaths=null,this.inactivityTime=300*1e3,this.offlineInactivityTime=600*1e3,this.presenceUsers$=new Se([]),this.presenceUsersSubscription=null,this.includeSelf$=new Se(!0),this.customPresenceUsers$=new Se([]),this.userIdleStateDetectionSubscription=null,this.userOfflineStateDetectionSubscription=null;try{this.loggingService.log("%c[WB] Creating CLASS: PresenceService","color: blue;"),this.databaseService.getDb().pipe($e(M=>!!M),ut(1)).subscribe(M=>{M&&(this.db=M,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},j=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",j)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},j=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",j)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange())},M=>{this.loggingService.catch("Error in PresenceService constructor: ",M)}),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(Lr()).subscribe(([M,j])=>{try{j?.length>=0&&this.analyticsService.updateDefaultProperties({presenceUsersCount:j?.length}),sessionStorage.getItem(F.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE)||j?.length>1&&M.length!==j.length&&(sessionStorage.setItem(F.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE,"true"),this.presenceActionsService?.onMultipleUsersOnline({users:j}))}catch(q){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",q)}}),this.authService.getUser$().pipe($e(M=>!!M),ut(1)).subscribe(M=>{M?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(M=>{try{M?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(M)),state:M?.onlineStatus})}catch(j){this.loggingService.catch("Error in presenceUser$ subscription: ",j)}},M=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",M)}),this.customPresenceUsers$.subscribe(()=>{try{let M=this.presenceUsers$.value.filter(j=>!j.localOnly);this.presenceUsers$.next(this.mergeWithCustomUsers(M))}catch(M){this.loggingService.catch("Error in customPresenceUsers$ subscription: ",M)}}),this.domService.onNetworkStatusChange$().subscribe(M=>{try{!M&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:y(h({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:F.PRESENCE_STATUS_OFFLINE}),state:F.PRESENCE_STATUS_OFFLINE})}catch(j){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",j)}},M=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",M)})}catch(M){this.loggingService.catch("Error in PresenceService constructor: ",M)}}setPresenceActionsService(e){try{this.presenceActionsService=e}catch(t){this.loggingService.catch("Error in setPresenceActionsService: ",t)}}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(vu(2e3),dn(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_ONLINE),e=!1)}),to(this.inactivityTime),dn(()=>{this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_AWAY,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}detectUserOfflineState(){try{this.unsubscribeUserOfflineStateDetectionSubscription();let e=!1;this.userOfflineStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(vu(2e3),to(this.offlineInactivityTime),dn(()=>{this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_OFFLINE,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserOfflineState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}unsubscribeUserOfflineStateDetectionSubscription(){try{this.userOfflineStateDetectionSubscription&&(this.userOfflineStateDetectionSubscription.unsubscribe(),this.userOfflineStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserOfflineStateDetectionSubscription: ",e)}}getUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().pipe($e(e=>!!e)).subscribe(e=>{e&&this.setPresenceUser(e)},e=>{this.loggingService.catch("Error in getUser: ",e)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e}),Lr(),dn(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(F.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(F.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(dn(e=>{this.updateUserOnLocationChange(e)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getLocation: ",e)})}getPresenceUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getPresenceUser","color: green;"),this.presenceUser$.asObservable()}getPresenceUserValue(){return this.presenceUser$.value}getOnlineUsersOnCurrentDocument(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),_r(this.afAuth).pipe($e(t=>!!t),ye(t=>this.isFeatureAllowed({firebaseUser:t,users:[],filteredUsers:[]})),ye(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(i=>(t.featureAllowed=i,t))):de(t)),ye(t=>t.featureAllowed?this.authService.isPlanExpired$().pipe(ge(i=>(t.featureAllowed=!i,t))):de(t)),ye(t=>t.featureAllowed?de(t).pipe(ye(i=>this.docService.getDocumentPaths$().pipe(ge(a=>(this.documentPaths=a,i.documentPaths=a,i)))),ye(i=>this.getDataFromDocumentId(e).pipe(ge(a=>(i.users=a||[],h({},i))))),ge(i=>(e?e?.statuses?.length?i.filteredUsers=i?.users?.filter(a=>e?.statuses?.includes(a?.onlineStatus)):i.filteredUsers=i?.users?.slice():i.filteredUsers=this.filterOnlineUsers(i.users,i.firebaseUser),i)),ye(i=>this.getIncludeSelf$().pipe(ge(a=>(a||(i.filteredUsers=i?.filteredUsers?.filter(l=>l?.userSnippylyId!==i.user?.userSnippylyId)),i)))),ye(i=>{let a=i?.filteredUsers||[];return this.customPresenceUsers$.pipe(ge(()=>this.mergeWithCustomUsers(a)))})):de([])),bt(Zt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.PRESENCE)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe($e(t=>!!t),ye(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.presence){let i=new Date(Date.now()-864e5).getTime();return this.commonDbService.dbListener({feature:"allPresence",properties:{documentId:e?.documentId??this.documentPaths?.documentId,organizationId:e?.organizationId??this.documentPaths?.organizationId,skipFirestore:!0,useQuery:!0,rtdbQuery:[l0("timestamp"),K_(i)]}}).pipe(Gn(a=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",a),de(null))),ge(a=>a?.data),ge(a=>{let l=[];if(a){let c=Object.values(a).filter(d=>typeof d=="object");for(let d of c)l.push(d)}return l}))}else return de([])}))}filterOnlineUsers(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(l=>{let c=cp(l.timestamp);return l.userSnippylyId&&(l.onlineStatus===F.PRESENCE_STATUS_ONLINE||l.onlineStatus===F.PRESENCE_STATUS_AWAY)&&c<this.offlineInactivityTime});return this.presenceUsers$.next(this.mergeWithCustomUsers(a)),a}catch(i){return this.loggingService.catch("Error in filterOnlineUsers:",i),[]}}enableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableIncludeSelf","color: green;"),this.includeSelf$.value===!0)return;this.includeSelf$.next(!0)}catch(e){this.loggingService.catch("Error in PresenceService enableIncludeSelf: ",e)}}disableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableIncludeSelf","color: green;"),this.includeSelf$.value===!1)return;this.includeSelf$.next(!1)}catch(e){this.loggingService.catch("Error in PresenceService disableIncludeSelf: ",e)}}getIncludeSelf$(){return this.includeSelf$.asObservable()}getIncludeSelf(){return this.includeSelf$.value}getPresenceUserFromExternalId(e){try{if(this.presenceUsers$.value&&this.presenceUsers$.value.length>0){let t=this.presenceUsers$.value.find(i=>i.userId===e);if(t)return t}return null}catch(t){return this.loggingService.catch("Error in getNameFromSnippylyId:",t),null}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}updateCurrentPresenceUser(e){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateCurrentPresenceUser","color: green;");try{if(this.documentPaths?.presence&&e&&e.userId&&this.authService.isFeatureAllowed(je.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new Ao,e?.onlineStatus===F.PRESENCE_STATUS_ONLINE&&(e.isTabAway=!1,e.isUserIdle=!1);let t=JSON.parse(JSON.stringify(e));this.authService.getUser()&&this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},t),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentPresenceUser:",t)}})}setCurrentPresenceUserStatus(e,t){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setCurrentPresenceUserStatus","color: green;");try{this.loggingService.log(e);let i=this.presenceUser$.value;if(i.onlineStatus!==e){this.presenceUsersSubscription&&this.presenceUsersSubscription?.unsubscribe();let a=i.onlineStatus,l=e;this.presenceUsersSubscription=this.getPresenceUsers$().pipe($e(c=>!!c?.length),ut(1)).subscribe(c=>{c?.length>1&&this.analyticsService.trackEvent(Y.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:l,totalUsers:c?.length,presenceSnippylyUserIds:c?.map(d=>d.userSnippylyId),presenceClientUserIds:c?.map(d=>d.userId)})})}i.onlineStatus=e,t&&(i.isTabAway=t?.isTabAway,i.isUserIdle=t?.isUserIdle),e===F.PRESENCE_STATUS_ONLINE&&(i.isTabAway=!1,i.isUserIdle=!1),e===F.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.updateCurrentPresenceUser(i)}catch(i){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",i)}})}updateUserStatusOnDocumentChange(e,t){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let i=this.presenceUser$.value;if(i.onlineStatus=e,t?.presence&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(je.PRESENCE)){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:t?.documentId,organizationId:t?.organizationId,userId:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",i)}})}updateUserOnLocationChange(e){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserOnLocationChange","color: green;");try{let t=this.presenceUser$.value;if(t.location=e?e.location:null,t.locationId=e?e?.locationId:null,this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous&&this.authService.isFeatureAllowed(je.PRESENCE)){let i=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=Hr(this.db,".info/connected"),t=_N(e).pipe(ge(i=>i?F.PRESENCE_STATUS_ONLINE:F.PRESENCE_STATUS_OFFLINE));return _r(this.afAuth).pipe(Rd(1),ye(i=>i?t:de(F.PRESENCE_STATUS_OFFLINE)),dn(i=>this.setCurrentPresenceUserStatus(i)))}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.authService.getUser()&&(document.visibilityState==="hidden"?(this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(F.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!1))}))}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let t=this.presenceUser$.value,i=!1;if(e.featureAllowList.includes(je.PRESENCE)?t?.onlineStatus!==F.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=F.PRESENCE_STATUS_ONLINE,i=!0):t?.onlineStatus!==F.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=F.PRESENCE_STATUS_OFFLINE,i=!0),i&&this.authService.getUser()&&this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous){let a=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}})}catch(e){this.loggingService.catch("Error in updateOnAllowedFeatureListChange:",e)}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),_r(this.afAuth).pipe($e(e=>!!e),ye(e=>this.docService.getDocumentPaths$().pipe(ge(t=>e))),dn(e=>X(this,null,function*(){try{if(this.documentPaths?.presence&&e){let t=yield Qv(e,!0).catch(a=>null);if(!t)return;let{user:i}=t.claims;if(!i?.isAnonymous&&this.documentPaths?.presence){this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession();let a=`${this.documentPaths.presence}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:F.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp}).catch(l=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",l)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}setPresenceUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPresenceUser","color: green;");try{let t=this.presenceUser$.value;t.userId=e?.userId,t.name=e?.name,t.email=e?.email,t.photoUrl=e?.photoUrl,t.userSnippylyId=e?.userSnippylyId,t.color=e?.color,t.textColor=e?.textColor,t.initial=e?.initial,t.timestamp=this.timestamp,t.type=e?.type,t.isReadOnly=e?.isReadOnly,t.isAnonymous=e?.isAnonymous;let i=e?.name?.split(" ");if(i&&i.length>0){let a=i[0],l=i.length>1?i[i.length-1]:null,c=l?l[0]:null;a&&(t.name=`${a} ${c?c+".":""}`)}this.updateCurrentPresenceUser(t)}catch(t){this.loggingService.catch("Error in setPresenceUser:",t)}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.presence&&e?this.commonDbService.getData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(a=>{a&&(this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.commonDbService.updateData({feature:"presence",errorCallback:l=>{i(l)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:F.PRESENCE_STATUS_OFFLINE})))})),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),i(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),i(a)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(Y.Events.Presence.PRESENCE_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}setOfflineInactivityTime(e){try{e>=this.inactivityTime?(this.offlineInactivityTime=e,this.analyticsService.trackEvent(Y.Events.Presence.PRESENCE_SET_CUSTOM_OFFLINE_INACTIVITY_TIMER,{offlineInactivityTime:this.offlineInactivityTime}),this.detectUserOfflineState()):this.loggingService.catch("Error in setOfflineInactivityTime: ","offline-inactivity-time value is less than inactivity-time.")}catch(t){this.loggingService.catch("Error in setOfflineInactivityTime: ",t)}}getOfflineInactivityTime(){return this.offlineInactivityTime}getPresenceUsers$(){return this.presenceUsers$.asObservable()}getPresenceUsers(){return this.presenceUsers$.value}get timestamp(){return this.commonDbService.getServerTimestamp()}addCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: addCustomUser","color: green;");let t=e?.user,i=e?.localOnly??!1;if(!t?.userId){this.loggingService.catch("Error in addCustomUser: ","userId is required");return}let a=this.buildCustomPresenceUser(t,i);if(!a)return;if(i){let l=this.customPresenceUsers$.value,c=l.findIndex(d=>d.userId===t.userId);if(c>=0){let d=[...l];d[c]=a,this.customPresenceUsers$.next(d)}else this.customPresenceUsers$.next([...l,a])}else this.persistCustomUserToDb(a)}catch(t){this.loggingService.catch("Error in addCustomUser: ",t)}}removeCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomUser","color: green;");let t=e?.user?.userId,i=e?.localOnly??!1;if(!t){this.loggingService.catch("Error in removeCustomUser: ","userId is required");return}if(i){let a=this.customPresenceUsers$.value,l=a.filter(c=>c.userId!==t);l.length!==a.length&&this.customPresenceUsers$.next(l)}else{let a=this.buildCustomPresenceUser(e.user,!1);a&&this.removeCustomUserFromDb(a)}}catch(t){this.loggingService.catch("Error in removeCustomUser: ",t)}}mergeWithCustomUsers(e){try{let t=this.customPresenceUsers$.value;if(t.length===0)return e;let i=new Set(e.map(l=>l.userId)),a=t.filter(l=>!i.has(l.userId));return[...e,...a]}catch(t){return this.loggingService.catch("Error in mergeWithCustomUsers: ",t),e}}buildCustomPresenceUser(e,t=!1){try{let i=this.configService.getApiKey(),a=new uO;return a.userId=e.userId,a.name=e.name||e.userId,a.email=e.email||"",a.photoUrl=e.photoUrl||"",a.onlineStatus=e.onlineStatus||F.PRESENCE_STATUS_ONLINE,a.color=e.color||this.avatarService.generateUserColor(),a.textColor=e.textColor||"",a.type="custom",a.initial=e.initial||(a.name?a.name.charAt(0).toUpperCase():"U"),a.timestamp=Date.now(),a.isReadOnly=e.isReadOnly??!1,a.isAnonymous=e.isAnonymous??!1,a.location=e.location||null,a.locationId=e.locationId??null,a.pageInfo=e.pageInfo||new Ao,a.isTabAway=!1,a.isUserIdle=!1,a.userSnippylyId=e.userSnippylyId||(i?hd(i,e.userId):`custom_${e.userId}`),a.localOnly=t,a}catch(i){return this.loggingService.catch("Error in buildCustomPresenceUser: ",i),null}}persistCustomUserToDb(e){try{if(this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(je.PRESENCE)){let t=JSON.parse(JSON.stringify(e));delete t.localOnly,this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},t),{timestamp:this.timestamp})))})}}catch(t){this.loggingService.catch("Error in persistCustomUserToDb: ",t)}}removeCustomUserFromDb(e){try{this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(je.PRESENCE)&&this.commonDbService.deleteData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in removeCustomUserFromDb: ",t)}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(st),Z(Ve),Z(Ke),Z(no),Z(Vn),Z(Hn),Z(Lt),Z(_m),Z(k),Z(_v),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var HS=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w){this.analyticsService=e,this.configService=t,this.presenceService=i,this.docService=a,this.afAuth=l,this.iamService=c,this.domService=d,this.databaseService=g,this.authService=u,this.loggingService=_,this.commonDbService=w,this.cursorUser$=new Se(new w1),this.documentPaths=null,this.inactivityTime=120*1e3,this.allowedElementIds$=new Se([]),this.cursorTagAvailable$=new Se(!1),this.cursorTagAvailable=!1,this.cursorUsers$=new Se([]),this.loggingService.log("%c[WB] Creating CLASS: CursorService","color: blue;");try{this.checkCursorTagAvailable(),this.databaseService.getDb().pipe($e(A=>!!A),ye(A=>this.cursorTagAvailable$.pipe($e(M=>!!M),ut(1),ge(()=>A))),ut(1)).subscribe(A=>{A&&this.cursorTagAvailable&&(this.getPresenceUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnDatabaseDisconnect().subscribe(()=>{},M=>{this.loggingService.catch("Error in CursorService constructor updateOnDatabaseDisconnect: ",M)}),this.addMouseMoveListener(),this.addScreenSizeChangeListener(),this.updateOnAllowedFeatureListChange())},A=>{this.loggingService.catch("Error in CursorService constructor getDb: ",A)}),this.cursorUsers$.pipe(Lr()).subscribe(([A,M])=>{sessionStorage.getItem(F.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED)||M?.length>1&&A.length!==M.length&&(this.analyticsService.trackEvent(Y.Events.Cursor.CURSOR_MULTIPLE_USERS_DETECTED,{totalUsers:M.length,cursorSnippylyUserIds:M.map(j=>j.userSnippylyId),cursorClientUserIds:M.map(j=>j.userId)}),sessionStorage.setItem(F.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED,"true"))}),this.authService.addPreSignOutFuction("cursor-signout",this.signOutUser.bind(this))}catch(A){this.loggingService.catch("Error in CursorService constructor: ",A)}}checkCursorTagAvailable(){this.loggingService.log("%c[WB] Calling FUNCTION: checkCursorTagAvailable","color: green;");try{this.cursorTagAvailable=!!document.querySelector(F.TAGS.VELT_CURSOR)||!!document.querySelector(F.TAGS.SNIPPYLY_CURSOR),this.cursorTagAvailable$.next(this.cursorTagAvailable)}catch(e){this.loggingService.catch("Error in CursorService checkCursorTagAvailable: ",e)}}addScreenSizeChangeListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addScreenSizeChangeListener","color: green;");try{this.docService.getDocumentPaths$().pipe($e(e=>!!e),ye(e=>this.domService.getCurrentWindowSize$("CursorService addScreenSizeChangeListener").pipe($e(t=>!!t)))).subscribe(e=>{this.setCurrentCursorUserScreenSize(e)},e=>{this.loggingService.catch("Error in addScreenSizeChangeListener getCurrentWindowSize: ",e)})}catch(e){this.loggingService.catch("Error in CursorService addScreenSizeChangeListener: ",e)}}addMouseMoveListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addMouseMoveListener","color: green;");try{this.domService.onWindowPointerMove$().pipe(vu(50)).subscribe(e=>{e&&this.setCurrentCursorUserPosition(e.pageX,e.pageY,this.domService.getTargetElementForCursorPosition(e,!0,!1,!1,void 0,!1))},e=>{this.loggingService.catch("Error in addMouseMoveListener getCurrentMousePosition: ",e)})}catch(e){this.loggingService.catch("Error in CursorService addMouseMoveListener: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e}),Lr(),dn(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(F.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(F.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getDocumentPaths: ",e)}}getLocation(){try{this.docService.getLocation$().pipe(dn(e=>{this.updateUserOnLocationChange(e)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getLocation subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getLocation: ",e)}}getCursorUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getCursorUser","color: green;"),this.cursorUser$.asObservable()}getPresenceUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getPresenceUser","color: green;"),this.presenceService.getPresenceUser().pipe($e(e=>!!e),Gn(e=>de(e.code))).subscribe(e=>{this.setCursorUser(e)},e=>{this.loggingService.catch("Error in getPresenceUser: ",e)})}getLiveCursorsOnCurrentDocument(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLiveCursorsOnCurrentDocument","color: green;"),_r(this.afAuth).pipe($e(e=>!!e),ye(e=>this.isFeatureAllowed({firebaseUser:e,users:[],filteredUsers:[]})),ye(e=>e.featureAllowed?this.iamService.isUserAllowed$().pipe(ge(t=>(e.featureAllowed=t,e))):de(e)),ye(e=>e.featureAllowed?this.authService.isPlanExpired$().pipe(ge(t=>(e.featureAllowed=!t,e))):de(e)),ye(e=>!e.featureAllowed||e?.user?.isAnonymous?de([]):de(e).pipe(ye(t=>this.docService.getDocumentPaths$().pipe(ge(i=>(this.documentPaths=i,t.documentPaths=i,t)))),ye(t=>this.getDataFromDocumentId().pipe(ge(i=>(t.users=i||[],h({},t))))),ge(t=>(t.filteredUsers=this.filterOnlineUsers(t.users,t.firebaseUser),t)),ye(t=>t?.filteredUsers?.length?this.domService.getCurrentWindowSize$("CursorService getLiveCursorsOnCurrentDocument").pipe(ge(()=>t)):de(t)),ge(t=>(t?.filteredUsers?.forEach(i=>{this.calculateCursorUserPosition(i)}),t)),ye(t=>t?.filteredUsers?de(t?.filteredUsers||[]):de([])))))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})),ye(t=>this.authService.getUser$().pipe(ge(i=>y(h({},t),{user:i})))),ye(t=>Mo(t.config,t.user,je.CURSOR)?de(y(h({},t),{featureAllowed:!0})):(this.loggingService.warn("Cursor feature is not allowed."),de(y(h({},t),{featureAllowed:!1})))),bt((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe($e(t=>!!t),ye(t=>{if(this.configService?.getApiKey()&&this.documentPaths?.cursor){let i=new Date(Date.now()-864e5).getTime();return this.commonDbService.dbListener({feature:"allCursors",properties:{documentId:e??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0,useQuery:!0,rtdbQuery:[l0("timestamp"),K_(i)]}}).pipe(Gn(a=>(this.loggingService.catch("Error in CursorService getDataFromDocumentId: ",a),de(null))),ge(a=>a?.data),ge(a=>{let l=[];return a&&(l=Object.values(a).filter(c=>typeof c=="object")),l}))}else return de([])}))}calculateCursorUserPosition(e){try{if(e?.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let i=t.iterateNext();if(i&&this.isElementInsideAllowedElements(i)){let a=i.getBoundingClientRect();a&&a.width&&a.height&&(e.position={top:a.top+a.height*e.targetElement.topPercentage/100,left:a.left+a.width*e.targetElement.leftPercentage/100})}}}}catch(t){this.loggingService.catch("Error in calculateCursorUserPosition:",t)}}filterOnlineUsers(e,t){try{let a=e.slice().filter(c=>{let d=cp(c.timestamp);return c.userSnippylyId&&c.onlineStatus===F.PRESENCE_STATUS_ONLINE&&d<this.inactivityTime});this.cursorUsers$.next(a),a=a.filter(c=>c?.userSnippylyId!==t?.uid);let l=this.docService.getLocation();return l&&l.locationId?a=a.filter(c=>c.locationId===l.locationId):a=a.filter(c=>!c.locationId),a}catch(i){return this.loggingService.catch("Error in filterOnlineUsers:",i),[]}}setCursorUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setCursorUser","color: green;");try{let t=this.cursorUser$.value;t.userId=e?.userId,t.name=e?.name,t.email=e?.email,t.photoUrl=e?.photoUrl,t.comment="",this.authService.isFeatureAllowed(je.PRESENCE)&&(t.onlineStatus=e?.onlineStatus),t.userSnippylyId=e?.userSnippylyId,t.color=e?.color,t.textColor=e?.textColor,t.initial=e?.initial,t.timestamp=this.timestamp,t.type=e?.type,t.isReadOnly=e?.isReadOnly,t.isAnonymous=e?.isAnonymous;let i=this.domService.getCurrentWindowSizeValue();t.screenWidth=i?.screenWidth,t.screenHeight=i?.screenHeight,t.screenScrollHeight=i?.screenScrollHeight,this.updateCurrentCursorUser(t)}catch(t){this.loggingService.catch("Error in setCursorUser:",t)}}setCurrentCursorUserPosition(e,t,i){try{let a=this.cursorUser$.value;a?.onlineStatus===F.PRESENCE_STATUS_ONLINE&&(a.positionX=e,a.positionY=t,i?a.targetElement=i:a.targetElement=null,this.updateCurrentCursorUser(a))}catch(a){this.loggingService.catch("Error in setCurrentCursorUserPosition:",a)}}setCurrentCursorUserScreenSize(e){try{if(e.screenWidth!==0&&e.screenHeight!==0){let t=this.cursorUser$.value;t?.onlineStatus===F.PRESENCE_STATUS_ONLINE&&(t.screenWidth=e.screenWidth,t.screenHeight=e.screenHeight,t.screenScrollHeight=e.screenScrollHeight,this.updateCurrentCursorUser(t))}}catch(t){this.loggingService.catch("Error in setCurrentCursorUserScreenSize:",t)}}updateCurrentCursorUser(e){return X(this,null,function*(){try{if(this.documentPaths&&e&&e.userId&&this.authService.isFeatureAllowed(je.CURSOR)){if(!e.isAnonymous){e.pageInfo=new Ao;let t=JSON.parse(JSON.stringify(e));this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},t),{timestamp:this.timestamp})))})}this.cursorUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentCursorUser:",t)}})}updateUserStatusOnDocumentChange(e,t){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let i=this.cursorUser$.value;if(i.onlineStatus=e,t&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(je.CURSOR)){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"cursor",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},a),{timestamp:this.timestamp})))})}}catch(i){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",i)}})}updateUserOnLocationChange(e){return X(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserOnLocationChange","color: green;");try{let t=this.cursorUser$.value;if(t.location=e?e.location:null,t.locationId=e?e?.locationId:null,this.documentPaths&&t&&t.userId&&!t.isAnonymous&&this.authService.isFeatureAllowed(je.CURSOR)){let i=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},i),{timestamp:this.timestamp})))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let t=this.cursorUser$.value,i=!1;if(e.featureAllowList.includes(je.CURSOR)?t?.onlineStatus!==F.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=F.PRESENCE_STATUS_ONLINE,i=!0):t?.onlineStatus!==F.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=F.PRESENCE_STATUS_OFFLINE,i=!0),i&&this.documentPaths&&t&&t.userId&&!t.isAnonymous){let a=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(y(h({},a),{timestamp:this.timestamp})))})}}})}catch(e){this.loggingService.catch("Error in updateOnAllowedFeatureListChange:",e)}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),_r(this.afAuth).pipe($e(e=>!!e),ye(e=>this.docService.getDocumentPaths$().pipe(ge(t=>e))),dn(e=>X(this,null,function*(){try{if(this.documentPaths&&e){let t=yield Qv(e,!0).catch(a=>null);if(!t)return;let{user:i}=t.claims;if(!i?.isAnonymous&&this.documentPaths?.cursor){let a=`${this.documentPaths.cursor}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:F.PRESENCE_STATUS_OFFLINE,comment:"",timestamp:this.timestamp}).catch(l=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",l)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths&&e?this.commonDbService.getData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:e.uid,skipFirestore:!0}}).then(a=>{a&&this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.uid,skipFirestore:!0},callback:()=>{t(null)},data:JSON.parse(JSON.stringify(y(h({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:F.PRESENCE_STATUS_OFFLINE})))}),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),i(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),i(a)}})}setInactivityTime(e){this.inactivityTime=e,this.analyticsService.trackEvent(Y.Events.Cursor.CURSOR_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime})}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in CursorService isElementInsideAllowedElements: ",t),!1}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(Lt),Z(mc),Z(st),Z(no),Z(Vn),Z(Ve),Z(Hn),Z(Ke),Z(k),Z(kn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var aV=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: CursorElement","color: blue;"),this.getLiveCursorsOnCurrentDocument=this._getOnlineUsersOnCurrentDocument,this.getOnlineUsersOnCurrentDocument=this._getOnlineUsersOnCurrentDocument,this.setInactivityTime=this._setInactivityTime,this.allowedElementIds=this._allowedElementIds}_getOnlineUsersOnCurrentDocument(){this.getService(k).log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Cursor.GET_LIVE_CURSORS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(HS).getLiveCursorsOnCurrentDocument()}catch(o){return this.getService(k).catch("Error in _getOnlineUsersOnCurrentDocument: ",o),de(null)}}_setInactivityTime(o){this.getService(k).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(Y.Events.Cursor.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:o}}),isNaN(o)?this.getService(k).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(HS).setInactivityTime(o)}catch(r){this.getService(k).catch("Error in setInactivityTime: ",r)}}_allowedElementIds(o){this.getService(k).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Cursor.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(HS).setAllowedElementIds(o)}catch(r){this.getService(k).catch("Error in allowedElementIds: ",r)}}};var lV=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: DocElement","color: blue;"),this.getDocumentMetadata=this._getDocumentMetadata}_getDocumentMetadata(){this.getService(k).log("%c[WB] Calling FUNCTION: getDocumentMetadata","color: green;");try{return this.trackEvent(Y.Events.Doc.GET_DOCUMENT_METADATA_TRIGGERED),this.getService(st).getDocumentMetadata$()}catch(o){return this.getService(k).catch("Error in getDocumentMetadata: ",o),de(null)}}};var sa=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u,_,w,A,M){this.afAuth=e,this.analyticsService=t,this.authService=i,this.databaseService=a,this.docService=l,this.configService=c,this.domService=d,this.huddleUtilsService=g,this.functions=u,this.loggingService=_,this.notificationService=w,this.commonDbService=A,this.usersService=M,this.documentPaths=null,this.localStream$=new Se(null),this.peerConnectionMap={},this.localStream=new MediaStream,this.screenSharingStream=new MediaStream,this.screenSharingStream$=new Se(null),this.remoteStreamMap={},this.remoteStreamMap$=new Se(null),this.localStreamState$=new Se({}),this.peerConnectionStateMap={},this.peerConnectionStateMap$=new Se({}),this.hudleToolComponentId$=new Se(null),this.attendees$=new Se([]),this.invitees$=new Se([]),this.huddleJoined$=new Se(!1),this.userHuddleStartTime$=new Se(null),this.messages$=new Se([]),this.messagesPanelVisible$=new Se(!1),this.huddleOnCursorMode$=new Se(!1),this.flockModeOnAvatarClickEnabled$=new Se(!1),this.chatEnabled$=new Se(!0),this.serverFallback$=new Se(!0),this.huddleOnCursorModeByAttendeeId$=new Se({}),this.huddleCursorAvailableByAttendeeId$=new Se({}),this.remoteStreamsByUserId$=new Se({}),this.messagesSubscription=null,this.huddleJoined=!1,this.onAnswerConnectionIdHistory={},this.onOfferUidHistory={},this.senders={},this.db=null,this.dbRefsRemoveOnDropCall=[],this.servers={iceServers:[{urls:["stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302"]}]},this.databaseService.getDb().pipe($e(j=>!!j),ut(1)).subscribe(j=>{try{j&&(this.db=j,this.isHuddleTagInstalled()&&this.getServerFallback()&&this.getTwilioIceServers(),this.getUser(),this.getDocumentPaths())}catch(q){this.loggingService.catch("Error in HuddleService getDb:",q)}},j=>{this.loggingService.catch("Error in HuddleService getDb subscription: ",j)}),this.docService.addPreDocumentIdChangeFunction("huddle-service",j=>X(this,null,function*(){this.huddleJoined$.value&&(yield this.dropCall(),yield this.removeLocalStream(),yield this.removeAttendee(),this.attendees$.next([]))})),this.getAttendees().subscribe(),this.getInvitees().subscribe(),this.localStream$.subscribe(j=>{j&&(this.localStream=j)}),this.screenSharingStream$.subscribe(j=>{j&&(this.screenSharingStream=j)}),this.configService.getConfig$().subscribe(j=>{try{!j?.featureAllowList?.find(ie=>ie===je.CURSOR)&&this.huddleOnCursorMode$.next(!1)}catch(q){this.loggingService.catch("Error in HuddleService configService.getConfig$:",q)}},j=>{this.loggingService.catch("Error in HuddleService configService.getConfig$ subscription: ",j)}),this.attendees$.subscribe(j=>{try{if(j?.length){if(this.huddleOnCursorMode$?.value){let q=this.huddleOnCursorModeByAttendeeId$.getValue()||{};j.forEach(ie=>{q[ie.userSnippylyId]=!0}),this.huddleOnCursorModeByAttendeeId$.next(q)}this.huddleJoined$?.value&&(j?.find(q=>q?.huddleOnCursorMode)?this.addCursorTag():this.removeCursorTag())}}catch(q){this.loggingService.catch("Error in HuddleService attendees$:",q)}},j=>{this.loggingService.catch("Error in HuddleService attendees$ subscription: ",j)}),mn([this.huddleJoined$,this.huddleOnCursorMode$]).subscribe(([j,q])=>{try{if(j){if(q){let ie=this.attendees$.getValue()||[],_e=this.huddleOnCursorModeByAttendeeId$.getValue()||{};ie.forEach(ae=>{_e[ae.userSnippylyId]=!0}),document?.body?.setAttribute(F.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE,"true")}else this.huddleOnCursorModeByAttendeeId$.next({}),document?.body?.removeAttribute(F.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE);this.updateHuddleOnCursorMode()}else this.removeCursorTag(),document?.body?.removeAttribute(F.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE)}catch(ie){this.loggingService.catch("Error in HuddleService huddleJoined$:",ie)}},j=>{this.loggingService.catch("Error in HuddleService huddleJoined$ subscription: ",j)}),this.huddleOnCursorModeByAttendeeId$.subscribe(j=>{try{this.huddleJoined&&(Object.keys(j).length?this.addCursorTag():this.removeCursorTag())}catch(q){this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$:",q)}},j=>{this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$ subscription: ",j)}),this.authService.addPreSignOutFuction("huddle-signout",this.signOutUser.bind(this))}isHuddleTagInstalled(){try{return!!document?.querySelector(`${F.TAGS.VELT_HUDDLE}`)||!!document?.querySelector(`${F.TAGS.SNIPPYLY_HUDDLE}`)}catch(e){return this.loggingService.catch("Error in HuddleService isHuddleTagInstalled:",e),!1}}getTwilioIceServers(){return X(this,null,function*(){try{let t=(yield qr(this.functions,Kr({url:Dn.cloudFunction.getIceServers,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5})())?.data;t&&t?.iceServers&&(this.servers.iceServers=t.iceServers)}catch(e){this.loggingService.catch("Error in HuddleService getTwilioIceServers:",e)}})}getRemoteStream(){return this.loggingService.log("%c[WB] Calling FUNCTION: getRemoteStream","color: green;"),this.remoteStreamMap$.asObservable()}getPeerConnectionStateMap(){return this.loggingService.log("%c[WB] Calling FUNCTION: getPeerConnectionStateMap","color: green;"),this.peerConnectionStateMap$.asObservable()}getLocalStreamState(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocalStreamState","color: green;"),this.localStreamState$.asObservable()}getScreenSharingStream(){return this.loggingService.log("%c[WB] Calling FUNCTION: getScreenSharingStream","color: green;"),this.screenSharingStream$.asObservable()}getAttendees(){return _r(this.afAuth).pipe($e(e=>!!e),ge(e=>({firebaseUser:e})),ye(e=>this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})))),ye(e=>this.authService.getUser$().pipe(ge(t=>y(h({},e),{user:t})))),ye(e=>Mo(e.config,e.user,je.HUDDLE)?de(y(h({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),de(y(h({},e),{allowed:!1})))),bt((e,t)=>e?.allowed===t?.allowed),ye(e=>this.docService.getDocumentPaths$().pipe(ge(t=>(this.documentPaths=t,e)))),ye(e=>e?.allowed?e?.user?.isAnonymous?de(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleAttendees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ge(t=>t?.data),ge(t=>t?(this.attendees$.next(Object.values(t)),Object.values(t)):(this.attendees$.next([]),null))):de(null):de([])))}getInvitees(){try{return _r(this.afAuth).pipe($e(e=>!!e),ge(e=>({firebaseUser:e})),ye(e=>this.configService.getConfig$().pipe($e(t=>!!t),ge(t=>y(h({},e),{config:t})))),ye(e=>this.authService.getUser$().pipe(ge(t=>y(h({},e),{user:t})))),ye(e=>Mo(e.config,e.user,je.HUDDLE)?de(y(h({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),de(y(h({},e),{allowed:!1})))),bt((e,t)=>e?.allowed===t?.allowed),ye(e=>this.docService.getDocumentPaths$().pipe(ge(t=>(this.documentPaths=t,e)))),ye(e=>e?.allowed?e?.user?.isAnonymous?de(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ge(t=>t?.data),ge(t=>t?(this.invitees$.next(Object.values(t)),Object.values(t)):(this.invitees$.next([]),null))):de(null):de([])))}catch(e){return this.loggingService.catch("Error in HuddleService getInvitees:",e),de([])}}clearHuddleInvitees(){try{this.documentPaths?.huddle&&this.commonDbService.deleteData({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}})}catch(e){this.loggingService.catch("Error in HuddleService clearHuddleInvitees:",e)}}getUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().pipe($e(e=>!!e)).subscribe(e=>{e&&(this.user=e)},e=>{this.loggingService.catch("Error in getUser: ",e)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().pipe(dn(e=>{this.documentPaths=e})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}setHuddleToolComponentId(e){this.hudleToolComponentId$.next(e||null)}getHuddleToolComponentId(){return this.hudleToolComponentId$.asObservable()}joinHuddle(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: joinHuddle","color: green;"),this.documentPaths?.huddle?(this.initialHuddleType=e,this.huddleJoined=!0,this.huddleJoined$.next(!0),this.initLocalStreams(),this.huddle=Hr(this.db,this.documentPaths?.huddle),this.iceCandidates=Hr(this.db,`${this.documentPaths?.huddle}/iceCandidates`),this.connections=Hr(this.db,`${this.documentPaths?.huddle}/connections`),this.attendees=Hr(this.db,`${this.documentPaths?.huddle}/attendees`),this.messages=Hr(this.db,`${this.documentPaths?.huddle}/messages`),this.setHuddleListener(),this.addAttendee(),this.callExistingAttendees(),this.userHuddleStartTime$.next(new Date().getTime())):this.loggingService.catch("Error in joinHuddle: documentPaths not found")}catch(t){this.loggingService.catch("Error in HuddleService joinHuddle:",t)}})}initLocalStreams(){try{if(!this.localStream$?.value?.getTracks()?.length){let e=new MediaStream([this.silence(),this.black()]);this.localStream$.next(e)}if(!this.screenSharingStream$?.value?.getTracks()?.length){let e=new MediaStream([this.black()]);this.screenSharingStream$.next(e)}}catch(e){this.loggingService.catch("Error in HuddleService initLocalStreams:",e)}}setHuddleListener(){this.loggingService.log("%c[WB] Calling FUNCTION: setHuddleListener","color: green;"),xg(this.connections,e=>{try{if(e.exists()){let t=e.val();Object.values(t).forEach(a=>{let l=Object.values(a);if(l&&l.length>0){let d=l[0]?.connectionId;this.onHuddleSnapshot(d,a)}}),Object.keys(this.remoteStreamMap).forEach(a=>X(this,null,function*(){t[a]||(this.remoteStreamMap[a]&&Object.values(this.remoteStreamMap[a]).forEach(l=>{l.getTracks().forEach(c=>{c.stop()})}),delete this.remoteStreamMap[a],yield this.removeIceCandidates(a))})),this.remoteStreamMap$.next(this.remoteStreamMap)}else Object.keys(this.remoteStreamMap).forEach(t=>X(this,null,function*(){Object.values(this.remoteStreamMap[t]).forEach(i=>{i.getTracks().forEach(a=>{a.stop()})}),yield this.removeIceCandidates(t)})),this.remoteStreamMap={},this.remoteStreamMap$.next(this.remoteStreamMap)}catch(t){this.loggingService.catch("Error in HuddleService setHuddleLister onValue:",t)}}),VY(this.iceCandidates).subscribe(e=>{try{e.event==="child_added"&&this.onIceCandidateSnapshot(e.snapshot)}catch(t){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",t)}}),VY(this.attendees).subscribe(e=>{try{if(e.event==="child_removed"){let t=e?.snapshot?.val();if(t){delete this.onOfferUidHistory[t?.userSnippylyId];let i=this.getCombinedId(this.user.userSnippylyId,t?.userSnippylyId);delete this.onAnswerConnectionIdHistory[i],this.closeConnection(i)}}}catch(t){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",t)}}),this.messagesSubscription&&this.messagesSubscription.unsubscribe(),this.messagesSubscription=new Vt(e=>{let t=xg(this.messages,i=>e.next(i),i=>e.error(i));return()=>t()}).pipe(ye(e=>this.usersService.getUserById$().pipe(ge(()=>e))),ye(e=>{if(e.exists()){let t=e.val();return so(this.huddleUtilsService.resolveUsersFromHuddleMessages(Object.values(t||{})))}return de([])}),Gn(e=>(this.loggingService.catch("Error in HuddleService messages onValue:",e),de([])))).subscribe(e=>{this.messages$.next(e)})}onHuddleSnapshot(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: onHuddleSnapshot","color: green;"),t.offerData&&!t.answerData&&t.offerData.from!==this.user.userSnippylyId&&t.offerData.to===this.user.userSnippylyId&&!(e in this.peerConnectionMap)&&!this.onOfferUidHistory[t.offerData.from]?(this.loggingService.log("offer received"),this.loggingService.log(t),this.onOfferUidHistory[t.offerData.from]=!0,this.onOffer(e,t.offerData)):t.answerData&&t.answerData.from!==this.user.userSnippylyId&&t.answerData.to===this.user.userSnippylyId&&this.peerConnectionMap[e]&&this.peerConnectionMap[e]?.connectionState!=="connected"&&!this.onAnswerConnectionIdHistory[e]&&(this.loggingService.log("answer received"),this.loggingService.log(t),this.onAnswerConnectionIdHistory[e]=!0,this.onAnswer(e,t.answerData))}catch(i){this.loggingService.catch("Error in HuddleService onHuddleSnapshot:",i)}}onIceCandidateSnapshot(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: onIceCandidateSnapshot","color: green;"),this.loggingService.log("ice candidate received");let t=e.val(),i=t.connectionId;t?.from!==this.user.userSnippylyId&&i in this.peerConnectionMap&&this.onIceCandidateChange(i,t)}catch(t){this.loggingService.catch("Error in HuddleService onIceCandidateSnapshot:",t)}}onOffer(e,t){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: onOffer","color: green;"),this.createPeerConnection(e,t.from)){this.addLocalStreamToPeerConnection(e,!0);let a=t.offer;yield this.setRemoteDescription(e,a),yield this.sendAnswer(e,t.from)}}catch(i){this.loggingService.catch("Error in HuddleService onOffer:",i)}})}sendAnswer(e,t){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendAnswer","color: green;"),this.loggingService.log(e),this.documentPaths?.huddle&&e){let i=yield this.peerConnectionMap[e].createAnswer();yield this.setLocalDescription(e,i);let l={answer:{type:i.type,sdp:i.sdp},from:this.user.userSnippylyId,connectionId:e,to:t},c=Hr(this.db,`${this.documentPaths?.huddle}/connections/${e}`);this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:c}),yield kN(c,{answerData:l}),wc(c).remove()}else this.loggingService.catch("Error in sendAnswer: documentPaths not found")}catch(i){this.loggingService.catch("Error in HuddleService onHuddleSnapshot:",i)}})}onAnswer(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onAnswer","color: green;");let i=t.answer;yield this.setRemoteDescription(e,i)}catch(i){this.loggingService.catch("Error in HuddleService onAnswer:",i)}})}onIceCandidateChange(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onIceCandidateChange","color: green;");let i=t.candidate;this.loggingService.log("onIceCandidateChange",i),yield this.peerConnectionMap[e].addIceCandidate(new RTCIceCandidate(i))}catch(i){this.loggingService.catch("Error in HuddleService onIceCandidateChange:",i)}})}setRemoteDescription(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRemoteDescription","color: green;"),yield this.peerConnectionMap[e].setRemoteDescription(new RTCSessionDescription(t))}catch(i){this.loggingService.catch("Error in HuddleService setRemoteDescription:",i)}})}addAttendee(){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: addAttendee","color: green;"),this.documentPaths?.huddle&&this.user?.userSnippylyId){let e=y(h({},this.user),{timestamp:this.timestamp,streamMetadata:{webcam:this.localStream?.id,screen:this.screenSharingStream?.id},initialHuddleType:this.initialHuddleType,huddleOnCursorMode:this.huddleOnCursorMode$?.value});e=this.huddleUtilsService.formatHuddleAttendeeData(e);let t=Hr(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}`);yield s0(t,JSON.parse(JSON.stringify(e))),this.dbRefsRemoveOnDropCall.push({type:"attendee",dbRef:t}),wc(t).remove(),yield this.updateUserHuddleState()}else this.loggingService.catch("Error in addAttendee: documentPaths not found")}catch(e){this.loggingService.catch("Error in HuddleService addAttendee:",e)}})}callExistingAttendees(){try{this.loggingService.log("%c[WB] Calling FUNCTION: callExistingAttendees","color: green;"),uge(this.attendees).pipe(ut(1)).subscribe(e=>{e&&e.length>1?(e.forEach(t=>{t.userSnippylyId!==this.user.userSnippylyId&&!this.onOfferUidHistory[t.userSnippylyId]&&(this.loggingService.log("calling"),this.loggingService.log(t),this.initOffer(t.userSnippylyId))}),this.addLocalStreamToAllPeerConnections()):this.deleteMessages()})}catch(e){this.loggingService.catch("Error in HuddleService callExistingAttendees:",e)}}addLocalStreamToAllPeerConnections(){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: addLocalStreamToAllPeerConnections","color: green;"),Object.keys(this.senders).forEach(e=>{this.loggingService.log(this.senders[e]),this.localStream.getTracks().forEach(t=>{this.loggingService.log(t),this.senders[e].replaceTrack(t)})})}catch(e){this.loggingService.catch("Error in HuddleService addLocalStreamToAllPeerConnections:",e)}})}initOffer(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: initOffer","color: green;");let t=this.createPeerConnection(null,e);t&&(this.addLocalStreamToPeerConnection(t,!1),yield this.sendOffer(t,e))}catch(t){this.loggingService.catch("Error in HuddleService initOffer:",t)}})}createPeerConnection(e,t){try{return this.loggingService.log("%c[WB] Calling FUNCTION: createPeerConnection","color: green;"),e||(e=this.getCombinedId(this.user?.userSnippylyId,t)),e in this.peerConnectionMap?null:(this.loggingService.log("creating pc"),this.peerConnectionMap[e]=new RTCPeerConnection(this.servers),this.peerConnectionMap[e].onicecandidateerror=i=>{this.loggingService.log("Huddle: onicecandidateerror",i)},this.peerConnectionMap[e].onicecandidate=i=>{if(this.loggingService.log("pc onicecandidate"),i.candidate){let a={candidate:i.candidate.toJSON(),from:this.user.userSnippylyId,connectionId:e},l=SN(this.iceCandidates,a);this.dbRefsRemoveOnDropCall.push({type:"iceCandidate",dbRef:l}),wc(l).remove()}},this.peerConnectionMap[e].ontrack=i=>{this.loggingService.log("pc ontrack"),this.onTrack(e,i)},this.peerConnectionMap[e].onconnectionstatechange=i=>X(this,null,function*(){this.logStatuses("onconnectionstatechange",e,i),this.peerConnectionMap[e].connectionState==="failed"&&(this.removeConnection(e),this.closeConnection(e),this.checkForRemovingAttendee())}),this.peerConnectionMap[e].onicegatheringstatechange=i=>X(this,null,function*(){this.logStatuses("onicegatheringstatechange",e,i)}),this.peerConnectionMap[e].onsignalingstatechange=i=>X(this,null,function*(){this.logStatuses("onsignalingstatechange",e,i)}),this.peerConnectionMap[e].oniceconnectionstatechange=i=>X(this,null,function*(){this.loggingService.log("pc oniceconnectionstatechange"),this.logStatuses("oniceconnectionstatechange",e,i);try{this.peerConnectionStateMap[e]=this.peerConnectionMap[e].iceConnectionState,this.peerConnectionStateMap$.next(this.peerConnectionStateMap),this.peerConnectionMap[e]?.iceConnectionState==="connected"?(this.loggingService.log("connected"),this.updateTransceiverDirection(e)):this.peerConnectionMap[e]?.iceConnectionState==="disconnected"?this.loggingService.log("Disconnected"):this.peerConnectionMap[e].iceConnectionState==="closed"&&(this.loggingService.log("Closed"),this.closeConnection(e))}catch(a){this.loggingService.catch("Error in HuddleService oniceconnectionstatechange:",a)}}),this.peerConnectionMap[e].onnegotiationneeded=()=>{this.loggingService.log("pc onnegotiationneeded"),this.logStatuses("onnegotiationneeded",e)},e)}catch(i){return this.loggingService.catch("Error in HuddleService createPeerConnection:",i),""}}logStatuses(e,t,i){let a={};["connectionState","iceConnectionState","iceGatheringState","signalingState"].forEach(c=>{a[c]=this.peerConnectionMap[t][c]}),this.loggingService.log("Huddle: logStatues: ",t,e,a,i,this.peerConnectionMap[t])}checkForRemovingAttendee(){return X(this,null,function*(){try{this.documentPaths?.huddle&&this.user?.userSnippylyId&&(Object.keys(this.peerConnectionMap)?.length||(this.commonDbService.deleteData({feature:"huddleAttendee",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:this.user?.userSnippylyId,skipFirestore:!0}}),this.joinHuddle(this.initialHuddleType)))}catch(e){this.loggingService.catch("Error in HuddleService checkForRemovingAttendee:",e)}})}closeConnection(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: closeConnection","color: green;"),this.peerConnectionMap[e]){let t=this.peerConnectionMap[e];t.getTransceivers()?.forEach(a=>{a.stop()}),t.getReceivers()?.forEach(a=>{a.track?.stop()}),t.close(),delete this.peerConnectionMap[e],delete this.onAnswerConnectionIdHistory[e],delete this.senders[e];let i=e.split("__").find(a=>a!==this.user?.userSnippylyId);i&&delete this.onOfferUidHistory[i]}}catch(t){this.loggingService.catch("Error in HuddleService closeConnection:",t)}}removeConnection(e){return X(this,null,function*(){try{this.documentPaths?.huddle&&e&&this.commonDbService.deleteData({feature:"huddleConnection",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:e,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in HuddleService removeConnection:",t)}})}addLocalStreamToPeerConnection(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: addLocalStreamToPeerConnection","color: green;"),t?(this.localStream.getTracks().forEach(i=>{this.peerConnectionMap[e].addTrack(i,this.localStream)}),this.screenSharingStream?.getVideoTracks()?.forEach(i=>{this.peerConnectionMap[e].addTrack(i,this.screenSharingStream)})):(this.localStream.getTracks().forEach(i=>{this.peerConnectionMap[e].addTrack(i,this.localStream)}),this.screenSharingStream?.getVideoTracks()?.forEach(i=>{this.peerConnectionMap[e].addTrack(i,this.screenSharingStream)}))}catch(i){this.loggingService.catch("Error in HuddleService addLocalStreamToPeerConnection:",i)}}updateTransceiverDirection(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateTransceiverDirection","color: green;");let t=this.peerConnectionMap[e].getTransceivers();this.loggingService.log(t),t.map(i=>{this.loggingService.log(i.currentDirection),i.currentDirection!=="sendrecv"&&(i.direction="sendrecv"),this.senders[e]=i.sender})}catch(t){this.loggingService.catch("Error in HuddleService updateTransceiverDirection:",t)}}generateKey(){this.loggingService.log("%c[WB] Calling FUNCTION: generateKey","color: green;");let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="";for(let i=0;i<20;i++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}getCombinedId(e,t){try{return e.localeCompare(t)===-1?`${e}__${t}`:`${t}__${e}`}catch(i){return this.loggingService.catch("Error in HuddleService getCombinedId:",i),""}}sendOffer(e,t){return X(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendOffer","color: green;"),this.documentPaths?.huddle&&e){this.onOfferUidHistory[t]=!0;let i=yield this.peerConnectionMap[e].createOffer();yield this.setLocalDescription(e,i);let a={sdp:i.sdp,type:i.type};t||(t="all");let l={offer:a,from:this.user.userSnippylyId,connectionId:e,to:t},c=Hr(this.db,`${this.documentPaths?.huddle}/connections/${e}`);yield s0(c,{offerData:l}),this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:c}),wc(c).remove()}}catch(i){this.loggingService.catch("Error in HuddleService sendOffer:",i)}})}setLocalDescription(e,t){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocalDescription","color: green;"),yield this.peerConnectionMap[e].setLocalDescription(t)}catch(i){this.loggingService.catch("Error in HuddleService setLocalDescription:",i)}})}onTrack(e,t){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: onTrack","color: green;"),this.remoteStreamMap[e]||(this.remoteStreamMap[e]={}),this.loggingService.log(t.receiver.track),t?.streams?.length){this.remoteStreamMap[e][t.streams[0].id]=t.streams[0];let i=e.split("__").find(l=>l!==this.user?.userSnippylyId),a=this.attendees$.value?.find(l=>l?.userSnippylyId===i);a&&(a?.streamMetadata?.webcam===t.streams[0].id&&(this.remoteStreamMap[e].webcam=t.streams[0]),a?.streamMetadata?.screen===t.streams[0].id&&(this.remoteStreamMap[e].screen=t.streams[0])),this.remoteStreamMap$.next(this.remoteStreamMap)}}catch(i){this.loggingService.catch("Error in HuddleService onTrack:",i)}}toggleScreenSharing(e){return X(this,null,function*(){try{if(e)this.screenSharingStream=yield navigator.mediaDevices?.getDisplayMedia({video:!0}),Object.keys(this.peerConnectionMap).forEach(t=>{this.peerConnectionMap[t].getSenders().find(l=>l?.track?.kind==this.screenSharingStream?.getVideoTracks()[0].kind)?.replaceTrack(this.screenSharingStream?.getVideoTracks()[0])});else{let t=this.localStream;Object.keys(this.peerConnectionMap).forEach(i=>{this.peerConnectionMap[i].getSenders().find(c=>c?.track?.kind==t.getVideoTracks()[0].kind)?.replaceTrack(t.getVideoTracks()[0])}),this.screenSharingStream?.getTracks().forEach(i=>i.stop())}}catch(t){this.loggingService.catch("Error in HuddleService toggleScreenSharing:",t)}})}setLocalStream(e){return X(this,null,function*(){try{if(this.localStream=new MediaStream([this.silence(),this.black()]),e?.audio||e?.video){let t=e,i=mv();e?.audio&&(e?.audio instanceof Object?t.audio=y(h({},e?.audio),{deviceId:i?.selectedAudioDevice?.deviceId}):t.audio={deviceId:i?.selectedAudioDevice?.deviceId}),e?.video&&(e?.video instanceof Object?t.video=y(h({},e?.video),{deviceId:i?.selectedVideoDevice?.deviceId}):t.video={deviceId:i?.selectedVideoDevice?.deviceId});let a=yield navigator.mediaDevices.getUserMedia(t);a?.getAudioTracks()?.length&&(this.localStream.getAudioTracks().forEach(l=>this.localStream.removeTrack(l)),a.getAudioTracks().forEach(l=>this.localStream.addTrack(l))),a?.getVideoTracks()?.length&&(this.localStream.getVideoTracks().forEach(l=>this.localStream.removeTrack(l)),a.getVideoTracks().forEach(l=>this.localStream.addTrack(l)))}this.localStream$.next(this.localStream)}catch(t){this.loggingService.catch("Error in HuddleService setLocalStream:",t)}})}setScreenSharingStream(){return X(this,null,function*(){try{let e=yield navigator.mediaDevices?.getDisplayMedia({video:!0});e&&this.screenSharingStream$.next(e)}catch(e){this.loggingService.catch("Error in HuddleService setScreenSharingStream:",e)}})}removeLocalStream(){return X(this,null,function*(){try{this.localStream$?.value&&(this.localStream$.value.getTracks().forEach(t=>{t.stop()}),this.localStream$.next(null))}catch(e){this.loggingService.catch("Error in HuddleService removeLocalStream:",e)}})}toggleLocalStreamAudio(e){return X(this,null,function*(){try{let t=this.localStream$.value;if(t){let i=t.getAudioTracks()[0];if(i.enabled&&!e)i.stop(),t.getAudioTracks()?.forEach(a=>{t.removeTrack(a)}),t.addTrack(this.silence()),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_AUDIO_MUTED,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(a=>a?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(a=>a?.userId)});else{let a=mv(),l=yield navigator.mediaDevices.getUserMedia({audio:{deviceId:a?.selectAudioDevice?.deviceId}});l&&(t.getAudioTracks()?.forEach(c=>{t.removeTrack(c)}),l.getAudioTracks()?.forEach(c=>{t.addTrack(c)}),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_AUDIO_UNMUTED,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(c=>c?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(c=>c?.userId)}))}Object.keys(this.peerConnectionMap).forEach(a=>{this.peerConnectionMap[a].getSenders().find(d=>d?.track?.kind==t?.getAudioTracks()[0].kind)?.replaceTrack(t?.getAudioTracks()[0])}),this.updateUserHuddleState()}}catch(t){this.loggingService.catch("Error in HuddleService toggleLocalStreamAudio:",t)}})}toggleLocalStreamVideo(e){return X(this,null,function*(){try{let t=this.localStream$.value;if(t){let i=t.getVideoTracks()[0];if(i.enabled&&!e)i.stop(),t.getVideoTracks()?.forEach(a=>{t.removeTrack(a)}),t.addTrack(this.black()),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_VIDEO_TURNED_OFF,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(a=>a?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(a=>a?.userId)});else{let a=mv(),l=yield navigator.mediaDevices.getUserMedia({video:{deviceId:a?.selectedVideoDevice?.deviceId}});l&&(t.getVideoTracks()?.forEach(c=>{t.removeTrack(c)}),l.getVideoTracks()?.forEach(c=>{t.addTrack(c)}),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_VIDEO_TURNED_ON,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(c=>c?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(c=>c?.userId)}))}Object.keys(this.peerConnectionMap).forEach(a=>{this.peerConnectionMap[a].getSenders().find(d=>d?.track?.kind==t?.getVideoTracks()[0].kind)?.replaceTrack(t?.getVideoTracks()[0])}),this.updateUserHuddleState()}}catch(t){this.loggingService.catch("Error in HuddleService toggleLocalStreamVideo:",t)}})}toggleLocalScreenSharing(){return X(this,null,function*(){try{let e=this.screenSharingStream;if(e){if(e.getVideoTracks()[0].enabled)this.stopScreenSharingStream();else{let i=yield navigator.mediaDevices?.getDisplayMedia({video:!0});i&&(e.getVideoTracks()?.forEach(a=>{e.removeTrack(a)}),i.getVideoTracks()?.forEach(a=>{e.addTrack(a),a.onended=()=>{this.stopScreenSharingStream(),this.updateScreenSharingTracksToPeers(),this.updateUserHuddleState()}})),this.screenSharingStream$.next(e),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_SCREENSHARING_STARTED,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(a=>a?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(a=>a?.userId)})}this.updateScreenSharingTracksToPeers(),this.updateUserHuddleState()}}catch(e){this.loggingService.catch("Error in HuddleService toggleLocalScreenSharing:",e)}})}stopScreenSharingStream(){return X(this,null,function*(){let e=this.screenSharingStream;if(e){let t=e.getVideoTracks()[0];t.enabled&&(t.stop(),e.getVideoTracks()?.forEach(i=>{e.removeTrack(i)}),e.addTrack(this.black()),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_SCREENSHARING_STOPPED,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(i=>i?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(i=>i?.userId)}))}})}updateScreenSharingTracksToPeers(){return X(this,null,function*(){Object.keys(this.peerConnectionMap).forEach(e=>{let i=this.peerConnectionMap[e].getSenders().filter(a=>a?.track?.kind==this.screenSharingStream?.getVideoTracks()[0].kind);i?.length>1&&i[1]?.replaceTrack(this.screenSharingStream?.getVideoTracks()[0])})})}dropCall(){return X(this,null,function*(){try{this.messagesSubscription&&this.messagesSubscription.unsubscribe(),this.removeHuddleSessionData(),this.huddleJoined=!1,this.huddleJoined$.next(!1),this.peerConnectionMap&&Object.keys(this.peerConnectionMap).forEach(e=>{let t=this.peerConnectionMap[e];t.getTransceivers()?.forEach(i=>{i.stop()}),t.getSenders()?.forEach(i=>{i.track?.stop()}),t.getReceivers()?.forEach(i=>{i.track?.stop()}),t.close()}),this.peerConnectionMap={},this.dbRefsRemoveOnDropCall.forEach(e=>X(this,null,function*(){yield yN(e.dbRef)})),this.onOfferUidHistory={},this.onAnswerConnectionIdHistory={},this.senders={},this.peerConnectionStateMap={},this.peerConnectionStateMap$.next(this.peerConnectionStateMap),this.localStream.getTracks().forEach(e=>{e.stop()}),this.screenSharingStream.getTracks().forEach(e=>{e.stop()}),this.localStream=new MediaStream([this.silence(),this.black()]),this.screenSharingStream=new MediaStream([this.black()]),this.localStream$.next(this.localStream),this.screenSharingStream$.next(this.screenSharingStream),this.localStreamState$.next({audioState:!1,videoState:!1,screenSharingState:!1}),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_LEFT,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(e=>e?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(e=>e?.userId)})}catch(e){this.loggingService.catch("Error in HuddleService dropCall:",e)}})}updateHuddleSessionData(e,t,i){try{let a=JSON.parse(sessionStorage.getItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)||"{}");i?sessionStorage.setItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(i)):(a[e]=t,sessionStorage.setItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(a)))}catch(a){this.loggingService.catch("Error in HuddleService updateHuddleSessionData:",a)}}getHuddleSessionData(){try{return sessionStorage.getItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)?JSON.parse(sessionStorage.getItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)):null}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleSessionData:",e),null}}removeHuddleSessionData(){try{sessionStorage.removeItem(F.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)}catch(e){this.loggingService.catch("Error in HuddleService removeHuddleSessionData:",e)}}removeAttendee(){return X(this,null,function*(){try{if(this.documentPaths?.huddle&&this.user.userSnippylyId){yield this.commonDbService.deleteData({feature:"huddleAttendee",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:this.user?.userSnippylyId,skipFirestore:!0}});return}else return}catch(e){return this.loggingService.catch("Error in HuddleService removeAttendee:",e),Promise.resolve(null)}})}updateUserHuddleState(){return X(this,null,function*(){try{if(this.attendees&&this.user&&this.documentPaths?.huddle){let e=this.getAudioState(),t=this.getVideoState(),i=this.getScreenSharingState();this.localStreamState$.next({audioState:e,videoState:t,screenSharingState:i});let a={audioState:e,videoState:t,screenSharingState:i};yield this.commonDbService.setData({feature:"huddleAttendeeState",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:this.user?.userSnippylyId,skipFirestore:!0},data:a})}}catch(e){this.loggingService.catch("Error in HuddleService updateUserHuddleState:",e)}})}updateHuddleOnCursorMode(){return X(this,null,function*(){try{if(this.attendees&&this.user&&this.documentPaths?.huddle){let e=Hr(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}/huddleOnCursorMode`);yield s0(e,!!this.huddleOnCursorMode$.value)}}catch(e){this.loggingService.catch("Error in HuddleService updateHuddleOnCursorMode:",e)}})}getAudioState(){try{let e=this.localStream$.value;if(e){let t=e?.getAudioTracks();return!!(t?.length?t[0]:null)?.enabled}return!1}catch(e){return this.loggingService.catch("Error in HuddleService getAudioState:",e),!1}}getVideoState(){try{let e=this.localStream$.value;if(e){let t=e?.getVideoTracks();return!!(t?.length?t[0]:null)?.enabled}return!1}catch(e){return this.loggingService.catch("Error in HuddleService getVideoState:",e),!1}}getScreenSharingState(){try{let e=this.screenSharingStream;if(e){let t=e?.getVideoTracks();return!!(t?.length?t[0]:null)?.enabled}return!1}catch(e){return this.loggingService.catch("Error in HuddleService getVideoState:",e),!1}}removeIceCandidates(e){return X(this,null,function*(){try{if(this.documentPaths?.huddle&&e){let t=yield this.commonDbService?.getData({feature:"allHuddleIceCandidates",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}});Object.keys(t).length>0&&Object.keys(t).forEach(i=>X(this,null,function*(){t[i].connectionId===e&&this.commonDbService.deleteData({feature:"huddleIceCandidate",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:i,skipFirestore:!0}})}))}}catch(t){this.loggingService.catch("Error in HuddleService dropCall:",t)}})}get timestamp(){return this.commonDbService.getServerTimestamp()}silence(){try{let e=new AudioContext,t=e.createOscillator(),i=t.connect(e.createMediaStreamDestination());return t.start(),Object.assign(i.stream.getAudioTracks()[0],{enabled:!1})}catch(e){this.loggingService.catch("Error in HuddleService silence:",e)}}black({width:e=640,height:t=480}={}){try{let i=Object.assign(document.createElement("canvas"),{width:e,height:t});i.getContext("2d")?.fillRect(0,0,e,t);let a=i.captureStream();return Object.assign(a.getVideoTracks()[0],{enabled:!1})}catch(i){this.loggingService.catch("Error in HuddleService black:",i)}}getInitialHuddleType(){try{return this.initialHuddleType}catch(e){return this.loggingService.catch("Error in HuddleService getInitialHuddleType:",e),null}}getHuddleAttendees$(){try{return this.attendees$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleAttendees$:",e),de([])}}getHuddleAttendees(){try{return this.attendees$.value}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleAttendees:",e),null}}getHuddleInvitees$(){try{return this.invitees$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleInvitees$:",e),de([])}}getHuddleInvitees(){try{return this.invitees$.value}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleInvitees:",e),null}}getHuddleStartTime(){try{return this.userHuddleStartTime$.value}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleStartTime:",e),null}}getTotalUserHuddleDuration(){try{return this.userHuddleStartTime$.value?new Date().getTime()-this.userHuddleStartTime$.value:null}catch(e){return this.loggingService.catch("Error in HuddleService gettotalUserHuddleDuration:",e),null}}inviteUsers(e){try{this.updateInvitees(e);let t={};t.notificationSource="huddleInvite",t.huddleInvitees=e,t.huddleType=this.getInitialHuddleType(),this.updateNotificationsDatabase(t)}catch(t){this.loggingService.catch("Error in HuddleService inviteUsers:",t)}}updateInvitees(e){try{if(this.documentPaths?.huddle){let t={};e.forEach(i=>{if(i?.email){let a=It(i.email);t[a]=i}}),this.commonDbService.setData({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0},data:t})}}catch(t){this.loggingService.catch("Error in HuddleService updateInvitees:",t)}}updateNotificationsDatabase(e={}){try{let t=h({notificationSource:"huddle"},e);this.notificationService.updateNotificationDatabase(t)}catch(t){this.loggingService.catch("Error in HuddleService updateNotificationsDatabase: ",t)}}getHuddleJoined$(){try{return this.huddleJoined$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleJoined$:",e),de(!1)}}getHuddleCursorAvailableByAttendeeId(){try{return this.huddleCursorAvailableByAttendeeId$.value}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleCursorAvailableByAttendeeId:",e),null}}getHuddleCursorAvailableByAttendeeId$(){try{return this.huddleCursorAvailableByAttendeeId$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleCursorAvailableByAttendeeId$:",e),de({})}}updateHuddleCursorAvailableByAttendeeId(e,t){try{let i=this.huddleCursorAvailableByAttendeeId$.value;i[e]=t,this.huddleCursorAvailableByAttendeeId$.next(i)}catch(i){this.loggingService.catch("Error in HuddleService updateCursorUserAvailableByUserId:",i)}}setRemoteStreamsByUserId(e){try{this.remoteStreamsByUserId$.next(e)}catch(t){this.loggingService.catch("Error in HuddleService setRemoteStreamsByUserId:",t)}}getRemoteStreamsByUserId$(){try{return this.remoteStreamsByUserId$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getRemoteStreamsByUserId$:",e),de({})}}enableHuddleOnCursorMode(){try{this.huddleOnCursorMode$.next(!0)}catch(e){this.loggingService.catch("Error in HuddleService enableHuddleOnCursorMode:",e)}}disableHuddleOnCursorMode(){try{this.huddleOnCursorMode$.next(!1)}catch(e){this.loggingService.catch("Error in HuddleService disableHuddleOnCursorMode:",e)}}getHuddleOnCursorMode$(){try{return this.huddleOnCursorMode$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleOnCursorMode$:",e),de(!1)}}enableFlockModeOnAvatarClick(){try{this.flockModeOnAvatarClickEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in HuddleService enableFlockModeOnAvatarClick:",e)}}disableFlockModeOnAvatarClick(){try{this.flockModeOnAvatarClickEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in HuddleService disableFlockModeOnAvatarClick:",e)}}getFlockModeOnAvatarClick$(){try{return this.flockModeOnAvatarClickEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getFlockModeOnAvatarClick$:",e),de(!1)}}getFlockModeOnAvatarClick(){try{return this.flockModeOnAvatarClickEnabled$.value}catch(e){return this.loggingService.catch("Error in HuddleService getFlockModeOnAvatarClick:",e),!1}}enableChat(){try{this.chatEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in HuddleService enableChat:",e)}}disableChat(){try{this.chatEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in HuddleService disableChat:",e)}}getChatEnabled$(){try{return this.chatEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getChatEnabled$:",e),de(!1)}}getChatEnabled(){try{return this.chatEnabled$.value}catch(e){return this.loggingService.catch("Error in HuddleService getChatEnabled:",e),!1}}enableServerFallback(){try{if(this.serverFallback$.value===!0)return;this.serverFallback$.next(!0)}catch(e){this.loggingService.catch("Error in HuddleService enableServerFallback:",e)}}disableServerFallback(){try{if(this.serverFallback$.value===!1)return;this.serverFallback$.next(!1)}catch(e){this.loggingService.catch("Error in HuddleService disableServerFallback:",e)}}getServerFallback$(){try{return this.serverFallback$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getServerFallback$:",e),de(!1)}}getServerFallback(){try{return this.serverFallback$.value}catch(e){return this.loggingService.catch("Error in HuddleService getServerFallback:",e),!1}}getHuddleOnCursorModeByAttendeeId$(){try{return this.huddleOnCursorModeByAttendeeId$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleOnCursorModeByAttendeeId$:",e),de({})}}toggleHuddleOnCursorModeByAttendeeId(e){try{let t=this.huddleOnCursorModeByAttendeeId$.value;t[e]?delete t[e]:t[e]=!0,this.huddleOnCursorModeByAttendeeId$.next(t)}catch(t){this.loggingService.catch("Error in HuddleService toggleHuddleOnCursorModeByAttendeeId:",t)}}addCursorTag(){try{if(!document.querySelector(`${F.TAGS.SNIPPYLY_CURSOR}`)){let e=document.createElement(F.TAGS.SNIPPYLY_CURSOR);e.setAttribute("snippyly-temporary","true"),document.body.appendChild(e)}}catch(e){this.loggingService.catch("Error in HuddleService addCursorTag:",e)}}removeCursorTag(){try{let e=document.querySelector(`${F.TAGS.SNIPPYLY_CURSOR}`);e?.hasAttribute("snippyly-temporary")&&e.remove()}catch(e){this.loggingService.catch("Error in HuddleService removeCursorTag:",e)}}sendMessage(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendMessage","color: green;"),this.documentPaths?.huddle&&this.user){let t=new AF;t.message=e,t.from=this.user,t.timestamp=this.timestamp,this.commonDbService.setData({feature:"huddleMessage",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:t.id,skipFirestore:!0},data:t})}}catch(t){this.loggingService.catch("Error in HuddleService sendMessage:",t)}}getMessages$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getMessages$","color: green;"),this.messages$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getMessages$:",e),de([])}}deleteMessages(){try{this.loggingService.log("%c[WB] Calling FUNCTION: deleteMessages","color: green;"),this.documentPaths?.huddle&&this.commonDbService.deleteData({feature:"allHuddleMessages",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}})}catch(e){this.loggingService.catch("Error in HuddleService deleteMessages:",e)}}showMessagesPanel(){try{this.loggingService.log("%c[WB] Calling FUNCTION: showMessagesPanel","color: green;"),this.messagesPanelVisible$.next(!0)}catch(e){this.loggingService.catch("Error in HuddleService showMessagesPanel:",e)}}hideMessagesPanel(){try{this.loggingService.log("%c[WB] Calling FUNCTION: hideMessagesPanel","color: green;"),this.messagesPanelVisible$.next(!1)}catch(e){this.loggingService.catch("Error in HuddleService hideMessagesPanel:",e)}}toggleMessagesPanel(){try{this.loggingService.log("%c[WB] Calling FUNCTION: toggleMessagesPanel","color: green;"),this.messagesPanelVisible$.next(!this.messagesPanelVisible$.value)}catch(e){this.loggingService.catch("Error in HuddleService toggleMessagesPanel:",e)}}getMessagesPanelVisible$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getMessagesPanelVisible$","color: green;"),this.messagesPanelVisible$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getMessagesPanelVisible$:",e),de(!1)}}getMessagesPanelVisible(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getMessagesPanelVisible","color: green;"),this.messagesPanelVisible$.value}catch(e){return this.loggingService.catch("Error in HuddleService getMessagesPanelVisible:",e),!1}}signOutUser(e){return X(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: signOutUser","color: green;"),this.huddleJoined$.value&&(yield this.dropCall(),yield this.removeLocalStream(),yield this.removeAttendee())}catch(t){this.loggingService.catch("Error in HuddleService signOutUser:",t)}})}};o.\u0275fac=function(t){return new(t||o)(Z(no),Z(ct),Z(Ke),Z(Hn),Z(st),Z(Lt),Z(Ve),Z(NU),Z(Oo),Z(k),Z(cn),Z(kn),Z(Mn))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var cV=class extends fr{constructor(o){super(o),this.getService(k).log("%c[WB] Creating CLASS: HuddleElement","color: blue;"),this.enableCursorMode=this._enableCursorMode,this.disableCursorMode=this._disableCursorMode,this.enableChat=this._enableChat,this.disableChat=this._disableChat,this.enableFlockModeOnAvatarClick=this._enableFlockModeOnAvatarClick,this.disableFlockModeOnAvatarClick=this._disableFlockModeOnAvatarClick}_enableCursorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: _enableCursorMode","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(sa).enableHuddleOnCursorMode()}catch(o){this.getService(k).catch("Error in enableCursorMode: ",o)}}_disableCursorMode(){this.getService(k).log("%c[WB] Calling FUNCTION: _disableCursorMode","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(sa).disableHuddleOnCursorMode()}catch(o){this.getService(k).catch("Error in disableCursorMode: ",o)}}_enableChat(){this.getService(k).log("%c[WB] Calling FUNCTION: _enableChat","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_CHAT_TRIGGERED),this.getService(sa).enableChat()}catch(o){this.getService(k).catch("Error in enableChat: ",o)}}_disableChat(){this.getService(k).log("%c[WB] Calling FUNCTION: _disableChat","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_CHAT_TRIGGERED),this.getService(sa).disableChat()}catch(o){this.getService(k).catch("Error in disableChat: ",o)}}_enableFlockModeOnAvatarClick(){this.getService(k).log("%c[WB] Calling FUNCTION: _enableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(sa).enableFlockModeOnAvatarClick()}catch(o){this.getService(k).catch("Error in enableFlockModeOnAvatarClick: ",o)}}_disableFlockModeOnAvatarClick(){this.getService(k).log("%c[WB] Calling FUNCTION: _disableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(sa).disableFlockModeOnAvatarClick()}catch(o){this.getService(k).catch("Error in disableFlockModeOnAvatarClick: ",o)}}};var sV=(()=>{let o=class o{constructor(e,t){this.analyticsService=e,this.loggingService=t,this.actionSubjects=new Map,this.subscriptions=[]}onAccessRequested(e){try{this.triggerAction(rp.ACCESS_REQUESTED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_ACCESS_REQUESTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRequested: ",t)}}onAccessRequestCanceled(e){try{this.triggerAction(rp.ACCESS_REQUEST_CANCELED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_ACCESS_REQUEST_CANCELED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRequestCanceled: ",t)}}onAccessAccepted(e){try{this.triggerAction(rp.ACCESS_ACCEPTED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_ACCESS_ACCEPTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessAccepted: ",t)}}onAccessRejected(e){try{this.triggerAction(rp.ACCESS_REJECTED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_ACCESS_REJECTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRejected: ",t)}}onEditorAssigned(e){try{this.triggerAction(rp.EDITOR_ASSIGNED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_EDITOR_ASSIGNED,{editorUserId:e?.editor?.userId,timestamp:e?.timestamp,role:e?.role,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onEditorAssigned: ",t)}}onEditorOnDifferentTabDetected(e){try{this.triggerAction(rp.EDITOR_ON_DIFFERENT_TAB_DETECTED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_EDITOR_ON_DIFFERENT_TAB_DETECTED,{editorUserId:e?.editor?.userId,timestamp:e?.timestamp,role:e?.role,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onEditorOnDifferentTabDetected: ",t)}}onViewerAssigned(e){try{this.triggerAction(rp.VIEWER_ASSIGNED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_VIEWER_ASSIGNED,{viewerUserId:e?.viewer?.userId,timestamp:e?.timestamp,role:e?.role,totalUsers:e?.totalUsers,isMultipleUsersDetected:(e?.totalUsers??0)>1,presenceSnippylyUserIds:e?.presenceSnippylyUserIds,presenceClientUserIds:e?.presenceClientUserIds})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onViewerAssigned: ",t)}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in LiveStateActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new it),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in LiveStateActionsService onAction: ",t),de(null)}}};o.\u0275fac=function(t){return new(t||o)(Z(ct),Z(k))},o.\u0275prov=Me({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var dV=(()=>{let o=class o{constructor(e,t,i,a,l,c,d,g,u){this.authService=e,this.commonDbService=t,this.databaseService=i,this.docService=a,this.domService=l,this.loggingService=c,this.metadataService=d,this.commonDbUtils=g,this.configService=u,this.HEARTBEAT_DURATION=5*1e3,this.heartbeatEnabled$=new Se(!1),this.subscriptions=[],this.heartbeatCreatedTimestamps=new Map,this.initializedHeartbeatIds=new Set;try{this.loggingService.log("%c[WB] Creating CLASS: HeartbeatService","color: blue;"),this.heartbeatEnabled$.pipe(bt()).subscribe(_=>{_?this.setupHeartbeat():this.teardownHeartbeat()}),this.docService.addPreDocumentIdChangeFunction("heartbeat-service",_=>_?.documentId?this.removeDocumentHeartbeat(_):Promise.resolve())}catch(_){this.loggingService.catch("Error in HeartbeatService constructor: ",_)}}setupWebWorker(e){try{let t=`
|
|
503
503
|
let intervalId;
|
|
504
504
|
self.addEventListener('message', (event) => {
|