@veltdev/sdk 4.7.1-beta.7 → 4.7.1-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/velt.js +2 -2
package/velt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var SNIPPYLY_VERSION = '4.7.1-
|
|
1
|
+
var SNIPPYLY_VERSION = '4.7.1-patch.1';
|
|
2
2
|
(function(c,E){"use strict";function U(){var e=X.splice(0,X.length);for(ue=0;e.length;)e.shift().call(null,e.shift())}function fe(e,t){for(var n=0,r=e.length;n<r;n++)Le(e[n],t)}function ot(e){for(var t,n=0,r=e.length;n<r;n++)t=e[n],_(t,B[pe(t)])}function de(e){return function(t){Lt(t)&&(Le(t,e),L.length&&fe(t.querySelectorAll(L),e))}}function pe(e){var t=ae.call(e,"is"),n=e.nodeName.toUpperCase(),r=H.call(D,t?J+t.toUpperCase():q+n);return t&&-1<r&&!Ie(n,t)?-1:r}function Ie(e,t){return-1<L.indexOf(e+'[is="'+t+'"]')}function Fe(e){var t=e.currentTarget,n=e.attrChange,r=e.attrName,o=e.target,l=e[Y]||2,a=e[ge]||3;!se||o&&o!==t||!t[C]||r==="style"||e.prevValue===e.newValue&&(e.newValue!==""||n!==l&&n!==a)||t[C](r,n===l?null:e.prevValue,n===a?null:e.newValue)}function Se(e){var t=de(e);return function(n){X.push(t,n.target),ue&&clearTimeout(ue),ue=setTimeout(U,1)}}function he(e){rt&&(rt=!1,e.currentTarget.removeEventListener(Ze,he)),L.length&&fe((e.target||u).querySelectorAll(L),e.detail===v?v:y),R&&at()}function lt(e,t){var n=this;Je.call(n,e,t),Ee.call(n,{target:n})}function Pe(e,t,n){var r=t.apply(e,n),o=pe(r);return-1<o&&_(r,B[o]),n.pop()&&L.length&&ot(r.querySelectorAll(L)),r}function Te(e,t){Tt(e,t),Q?Q.observe(e,gt):(ce&&(e.setAttribute=lt,e[g]=ve(e),e[b](st,Ee)),e[b](N,Fe)),e[x]&&se&&(e.created=!0,e[x](),e.created=!1)}function at(){for(var e,t=0,n=z.length;t<n;t++)e=z[t],P.contains(e)||(n--,z.splice(t--,1),Le(e,v))}function Ve(e){throw new Error("A "+e+" type is already registered")}function Le(e,t){var n,r,o=pe(e);-1<o&&!Mt.call(e,"TEMPLATE")&&(W(e,B[o]),o=0,t!==y||e[y]?t!==v||e[v]||(e[y]=!1,e[v]=!0,r="disconnected",o=1):(e[v]=!1,e[y]=!0,r="connected",o=1,R&&H.call(z,e)<0&&z.push(e)),o&&(n=e[t+O]||e[r+O])&&n.call(e))}function K(){}function Re(e,t,n){var r=n&&n[k]||"",o=t.prototype,l=we(o),a=t.observedAttributes||Ce,m={prototype:l};le(l,x,{value:function(){if(ne)ne=!1;else if(!this[j]){this[j]=!0,new t(this),o[x]&&o[x].call(this);var i=G[re.get(t)];(!Z||i.create.length>1)&&ke(this)}}}),le(l,C,{value:function(i){-1<H.call(a,i)&&o[C]&&o[C].apply(this,arguments)}}),o[Be]&&le(l,ut,{value:o[Be]}),o[je]&&le(l,ct,{value:o[je]}),r&&(m[k]=r),e=e.toUpperCase(),G[e]={constructor:t,create:r?[r,oe(e)]:[e]},re.set(t,e),u[S](e.toLowerCase(),m),Me(e),V[e].r()}function Ue(e){var t=G[e.toUpperCase()];return t&&t.constructor}function _e(e){return typeof e=="string"?e:e&&e.is||""}function ke(e){for(var t,n=e[C],r=n?e.attributes:Ce,o=r.length;o--;)t=r[o],n.call(e,t.name||t.nodeName,null,t.value||t.nodeValue)}function Me(e){return e=e.toUpperCase(),e in V||(V[e]={},V[e].p=new $e(function(t){V[e].r=t})),V[e].p}function xe(){w&&delete c.customElements,I(c,"customElements",{configurable:!0,value:new K}),I(c,"CustomElementRegistry",{configurable:!0,value:K});for(var e=it.get(/^HTML[A-Z]*[a-z]/),t=e.length;t--;(function(n){var r=c[n];if(r){c[n]=function(o){var l,a;return o||(o=this),o[j]||(ne=!0,l=G[re.get(o.constructor)],a=Z&&l.create.length===1,o=a?Reflect.construct(r,Ce,l.constructor):u.createElement.apply(u,l.create),o[j]=!0,ne=!1,a||ke(o)),o},c[n].prototype=r.prototype;try{r.prototype.constructor=c[n]}catch{pt=!0,I(r,j,{value:c[n]})}}})(e[t]));u.createElement=function(n,r){var o=_e(r);return o?Oe.call(this,n,oe(o)):Oe.call(this,n)},tt||(Ne=!0,u[S](""))}var u=c.document,T=c.Object,it=(function(e){var t,n,r,o,l=/^[A-Z]+[a-z]/,a=function(d){var f,h=[];for(f in i)d.test(f)&&h.push(f);return h},m=function(d,f){(f=f.toLowerCase())in i||(i[d]=(i[d]||[]).concat(f),i[f]=i[f.toUpperCase()]=d)},i=(T.create||T)(null),s={};for(n in e)for(o in e[n])for(r=e[n][o],i[o]=r,t=0;t<r.length;t++)i[r[t].toLowerCase()]=i[r[t].toUpperCase()]=o;return s.get=function(d){return typeof d=="string"?i[d]||(l.test(d)?[]:""):a(d)},s.set=function(d,f){return l.test(d)?m(d,f):m(f,d),s},s})({collections:{HTMLAllCollection:["all"],HTMLCollection:["forms"],HTMLFormControlsCollection:["elements"],HTMLOptionsCollection:["options"]},elements:{Element:["element"],HTMLAnchorElement:["a"],HTMLAppletElement:["applet"],HTMLAreaElement:["area"],HTMLAttachmentElement:["attachment"],HTMLAudioElement:["audio"],HTMLBRElement:["br"],HTMLBaseElement:["base"],HTMLBodyElement:["body"],HTMLButtonElement:["button"],HTMLCanvasElement:["canvas"],HTMLContentElement:["content"],HTMLDListElement:["dl"],HTMLDataElement:["data"],HTMLDataListElement:["datalist"],HTMLDetailsElement:["details"],HTMLDialogElement:["dialog"],HTMLDirectoryElement:["dir"],HTMLDivElement:["div"],HTMLDocument:["document"],HTMLElement:["element","abbr","address","article","aside","b","bdi","bdo","cite","code","command","dd","dfn","dt","em","figcaption","figure","footer","header","i","kbd","mark","nav","noscript","rp","rt","ruby","s","samp","section","small","strong","sub","summary","sup","u","var","wbr"],HTMLEmbedElement:["embed"],HTMLFieldSetElement:["fieldset"],HTMLFontElement:["font"],HTMLFormElement:["form"],HTMLFrameElement:["frame"],HTMLFrameSetElement:["frameset"],HTMLHRElement:["hr"],HTMLHeadElement:["head"],HTMLHeadingElement:["h1","h2","h3","h4","h5","h6"],HTMLHtmlElement:["html"],HTMLIFrameElement:["iframe"],HTMLImageElement:["img"],HTMLInputElement:["input"],HTMLKeygenElement:["keygen"],HTMLLIElement:["li"],HTMLLabelElement:["label"],HTMLLegendElement:["legend"],HTMLLinkElement:["link"],HTMLMapElement:["map"],HTMLMarqueeElement:["marquee"],HTMLMediaElement:["media"],HTMLMenuElement:["menu"],HTMLMenuItemElement:["menuitem"],HTMLMetaElement:["meta"],HTMLMeterElement:["meter"],HTMLModElement:["del","ins"],HTMLOListElement:["ol"],HTMLObjectElement:["object"],HTMLOptGroupElement:["optgroup"],HTMLOptionElement:["option"],HTMLOutputElement:["output"],HTMLParagraphElement:["p"],HTMLParamElement:["param"],HTMLPictureElement:["picture"],HTMLPreElement:["pre"],HTMLProgressElement:["progress"],HTMLQuoteElement:["blockquote","q","quote"],HTMLScriptElement:["script"],HTMLSelectElement:["select"],HTMLShadowElement:["shadow"],HTMLSlotElement:["slot"],HTMLSourceElement:["source"],HTMLSpanElement:["span"],HTMLStyleElement:["style"],HTMLTableCaptionElement:["caption"],HTMLTableCellElement:["td","th"],HTMLTableColElement:["col","colgroup"],HTMLTableElement:["table"],HTMLTableRowElement:["tr"],HTMLTableSectionElement:["thead","tbody","tfoot"],HTMLTemplateElement:["template"],HTMLTextAreaElement:["textarea"],HTMLTimeElement:["time"],HTMLTitleElement:["title"],HTMLTrackElement:["track"],HTMLUListElement:["ul"],HTMLUnknownElement:["unknown","vhgroupv","vkeygen"],HTMLVideoElement:["video"]},nodes:{Attr:["node"],Audio:["audio"],CDATASection:["node"],CharacterData:["node"],Comment:["#comment"],Document:["#document"],DocumentFragment:["#document-fragment"],DocumentType:["node"],HTMLDocument:["#document"],Image:["img"],Option:["option"],ProcessingInstruction:["node"],ShadowRoot:["#shadow-root"],Text:["#text"],XMLDocument:["xml"]}});typeof E!="object"&&(E={type:E||"auto"});var X,Ee,$,ve,Q,He,W,_,A,S="registerElement",qe=1e5*c.Math.random()>>0,g="__"+S+qe,b="addEventListener",y="attached",O="Callback",v="detached",k="extends",C="attributeChanged"+O,ut=y+O,Be="connected"+O,je="disconnected"+O,x="created"+O,ct=v+O,Y="ADDITION",ge="REMOVAL",N="DOMAttrModified",Ze="DOMContentLoaded",st="DOMSubtreeModified",q="<",J="=",mt=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,ft=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],D=[],B=[],L="",P=u.documentElement,H=D.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},be=T.prototype,ye=be.hasOwnProperty,ee=be.isPrototypeOf,I=T.defineProperty,Ce=[],te=T.getOwnPropertyDescriptor,Ge=T.getOwnPropertyNames,dt=T.getPrototypeOf,ze=T.setPrototypeOf,Ke=!!T.__proto__,pt=!1,j="__dreCEv1",w=c.customElements,Z=!/^force/.test(E.type)&&!!(w&&w.define&&w.get&&w.whenDefined),Xe=T.create||T,ht=c.Map||function(){var e,t=[],n=[];return{get:function(r){return n[H.call(t,r)]},set:function(r,o){e=H.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},$e=c.Promise||function(e){function t(l){for(r=!0;n.length;)n.shift()(l)}var n=[],r=!1,o={catch:function(){return o},then:function(l){return n.push(l),r&&setTimeout(t,1),o}};return e(t),o},ne=!1,G=Xe(null),V=Xe(null),re=new ht,oe=function(e){return e.toLowerCase()},we=T.create||function e(t){return t?(e.prototype=t,new e):this},Tt=ze||(Ke?function(e,t){return e.__proto__=t,e}:Ge&&te?(function(){function e(t,n){for(var r,o=Ge(n),l=0,a=o.length;l<a;l++)r=o[l],ye.call(t,r)||I(t,r,te(n,r))}return function(t,n){do e(t,n);while((n=dt(n))&&!ee.call(n,t));return t}})():function(e,t){for(var n in t)e[n]=t[n];return e}),F=c.MutationObserver||c.WebKitMutationObserver,Qe=c.HTMLAnchorElement,p=(c.HTMLElement||c.Element||c.Node).prototype,R=!ee.call(p,P),le=R?function(e,t,n){return e[t]=n.value,e}:I,Lt=R?function(e){return e.nodeType===1}:function(e){return ee.call(p,e)},z=R&&[],We=p.attachShadow,Ye=p.cloneNode,Mt=p.closest||function(e){for(var t=this;t&&t.nodeName!==e;)t=t.parentNode;return t},Ae=p.dispatchEvent,ae=p.getAttribute,Et=p.hasAttribute,vt=p.removeAttribute,Je=p.setAttribute,ie=u.createElement,Ht=u.importNode,Oe=ie,gt=F&&{attributes:!0,characterData:!0,attributeOldValue:!0},et=F||function(e){ce=!1,P.removeEventListener(N,et)},ue=0,tt=S in u&&!/^force-all/.test(E.type),nt=!0,Ne=!1,ce=!0,rt=!0,se=!0;if(F&&(A=u.createElement("div"),A.innerHTML="<div><div></div></div>",new F(function(e,t){if(e[0]&&e[0].type=="childList"&&!e[0].removedNodes[0].childNodes.length){A=te(p,"innerHTML");var n=A&&A.set;n&&I(p,"innerHTML",{set:function(r){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,r)}})}t.disconnect(),A=null}).observe(A,{childList:!0,subtree:!0}),A.innerHTML=""),tt||(ze||Ke?(W=function(e,t){ee.call(t,e)||Te(e,t)},_=Te):(W=function(e,t){e[g]||(e[g]=T(!0),Te(e,t))},_=W),R?(ce=!1,(function(){var e=te(p,b),t=e.value,n=function(l){var a=new CustomEvent(N,{bubbles:!0});a.attrName=l,a.prevValue=ae.call(this,l),a.newValue=null,a[ge]=a.attrChange=2,vt.call(this,l),Ae.call(this,a)},r=function(l,a){var m=Et.call(this,l),i=m&&ae.call(this,l),s=new CustomEvent(N,{bubbles:!0});Je.call(this,l,a),s.attrName=l,s.prevValue=m?i:null,s.newValue=a,m?s.MODIFICATION=s.attrChange=1:s[Y]=s.attrChange=0,Ae.call(this,s)},o=function(l){var a,m=l.currentTarget,i=m[g],s=l.propertyName;i.hasOwnProperty(s)&&(i=i[s],a=new CustomEvent(N,{bubbles:!0}),a.attrName=i.name,a.prevValue=i.value||null,a.newValue=i.value=m[s]||null,a.prevValue==null?a[Y]=a.attrChange=0:a.MODIFICATION=a.attrChange=1,Ae.call(m,a))};e.value=function(l,a,m){l===N&&this[C]&&this.setAttribute!==r&&(this[g]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,l,a,m)},I(p,b,e)})()):F||(P[b](N,et),P.setAttribute(g,1),P.removeAttribute(g),ce&&(Ee=function(e){var t,n,r,o=this;if(o===e.target){t=o[g],o[g]=n=ve(o);for(r in n){if(!(r in t))return $(0,o,r,t[r],n[r],Y);if(n[r]!==t[r])return $(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return $(2,o,r,t[r],n[r],ge)}},$=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,Fe(a)},ve=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l<a;l++)t=o[l],(n=t.name)!=="setAttribute"&&(r[n]=t.value);return r})),u[S]=function(e,t){if(n=e.toUpperCase(),nt&&(nt=!1,F?(Q=(function(i,s){function d(f,h){for(var M=0,me=f.length;M<me;h(f[M++]));}return new F(function(f){for(var h,M,me,De=0,bt=f.length;De<bt;De++)h=f[De],h.type==="childList"?(d(h.addedNodes,i),d(h.removedNodes,s)):(M=h.target,se&&M[C]&&h.attributeName!=="style"&&(me=ae.call(M,h.attributeName))!==h.oldValue&&M[C](h.attributeName,h.oldValue,me))})})(de(y),de(v)),He=function(i){return Q.observe(i,{childList:!0,subtree:!0}),i},He(u),We&&(p.attachShadow=function(){return He(We.apply(this,arguments))})):(X=[],u[b]("DOMNodeInserted",Se(y)),u[b]("DOMNodeRemoved",Se(v))),u[b](Ze,he),u[b]("readystatechange",he),u.importNode=function(i,s){switch(i.nodeType){case 1:return Pe(u,Ht,[i,!!s]);case 11:for(var d=u.createDocumentFragment(),f=i.childNodes,h=f.length,M=0;M<h;M++)d.appendChild(u.importNode(f[M],!!s));return d;default:return Ye.call(i,!!s)}},p.cloneNode=function(i){return Pe(this,Ye,[!!i])}),Ne)return Ne=!1;if(-2<H.call(D,J+n)+H.call(D,q+n)&&Ve(e),!mt.test(n)||-1<H.call(ft,n))throw new Error("The type "+e+" is invalid");var n,r,o=function(){return a?u.createElement(m,n):u.createElement(m)},l=t||be,a=ye.call(l,k),m=a?t[k].toUpperCase():n;return a&&-1<H.call(D,q+m)&&Ve(m),r=D.push((a?J:q)+n)-1,L=L.concat(L.length?",":"",a?m+'[is="'+e.toLowerCase()+'"]':m),o.prototype=B[r]=ye.call(l,"prototype")?l.prototype:we(p),L.length&&fe(u.querySelectorAll(L),y),o},u.createElement=Oe=function(e,t){var n=_e(t),r=n?ie.call(u,e,oe(n)):ie.call(u,e),o=""+e,l=H.call(D,(n?J:q)+(n||o).toUpperCase()),a=-1<l;return n&&(r.setAttribute("is",n=n.toLowerCase()),a&&(a=Ie(o.toUpperCase(),n))),se=!u.createElement.innerHTMLHelper,a&&_(r,B[l]),r}),addEventListener("beforeunload",function(){delete u.createElement,delete u.importNode,delete u[S]},!1),K.prototype={constructor:K,define:Z?function(e,t,n){if(n)Re(e,t,n);else{var r=e.toUpperCase();G[r]={constructor:t,create:[r]},re.set(t,r),w.define(e,t)}}:Re,get:Z?function(e){return w.get(e)||Ue(e)}:Ue,whenDefined:Z?function(e){return $e.race([w.whenDefined(e),Me(e)])}:Me},!w||/^force/.test(E.type))xe();else if(!E.noBuiltIn)try{(function(e,t,n){var r=new RegExp(`^<a\\s+is=('|")`+n+"\\1></a>$");if(t[k]="a",e.prototype=we(Qe.prototype),e.prototype.constructor=e,c.customElements.define(n,e,t),!r.test(u.createElement("a",{is:n}).outerHTML)||!r.test(new e().outerHTML))throw t})(function e(){return Reflect.construct(Qe,[],e)},{},"document-register-element-a"+qe)}catch{xe()}if(!E.noBuiltIn)try{if(ie.call(u,"a","a").outerHTML.indexOf("is")<0)throw{}}catch{oe=function(t){return{is:t.toLowerCase()}}}})(window);Promise.allSettled||(Promise.allSettled=function(c){return Promise.all(c.map(function(E){return Promise.resolve(E).then(function(U){return{status:"fulfilled",value:U}}).catch(function(U){return{status:"rejected",reason:U}})}))});
|
|
3
3
|
|
|
4
4
|
var ZSe=Object.create;var d4=Object.defineProperty,XSe=Object.defineProperties,QSe=Object.getOwnPropertyDescriptor,JSe=Object.getOwnPropertyDescriptors,ebe=Object.getOwnPropertyNames,c4=Object.getOwnPropertySymbols,mK=Object.getPrototypeOf,k8=Object.prototype.hasOwnProperty,pK=Object.prototype.propertyIsEnumerable,tbe=Reflect.get;var dK=(i,o,n)=>o in i?d4(i,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[o]=n,E=(i,o)=>{for(var n in o||={})k8.call(o,n)&&dK(i,n,o[n]);if(c4)for(var n of c4(o))pK.call(o,n)&&dK(i,n,o[n]);return i},D=(i,o)=>XSe(i,JSe(o));var ju=(i,o)=>{var n={};for(var e in i)k8.call(i,e)&&o.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&c4)for(var e of c4(i))o.indexOf(e)<0&&pK.call(i,e)&&(n[e]=i[e]);return n};var nbe=(i,o)=>()=>(o||i((o={exports:{}}).exports,o),o.exports),m4=(i,o)=>{for(var n in o)d4(i,n,{get:o[n],enumerable:!0})},ibe=(i,o,n,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of ebe(o))!k8.call(i,t)&&t!==n&&d4(i,t,{get:()=>o[t],enumerable:!(e=QSe(o,t))||e.enumerable});return i};var gK=(i,o,n)=>(n=i!=null?ZSe(mK(i)):{},ibe(o||!i||!i.__esModule?d4(n,"default",{value:i,enumerable:!0}):n,i));var $p=(i,o,n)=>tbe(mK(i),n,o);var Q=(i,o,n)=>new Promise((e,t)=>{var r=c=>{try{s(n.next(c))}catch(p){t(p)}},a=c=>{try{s(n.throw(c))}catch(p){t(p)}},s=c=>c.done?e(c.value):Promise.resolve(c.value).then(r,a);s((n=n.apply(i,o)).next())});var AY=nbe((KOo,OY)=>{"use strict";var Ot={};Ot.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};Ot.localCName=Ot.generateIdentifier();Ot.splitLines=function(i){return i.trim().split(`
|
|
@@ -482,7 +482,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
482
482
|
<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"/>
|
|
483
483
|
</svg>
|
|
484
484
|
`;break}s.innerHTML=c.trim();let p=s.firstElementChild;return p&&a.appendChild(p),a.addEventListener("click",r),a.__cleanup=()=>{a.removeEventListener("click",r)},a}exitPictureInPicture(){return Q(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 Q(this,null,function*(){try{this.isPipActive$.value||this.pipWindow||document.pictureInPictureElement?yield this.exitPictureInPicture():yield this.openPictureInPicture(e,t)}catch(r){this.loggingService.catch("Error in PipService togglePictureInPicture:",r),this.isPipActive$.next(!1),this.pipWindow=void 0}})}findVideoElement(){return Q(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 r of e){let a=document.querySelector(r);if(a&&a.srcObject)return a}let t=Array.from(document.querySelectorAll("video"));for(let r of t)if(r.srcObject)return r;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 Yn;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)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var bn=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.analyticsService=e,this.loggingService=t,this.matDialog=r,this.storageService=a,this.docService=s,this.databaseService=c,this.domService=p,this.pipService=g,this.recorderStatusSubject$=new Ce(null),this.recorderDurationSubject$=new Ce(null),this.darkMode$=new Ce(null),this.shadowDom$=new Ce(null),this.recordingDurations=[],this.chunks=[],this.recordingCountdownEnabled$=new Ce(!0),this.recorderInitData$=new Qe,this.recordedRawData$=new Qe,this.recordedData$=new Qe,this.onInitRecording$=new Ce(null),this.onRecordingAttributeRemovedFromBodySubject$=new Qe,this.videoEditor$=new Ce(!1),this.videoEditorTimelinePreview$=new Ce(!1),this.settingsEmbedded$=new Ce(!1),this.autoOpenVideoEditor$=new Ce(!1),this.playVideoInFullScreen$=new Ce(void 0),this.recordedDataStream=[],this.documentPaths=null,this.uploadPromises=[],this.chunkUrls$=new Ce({}),this.recordingQualityConstraints=new Ce({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 Ce({safari:{videoBitsPerSecond:25e5,audioBitsPerSecond:128e3},other:{videoBitsPerSecond:1e6,audioBitsPerSecond:128e3}}),this.recordingMicEnabled$=new Ce(null),this.onboardingTooltip$=new Ce(!1),this.audioContext=null,this.audioDestination=null,this.activeInputTracks=new Set,this.retakeOnVideoEditor$=new Ce(!1),this.maxRecordingLength=null,this.screenStreamSubject$=new Ce(null),this.playbackOnPreviewClick$=new Ce(!0),this.onInitRecording$.subscribe(f=>{f?this.setRecordingAttributeAtBody():this.removeRecordingAttributeFromBody()}),this.pipService.getPipPauseRecordingTriggered$().subscribe(f=>{f&&(this.recorderStatusSubject$.value==="started"||this.recorderStatusSubject$.value==="resumed"?this.pauseRecording():this.recorderStatusSubject$.value==="paused"&&this.resumeRecording(),this.pipService.resetPipPauseRecordingTriggered())}),this.databaseService.getDb().pipe(Le(f=>!!f),rt(1)).subscribe(f=>{f&&this.getDocumentPaths()},f=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",f)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(Qt(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(U.ATTRIBUTES.VELT_ONGOING_RECORDING,e.type),e?.isCommentRecording&&document.body.setAttribute(U.ATTRIBUTES.VELT_COMMENT_RECORDING,"true"))}catch(e){this.loggingService.catch("Error in RecorderService setRecordingAttributeAtBody: ",e)}}removeRecordingAttributeFromBody(){try{document.body.removeAttribute(U.ATTRIBUTES.VELT_ONGOING_RECORDING),document.body.removeAttribute(U.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,r,a,s,c,p,g,f){return Q(this,null,function*(){try{let I={};switch(e){case"audio":I.audio={enabled:!0};break;case"video":I.video={enabled:!0},I.audio={enabled:!0};break;case"screen":I.screen={enabled:!0,stream:f},I.video={enabled:!1},I.audio={enabled:!1};break;default:break}f&&e==="screen"&&(I.screen={enabled:!0,stream:f}),this.matDialog.open(A9,{panelClass:"velt-mat-dialog-container",data:{type:e,mediaConfig:I,darkMode:[!0,!1].includes(a)?a:this.darkMode$.value,shadowDom:s,recordingCountdown:g}}).afterClosed().subscribe(x=>{if(x){let B={};switch(e){case"audio":B.audio={enabled:!0,deviceId:x.audio?.deviceId},B.audio=x.audio;break;case"video":B.video={enabled:!0,deviceId:x.video?.deviceId},B.audio={enabled:!0,deviceId:x.audio?.deviceId},B.video=x.video,B.audio=x.audio;break;case"screen":B.screen={enabled:!0},B.audio=x.audio,B.video=x.video,B.screen=x.screen;break;default:break}this.onInitRecording$.next({type:e,panelId:t,mediaConfig:B,isCommentRecording:r,darkMode:[!0,!1].includes(a)?a:!!this.darkMode$.value,shadowDom:s,commentAnnotationId:c,clientDocumentId:p})}},x=>{this.loggingService.catch("Error in RecorderService initRecording afterClosed: ",x)})}catch(I){this.loggingService.catch("Error in RecorderService initRecording: ",I)}})}startRecording(e,t){return Q(this,null,function*(){try{this.loggingService.log("[startRecording] Starting with config:",e,"mediaConfig:",t);let r=new MediaStream,a=yield this.getBrowserSpecificOptions();return yield this.collectMediaTracks(r,e,t),yield this.initializeMediaRecorder(r,a,e),this.setupRecorderData(e,r),r}catch(r){return this.loggingService.catch("Error in RecorderService startRecording: ",r),Promise.reject(r)}})}getBrowserSpecificOptions(){return Q(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(s=>s.includes("mp4")&&s.includes("h264"))||t.find(s=>s.includes("mp4"))||t[0];e.mimeType=a}return new Yn().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,r){return Q(this,null,function*(){try{let a=[],s=[];if(t.type.screen&&r?.screen?.stream){let c=this.getCommonVideoQualityConstraints(!0);r.screen.stream.getTracks().forEach(p=>{p.onended=()=>this.stopRecording(),p.kind==="video"?(p.applyConstraints(E({},c)),s.push(p),this.loggingService.log("[collectMediaTracks] Added screen video track"),this.registerActiveTrack(p)):p.kind==="audio"&&(a.push(p),this.loggingService.log("[collectMediaTracks] Collected tab audio track for mixing"),this.registerActiveTrack(p))})}if(t?.type.audio||t?.type.video)if(this.isFirefox()&&t.type.screen&&(r?.audio?.stream||r?.video?.stream))t.type.audio&&r?.audio?.stream&&r.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&&r?.video?.stream&&r.video.stream.getVideoTracks().forEach(g=>{s.push(g),this.loggingService.log("[collectMediaTracks] Added user video track (Firefox)"),this.registerActiveTrack(g)});else{let p=this.buildMediaConstraints(t,r),g=yield navigator.mediaDevices.getUserMedia(p);if(g){if(t?.type.audio){let f=g.getAudioTracks();if(f.length>0)if(this.isSafari()){let I=f[0];if(I.getSettings().sampleRate!==48e3){this.loggingService.log("[collectMediaTracks] Adjusting audio sample rate for Safari");let z=(yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:48e3}})).getAudioTracks()[0];a.push(z),this.registerActiveTrack(z),I.stop()}else a.push(I),this.registerActiveTrack(I)}else f.forEach(I=>{a.push(I),this.loggingService.log("[collectMediaTracks] Collected mic audio track for mixing"),this.registerActiveTrack(I)})}if(t?.type.video){let f=g.getVideoTracks();if(f.length>0)if(this.isSafari()){let I=f[0];I.enabled=!0;let x=I.clone();s.push(x),this.loggingService.log("[collectMediaTracks] Added user video track (Safari, cloned)"),r&&r.video&&(r.video.track=I),this.registerActiveTrack(I)}else f.forEach(I=>{s.push(I),this.loggingService.log("[collectMediaTracks] Added user video track"),this.registerActiveTrack(I)})}}}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]))}s.forEach(c=>{e.addTrack(c)}),this.loggingService.log(`[collectMediaTracks] Added ${s.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 r=this.getCommonVideoQualityConstraints(!!e.type.video);return{audio:this.getCommonAudioConstraints(!!e.type.audio,t),video:e.type.video?D(E({deviceId:t?.video?.deviceId?{ideal:t.video.deviceId}:void 0},r),{facingMode:"user"}):!1}}catch(r){return this.loggingService.catch("Error in RecorderService buildMediaConstraints: ",r),{}}}getCommonAudioConstraints(e,t){try{if(!e)return!1;let r=this.recordingQualityConstraints.value[this.isSafari()?"safari":"other"]?.audio||{};return E({deviceId:t?.audio?.deviceId?{ideal:t.audio.deviceId}:void 0},r)}catch(r){return this.loggingService.catch("Error in RecorderService getCommonAudioConstraints: ",r),{}}}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 Q(this,null,function*(){try{let r=t.getAudioTracks()[0];if(r.getSettings().sampleRate!==48e3){this.loggingService.log("[startRecording] Adjusting audio sample rate for Safari");let s=yield navigator.mediaDevices.getUserMedia({audio:{sampleRate:48e3}});e.addTrack(s.getAudioTracks()[0])}else e.addTrack(r)}catch(r){this.loggingService.catch("Error in RecorderService adjustSafariAudioTrack: ",r);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 Q(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 s=new MediaStream([a]),c=this.audioContext.createMediaStreamSource(s),p=this.audioContext.createGain();p.gain.value=1,c.connect(p),p.connect(t),this.loggingService.log(`[mixAudioTracks] Connected audio track: ${a.label||"unlabeled"}`)}catch(s){this.loggingService.catch(`[mixAudioTracks] Error connecting track ${a.label}:`,s)}let r=this.audioDestination.stream.getAudioTracks();return r.length>0?(this.loggingService.log("[mixAudioTracks] Successfully created mixed audio track"),r[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,r){return Q(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(f=>{f.contentHint="detail",f.enabled=!0})}let c=new Yn().getBrowserName()==="Firefox";c&&e.getTracks().forEach(g=>{g.enabled=!0}),this.mediaRecorder.addEventListener("dataavailable",g=>{if(g.data?.size>0){let f=a++;this.chunks.push(g.data);let I=`recording_${new Date().getTime()}_${Math.random().toString(36).substring(2,9)}`,x=g.data,B=this.uploadChunk(x,I,f);this.uploadPromises||(this.uploadPromises=[]),this.uploadPromises.push({promise:B,index:f}),B.then(z=>{this.chunkUrls$.next(D(E({},this.chunkUrls$.value),{[f]:z}))}).catch(z=>{})}}),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 p=4e3;c&&r.type.screen&&(p=void 0),p?this.mediaRecorder.start(p):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,r){return Q(this,null,function*(){try{let s=this.mediaRecorder.mimeType||"video/mp4",c=s.includes("webm")?"webm":"mp4",p=`chunk_${r}_${new Date().getTime()}.${c}`,g=new File([e],p,{type:s});return yield this.uploadChunkToStorage(g,t,r)}catch(a){throw a}})}uploadChunkToStorage(e,t,r){try{if(!this.documentPaths?.documentId)throw new Error("Document ID is required for chunk upload");let a=this.documentPaths?.organizationId,s=this.documentPaths?.documentId,c=`${U.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/${t}`;return a&&(c=`${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${a}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/${t}`),this.storageService.uploadChunk(c,e,r)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunkToStorage: ",a),a}}setupRecorderData(e,t){try{return this.recorderInitData=new p9,this.recorderStatusSubject$.next("started"),this.isSafari()&&e.type.video&&t.getVideoTracks().forEach(r=>{r.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(r){return this.loggingService.catch("Error in RecorderService setupRecorderData: ",r),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 Q(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(r=>{r.stop()}),this.stopAllActiveInputTracks(),this.cleanupAudioMixing(),yield this.timeout(100);let t=new UI;if(this.chunks.length>0){let r=this.recorderInitData?.type==="audio"?"audio/mp4":"video/mp4";this.loggingService.log("[onStopRecording] Creating blob with type:",r),t.blob=new Blob(this.chunks,{type:r}),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 s={};s.duration=a*1e3,s.display=this.convertMillisecondsToTime(a*1e3),this.recorderDurationSubject$.next(s),t.recordedTime=s}else{let s=this.recorderDurationSubject$.value;t.recordedTime=s}}catch(a){let s=this.recorderDurationSubject$.value;t.recordedTime=s,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 nce(t.blob,3);a&&(t.thumbnail=yield ice(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 Q(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(r=>{r?.readyState!=="ended"&&r.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(r=>{r.end?e+=r?.end-r.start:e+=new Date().getTime()-r.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(r=>{r.end?e+=r?.end-r.start:e+=new Date().getTime()-r.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),r=Math.floor(t/60),a=Math.floor(r/60);return t=t%60,r=r%60,`${a.toString().padStart(2,"0")}:${r.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 Yn().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(r=>MediaRecorder.isTypeSupported(r))}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 Q(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}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:E(E({},t.other?.audio),e.other?.audio),video:E(E({},t.other?.video),e.other?.video)},safari:{audio:E(E({},t.safari?.audio),e.safari?.audio),video:E(E({},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:E(E({},t.other),e.other),safari:E(E({},t.safari),e.safari)},this.recordingEncodingOptions.next(t)}catch(t){this.loggingService.catch("Error in RecorderService setRecordingEncodingOptions: ",t)}}getVideoDuration(e){return Q(this,null,function*(){return new Promise((t,r)=>{try{let a=URL.createObjectURL(e),s=document.createElement("video"),c=navigator.userAgent.includes("Firefox");c&&(s.preload="auto"),s.onloadedmetadata=()=>{let p=s.duration;c&&p>0&&p<10&&e.size>1e6?setTimeout(()=>{let g=s.duration;URL.revokeObjectURL(a),t(g)},1e3):(URL.revokeObjectURL(a),t(p))},s.onerror=p=>{URL.revokeObjectURL(a),r(p)},s.src=a,s.load()}catch(a){this.loggingService.catch("Error in RecorderService getVideoDuration: ",a),r(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 Q(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(r=>{r.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 Q(this,null,function*(){try{let t=document.createElement("video");t.srcObject=e,t.muted=!0,t.autoplay=!0;let r=document.createElement("canvas"),a=r.getContext("2d");yield new Promise(g=>{t.onloadedmetadata=g}),r.width=t.videoWidth||1280,r.height=t.videoHeight||720;let s=r.captureStream(30);this.firefoxFallbackRecorder=new MediaRecorder(s,{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 f=new UI;f.blob=g,f.url=URL.createObjectURL(g),f.type=this.recorderInitData?.type,f.recordedTime=this.recorderDurationSubject$.value,this.recordedRawData$.next(f)}this.firefoxFallbackRecorder=void 0});let p=()=>{t.readyState>=2&&a&&a.drawImage(t,0,0,r.width,r.height),t.srcObject&&this.firefoxFallbackRecorder?.state==="recording"&&requestAnimationFrame(p)};this.firefoxFallbackRecorder.start(1e3),p()}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(r=>{r.stop()})}).catch(t=>{this.loggingService.catch("Error in RecorderService askDevicePermission: ",t)})}catch(t){this.loggingService.catch("Error in RecorderService askDevicePermission: ",t)}}openPictureInPicture(){return Q(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)(ee(Je),ee(_),ee(po),ee(su),ee(ot),ee(In),ee(Be),ee(cs))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ps=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I){this.afAuth=e,this.authService=t,this.configService=r,this.databaseService=a,this.docService=s,this.commonDbService=c,this.iamService=p,this.loggingService=g,this.notificationService=f,this.userPermissionService=I,this.documentPaths=null,this.views$=new Ce({}),this.commentViews$=new Ce({}),this.documentViews$=new Ce({}),this.locationViews$=new Ce({}),this.commentViewsByOrganizationIdAndDocumentId$=new Ce({}),this.documentViewsByOrganizationIdAndDocumentId$=new Ce({}),this.locationViewsByOrganizationIdAndLocationId$=new Ce({}),this.documentViewsEnabled$=new Ce(!1),this.documentViewsSetByDocumentId={},this.loggingService.log("%c[WB] Creating CLASS: ViewsService","color: blue;");try{this.authService.setViewsService(this),this.databaseService.getDb().pipe(Le(x=>!!x),rt(1)).subscribe(x=>{x&&(this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(B=>{this.notificationService.setNotificationViews(B)}),this.authService.getUser$().pipe(Le(B=>!!B),fe(B=>this.documentViewsEnabled$.pipe(Le(z=>z),de(()=>B))),fe(B=>this.docService.getDocumentPaths$().pipe(so(null),Oi(),de(([z,G])=>(z?.documentId!==G?.documentId&&this.views$.next({}),G)),de(z=>(this.documentPaths=z,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:B,_documentPaths:z})),fe(z=>this.docService.getDocumentIds$().pipe(fe(G=>(G?.length&&(G.find(J=>J.documentId===this.documentPaths?.documentId)||G.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),G.forEach(J=>{this.setDocumentAsRead({documentId:J.documentId,clientDocumentId:J.clientDocumentId})})),le(z))))))),fe(B=>this.docService.getDocumentMetadata$().pipe(Le(z=>!!z),de(z=>D(E({},B),{_documentMetadata:z}))))).subscribe(),this.authService.getUser$().pipe(Le(B=>!!B),fe(B=>this.documentViewsEnabled$.pipe(Le(z=>z),de(()=>B))),fe(B=>this.docService.getLocation$().pipe(Le(z=>!!z))),fe(B=>this.docService.getDocumentIds$().pipe(fe(z=>(z.find(G=>G.documentId===this.documentPaths?.documentId)||z.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),z.forEach(G=>{this.setLocationAsRead({documentId:G.documentId,clientDocumentId:G.clientDocumentId})}),le(B)))))).subscribe())},x=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",x)})}catch(x){this.loggingService.catch("Error in ViewsService constructor: ",x)}}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 r,a;try{if(e&&(a=Nn(e)),t&&typeof t=="object"){let s=or(t);r=Nn(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return ei(this.afAuth).pipe(Le(s=>!!s),fe(s=>this.isFeatureAllowed({firebaseUser:s})),fe(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(de(c=>(s.featureAllowed=c,s))):le(s)),fe(s=>s.featureAllowed?le(s).pipe(fe(c=>this.docService.getDocumentPaths$().pipe(de(p=>(this.documentPaths=p,c.documentPaths=p,c)))),fe(c=>a?this.getDataFromDocumentIds([a]):this.docService.getDocumentIds$().pipe(fe(p=>{let g=p?.length>0?p.map(f=>f.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(g)})))):le([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>t.user?le(D(E({},t),{featureAllowed:!0})):le(D(E({},t),{featureAllowed:!1}))),Ct((t,r)=>t?.featureAllowed===r?.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:r}=e;return t?.some(a=>!a)||!this.documentPaths?le([]):this.documentViewsEnabled$.pipe(fe(a=>a?mn([this.getCommentViewsDataFromDocuments(),this.getDocumentViewsDataFromDocuments(t),this.getLocationViewsDataFromDocuments(t)]):mn([this.getCommentViewsDataFromDocuments()])))}else return le(null)}getCommentViews(e){try{let t={};Object.entries(e??{}).forEach(([r,a])=>{let s=a.metadata?.documentId,c=a.views;!s||!c||(t[s]||(t[s]={}),t[s][a.annotationId]=c)}),Object.entries(t??{}).forEach(([r,a])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:r,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(Le(e=>!!e),Qt(e=>{this.getCommentViews(e)})):le([])}catch(e){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",e),le([])}}getDocumentViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,r=le([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(a.documentId=e?.length?e[0]:void 0,a.organizationId=this.documentPaths?.organizationId);let s=[];for(let c=0;c<(e?.length??0);c+=U.LISTENER_BATCH_SIZE)s.push(e?.slice(c,c+U.LISTENER_BATCH_SIZE)??[]);return r=mn(s.map(c=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:D(E({},a),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",c),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[lt("metadata.veltFolderId","==",t)]:[])]})}).pipe(Ar()))).pipe(de(c=>ia(c))),r.pipe(de(c=>({data:c?.data,operation:c?.operation})),de(({data:c,operation:p})=>{let g={};return e?(Object.entries(c??{}).forEach(([f,I])=>{let x=I.metadata?.documentId;x&&(g[x]||(g[x]={}),g[x][f]=I)}),{data:c,documentMap:g,operation:p}):{data:c,documentMap:g,operation:p}}),de(({data:c,documentMap:p,operation:g})=>{if(g?.type==="removed"){if(g?.ids?.length){let f=this.documentViews$.value;g?.ids?.forEach(I=>{delete f?.[I]}),this.documentViews$.next(f)}}else Object.entries(p??{}).forEach(([f,I])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:f,documentViews:I})})}))}getLocationViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,r=le([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(a.documentId=e?.length?e[0]:void 0,a.organizationId=this.documentPaths?.organizationId);let s=[];for(let c=0;c<(e?.length??0);c+=U.LISTENER_BATCH_SIZE)s.push(e?.slice(c,c+U.LISTENER_BATCH_SIZE)??[]);return r=mn(s.map(c=>this.commonDbService.dbListener({feature:"allLocationViews",properties:D(E({},a),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",c),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[lt("metadata.veltFolderId","==",t)]:[])]})}).pipe(Ar()))).pipe(de(c=>ia(c))),r.pipe(de(c=>({data:c?.data,operation:c?.operation})),de(({data:c,operation:p})=>{let g={};return e?(Object.entries(c??{}).forEach(([f,I])=>{let x=I.metadata?.documentId;x&&(g[x]||(g[x]={}),g[x][f]=I)}),{data:c,documentMap:g,operation:p}):{data:c,documentMap:g,operation:p}}),de(({data:c,documentMap:p,operation:g})=>{if(g?.type==="removed"){if(g?.ids?.length){let f=this.locationViews$.value;g?.ids?.forEach(I=>{delete f?.[I]}),this.locationViews$.next(f)}}else Object.entries(p??{}).forEach(([f,I])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:f,locationViews:I})})}))}setViewsData(e){try{this.views$.next(E(E({},this.views$.getValue()),e||{}))}catch(t){this.loggingService.catch("Error in ViewsService setViewsData:",t)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,commentViews:r,queryHash:a}){try{if(r||(r={}),t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s=E(E({},this.commentViews$.value),r);this.commentViews$.next(s),this.commentViewsByOrganizationIdAndDocumentId$.next(D(E({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:D(E({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:D(E({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,documentViews:r,queryHash:a}){try{if(r||(r={}),t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s=E(E({},this.documentViews$.value),r);this.documentViews$.next(s),this.documentViewsByOrganizationIdAndDocumentId$.next(D(E({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:D(E({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:D(E({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,locationViews:r,queryHash:a}){try{if(r||(r={}),t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s=E(E({},this.locationViews$.value),r);this.locationViews$.next(s),this.locationViewsByOrganizationIdAndLocationId$.next(D(E({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:D(E({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[t]:D(E({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[t]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentFeatureViews$(){return this.commentViews$.pipe(Ct((e,t)=>JSON.stringify(e||{})===JSON.stringify(t||{})))}setCommentAnnotationAsRead(e){return Q(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){this.updateCommentAnnotationViews(e);let r=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:r,metadata:{apiKey:this.configService.getApiKey(),organizationId:r,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 Q(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){this.removeCommentAnnotationViews(e);let r=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:r,metadata:{apiKey:this.configService.getApiKey(),organizationId:r,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(),r={views:{},comments:{}};if(t){let a={},s=e?.views?.comments||{},c=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(g=>{s[g.commentId]||(s[g.commentId]={views:{}}),s[g.commentId].views||(s[g.commentId].views={}),s[g.commentId].views[t.userSnippylyId]||(s[g.commentId].views[t.userSnippylyId]={timestamp:c})});let p=new Set(e.comments?.map(g=>g.commentId+""));if(Object.keys(s??{}).forEach(g=>{p.has(g)||delete s[g]}),e.comments?.length){let g=s[e.comments[0].commentId]?.views||{},f=Object.keys(g??{}).filter(I=>e.comments?.every(x=>s[x.commentId]?.views?.[I]));f.forEach(I=>{a[I]={timestamp:g[I].timestamp}}),e.viewedByUserIds=f}r.views=a,r.comments=s,e.views=r}return r}catch(t){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",t),{views:{},comments:{}}}}removeCommentAnnotationViews(e){try{let t=this.authService.getUser(),r={views:{},comments:{}};if(t){let a={},s=e?.views?.comments||{};e.comments?.forEach(p=>{s[p.commentId]?.views?.[t.userSnippylyId]&&delete s[p.commentId].views[t.userSnippylyId]});let c=new Set(e.comments?.map(p=>p.commentId+""));if(Object.keys(s??{}).forEach(p=>{c.has(p)||delete s[p]}),e.comments?.length){let p=s[e.comments[0].commentId]?.views||{},g=Object.keys(p??{}).filter(f=>e.comments?.every(I=>s[I.commentId]?.views?.[f]));g.forEach(f=>{a[f]={timestamp:p[f].timestamp}}),e.viewedByUserIds=g}else e.viewedByUserIds=[];r.views=a,r.comments=s,e.views=r}return r}catch(t){return this.loggingService.catch("Error in ViewsService removeCommentAnnotationViews:",t),{views:{},comments:{}}}}getNotificationFeatureViews$(){return this.views$.pipe(Ct((e,t)=>JSON.stringify(e?.notification||{})===JSON.stringify(t?.notification||{})))}setNotificationsAsRead(e){try{let t=this.authService.getUser();if(t){let r=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:r}})})}}catch(t){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",t)}}getDocumentViews$(){return this.views$.pipe(Ct((e,t)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(t?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(fe(t=>(this.documentPaths=t,e?this.locationViews$.pipe(de(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.users||{}:{}})):this.documentViews$.pipe(de(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.users||{}:{}})))),Ct(Xt))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",t),le({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(fe(t=>(this.documentPaths=t,e?this.locationViews$.pipe(de(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.day||{}:{}})):this.documentViews$.pipe(de(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.day||{}:{}})))))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",t),le({})}}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(r){return Q(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 s=new Date().getTime()+this.commonDbService.getOffset(),c=new Date().toISOString().split("T")[0],p=this.getDocumentViewsById(e);if(p){let g=new Date().toISOString().split("T")[0];p?.users[a.userSnippylyId]||(p.users[a.userSnippylyId]={}),p.users[a.userSnippylyId][g]={timestamp:this.timestamp},p?.day[g]||(p.day[g]={}),p.day[g][a.userSnippylyId]={timestamp:this.timestamp},p.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:p})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:c,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),this.commonDbService.updateData({feature:"documentUsersViews",properties:{id:e,user:a.userSnippylyId,date:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),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(Le(g=>g!==null),rt(1)).subscribe(()=>{let g={day:{[c]:{[a.userSnippylyId]:{timestamp:s}}},users:{[a.userSnippylyId]:{[c]:{timestamp:s}}},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(rt(1)).subscribe(t=>{if(Object.keys(t??{}).length===2){let r=this.docService.getDocumentMetadata();if(r?.creator?.email&&r?.creator?.email!==e.email){let a=[r.creator.email];this.updateNotificationsDatabase(oz.FIRST_VIEWED,{documentViews:{emails:a}})}}})}catch(t){this.loggingService.catch("Error in checkAndTriggerNotification:",t)}}setLocationAsRead(r){return Q(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let a=this.authService.getUser(),s=this.docService.getLocation(),c=s?.locationId,p=s?.location;if(a&&c&&p){let g=new Date().getTime()+this.commonDbService.getOffset(),f=new Date().toISOString().split("T")[0],I=this.getLocationViewsById(c);if(I){let x=new Date().toISOString().split("T")[0];I?.users[a.userSnippylyId]||(I.users[a.userSnippylyId]={}),I.users[a.userSnippylyId][x]={timestamp:this.timestamp},I?.day[x]||(I.day[x]={}),I.day[x][a.userSnippylyId]={timestamp:this.timestamp},I.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"location",data:I,properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:p,properties:{id:c,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:c,user:a.userSnippylyId,date:f,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:g}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:c,date:f,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 x={day:{[f]:{[a.userSnippylyId]:{timestamp:g}}},users:{[a.userSnippylyId]:{[f]:{timestamp:g}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),location:p};this.commonDbService.updateData({feature:"location",data:x,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 r=E({actionType:e,notificationSource:"documentViews"},t);this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",r)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(t){return new(t||o)(ee(Ri),ee(je),ee(Ft),ee(In),ee(ot),ee(un),ee(En),ee(_),ee(hn),ee(ss))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ol=(()=>{let o=class o{constructor(e,t,r,a){this.docService=e,this.loggingService=t,this.authService=r,this.configService=a;try{this.loggingService.log("%c[WB] Creating CLASS: MetadataService","color: blue;")}catch(s){this.loggingService.catch("Error in MetadataService constructor: ",s)}}getGlobalMetadata(){return Q(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),r=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),r&&(r=JSON.parse(JSON.stringify(r)),r.forEach(f=>{delete f?.locations,delete f?.location,delete f?.locationId,delete f?.pageInfo,delete f?.documentId,f.documentId=f?.clientDocumentId,delete f?.clientDocumentId,delete f?.veltFolderId,f?.clientOrganizationId&&(f.organizationId=f?.clientOrganizationId,delete f?.clientOrganizationId)}));let s=[];a&&(a=JSON.parse(JSON.stringify(a)),a?.location&&s.push(a?.location));let c=this.docService.getLocations();c&&Object.values(c).forEach(f=>{f?.location&&s.push(f?.location)});let p=this.docService.getDocumentPaths()?.folderId;return{organization:t,documents:r,locations:s,folderId:p}}catch(e){return this.loggingService.catch("Error in MetadataService getGlobalMetadata: ",e),{}}})}getDebugInfo(){return Q(this,null,function*(){try{let e=this.authService.getUser();if(!e)return null;let t,r;e&&(t=wr(e)??void 0,r=JSON.parse(JSON.stringify(e)),delete r?.contacts);let a=this.configService.getApiKey(),s=window?.Velt?.version,c=this.docService.getOrganizationMetadata(e?.organizationId),p,g;c&&(p=JSON.parse(JSON.stringify(c)),delete p?.organizationId,p.organizationId=p?.clientOrganizationId,delete p?.clientOrganizationId,delete p?.pageInfo,delete p?.apiKey,g=JSON.parse(JSON.stringify(c)),delete g?.clientOrganizationId,delete g?.pageInfo,delete g?.apiKey);let f=this.docService.getDocumentMetadataOfAvailableDocuments(),I=this.docService.getLocation(),x=[],B=[];I&&(x.push(I),I?.location&&B.push(I?.location));let z=this.docService.getLocations();z&&Object.values(z).forEach(be=>{x.push(be),be?.location&&B.push(be?.location)});let G=[],J=[];f&&(G=JSON.parse(JSON.stringify(f)),G.forEach(be=>{delete be?.apiKey,delete be?.locations,delete be?.location,delete be?.locationId,delete be?.pageInfo,delete be?.documentId,be.documentId=be?.clientDocumentId,delete be?.clientDocumentId,delete be?.veltFolderId,be?.clientOrganizationId&&(be.organizationId=be?.clientOrganizationId,delete be?.clientOrganizationId)}),J=JSON.parse(JSON.stringify(f)),J.forEach(be=>{delete be?.apiKey,delete be?.locations,delete be?.location,delete be?.locationId,delete be?.pageInfo,delete be?.clientDocumentId,be.folderId=be?.veltFolderId,delete be?.veltFolderId,delete be?.clientOrganizationId}));let ne,ve=this.docService.getDocumentPaths();ve?.folderId&&ve?.veltFolderId&&(ne={folderId:ve?.folderId,veltFolderId:ve?.veltFolderId});let _e,Fe;ne&&(_e=JSON.parse(JSON.stringify(ne)),delete _e?.veltFolderId,Fe=JSON.parse(JSON.stringify(ne)),Fe.folderId=Fe.veltFolderId,delete Fe?.veltFolderId);let Ve={};return Ve.veltVersion=s,Ve.apiKey=a,Ve.serverMap={organization:g??void 0,documents:J,locations:x??void 0,folder:Fe??void 0,user:r??void 0,accessFields:this.docService.getProcessedDocContext()??void 0},Ve.clientMap={organization:p??void 0,documents:G,locations:B??void 0,folder:_e??void 0,user:t??void 0,context:this.docService.getDocContext()??void 0},Ve}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(fe(()=>Q(this,null,function*(){return yield this.getDebugInfo()})),Ct(Xt))}};o.\u0275fac=function(t){return new(t||o)(ee(ot),ee(_),ee(je),ee(Ft))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var WC=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.metadataService=r,this.buttonClickSubject$=new Qe,this.buttonToggleMap$=new Ce({}),this.contextDataMapping={commentAnnotation:{source:["componentConfigSignal","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 Q(this,arguments,function*({id:e,type:t,groupId:r,contextData:a,data:s}){try{this.buttonToggle(e,void 0,t,r);let g=this.extractButtonData(a),f=this.createButtonContext(e,t,r),I=yield this.metadataService.getGlobalMetadata(),x={};if(s){let p=s,{componentConfigSignal:z}=p,G=ju(p,["componentConfigSignal"]);if(x=E({},G),z&&typeof z=="function")try{let J=z();J&&typeof J=="object"&&(x=E(E({},x),J))}catch(J){this.loggingService.catch("Error accessing componentConfigSignal: ",J)}}let B=D(E({buttonContext:f},g),{metadata:I,data:x});this.buttonClickSubject$.next(B),this.coreActionsService.triggerAction(mt.VELT_BUTTON_CLICK,B)}catch(g){this.loggingService.catch("Error in ButtonService buttonClick: ",g)}})}buttonActive({id:e,type:t,groupId:r,contextData:a}){try{let s=this.buttonToggleMap$.value?.[r||"ungrouped"]?.[e]||!0;this.buttonToggle(e,s,t,r)}catch(s){this.loggingService.catch("Error in ButtonService buttonClick: ",s)}}buttonToggle(e,t,r,a){try{let s=this.buttonToggleMap$.value,c=this.createNewToggleMap(s,e,t,r,a);this.buttonToggleMap$.next(c)}catch(s){this.loggingService.catch("Error in ButtonService buttonToggle: ",s)}}extractButtonData(e){try{let t={};return Object.entries(this.contextDataMapping).forEach(([r,a])=>{let s=this.getNestedValue(e,a.source);s!==void 0&&(t[a.target]=s)}),t}catch(t){return this.loggingService.catch("Error in ButtonService extractContextData: ",t),{}}}getNestedValue(e,t){try{let r=e;for(let a of t){if(r?.[a]===void 0)return;Vi(r[a])?r=r[a]():r=r[a]}return r}catch(r){this.loggingService.catch("Error in ButtonService getNestedValue: ",r);return}}createButtonContext(e,t,r){try{let a={type:t,selections:this.buttonToggleMap$.value,clickedButtonId:e};return(t==="single-select"||t==="multi-select")&&r?D(E({},a),{groupId:r}):a}catch(a){return this.loggingService.catch("Error in ButtonService createButtonMetadata: ",a),{}}}createNewToggleMap(e,t,r,a,s){try{let c=E({},e);return a==="button-toggle"?D(E({},c),{ungrouped:D(E({},c.ungrouped),{[t]:r??!c.ungrouped?.[t]})}):a==="single-select"&&s?D(E({},c),{[s]:{[t]:r??!0}}):a==="multi-select"&&s?D(E({},c),{[s]:D(E({},c[s]),{[t]:r??!c[s]?.[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 Q(this,null,function*(){try{if(e){let{id:s,group:c}=e,p=JSON.parse(JSON.stringify(this.buttonToggleMap$.value||{}));c&&s?delete p?.[c]?.[s]:c?delete p?.[c]:s&&Object.keys(p).forEach(g=>{Object.keys(p[g]).forEach(f=>{f===s&&delete p?.[g]?.[f]})}),this.buttonToggleMap$.next(p)}else this.buttonToggleMap$.next({});let t={selections:this.buttonToggleMap$.value},r=yield this.metadataService.getGlobalMetadata(),a={buttonContext:t,metadata:r};this.coreActionsService.triggerAction(mt.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)(ee(ni),ee(_),ee(ol))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var qC=(()=>{let o=class o{constructor(e,t){this.httpClient=e,this.loggingService=t,this.fileContentMap$=new Ce({})}getFileContent(e){try{let t=Nn(e);return this.fileContentMap$.value[t]?le(this.fileContentMap$.value[t]):this.httpClient.get(e,{responseType:"text"}).pipe(de(r=>(this.fileContentMap$.next(D(E({},this.fileContentMap$.value),{[t]:r})),r)))}catch(t){return this.loggingService.catch("Error in TranscriptionService saveRecorderToDb: ",t),le(null)}}getVttFileTextToArray(e){try{let c=[],p=e.split(`
|
|
485
|
-
`);for(var t=0;t<p.length;t++)if(p[t].indexOf("-->")!==-1){var r=p[t].split(" --> ")[0],a=p[t].split(" --> ")[1],s=p[t+1];c.push({startTime:r,endTime:a,startTimeInSeconds:this.getTimeInSecondsFromVttTime(r),endTimeInSeconds:this.getTimeInSecondsFromVttTime(a),text:s})}return c}catch(c){return this.loggingService.catch("Error in TranscriptionService getVttFileTextToArray: ",c),[]}}getTimeInSecondsFromVttTime(e){try{let t=e.split(":"),r=0;t.length===3&&(r=parseInt(t[0]),t.shift());let a=parseInt(t[0]),s=parseInt(t[1].split(".")[0]),c=parseInt(t[1].split(".")[1]);return((r*60*60+a*60+s)*1e3+c)/1e3}catch(t){return this.loggingService.catch("Error in TranscriptionService getTimeInSecondsFromVttTime: ",t),0}}};o.\u0275fac=function(t){return new(t||o)(ee(HP),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wi=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=c,this.domService=p,this.afAuth=g,this.iamService=f,this.functions=I,this.avatarService=x,this.contactService=B,this.storageService=z,this.dialog=G,this.loggingService=J,this.notificationService=ne,this.transcriptionService=ve,this.recorderService=_e,this.recorderUtilsService=Fe,this.userPermissionService=Ve,this.recorderAnnotationById$=new Ce({}),this.documentPaths=null,this.allowedElementIds$=new Ce([]),this.addRecorderMode$=new Ce(!1),this.recorderContainerDarkMode$=new Ce(!1),this.recordingTranscriptionEnabled$=new Ce(!0),this.draftRecordings$=new Ce([]),this.recorderNotesFound$=new Ce(!1),this.recordedData=null,this.videoEditorAutoOpen$=new Ce({}),this.commentService=null,this.getAllRecorderAnnotations().subscribe(be=>{}),this.loggingService.log("%c[WB] Creating CLASS: RecorderAnnotationService","color: blue;"),this.analyticsService.setRecorderAnnotationService(this),this.authService.setRecorderAnnotationService(this),this.databaseService.getDb().pipe(Le(be=>!!be),rt(1)).subscribe(be=>{be&&this.getDocumentPaths()},be=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",be)}),this.domService.onWindowPointerMove$().subscribe(be=>{if(this.addRecorderMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let Ie=this.domService.getBackgroundElement(be.clientX,be.clientY);Ie&&(this.isElementInsideAllowedElements(Ie)?zk(be.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=Ie):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowPointerMove$ subscription: ",be)}),this.domService.onWindowKeyupEsc$().subscribe(be=>{this.addRecorderMode$.value&&this.disableAddRecorderMode()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupEsc$ subscription: ",be)}),this.domService.onDocumentClick$().subscribe(be=>{if(be&&this.addRecorderMode$.value){if(be.preventDefault(),be.stopPropagation(),!zk(be.target)){let Ie=this.domService.getBackgroundElement(be.clientX,be.clientY);Ie&&this.isElementInsideAllowedElements(Ie)}this.disableAddRecorderMode()}},be=>{this.loggingService.catch("Error in RecorderAnnotationService onDocumentClick$ subscription: ",be)}),this.addRecorderMode$.subscribe(be=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),be?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"))},be=>{this.loggingService.catch("Error in RecorderAnnotationService addRecorderMode$ subscription: ",be)}),this.domService.onWindowKeyupBackspace$().subscribe(be=>{this.deleteRecorderPinAnnotations()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupBackspace$ subscription: ",be)}),this.domService.onWindowKeyupDelete$().subscribe(be=>{this.deleteRecorderPinAnnotations()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",be)}),this.recorderService.onRecordedData().subscribe(be=>{this.recordedData=be},be=>{this.loggingService.catch("Error in RecorderAnnotationService onRecordedData subscription: ",be)}),this.domService.getDeleteCommmentAnnotations$().subscribe(be=>{be?.length&&be.forEach(Ie=>Q(this,null,function*(){}))},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",be)})}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(Qt(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(de(()=>this.getAnnotationById(e)),fe(t=>Q(this,null,function*(){return t?yield this.createRecorderData(t,!0):void 0})))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderId: ",t),le(void 0)}}getRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t={};return yield Promise.all(e.recorderIds.map(r=>Q(this,null,function*(){let a=this.getAnnotationById(r);if(!a)return;let s=yield this.createRecorderData(a,!0);s&&(t[r]=s)}))),{data:Object.keys(t).length>0?t:null}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderIds: ",t),{data:null}}})}fetchRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t=this.recorderAnnotationById$.value,r=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(s=>e.recorderIds.includes(s.annotationId))),a.length===0?[]:(yield Promise.all(a.map(s=>Q(this,null,function*(){if(!s)return;let c=yield this.createRecorderData(s,!0);c&&r.push(c)}))),r)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService fetchRecorderDataByRecorderIds: ",t),[]}})}deleteRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t=this.recorderAnnotationById$.value,r=[],a=Object.values(t),s=[];return e?.recorderIds?.length&&(s=a.filter(c=>e.recorderIds.includes(c.annotationId))),s.length===0?[]:(yield Promise.all(s.map(c=>Q(this,null,function*(){if(!c)return;let p=yield this.createRecorderData(c,!0);yield this.deleteRecorderPinAnnotation(c),p&&r.push(p)}))),r)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderDataByRecorderIds: ",t),[]}})}getRecordings(e){try{return this.recorderAnnotationById$.pipe(fe(t=>Q(this,null,function*(){let r=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(s=>e.recorderIds.includes(s.annotationId))),a.length===0?[]:(yield Promise.all(a.map(s=>Q(this,null,function*(){if(!s)return;let c=yield this.createRecorderData(s,!0);c&&r.push(c)}))),r)})),Un(t=>(this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),le([]))))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),le([])}}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,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllRecorderAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in RecorderAnnotationService getAllRecorderAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>s?this.getDataFromDocumentIds([s]).pipe(de(g=>(p.annotations=g||[],E({},p)))):this.docService.getDocumentIds$().pipe(fe(g=>{let f=g?.length>0?g.map(I=>I.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(f).pipe(de(I=>(p.annotations=I||[],E({},p))))}))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(f=>f.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("RecorderAnnotationService getAllRecorderAnnotations").pipe(de(()=>p)):le(p)),de(p=>{let g=[];return p?.filteredAnnotations?.forEach(f=>{this.calculateRecorderAnnotationPosition(f),f?.targetElement||g.push(f)}),this.draftRecordings$.next(g),p}),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([]))):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.RECORDER)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Recorder feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:r}=e;if(t?.some(p=>!p)||!this.documentPaths)return le([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=le([]),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 p=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let f=0;f<(p?.length??0);f+=U.LISTENER_CONTEXT_BATCH_SIZE)g.push(p?.slice(f,f+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=mn(g.map(f=>this.commonDbService.dbListener({feature:"allRecorders",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",t),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[],...f?.length?[lt("context.accessFields","array-contains-any",f)]:[])]})}).pipe(Ar()))).pipe(de(f=>ia(f)))}else{let p=[];for(let g=0;g<(t?.length??0);g+=U.LISTENER_BATCH_SIZE)p.push(t?.slice(g,g+U.LISTENER_BATCH_SIZE)??[]);s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allRecorders",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",g),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}return s.pipe(de(p=>({data:p?.data,operation:p?.operation})),de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p).filter(I=>typeof I=="object")),{data:f,operation:g}}),de(({data:p,operation:g})=>{if(!t)return{data:p,documentMap:{},operation:g};let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),de(({data:p,documentMap:g,operation:f})=>{if(!r)if(f?.type==="removed"){if(f?.ids?.length){let I=this.recorderAnnotationById$.value;f?.ids?.forEach(x=>{delete I?.[x]}),this.recorderAnnotationById$.next(I)}}else Object.entries(g).forEach(([I,x])=>{this.setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:x})});return p}),Un(p=>(this.loggingService.catch("Error in RecorderAnnotationService getDataFromDocumentId: ",p),le([]))))}else return le([])}setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.recorderAnnotationById$.value),s);this.recorderAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in RecorderAnnotationService setRecorderAnnotationsByOrganizationIdAndDocumentId:",s)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(r=>t.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService filterAnnotationsByLocations:",r),[]}}calculateRecorderAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let r=t.iterateNext();if(r&&Pi(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:c}=Hg(r);e.position={top:s*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 r=this.recorderAnnotationById$.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in RecorderAnnotationService getAnnotationById: ",r);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(fe(()=>{let r=this.getAnnotationById(e,t);return r?le(r):le(null)}),Un(r=>(this.loggingService.catch("Error in RecorderAnnotationService getCommentAnnotationById: ",r),le(null))))}getRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};return Object.values(this.recorderAnnotationById$.value).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderAnnotationsByOrganizationIdAndDocumentId:",r),[]}}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 r=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setLocationToRecorderAnnotation:",t)}}addRecorder(e,t,r){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."),le(null);{t.from=a,t.color=U.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:s,topPositionY:c}=this.domService.getTopLeftPosition();t.positionX=s,t.positionY=c;let p=this.domService.getCurrentWindowSizeValue();if(t.screenWidth=p.screenWidth,t.screenHeight=p.screenHeight,t.screenScrollHeight=p.screenScrollHeight,t.recorderedElementPath="",e&&(t.targetElement=this.domService.getTargetElementForCursorPosition(e)),t?.targetElement?.xpath){let g=this.domService.getXPath(t.targetElement.xpath);if(g){let f=g.iterateNext();f&&(Pi(f)||(t.targetElement=null))}}return this.setLocationToRecorderAnnotation(t),t.pageInfo=Ni(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveRecorderToDb(t,r)}}else return le(null)}catch(a){return this.loggingService.catch("Error in RecorderAnnotationService addRecorder: ",a),le(null)}}saveRecorderToDb(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: saveRecorderToDb","color: green;");try{return this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.RECORDER)?this.docService.getDocumentPaths$().pipe(Le(r=>!!r),rt(1),fe(r=>(this.documentPaths=r,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(a=>!!a),rt(1),fe(a=>Q(this,null,function*(){if(this.documentPaths?.recorder){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.recorderUrl=this.generateRecorderUrl(e));let s=JSON.parse(JSON.stringify(e));if(s.position=null,!s?.metadata?.documentId){s?.metadata||(s.metadata={});let g=this.docService.getBaseMetadata("recorder",{commentAnnotationId:e.commentAnnotationId});s.metadata=E(E({},s?.metadata),g)}let{documentId:c,organizationId:p}=s?.metadata||{};if(e.commentAnnotationId){let g=this.commentService?.getAnnotationById(e.commentAnnotationId??"");if(g?.context?.access&&g?.context?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:e.from?.userId,accessFields:g.context.accessFields}))return this.loggingService.catch("User does not have context access to add recorder annotation.",void 0,void 0,!0),null;s.context={access:g.context.access,accessFields:g.context.accessFields}}}return yield new Promise((g,f)=>Q(this,null,function*(){yield this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:p},data:JSON.parse(JSON.stringify(s)),callback:()=>{g(!0)},errorCallback:I=>{f(I)}})})),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}),this.processRecording(e,"recording","merge"),this.updateNotificationsDatabase(e,Z0.ADDED),e}else return null})))))):le(null)}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService saveRecorderToDb: ",r),le(null)}}processRecording(e,t,r){return Q(this,null,function*(){try{let a=Ji(this.functions,eo({url:wn?.cloudFunction?.processRecording,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),s=this.docService.getDocumentPaths();e?.metadata?.documentId&&(s=new Sm({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:s?.recorder+e?.annotationId,fromUser:this.authService.getUser(),clientOrganizationId:s?.clientOrganizationId,clientDocumentId:s?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:s?.recorder,annotationId:e?.annotationId,sourceFeature:t||"recording",annotationData:e,skipMerge:!0,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:r,returnType:"transcription",generatePreviewImages:this.recorderService.getVideoEditor()&&this.recorderService.getVideoEditorTimelinePreview()};if(c?.useFirestore){let z=yield this.recorderUtilsService.encryptRecorderAnnotation(e);c.annotationData=z}let p=this.documentPaths?.organizationId,g=this.documentPaths?.documentId;e?.metadata?.documentId&&(g=e.metadata.documentId,p=e.metadata.organizationId);let f=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;p&&(f=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${p}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),c.bucketPath=f;let I;try{I=yield a(c)}catch(z){z?.details?.type==="recording"&&this.recorderActionsService?.onError({type:"recordingFailed",message:"Recording failed",recorderId:z.details.recorderId}),z?.details?.type==="transcription"&&this.recorderActionsService?.onError({type:"transcriptionFailed",message:"Transcription failed",recorderId:z.details.recorderId}),this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",z)}let x=this.getAnnotationById(e?.annotationId);if(!x)return;let B=yield this.createRecorderData(x,!1);if(B){if(I?.data?.transcriptedText&&(B.transcription.contentSummary=I.data.transcriptedText),I?.data?.vttUrl)try{let z=yield this.transcriptionService.getFileContent(I.data.vttUrl).toPromise();z&&(B.transcription.transcriptSegments=this.getVttFileTextToArray(z),B.transcription.vttFileUrl=I.data.vttUrl),B?.assets?.length&&B.assets.forEach(G=>{G.transcription=B.transcription}),B?.assetsAllVersions?.length&&(B.assetsAllVersions[0].transcription=B.transcription),this.recorderActionsService?.onTranscriptionDone(B)}catch(z){this.loggingService.catch("Error fetching VTT content: ",z)}x?.attachments?.length&&this.recordedData&&(this.recordedData.videoUrl=x.attachments[0].url),t==="recording"&&this.recorderActionsService?.onRecordingDone(B)}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 Q(this,null,function*(){try{if(!e)return null;let r=aC(e.metadata||{}),a=wr(e.from),s={recorderId:e.annotationId||"",from:a,assets:[],metadata:r,assetsAllVersions:[],transcription:{transcriptSegments:[],vttFileUrl:"",contentSummary:""}},c=e;e.latestVersion&&e.recordingEditVersions?.[e.latestVersion]&&(c=e.recordingEditVersions[e.latestVersion]);let p=f=>Q(this,null,function*(){let I={transcriptSegments:[],vttFileUrl:"",contentSummary:f?.transcription?.transcriptedText||""};if(t&&f?.transcription?.vttUrl)try{let x=yield this.transcriptionService.getFileContent(f.transcription.vttUrl).toPromise();x&&(I.transcriptSegments=this.getVttFileTextToArray(x),I.vttFileUrl=f.transcription.vttUrl)}catch(x){this.loggingService.catch("Error fetching VTT content: ",x)}return I}),g=yield p(c);if(s.transcription=g,c?.attachments?.length)for(let f of c.attachments)f?.url&&s.assets.push({version:e.latestVersion||1,url:f.url,mimeType:f.mimeType,fileName:f.name,fileSizeInBytes:f.size,fileFormat:f.type,transcription:E({},g),thumbnailUrl:e.attachments?.[0]?.thumbnail});if(e.recordingEditVersions){let f=Object.entries(e.recordingEditVersions).map(z=>Q(this,[z],function*([x,B]){let G=parseInt(x),J=yield p(B),ne=B?.attachments?.[0]||B?.attachment;return{version:G,url:ne?.url,mimeType:ne?.mimeType,fileName:ne?.name,fileSizeInBytes:ne?.size,fileFormat:ne?.type,transcription:J,thumbnailUrl:B?.attachments?.[0]?.thumbnail}})),I=yield Promise.all(f);s.assetsAllVersions=I.filter(x=>x.url)}else s.assetsAllVersions=[...s.assets];return s}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService createRecorderData: ",r),null}})}updateRecorder(e,t=!1,r){try{r&&this.setLocationToRecorderAnnotation(e),t&&this.updateNotificationsDatabase(e,Z0.UPDATED),this.updateRecorderToDb(e)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateRecorder: ",a)}}resolveRecorder(e){try{this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(e,Z0.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 r=t.iterateNext();r&&(Pi(r)||(e.targetElement=null))}}if(e.annotationId){let t=this.recorderAnnotationById$.value;this.recorderAnnotationById$.next(D(E({},t),{[e.annotationId]:E({},e)}))}if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.RECORDER)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata();t.metadata=E(E({},t?.metadata),s)}let{documentId:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:r,organizationId:a},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService updateRecorderToDb: ",t)}}deleteRecorderPinAnnotations(){try{let e=this.domService.getSelectedAnnotationsMap(),t=this.authService.getUser(),r=[];Object.keys(e).forEach(a=>Q(this,null,function*(){let s=e[a];s.type==="recorder"&&t&&s.from&&(t?.isAdmin||s.from.userId===t.userId)&&r.push(s)})),r?.length&&(this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETE_TRIGGERED,{annotationId:r.map(a=>a.annotationId).join()}),this.dialog.open(La,{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(rt(1)).subscribe(a=>{a&&(r.forEach(s=>Q(this,null,function*(){yield this.deleteRecorderPinAnnotation(s)})),setTimeout(()=>{document.querySelectorAll(`[${U.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(Ne.RECORDER)&&this.documentPaths?.recorder&&e?.annotationId){this.updateNotificationsDatabase(e,Z0.DELETED),e?.attachment&&this.storageService.deleteAttachment({attachment:e.attachment}),e?.attachments&&e.attachments.forEach(s=>{this.storageService.deleteAttachment({attachment:s}).catch(c=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete attachment: ",c)})}),e?.transcription&&(e?.transcription?.srtBucketPath&&this.storageService.deleteFileFromPath(e.transcription.srtBucketPath).catch(s=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete srt file: ",s)}),e?.transcription?.vttBucketPath&&this.storageService.deleteFileFromPath(e.transcription.vttBucketPath).catch(s=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete vtt file: ",s)})),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:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);return this.commonDbService.deleteData({feature:"recorder",properties:{id:e.annotationId,documentId:r,organizationId:a}}).then(s=>Q(this,null,function*(){let c=yield this.createRecorderData(e,!0);c&&this.recorderActionsService?.onDeleteRecording(c)}))}else return Promise.resolve()}enableAddRecorderMode(){this.authService.isFeatureAllowed(Ne.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:Ne.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:Ne.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 r=this.domService.getXPath(t),a=this.getRecorderPinAnnotationObject();a&&(a.targetElement={xpath:r,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 nu;t.from=e,t.color=U.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:r,topPositionY:a}=this.domService.getTopLeftPosition();t.positionX=r,t.positionY=a;let s=this.domService.getCurrentWindowSizeValue();t.screenWidth=s.screenWidth,t.screenHeight=s.screenHeight,t.screenScrollHeight=s.screenScrollHeight,t.recorderedElementPath="";let c=this.docService.getLocation();return c&&(t.locationId=c.locationId,t.location=c.location),t}return null}updateNotificationsDatabase(e,t,r={}){try{let a=E({annotationData:e,actionType:t,notificationSource:"recorder",recordingType:e?.recordingType},r);this.notificationService.updateNotificationDatabase(a)}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=Ni(),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 r=this.documentPaths?.organizationId,a=this.documentPaths?.documentId;t?.metadata?.documentId&&(a=t.metadata.documentId,r=t.metadata.organizationId);let s=`${U.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;return r&&(s=`${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${r}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),this.storageService.uploadFile({path:s,file:e})}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(U.URL_PARAMS.RECORDER_ID),t.searchParams.append(U.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),le(!1)}}getRecorderNotesFound(){try{return this.recorderNotesFound$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),!1}}editVideoRecording(e,t,r,a,s,c){return Q(this,null,function*(){try{let p=Ji(this.functions,eo({url:wn?.cloudFunction?.videoBackend,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),g=this.docService.getDocumentPaths();r?.metadata?.documentId&&(g=new Sm({apiKey:this.configService.getApiKey(),clientDocumentId:r.metadata.clientDocumentId,clientOrganizationId:r.metadata.clientOrganizationId,documentId:r.metadata.documentId,organizationId:r.metadata.organizationId}));let f={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:g?.recorder+(r?.annotationId||""),fromUser:this.authService.getUser(),clientOrganizationId:g?.clientOrganizationId,clientDocumentId:g?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:g?.recorder,annotationId:r?.annotationId,annotationData:r,videoUrl:e,segments:t,zoomOptions:a,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:s,backendUpload:!0};if(c){let G=yield c.arrayBuffer(),J=new Uint8Array(G),ne="";for(let _e=0;_e<J.length;_e++)ne+=String.fromCharCode(J[_e]);let ve=btoa(ne);f.videoBlobData=ve,f.videoBlobType=c.type,f.videoBlobSize=c.size}if(f?.useFirestore&&r){let G=yield this.recorderUtilsService.encryptRecorderAnnotation(r);f.annotationData=G}let I=this.documentPaths?.organizationId,x=this.documentPaths?.documentId;r?.metadata?.documentId&&(x=r.metadata.documentId,I=r.metadata.organizationId);let B=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${x}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;I&&(B=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${I}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${x}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),f.bucketPath=B;let z=yield p(f);if(s==="standalone"){let G=z?.data;if(G&&G?.videoData){let J=atob(G.videoData),ne=new ArrayBuffer(J.length),ve=new Uint8Array(ne);for(let Ve=0;Ve<J.length;Ve++)ve[Ve]=J.charCodeAt(Ve);let _e=new Blob([ve],{type:G.mimeType||"video/mp4"}),Fe=document.createElement("a");Fe.href=URL.createObjectURL(_e),Fe.download="edited-video.mp4",document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe)}}return z}catch(p){throw this.loggingService.catch("Error in RecorderAnnotationService editVideoRecording: ",p),p}})}setVideoEditorAutoOpen(e){try{this.videoEditorAutoOpen$.next(E(E({},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),le({})}}getVideoEditorAutoOpen(){try{return this.videoEditorAutoOpen$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),{}}}downloadLatestVideo(e){return Q(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 r,a,s=t.latestVersion;if(s&&t.recordingEditVersions?.[s]?(r=t.recordingEditVersions[s].attachments?.[0]?.url,a=t.recordingEditVersions[s].attachments?.[0]?.name):(r=t.attachments?.[0]?.url||t.attachment?.url,a=t.attachments?.[0]?.name||t.attachment?.name),!r)return this.loggingService.catch("No video URL found for recording: "+e),!1;let c=yield fetch(r);if(!c.ok)return this.loggingService.catch("Failed to fetch video: "+c.statusText),!1;let p=yield c.blob(),g=document.createElement("a");return g.href=URL.createObjectURL(p),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)(ee(Je),ee(Ft),ee(ot),ee(In),ee(un),ee(je),ee(Be),ee(Ri),ee(En),ee(Do),ee(ym),ee(Si),ee(su),ee(po),ee(_),ee(hn),ee(qC),ee(bn),ee(jC),ee(ss))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var we=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve,be,Ie,Ae,Se,he,Oe,Re,Zi){this.analyticsService=e,this.areaService=t,this.commonDbService=r,this.configService=a,this.docService=s,this.databaseService=c,this.authService=p,this.domService=g,this.afAuth=f,this.avatarService=I,this.contactService=x,this.storageService=B,this.functions=z,this.dialog=G,this.iamService=J,this.loggingService=ne,this.notificationService=ve,this.customFilterService=_e,this.reactionService=Fe,this.hotkeyService=Ve,this.recorderService=be,this.viewsService=Ie,this.buttonService=Ae,this.metadataService=Se,this.commonDbUtilsService=he,this.attachmentResolverService=Oe,this.userPermissionService=Re,this.recorderAnnotationService=Zi,this.customPinsById=new Map,this.commentAdded$=new Qe,this.commentUpdated$=new Qe,this.commentAccepted$=new Qe,this.commentRejected$=new Qe,this.commentAnnotationDeleted$=new Qe,this.multiThreadCommentAnnotationDeleted$=new Qe,this.commentAnnotationById$=new Ce(null),this.multiThreadCommentAnnotationById$=new Ce(null),this.ghostCommentAnnotationMap$=new Ce({}),this.unreadCommentsMap$=new Ce(null),this.documentPaths=null,this.user=null,this.customCategoryMap=U.CommentCategoryMap,this.allowedElementIds$=new Ce([]),this.allowedElementClassNames$=new Ce([]),this.allowedElementQuerySelectors$=new Ce([]),this.addCommentMode$=new Ce(!1),this.persistentCommentMode$=new Ce(!1),this.seenByUsers$=new Ce(!0),this.deleteReplyConfirmation$=new Ce(!1),this.persistentModeBanner$=new Ce(!0),this.commentAddedEmitter=null,this.commentContextProvider=null,this.textCommentMode$=new Ce(!0),this.sidebarVisible$=new Ce(!1),this.sidebarOpenedByCustomTrigger$=new Ce(!1),this.floatingCommentsEnabled$=new Ce(!0),this.moderatorMode$=new Ce(!1),this.streamMode$=new Ce(!1),this.enableSignInButton$=new Ce(!1),this.enableUpgradeButton$=new Ce(!1),this.onSignInClick$=new Qe,this.onUpgradeClick$=new Qe,this.enableAttachment$=new Ce(!0),this.enableReactions$=new Ce(!0),this.allowedRecordings$=new Ce(["audio","video","screen"]),this.openSidebar$=new Qe,this.showScreenSizeInfo$=new Ce(!1),this.showCommentIndex$=new Ce(!1),this.popoverMode$=new Ce(!1),this.popoverTriangleComponent$=new Ce(!0),this.draftMode$=new Ce(!0),this.enableDialogOnHover$=new Ce(!0),this.enableDialogOnTargetElementClick$=new Ce(!1),this.enablePriority$=new Ce(!1),this.enableStatus$=new Ce(!0),this.enableResolve$=new Ce(!0),this.enableGhostComments$=new Ce(!1),this.enableGhostCommentsMessage$=new Ce(!0),this.inboxMode$=new Ce(!1),this.enableAutoCategorize$=new Ce(!1),this.commentContainerDarkMode$=new Ce(!1),this.suggestionMode$=new Ce(!1),this.mobileMode$=new Ce(!0),this.inlineCommentMode$=new Ce(!1),this.minimap$=new Ce(!1),this.commentsOnDom$=new Ce(!0),this.commentToolEnabled$=new Ce(!0),this.totalMediaLength$=new Ce(0),this.sidebarUrlNavigationEnabled$=new Ce(!1),this.detectionStrategy$=new Ce(Fk.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Ce(!1),this.sidebarButtonOnCommentDialogClick$=new Qe,this.commentNavigationButtonClick$=new Qe,this.deviceIndicatorOnCommentPins$=new Ce(!1),this.sidebarCommentClick$=new Qe,this.privateCommentMode$=new Ce(!1),this.privateCommentAllowed$=new Ce(!1),this.scrollToComment$=new Ce(!0),this.userMentions$=new Ce(!0),this.paginatedContactList$=new Ce(!1),this.deleteOnBackspace$=new Ce(!0),this.hotkeyEnabled$=new Ce(!1),this.recordingSummaryEnabled$=new Ce(!0),this.unreadIndicatorMode$=new Ce(cf.MINIMAL),this.composerMode$=new Ce(df.DEFAULT),this.enterKeyToSubmit$=new Ce(!1),this.resolvedCommentsOnDom$=new Ce(!1),this.bubbleOnPinEnabled$=new Ce(!1),this.bubbleOnPinHoverEnabled$=new Ce(!0),this.excludeLocationIdsFromSidebar$=new Ce([]),this.multiThread$=new Ce(!1),this.groupMatchedComments$=new Ce(!1),this.shortUserName$=new Ce(!0),this.collapsedComments$=new Ce(!1),this.fullExpanded$=new Ce(!1),this.queryParamsComments$=new Ce(!1),this.resolveStatusAccessAdminOnly$=new Ce(!1),this.linkCallback$=new Ce(!1),this.svgAsImg$=new Ce(!1),this.commentToNearestAllowedElement$=new Ce(!1),this.filterCommentsOnDom$=new Ce(!1),this.maxReplyAvatars$=new Ce(3),this.replyAvatars$=new Ce(!1),this.commentplaceholder$=new Ce(void 0),this.replyplaceholder$=new Ce(void 0),this.screenshotEnabled$=new Ce(!1),this.pinShadowDOM$=new Ce(!0),this.dialogShadowDOM$=new Ce(!0),this.textCommentToolShadowDOM$=new Ce(!0),this.pinDarkMode$=new Ce(null),this.textCommentToolDarkMode$=new Ce(null),this.textCommentToolbarDarkMode$=new Ce(null),this.textCommentToolbarShadowDOM$=new Ce(!0),this.sidebarShadowDOM$=new Ce(!0),this.changeDetectionInCommentMode$=new Ce(!1),this.commentSelectionChange$=new Qe,this.commentsFromSidebarMap$=new Ce(null),this.sidebarButtonCountType$=new Ce("default"),this.filterGhostCommentsInSidebar$=new Ce(!1),this.commentSidebarFilters$=new Ce({}),this.commentSidebarSystemFiltersOperator$=new Ce(md.AND),this.bubbleCommentAnnotationIds$=new Ce([]),this.updateCommentDialogPositionTriggerSubject$=new Ce(void 0),this.areaCommentEnabled$=new Ce(!0),this.commentPinCursorImage$=new Ce(""),this.commentAnnotationsFromCommentsContainer$=new Ce([]),this.customChipDropdownData$=new Ce(null),this.originalCommentAnnotationsByDocumentId$=new Ce({}),this.draftCommentAnnotationsByAnnotationId$=new Ce(null),this.draftMultiThreadCommentAnnotationsByAnnotationId$=new Ce({}),this.copyLink$=new Ce(""),this.addCommentDragMode=!1,this.dragSubscriptions=[],this.hotkeySubscriptions=[],this.sidebarData$=new Ce(null),this.sidebarCustomActionEventData$=new Ce(null),this.sidebarCustomActionEventDataAllChanges$=new Ce(null),this.sidebarCustomActionEventDataOnInit$=new Ce(null),this.customActions$=new Ce(!1),this.focusedThreadMode$=new Ce(!1),this.openAnnotationInFocusMode$=new Ce(!1),this.customStatusesShown$=new Ce(!1),this.readOnly$=new Ce(!1),this.customAutocompleteSearch$=new Ce(!1),this.deleteThreadWithFirstComment$=new Ce(!0),this.transformContext$=new Ce(null),this.expandMentionGroups$=new Ce(!1),this.showMentionGroupsFirst$=new Ce(!1),this.showMentionGroupsOnly$=new Ce(!1),this.fullScreenInSidebar$=new Ce(!1),this.composerFileAttachments$=new Ce(null),this.attachmentNameInMessage$=new Ce(!1),this.allowedFileTypes$=new Ce([]),this.forceCloseAllOnEsc$=new Ce(!1),this.autoCompleteScrollConfig$=new Ce({itemSize:55,minBufferPx:350,maxBufferPx:600,templateCacheSize:350}),this.getCommentAnnotationForClient=bt=>{try{let It=["commentCategories","color","resolved","inProgress","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","screenScrollTop","taggedElementPath","taggedElementRect","targetElement","position","documentParamsId","documentParams","ghostComment","areaAnnotationId","iam","commentSource","involvedUserIds","mentionedUserIds","viewedByUserIds","views"],yt=JSON.parse(JSON.stringify(bt)),Lt={};return Object.keys(yt).forEach(Yt=>{It.includes(Yt)||(Lt[Yt]=yt[Yt])}),Lt?.comments?.forEach(Yt=>{let zt=[];Yt?.reactionAnnotationIds&&Yt?.reactionAnnotationIds?.forEach(tn=>{let Ii=this.reactionService.getAnnotationById(tn);if(Ii){let nn=this.reactionService.getReactionAnnotationForClient(Ii);zt.push(nn)}}),Yt.reactionAnnotations=zt}),yt?.viewedByUserIds?.forEach(Yt=>{let zt=this.contactService.getUserBySnippylyId(Yt);zt&&(Lt.viewedBy||(Lt.viewedBy=[]),Lt.viewedBy.push(zt))}),this.user?.userSnippylyId&&(Lt.unread=!yt?.viewedByUserIds?.includes(this.user.userSnippylyId)),JSON.parse(JSON.stringify(Lt))}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(Bi(100),Oi()).subscribe(([bt,It])=>{try{if(this.draftCommentAnnotationsByAnnotationId$.value){let yt=Object.keys(this.draftCommentAnnotationsByAnnotationId$.value||{}),Lt=[];Object.keys(bt||{}).forEach(zt=>{!It?.[zt]&&yt.includes(zt)&&Lt.push(zt)});let Yt=JSON.parse(JSON.stringify(this.draftCommentAnnotationsByAnnotationId$.value||{}));Lt.forEach(zt=>{delete Yt[zt]}),hi(Yt,this.draftCommentAnnotationsByAnnotationId$.value)||this.draftCommentAnnotationsByAnnotationId$.next(Yt)}}catch{}}),this.docService.getDocumentPaths$().pipe(Oi()).subscribe(([bt,It])=>{bt?.documentId!==It?.documentId&&this.unreadCommentsMap$.next(null),It&&this.shouldEnableReadOnly()},bt=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",bt)}),this.authService.getUser$().subscribe(bt=>{bt||this.resetCacheData()},bt=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",bt)}),this.authService.getUser$().pipe(fe(bt=>bt?mn([this.iamService.isUserAdmin$(),this.contactService.getUserOrganizationContacts$()]).pipe(de(([It,yt])=>{let Lt=!1;return yt?.find(Yt=>Yt.userId===bt?.userId)&&(Lt=!0),{isUserAdmin:It,isOrgUser:Lt}})):le({isUserAdmin:!1,isOrgUser:!1}))).subscribe(({isUserAdmin:bt,isOrgUser:It})=>{let yt=bt||It;yt!==this.privateCommentAllowed$.value&&this.privateCommentAllowed$.next(yt)}),this.databaseService.getDb().pipe(Le(bt=>!!bt),rt(1)).subscribe(bt=>{bt&&this.getDocumentPaths()},bt=>{this.loggingService.catch("Error in CommentService getDb subscription: ",bt)}),this.domService.onWindowPointerMove$().subscribe(bt=>{if(this.addCommentMode$.value){let It=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let yt=this.domService.getBackgroundElement(bt.clientX,bt.clientY,!0,!0);if(yt&&Ice(yt,{x:bt.clientX,y:bt.clientY})&&(yt=yt?.parentElement),yt)if(this.isElementInsideAllowedElements(yt))if(Ip(bt.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==yt&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=yt;let Lt=this.domService.getSelectedAnnotationsMap("comment")||{},Yt=this.commentPinCursorImage$.value||U.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,Yt,!!Object.keys(Lt)?.length),It=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&It&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},bt=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",bt)}),this.domService.onWindowKeyupEsc$().subscribe(bt=>{if(this.addCommentMode$.value){let It=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(It)?.length&&this.domService.resetSelectedAnnotationsMap(),this.disableAddCommentMode()}},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",bt)}),this.domService.onDocumentClick$().subscribe(bt=>{if(bt?.target&&!Ki(bt?.target)){let It=this.domService.getSelectedAnnotationsMap("comment")||{};if(It=E(E({},It),this.domService.getSelectedAnnotationsMap("multiThread")||{}),Object.keys(It)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),bt.preventDefault(),bt.stopPropagation();return}}if(bt&&this.addCommentMode$.value&&!Ip(bt.target)){let It=!1;if(this.addCommentDragMode)bt.preventDefault(),bt.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let yt=this.domService.getBackgroundElement(bt.clientX,bt.clientY);if((this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(bt.clientX,bt.clientY)||bt?.target&&Ki(bt?.target))&&(yt=null),yt&&(this.isElementInsideAllowedElements(yt)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement(yt))&&(It=this.isElementInsideManualCommentContainer(yt),!It)){bt.preventDefault(),bt.stopPropagation();let Lt=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(bt,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,Lt)}}this.persistentCommentMode$?.value?this.detectToAddAreaComment():It||this.disableAddCommentMode()}},bt=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",bt)}),this.addCommentMode$.subscribe(bt=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),bt?(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(It=>It.unsubscribe()),this.clearFreeStyleCommentContext())},bt=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",bt)}),this.domService.onWindowKeyupBackspace$().subscribe(bt=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",bt)}),this.domService.onWindowKeyupDelete$().subscribe(bt=>{this.deleteCommentPinAnnotations("keyupDelete")},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",bt)}),this.domService.getDeleteCommmentAnnotations$().subscribe(bt=>{bt?.length&&(bt?.filter(yt=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes(yt.type))).forEach(yt=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(yt)}))},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",bt)}),this.getPopoverMode$().subscribe(bt=>{bt?document?.body?.setAttribute(U.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(U.ATTRIBUTES.VELT_POPOVER_MODE)},bt=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",bt)}),this.customFilterService.customCategoryMap$.subscribe(bt=>{this.customCategoryMap=bt},bt=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",bt)}),this.hotkeyEnabled$.subscribe(bt=>{bt?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},bt=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",bt)}),this.domService.getSelectedAnnotationsMap$().pipe(Oi()).subscribe(([bt,It])=>{try{let yt=Object.values(bt||{}).filter(Yt=>!["tag","recorder","rewriter","arrow","area"].includes(Yt.type)),Lt=Object.values(It||{}).filter(Yt=>!["tag","recorder","rewriter","arrow","area"].includes(Yt.type));yt?.forEach(Yt=>{Lt?.find(zt=>zt.annotationId===Yt.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(Yt),selected:!1})}),Lt?.forEach(Yt=>{yt?.find(zt=>zt.annotationId===Yt.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(Yt),selected:!0})})}catch(yt){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",yt)}},bt=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",bt)})}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.customAutocompleteSearch$.next(!1),this.hightlightElement=null,this.addCommentMode$.next(!1),this.unreadCommentsMap$.next(null),this.documentPaths=null,this.commentsFromSidebarMap$.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 r,a,s,c=null,p=null;this.dragSubscriptions.forEach(g=>g.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe(Le(g=>!Ki(g?.target)),rt(1)).subscribe(g=>{c=null,p=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(f=>{if(c===null){let I=f?.startPoint?.event?.target,x=Ki(I),B=Ip(I),z=this.isElementInsideAllowedElements(I);c=!x&&!B&&z}if(c){this.addCommentDragMode=!0,r=f.startPoint,a=f.curPoint;let I=f?.curPoint?.event?.target,x=Ki(I),B=Ip(I),z=this.isElementInsideAllowedElements(I);p=!x&&!B&&z,p?s=this.domService.drawRectangle(r,a):s?.remove()}})),this.domService.onWindowPointerUp$().pipe(ml(1),rt(1)).subscribe(f=>{if(a={x:f.clientX,y:f.clientY},r&&a&&(s?.remove(),c&&p)){let I=[{x:r.x-window.scrollX,y:r.y-window.scrollY},{x:a.x,y:a.y}],x=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(f,void 0,I,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,x)}this.dragSubscriptions.forEach(I=>I.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({})}catch(e){this.loggingService.catch("Error in CommentService resetCacheData: ",e)}}addAreaContainerTag(){try{if(!(document.querySelector(U.TAGS.VELT_AREAS)||document.querySelector(U.TAGS.SNIPPYLY_AREAS))){let t=document.createElement(U.TAGS.VELT_AREAS);document.body.appendChild(t)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${U.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(t=>{window.getComputedStyle(t).position==="static"&&t.setAttribute(U.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${U.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(t=>{t.removeAttribute(U.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:Ne.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:Ne.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:Ne.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:r,detectGhostComments:a,skipPositionCalculation:s,query:c,fromCommentSidebar:p,analytics:g,addFilterCommentsOnDomCheck:f}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let I,x,B;g?.enabled&&this.analyticsService.trackEvent(g?.eventName||Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,g?.properties);try{if(e&&(B=`${Nn(e)}`),t&&typeof t=="object"){let z=or(t);x=z?.id,I=Nn(JSON.stringify(z))}}catch(z){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",z)}return ei(this.afAuth).pipe(Le(z=>!!z),fe(z=>this.isFeatureAllowed({firebaseUser:z,annotations:[],filteredAnnotations:[]})),fe(z=>z.featureAllowed?this.iamService.isUserAllowed$().pipe(de(G=>(z.featureAllowed=G,z))):le(z)),fe(z=>z.featureAllowed?le(z).pipe(fe(G=>this.docService.getDocumentPaths$().pipe(de(J=>(this.documentPaths=J,G.documentPaths=J,G)))),fe(G=>c?.documentIds?.length||B?this.getDataFromDocumentIds({documentIds:B?[B]:c?.documentIds?.map(J=>`${Nn(J)}`),organizationId:this.documentPaths?.organizationId,query:c}).pipe(de(J=>({res:G,data:J}))):this.docService.getDocumentIds$().pipe(fe(J=>{let ne=J?.length>0?J.map(ve=>ve.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ne.length>0?ne:[B??""],organizationId:this.documentPaths?.organizationId,query:c}).pipe(de(ve=>({res:G,data:ve})))}))),fe(G=>G?.data?(G.res.annotations=G.data||[],le(G.res).pipe(fe(J=>this.docService.getLocation$().pipe(de(ne=>(J.location=ne,J)))),fe(J=>this.docService.getLocations$().pipe(de(ne=>(J.customLocations=ne,J)))),fe(J=>this.docService.getExcludedLocationIds$().pipe(de(ne=>(J.excludedLocationIds=ne,J)))),de(J=>{if(J.filteredAnnotations=[],c)return J.filteredAnnotations=J.annotations?.slice(),J;if(B&&!I||p)return J.filteredAnnotations=J.annotations?.slice(),J?.excludedLocationIds?.length&&(J.filteredAnnotations=J.filteredAnnotations?.filter(ne=>ne?.location?.id?!J.excludedLocationIds.includes(ne.location.id):!0)),J;{let ne=[],ve=[];return I?(ne.push(I),x&&ve.push(x)):(ne.push(J?.location?.locationId),ne.push(...Object.values(J?.customLocations||[]).map(_e=>_e.locationId)),J?.location?.location?.id&&ve.push(J?.location?.location?.id),ve.push(...Object.values(J?.customLocations||{}).map(_e=>_e.location?.id).filter(_e=>!!_e))),J.filteredAnnotations=this.filterAnnotationsByLocationIds(J?.annotations,ne,ve),J?.excludedLocationIds?.length&&(J.filteredAnnotations=J.filteredAnnotations?.filter(_e=>_e?.location?.id?!J.excludedLocationIds.includes(_e.location.id):!0)),J}}),fe(J=>this.isPrivateCommentAllowed$().pipe(de(ne=>(ne||(J.filteredAnnotations=J.filteredAnnotations?.filter(ve=>ve?.iam?.accessMode!==uo.PRIVATE)),J)))),fe(J=>this.draftCommentAnnotationsByAnnotationId$.pipe(de(ne=>(J.filteredAnnotations=J.filteredAnnotations?.filter(ve=>!ve.isDraft),ne&&J.filteredAnnotations.push(...Object.values(ne)),J)))),fe(J=>r?le(J):J?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(de(()=>J)):le(J)),fe(J=>r?le(J):this.addCommentMode$.pipe(fe(ne=>ne&&!this.getChangeDetectionInCommentMode()?le(J):J?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(de(()=>J)):le(J)))),de(J=>{if(!s){(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(J.filteredAnnotations=J.filteredAnnotations?.map(ve=>{let _e=Object.assign({},ve);return this.calculateCommentAnnotationPosition(_e,a),_e}));let ne={};J.filteredAnnotations?.forEach(ve=>{if(ve?.targetTextRange){let _e=this.domService.getElementFromTargetTextRange(ve?.targetTextRange);ne[ve.annotationId]=!!_e}}),J.textAnnotationsElementMap=ne}return J}),fe(J=>J?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(de(ne=>(this.updateUnreadAnnotationsMap(J?.annotations,ne),J))):le(J)))):le(null))):le(null)),de(z=>{try{return typeof z=="object"&&z?JSON.parse(JSON.stringify(z)):z}catch{return z}}),Ct((z,G)=>Xt(z?.filteredAnnotations,G?.filteredAnnotations)&&Xt(z?.textAnnotationsElementMap,G?.textAnnotationsElementMap)),fe(z=>z?z?.filteredAnnotations?le(z?.filteredAnnotations||[]):le([]):le(null)),fe(z=>f?this.filterCommentsUsingSidebarSettings(z):le(z)))}getAllMultiThreadCommentAnnotations(e,t,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let c,p;try{if(e&&(p=Nn(e)),t&&typeof t=="object"){let g=or(t);c=Nn(JSON.stringify(g))}}catch(g){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",g)}return ei(this.afAuth).pipe(Le(g=>!!g),fe(g=>this.isFeatureAllowed({firebaseUser:g,annotations:[],filteredAnnotations:[]})),fe(g=>g.featureAllowed?this.iamService.isUserAllowed$().pipe(de(f=>(g.featureAllowed=f,g))):le(g)),fe(g=>g.featureAllowed?le(g).pipe(fe(f=>this.docService.getDocumentPaths$().pipe(de(I=>(this.documentPaths=I,f.documentPaths=I,f)))),fe(f=>p?this.getMultiThreadDataFromDocumentIds([p]).pipe(de(I=>({res:f,data:I}))):this.docService.getDocumentIds$().pipe(fe(I=>{let x=I?.length>0?I.map(B=>B.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(x.length>0?x:[`${p}`]).pipe(de(B=>({res:f,data:B})))}))),fe(({res:f,data:I})=>I?(f.annotations=I||[],le(f).pipe(fe(x=>this.docService.getLocation$().pipe(de(B=>(x.location=B,x)))),fe(x=>this.docService.getLocations$().pipe(de(B=>(x.customLocations=B,x)))),fe(x=>this.docService.getExcludedLocationIds$().pipe(de(B=>(x.excludedLocationIds=B,x)))),de(x=>{if(x.filteredAnnotations=[],p&&!c)return x.filteredAnnotations=x.annotations?.slice(),x?.excludedLocationIds?.length&&(x.filteredAnnotations=x.filteredAnnotations?.filter(B=>B?.location?.id?!x.excludedLocationIds.includes(B.location.id):!0)),x;{let B=[],z=[];return c?B.push(c):(B.push(x?.location?.locationId),B.push(...Object.values(x?.customLocations||[]).map(G=>G.locationId)),x?.location?.location?.id&&z.push(x?.location?.location?.id),z.push(...Object.values(x?.customLocations||{}).map(G=>G.location?.id).filter(G=>!!G))),x.filteredAnnotations=this.filterAnnotationsByLocationIds(x?.annotations,B,z),x?.excludedLocationIds?.length&&(x.filteredAnnotations=x.filteredAnnotations?.filter(G=>G?.location?.id?!x.excludedLocationIds.includes(G.location.id):!0)),x}}),fe(x=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(de(B=>(x.filteredAnnotations=x.filteredAnnotations?.filter(z=>!z.isDraft),B&&x.filteredAnnotations.push(...Object.values(B)),x)))),fe(x=>r?le(x):x?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(de(()=>x)):le(x)),fe(x=>r?le(x):this.addCommentMode$.pipe(fe(B=>B&&!this.getChangeDetectionInCommentMode()?le(x):x?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(de(()=>x)):le(x)))),de(x=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(x.filteredAnnotations=x.filteredAnnotations?.map(B=>{let z=Object.assign({},B);return this.calculateCommentAnnotationPosition(z,a),z})),x)),fe(x=>x?.filteredAnnotations?le(x?.filteredAnnotations||[]):le([])))):le(null))):le(null)),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>(this.user=r,D(E({},t),{user:r}))))),fe(t=>ao(t.config,t.user,Ne.COMMENT)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocuments(e){let{documentIds:t,organizationId:r,query:a}=e;if(!this.configService?.getApiKey())return le(null);if(t?.some(I=>!I)||!this.documentPaths)return le(null);let s,c,p=[];if(a)a?.folderId&&(s=Ai(a?.folderId)),a?.locationId&&(p=[...p,a?.locationId]),a?.locationIds?.length&&(p=[...p,...a?.locationIds]),c=a?.statusIds;else{s=this.docService.getDocumentPaths()?.veltFolderId;let I=this.docService.getDocumentPaths()?.locationId;I&&(p=[...p,I])}let g=le([]),f={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(f.documentId=t?.length?t[0]:void 0,f.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let I=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()];this.loggingService.logContext("[CONTEXT] getDataFromDocuments called with docContextFields:",JSON.parse(JSON.stringify(I??"nil")));let x=[];for(let B=0;B<(I?.length??0);B+=U.LISTENER_CONTEXT_BATCH_SIZE)x.push(I?.slice(B,B+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);g=mn(x.map(B=>this.commonDbService.dbListener({feature:"allComments",properties:D(E({},f),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",r??this.documentPaths?.organizationId),lt("metadata.documentId","in",t),...c?.length?[lt("status.id","in",c)]:[],...s?[lt("metadata.veltFolderId","==",s)]:[],...p?.length?[lt("location.id","in",p)]:[],...B?.length?[lt("context.accessFields","array-contains-any",B)]:[]),to("lastUpdated","desc"),to("createdAt","desc")]})}).pipe(Ar()))).pipe(de(B=>ia(JSON.parse(JSON.stringify(B)))))}else{let I=[];for(let x=0;x<(t?.length??0);x+=U.LISTENER_BATCH_SIZE)I.push(t?.slice(x,x+U.LISTENER_BATCH_SIZE)??[]);g=mn(I.map(x=>this.commonDbService.dbListener({feature:"allComments",properties:D(E({},f),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",r??this.documentPaths?.organizationId),lt("metadata.documentId","in",x),...c?.length?[lt("status.id","in",c)]:[],...s?[lt("metadata.veltFolderId","==",s)]:[],...p?.length?[lt("location.id","in",p)]:[]),to("lastUpdated","desc"),to("createdAt","desc")]})}).pipe(Ar()))).pipe(de(x=>ia(JSON.parse(JSON.stringify(x)))))}return g.pipe(fe(I=>I?.data?le(I).pipe(fe(x=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:x,feature:"allComments"}).pipe(de(B=>({data:Object.values(B?.data||{}).filter(z=>typeof z=="object"),operation:B?.operation})))),de(({data:x,operation:B})=>{let z=x.reduce((G,J)=>{let ne=J.metadata?.documentId;return ne&&(G[ne]||(G[ne]=[]),G[ne].push(J)),G},{});return{data:x,documentMap:z,operation:B}}),de(({data:x,documentMap:B,operation:z})=>c?{data:x,documentMap:B,operation:z}:(x?.length&&(x?.forEach(G=>{this.sanitizeCommentAnnotation(G)}),this.setAnnotationIndex(x),this.updateAnnotationsForSelectAllContentMode(x),x.forEach(G=>{this.customFilterService.convertLegacyAnnotationStatus(G),this.customFilterService.convertLegacyPriority(G),this.customFilterService.convertLegacyCategory(G)})),{data:x,documentMap:B,operation:z})),Un(x=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",x),le([]))),Qt(({documentMap:x})=>{c||Object.entries(x??{}).forEach(([B,z])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(z)))})}),de(({data:x,documentMap:B,operation:z})=>({data:this.filterUserDraftComments(x),documentMap:B,operation:z})),de(({data:x,documentMap:B,operation:z})=>({data:this.removeDraftFlags(x),documentMap:B,operation:z})),fe(({data:x,documentMap:B,operation:z})=>c?le({data:x,documentMap:B,operation:z}):this.mergeDraftAnnotations(x).pipe(de(G=>({data:G,documentMap:B,operation:z})))),de(({data:x,documentMap:B,operation:z})=>{if(!c)if(z?.type==="removed"){if(z?.ids?.length){let G=this.commentAnnotationById$.value??{};z?.ids?.forEach(J=>{delete G?.[J]}),this.commentAnnotationById$.next(G)}}else Object.entries(B??{}).length?Object.entries(B??{}).forEach(([J,ne])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:J,annotations:ne})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return x})):le(null)))}fetchCommentAnnotations(e){return Q(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 r=this.configService?.getApiKey(),a=e?.organizationId??t?.clientOrganizationId,s=os(a??""),c=[];e?.allDocuments||(c=e?.documentIds?.map(z=>Dr(z??""))??this.docService.getDocumentIds()?.map(z=>z.documentId));let p=[];if(p.push(lt("metadata.organizationId","==",s)),p.push(lt("metadata.apiKey","==",r)),e?.folderId){let z=Ai(e?.folderId);p.push(lt("metadata.veltFolderId","==",z))}if(e?.locationId&&p.push(lt("location.id","==",e?.locationId)),c?.length&&p.push(lt("metadata.documentId","in",c)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");p.push(lt("resolvedByUserId","==",e?.resolvedBy))}if(e?.mentionedUserIds?.length){if(e?.order==="asc")throw new Error("Order by mentionedUserIds is not supported in ascending order.");p.push(lt("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.");p.push(lt("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.");p.push(lt("status.id","in",e?.statusIds))}let g=new Date().getTime();if(e?.createdAfter&&p.push(lt("createdAt",">=",e?.createdAfter)),e?.createdBefore&&p.push(lt("createdAt","<=",e?.createdBefore??g)),e?.updatedAfter&&p.push(lt("lastUpdated",">=",e?.updatedAfter??g)),e?.updatedBefore&&p.push(lt("lastUpdated","<=",e?.updatedBefore??g)),p.push(to("lastUpdated",e?.order??"desc"),to("createdAt",e?.order??"desc")),e?.pageToken){let z=yield lz(e?.pageToken??"","veltencrypttoken","veltencrypttoken");p.push(Spe(parseInt(z,10),"lastUpdated"))}let f=e?.pageSize??100;p.push(_m(f+1));let I=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:p,apiKey:r??"",organizationId:s}}),x=I.length>f;I=I.slice(0,f);let B=I?.reduce((z,G)=>(z[G?.annotationId]=G,z),{});return B=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:B,shouldAwait:!0}),B=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:B}),{data:Object.values(B??{}),hasMore:x}}catch(t){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",t),t}})}filterUserDraftComments(e){let t=this.authService.getUser();return e.filter(r=>(r.comments=r?.comments?.filter(a=>a?.from?.userId===t?.userId||!a?.isDraft),!!r?.comments?.length))}removeDraftFlags(e){return e.forEach(t=>delete t.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(de(t=>{let r=t||{};return e?.filter(a=>{r?.[a?.annotationId]&&delete r[a?.annotationId]}),r}),de(t=>{if(t){let r=e.slice();return r.push(...Object.values(t)),r}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:t,query:r}){return this.getDataFromDocuments({documentIds:e,organizationId:t,query:r})}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 le(null);let r=this.docService.getDocumentPaths()?.veltFolderId,a=le([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=t?.length?t[0]:void 0,s.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let c=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],p=[];for(let g=0;g<(c?.length??0);g+=U.LISTENER_CONTEXT_BATCH_SIZE)p.push(c?.slice(g,g+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);a=mn(p.map(g=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:D(E({},s),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",this.documentPaths?.organizationId),lt("metadata.documentId","in",t),...r?[lt("metadata.veltFolderId","==",r)]:[],...g?.length?[lt("context.accessFields","array-contains-any",g)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}else{let c=[];for(let p=0;p<(t?.length??0);p+=U.LISTENER_BATCH_SIZE)c.push(t?.slice(p,p+U.LISTENER_BATCH_SIZE)??[]);a=mn(c.map(p=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:D(E({},s),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",this.documentPaths?.organizationId),lt("metadata.documentId","in",p),...r?[lt("metadata.veltFolderId","==",r)]:[])]})}).pipe(Ar()))).pipe(de(p=>ia(p)))}return a.pipe(fe(c=>c?.data?le(c).pipe(de(p=>({data:p?.data,operation:p?.operation})),de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p??{}).filter(I=>typeof I=="object")),{data:f,operation:g}}),Un(p=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",p),le({data:[],operation:null}))),de(({data:p,operation:g})=>{p.forEach(I=>{delete I.isDraft});let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),fe(({data:p,documentMap:g,operation:f})=>{let I=[];return this.commentAnnotationById$.pipe(fe(()=>this.domService.getSelectedAnnotationsMap$().pipe(de(x=>({selectedAnnotationsMap:x})))),de(({selectedAnnotationsMap:x})=>{let B={};return Object.keys(g??{}).forEach(z=>{let G=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:z});G&&G?.forEach(J=>{B[J?.annotationId]=J})}),I=p.filter(z=>{let G=!1;if(z?.commentAnnotations){for(let J in z?.commentAnnotations)if(B?.[J]&&B?.[J]?.status?.id!==this.customFilterService.resolvedStatus.id){G=!0;break}}return G}),I.forEach(z=>{Object.keys(z?.commentAnnotations||{}).forEach(G=>{z.commentAnnotationsMap||(z.commentAnnotationsMap={}),z.commentAnnotationsMap[G]=B?.[G]})}),{data:I,operation:f}}))}),fe(({data:p,operation:g})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(de(f=>{let I=f||{};return p?.filter(x=>{I?.[x?.annotationId]&&delete I[x?.annotationId]}),I}),de(f=>{if(f){let I=p.slice();return I.push(...Object.values(f)),{data:I,operation:g}}return{data:p,operation:g}}))),de(({data:p,operation:g})=>{let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});if(g?.type==="removed"){if(g?.ids?.length){let I=this.multiThreadCommentAnnotationById$.value;g?.ids?.forEach(x=>{delete I?.[x]}),this.multiThreadCommentAnnotationById$.next(I)}}else Object.keys(f??{}).forEach(I=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:f[I]})});return p})):le(null)))}else return le(null)}updateUnreadAnnotationsMap(e,t){try{let r=new Date(U.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(s=>s?.lastUpdated>r);if(t){let s={},c=!1;a.forEach(p=>{let g=0,f=t?.[p?.annotationId];if(f){let I=f?.comments;I&&p?.comments?.forEach(x=>{I?.[x?.commentId]?.views?.[this.user?.userSnippylyId]||g++})}g?g!==s?.[p?.annotationId]&&(s[p?.annotationId]=g,c=!0):s?.[p?.annotationId]&&(delete s[p?.annotationId],c=!0)}),this.unreadCommentsMap$.next(s)}}catch(r){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",r)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(t=>{if(t?.selectAllContent&&t?.targetElementId){let r=ya(t.targetElementId,["id","data-id"]);if(r){let a=r.textContent;a&&(t.targetTextRange={commonAncestorContainer:this.domService.getXPath(r),text:a,occurrence:1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(r)??void 0},delete t?.targetElement)}}})}catch(t){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",t)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.commentAnnotationById$.value??{}),s);this.commentAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),de(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",r),le([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r=null;this.commentAnnotationById$.value&&(r={},Object.values(this.commentAnnotationById$.value).forEach(s=>{s?.metadata?.documentId==t&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)}));let a=this.draftCommentAnnotationsByAnnotationId$.value;return a&&(r===null&&(r={}),Object.values(a).forEach(s=>{s?.metadata?.documentId===t&&s?.metadata?.organizationId===e&&!r[s?.annotationId]&&(r[s?.annotationId]=s)})),r?Object.values(r):null}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getCommentAnnotationsByDocumentId$({clientDocumentId:e,documentId:t}){try{return e&&!t&&(t=this.docService.generateDocumentId(e)),t?this.docService.getDocumentPaths$().pipe(fe(r=>this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:r?.organizationId,documentId:t}))):le(null)}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByDocumentId$:",r),le(null)}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(fe(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):le([])))}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(r=>{r?.annotationId&&(t[r?.annotationId]=r)}),this.originalCommentAnnotationsByDocumentId$.next(E(E({},this.originalCommentAnnotationsByDocumentId$.value),t))}catch(t){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",t)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.multiThreadCommentAnnotationById$.value),s);this.multiThreadCommentAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){return this.multiThreadCommentAnnotationById$.pipe(de(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(s=>{s?.metadata?.documentId==t&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(s=>{s?.metadata?.documentId===t&&s?.metadata?.organizationId===e&&!r[s?.annotationId]&&(r[s?.annotationId]=s)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(fe(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):le([])))}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(fe(e=>this.docService.getLocations$().pipe(de(t=>({location:e,locations:t})))),de(e=>{let t=[];return t.push(e?.location?.locationId),t.push(...Object.values(e.locations||[]).map(r=>r.locationId)),t||[]}))}filterAnnotationsByLocationIds(e,t,r){try{return e.filter(a=>t.includes(a.locationId)||r?.includes(a?.location?.id)||t?.find(s=>s==a?.location?.id)||r?.find(s=>s==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in CommentService filterAnnotationsByLocations:",a),[]}}setAnnotationIndex(e){try{e.forEach((t,r)=>{t?.annotationId&&(t.annotationIndex=r+1)})}catch(t){this.loggingService.catch("Error in CommentService setAnnotationIndex:",t)}}calculateCommentAnnotationPosition(e,t){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let r=ya(e.targetElementId,["id","data-id"]);if(r&&this.domService.isElementVisible(r)){let a=r.getAttribute(U.ATTRIBUTES.VELT_COMMENT_TYPE),s=!0;if(a)switch(a){case"popover":s=!0;break;default:s=!1;break}else{let c=document.querySelector(`${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);c&&r?.contains(c)&&(s=!1)}s?e.targetElement={xpath:this.domService.getXPath(r),fXpath:this.domService.getXPath(r,!0),cfXpath:this.domService.getXPath(r,!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 r=e.targetElement?.xpath,a=null,s=e?.targetElement?.anchor;if(s){let p=this.domService.resolveAnchorRecord(s);p?.element&&this.domService.isElementVisible(p.element)&&Pi(p.element)&&(a=p.element)}else r&&(a=this.domService.getElementFromXPath(r),this.domService.isXpathWithId(r)||((!a||!this.domService.isElementVisible(a))&&e.targetElement?.cfXpath&&(r=e.targetElement?.cfXpath,a=this.domService.getElementFromXPath(r)),this.getDetectionStrategy()===Fk.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(r=e.targetElement?.fXpath,r&&(a=this.domService.getElementFromXPath(r)))));(!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 p=this.docService.getLocation();if(!pf({location:p?.location,locationId:p?.locationId},{location:e?.location,locationId:e?.locationId})){let g=this.docService.getAdditionLocationFromElement(a),f=g?this.docService.genarateLocationId(g):void 0;e?.location?.id&&e?.location?.id===g?.id||f&&f===e?.locationId?c=!1:c=!0}}if(c&&(e.ghostComment=null),!c&&a&&Pi(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let g=this.popoverMode$?.value?0:e.targetElement?.topPercentage,f=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:I,width:x}=Hg(a);e.position={top:I*(g||0)/100,left:x*(f||0)/100};let B=window.getComputedStyle(a).transform;if(B&&B!=="none")try{let z=new DOMMatrixReadOnly(B),G=Math.sqrt(z.a*z.a+z.b*z.b)||1,J=Math.sqrt(z.c*z.c+z.d*z.d)||1;(Math.abs(G-1)>.01||Math.abs(J-1)>.01)&&(e.position.parentScaleX=G,e.position.parentScaleY=J)}catch{}if(this.transformContext$.value){let{containerSelector:z,transforms:G}=this.transformContext$.value,J=document.querySelector(z);J&&J.contains(a)&&(e.position.transformContext=G)}}!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(r){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",r)}}addComment(e,t,r,a,s,c=[],p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve,be,Ie,Ae,Se){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let he=this.authService.getUser();if(he)if(he.isReadOnly||he.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{let Oe=new Zo;ve&&(Oe=E(E({},Oe),ve)),Oe.comments=[],ve?.comments?.length&&(Oe.comments=ve.comments.map(zt=>{let tn=new yd;return tn=E(E({},tn),zt),tn.from=he,tn.lastUpdated=new Date,tn.createdAt=this.timestamp,tn})),Oe.from=he,Oe.color=Oe?.color||U.DEFAULT_ANNOTATION_COLOR,Oe.lastUpdated=this.timestamp,Oe.createdAt=this.timestamp,Oe.sourceId=J,Oe.assignedTo=ve?.assignedTo||ne,Oe.customList=ve?.customList||[],Ie&&(Oe.targetElementId=Ie);let{topPositionX:Re,topPositionY:Zi}=this.domService.getTopLeftPosition();Oe.positionX=Re,Oe.positionY=Zi;let bt=this.domService.getCurrentWindowSizeValue();if(Oe.screenWidth=bt.screenWidth,Oe.screenHeight=bt.screenHeight,Oe.screenScrollHeight=bt.screenScrollHeight,Oe.taggedElementPath="",e&&(Oe.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,zt=>{if(this.getSvgAsImg()){let tn=zt?.closest(`[${U.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);tn&&tn instanceof HTMLElement&&(zt=tn)}if(this.getPopoverMode()){let tn=zt?.closest(`[${U.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(tn&&tn instanceof HTMLElement)return tn}return zt}),this.getCommentToNearestAllowedElement()&&Oe.targetElement?.xpath)){let zt=this.domService.getElementFromXPath(Oe.targetElement.xpath);if(zt&&!this.isElementInsideAllowedElements(zt)){let tn=this.getNearestAllowedElement(zt);if(tn)Oe.targetElement.xpath=this.domService.getXPath(tn),Oe.targetElement.fXpath=this.domService.getXPath(tn,!0),Oe.targetElement.cfXpath=this.domService.getXPath(tn,!0,!0),Oe.targetElement.anchor=this.domService.generateAnchorRecord(tn);else return}}if(t&&(Oe.targetTextRange=t),Oe?.targetElement?.xpath){let zt=this.domService.getXPath(Oe.targetElement.xpath);if(zt){let tn=zt.iterateNext();tn&&(Pi(tn)||(Oe.targetElement=null))}}this.customFilterService.defaultStatus&&!ve?.status&&(Oe.status=this.customFilterService.defaultStatus),Oe.pageInfo=Ni(),Oe.pageInfo&&(Oe.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let It=this.docService.getClientDocumentId(),yt=this.docService.getLocation()?.location;if(Fe&&(Oe.context=Fe&&dc(Fe),Oe.contextId=this.generateContextId(Oe.context)),this.commentContextProvider!==null){let zt=this.commentContextProvider(It,yt);zt&&(Oe.context=zt&&dc(zt),Oe.contextId=this.generateContextId(Oe.context))}if(a){Oe.sourceId=a?.sourceId;let zt=a?.targetElement,tn=a?.commentData;if(zt?.targetText)Oe.targetTextRange={commonAncestorContainer:"/html/body",text:zt.targetText,occurrence:zt?.occurrence||1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(document.body)??void 0};else if(zt?.elementId)if(Oe.targetElementId=zt.elementId,zt?.selectAllContent)Oe.selectAllContent=!!zt?.selectAllContent;else{let nn=ya(zt.elementId,["id","data-id"]);nn?Oe.targetElement={xpath:this.domService.getXPath(nn),fXpath:this.domService.getXPath(nn,!0),cfXpath:this.domService.getXPath(nn,!0,!0),anchor:this.domService.generateAnchorRecord(nn),topPercentage:50,leftPercentage:90}:Oe.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",anchor:this.domService.generateAnchorRecord(document.body),topPercentage:50,leftPercentage:90}}a?.status&&(Oe.status=a.status),a?.context&&(Oe.context=a.context?dc(a.context):a.context,Oe.contextId=this.generateContextId(Oe.context)),Oe.comments||(Oe.comments=[]);let Ii=this.authService.getUser();tn?.forEach(nn=>{let ti=new yd;ti.commentText=nn.commentText,ti.commentHtml=nn.commentHtml,ti.replaceContentHtml=nn.replaceContentHtml,ti.replaceContentText=nn.replaceContentText,ti.from=Ii,Oe.comments.push(ti)})}if(s&&(Oe.isPageAnnotation=!0),c?.length&&(Oe.comments=c),p&&(Oe.commentType="chart",Oe.metadata=p),f?.sourceId&&(Oe.sourceId=f.sourceId),Oe?.targetElement?.xpath&&!f){let zt=this.domService.getElementFromXPath(Oe.targetElement.xpath);zt&&(f=this.getInlineCommentSectionConfig(zt))}f?.targetInlineCommentElementId&&(Oe.targetInlineCommentElementId=f?.targetInlineCommentElementId,Oe.targetElementId=f.targetInlineCommentElementId,f?.config?.id&&(Oe.inlineCommentSectionConfig=f?.config));let Lt=!Oe?.comments?.length,Yt=!!(a?.openComment===!1||Ve);this.getPrivateCommentMode()&&(Oe?.iam||(Oe.iam=new BI),Oe.iam.accessMode=uo.PRIVATE),I&&(Oe.context=I.context?dc(I.context):I.context,Oe.commentType="manual",delete Oe.targetElement,Oe.contextId=this.generateContextId(Oe.context)),x&&(Oe.targetElementId=x.targetElementId,Oe.targetElement=x.targetElement),this.saveCommentToDb(Oe,r,Lt,Yt,g,B,z,_e,G,be,Ae,Se)}}catch(he){this.loggingService.catch("Error in CommentService addComment: ",he)}}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 r;e.targetElement?r=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?r=ya(e.targetElementId,["id","data-id"]):e.targetTextRange&&(r=this.domService.getElementFromTargetTextRange(e.targetTextRange));let a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[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=ya(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,r=!1,a=!1,s,c,p,g,f,I,x,B){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.COMMENT)&&this.docService.getDocumentPaths$().pipe(Le(z=>!!z),rt(1),fe(z=>(this.documentPaths=z,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(G=>!!G),rt(1),fe(G=>Q(this,null,function*(){if(this.documentPaths?.comment){e.annotationId=this.commonDbService.generateDocumentId();let J=this.docService.getClientDocumentId(),ne=this.docService.getLocation()?.location;if(p)e.multiThreadAnnotationId=p;else if(this.getMultiThread()){let Se=mm();e.targetElementId&&(Se=mm(e.targetElementId),e?.location?.id?Se=mm([e?.location?.id,e.targetElementId]):e?.locationId&&(Se=mm([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=Se}let ve={addContext:Se=>{Se.access&&(Se.accessFields=Qk(Se)),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:Se}),e.context=Se&&dc(Se),e.contextId=this.generateContextId(e.context),Se?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&setTimeout(()=>{this.updateCommentAnnotationContext(e.annotationId,Se)},200)},documentId:J,location:ne,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?ve.elementRef={xpath:e.targetElement.xpath}:ve.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(ve),this.commentAdded$.next(ve),f&&f(ve);let _e=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(ve);_e&&this.commentActionsService?.triggerAddCommentAnnotationEvent(_e),this.setLocationToCommentAnnotation(e);let Fe=this.getElementForCommentAnnotation(e),Ve=this.docService.getBaseMetadata("comment",{element:Fe,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!Ve?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=E(E({},e.metadata),Ve),I&&(e.metadata=E(E({},e.metadata),I)),s&&typeof s=="object"&&(e.locationId=g||this.docService.genarateLocationId(s),e.location=s,B||this.docService.addLocation({location:s})),r)window.localStorage.setItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let Se=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);Se&&JSON.parse(Se).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let be=e.comments,Ie=JSON.parse(JSON.stringify(e));if(Ie?.context?.access||(Ie?.context||(Ie.context={}),Ie.context.access={default:"velt"},Ie.context.accessFields=[...Ie.context.accessFields||[],U.DEFAULT_VELT_CONTEXT]),Ie.position=null,t){Ie.targetElement=null,Ie.targetTextRange=null;let Se={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?Ne.MULTI_THREAD:Ne.COMMENT},he=yield this.areaService.generateAreaAnnotationId();Ie.areaAnnotationId=he;let Oe=this.areaService.addArea(void 0,t,Se,he,{locationId:Ie.locationId,location:Ie.location},Ie.context);Oe&&(Ie.metadata=E(E({},Ie.metadata),Oe?.metadata||{}))}!a&&!Ie?.targetInlineCommentElementId&&!Ie?.isPageAnnotation&&this.domService.toggleAnnotationSelection(Ie,c),e.targetTextRange&&sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),Ie?.comments?.length?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e.annotationId,commentThreadId:Ie?.comments[0]?.commentId,commentType:this.getCommentType(Ie),commentMode:this.getCommentMode(),source:x??"internal"}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(Ie),commentMode:this.getCommentMode()});let Ae=this.getAnnotationNumber(e);Ae&&(Ie.annotationNumber=Ae),Ie?.comments?.length?Ie.comments=[]:Ie.isDraft=!0,Ie?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(Ie),Ie?.context&&(Ie.contextId=this.generateContextId(Ie.context)),be?.length?this.saveComment(Ie,{type:Wt.NEWLY_ADDED,updatedComment:be[0]}):this.draftCommentAnnotationsByAnnotationId$.next(D(E({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:Ie}))}})))))).subscribe(()=>{},z=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",z)})}catch(z){this.loggingService.catch("Error in CommentService saveCommentToDb: ",z)}}saveMultiThreadCommentAnnotation(e){return Q(this,null,function*(){try{if(e?.multiThreadAnnotationId){let t=this.docService.getDocumentPaths();if(this.databaseService.getDbValue()&&t?.multiThread){let r={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(s=>s.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,r=E(E({},a),r)),r?.commentAnnotations||(r.commentAnnotations={}),r.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(D(E({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[r.annotationId]:D(E({},r),{isDraft:!0})}));else{let c=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[r.annotationId];if(c&&(r=E(E({},r),c)),delete r.isDraft,r.commentAnnotationsMap={},!r?.metadata?.documentId){r?.metadata||(r.metadata={});let f=this.docService.getBaseMetadata();r.metadata=E(E({},r?.metadata),f)}let{documentId:p,organizationId:g}=r?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:r.annotationId,documentId:p,organizationId:g},data:JSON.parse(JSON.stringify(r)),callback:()=>{let f=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;f[e.annotationId]&&(delete f[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(f))}})}return r}}return null}catch(t){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",t),null}})}setCommentCategory(e){return Q(this,null,function*(){try{if(e?.comments?.length){let t=e.comments[0].commentText?.trim();if(t){let r=yield this.getCommentCategory(t).toPromise();if(r){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let s=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(c=>c.annotationId===e.annotationId);if(s||(s=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:e.annotationId}})),s?.annotationId){let c=s;c.commentCategories=[r];let{documentId:p,organizationId:g}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:p,organizationId:g,metadata:{apiKey:this.configService.getApiKey(),organizationId:g,veltFolderId:c?.metadata?.veltFolderId,documentId:p}},data:JSON.parse(JSON.stringify(c))})}}}}}}catch(t){this.loggingService.catch("Error in CommentService setCommentCategory: ",t)}})}getCommentCategory(e){try{let t=Ji(this.functions,eo({url:wn.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 io(t({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(de(s=>{if(s?.data){let c=s.data,p=c?.length?c[0]?.content?.trim():void 0;return p&&Object.keys(this.customCategoryMap).includes(p)?this.customCategoryMap[p]:void 0}else return}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentCategory: ",t),le(void 0)}}updateCommentAnnotationContext(e,t,r){return Q(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:t,merge:r?.merge});let a=this.authService.getUser(),s=this.docService.getDocumentPaths();if(a&&s?.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:s?.documentId??"",organizationId:s?.organizationId??"",id:e}})),c?.annotationId){let p=t,g=JSON.parse(JSON.stringify(c.context||{}));r?.merge&&(p=E(E({},g),t)),p&&typeof p=="object"&&("access"in t?t.access!==null&&t.access!==void 0?p.accessFields=Qk(p):(delete p.access,delete p.accessFields):(!r?.merge&&g?.access&&(p.access=g.access),p.access!==null&&p.access!==void 0&&(p.accessFields=Qk(p))));let f={context:JSON.parse(JSON.stringify(p||{}))};if(f?.context?.commentType==="manual"&&(f.commentType="manual",f.targetElement=null),c.context=f.context?dc(f.context):f.context,c.contextId=this.generateContextId(c.context),hi(g,p))return Promise.resolve("Comment annotation context is already updated.");{let{documentId:I,organizationId:x}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);return this.commonDbService.setData({feature:"comment",properties:{id:e,documentId:I,organizationId:x,metadata:{apiKey:this.configService.getApiKey(),organizationId:x,veltFolderId:c?.metadata?.veltFolderId,documentId:I}},data:JSON.parse(JSON.stringify(c)),callback:()=>{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:f?.context,merge:r?.merge})}})}}else return this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:t,merge:r?.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,r,a,s,c){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.COMMENT)){if(t&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let p=this.domService.getXPath(e.targetElement.xpath);if(p){let g=p.iterateNext();g&&(Pi(g)||(e.targetElement=null))}}if(e?.type==="multiThread"){let p=JSON.parse(JSON.stringify(e));if(p.position=null,p.ghostComment=null,!p?.metadata?.documentId){p?.metadata||(p.metadata={});let I=this.docService.getBaseMetadata();p.metadata=E(E({},p?.metadata),I)}let{documentId:g,organizationId:f}=p?.metadata||{};r?this.commonDbService.updateData({feature:"multiThread",properties:{id:p.annotationId,documentId:g,organizationId:f},data:JSON.parse(JSON.stringify(p))}):this.commonDbService.setData({feature:"multiThread",properties:{id:p.annotationId,documentId:g,organizationId:f},data:JSON.parse(JSON.stringify(p))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let p=JSON.parse(JSON.stringify(e));p.position=null,p.ghostComment=null,p.lastUpdated=this.timestamp,p.status||(p.status=this.customFilterService.defaultStatus),delete p.resolved,delete p.inProgress,this.setLocationFromDocumentParams(p);let g=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(g&&JSON.parse(g).annotationId===p.annotationId&&window.localStorage.removeItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),p?.multiThreadAnnotationId&&!s&&this.saveMultiThreadCommentAnnotation(p).then(f=>{}),p?.comments?.length){if(delete p?.isDraft,p?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[p?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(p),!p?.metadata?.documentId){p?.metadata||(p.metadata={});let B=this.docService.getBaseMetadata();p.metadata=E(E({},p?.metadata),B)}let{documentId:f,organizationId:I}=p?.metadata||{},x=a?E({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;this.viewsService.updateCommentAnnotationViews(p),this.commonDbService.setData({feature:"comment",properties:{id:p.annotationId,documentId:f,targetCommentId:c?.commentId,organizationId:I,metadata:{apiKey:this.configService.getApiKey(),organizationId:I,veltFolderId:p?.metadata?.veltFolderId,documentId:f}},extraData:x,data:JSON.parse(JSON.stringify(p)),callback:B=>{a&&!B?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{}),this.getScreenshotEnabled()&&a?.actionType===Wt.NEWLY_ADDED&&this.captureScreenshot(e)}})}else this.draftCommentAnnotationsByAnnotationId$.next(D(E({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:p}))}}}catch(p){this.loggingService.catch("Error in CommentService updateComment: ",p)}}captureScreenshot(e){return Q(this,null,function*(){try{if(this.getScreenshotEnabled()){let r=Ji(this.functions,eo({url:wn.cloudFunction.screenshot,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a,s={source:"velt",sourceData:{commentAnnotation:e},eventType:"screenshot"};e?.areaAnnotationId&&(a=this.areaService.getAnnotationById(e?.areaAnnotationId),a&&(s.sourceData||(s.sourceData={}),s.sourceData.areaAnnotation=a));let c=yield Dl(s,this.authService.getUser()?.userId??"");yield r({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,r)=>Q(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),s=this.authService.getUser(),c=[];Object.keys(a).forEach(p=>{let g=a[p];["tag","recorder","rewriter","arrow","area","multiThread"].includes(g.type)||s&&g.from&&(s?.isAdmin||g.from.userId===s.userId)&&c.push(g)}),c?.length?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:c.map(p=>p.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(La,{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"}}).afterClosed().pipe(rt(1)).subscribe(p=>{try{p?(c.forEach(g=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(g)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(f=>{this.domService.removeHighlightFromElement(f)}),t()},100)):t()}catch(g){r(g)}},p=>{r(p)})):t(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),r(a)}}))}deleteCommentPinAnnotation(e,t){return Q(this,null,function*(){try{if(setTimeout(()=>{if(this.draftCommentAnnotationsByAnnotationId$?.value?.[e.annotationId]){let r=this.draftCommentAnnotationsByAnnotationId$.value;delete r[e.annotationId],this.draftCommentAnnotationsByAnnotationId$.next(r)}},50),this.authService.isFeatureAllowed(Ne.COMMENT))if((t||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Wt.DELETED),e.comments?.forEach(r=>{r.reactionAnnotationIds&&r.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 r=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);r&&JSON.parse(r).annotationId===e.annotationId&&window.localStorage.removeItem(U.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:s,organizationId:c}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);return e?.isDraft?Promise.resolve():this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:s,organizationId:c,metadata:{apiKey:this.configService.getApiKey(),organizationId:c,veltFolderId:e?.metadata?.veltFolderId,documentId:s}}})}else return Promise.resolve();return Promise.resolve()}catch(r){return this.loggingService.catch("Error in CommentService deleteCommentPinAnnotation: ",r),Promise.resolve()}})}removeCommentAnnotationFromMultiThread(e){return Q(this,null,function*(){try{let t=e?.multiThreadAnnotationId;if(t){let r=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(t);if(!a){let g=e?.metadata?.documentId||r?.documentId,f=e?.metadata?.organizationId||r?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:g,organizationId:f,id:t}})}let s=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t];a&&delete a?.commentAnnotations?.[e.annotationId],s&&(delete s?.commentAnnotations?.[e.annotationId],Object.keys(s?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:c,organizationId:p}=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:p}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:p},data:JSON.parse(JSON.stringify(a))})}}catch(t){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",t)}})}getAnnotationById(e,t){try{let r=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in CommentService getAnnotationById: ",r);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 r=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in CommentService getAnnotationById: ",r);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 r=t?.targetElement?.xpath;if(r)return{xpath:r}}return}catch(t){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",t);return}}scrollToCommentByAnnotationId(e){try{let t=this.getAnnotationById(e),r=document.getElementById(`comment-pin-container-${e}`);r||(r=document.querySelector(`[data-velt-id='${e}']`)),r||(r=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),r&&(r.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 r=e?this.getAnnotationById(e):void 0;r?this.domService.toggleAnnotationSelection(r,void 0,void 0,!0):this.domService.resetSelectedAnnotationsMap()}catch(r){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",r)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(Ne.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([go.ADMIN,go.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:Ne.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:Ne.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()}showCommentIndex(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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,r=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(U.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),t&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||t||r)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1)),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: ",`<${U.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)):(document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(U.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: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableStatus: ",t)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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 r=[...this.bubbleCommentAnnotationIds$.value||[],...e],a=[...new Set(r)];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 r=(this.bubbleCommentAnnotationIds$.value||[]).filter(a=>!e.includes(a));this.bubbleCommentAnnotationIds$.next(r)}catch(t){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",t)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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()}addCommentOnElement(e){this.addComment(void 0,void 0,void 0,e)}enablePrivateCommentMode(){return Q(this,null,function*(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.isPrivateCommentAllowed$().pipe(rt(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:Ne.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()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}enableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}setExcludeLocationIdsFromSidebar(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}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:Ne.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:Ne.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()}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,r){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(a=>(!r&&t&&(r=ya(t,["id","data-id"])),le(D(E({},a),{element:r})))),fe(a=>this.getLocations$().pipe(de(s=>D(E({},a),{locationIds:s})))),de(({locationIds:a,element:s})=>{let c=[],p=this.docService.getDocumentPaths();if(p?.documentId){let g=this.docService.getAdditionalDocumentIdFromElement(s),f=g?this.docService.generateDocumentId(g):p?.documentId,I=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:p?.organizationId,documentId:f||""});if(I)for(let x of I)(t&&x?.targetElementId===t||x?.targetElement?.xpath===e)&&a?.includes(x?.locationId)&&c.push(x)}return c.length?c:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),le(null)}}getCommentAnnotationsByContext({context:e,contextOptions:t,element:r,clientDocumentId:a}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$()),de(()=>{let s=null,c=this.docService.getDocumentPaths(),p=dc(e),g=this.generateContextId(p);if(c?.documentId){let f=a||this.docService.getAdditionalDocumentIdFromElement(r??null),I=f?this.docService.generateDocumentId(f):c?.documentId,x=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:c?.organizationId,documentId:I||""});if(x){s=[];for(let B of x)t?.partialMatch?Lk(B?.context,p)&&s.push(B):g&&B?.contextId===g&&s.push(B)}}return s}))}catch(s){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",s),le(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(de(()=>this.getAnnotationById(e)),fe(t=>t?t?.iam?.accessMode===uo.PRIVATE?this.isPrivateCommentAllowed$().pipe(de(r=>{if(r)return t})):le(t):le(t)),fe(t=>t?this.filterCommentsUsingSidebarSettings(t).pipe(de(r=>{if(r)return r})):le(t)))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",t),le(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(de(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let t=document.querySelector(`${U.TAGS.VELT_COMMENT_BUBBLE}[${U.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return t||(t=document.querySelector(`${U.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${U.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(fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,sectionId:e})))),fe(t=>{let r=ya(e,["id","data-id"]);if(r){let a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.genarateLocationId(a);return this.docService.getLocations$().pipe(de(c=>{let g=Object.values(c||{}).find(f=>f.locationId===s||a?.id&&f.location.id===a.id);return D(E({},t),{additionalLocation:g,locationOnElement:!!a})}))}}return le(D(E({},t),{additionalLocation:null,element:r}))}),fe(t=>t?.locationOnElement?le(t):this.docService.getLocation$().pipe(de(r=>D(E({},t),{location:r})))),de(({documentPaths:t,location:r,additionalLocation:a,locationOnElement:s,element:c})=>{let p=null;if(this.authService.getUser()&&t?.documentId){let f=this.docService.getAdditionalDocumentIdFromElement(c),I=f?this.docService.generateDocumentId(f):t?.documentId,x=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:I||""});if(x){p=[];let B=mm(e);s?a?.location?.id?B=mm([a?.location?.id,e]):a?.locationId&&(B=mm([a?.locationId+"",e])):r&&(r?.location?.id?B=mm([r?.location?.id,e]):r?.locationId&&(B=mm([r?.locationId+"",e])));for(let z of x)z?.multiThreadAnnotationId===B?p.push(z):(z?.targetInlineCommentElementId===e||z?.targetElementId===e)&&(s?a&&pf({location:a?.location,locationId:a?.locationId},{location:z.location,locationId:z.locationId})&&p.push(z):r?pf({location:r?.location,locationId:r?.locationId},{location:z.location,locationId:z.locationId})&&p.push(z):z?.locationId||p.push(z))}}return p}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),le(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(fe(()=>this.multiThreadCommentAnnotationById$),fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,multiThreadAnnotationId:e})))),de(({documentPaths:t,location:r,additionalLocation:a,locationOnElement:s})=>{let c=null;if(t?.documentId){let p=this.getMultiThreadAnnotationById(e),{documentId:g,organizationId:f}=p?.metadata||{documentId:t?.documentId,organizationId:t?.organizationId},I=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:f,documentId:g||""});if(I){c=[];for(let x of I)x?.multiThreadAnnotationId===e&&p?.commentAnnotations?.[x?.annotationId]&&c.push(x)}}return c}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),le(null)}}getCommentAnnotationsByAnnotationIds(e){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,annotationIds:e})))),de(({documentPaths:t})=>{let r=null;if(t?.documentId){let a=this.commentAnnotationById$.value?Object.values(this.commentAnnotationById$.value):[],s=this.draftCommentAnnotationsByAnnotationId$.value?Object.values(this.draftCommentAnnotationsByAnnotationId$.value):[];if(a=[...a,...s],a){r=[];for(let c of a)e.includes(c?.annotationId)&&r.push(c)}}return r}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByAnnotationIds: ",t),le(null)}}getCommentAnnotationsByFolderId({folderId:e,veltFolderId:t}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$()),de(()=>{e&&!t&&(t=Ai(e));let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=null;if(r&&a?.documentId){this.commentAnnotationById$.value&&(s={},Object.values(this.commentAnnotationById$.value).forEach(p=>{p?.metadata?.folderId==e&&p?.metadata?.veltFolderId==t&&(s[p?.annotationId]=p)}));let c=this.draftCommentAnnotationsByAnnotationId$.value;c&&(s===null&&(s={}),Object.values(c).forEach(p=>{p?.metadata?.folderId==e&&p?.metadata?.veltFolderId==t&&!s[p?.annotationId]&&(s[p?.annotationId]=p)}))}return s?Object.values(s):null}))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByFolderId: ",r),le(null)}}getCommentAnnotationsForCommentComponent(e){try{let{annotationId:t,folderId:r,veltFolderId:a,targetElementId:s,clientDocumentId:c,documentId:p,context:g,contextOptions:f,element:I,type:x,sectionId:B,locationId:z}=e||{};if(c&&!p&&(p=this.docService.generateDocumentId(c)),r&&!a&&(a=Ai(r)),t)return this.getCommentAnnotationByAnnotationId(t).pipe(de(J=>J?[J]:null));let G=[];if(s&&(x==="pin"||x==="tool"||x==="bubble")){let J=ya(s,["id","data-id"]);if(J){let ne=J,ve=this.domService.getXPath(J);G.push(this.getCommentAnnotationAvailableOnXPath(ve,s,ne))}}return B&&G.push(this.getCommentAnnotationsBySectionId(B)),g&&G.push(this.getCommentAnnotationsByContext({context:g,contextOptions:f,element:I,clientDocumentId:c})),p&&G.push(this.getCommentAnnotationsByDocumentId$({documentId:p})),r&&G.push(this.getCommentAnnotationsByFolderId({folderId:r,veltFolderId:a})),G.length===0?le(null):mn(G).pipe(de(J=>{let ne=J.filter(_e=>_e!==null&&Array.isArray(_e));if(ne.length===0)return null;if(ne.length===1){let _e=ne[0];return z&&_e?.length?_e.filter(Ve=>Ve?.location?.id===z):_e}let ve=ne[0];for(let _e=1;_e<ne.length;_e++){let Fe=ne[_e];ve=ve.filter(Ve=>Fe.some(Ie=>Ie.annotationId===Ve.annotationId))}return z&&ve?.length&&(ve=ve.filter(_e=>_e?.location?.id===z)),ve}),Ct(Xt))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsForCommentComponent: ",t),le(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 r=0;r<t.length;r++){let a=t[r];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,U.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",t),!1}}saveComment(e,t){return Q(this,null,function*(){try{t?.annotation&&(e=t.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let r=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(r?.comments?.length){let f=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],r.comments?.forEach(I=>{let x=f.find(B=>B.commentId===I.commentId);x?e.comments.push(x):e.comments.push(I)})}e.comments||(e.comments=[]);let a=!1,s=!1,c;switch(t.type){case Wt.NEWLY_ADDED:case Wt.ADDED:if(!t.updatedComment)break;e?.comments?.length||(s=!0),e.comments.push(t.updatedComment);let f=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:t.type,otherFields:{assigned:f}};break;case Wt.APPROVED:e.approved=!0,c={commentAnnotation:e,targetComment:null,actionType:Wt.APPROVED};break;case Wt.ASSIGNED:e.assignedTo=t.assignedTo,c={commentAnnotation:e,targetComment:null,actionType:Wt.ASSIGNED};break;case Wt.UPDATED:if(!t.updatedComment)break;let I=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);if(I>=0){e.comments[I]=t.updatedComment,e.comments[I].status=Wt.UPDATED;let ne=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.UPDATED,otherFields:{assigned:ne}}}break;case Wt.REACTION_ADDED:if(!t.updatedComment)break;let x=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);x>=0&&(e.comments[x]=t.updatedComment,e.comments[x].status=Wt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.REACTION_ADDED});break;case Wt.REACTION_DELETED:if(!t.updatedComment)break;let B=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);B>=0&&(e.comments[B]=t.updatedComment,e.comments[B].status=Wt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.REACTION_DELETED});break;case Wt.STATUS_CHANGED:e.status.type==="terminal"&&(this.domService.resetSelectedAnnotationsMap(!1,"comment"),e.resolvedByUserId=this.authService.getUser()?.userId),c={commentAnnotation:e,targetComment:null,actionType:Wt.STATUS_CHANGED,otherFields:{oldStatus:t.oldStatus,newStatus:t.newStatus}};break;case Wt.PRIORITY_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.PRIORITY_CHANGED,otherFields:{oldPriority:t.oldPriority,newPriority:t.newPriority}};break;case Wt.ACCESS_MODE_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:t.oldAccessMode,newAccessMode:t.newAccessMode}};break;case Wt.CUSTOM_LIST_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:t.oldCustomList,newCustomList:t.newCustomList}};break;case Wt.SUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Wt.SUBSCRIBED};break;case Wt.UNSUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Wt.UNSUBSCRIBED};break;case Wt.DELETED:if(!t.updatedComment)break;let z=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);if(z>=0){if((z===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!t.skipDeleteThreadConfirmation){let _e={};if(this.deleteReplyConfirmation$.value&&(z!==0||this.deleteThreadWithFirstComment$.value===!1)?_e={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply"}:_e={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment"},!(yield this.dialog.open(La,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:_e}).afterClosed().toPromise()))return}let ne=e.comments.splice(z,1),ve=e.metadata;ne?.length&&ne.forEach(_e=>{_e?.attachments&&_e.attachments.forEach(Fe=>{let Ve={attachmentId:Fe.attachmentId,organizationId:ve?.organizationId??null,documentId:ve?.documentId??null,folderId:ve?.folderId??null,commentAnnotationId:e.annotationId,apiKey:ve?.apiKey??null};this.deleteAttachment({attachment:Fe,metadata:Ve})}),_e?.reactionAnnotationIds&&_e.reactionAnnotationIds.forEach(Fe=>{this.deleteReaction(Fe)})})}e.status=this.customFilterService.defaultStatus,z===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:Wt.DELETED});break;case Wt.ACCEPTED:let G={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Wt.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(G),c={commentAnnotation:e,targetComment:null,actionType:Wt.ACCEPTED};break;case Wt.REJECTED:let J={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Wt.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(J),this.domService.resetSelectedAnnotationsMap(),c={commentAnnotation:e,targetComment:null,actionType:Wt.REJECTED};break;default:break}if(e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null),t?.updatedComment?.isDraft&&(c=void 0),a)this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment");else{if(s&&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===Wt.ADDED||t.type===Wt.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e])}let p=this.getCustomPinById(e.annotationId),g={type:t.type,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e.annotationId,targetCommentId:t.updatedComment?.commentId,updateContext:(f,I)=>{this.updateCommentAnnotationContext(e.annotationId,f,I)}};p!==void 0&&(g.element=p),delete g?.annotation?.pageInfo,delete g?.annotation?.targetElement,delete g?.annotation?.targetTextRange,g?.type===Wt.DELETED&&(e.comments?.length||(g.annotation=null)),a||this.commentUpdated$.next(g)}catch(r){this.loggingService.catch("Error in CommentService saveComment: ",r)}})}attachComment(e,t=[],r,a,s,c,p,g){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let f;if(e){let I=ya(e,t);I&&(f={targetElement:{xpath:this.domService.getXPath(I),topPercentage:50,leftPercentage:90},targetElementId:e})}(f||r||s)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,c,void 0,void 0,f,g,void 0,void 0,a,void 0,void 0,void 0,r,void 0,s,void 0,void 0,p)}catch(f){this.loggingService.catch("Error in CommentService attachComment: ",f)}}generateComponentIdFromObject(e){try{let t=dc(e||{});return Tt(JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CommentService generateComponentIdFromObject: ",t);return}}updateNotificationsDatabase(e,t,r,a={}){try{let s=E({annotationData:e,targetAnnotationData:t,actionType:r,notificationSource:"comment"},a);this.notificationService.updateNotificationDatabase(s)}catch(s){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",s)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}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 r=!1,a=e?.targetElement?.anchor;if(!t&&a){let s=this.domService.resolveAnchorRecord(a);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(t=s.element)}!t&&e?.targetElement?.xpath&&(r=this.domService.isXpathWithId(e?.targetElement?.xpath),t=this.domService.getElementFromXPath(e?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null)),r||(!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&&!Pi(t)&&(t=null),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),null}}getElementFromComments(e){try{let t=[],r=null;if(e?.ghostComment)!r&&e.ghostComment?.targetElement?.fXpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e.ghostComment?.targetElement?.cfXpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e.ghostComment?.targetElement?.xpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),r&&!this.domService.isElementVisible(r)&&(r=null));else{let a=!1,s=e?.targetElement?.anchor;if(!r&&s){let c=this.domService.resolveAnchorRecord(s);c?.element&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(r=c.element)}!r&&e?.targetElement?.xpath&&(a=this.domService.isXpathWithId(e?.targetElement?.xpath),r=this.domService.getElementFromXPath(e?.targetElement?.xpath),r&&!this.domService.isElementVisible(r)&&(r=null)),a||(!r&&e?.targetElement?.cfXpath&&(r=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e?.targetElement?.fXpath&&(r=this.domService.getElementFromXPath(e?.targetElement?.fXpath),r&&!this.domService.isElementVisible(r)&&(r=null)))}return r&&!Pi(r)&&(r=null),e?.targetElementId&&(t=Array.from(rce(e.targetElementId,["id","data-id"]))),r&&!t.includes(r)&&t.push(r),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),[]}}getGhostCommentTargetElement(e){try{let t=e.targetElement?.fXpath||e.targetElement?.xpath,r=null;if(t)for(;!r&&t;)r=this.domService.getElementFromXPath(t),r&&(!this.domService.isElementVisible(r)||!Pi(r))&&(r=null),r||(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=Tl.ELEMENT_DELETED;let t=e?.pageInfo?.deviceInfo?.deviceType,r=new Yn().getDeviceType();t&&t!==r&&(e.ghostComment.type=Tl.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${t}.`,[mr.MOBILE,mr.TABLET].includes(t)&&[mr.MOBILE,mr.TABLET].includes(r)||[mr.DESKTOP,mr.MONITOR].includes(t)&&[mr.DESKTOP,mr.MONITOR].includes(r)?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||{},r=t[e?.annotationId]||{};hi(e.ghostComment,r)||(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(Ct(Xt))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>t?{count:t[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(de(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(de(e=>e?{count:Object.values(e).reduce((r,a)=>r+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>{if(t){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),a&&Object.keys(t).forEach(c=>{a?.find(g=>g.annotationId===c)?.location?.id===e&&(s+=t[c])})),{count:s}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>{if(t){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),Object.keys(t).forEach(c=>{t[c]&&a?.find(g=>g.annotationId===c)?.location?.id===e&&(s+=1)})),{count:s}}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;if(t){for(let r of e)if(t?.id!==r?.status?.id){let a=JSON.parse(JSON.stringify(r||{}));r.status=this.customFilterService.resolvedStatus;let s={annotation:r,type:Wt.STATUS_CHANGED,oldStatus:a.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(r,s)}}}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:Ne.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:Ne.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 Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addManualComment","color: green;"),new Promise((t,r)=>{let a=this.domService.getLastDocumentClick()?.target,s=e?.location||this.docService.getAdditionLocationFromElement(a);if(s?.id){let c=this.docService.getLocationByClientLocationId(s.id);c&&(s=c)}this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,s,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=Ni(),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 r=`${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`;this.documentPaths?.organizationId&&(r=`${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${U.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:r,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(U.URL_PARAMS.COMMENT_ID),t.searchParams.append(U.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(Ne.COMMENT)){let t=this.domService.getRange();if(window.getSelection()?.toString()&&!Kk()&&t?.commonAncestorContainer&&this.isElementInsideAllowedElements(t.commonAncestorContainer)&&!Ip(t.commonAncestorContainer)){let r=t?this.domService.getTargetTextRangeFromSelectionRange(t):void 0;this.domService.clearTextSelection(),setTimeout(()=>{this.addComment(void 0,r)},100)}}}catch(e){this.loggingService.catch("Error in CommentService addCommentOnSelectedText: ",e)}}getInlineCommentSectionConfig(e){try{let t;if(e){let r=e?.closest(`[${U.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(r){let a=r.getAttribute(U.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(t={},t.targetInlineCommentElementId=a,r.getAttribute(U.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(t.config=JSON.parse(r.getAttribute(U.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={},r=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(s=>{let c=e.subscribedUsers?.[s];c?.type==="manual"&&(t[s]=c)}),e?.assignedTo?.userId){let s=Tt(e?.assignedTo?.userId);r[s]||t[s]?.type!=="manual"&&(t[s]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(s=>!s?.isDraft)?.forEach(s=>{if(s?.from?.userId){let c=Tt(s?.from?.userId);r[c]||t[c]?.type!=="manual"&&(t[c]={user:s?.from,type:"auto"})}s?.to?.forEach(c=>{if(c?.userId){let p=Tt(c.userId);r[p]||t[p]?.type!=="manual"&&(t[p]={user:c,type:"auto"})}}),s?.toOrganizationUserGroup?.forEach(c=>{if(c?.groupId)a[c?.groupId]={type:"auto"};else if(c?.clientGroupId){let p=Tt(c.clientGroupId);a[p]={type:"auto"}}})}),e.subscribedUsers=t,e.unsubscribedUsers=r,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(fe(()=>{let{annotationId:t,documentId:r}=e;if(r){let a=Nn(r).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(de(s=>s.find(p=>p.annotationId===t)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let s=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(s){let c=s.find(p=>p.annotationId===t);return le(c||null)}}}return le(null)}),Un(t=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",t),le(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(de(t=>t?.data),de(t=>{let r=[];return t&&(r=Object.values(t??{}).filter(a=>typeof a=="object")),r})):le([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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,r,a,s){try{this.sidebarCustomActionEventData$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s})}catch(c){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",c)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,t){try{this.sidebarData$.next({data:e,options:t})}catch(r){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",r)}}getSidebarCustomData(){return this.sidebarData$.asObservable()}setSidebarCustomActionEventDataAllChanges(e,t,r,a,s){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s});let c=yield this.metadataService.getGlobalMetadata(),p={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:r,commentAnnotations:t,systemFilteredAnnotations:a,metadata:c,customFilters:s};this.commentActionsService?.triggerAction(zi.COMMENT_SIDEBAR_DATA_UPDATE,p)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",c)}})}setSidebarCustomActionEventDataOnInit(e,t,r,a,s){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s});let p={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:r,commentAnnotations:t,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()},customFilters:s};this.commentActionsService?.triggerAction(zi.COMMENT_SIDEBAR_DATA_INIT,p)}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?hi(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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:r}=e||{},a=null;t&&(a={},t.forEach(c=>{c?.annotationId&&a&&(a[c.annotationId]=c)}));let s={};t===void 0?s.data=this.commentsFromSidebarMap$.value?.data:s.data=a,r===void 0?s.sidebarVisible=this.commentsFromSidebarMap$.value?.sidebarVisible:s.sidebarVisible=r,hi(this.commentsFromSidebarMap$.value,s)||this.commentsFromSidebarMap$.next(s)}catch(t){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",t)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}setSidebarButtonCountType(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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),r;return t?r=e||[]:e?r=[e]:r=[],this.getFilterCommentsOnDom$().pipe(fe(a=>a?r.length===0?le(e):this.getCommentsFromSidebarMap$().pipe(de(s=>{if(!s?.sidebarVisible)return e;let c=r.filter(p=>p?.isDraft||!!s?.data?.[p?.annotationId]);return t?c:c.length>0?c[0]:null})):le(e)))}catch{return le(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:Ne.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:Ne.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:Ne.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:Ne.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 Q(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,r=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():r.forEach(s=>{a[e.userId]?.documents?.[s]?.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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||Ne.COMMENT,config:e})}catch(r){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",r)}}generateContextId(e){try{let t;if(e&&typeof e=="object"){let r=JSON.parse(JSON.stringify(e));if(delete r.accessFields,delete r.access,Object.keys(r).length){let a=dc(r),s=JSON.stringify(a);t=Tt(s)}}return t}catch{return}}setMaxReplyAvatars(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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}enableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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||{},r=-1,a=Object.values(t).filter(s=>{let c=s.metadata?.documentId===e.metadata?.documentId;return c&&s.annotationNumber&&(r=Math.max(r,s.annotationNumber)),c});return r===-1?a.length+1:r+1}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationNumber: ",t),null}}enableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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 Q(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 Q(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:Ne.COMMENT,config:{autoCompleteScrollConfig:e}});let t=this.autoCompleteScrollConfig$.value,r={itemSize:e.itemSize??t.itemSize,minBufferPx:e.minBufferPx??t.minBufferPx,maxBufferPx:e.maxBufferPx??t.maxBufferPx,templateCacheSize:e.templateCacheSize??t.templateCacheSize};this.autoCompleteScrollConfig$.next(r)}catch(t){this.loggingService.catch("Error in CommentService setAutoCompleteScrollConfig: ",t)}}getAutoCompleteScrollConfig(){return this.autoCompleteScrollConfig$.value}getAutoCompleteScrollConfig$(){return this.autoCompleteScrollConfig$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Id),ee(un),ee(Ft),ee(ot),ee(In),ee(je),ee(Be),ee(Ri),ee(ym),ee(Si),ee(su),ee(Do),ee(po),ee(En),ee(_),ee(hn),ee(Wo),ee(ur),ee(nge),ee(bn),ee(Ps),ee(WC),ee(ol),ee(Im),ee(ru),ee(ss),ee(Wi))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var S=(()=>{let _DynamicDataService=class _DynamicDataService{constructor(i,o,n,e,t,r){this.authService=i,this.commentService=o,this.loggingService=n,this.injector=e,this.docService=t,this.configService=r,this.subscriptions=[],this.commonData$=new Ce({}),this.evaluateConditionTriggered=new Me,this.conditionRegex=/\{(.*?)\}/g,this.extractedProps={},this.condition="",this.dataComponentConfigSignal=xe({});try{this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{user:a}))})),this.subscriptions.push(this.commentService.getUnreadCommentAnnotationCountOnCurrentDocument$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{unreadCommentAnnotationCount:a?.count||0}))})),this.subscriptions.push(this.commentService.getUnreadCommentCountOnCurrentDocument$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{unreadCommentCount:a?.count||0}))})),this.subscriptions.push(this.docService.getUIState$().subscribe(a=>{this.commonData$.next(E(E({},this.commonData$.value),a))})),this.subscriptions.push(this.getCommonData().subscribe(a=>{this.dataComponentConfigSignal.update(s=>(s=E(E({},s),a),s)),this.executeConditionalClasses()})),this.subscriptions.push(this.evaluateConditionTriggered.subscribe(a=>{this.extractedProps=a.extractedProps,this.evaluateCondition(a.className,a.elementRef,a.condition)}))}catch(a){this.loggingService.catch("Error in DynamicDataService constructor: ",a)}}ngOnDestroy(){try{this.subscriptions.forEach(i=>i.unsubscribe())}catch(i){this.loggingService.catch("Error in DynamicDataService ngOnDestroy: ",i)}}getCommonData(){return this.commonData$.asObservable()}getModifiedPathBasedOnCondition(i,o){try{return Object.keys(o).forEach(n=>{o[n].path=this.modifyPathBasedOnCondition(n,i)}),o}catch(n){this.loggingService.catch("Error in DynamicDataService getModifiedPathBasedOnCondition: ",n)}}getComputedValues(i,o,n,e,t,r){try{Object.keys(n).forEach(a=>{let s;if(Vi(i)?s=ki(()=>Na(i(),n[a].path)):s=ki(()=>Na(i,n[a].path)),Vi(s()))lo(()=>{try{let c=s()();n[a].value=c,this.evaluateConditionTriggered.emit({extractedProps:n,className:e,elementRef:t,condition:r})}catch{}},{injector:this.injector,allowSignalWrites:!0});else{let c=s();n[a].value=c,this.evaluateConditionTriggered.emit({extractedProps:n,className:e,elementRef:t,condition:r})}})}catch(a){this.loggingService.catch("Error in DynamicDataService getComputedValues: ",a)}}modifyPathBasedOnCondition(i,o){try{let n=i;if(i.startsWith("userContact."))n=i.replace("userContact","selectorItem.contact");else if(i.startsWith("comment."))n=i.replace("comment","commentObj");else if(i.startsWith("commentAnnotation."))n=i.replace("commentAnnotation","componentConfigSignal.annotation");else if(i.startsWith("commentAnnotations."))n=i.replace("commentAnnotations","componentConfigSignal.annotations");else{let e=i.match(/^([^.\[]+)/),t=e?e[1]:"";if(t&&o&&typeof o=="function"&&o()&&t in o()){let r=i.match(/\[(.*?)\]/);if(r&&r[1]){let a=r[1];if(a.includes(".")){let s=a.split(".")[0];s&&o()&&s in o()?n=i:n=i.replace(`[${a}]`,`[componentConfigSignal.${a}]`)}else n=i}else n=i}else n="componentConfigSignal."+i}return n}catch(n){return this.loggingService.catch("Error in DynamicDataService modifyPathBasedOnCondition: ",n),i}}applyConditionalClasses(i,o){try{this.elementRef=i,this.data=o}catch(n){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",n)}}executeConditionalClasses(){try{let i=this.getHostElementAttributes(this.elementRef),n=[...Object.keys(i).filter(e=>e.startsWith("velt-class-")).map(e=>({name:e,value:i[e]}))];if(i["velt-class"]){let e=i["velt-class"],t=/'([^']+)':\s*([^,]+)(?:,|$)/g,r=[],a=0,s=100,c;for(;(c=t.exec(e))!==null;){if(a++>s){this.loggingService.catch("Too many class definitions detected.");break}if(c.length<3)continue;let[,p,g]=c;!p||!g||p.split(" ").forEach(f=>{f.trim()&&r.push({name:`velt-class-${f.trim()}`,value:g.trim()})})}n=[...n,...r]}this.data&&typeof this.data=="object"&&Object.keys(this.data).forEach(e=>{this.updateDataComponentConfigSignal(e,this.data[e])}),n.forEach(e=>{let t=e.name.replace("velt-class-","");this.condition=e.value,this.condition&&(this.extractProps(),this.extractedProps=this.getModifiedPathBasedOnCondition(this.dataComponentConfigSignal,this.extractedProps),this.getComputedValues(this.dataComponentConfigSignal,this.evaluateCondition,this.extractedProps,t,this.elementRef,e.value))})}catch(i){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",i)}}updateDataComponentConfigSignal(i,o){try{i==="dataComponentConfigSignal"?this.dataComponentConfigSignal.set(o):this.dataComponentConfigSignal.update(n=>D(E({},n),{[i]:o}))}catch(n){this.loggingService.catch("Error in DataComponent updateDataComponentConfigSignal: ",n)}}extractProps(){try{this.extractedProps={},this.conditionRegex.lastIndex=0;let i;for(;(i=this.conditionRegex.exec(this.condition))!==null;){let o=i[1];this.extractedProps[o]={value:null,path:null,isDynamicPath:this.hasDynamicParts(o)}}}catch(i){this.loggingService.catch("Error in DynamicDataService extractProps: ",i)}}hasDynamicParts(i){try{let o=/\[[^\]'"]*[^\]'"]\]/.test(i),n=/\[[^[\]]*[\.\[][^[\]]*\]/.test(i);return o||n}catch(o){return this.loggingService.catch("Error checking for dynamic path: ",o),!1}}evaluateCondition(i,o,n){try{if(n){let e=this.extractedProps,t=n.replace(this.conditionRegex,(s,c)=>{let p=e[c];if(p&&p.value!==void 0){let g=p.value;return typeof g=="string"?`'${g}'`:typeof g=="boolean"||typeof g=="number"?String(g):g===null?"null":typeof g=="object"?g?"true":"false":String(g)}return"false"}),r=this.sanitizeCondition(t),a=this.safeEval(r);return i&&o&&(a?this.setHostElementClasses(o,i):this.removeHostElementClasses(o,i)),a}return!1}catch(e){return this.loggingService.catch("Error in IfComponent evaluateCondition: ",e),!1}}sanitizeCondition(i){try{return i.replace(/[^a-zA-Z0-9\s\+\-\*\/\%\(\)\!\=\<\>\|\&\.\[\]\{\},'"]/g,"")}catch(o){return this.loggingService.catch("Error in IfComponent sanitizeCondition: ",o),""}}safeEval(expression){try{if(this.configService.getSafeEval()){let i=this.tokenize(expression.trim());return this.evaluateTokens(i)}else return eval(expression)}catch(i){return this.loggingService.catch("safeEval error",i),!1}}tokenize(i){try{if(!i||i.trim()==="")return[];let o=[],n=0;for(;n<i.length;){let e=i[n];if(/\s/.test(e)){n++;continue}if(e==='"'||e==="'"){let t=e,r="";for(n++;n<i.length;)if(i[n]==="\\"&&n+1<i.length)r+=i[n+1],n+=2;else if(i[n]===t){n++;break}else r+=i[n],n++;o.push({type:"string",value:r});continue}if(e==="("){o.push({type:"lparen",value:"("}),n++;continue}if(e===")"){o.push({type:"rparen",value:")"}),n++;continue}if(n<i.length-2&&i.substring(n,n+3)==="==="){o.push({type:"operator",value:"===",precedence:4}),n+=3;continue}if(n<i.length-2&&i.substring(n,n+3)==="!=="){o.push({type:"operator",value:"!==",precedence:4}),n+=3;continue}if(n<i.length-1&&i.substring(n,n+2)==="&&"){o.push({type:"operator",value:"&&",precedence:2}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="||"){o.push({type:"operator",value:"||",precedence:1}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="<="){o.push({type:"operator",value:"<=",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)===">="){o.push({type:"operator",value:">=",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="=="){o.push({type:"operator",value:"==",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="!="){o.push({type:"operator",value:"!=",precedence:4}),n+=2;continue}if(e==="!"){o.push({type:"unary",value:"!",precedence:5}),n++;continue}if(e==="<"){o.push({type:"operator",value:"<",precedence:4}),n++;continue}if(e===">"){o.push({type:"operator",value:">",precedence:4}),n++;continue}if(/[a-zA-Z0-9._]/.test(e)){let t="";for(;n<i.length&&/[a-zA-Z0-9._]/.test(i[n]);)t+=i[n],n++;/^-?\d+(\.\d+)?$/.test(t)?o.push({type:"number",value:parseFloat(t)}):t==="true"||t==="false"?o.push({type:"boolean",value:t==="true"}):t==="null"?o.push({type:"null",value:null}):t==="undefined"?o.push({type:"undefined",value:void 0}):o.push({type:"identifier",value:t});continue}n++}return o}catch(o){return this.loggingService.catch("tokenize error",o),[]}}evaluateTokens(i){try{if(!i||i.length===0)return!1;let o=this.infixToPostfix(i);return this.evaluatePostfix(o)}catch(o){return this.loggingService.catch("evaluateTokens error",o),!1}}infixToPostfix(i){try{let o=[],n=[];for(let e of i)if(e.type==="string"||e.type==="number"||e.type==="boolean"||e.type==="null"||e.type==="undefined"||e.type==="identifier")o.push(e);else if(e.type==="unary")n.push(e);else if(e.type==="operator"){for(;n.length>0;){let t=n[n.length-1];if(t.type==="lparen"||t.precedence!==void 0&&t.precedence<e.precedence)break;o.push(n.pop())}n.push(e)}else if(e.type==="lparen")n.push(e);else if(e.type==="rparen"){for(;n.length>0&&n[n.length-1].type!=="lparen";)o.push(n.pop());n.length>0&&n.pop()}for(;n.length>0;){let e=n.pop();e.type!=="lparen"&&e.type!=="rparen"&&o.push(e)}return o}catch(o){return this.loggingService.catch("infixToPostfix error",o),[]}}evaluatePostfix(i){try{let o=[];for(let n of i)if(n.type==="string"||n.type==="number"||n.type==="boolean"||n.type==="null"||n.type==="undefined"||n.type==="identifier")o.push(n.value);else if(n.type==="unary"){if(o.length>=1){let e=o.pop();n.value==="!"&&o.push(!this.isTruthy(e))}}else if(n.type==="operator"&&o.length>=2){let e=o.pop(),t=o.pop();n.value==="&&"?o.push(this.isTruthy(t)&&this.isTruthy(e)):n.value==="||"?o.push(this.isTruthy(t)||this.isTruthy(e)):o.push(this.compare(t,e,n.value))}return o.length===1?this.isTruthy(o[0]):!1}catch(o){return this.loggingService.catch("evaluatePostfix error",o),!1}}parseValue(i){try{let o=i.trim();return o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")?o.substring(1,o.length-1):/^-?\d+(\.\d+)?$/.test(o)?parseFloat(o):o==="true"?!0:o==="false"?!1:o==="null"?null:o==="undefined"?void 0:o}catch(o){return this.loggingService.catch("parseValue error",o),i}}compare(i,o,n){try{switch(n){case"===":return i===o;case"!==":return i!==o;case"==":return i==o;case"!=":return i!=o;case"<":return i<o;case">":return i>o;case"<=":return i<=o;case">=":return i>=o;default:return!1}}catch(e){return this.loggingService.catch("compare error",e),!1}}isTruthy(i){try{return i==null||i===""||i==="false"?!1:i==="true"?!0:typeof i=="number"?i!==0:!!i}catch(o){return this.loggingService.catch("isTruthy error",o),!1}}getHostElementAttributes(i){try{let o=i,n={};for(let e of o.attributes)n[e.name]=e.value;return n}catch{return{}}}setHostElementClasses(i,o){try{i.classList.add(o)}catch{}}removeHostElementClasses(i,o){try{i.classList.remove(o)}catch{}}};_DynamicDataService.\u0275fac=function(o){return new(o||_DynamicDataService)(ee(je),ee(we),ee(_),ee(St),ee(ot),ee(Ft))},_DynamicDataService.\u0275prov=Pe({token:_DynamicDataService,factory:_DynamicDataService.\u0275fac,providedIn:"root"});let DynamicDataService=_DynamicDataService;return DynamicDataService})();var H=(()=>{let o=class o{set veltIf(e){try{e&&this.setIfCondition(e)}catch(t){this._loggingService.catch("Error in BaseComponent set veltIf:",t)}}constructor(e,t,r){this._elementRef=e,this._dynamicDataService=t,this._loggingService=r,this.componentConfigSignal=xe({}),this.veltElement=!0,this.conditionSignal=xe(null)}initializeComponentConfigSignal(e){try{this.componentConfigSignal.set(e)}catch(t){this._loggingService.catch("Error in BaseComponent initializeComponentConfigSignal:",t)}}ngOnInit(){try{this._dynamicDataService.applyConditionalClasses(this._elementRef?.nativeElement,{componentConfigSignal:this.componentConfigSignal})}catch(e){this._loggingService.catch("Error in BaseComponent ngOnInit:",e)}}ngOnDestroy(){}setIfCondition(e){try{this.conditionSignal.set(e)}catch(t){this._loggingService.catch("Error in BaseComponent setIfCondition:",t)}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(S),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-base"]],hostVars:1,hostBindings:function(t,r){t&2&&T("data-velt-element",r.veltElement)},inputs:{componentConfigSignal:"componentConfigSignal",template:"template",wireframe:"wireframe",veltIf:"veltIf"},standalone:!1,decls:0,vars:0,template:function(t,r){},encapsulation:2});let i=o;return i})();var nt=(()=>{let o=class o extends H{onDarkModeChange(){return this.darkModeSubject$.asObservable()}constructor(e,t,r,a,s,c,p){super(e,c,p),this._elementRef=e,this._themeService=t,this._changeDetector=r,this._featureService=a,this._componentDarkModeObservable=s,this._componentDarkMode=null,this._globalDarkMode=!1,this._featureDarkMode=!1,this._themeSubscriptions=[],this._darkMode=!1,this.darkMode=!1,this.darkModeSubject$=new Ce(!1);try{this._themeSubscriptions.push(this._themeService.getDarkMode$().subscribe(g=>{this._globalDarkMode=g,this.setDarkMode()})),this._featureService&&(this._featureService instanceof we?this._themeSubscriptions.push(this._featureService.getCommentContainerDarkMode().subscribe(g=>{this._featureDarkMode=g,this.setDarkMode()})):this._featureService instanceof ur&&this._themeSubscriptions.push(this._featureService.getDarkMode$().subscribe(g=>{g!==null&&(this._featureDarkMode=g),this.setDarkMode()}))),this._componentDarkModeObservable&&this._componentDarkModeObservable instanceof $t&&this._themeSubscriptions.push(this._componentDarkModeObservable.subscribe(g=>{this._componentDarkMode=g,this.setDarkMode()}))}catch{}}ngOnInit(){super.ngOnInit()}ngOnChanges(e){try{if(e._darkMode){let t=e._darkMode.currentValue;typeof t=="string"&&(t=t==="true"),this._componentDarkMode=t,this.setDarkMode()}}catch{}}setComponentDarkMode(e){try{this._componentDarkMode=e,this.setDarkMode()}catch{}}setDarkMode(){try{this._componentDarkMode===null?this._featureDarkMode?this.darkMode=!0:this.darkMode=!!this._globalDarkMode:this.darkMode=!!this._componentDarkMode,this.darkMode?this._elementRef.nativeElement.hasAttribute("dark")||this._elementRef.nativeElement.setAttribute("dark",""):this._elementRef.nativeElement.hasAttribute("dark")&&this._elementRef.nativeElement.removeAttribute("dark"),this.darkModeSubject$.next(this.darkMode),this._changeDetector&&this._changeDetector.markForCheck()}catch{}}ngOnDestroy(){try{super.ngOnDestroy(),this._themeSubscriptions.forEach(e=>{e.unsubscribe()})}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Ke),h(an),h("FeatureService",8),h($t),h(S),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-themed"]],inputs:{_darkMode:[0,"darkMode","_darkMode"]},standalone:!1,features:[L,Xe],decls:0,vars:0,template:function(t,r){},encapsulation:2,changeDetection:0});let i=o;return i})();var Ge=(()=>{let o=class o{constructor(e){this.loggingService=e,this.wireframeMap=new Ce(new Map);try{this.loggingService.log("%c[WB] Creating CLASS: WireframeService","color: blue;")}catch(t){this.loggingService.catch("Error in WireframeService constructor: ",t)}}setWireframe(e,t){try{let r=this.wireframeMap.value;r.set(e,t),this.wireframeMap.next(r)}catch(r){this.loggingService.catch("Error in WireframeService setWireframe: ",r)}}setWireframeMap(e){try{let t=this.wireframeMap.value;e.forEach((r,a)=>{t.set(a,r)}),this.wireframeMap.next(t)}catch(t){this.loggingService.catch("Error in WireframeService setWireframeMap: ",t)}}getWireframe(e,t=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&t){let s=e?.split("---")[0];s&&(a=r.get(s))}return a&&(a?.children?.length>0||a?.innerHTML?.trim()?.length>0)?a:void 0}catch(r){this.loggingService.catch("Error in WireframeService getWireframe: ",r);return}}getConditionElement(e,t=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&t){let s=e?.split("---")[0];s&&(a=r.get(s))}return a}catch(r){this.loggingService.catch("Error in WireframeService getConditionElement: ",r);return}}getWireframe$(e,t=!0){return this.wireframeMap.asObservable().pipe(de(r=>this.getWireframe(e,t)))}setChildren(e){try{this.wireframeMap.next(e)}catch(t){this.loggingService.catch("Error in WireframeService setChildren: ",t)}}getWireframeMap(){return this.wireframeMap.value}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var oge=i=>({componentConfigSignal:i}),NFe=(i,o)=>({condition:i,data:o}),FFe=(i,o,n,e,t)=>({template:i,context:o,componentName:"velt-confirm-dialog-wireframe",variant:n,setIfCondition:e,componentElementRef:t});function LFe(i,o){if(i&1&&(v(0),w(1,"app-confirm-dialog-title",5)(2,"app-confirm-dialog-message",5),y(3,"div",6),w(4,"app-confirm-dialog-reject",5)(5,"app-confirm-dialog-approve",5),b(),C()),i&2){let n=l(3);m(),d("componentConfigSignal",n.componentConfigSignal),m(),d("componentConfigSignal",n.componentConfigSignal),m(2),d("componentConfigSignal",n.componentConfigSignal),m(),d("componentConfigSignal",n.componentConfigSignal)}}function BFe(i,o){if(i&1&&(v(0),u(1,LFe,6,4,"ng-container",4),C()),i&2){let n=l().ngIf,e=l();m(),d("veltDynamicTemplate",$(3,FFe,e.template,A(1,oge,e.componentConfigSignal),n.variant,e.setIfCondition.bind(e),e.elementRef))}}function VFe(i,o){if(i&1&&(v(0),u(1,BFe,2,9,"ng-container",3),C()),i&2){let n=l();m(),d("veltIf",k(3,NFe,n.conditionSignal(),A(1,oge,n.componentConfigSignal)))}}var La=(()=>{let o=class o extends nt{constructor(e,t,r,a,s,c,p){super(s,a,void 0,void 0,void 0,p,e),this.loggingService=e,this.dialogRef=t,this.wireframeService=r,this.themeService=a,this.elementRef=s,this.dynamicDataService=p,this.subscriptions=[],this.componentConfigSignal=xe({title:"",message:"",yesButton:"",noButton:"",variant:"",closeDialog:this.closeDialog.bind(this)}),this.componentId="velt-confirm-dialog",this.veltElement=!0;try{c&&(this.componentConfigSignal.update(g=>(g=E(E({},g),c),g)),c?.darkMode&&[!0,!1].includes(c?.darkMode)&&super.setComponentDarkMode(c?.darkMode)),this.setZIndex()}catch(g){this.loggingService.catch("Error in ConfirmDialogComponent constructor: ",g)}}ngOnInit(){try{this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");let e="velt-confirm-dialog-wireframe";super.ngOnInit(),this.componentConfigSignal().variant&&(e+=`---${this.componentConfigSignal().variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r}}))}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent OnInit: ",e)}}ngOnDestroy(){super.ngOnDestroy();try{this.subscriptions.forEach(e=>e.unsubscribe())}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent OnDestroy: ",e)}}setZIndex(){try{if(this.dialogRef){let e=this.dialogRef._overlayRef;e&&(e.backdropElement&&(e.backdropElement.style.zIndex="2147483647"),e.hostElement&&(e.hostElement.style.zIndex="2147483647"))}}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent setZIndex: ",e)}}closeDialog(e){try{this.dialogRef.close(e)}catch(t){this.loggingService.catch("Error in ConfirmDialogComponent closeDialog: ",t)}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(dr),h(Ge),h(Ke),h(R),h(rc,8),h(S))},o.\u0275cmp=O({type:o,selectors:[["snippyly-confirm-dialog"]],hostVars:1,hostBindings:function(t,r){t&2&&T("data-velt-element",r.veltElement)},standalone:!1,features:[V([S]),L],decls:3,vars:5,consts:[["floatingConfirmationRef",""],[1,"velt-confirm-dialog",3,"snippylyOverlay","snippylyOverlayZIndex","snippylyOverlayBackdropZIndex"],[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[3,"componentConfigSignal"],["mat-dialog-actions","",1,"velt-confirm-dialog-actions"]],template:function(t,r){if(t&1&&(y(0,"div",1,0),u(2,VFe,2,6,"ng-container",2),b()),t&2){let a=me(1);d("snippylyOverlay",a)("snippylyOverlayZIndex",1200)("snippylyOverlayBackdropZIndex",1100),T("data-testid",r.componentId),m(2),d("ngIf",r.componentConfigSignal())}},styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}[_nghost-%COMP%] *[_ngcontent-%COMP%]{outline:0}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent)}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}.velt-confirm-dialog[_ngcontent-%COMP%]{width:455px;padding:40px;display:block;box-sizing:border-box;background-color:var(--velt-background-0)}.velt-confirm-dialog-actions[_ngcontent-%COMP%]{justify-content:space-between;gap:var(--velt-spacing-md);min-height:auto} .velt-mat-dialog-container mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface:has(snippyly-confirm-dialog){border-radius:var(--velt-border-radius-xl);padding:0}@media (max-width: 768px){.velt-confirm-dialog[_ngcontent-%COMP%]{width:auto;max-width:455px;padding:24px}}"],changeDetection:0});let i=o;return i})();var Id=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=c,this.domService=p,this.afAuth=g,this.iamService=f,this.dialog=I,this.loggingService=x,this.notificationService=B,this.userPermissionService=z,this.areaAnnotationById$=new Ce({}),this.documentPaths=null,this.areaEnabled$=new Ce(!0),this.allowedElementIds$=new Ce([]),this.addAreaMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.analyticsService.setAreaService(this),this.authService.setAreaService(this),this.databaseService.getDb().pipe(Le(G=>!!G),rt(1)).subscribe(G=>{G&&this.getDocumentPaths()},G=>{this.loggingService.catch("Error in AreaService getDb subscription: ",G)}),this.domService.onWindowPointerMove$().subscribe(G=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let J=this.domService.getBackgroundElement(G.clientX,G.clientY);J&&(this.isElementInsideAllowedElements(J)?Hk(G.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=J,this.domService.highlightElement(this.highlightElement,U.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},G=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",G)}),this.domService.onWindowKeyupEsc$().subscribe(G=>{this.addAreaMode$.value&&this.disableAddAreaMode()},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",G)}),this.domService.onDocumentClick$().subscribe(G=>{if(G&&this.addAreaMode$.value){if(G.preventDefault(),G.stopPropagation(),!Hk(G.target)){let J=this.domService.getBackgroundElement(G.clientX,G.clientY);J&&this.isElementInsideAllowedElements(J)&&this.addArea(G)}this.disableAddAreaMode()}},G=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",G)}),this.addAreaMode$.subscribe(G=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),G?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},G=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",G)}),this.domService.onWindowKeyupBackspace$().subscribe(G=>{this.deleteAreaPinAnnotations("keyupBackspace")},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",G)}),this.domService.onWindowKeyupDelete$().subscribe(G=>{this.deleteAreaPinAnnotations("keyupDelete")},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",G)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}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()}getAllAreaAnnotations(e,t,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>s?this.getDataFromDocumentIds([s]).pipe(de(g=>(p.annotations=g||[],E({},p)))):this.docService.getDocumentIds$().pipe(fe(g=>{let f=g?.length>0?g.map(I=>I.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(f).pipe(de(I=>(p.annotations=I||[],E({},p))))}))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[],f=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(I=>I.locationId)),p?.location?.location?.id&&f.push(p?.location?.location?.id)),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g,f),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(de(()=>p)):le(p)),de(p=>(p.filteredAnnotations=p.filteredAnnotations?.map(g=>{let f=Object.assign({},g);return f.areaProperties=this.calculateAreaAnnotationPosition(f),f}),p)),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([])),fe(p=>{if(this.authService.isFeatureAllowed(Ne.COMMENT))return le(p);{let g=p?.filter(f=>!f?.targetAnnotations?.filter(I=>I?.type===Ne.COMMENT)?.length);return le(g)}})):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.AREA)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:r}=e;if(t?.some(p=>!p)||!this.documentPaths)return le([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=le([]),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 p=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let f=0;f<(p?.length??0);f+=U.LISTENER_CONTEXT_BATCH_SIZE)g.push(p?.slice(f,f+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=mn(g.map(f=>this.commonDbService.dbListener({feature:"allAreas",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",t),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[],...f?.length?[lt("context.accessFields","array-contains-any",f)]:[])]})}).pipe(Ar()))).pipe(de(f=>ia(f)))}else{let p=[];for(let g=0;g<(t?.length??0);g+=U.LISTENER_BATCH_SIZE)p.push(t?.slice(g,g+U.LISTENER_BATCH_SIZE)??[]);s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allAreas",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",g),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}return s.pipe(de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p??{}).filter(I=>typeof I=="object")),{data:f,operation:g}}),de(({data:p,operation:g})=>{if(!t)return{data:p,documentMap:{},operation:g};let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),de(({data:p,documentMap:g,operation:f})=>{if(!r)if(f?.type==="removed"){if(f?.ids?.length){let I=this.areaAnnotationById$.value;f?.ids?.forEach(x=>{delete I?.[x]}),this.areaAnnotationById$.next(I)}}else Object.entries(g??{}).forEach(([I,x])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:x})});return p}))}else return le([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",s)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}filterAnnotationsByLocationIds(e,t,r){try{return e.filter(a=>t.includes(a.locationId)||r?.includes(a?.location?.id)||t?.find(s=>s==a?.location?.id)||r?.find(s=>s==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",a),[]}}calculateAreaAnnotationPosition(e){try{if(e.targetElements?.length){let t=e.targetElements[0],r=e.targetElements[1];if(t?.xpath&&r?.xpath||t?.anchor&&r?.anchor){let a=null,s=null;if(t?.anchor){let c=this.domService.resolveAnchorRecord(t.anchor);c?.element&&c?.element instanceof HTMLElement&&!Ki(c.element)&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(a=c.element)}else t?.xpath&&(a=this.domService.getElementFromXPath(t.xpath),a&&Ki(a)&&(a=null),this.domService.isXpathWithId(t.xpath)||(!a&&t.cfXpath&&(a=this.domService.getElementFromXPath(t.cfXpath),a&&Ki(a)&&(a=null)),!a&&t.fXpath&&(a=this.domService.getElementFromXPath(t.fXpath),a&&Ki(a)&&(a=null))));if(r?.anchor){let c=this.domService.resolveAnchorRecord(r.anchor);c?.element&&c?.element instanceof HTMLElement&&!Ki(c.element)&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(s=c.element)}else r?.xpath&&(s=this.domService.getElementFromXPath(r.xpath),s&&Ki(s)&&(s=null),this.domService.isXpathWithId(r.xpath)||(!s&&r.cfXpath&&(s=this.domService.getElementFromXPath(r.cfXpath),s&&Ki(s)&&(s=null)),!s&&r.fXpath&&(s=this.domService.getElementFromXPath(r.fXpath),s&&Ki(s)&&(s=null))));if(a&&s){let c=hz(a,s);if(c){let p=a.getBoundingClientRect(),g={};p&&p.width&&p.height&&(g={top:p.height*t.topPercentage/100,left:p.width*t.leftPercentage/100});let f=s.getBoundingClientRect(),I={};f&&f.width&&f.height&&(I={top:f.height*r.topPercentage/100,left:f.width*r.leftPercentage/100});let x=fz(g.left,g.top,a,c),B=fz(I.left,I.top,s,c),z,G,J,ne,ve={};x.x>B.x?x.y>B.y?(ne={x:x.x,y:x.y},z={x:B.x,y:B.y},ve.handle1=ne,ve.handle2=z):(G={x:x.x,y:x.y},J={x:B.x,y:B.y},ve.handle1=G,ve.handle2=J):x.y>B.y?(J={x:x.x,y:x.y},G={x:B.x,y:B.y},ve.handle1=J,ve.handle2=G):(z={x:x.x,y:x.y},ne={x:B.x,y:B.y},ve.handle1=z,ve.handle2=ne);let _e={topLeft:z||{x:J?.x,y:G?.y},bottomRight:ne||{x:G?.x,y:J?.y},topRight:G||{x:ne?.x,y:z?.y},bottomLeft:J||{x:z?.x,y:ne?.y}};return ve.coordinates=_e,ve.targetElement=this.domService.getXPath(c),ve}}}}return}catch(t){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",t);return}}addArea(e,t=[],r,a,s,c){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let p=this.authService.getUser();if(p)if(p.isReadOnly||p.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let g=new t9;a&&(g.annotationId=a),g.from=p,g.color=U.DEFAULT_ANNOTATION_COLOR,g.lastUpdated=this.timestamp,r&&(g.targetAnnotations=[r]),g.props=new uc;let f=this.domService.getCurrentWindowSizeValue();if(g.props.screenWidth=f.screenWidth,g.props.screenHeight=f.screenHeight,g.props.screenScrollHeight=f.screenScrollHeight,g.props.viewportWidth=window.innerWidth,g.props.viewportHeight=window.innerHeight,e||t?.length>0){let B=e?this.getPointsForAreaPinAnnotation(e):t;g.targetElements=[],B.forEach(z=>{g.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(g),s&&(g.locationId=s.locationId,g.location=s.location),g.pageInfo=Ni(),g.pageInfo&&(g.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let I=this.getElementForAreaAnnotation(g),x=this.docService.getBaseMetadata("area",{element:I});if(g?.metadata||(g.metadata={}),g.metadata=E(E({},g.metadata),x),c?.access&&c?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:p.userId,accessFields:c.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}g.context={access:c.access,accessFields:c.accessFields}}return this.saveAreaToDb(g),g}return}catch(p){this.loggingService.catch("Error in AreaService addArea: ",p);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}getElementForAreaAnnotation(e){try{let t,r,a;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(r=s.element)}else e.targetElements[0]?.xpath&&(r=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(a=s.element)}else e.targetElements[1]?.xpath&&(a=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return r&&a&&(t=hz(r,a)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.AREA)&&mn([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe(Le(([t,r])=>!!t&&!!r),rt(1),fe(([t,r])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let a=JSON.parse(JSON.stringify(e));if(a.position=null,!a?.metadata?.documentId){a?.metadata||(a.metadata={});let p=this.docService.getBaseMetadata();a.metadata=E(E({},a?.metadata),p)}this.domService.toggleAnnotationSelection(a),this.analyticsService.trackEvent(Y.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:s,organizationId:c}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:s,organizationId:c},data:JSON.parse(JSON.stringify(a))})}else return le(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,r){try{r&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,Nk.UPDATED),this.updateAreaToDb(e)}catch(a){this.loggingService.catch("Error in AreaService updateArea: ",a)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata();t.metadata=E(E({},t?.metadata),s)}let{documentId:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:r,organizationId:a},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(t??{}).forEach(s=>Q(this,null,function*(){let c=t[s];c.type==="area"&&r&&c.from&&(r?.isAdmin||c.from.userId===r.userId)&&a.push(c)})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(La,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(rt(1)).subscribe(s=>{s&&(a.forEach(c=>Q(this,null,function*(){yield this.deleteAreaPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};return Object.values(this.areaAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r??{})}catch(r){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",r),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let a=Object.values(this.areaAnnotationById$.value||{}),s;t?s=a.find(c=>c?.annotationId===t):s=a.find(c=>c?.targetAnnotations?.find(p=>p?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(c=>c?.annotationId!==e),s.targetAnnotations?.length?this.updateAreaToDb(s):this.deleteAreaPinAnnotation(s))}}catch(r){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",r)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(Ne.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,Nk.DELETED),this.analyticsService.trackEvent(Y.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:r}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),le(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(Ne.AREA)?(this.analyticsService.trackEvent(Y.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(Y.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],r=e,a=r?.touches?.length?r.touches[0]?.clientX:r.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r.clientY;return t.push({x:a,y:s}),t.push({x:a+100,y:s+100}),t}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 AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let r={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",r)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=Ni(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(U.URL_PARAMS.TAG_ID),t.searchParams.append(U.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return Q(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield pm(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Ft),ee(ot),ee(In),ee(un),ee(je),ee(Be),ee(Ri),ee(En),ee(po),ee(_),ee(hn),ee(ss))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var gi=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,n={},e=!0){try{this.hideAnalytics||(n||(n={}),n=D(E({},n),{source:"external"}),this.getService(Je).trackAuthenticatedEvent(o,n,e))}catch(t){this.getService(_).catch("Error in _trackEvent: ",t);return}}};var M9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Id).enableArea()}catch(o){this.getService(_).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Id).disableArea()}catch(o){this.getService(_).catch("Error in _disableAreaComment: ",o)}}};var xm=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.authService=s,this.domService=c,this.afAuth=p,this.iamService=g,this.dialog=f,this.loggingService=I,this.notificationService=x,this.commonDbService=B,this.arrowAnnotations$=new Ce({}),this.arrowAnnotationsByDocumentId$=new Ce({}),this.documentPaths=null,this.allowedElementIds$=new Ce([]),this.addArrowMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(Le(z=>!!z),rt(1)).subscribe(z=>{z&&this.getDocumentPaths()},z=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",z)}),this.domService.onWindowPointerMove$().subscribe(z=>{if(this.addArrowMode$.value){let G=!0,J=this.domService.getBackgroundElement(z.clientX,z.clientY);J&&(this.isElementInsideAllowedElements(J)?$k(z.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==J&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=J,this.domService.highlightElement(this.highlightElement,U.CURSOR.ARROW_PIN),G=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&G&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},z=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",z)}),this.domService.onWindowKeyupEsc$().subscribe(z=>{this.addArrowMode$.value&&this.disableAddArrowMode()},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",z)}),this.domService.onDocumentClick$().subscribe(z=>{if(z&&this.addArrowMode$.value){if(!$k(z.target)){let G=this.domService.getBackgroundElement(z.clientX,z.clientY);G&&this.isElementInsideAllowedElements(G)&&(z.preventDefault(),z.stopPropagation(),this.addArrow(z))}this.disableAddArrowMode()}},z=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",z)}),this.addArrowMode$.subscribe(z=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),z?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"))},z=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",z)}),this.domService.onWindowKeyupBackspace$().subscribe(z=>{this.deleteArrowPinAnnotations("keyupBackspace")},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",z)}),this.domService.onWindowKeyupDelete$().subscribe(z=>{this.deleteArrowPinAnnotations("keyupDelete")},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",z)})}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,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>this.getDataFromDocumentId(s).pipe(de(g=>(p.annotations=g||[],E({},p))))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(f=>f.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(de(()=>p)):le(p)),de(p=>(p?.filteredAnnotations?.forEach(g=>{this.calculateArrowAnnotationPosition(g)}),p)),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([]))):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.ARROW)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),fe(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(de(r=>({data:r?.data,operation:r?.operation})),de(({data:r,operation:a})=>{let s=[];return r&&(s=Object.values(r).filter(c=>typeof c=="object")),{data:s,operation:a}}),Un(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),le({data:[],operation:null}))),de(({data:r,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let s=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(c=>{delete s?.[c]}),this.arrowAnnotationsByDocumentId$.next(s)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,r);return r})):le([])))}setArrowAnnotationsByDocumentId(e,t){try{if(e){let r=D(E({},this.arrowAnnotationsByDocumentId$.value),{[e]:t});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(r=>t.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let r=t.iterateNext();if(r&&Pi(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:c}=Hg(r);e.position={top:s*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 r=new n9;r.from=t,r.color=t?.color||U.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new uc;let a=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=a.screenWidth,r.props.screenHeight=a.screenHeight,r.props.screenScrollHeight=a.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=U.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>U.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,e&&(r.targetElement=this.domService.getTargetElementForCursorPosition(e)),r?.targetElement?.xpath){let s=this.domService.getXPath(r.targetElement.xpath);if(s){let c=s.iterateNext();c&&(Pi(c)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=Ni(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}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 r=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[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(Ne.ARROW)&&this.docService.getDocumentPaths$().pipe(Le(t=>!!t),rt(1),fe(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(r=>!!r),rt(1),fe(r=>{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 le(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,r){try{r&&this.setLocationToArrowAnnotation(e),t&&this.updateNotificationsDatabase(e,Rk.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 r=t.iterateNext();r&&(Pi(r)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.ARROW)&&this.docService.getDocumentPaths$().pipe(Le(t=>!!t),rt(1),fe(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(r=>!!r),rt(1),fe(r=>{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 le(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(),r=this.authService.getUser(),a=[];Object.keys(t).forEach(s=>Q(this,null,function*(){let c=t[s];if(c.type==="arrow"){let p=r&&!r?.isAnonymous&&!r?.isGuest;r&&c.from&&(p||c.from.userId===r.userId)&&a.push(c)}})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(La,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(rt(1)).subscribe(s=>{s&&(a.forEach(c=>Q(this,null,function*(){yield this.deleteArrowPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(t){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",t)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(Ne.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,Rk.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(Ne.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 r={annotationData:e,actionType:t,notificationSource:"arrow"};this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(e){try{return e?.pageInfo?.arrowUrl?e.pageInfo.arrowUrl:(e?.pageInfo||(e.pageInfo=Ni(),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(U.URL_PARAMS.TAG_ID),t.searchParams.append(U.URL_PARAMS.TAG_ID,e.annotationId),t.href}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Ft),ee(ot),ee(In),ee(je),ee(Be),ee(Ri),ee(En),ee(po),ee(_),ee(hn),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var R9=class extends gi{constructor(o){super(o),this.getService(_).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(xm).setAllowedElementIds(o)}catch(n){this.getService(_).catch("Error in allowedElementIds: ",n)}}};var Fl=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Ce({}),this.onAutocompleteChipClick$=new Qe;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)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var F9=class extends gi{constructor(o){super(o),this.getService(_).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(_).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(Fl).create(o)}catch(n){this.getService(_).catch("Error in _create: ",n)}}_onAutocompleteChipClick(){this.getService(_).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(Fl).getOnAutocompleteChipClick$()}catch(o){return this.getService(_).catch("Error in _onAutocompleteChipClick: ",o),le(null)}}};var rge=(()=>{let o=class o{constructor(e,t,r,a,s,c,p){this.authService=e,this.iamService=t,this.docService=r,this.configService=a,this.commonDbService=s,this.loggingService=c,this.commentService=p,this.documentPaths=null,this.LISTENER_BATCH_SIZE=30}getAnnotationsCount(e){try{return this.authService.getUser$().pipe(Le(t=>!!t),fe(t=>this.commentService.isFeatureAllowed({firebaseUser:t,annotations:[],filteredAnnotations:[]})),fe(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(de(r=>(t.featureAllowed=r,t))):le(t)),fe(t=>t.featureAllowed?this.processRequest(t,e):le(null)),de(t=>t??{data:null}),Ct(Xt))}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",t),le({data:null})}}processRequest(e,t){try{return le(e).pipe(fe(()=>this.initializeDocumentPaths(e)),fe(()=>this.getDocumentIds$(t)),fe(r=>{let a=this.authService.getUser()?.userSnippylyId,s=this.buildRequestContext(t,r);if(!this.validateRequestContext(s,t))return le({data:null,mode:s.mode,serverDocumentIds:s.serverDocumentIds});if(!s.organizationId)return le({data:null,mode:s.mode,serverDocumentIds:s.serverDocumentIds});let c=this.setupTriggers$(s.mode,s.organizationId,s.veltFolderId,s.serverDocumentIds);return this.shouldUseAggregateMode(s.mode)?this.handleAggregateCounts$({triggers$:c,serverDocumentIds:s.serverDocumentIds,request:t,userId:a,organizationId:s.organizationId,clientOrganizationId:s.clientOrganizationId,veltFolderId:s.veltFolderId,folderId:s.folderId,mode:s.mode}).pipe(de(p=>({data:p,mode:s.mode,serverDocumentIds:s.serverDocumentIds}))):this.handleGroupedCounts$(c,r,t,a,s.organizationId,s.veltFolderId).pipe(de(p=>({data:p,mode:s.mode,serverDocumentIds:s.serverDocumentIds})))}),fe(r=>{if(!r?.data)return le(null);let{data:a,mode:s,serverDocumentIds:c}=r;return t?.filterGhostComments?this.filterGhostComments$(a,s,c):le(a)}),Un(r=>(this.loggingService.catch("Error processing request: ",r),le(null))))}catch(r){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",r),le(null)}}initializeDocumentPaths(e){try{return this.docService.getDocumentPaths$().pipe(Le(t=>!!t),Qt(t=>{this.documentPaths=t,e.documentPaths=t}),de(()=>{}))}catch(t){return this.loggingService.catch("Error in CommentService initializeDocumentPaths: ",t),le(e)}}buildRequestContext(e,t){try{let r=this.documentPaths?.organizationId,a=this.documentPaths?.clientOrganizationId,s,c,p;if(e?.allDocuments||e?.documentIds||e?.folderId||e?.organizationId||e?.locationIds){if(e.organizationId&&(r=os(e.organizationId),a=e.organizationId),!r)throw new Error("organizationId is required for this request type");e.folderId&&(s=Ai(e.folderId),c=e.folderId),e.allDocuments&&(p=!0)}else s=this.documentPaths?.veltFolderId,c=this.documentPaths?.folderId,p=this.documentPaths?.allDocuments;let g=this.determineMode(e,s,p,t),f=g.isOrgMode?[]:t.length>0?t.map(I=>I.documentId):[this.documentPaths?.documentId??""];return{organizationId:r,clientOrganizationId:a,veltFolderId:s,folderId:c,allDocuments:p,mode:g,serverDocumentIds:f}}catch(r){return this.loggingService.catch("Error in CommentService buildRequestContext: ",r),{organizationId:void 0,clientOrganizationId:void 0,veltFolderId:void 0,folderId:void 0,allDocuments:void 0,mode:{isOrgMode:!1,isFolderMode:!1,isBatchMode:!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(r=>!r)||!this.documentPaths)}catch(r){return this.loggingService.catch("Error in CommentService validateRequestContext: ",r),!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?le(e.documentIds.map(t=>({clientDocumentId:t,documentId:Dr(t)}))):this.docService.getDocumentIds$().pipe(de(t=>t.length>0?t:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIds: ",t),le([])}}determineMode(e,t,r,a){try{let s=!!e?.organizationId&&!e?.documentIds?.length&&!t&&!r,c=!!t&&!!r,p=!!e?.aggregateDocuments&&!r&&!!a?.length;return{isOrgMode:s,isFolderMode:c,isBatchMode:p}}catch(s){return this.loggingService.catch("Error in CommentService determineMode: ",s),{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1}}}setupTriggers$(e,t,r,a){try{if(e.isOrgMode)return[this.commonDbService.dbListener({feature:"organizationMetadata",properties:{useCollectionGroup:!1,isCollection:!1,organizationId:t}}).pipe(de(c=>c?.data?.commentViewsUpdatedAt??null),Le(c=>!!c),Ct(Xt))];if(e.isFolderMode)return[this.commonDbService.dbListener({feature:"folder",properties:{useCollectionGroup:!1,isCollection:!1,folderId:r,organizationId:t}}).pipe(de(c=>c?.data?.commentViewsUpdatedAt??null),Le(c=>!!c),Ct(Xt))];if(e.isBatchMode){let s=[];for(let c=0;c<a.length;c+=this.LISTENER_BATCH_SIZE)s.push(a.slice(c,c+this.LISTENER_BATCH_SIZE));return s.map(c=>this.commonDbService.dbListener({feature:"allDocuments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",t),lt("metadata.documentId","in",c))]}}).pipe(de(g=>Object.values(g?.data||{}).map(I=>I?.commentViewsUpdatedAt??null).sort().join(",")),Ct(Xt)))}else return a.map(s=>this.commonDbService.dbListener({feature:"documentMetadata",properties:{useCollectionGroup:!1,isCollection:!1,documentId:s,organizationId:t}}).pipe(de(p=>p?.data?.commentViewsUpdatedAt??null),Le(p=>!!p),Ct(Xt)))}catch(s){return this.loggingService.catch("Error in CommentService setupTriggers: ",s),[]}}handleGroupedCounts$(e,t,r,a,s,c){try{let p=t.map((g,f)=>e[f].pipe(so(void 0),fe(()=>io(this.getCountsForDocument$(g.documentId,g.clientDocumentId,r,a,s,c)))));return mn(p).pipe(de(g=>{let f={};return g.forEach(I=>{I&&(f[I.clientDocumentId]={total:I.total,unread:I.unread})}),{data:f}}),Un(g=>(this.loggingService.catch("Error in grouped counts: ",g),le(null))))}catch(p){return this.loggingService.catch("Error in CommentService handleGroupedCounts: ",p),le(null)}}handleAggregateCounts$(e){try{let{triggers$:t,serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}=e;return mn(t).pipe(de(()=>{})).pipe(so(void 0),fe(()=>io(this.getAggregateCounts({serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}))),Un(B=>(this.loggingService.catch("Error in aggregate counts: ",B),le(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleAggregateCounts: ",t),le(null)}}getCountsForDocument$(e,t,r,a,s,c){return Q(this,null,function*(){try{let p=this.configService?.getApiKey(),g={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},f=[lt("metadata.apiKey","==",p),lt("metadata.organizationId","==",s),lt("metadata.documentId","in",[e]),...c?[lt("metadata.veltFolderId","==",c)]:[],...r?.statusIds?.length?[lt("status.id","in",r.statusIds)]:[],...r?.locationIds?.length?[lt("location.id","in",r.locationIds)]:[]],I=[li(...f),to("lastUpdated","desc"),to("createdAt","desc")],x=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},g),{firestoreQuery:I})}),B=[...f,lt("viewedByUserIds","array-contains",a)],z=[li(...B),to("lastUpdated","desc"),to("createdAt","desc")],G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},g),{firestoreQuery:z})});return{clientDocumentId:t,total:x,unread:x-G}}catch(p){return this.loggingService.catch("Error in CommentService getCountsForDocument: ",p),null}})}getAggregateCounts(e){return Q(this,null,function*(){try{let t="",{serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}=e,x=this.configService?.getApiKey(),B={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},z=[lt("metadata.apiKey","==",x),lt("metadata.organizationId","==",c),...a?.statusIds?.length?[lt("status.id","in",a.statusIds)]:[],...a?.locationIds?.length?[lt("location.id","in",a.locationIds)]:[]],G,J;if(I.isFolderMode){t=f??"",z.push(lt("metadata.veltFolderId","==",g));let ne=[li(...z),to("lastUpdated","desc"),to("createdAt","desc")];G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:ne})});let ve=[...z,lt("viewedByUserIds","array-contains",s)],_e=[li(...ve),to("lastUpdated","desc"),to("createdAt","desc")];J=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:_e})})}else if(I.isOrgMode){t=p??"";let ne=[li(...z),to("lastUpdated","desc"),to("createdAt","desc")];G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:ne})});let ve=[...z,lt("viewedByUserIds","array-contains",s)],_e=[li(...ve),to("lastUpdated","desc"),to("createdAt","desc")];J=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:_e})})}else{t="result";let ne=[];for(let be=0;be<r.length;be+=this.LISTENER_BATCH_SIZE)ne.push(r.slice(be,be+this.LISTENER_BATCH_SIZE));let ve=ne.map(be=>Q(this,null,function*(){let Ie=[...z,lt("metadata.documentId","in",be),...g?[lt("metadata.veltFolderId","==",g)]:[]],Ae=[li(...Ie),to("lastUpdated","desc"),to("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:Ae})})}));G=(yield Promise.allSettled(ve)).reduce((be,Ie)=>be+(Ie.status==="fulfilled"&&Ie.value||0),0);let Fe=ne.map(be=>Q(this,null,function*(){let Ie=[...z,lt("metadata.documentId","in",be),...g?[lt("metadata.veltFolderId","==",g)]:[],lt("viewedByUserIds","array-contains",s)],Ae=[li(...Ie),to("lastUpdated","desc"),to("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:Ae})})}));J=(yield Promise.allSettled(Fe)).reduce((be,Ie)=>be+(Ie.status==="fulfilled"&&Ie.value||0),0)}return{data:{[t]:{total:G,unread:G-J}}}}catch(t){return this.loggingService.catch("Error in CommentService getAggregateCounts: ",t),null}})}filterGhostComments$(e,t,r){try{return e?this.commentService.getGhostCommentAnnotationMap$().pipe(de(a=>{if(!a)return e;let s=this.buildGhostCommentAnnotationMap(a),c=this.groupGhostCommentsByModeId(s,t,r);return this.adjustCountsForGhostComments(e,c),e})):le(null)}catch(a){return this.loggingService.catch("Error in CommentService filterGhostComments: ",a),le(null)}}buildGhostCommentAnnotationMap(e){let t={};return Object.keys(e).forEach(r=>{let a=this.commentService.getAnnotationById(r);a&&(t[r]=a)}),t}groupGhostCommentsByModeId(e,t,r){try{let a={};return Object.values(e).forEach(s=>{let c=this.getModeIdForAnnotation(s,t,r);c&&(a[c]||(a[c]=[]),a[c].push(s))}),a}catch(a){return this.loggingService.catch("Error in CommentService groupGhostCommentsByModeId: ",a),{}}}getModeIdForAnnotation(e,t,r){try{return t.isOrgMode?e?.metadata?.clientOrganizationId||null:t.isFolderMode?e?.metadata?.folderId||null:t.isBatchMode?r.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(s=>{let c=t[s];if(!(!c||!e?.data?.[s]?.total)&&(e.data[s].total=Math.max(0,e.data[s].total-c.length),a)){let p=c.filter(g=>g?.viewedByUserIds&&!g?.viewedByUserIds?.includes(a));p.length>0&&(e.data[s].unread=Math.max(0,e.data[s].unread-p.length))}})}catch(r){this.loggingService.catch("Error in CommentService adjustCountsForGhostComments: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(En),ee(ot),ee(Ft),ee(un),ee(_),ee(we))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Xn=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B){this.analyticsService=e,this.authService=t,this.commentService=r,this.commentViewsService=a,this.contactService=s,this.customFilterService=c,this.docService=p,this.iamService=g,this.loggingService=f,this.metadataService=I,this.reactionService=x,this.commonDbService=B,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(z=>{this.isUserAdmin=z})}catch(z){this.loggingService.catch("Error in CommentActionsService constructor: ",z)}}addCommentAnnotation(a,s){return Q(this,arguments,function*({annotation:e,options:t},r){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),new Promise(c=>{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,p=>Q(this,null,function*(){let g=yield this.getAddCommentAnnotationEventFromCommentAddEventData(p);c(g)}),void 0,void 0,e,void 0,void 0,void 0,void 0,void 0,r)})}catch(c){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",c),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return Q(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(zi.ADD_COMMENT_ANNOTATION,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",t)}}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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){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 p=this.commentService.getAnnotationById(e,t);if(p){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===p?.from?.userId){this.commentService.deleteCommentPinAnnotation(p);let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:p.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(p),metadata:f};return this.triggerAction(zi.DELETE_COMMENT_ANNOTATION,I),I}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(s,c){return Q(this,arguments,function*({annotationId:e,priority:t,options:r},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,r);if(g){g=JSON.parse(JSON.stringify(g));let f=g.priority?JSON.parse(JSON.stringify(g.priority)):null;f&&t&&f?.id===t?.id?g.priority=void 0:g.priority=t,this.commentService.saveComment(g,{type:Wt.PRIORITY_CHANGED,newPriority:t,oldPriority:f});let I=yield this.metadataService.getGlobalMetadata(),x={newPriority:t,oldPriority:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};return this.triggerAction(zi.UPDATE_PRIORITY,x),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}),x}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",p),null}})}updateStatus(s,c){return Q(this,arguments,function*({annotationId:e,status:t,options:r},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateStatus","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,r);if(g){g=JSON.parse(JSON.stringify(g));let f=g.status?JSON.parse(JSON.stringify(g.status)):null;g.status=t,this.commentService.saveComment(g,{type:Wt.STATUS_CHANGED,newStatus:t,oldStatus:f});let I=yield this.metadataService.getGlobalMetadata(),x={newStatus:t,oldStatus:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};return this.triggerAction(zi.UPDATE_STATUS,x),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldStatus:f,newStatus:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),x}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",p),null}})}updateAccess(s,c){return Q(this,arguments,function*({annotationId:e,accessMode:t,options:r},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,r);if(g)if(this.commentService.isPrivateCommentAllowed()){g=JSON.parse(JSON.stringify(g));let f=g.iam?.accessMode;g.iam.accessMode=t,this.commentService.saveComment(g,{type:Wt.ACCESS_MODE_CHANGED,newAccessMode:t,oldAccessMode:f});let I=yield this.metadataService.getGlobalMetadata(),x={newAccessMode:t,oldAccessMode:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};switch(this.triggerAction(zi.UPDATE_ACCESS,x),t){case uo.PRIVATE:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:uo.PRIVATE,source:a??this.defaultSource});break;case uo.PUBLIC:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:uo.PUBLIC,source:a??this.defaultSource});break;default:break}return x}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(p){return this.loggingService.catch("Error in CommentActionsService updateAccess: ",p),null}})}resolveCommentAnnotation(r){return Q(this,arguments,function*({annotationId:e,options:t}){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: resolveCommentAnnotation","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let s=this.commentService.getAnnotationById(e,t);if(s){s=JSON.parse(JSON.stringify(s));let c=this.customFilterService.resolvedStatus,p=s.status?JSON.parse(JSON.stringify(s.status)):null;c&&(s.status=c,this.commentService.saveComment(s,{type:Wt.STATUS_CHANGED,newStatus:c,oldStatus:p}));let g=yield this.metadataService.getGlobalMetadata(),f={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(s),metadata:g};return this.triggerAction(zi.RESOLVE_COMMENT,f),f}else this.triggerAnnotationNotFoundError(e);return null}catch(a){return this.loggingService.catch("Error in CommentActionsService resolveCommentAnnotation: ",a),null}})}getLink(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){let p=this.commentService.getCommentUrl(c)??null,g=yield this.metadataService.getGlobalMetadata();return{link:p,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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let c=yield this.getLink({annotationId:e,options:t},r);if(c?.link){Js(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:r??this.defaultSource,link:c.link});let p=yield this.metadataService.getGlobalMetadata(),g={link:c.link,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c.commentAnnotation),metadata:p};return this.triggerAction(zi.COPY_LINK,g),g}return null}catch(c){return this.loggingService.catch("Error in CommentActionsService copyLink: ",c),null}})}addComment(p,g){return Q(this,arguments,function*({annotationId:e,comment:t,assignedTo:r,assigned:a,options:s},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let f=this.authService.getUser();if(!f)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(f){let I=this.commentService.getAnnotationById(e,s),x=I?.comments?.length?Wt.ADDED:Wt.NEWLY_ADDED;if(I){I.status.type==="terminal"&&(I.status=this.customFilterService.defaultStatus);let B=new yd;B=E(E({},B),t),B.lastUpdated=new Date,B.attachments||(B.attachments=[]),B.attachments=B.attachments.filter(J=>J?.attachmentId),B.createdAt=this.timestamp,B.from=f,r&&(I.assignedTo=r),this.commentService.saveComment(I,{type:x,updatedComment:B,assigned:a});let z=yield this.metadataService.getGlobalMetadata(),G={annotationId:e,commentId:B?.commentId,comment:B,commentAnnotation:this.commentService.getCommentAnnotationForClient(I),metadata:z};return this.triggerAction(zi.ADD_COMMENT,G),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:t?.commentId,commentType:this.commentService.getCommentType(I),commentMode:this.commentService.getCommentMode(),source:c??this.defaultSource}),G}else this.triggerAnnotationNotFoundError(e)}return null}catch(f){return this.loggingService.catch("Error in CommentActionsService addComment: ",f),null}})}approveCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){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:Wt.APPROVED}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource});let p=yield this.metadataService.getGlobalMetadata(),g={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:p};return this.triggerAction(zi.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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=U.CommentAcceptStatus,this.commentService.saveComment(c,{type:Wt.ACCEPTED,oldStatus:g,newStatus:U.CommentAcceptStatus});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:f,actionUser:p,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(zi.ACCEPT_COMMENT_ANNOTATION,I),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",c),null}})}rejectCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=U.CommentRejectStatus,this.commentService.saveComment(c,{type:Wt.REJECTED,oldStatus:g,newStatus:U.CommentRejectStatus});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:f,actionUser:p,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(zi.REJECT_COMMENT_ANNOTATION,I),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",c),null}})}toggleNotificationSubscription(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=Tt(p.userId);if(g){c.subscribedUsers||(c.subscribedUsers={}),c.unsubscribedUsers||(c.unsubscribedUsers={});let f,I=!1;if(c?.unsubscribedUsers?.[g])I=!1;else if(c?.subscribedUsers?.[g])I=!0;else{let z=this.contactService.getCurrentOrganizationUserIAM();if(z){let G=z.groups||{};Object.keys(G).forEach(J=>{c?.subscribedGroups?.[J]&&(I=!0)})}}if(r==="subscribe"||!r&&!I)delete c.unsubscribedUsers[g],c.subscribedUsers[g]={user:p,type:"manual"},f=Wt.SUBSCRIBED;else if(r==="unsubscribe"||!r&&I)delete c.subscribedUsers[g],c.unsubscribedUsers[g]={user:p,type:"manual"},f=Wt.UNSUBSCRIBED;else return null;this.commentService.saveComment(c,{type:f});let x=yield this.metadataService.getGlobalMetadata(),B={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:x};return f===Wt.SUBSCRIBED?this.triggerAction(zi.SUBSCRIBE_COMMENT_ANNOTATION,B):this.triggerAction(zi.UNSUBSCRIBE_COMMENT_ANNOTATION,B),B}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",c),null}})}assignUser(s,c){return Q(this,arguments,function*({annotationId:e,assignedTo:t,options:r},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,r);if(g){g.assignedTo=t,this.commentService.saveComment(g,{type:Wt.ASSIGNED,assignedTo:t});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,assignedTo:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:f};return this.triggerAction(zi.ASSIGN_USER,I),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}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService assignUser: ",p),null}})}getComment(r){return Q(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,r,a,s){return Q(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=Wt.UPDATED,t.isEdited||(t.isEdited=!0,t.editedAt=new Date),this.commentService.saveComment(e,{type:Wt.UPDATED,updatedComment:t});let p=yield this.metadataService.getGlobalMetadata(),g={annotationId:e?.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:p};return this.triggerAction(zi.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:s??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:r,options:a});return null}catch(c){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",c),null}})}updateComment(p,g){return Q(this,arguments,function*({annotationId:e,comment:t,skipDeleteThreadConfirmation:r,merge:a,options:s},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let f=this.commentService.getAnnotationById(e,s),I=this.authService.getUser();if(!I)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(f&&I){let x=t,B=f.comments?.find(z=>z.commentId===t.commentId);if(B){if(this.isUserAdmin||I?.userId===B?.from?.userId)return f?.status.type==="terminal"&&(f.status=this.customFilterService.defaultStatus),a&&(x=E(E({},B),t)),x.from=B.from,x.createdAt=B.createdAt,x.lastUpdated=new Date,yield this.updateOrDeleteComment(f,x,r,s,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(f){return this.loggingService.catch("Error in CommentActionsService updateComment: ",f),null}})}deleteComment(c,p){return Q(this,arguments,function*({annotationId:e,commentId:t,skipDeleteThreadConfirmation:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let g=this.commentService.getAnnotationById(e,a),f=this.authService.getUser();if(g){let I=g.comments?.find(x=>x?.commentId===t);if(I)if(this.isUserAdmin||f?.userId===I?.from?.userId){this.commentService.saveComment(g,{type:Wt.DELETED,updatedComment:I,skipDeleteThreadConfirmation:r});let x=yield this.metadataService.getGlobalMetadata(),B={annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),comment:I,metadata:x};return this.triggerAction(zi.DELETE_COMMENT,B),B}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(g){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",g),null}})}addAttachment(s,c){return Q(this,arguments,function*({annotationId:e,files:t,options:r},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let p=[],g=this.commentService.getAnnotationById(e,r);if(g||a==="internal"){let x=[];t.forEach(B=>{let{valid:z,file:G,maxAllowedSize:J,error:ne}=this.validateFile(B);z&&G?x.push(this.uploadFile(G,g||{}).then(ve=>({valid:z,file:G,maxAllowedSize:J,error:ne,attachment:ve||void 0}))):x.push(Promise.resolve({valid:z,file:G,maxAllowedSize:J,error:ne,attachment:void 0}))}),p=yield Promise.all(x)}else this.triggerAnnotationNotFoundError(e);let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:g?this.commentService.getCommentAnnotationForClient(g):void 0,attachments:p,metadata:f};return this.triggerAction(zi.ADD_ATTACHMENT,I),p}catch(p){return this.loggingService.catch("Error in CommentActionsService addAttachment: ",p),[]}})}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 r=e.size<=t;return{valid:r,file:e,maxAllowedSize:t,maxAllowedSizeInMB:t/1024/1024,error:r?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(s){return Q(this,arguments,function*({annotationId:e,commentId:t,attachmentId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let p=c.comments?.find(f=>f?.commentId===t),g=c.metadata;if(p){let f=this.authService.getUser();if(this.isUserAdmin||f?.userId===p?.from?.userId){let I=p.attachments?.find(x=>x?.attachmentId===r);if(I){p.attachments=p.attachments?.filter(G=>G?.attachmentId!==r);let x={attachmentId:I.attachmentId,organizationId:g?.organizationId??null,documentId:g?.documentId??null,folderId:g?.folderId??null,commentAnnotationId:c.annotationId,apiKey:g?.apiKey??null};yield this.commentService.deleteAttachment({attachment:I,metadata:x});let B=yield this.metadataService.getGlobalMetadata(),z={attachment:I,annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:B};return this.triggerAction(zi.DELETE_ATTACHMENT,z),this.updateComment({annotationId:e,comment:p,options:a}),z}}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 Q(this,arguments,function*({annotationId:e,commentId:t,options:r}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getAttachment","color: green;");let s=this.commentService.getAnnotationById(e,r);return s?s.comments?.find(p=>p?.commentId===t)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",s),[]}})}uploadFile(e,t){return Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,t)}catch(r){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",r),null}})}getRecording(a){return Q(this,arguments,function*({annotationId:e,commentId:t,options:r}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getRecording","color: green;");let s=this.commentService.getAnnotationById(e,r);return s?s.comments?.find(p=>p?.commentId===t)?.recorders||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getRecording: ",s),[]}})}deleteRecording(s){return Q(this,arguments,function*({annotationId:e,commentId:t,recorderId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let p=c.comments?.find(g=>g?.commentId===t);if(p){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===p?.from?.userId){let f=p.recorders?.find(I=>I?.id===r);if(f){p.recorders=p.recorders?.filter(B=>B?.id!==r);let I=yield this.metadataService.getGlobalMetadata(),x={annotationId:e,commentId:t,recording:f,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:I};return this.triggerAction(zi.DELETE_RECORDING,x),this.updateComment({annotationId:e,comment:p,skipDeleteThreadConfirmation:!0,options:a}),x}}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 Q(this,null,function*(){try{let t=yield this.commentService.fetchCommentAnnotations(e),r;if(t?.hasMore){let s=t?.data[t?.data?.length-1];r=yield sz(s?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=t?.data?.reduce((s,c)=>(s[c.metadata.clientDocumentId??c.metadata.documentId]=s[c.metadata.clientDocumentId??c.metadata.documentId]||[],s[c.metadata.clientDocumentId??c.metadata.documentId].push(this.commentService.getCommentAnnotationForClient(c)),s),{});return E({data:a},t?.hasMore?{nextPageToken:r}:{})}catch(t){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",t),{data:null}}})}toggleReaction(c,p){return Q(this,arguments,function*({annotationId:e,commentId:t,reaction:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let g=this.commentService.getAnnotationById(e,a),f=this.authService.getUser();if(g&&f){let I=g.comments?.find(x=>x?.commentId===t);if(I){let x=yield this.reactionService.addOrUpdateReaction(r.reactionId,I?.reactionAnnotationIds||[],void 0,void 0,g?.annotationId,r.customReaction,s),B=Wt.REACTION_ADDED;if(x){x?.reactions?.find(J=>J.from?.userId===f?.userId)||(B=Wt.REACTION_DELETED),I.reactionAnnotationIds||(I.reactionAnnotationIds=[]),I.reactionAnnotationIds.includes(x.annotationId)||I.reactionAnnotationIds.push(x.annotationId),x?.reactions?.length||(I.reactionAnnotationIds=I.reactionAnnotationIds.filter(J=>J!==x.annotationId)),this.commentService.saveComment(g,{type:B,updatedComment:I});let z=yield this.metadataService.getGlobalMetadata(),G={annotationId:e,commentId:t,reaction:x,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:z};return s==="add"?this.triggerAction(zi.ADD_REACTION,G):s==="delete"?this.triggerAction(zi.DELETE_REACTION,G):this.triggerAction(zi.TOGGLE_REACTION,G),G}}}else this.triggerAnnotationNotFoundError(e);return null}catch(g){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",g),null}})}onComposerClick(t){return Q(this,arguments,function*({commentAnnotation:e}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onComposerClick","color: green;");let r=yield this.metadataService.getGlobalMetadata(),a={commentAnnotation:e?.annotationId?this.commentService.getCommentAnnotationForClient(e):void 0,metadata:r};this.triggerAction(zi.COMPOSER_CLICKED,a)}catch(r){this.loggingService.catch("Error in CommentActionsService onComposerClick: ",r)}})}autocompleteSearch(e){return Q(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(zi.AUTOCOMPLETE_SEARCH,e)}catch(t){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",t)}})}onCommentPinClick(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentPinClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),r={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(zi.COMMENT_PIN_CLICKED,r),r}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentPinClick: ",t),null}})}onCommentBubbleClick(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentBubbleClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),r={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(zi.COMMENT_BUBBLE_CLICKED,r),r}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentBubbleClick: ",t),null}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:r}=this.docService.getServerId(e?.options);e.options=D(E({},e?.options),{documentId:t,organizationId:r})}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 Qe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in CommentActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in CommentActionsService onAction: ",t),le(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."),le({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),le({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(de(t=>t?t.reduce((r,a)=>{let s=a.metadata?.clientDocumentId;return!s||e?.documentIds&&!e?.documentIds?.includes(s)||(r[s]||(r[s]=[]),r[s].push(a)),r},{}):null),de(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),le({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentViewsService.getAnnotationsCount(e).pipe(de(t=>t||{data:null}))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),le({data:null})}}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(je),ee(we),ee(rge),ee(Si),ee(Wo),ee(ot),ee(En),ee(_),ee(ol),ee(ur),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var L9=class extends gi{constructor(o){super(o),this.getService(_).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.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.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.setRecordings=this._setRecordings,this.addCommentOnElement=this._addCommentOnElement,this.enablePrivateCommentMode=this._enablePrivateCommentMode,this.disablePrivateCommentMode=this._disablePrivateCommentMode,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.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.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.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.on=this._on}_getAllCommentAnnotations(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{documentId:o,location:n}}),this.getService(we).getAllCommentAnnotations({customClientDocumentId:o,params:n,excludeDomChanges:!0,skipPositionCalculation:!0,addFilterCommentsOnDomCheck:!0}).pipe(de(e=>e?.length?e?.map(t=>this.getService(we).getCommentAnnotationForClient(t)):e))}catch(e){return this.getService(_).catch("Error in _getLiveCommentsOnCurrentDocument: ",e),le(null)}}_deleteSelectedComment(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteSelectedComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_SELECTED_COMMENT_TRIGGERED),this.getService(we).deleteCommentPinAnnotations("commentElement")}catch(o){return this.getService(_).catch("Error in _deleteSelectedComment: ",o),Promise.resolve(null)}}_enableTextComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).enableTextComments()}catch(o){this.getService(_).catch("Error in _enableTextComments: ",o)}}_disableTextComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).disableTextComments()}catch(o){this.getService(_).catch("Error in _disableTextComments: ",o)}}_allowedElementIds(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(we).setAllowedElementIds(o)}catch(n){this.getService(_).catch("Error in allowedElementIds: ",n)}}_allowedElementClassNames(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementClassNames","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_CLASS_NAMES_TRIGGERED,{payload:{classNames:o}}),this.getService(we).setAllowedElementClassNames(o)}catch(n){this.getService(_).catch("Error in allowedElementClassNames: ",n)}}_allowedElementQuerySelectors(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementQuerySelectors","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_QUERY_SELECTORS_TRIGGERED,{payload:{querySelectors:o}}),this.getService(we).setAllowedElementQuerySelectors(o)}catch(n){this.getService(_).catch("Error in allowedElementQuerySelectors: ",n)}}_disableFloatingComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!0)}catch(o){this.getService(_).catch("Error in _disableFloatingComments: ",o)}}_enableFloatingComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!1)}catch(o){this.getService(_).catch("Error in _enableFloatingComments: ",o)}}_attachComment(o){this.getService(_).log("%c[WB] Calling FUNCTION: attachComment","color: green;");try{this.trackEvent(Y.Events.Comments.ATTACH_COMMENT_TRIGGERED,{payload:{elementId:o}}),this.getService(we).attachComment(o,["id","data-id"])}catch(n){this.getService(_).catch("Error in _attachComment: ",n)}}_openCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: openCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.OPEN_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!0,!0)}catch(o){this.getService(_).catch("Error in _openCommentSidebar: ",o)}}_closeCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: closeCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.CLOSE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!1,!0)}catch(o){this.getService(_).catch("Error in _closeCommentSidebar: ",o)}}_toggleCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: toggleCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.TOGGLE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).toggleSidebarVisibility(!0)}catch(o){this.getService(_).catch("Error in _toggleCommentSidebar: ",o)}}_enableModeratorMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!0)}catch(o){this.getService(_).catch("Error in _enableModeratorMode: ",o)}}_disableModeratorMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!1)}catch(o){this.getService(_).catch("Error in _disableModeratorMode: ",o)}}_enableStreamMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!0)}catch(o){this.getService(_).catch("Error in _enableStreamMode: ",o)}}_disableStreamMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!1)}catch(o){this.getService(_).catch("Error in _disableStreamMode: ",o)}}_enableSignInButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!0)}catch(o){this.getService(_).catch("Error in _enableSignInButton: ",o)}}_disableSignInButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!1)}catch(o){this.getService(_).catch("Error in _disableSignInButton: ",o)}}_enableUpgradeButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!0)}catch(o){this.getService(_).catch("Error in _enableUpgradeButton: ",o)}}_disableUpgradeButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!1)}catch(o){this.getService(_).catch("Error in _disableUpgradeButton: ",o)}}_onCommentModeChange(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentModeChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_MODE_CHANGE_TRIGGERED),this.getService(we).addCommentModeChange()}catch(o){return this.getService(_).catch("Error in _onCommentModeChange: ",o),le(!1)}}_enableAttachment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!0)}catch(o){this.getService(_).catch("Error in _enableAttachment: ",o)}}_disableAttachment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!1)}catch(o){this.getService(_).catch("Error in _disableAttachment: ",o)}}_isUserGlobalContact(){this.getService(_).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Comments.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(we).isUserGlobalContact$()}catch(o){return this.getService(_).catch("Error in _isUserGlobalContact: ",o),le(!1)}}_enableDeviceInfo(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!0)}catch(o){this.getService(_).catch("Error in _enableDeviceInfo: ",o)}}_disableDeviceInfo(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!1)}catch(o){this.getService(_).catch("Error in _disableDeviceInfo: ",o)}}_enableCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_MODE_TRIGGERED),this.getService(we).enableAddCommentMode()}catch(o){this.getService(_).catch("Error in _enableCommentMode: ",o)}}_disableCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_MODE_TRIGGERED),this.getService(we).disableAddCommentMode()}catch(o){this.getService(_).catch("Error in _disableCommentMode: ",o)}}_enablePersistentCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).enablePersistentCommentMode()}catch(o){this.getService(_).catch("Error in _enablePersistentCommentMode: ",o)}}_disablePersistentCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).disablePersistentCommentMode()}catch(o){this.getService(_).catch("Error in _disablePersistentCommentMode: ",o)}}_showCommentIndex(o){this.getService(_).log("%c[WB] Calling FUNCTION: showCommentIndex","color: green;");try{this.getService(we).showCommentIndex(o)}catch(n){this.getService(_).catch("Error in _showCommentIndex: ",n)}}_enableCommentIndex(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!0)}catch(o){this.getService(_).catch("Error in _enableCommentIndex: ",o)}}_disableCommentIndex(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!1)}catch(o){this.getService(_).catch("Error in _disableCommentIndex: ",o)}}_enablePopoverMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_MODE_TRIGGERED),this.getService(we).enablePopoverMode()}catch(o){this.getService(_).catch("Error in _enablePopoverMode: ",o)}}_disablePopoverMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_MODE_TRIGGERED),this.getService(we).disablePopoverMode()}catch(o){this.getService(_).catch("Error in _disablePopoverMode: ",o)}}_enableDialogOnHover(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!0)}catch(o){this.getService(_).catch("Error in _enableDialogOnHover: ",o)}}_disableDialogOnHover(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!1)}catch(o){this.getService(_).catch("Error in _disableDialogOnHover: ",o)}}_enablePopoverTriangleComponent(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).enablePopoverTriangleComponent()}catch(o){this.getService(_).catch("Error in _enablePopoverTriangleComponent: ",o)}}_disablePopoverTriangleComponent(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).disablePopoverTriangleComponent()}catch(o){this.getService(_).catch("Error in _disablePopoverTriangleComponent: ",o)}}_enableDialogOnTargetElementClick(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!0)}catch(o){this.getService(_).catch("Error in _enableDialogOnTargetElementClick: ",o)}}_disableDialogOnTargetElementClick(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!1)}catch(o){this.getService(_).catch("Error in _disableDialogOnTargetElementClick: ",o)}}_enablePriority(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!0)}catch(o){this.getService(_).catch("Error in _enablePriority: ",o)}}_disablePriority(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!1)}catch(o){this.getService(_).catch("Error in _disablePriority: ",o)}}_enableStatus(){this.getService(_).log("%c[WB] Calling FUNCTION: enableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!0)}catch(o){this.getService(_).catch("Error in _enableStatus: ",o)}}_disableStatus(){this.getService(_).log("%c[WB] Calling FUNCTION: disableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!1)}catch(o){this.getService(_).catch("Error in _disableStatus: ",o)}}_enableResolveButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!0)}catch(o){this.getService(_).catch("Error in _enableResolveButton: ",o)}}_disableResolveButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!1)}catch(o){this.getService(_).catch("Error in _disableResolveButton: ",o)}}_enableGhostComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).enableGhostComments()}catch(o){this.getService(_).catch("Error in _enableGhostCommentsInDOM: ",o)}}_disableGhostComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).disableGhostComments()}catch(o){this.getService(_).catch("Error in _disableGhostComments: ",o)}}_enableGhostCommentsIndicator(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).enableGhostCommentsMessage()}catch(o){this.getService(_).catch("Error in _enableGhostCommentsIndicator: ",o)}}_disableGhostCommentsIndicator(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).disableGhostCommentsMessage()}catch(o){this.getService(_).catch("Error in _disableGhostCommentsIndicator: ",o)}}_setCustomStatus(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomStatus","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_STATUS_TRIGGERED,{payload:{customStatuses:o}}),this.getService(we).setCustomStatuses(o)}catch(n){this.getService(_).catch("Error in _setCustomStatus: ",n)}}_enableInboxMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INBOX_MODE_TRIGGERED),this.getService(we).enableInboxMode()}catch(o){this.getService(_).catch("Error in _enableInboxMode: ",o)}}_setCustomPriority(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomPriority","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_PRIORITY_TRIGGERED,{payload:{customPriorities:o}}),this.getService(we).setCustomPriorities(o)}catch(n){this.getService(_).catch("Error in _setCustomPriority: ",n)}}_setCustomCategory(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomCategory","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_CATEGORY_TRIGGERED,{payload:{customCategories:o}}),this.getService(we).setCustomCategories(o)}catch(n){this.getService(_).catch("Error in _setCustomCategory: ",n)}}_disableInboxMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INBOX_MODE_TRIGGERED),this.getService(we).disableInboxMode()}catch(o){this.getService(_).catch("Error in _disableInboxMode: ",o)}}_enableAutoCategorize(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!0)}catch(o){this.getService(_).catch("Error in _enableAutoCategorize: ",o)}}_disableAutoCategorize(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!1)}catch(o){this.getService(_).catch("Error in _disableAutoCategorize: ",o)}}_enableDarkMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!0)}catch(o){this.getService(_).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!1)}catch(o){this.getService(_).catch("Error in _disableDarkMode: ",o)}}_setContextProvider(o){try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_PROVIDER_TRIGGERED,{payload:{documentId:fpe,location}}),this.getService(we).setContextProvider(o)}catch(n){this.getService(_).catch("Error in _setContextProvider: ",n)}}_enableSuggestionMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!0)}catch(o){this.getService(_).catch("Error in _enableSuggestionMode: ",o)}}_disableSuggestionMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!1)}catch(o){this.getService(_).catch("Error in _disableSuggestionMode: ",o)}}_enableMobileMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!0)}catch(o){this.getService(_).catch("Error in _enableMobileMode: ",o)}}_disableMobileMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!1)}catch(o){this.getService(_).catch("Error in _disableMobileMode: ",o)}}_enableInlineCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).enableInlineCommentMode()}catch(o){this.getService(_).catch("Error in _enableInlineCommentMode: ",o)}}_disableInlineCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).disableInlineCommentMode()}catch(o){this.getService(_).catch("Error in _disableInlineCommentMode: ",o)}}_enableMinimap(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MINIMAP_TRIGGERED),this.getService(we).enableMinimap()}catch(o){this.getService(_).catch("Error in _enableMinimap: ",o)}}_disableMinimap(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MINIMAP_TRIGGERED),this.getService(we).disableMinimap()}catch(o){this.getService(_).catch("Error in _disableMinimap: ",o)}}_showCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: showCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showCommentsOnDom()}catch(o){this.getService(_).catch("Error in _showCommentsOnDom: ",o)}}_hideCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: hideCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideCommentsOnDom()}catch(o){this.getService(_).catch("Error in _hideCommentsOnDom: ",o)}}_enableCommentTool(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).enableCommentTool()}catch(o){this.getService(_).catch("Error in _enableCommentTool: ",o)}}_disableCommentTool(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).disableCommentTool()}catch(o){this.getService(_).catch("Error in _disableCommentTool: ",o)}}_setTotalMediaLength(o){this.getService(_).log("%c[WB] Calling FUNCTION: setTotalMediaLength","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TOTAL_MEDIA_LENGTH_TRIGGERED,{payload:{length:o}}),this.getService(we).setTotalMediaLength(o)}catch(n){this.getService(_).catch("Error in _setTotalMediaLength: ",n)}}_onCommentAdd(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentAdd","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_ADD_TRIGGERED),this.getService(we).onCommentAdd$()}catch(o){return this.getService(_).catch("Error in _onCommentAdd: ",o),le()}}_onCommentUpdate(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentUpdate","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_UPDATE_TRIGGERED),this.getService(we).onCommentUpdate$()}catch(o){return this.getService(_).catch("Error in _onCommentUpdate: ",o),le()}}_addCommentOnSelectedText(){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentOnSelectedText","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_SELECTED_TEXT_TRIGGERED),this.getService(we).addCommentOnSelectedText()}catch(o){this.getService(_).catch("Error in _addCommentOnSelectedText: ",o)}}_enableSidebarUrlNavigation(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).enableSidebarUrlNavigation()}catch(o){this.getService(_).catch("Error in _enableSidebarUrlNavigation: ",o)}}_disableSidebarUrlNavigation(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).disableSidebarUrlNavigation()}catch(o){this.getService(_).catch("Error in _disableSidebarUrlNavigation: ",o)}}_setDStrategy(o){this.getService(_).log("%c[WB] Calling FUNCTION: setDStrategy","color: green;");try{this.trackEvent(Y.Events.Comments.SET_D_STRATEGY_TRIGGERED,{payload:{strategy:o}}),this.getService(we).setDetectionStrategy(o)}catch(n){this.getService(_).catch("Error in _setDStrategy: ",n)}}_enableSidebarButtonOnCommentDialog(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).enableSidebarButtonOnCommentDialog()}catch(o){this.getService(_).catch("Error in _enableSidebarButtonOnCommentDialog: ",o)}}_disableSidebarButtonOnCommentDialog(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableSidebarButtonOnCommentDialog()}catch(o){this.getService(_).catch("Error in _disableSidebarButtonOnCommentDialog: ",o)}}_onSidebarButtonOnCommentDialogClick(){this.getService(_).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(we).getSidebarButtonOnCommentDialogClick$()}catch(o){return this.getService(_).catch("Error in _onSidebarButtonOnCommentDialogClick: ",o),le(null)}}_enableReactions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REACTIONS_TRIGGERED),this.getService(we).enableReactions()}catch(o){this.getService(_).catch("Error in _enableReactions: ",o)}}_disableReactions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REACTIONS_TRIGGERED),this.getService(we).disableReactions()}catch(o){this.getService(_).catch("Error in _disableReactions: ",o)}}_setRecordings(o){this.getService(_).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(n=>n.trim())),this.getService(we).setAllowedRecordings(o)}catch(n){this.getService(_).catch("Error in _setRecordings: ",n)}}_addCommentOnElement(o){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentOnElement","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_ELEMENT_TRIGGERED,{payload:{data:o}}),this.getService(we).addCommentOnElement(o)}catch(n){this.getService(_).catch("Error in _addCommentOnElement: ",n)}}_enablePrivateCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).enablePrivateCommentMode()}catch(o){this.getService(_).catch("Error in _enablePrivateCommentMode: ",o)}}_disablePrivateCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).disablePrivateCommentMode()}catch(o){this.getService(_).catch("Error in _disablePrivateCommentMode: ",o)}}_enableScrollToComment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).enableScrollToComment()}catch(o){this.getService(_).catch("Error in _enableScrollToComment: ",o)}}_disableScrollToComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).disableScrollToComment()}catch(o){this.getService(_).catch("Error in _disableScrollToComment: ",o)}}_enableUserMentions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_USER_MENTIONS_TRIGGERED),this.getService(we).enableUserMentions()}catch(o){this.getService(_).catch("Error in _enableUserMentions: ",o)}}_disableUserMentions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_USER_MENTIONS_TRIGGERED),this.getService(we).disableUserMentions()}catch(o){this.getService(_).catch("Error in _disableUserMentions: ",o)}}_setCommentSidebarFilters(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_FILTERS_TRIGGERED,{payload:{filters:o}}),this.getService(we).setCommentSidebarFilters(o)}catch(n){this.getService(_).catch("Error in _setCommentSidebarFilters: ",n)}}_setSystemFiltersOperator(o){this.getService(_).log("%c[WB] Calling FUNCTION: setSystemFiltersOperator","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SYSTEM_FILTERS_OPERATOR_TRIGGERED,{payload:{operator:o}}),this.getService(we).setCommentSidebarSystemFiltersOperator(o)}catch(n){this.getService(_).catch("Error in _setSystemFiltersOperator: ",n)}}_enableCommentPinHighlighter(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(we).enableCommentPinHighlighter()}catch(o){this.getService(_).catch("Error in _enableCommentPinHighlighter: ",o)}}_disableCommentPinHighlighter(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentPinHighlighter","color: green;");try{this.getService(we).disableCommentPinHighlighter()}catch(o){this.getService(_).catch("Error in _disableCommentPinHighlighter: ",o)}}_enableDeleteOnBackspace(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).enableDeleteOnBackspace()}catch(o){this.getService(_).catch("Error in _enableDeleteOnBackspace: ",o)}}_disableDeleteOnBackspace(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).disableDeleteOnBackspace()}catch(o){this.getService(_).catch("Error in _disableDeleteOnBackspace: ",o)}}_enableHotkey(){this.getService(_).log("%c[WB] Calling FUNCTION: enableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_HOTKEY_TRIGGERED),this.getService(we).enableHotkey()}catch(o){this.getService(_).catch("Error in _enableHotkey: ",o)}}_disableHotkey(){this.getService(_).log("%c[WB] Calling FUNCTION: disableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_HOTKEY_TRIGGERED),this.getService(we).disableHotkey()}catch(o){this.getService(_).catch("Error in _disableHotkey: ",o)}}_enableDeviceIndicatorOnCommentPins(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).enableDeviceIndicatorOnCommentPins()}catch(o){this.getService(_).catch("Error in _enableDeviceIndicatorOnCommentPins: ",o)}}_disableDeviceIndicatorOnCommentPins(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).disableDeviceIndicatorOnCommentPins()}catch(o){this.getService(_).catch("Error in _disableDeviceIndicatorOnCommentPins: ",o)}}_getElementRefByAnnotationId(o){this.getService(_).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(we).getElementRefByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _getElementRefByAnnotationId: ",n);return}}_scrollToCommentByAnnotationId(o){this.getService(_).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(we).scrollToCommentByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _scrollToCommentByAnnotationId: ",n)}}_selectCommentByAnnotationId(o){this.getService(_).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(we).selectCommentByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _selectCommentByAnnotationId: ",n)}}_enableRecordingSummary(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).enableRecordingSummary()}catch(o){this.getService(_).catch("Error in _enableRecordingSummary: ",o)}}_disableRecordingSummary(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).disableRecordingSummary()}catch(o){this.getService(_).catch("Error in _disableRecordingSummary: ",o)}}_enableRecordingTranscription(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(Wi).enableRecordingTranscription()}catch(o){this.getService(_).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(Wi).disableRecordingTranscription()}catch(o){this.getService(_).catch("Error in _disableRecordingTranscription: ",o)}}_enableRecordingCountdown(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).enableRecordingCountdown()}catch(o){this.getService(_).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).disableRecordingCountdown()}catch(o){this.getService(_).catch("Error in _disableRecordingCountdown: ",o)}}_setUnreadIndicatorMode(o){this.getService(_).log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;");try{this.trackEvent(Y.Events.Comments.SET_UNREAD_INDICATOR_MODE_TRIGGERED,{payload:{mode:o}}),this.getService(we).setUnreadIndicatorMode(o)}catch(n){this.getService(_).catch("Error in _setUnreadIndicatorMode: ",n)}}_enableEnterKeyToSubmit(){this.getService(_).log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).enableEnterKeyToSubmit()}catch(o){this.getService(_).catch("Error in _enableEnterKeyToSubmit: ",o)}}_disableEnterKeyToSubmit(){this.getService(_).log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).disableEnterKeyToSubmit()}catch(o){this.getService(_).catch("Error in _disableEnterKeyToSubmit: ",o)}}_enablePinShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).enablePinShadowDOM()}catch(o){this.getService(_).catch("Error in _enablePinShadowDOM: ",o)}}_disablePinShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).disablePinShadowDOM()}catch(o){this.getService(_).catch("Error in _disablePinShadowDOM: ",o)}}_enableDialogShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).enableDialogShadowDOM()}catch(o){this.getService(_).catch("Error in _enableDialogShadowDOM: ",o)}}_disableDialogShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).disableDialogShadowDOM()}catch(o){this.getService(_).catch("Error in _disableDialogShadowDOM: ",o)}}_enableSidebarShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).enableSidebarShadowDOM()}catch(o){this.getService(_).catch("Error in _enableSidebarShadowDOM: ",o)}}_disableSidebarShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).disableSidebarShadowDOM()}catch(o){this.getService(_).catch("Error in _disableSidebarShadowDOM: ",o)}}_enableChangeDetectionInCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).enableChangeDetectionInCommentMode()}catch(o){this.getService(_).catch("Error in _enableChangeDetectionInCommentMode: ",o)}}_disableChangeDetectionInCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).disableChangeDetectionInCommentMode()}catch(o){this.getService(_).catch("Error in _disableChangeDetectionInCommentMode: ",o)}}_showResolvedCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: showResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showResolvedCommentsOnDom()}catch(o){this.getService(_).catch("Error in _showResolvedCommentsOnDom: ",o)}}_hideResolvedCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: hideResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideResolvedCommentsOnDom()}catch(o){this.getService(_).catch("Error in _hideResolvedCommentsOnDom: ",o)}}_setCustomReactions(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(we).setCustomReactions(o)}catch(n){this.getService(_).catch("Error in _setCustomReactions: ",n)}}_onCommentSelectionChange(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSelectionChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SELECTION_CHANGE_TRIGGERED),this.getService(we).onCommentSelectionChange$()}catch(o){return this.getService(_).catch("Error in _onCommentSelectionChange: ",o),le(null)}}_getUnreadCommentCountByAnnotationId(o){this.getService(_).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(we).getUnreadCommentCountByAnnotationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentCountByAnnotationId: ",n),le(null)}}_getUnreadCommentAnnotationCountOnCurrentDocument(){this.getService(_).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(we).getUnreadCommentAnnotationCountOnCurrentDocument$()}catch(o){return this.getService(_).catch("Error in _getUnreadCommentAnnotationCountOnCurrentDocument: ",o),le(null)}}_getUnreadCommentCountOnCurrentDocument(){this.getService(_).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(we).getUnreadCommentCountOnCurrentDocument$()}catch(o){return this.getService(_).catch("Error in _getUnreadCommentCountOnCurrentDocument: ",o),le(null)}}_getUnreadCommentAnnotationCountByLocationId(o){this.getService(_).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(we).getUnreadCommentAnnotationCountByLocationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentAnnotationCountByLocationId: ",n),le(null)}}_getUnreadCommentCountByLocationId(o){this.getService(_).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(we).getUnreadCommentCountByLocationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentCountByLocationId: ",n),le(null)}}_updateCommentDialogPosition(){this.getService(_).log("%c[WB] Calling FUNCTION: updateCommentDialogPosition","color: green;");try{this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_DIALOG_POSITION_TRIGGERED),this.getService(we).updateCommentDialogPosition()}catch(o){this.getService(_).catch("Error in _updateCommentDialogPosition: ",o)}}_enableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(we).enableAreaComment()}catch(o){this.getService(_).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(we).disableAreaComment()}catch(o){this.getService(_).catch("Error in _disableAreaComment: ",o)}}_setPinCursorImage(o){this.getService(_).log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;");try{this.trackEvent(Y.Events.Comments.SET_PIN_CURSOR_IMAGE_TRIGGERED,{payload:{image:o}}),this.getService(we).setPinCursorImage(o)}catch(n){this.getService(_).catch("Error in _setPinCursorImage: ",n)}}_addManualComment(o){this.getService(_).log("%c[WB] Calling FUNCTION: addManualComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_MANUAL_COMMENT_TRIGGERED,{payload:{config:o}}),this.getService(we).addManualComment(o)}catch(n){return this.getService(_).catch("Error in _addManualComment: ",n),Promise.resolve()}}_createCustomListDataOnAnnotation(o){this.getService(_).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(we).createCustomListDataOnAnnotation(o)}catch(n){this.getService(_).catch("Error in _createCustomListDataOnAnnotation: ",n)}}_createCustomListDataOnComment(o){this.getService(_).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(Fl).create(o)}catch(n){this.getService(_).catch("Error in _createCustomListDataOnComment: ",n)}}_excludeLocationIdsFromSidebar(o){this.getService(_).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(we).setExcludeLocationIdsFromSidebar(o)}catch(n){this.getService(_).catch("Error in _excludeLocationIdsFromSidebar: ",n)}}_enableBubbleOnPin(){this.getService(_).log("%c[WB] Calling FUNCTION: enableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).enableBubbleOnPin()}catch(o){this.getService(_).catch("Error in _enableBubbleOnPin: ",o)}}_disableBubbleOnPin(){this.getService(_).log("%c[WB] Calling FUNCTION: disableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).disableBubbleOnPin()}catch(o){this.getService(_).catch("Error in _disableBubbleOnPin: ",o)}}_enableBubbleOnPinHover(){this.getService(_).log("%c[WB] Calling FUNCTION: enableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).enableBubbleOnPinHover()}catch(o){this.getService(_).catch("Error in _enableBubbleOnPinHover: ",o)}}_disableBubbleOnPinHover(){this.getService(_).log("%c[WB] Calling FUNCTION: disableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).disableBubbleOnPinHover()}catch(o){this.getService(_).catch("Error in _disableBubbleOnPinHover: ",o)}}_enableMultiThread(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MULTI_THREAD_TRIGGERED),this.getService(we).enableMultiThread()}catch(o){this.getService(_).catch("Error in _enableMultiThread: ",o)}}_disableMultiThread(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MULTI_THREAD_TRIGGERED),this.getService(we).disableMultiThread()}catch(o){this.getService(_).catch("Error in _disableMultiThread: ",o)}}_enableGroupMatchedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(we).enableGroupMatchedComments()}catch(o){this.getService(_).catch("Error in _enableGroupMatchedComments: ",o)}}_disableGroupMatchedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(we).disableGroupMatchedComments()}catch(o){this.getService(_).catch("Error in _disableGroupMatchedComments: ",o)}}_updateContext(o,n,e){this.getService(_).log("%c[WB] Calling FUNCTION: updateContext","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_CONTEXT_TRIGGERED,{payload:{annotationId:o,context:n,config:e}}),this.getService(we).updateCommentAnnotationContext(o,n,e)}catch(t){return this.getService(_).catch("Error in _updateContext: ",t),Promise.resolve()}}_getSelectedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: getSelectedComments","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_SELECTED_COMMENTS_TRIGGERED),this.getService(Be).getSelectedComments$()}catch(o){return this.getService(_).catch("Error in _getSelectedComments: ",o),le([])}}_enableDeleteReplyConfirmation(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(we).enableDeleteReplyConfirmation()}catch(o){this.getService(_).catch("Error in _enableDeleteReplyConfirmation: ",o)}}_disableDeleteReplyConfirmation(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeleteReplyConfirmation","color: green;");try{this.getService(we).disableDeleteReplyConfirmation()}catch(o){this.getService(_).catch("Error in _disableDeleteReplyConfirmation: ",o)}}_onCopyLink(){this.getService(_).log("%c[WB] Calling FUNCTION: onCopyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COPY_LINK_TRIGGERED),this.getService(we).getCopyLink$()}catch(o){return this.getService(_).catch("Error in _onCopyLink: ",o),le("")}}_getCommentAnnotationById(o){this.getService(_).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(we).getCommentAnnotationById(o)}catch(n){return this.getService(_).catch("Error in _getCommentAnnotationById: ",n),le(null)}}_enableCollapsedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).enableCollapsedComments()}catch(o){this.getService(_).catch("Error in _enableCollapsedComments: ",o)}}_disableCollapsedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).disableCollapsedComments()}catch(o){this.getService(_).catch("Error in _disableCollapsedComments: ",o)}}_onCommentSidebarActionButtonClick(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarActionButtonClick","color: green;");try{return this.getService(we).getSidebarCustomActionEventData()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarActionButtonClick: ",o),le(null)}}_setCommentSidebarData(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: setCommentSidebarData","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DATA_TRIGGERED,{payload:{data:o,options:n}}),this.getService(we).setCommentSidebarData(o,n)}catch(e){this.getService(_).catch("Error in _setCommentSidebarData: ",e)}}_onCommentSidebarInit(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarInit","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_INIT_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataOnInit()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarInit: ",o),le(null)}}_onCommentSidebarData(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarData","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_DATA_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataAllChanges()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarData: ",o),le(null)}}_setCommentSidebarDefaultCustomActions(o){this.getService(_).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(we).setSidebarCustomActionEventData(o,[],{},[],{})}catch(n){this.getService(_).catch("Error in _setCommentSidebarDefaultCustomActions: ",n)}}_enableSidebarCustomActions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).enableSidebarCustomActions()}catch(o){this.getService(_).catch("Error in _enableSidebarCustomActions: ",o)}}_disableSidebarCustomActions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).disableSidebarCustomActions()}catch(o){this.getService(_).catch("Error in _disableSidebarCustomActions: ",o)}}_enableQueryParamsComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).enableQueryParamsComments()}catch(o){this.getService(_).catch("Error in _enableQueryParamsComments: ",o)}}_disableQueryParamsComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).disableQueryParamsComments()}catch(o){this.getService(_).catch("Error in _disableQueryParamsComments: ",o)}}_enableResolveStatusAccessAdminOnly(){this.getService(_).log("%c[WB] Calling FUNCTION: enableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).enableResolveStatusAccessAdminOnly()}catch(o){this.getService(_).catch("Error in _enableResolveStatusAccessAdminOnly: ",o)}}_disableResolveStatusAccessAdminOnly(){this.getService(_).log("%c[WB] Calling FUNCTION: disableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).disableResolveStatusAccessAdminOnly()}catch(o){this.getService(_).catch("Error in _disableResolveStatusAccessAdminOnly: ",o)}}_enableLinkCallback(){this.getService(_).log("%c[WB] Calling FUNCTION: enableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_LINK_CALLBACK_TRIGGERED),this.getService(we).enableLinkCallback()}catch(o){this.getService(_).catch("Error in _enableLinkCallback: ",o)}}_disableLinkCallback(){this.getService(_).log("%c[WB] Calling FUNCTION: disableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_LINK_CALLBACK_TRIGGERED),this.getService(we).disableLinkCallback()}catch(o){this.getService(_).catch("Error in _disableLinkCallback: ",o)}}_enableSeenByUsers(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).enableSeenByUsers()}catch(o){this.getService(_).catch("Error in _enableSeenByUsers: ",o)}}_disableSeenByUsers(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).disableSeenByUsers()}catch(o){this.getService(_).catch("Error in _disableSeenByUsers: ",o)}}_enableShortUserName(){this.getService(_).log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).enableShortUserName()}catch(o){this.getService(_).catch("Error in _enableShortUserName: ",o)}}_disableShortUserName(){this.getService(_).log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).disableShortUserName()}catch(o){this.getService(_).catch("Error in _disableShortUserName: ",o)}}_addCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_ANNOTATION_TRIGGERED,{payload:{addCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).addCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _addCommentAnnotation: ",n),null}})}_approveCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: approveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.APPROVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{approveCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).approveCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _approveCommentAnnotation: ",n),null}})}_acceptCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: acceptCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ACCEPT_COMMENT_ANNOTATION_TRIGGERED,{payload:{acceptCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).acceptCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _acceptCommentAnnotation: ",n),null}})}_rejectCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: rejectCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.REJECT_COMMENT_ANNOTATION_TRIGGERED,{payload:{rejectCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).rejectCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _rejectCommentAnnotation: ",n),null}})}_subscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: subscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.SUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{subscribeCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).toggleNotificationSubscription(o,"subscribe")}catch(n){return this.getService(_).catch("Error in _subscribeCommentAnnotation: ",n),null}})}_unsubscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: unsubscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.UNSUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{unsubscribeCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).toggleNotificationSubscription(o,"unsubscribe")}catch(n){return this.getService(_).catch("Error in _unsubscribeCommentAnnotation: ",n),null}})}_deleteCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_ANNOTATION_TRIGGERED,{payload:{deleteCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).deleteCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _deleteCommentAnnotation: ",n),null}})}_getCommentAnnotations(o){this.getService(_).log("%c[WB] Calling FUNCTION: getCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{query:o}}),this.getService(Xn).getCommentAnnotations(o).pipe(de(n=>(n.data&&Object.keys(n.data).forEach(e=>{if(n.data?.[e]?.length){let t=n.data[e];n.data[e]=t?.map(r=>this.getService(we).getCommentAnnotationForClient(r))}}),n)))}catch(n){return this.getService(_).catch("Error in _getCommentAnnotations: ",n),le({data:null})}}_getCommentAnnotationsCount(o){this.getService(_).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(Xn).getCommentAnnotationsCount$(o)}catch(n){return this.getService(_).catch("Error in _getCommentAnnotationsCount: ",n),le({data:null})}}_assignUser(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: assignUser","color: green;");try{return this.trackEvent(Y.Events.Comments.ASSIGN_USER_TRIGGERED,{payload:{assignUserRequest:o}}),this.getService(Xn).convert(o).assignUser(o,"external")}catch(n){return this.getService(_).catch("Error in _assignUser: ",n),null}})}_updatePriority(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updatePriority","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_PRIORITY_TRIGGERED,{payload:{updatePriorityRequest:o}}),this.getService(Xn).convert(o).updatePriority(o,"external")}catch(n){return this.getService(_).catch("Error in _updatePriority: ",n),null}})}_updateStatus(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateStatus","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_STATUS_TRIGGERED,{payload:{updateStatusRequest:o}}),this.getService(Xn).convert(o).updateStatus(o,"external")}catch(n){return this.getService(_).catch("Error in _updateStatus: ",n),null}})}_updateAccess(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateAccess","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_ACCESS_TRIGGERED,{payload:{updateAccessRequest:o}}),this.getService(Xn).convert(o).updateAccess(o,"external")}catch(n){return this.getService(_).catch("Error in _updateAccess: ",n),null}})}_resolveCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: resolveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.RESOLVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{resolveCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).resolveCommentAnnotation(o)}catch(n){return this.getService(_).catch("Error in _resolveCommentAnnotation: ",n),null}})}_getLink(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getLink","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_LINK_TRIGGERED,{payload:{getLinkRequest:o}}),this.getService(Xn).convert(o).getLink(o,"external")}catch(n){return this.getService(_).catch("Error in _getLink: ",n),null}})}_copyLink(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: copyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.COPY_LINK_TRIGGERED,{payload:{copyLinkRequest:o}}),this.getService(Xn).convert(o).copyLink(o,"external")}catch(n){return this.getService(_).catch("Error in _copyLink: ",n),null}})}_addComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_TRIGGERED,{payload:{addCommentRequest:o}}),this.getService(Xn).convert(o).addComment(o,"external")}catch(n){return this.getService(_).catch("Error in _addComment: ",n),null}})}_updateComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_TRIGGERED,{payload:{updateCommentRequest:o}}),this.getService(Xn).convert(o).updateComment(o,"external")}catch(n){return this.getService(_).catch("Error in _updateComment: ",n),null}})}_deleteComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_TRIGGERED,{payload:{deleteCommentRequest:o}}),this.getService(Xn).convert(o).deleteComment(o,"external")}catch(n){return this.getService(_).catch("Error in _deleteComment: ",n),null}})}_getComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getComment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_TRIGGERED,{payload:{getCommentRequest:o}}),this.getService(Xn).convert(o).getComment(o)}catch(n){return this.getService(_).catch("Error in _getComment: ",n),[]}})}_addAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_ATTACHMENT_TRIGGERED,{payload:{addAttachmentRequest:o}}),this.getService(Xn).convert(o).addAttachment(o)}catch(n){return this.getService(_).catch("Error in _addAttachment: ",n),Promise.resolve([])}})}_deleteAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_ATTACHMENT_TRIGGERED,{payload:{deleteAttachmentRequest:o}}),this.getService(Xn).convert(o).deleteAttachment(o)}catch(n){return this.getService(_).catch("Error in _deleteAttachment: ",n),null}})}_getAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ATTACHMENT_TRIGGERED,{payload:{getAttachmentRequest:o}}),this.getService(Xn).convert(o).getAttachment(o)}catch(n){return this.getService(_).catch("Error in _getAttachment: ",n),[]}})}_getRecording(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_RECORDING_TRIGGERED,{payload:{getRecordingRequest:o}}),this.getService(Xn).convert(o).getRecording(o)}catch(n){return this.getService(_).catch("Error in _getRecording: ",n),[]}})}_deleteRecording(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_RECORDING_TRIGGERED,{payload:{deleteRecordingRequest:o}}),this.getService(Xn).convert(o).deleteRecording(o)}catch(n){return this.getService(_).catch("Error in _deleteRecording: ",n),null}})}_fetchCommentAnnotations(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: fetchCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.FETCH_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{fetchCommentAnnotationsRequest:o}}),this.getService(Xn).fetchCommentAnnotations(o)}catch(n){return this.getService(_).catch("Error in _fetchCommentAnnotations: ",n),{data:null}}})}_addReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_REACTION_TRIGGERED,{payload:{addReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o,"add")}catch(n){return this.getService(_).catch("Error in _addReaction: ",n),null}})}_deleteReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_REACTION_TRIGGERED,{payload:{deleteReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o,"delete")}catch(n){return this.getService(_).catch("Error in _deleteReaction: ",n),null}})}_toggleReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: toggleReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.TOGGLE_REACTION_TRIGGERED,{payload:{toggleReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o)}catch(n){return this.getService(_).catch("Error in _toggleReaction: ",n),null}})}_on(o){this.getService(_).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(Xn).onAction(o)}catch(n){return this.getService(_).catch("Error in _on: ",n),le(null)}}_enableReadOnly(){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.ENABLE_READ_ONLY_TRIGGERED),this.getService(we).enableReadOnly()}catch(o){this.getService(_).catch("Error in _toggleReaction: ",o);return}})}_disableReadOnly(){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.DISABLE_READ_ONLY_TRIGGERED),this.getService(we).disableReadOnly()}catch(o){this.getService(_).catch("Error in _disableReadOnly: ",o);return}})}_enableCustomAutocompleteSearch(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).enableCustomAutocompleteSearch()}catch(o){this.getService(_).catch("Error in _enableCustomAutocompleteSearch: ",o);return}}_disableCustomAutocompleteSearch(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).disableCustomAutocompleteSearch()}catch(o){this.getService(_).catch("Error in _disableCustomAutocompleteSearch: ",o);return}}_setTransformContext(o){this.getService(_).log("%c[WB] Calling FUNCTION: setTransformContext","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TRANSFORM_CONTEXT_TRIGGERED,{payload:{transformContext:o}}),this.getService(we).setTransformContext(o)}catch(n){this.getService(_).catch("Error in _setTransformContext: ",n);return}}_enableSvgAsImg(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).enableSvgAsImg()}catch(o){this.getService(_).catch("Error in _enableSvgAsImg: ",o);return}}_disableSvgAsImg(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).disableSvgAsImg()}catch(o){this.getService(_).catch("Error in _disableSvgAsImg: ",o);return}}_enableFullExpanded(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).enableFullExpanded()}catch(o){this.getService(_).catch("Error in _enableFullExpanded: ",o);return}}_disableFullExpanded(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).disableFullExpanded()}catch(o){this.getService(_).catch("Error in _disableFullExpanded: ",o);return}}_enableCommentToNearestAllowedElement(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).enableCommentToNearestAllowedElement()}catch(o){this.getService(_).catch("Error in _enableCommentToNearestAllowedElement: ",o);return}}_disableCommentToNearestAllowedElement(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).disableCommentToNearestAllowedElement()}catch(o){this.getService(_).catch("Error in _disableCommentToNearestAllowedElement: ",o);return}}_enableDraftMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DRAFT_MODE_TRIGGERED),this.getService(we).enableDraftMode()}catch(o){this.getService(_).catch("Error in _enableDraftMode: ",o);return}}_disableDraftMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DRAFT_MODE_TRIGGERED),this.getService(we).disableDraftMode()}catch(o){this.getService(_).catch("Error in _disableDraftMode: ",o);return}}_enableFilterCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).enableFilterCommentsOnDom()}catch(o){this.getService(_).catch("Error in _enableFilterCommentsOnDom: ",o);return}}_disableFilterCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).disableFilterCommentsOnDom()}catch(o){this.getService(_).catch("Error in _disableFilterCommentsOnDom: ",o);return}}_enableReplyAvatars(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REPLY_AVATARS_TRIGGERED),this.getService(we).enableReplyAvatars()}catch(o){this.getService(_).catch("Error in _enableReplyAvatars: ",o);return}}_disableReplyAvatars(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REPLY_AVATARS_TRIGGERED),this.getService(we).disableReplyAvatars()}catch(o){this.getService(_).catch("Error in _disableReplyAvatars: ",o);return}}_setMaxReplyAvatars(o){this.getService(_).log("%c[WB] Calling FUNCTION: setMaxReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.SET_MAX_REPLY_AVATARS_TRIGGERED,{payload:{maxReplyAvatars:o}}),this.getService(we).setMaxReplyAvatars(o)}catch(n){this.getService(_).catch("Error in _setMaxReplyAvatars: ",n);return}}_setSidebarButtonCountType(o){this.getService(_).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(we).setSidebarButtonCountType(o)}catch(n){this.getService(_).catch("Error in _setSidebarButtonCountType: ",n);return}}_enableFilterGhostCommentsInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(we).enableFilterGhostCommentsInSidebar()}catch(o){this.getService(_).catch("Error in _enableFilterGhostCommentsInSidebar: ",o);return}}_disableFilterGhostCommentsInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(we).disableFilterGhostCommentsInSidebar()}catch(o){this.getService(_).catch("Error in _disableFilterGhostCommentsInSidebar: ",o);return}}_enableFullScreenInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(we).enableFullScreenInSidebar()}catch(o){this.getService(_).catch("Error in _enableFullScreenInSidebar: ",o);return}}_disableFullScreenInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(we).disableFullScreenInSidebar()}catch(o){this.getService(_).catch("Error in _disableFullScreenInSidebar: ",o);return}}_setComposerFileAttachments(o){this.getService(_).log("%c[WB] Calling FUNCTION: setComposerFileAttachments","color: green;");try{this.getService(we).setComposerFileAttachments(o),this.trackEvent(Y.Events.Comments.SET_COMPOSER_FILE_ATTACHMENTS_TRIGGERED,{payload:{data:o}})}catch(n){this.getService(_).catch("Error in _setComposerFileAttachments: ",n);return}}_setAllowedFileTypes(o){this.getService(_).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(we).setAllowedFileTypes(o)}catch(n){this.getService(_).catch("Error in _setAllowedFileTypes: ",n);return}}_enableForceCloseAllOnEsc(){this.getService(_).log("%c[WB] Calling FUNCTION: enableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(we).enableForceCloseAllOnEsc()}catch(o){this.getService(_).catch("Error in _enableForceCloseAllOnEsc: ",o);return}}_disableForceCloseAllOnEsc(){this.getService(_).log("%c[WB] Calling FUNCTION: disableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(we).disableForceCloseAllOnEsc()}catch(o){this.getService(_).catch("Error in _disableForceCloseAllOnEsc: ",o);return}}_markAsRead(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: markAsRead","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_READ_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(we).markAsRead(o);return}catch(n){this.getService(_).catch("Error in _markAsRead: ",n);return}})}_markAsUnread(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: markAsUnread","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_UNREAD_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(we).markAsUnread(o)}catch(n){this.getService(_).catch("Error in _markAsUnread: ",n);return}})}_enableScreenshot(){this.getService(_).log("%c[WB] Calling FUNCTION: enableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCREENSHOT_TRIGGERED),this.getService(we).enableScreenshot()}catch(o){this.getService(_).catch("Error in _enableScreenshot: ",o);return}}_disableScreenshot(){this.getService(_).log("%c[WB] Calling FUNCTION: disableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCREENSHOT_TRIGGERED),this.getService(we).disableScreenshot()}catch(o){this.getService(_).catch("Error in _disableScreenshot: ",o);return}}_enablePaginatedContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(we).enablePaginatedContactList()}catch(o){this.getService(_).catch("Error in _enablePaginatedContactList: ",o);return}}_disablePaginatedContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(we).disablePaginatedContactList()}catch(o){this.getService(_).catch("Error in _disablePaginatedContactList: ",o);return}}};var B9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Contact.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(Si).isUserGlobalContact$()}catch(o){return this.getService(_).catch("Error in _isUserGlobalContact: ",o),le(!1)}}_onContactSelected(){this.getService(_).log("%c[WB] Calling FUNCTION: onContactSelected","color: green;");try{return this.trackEvent(Y.Events.Contact.ON_CONTACT_SELECTED_TRIGGERED),this.getService(Si).onContactSelected$()}catch(o){return this.getService(_).catch("Error in _onContactSelected: ",o),le(null)}}_enableAtHere(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.ENABLE_AT_HERE_TRIGGERED),this.getService(Si).enableAtHere()}catch(o){this.getService(_).catch("Error in _enableAtHere: ",o)}}_setAtHereLabel(o){this.getService(_).log("%c[WB] Calling FUNCTION: setAtHereLabel","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_LABEL_TRIGGERED,{payload:{label:o}}),this.getService(Si).setAtHereLabel(o)}catch(n){this.getService(_).catch("Error in setAtHereLabel: ",n)}}_setAtHereDescription(o){this.getService(_).log("%c[WB] Calling FUNCTION: setAtHereDescription","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_DESCRIPTION_TRIGGERED,{payload:{description:o}}),this.getService(Si).setAtHereDescription(o)}catch(n){this.getService(_).catch("Error in setAtHereDescription: ",n)}}_disableAtHere(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.DISABLE_AT_HERE_TRIGGERED),this.getService(Si).disableAtHere()}catch(o){this.getService(_).catch("Error in _disableAtHere: ",o)}}_updateContactListScopeForOrganizationUsers(o){this.getService(_).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(Si).updateContactListScopeForOrganizationUsers(o)}catch(n){this.getService(_).catch("Error in _updateContactListScopeForOrganizationUsers: ",n)}}_updateContactList(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: _updateContactList","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{payload:{userContacts:o,config:n}}),typeof o=="object"&&o instanceof Array&&(!n||n&&typeof n=="object")&&(o=JSON.parse(JSON.stringify(o)),this.getService(Si).convert(n).updateContactList(o,n))}catch(e){this.getService(_).catch("Error in _updateContactList: ",e)}}_getContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: getContactList","color: green;");try{return this.trackEvent(Y.Events.Contact.GET_CONTACT_LIST_TRIGGERED),this.getService(Si).getContactList$()}catch(o){return this.getService(_).catch("Error in _getContactList: ",o),le(null)}}};var V9=(()=>{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 Qe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in CrdtActionsService triggerAction: ",r)}}onAction(e){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe);let t=this.actionSubjects.get(e);return t?t.asObservable():le(null)}catch(t){return this.loggingService.catch("Error in CrdtActionsService onAction: ",t),le(null)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ed=(()=>{let o=class o{static generateKey(){return Q(this,null,function*(){try{return yield window.crypto.subtle.generateKey({name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"])}catch(e){return Ze.catch("Failed to generate key: ",e),null}})}static deriveKeyFromPassword(e,t){return Q(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 r=new TextEncoder().encode(e),a=yield window.crypto.subtle.importKey("raw",r,"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(r){return Ze.catch("Failed to derive key from password: ",r),null}})}static resolveKey(e){return Q(this,null,function*(){try{if(e.customKey){if(e.customKey instanceof CryptoKey)return{key:e.customKey};if(typeof e.customKey=="string"){let r=yield this.deriveKeyFromPassword(e.customKey,e.customSalt);if(!r)return Ze.catch("Failed to derive key from password"),null;let{key:a,salt:s}=r;return{key:a,salt:s}}}let t=yield this.generateKey();return t?{key:t}:(Ze.catch("Failed to generate key"),null)}catch(t){return Ze.catch("Failed to resolve key: ",t),null}})}static encrypt(r){return Q(this,arguments,function*(e,t={}){try{if(t.customEncryptCallback)try{return yield t.customEncryptCallback(e)}catch(I){return Ze.catch("Custom encryption callback failed: ",I),""}let a=yield this.resolveKey(t);if(!a)return Ze.catch("Failed to resolve key"),"";let{key:s,salt:c}=a,p;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return Ze.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";p=t.customIV}else p=window.crypto.getRandomValues(new Uint8Array(this.IV_LENGTH));let g=new TextEncoder().encode(e),f={name:"AES-GCM",iv:p,tagLength:128};t.additionalData&&(f.additionalData=t.additionalData);try{let I=yield window.crypto.subtle.encrypt(f,s,g),x=new Uint8Array(p.length+I.byteLength);x.set(p,0),x.set(new Uint8Array(I),p.length);let B=8192,z=[];for(let G=0;G<x.length;G+=B){let J=x.slice(G,Math.min(G+B,x.length)),ne="";for(let ve=0;ve<J.length;ve++)ne+=String.fromCharCode(J[ve]);z.push(ne)}return btoa(z.join(""))}catch(I){return Ze.catch("Encryption failed: ",I),""}}catch(a){return Ze.catch("Failed to encrypt: ",a),null}})}static decrypt(r){return Q(this,arguments,function*(e,t={}){try{if(t.customDecryptCallback)try{return yield t.customDecryptCallback(e)}catch(I){return Ze.catch("Custom decryption callback failed: ",I),""}let a=yield this.resolveKey(t);if(!a)return Ze.catch("Failed to resolve key"),"";let{key:s}=a,c=new Uint8Array(atob(e).split("").map(I=>I.charCodeAt(0)));if(c.length<this.IV_LENGTH)return Ze.catch("Invalid encrypted data: Too short"),"";let p;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return Ze.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";p=t.customIV}else p=c.slice(0,this.IV_LENGTH);let g=c.slice(this.IV_LENGTH),f={name:"AES-GCM",iv:p,tagLength:128};t.additionalData&&(f.additionalData=t.additionalData);try{let I=yield window.crypto.subtle.decrypt(f,s,g);return new TextDecoder().decode(I)}catch(I){return Ze.catch("Decryption failed: ",I),""}}catch(a){return Ze.catch("Failed to decrypt: ",a),""}})}static encryptData(r){return Q(this,arguments,function*(e,t={}){try{let a=JSON.stringify(e);return(yield this.encrypt(a,t))??""}catch(a){return Ze.catch("Failed to encrypt data: ",a),""}})}static decryptData(r){return Q(this,arguments,function*(e,t={}){try{let a=yield this.decrypt(e,t);return JSON.parse(a)}catch(a){return Ze.catch("Failed to decrypt data: ",a),null}})}};o.IV_LENGTH=12,o.SALT_LENGTH=16,o.PBKDF2_ITERATIONS=1e5,o.KEY_LENGTH=256;let i=o;return i})();var ds=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f){this.authService=e,this.commonDbService=t,this.commonDbUtilsService=r,this.configService=a,this.crdtActionsService=s,this.docService=c,this.domService=p,this.loggingService=g,this.notificationService=f,this.MIN_WEBHOOK_DEBOUNCE_TIME=5*1e3,this.webhookDebounceTime=this.MIN_WEBHOOK_DEBOUNCE_TIME,this.updateDataWebhookTrigger$=new Qe,this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null,this.webhookEnabled$=new Ce(!1);try{this.loggingService.log("%c[WB] Creating CLASS: CrdtService","color: blue;"),this.setupUpdateDataWebhookDebounce()}catch(I){this.loggingService.catch("Error in CrdtService constructor: ",I)}}setupUpdateDataWebhookDebounce(){try{this.updateDataWebhookDebounceSubscription&&(this.updateDataWebhookDebounceSubscription.unsubscribe(),this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null),this.updateDataWebhookDebounceSubscription=this.updateDataWebhookTrigger$.pipe(Qt(e=>{this.pendingWebhookEvent=e}),Bi(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 Q(this,arguments,function*({id:e,state:t,data:r}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateData","color: green;");let s=this.docService.getDocumentPaths(),c=this.authService.getUser(),p=this.domService.getTabId();if(c?.userId&&s){let g=Tt(e),f=c.userId,I=Tt(c.userId),x=new Date().toISOString(),B=null,z=this.configService.getEncryptionProvider();if(z?.encrypt&&typeof z.encrypt=="function")B=yield z.encrypt({data:t});else{let ve={};ve.customKey=g,B=yield Ed.encryptData(t,ve)}let G={id:e,veltId:g,encryptedState:B,lastUpdate:x,lastUpdatedBy:f,lastUpdatedByVeltUserId:I,sessionId:p},J={methodName:KW.UPDATE_DATA,uniqueId:vt(),timestamp:new Date().getTime(),source:YW.INTERNAL,payload:{id:e,data:r,lastUpdatedBy:f,sessionId:p,lastUpdate:x}},ne=yield this.commonDbService.updateData({feature:"crdtData",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:g,skipFirestore:!0},data:G});return this.crdtActionsService.triggerAction(qle.UPDATE_DATA,J),this.updateDataWebhookTrigger$.next(J?.payload),ne}return Promise.resolve(null)}catch(s){return this.loggingService.catch("Error in CrdtService updateData: ",s),Promise.resolve(null)}})}triggerUpdateDataWebhook(e){try{this.updateNotificationsDatabase(e,iz.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 r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"crdtData",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(fe(c=>Q(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.data.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.data.encryptedState,f)}c.data.state=p,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,delete c?.encryptedState}return c}}catch(p){return this.loggingService.catch("Error in CrdtService onDataChange subscription: ",p),null}}))):le(null))).subscribe(s=>{s&&(s.data?t(s.data):t(s))});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onDataChange: ",r),()=>{}}}getData(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getData","color: green;");let r=this.docService.getDocumentPaths();if(r){let a=Tt(e),s=yield this.commonDbService.getData({feature:"crdtData",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:a,skipFirestore:!0}});if(s?.encryptedState){let c=null,p=this.configService.getEncryptionProvider();if(p?.decrypt&&typeof p.decrypt=="function")c=yield p.decrypt({data:s.encryptedState});else{let g={};g.customKey=a,c=yield Ed.decryptData(s.encryptedState,g)}s.state=c,delete s?.encryptedState}return s}return Promise.resolve(null)}catch(r){return this.loggingService.catch("Error in CrdtService getData: ",r),Promise.resolve(null)}})}onStateChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onStateChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"crdtSyncState",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(fe(c=>Q(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.data.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.data.encryptedState,f)}c.data.state=p,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,delete c?.encryptedState}return c}}catch(p){return this.loggingService.catch("Error in CrdtService onStateChange subscription: ",p),null}}))):le(null))).subscribe(s=>{s&&(s.data?t(s.data):t(s))});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onStateChange: ",r),()=>{}}}updateState(r){return Q(this,arguments,function*({id:e,state:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateState","color: green;");let a=this.docService.getDocumentPaths(),s=this.authService.getUser(),c=this.domService.getTabId();if(s?.userId&&a){let p=Tt(e),g=s.userId,f=Tt(g),I=null,x=this.configService.getEncryptionProvider();if(x?.encrypt&&typeof x.encrypt=="function")I=yield x.encrypt({data:t});else{let B={};B.customKey=p,I=yield Ed.encryptData(t,B)}return this.commonDbService.setData({feature:"crdtSyncState",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:p,skipFirestore:!0},data:{id:e,veltId:p,encryptedState:I,lastUpdate:new Date().toISOString(),lastUpdatedBy:g,lastUpdatedByVeltUserId:f,sessionId:c}})}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService updateState: ",a),Promise.resolve(null)}})}registerSyncUser(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: registerSyncUser","color: green;");let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=this.configService.getApiKey(),c=Tt(e),p=this.domService.getTabId();if(r?.userId&&a&&s){let g=r.userId,f=Tt(g),I={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:f,apiKey:s,skipFirestore:!0},x={userId:g,veltUserId:f,status:"online",lastSeen:Date.now(),sessionId:p};yield this.commonDbService.setData({feature:"crdtSyncPresence",properties:I,data:x});let B=this.commonDbUtilsService.getDocumentPath({feature:"crdtSyncPresence",properties:I,defaultDocumentPaths:a,apiKey:s});B&&(yield this.commonDbService.setupOnDisconnect(B,{status:"offline",lastSeen:new Date().getTime(),sessionId:p}))}}catch(r){this.loggingService.catch("Error in CrdtService registerSyncUser: ",r)}})}onRegisteredUserChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onRegisteredUserChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"allCrdtSyncPresence",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(Qt(c=>{try{c?.data?t(c.data):t(c)}catch(p){this.loggingService.catch("Error in CrdtService onRegisteredUserChange subscription: ",p)}})):le(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onRegisteredUserChange: ",r),()=>{}}}setPresence(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: setPresence","color: green;");let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=this.configService.getApiKey(),c=Tt(e),p=this.domService.getTabId();if(r?.userId&&a&&s){let g=r.userId,f=Tt(g),I={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:f,apiKey:s,skipFirestore:!0},x={userId:g,veltUserId:f,status:"online",lastSeen:Date.now(),sessionId:p};yield this.commonDbService.setData({feature:"crdtPresence",properties:I,data:x});let B=this.commonDbUtilsService.getDocumentPath({feature:"crdtPresence",properties:I,defaultDocumentPaths:a,apiKey:s});B&&(yield this.commonDbService.setupOnDisconnect(B,{status:"offline",lastSeen:new Date().getTime(),sessionId:p}))}}catch(r){this.loggingService.catch("Error in CrdtService setPresence: ",r)}})}onPresenceChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onPresenceChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"allCrdtPresence",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(Qt(c=>{try{c?.data?t(c.data):t(c)}catch(p){this.loggingService.catch("Error in CrdtService onPresenceChange subscription: ",p)}})):le(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onPresenceChange: ",r),()=>{}}}saveVersion(s){return Q(this,arguments,function*({id:e,versionId:t,versionName:r,state:a}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveVersion","color: green;");let c=this.docService.getDocumentPaths();if(c){let p=Tt(e),g="",f=this.configService.getEncryptionProvider();if(f?.encrypt&&typeof f.encrypt=="function")g=yield f.encrypt({data:a});else{let x={};x.customKey=p,g=yield Ed.encryptData(a,x)}let I={versionId:t,versionName:r,encryptedState:g,timestamp:new Date().getTime()};return this.commonDbService.setData({feature:"crdtVersion",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:p,versionId:t,skipFirestore:!0},data:E({id:e},I)})}return Promise.resolve(null)}catch(c){return this.loggingService.catch("Error in CrdtService saveVersion: ",c),Promise.resolve(null)}})}getVersion(r){return Q(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 s=Tt(e),c=yield this.commonDbService.getData({feature:"crdtVersion",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:s,versionId:t,skipFirestore:!0}});if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=s,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,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 Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersions","color: green;");let r=this.docService.getDocumentPaths();if(r){let a=Tt(e),s=yield this.commonDbService.getData({feature:"crdtVersions",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:a,skipFirestore:!0}}),c=null;if(s){c=[];for(let p of Object.values(s))if(p?.encryptedState){let g=null,f=this.configService.getEncryptionProvider();if(f?.decrypt&&typeof f.decrypt=="function")g=yield f.decrypt({data:p.encryptedState});else{let x={};x.customKey=a,g=yield Ed.decryptData(p.encryptedState,x)}let I=D(E({},p),{state:g});delete I?.encryptedState,c.push(I)}else c.push(p)}return c}return Promise.resolve(null)}catch(r){return this.loggingService.catch("Error in CrdtService getVersions: ",r),Promise.resolve(null)}})}updateNotificationsDatabase(e,t,r={}){try{let a=E({crdtData:e,actionType:t,notificationSource:"crdt"},r);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)}}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(un),ee(Im),ee(Ft),ee(V9),ee(ot),ee(Be),ee(_),ee(hn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var U9=class extends gi{constructor(o){super(o),this.getService(_).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.enableWebhook=this._enableWebhook,this.disableWebhook=this._disableWebhook,this.setWebhookDebounceTime=this._setWebhookDebounceTime,this.on=this._on}_updateData(o){this.getService(_).log("%c[WB] Calling FUNCTION: updateData","color: green;");try{return this.getService(ds).updateData(o)}catch(n){return this.getService(_).catch("Error in updateData: ",n),Promise.resolve(null)}}_onDataChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onDataChange","color: green;");try{return this.getService(ds).onDataChange(o)}catch(n){return this.getService(_).catch("Error in onDataChange: ",n),()=>{}}}_getData(o){this.getService(_).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.getService(ds).getData(o)}catch(n){return this.getService(_).catch("Error in getData: ",n),Promise.resolve(null)}}_onStateChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onStateChange","color: green;");try{return this.getService(ds).onStateChange(o)}catch(n){return this.getService(_).catch("Error in onStateChange: ",n),()=>{}}}_updateState(o){this.getService(_).log("%c[WB] Calling FUNCTION: updateState","color: green;");try{return this.getService(ds).updateState(o)}catch(n){return this.getService(_).catch("Error in updateState: ",n),Promise.resolve(null)}}_registerSyncUser(o){this.getService(_).log("%c[WB] Calling FUNCTION: registerSyncUser","color: green;");try{return this.getService(ds).registerSyncUser(o)}catch(n){return this.getService(_).catch("Error in registerSyncUser: ",n),Promise.resolve()}}_onRegisteredUserChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onRegisteredUserChange","color: green;");try{return this.getService(ds).onRegisteredUserChange(o)}catch(n){return this.getService(_).catch("Error in onRegisteredUserChange: ",n),()=>{}}}_setPresence(o){this.getService(_).log("%c[WB] Calling FUNCTION: setPresence","color: green;");try{return this.getService(ds).setPresence(o)}catch(n){return this.getService(_).catch("Error in setPresence: ",n),Promise.resolve()}}_onPresenceChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onPresenceChange","color: green;");try{return this.getService(ds).onPresenceChange(o)}catch(n){return this.getService(_).catch("Error in onPresenceChange: ",n),()=>{}}}_saveVersion(o){this.getService(_).log("%c[WB] Calling FUNCTION: saveVersion","color: green;");try{return this.getService(ds).saveVersion(o)}catch(n){return this.getService(_).catch("Error in saveVersion: ",n),Promise.resolve(null)}}_getVersion(o){this.getService(_).log("%c[WB] Calling FUNCTION: getVersion","color: green;");try{return this.getService(ds).getVersion(o)}catch(n){return this.getService(_).catch("Error in getVersion: ",n),Promise.resolve(null)}}_getVersions(o){this.getService(_).log("%c[WB] Calling FUNCTION: getVersions","color: green;");try{return this.getService(ds).getVersions(o)}catch(n){return this.getService(_).catch("Error in getVersions: ",n),Promise.resolve(null)}}_enableWebhook(){this.getService(_).log("%c[WB] Calling FUNCTION: enableWebhook","color: green;");try{return this.getService(ds).enableWebhook()}catch(o){this.getService(_).catch("Error in enableWebhook: ",o);return}}_disableWebhook(){this.getService(_).log("%c[WB] Calling FUNCTION: disableWebhook","color: green;");try{return this.getService(ds).disableWebhook()}catch(o){this.getService(_).catch("Error in disableWebhook: ",o);return}}_setWebhookDebounceTime(o){this.getService(_).log("%c[WB] Calling FUNCTION: setWebhookDebounceTime","color: green;");try{!isNaN(o)&&o>0?this.getService(ds).setWebhookDebounceTime(o):this.getService(_).catch("Error in setWebhookDebounceTime: ","Provided value must be a positive number greater than zero.")}catch(n){this.getService(_).catch("Error in setWebhookDebounceTime: ",n)}}_on(o){this.getService(_).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(V9).onAction(o)}catch(n){return this.getService(_).catch("Error in on: ",n),le(null)}}};var Ms=(function(i){return i.CLICK="click",i.HOVER="hover",i.SCROLL="scroll",i.NAVIGATE="navigate",i})(Ms||{}),Np=class{constructor(){this.type=Ms.HOVER,this.data=null,this.pageInfo=Ni(),this.timestamp=Date.now()}},j9=class{constructor(o,n){this.targetXpath=o,this.xpath=n}};var $9=class{constructor(){this.sessionId=null,this.isLeader=!1,this.lastProcessedActionTimestamp=null}};var Af=class{constructor(o){this.snippylyId=o,this.joinTimestamp=Date.now()}};var H9=class{constructor(o,n,e){this.followers=[],this.actionStack=[],this.id=vt(),this.leaderId=o,this.leaderName=n,this.followers.push(new Af(e))}};var age=(()=>{let o=class o{constructor(e,t,r,a,s){this.databaseService=e,this.docService=t,this.loggingService=r,this.authService=a,this.commonDbService=s,this.currentUser$=new Ce(null),this.currentSession$=new Ce(null);try{this.databaseService.getDb().pipe(Le(c=>!!c),rt(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,r){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(rt(1)).subscribe(s=>{s?.data&&s?.data?.sessionId?this.subscribeToCurrentSession(s?.data?.sessionId,r):this.createFlockSession(e,t,r)})}catch(a){this.loggingService.catch("Error in FlockSessionService provisionFlockSession: ",a)}return null}swapLeader(e,t,r){try{if(this.updateRemoteFlockUser(e,{isLeader:!1}),this.updateRemoteFlockUser(t,{isLeader:!0}),this.currentSession){this.currentSession.leaderId=t,this.currentSession.leaderName=r,this.currentSession.followers.push(new Af(e));let a=this.currentSession.followers.findIndex(s=>s.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,r){try{let a=new H9(e,t,r);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(r=>r.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 r=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];r&&this.db&&this.commonDbService.updateData({feature:"flockUser",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateRemoteFlockUser: ",r)}}subscribeToCurrentSession(e,t=void 0){try{let r=this.docService.getDocumentPaths();r&&this.db&&(this.sessionSub&&this.sessionSub.unsubscribe(),this.sessionSub=this.commonDbService.dbListener({feature:"flockSession",properties:{documentId:r?.documentId,organizationId:r?.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(s=>s.snippylyId===t)===-1&&(this.currentSession.followers.push(new Af(t)),this.updateSession(this.currentSession.id,this.currentSession)),this.currentSession$.next(this.currentSession??null)):(this.currentSession=void 0,this.currentSession$.next(null))}))}catch(r){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentSession: ",r)}}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(Un(r=>(this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",r),le(null)))).subscribe(r=>{r?.data&&typeof r?.data=="object"&&Object.keys(r?.data)?.length>0&&(this.currentUser$.next(r?.data),r?.data?.sessionId&&this.subscribeToCurrentSession(r?.data?.sessionId))},r=>{this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser subscription: ",r)}))}catch(t){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",t)}}updateSession(e,t={}){try{if(!e)return;let r=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];r&&this.db&&this.commonDbService.updateData({feature:"flockSession",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateSession: ",r)}}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(r=>{this.updateRemoteFlockUser(r.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 r=this.docService.getDocumentPaths();if(r&&this.db&&e){let a=Ti(this.db,`${r.flock}/sessions/${e}/actionStack`);Kh(a,s=>s?(s.unshift(t),s.slice(0,5)):[t]),t.type===Ms.NAVIGATE&&this.updateSession(e,{pageInfo:t.pageInfo})}}catch(r){this.loggingService.catch("Error in FlockSessionService addActionToStack: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(In),ee(ot),ee(_),ee(je),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var sge={en:{"Action button":"Action button",Yes:"Yes",Delete:"Delete",Cancel:"Cancel","Delete thread?":"Delete thread?","All replies to this thread will be lost.":"All replies to this thread will be lost.","Delete comment?":"Delete comment?","This selected comment will be deleted.":"This selected comment will be deleted.","Delete recording?":"Delete recording?","This selected recording will be deleted.":"This selected recording will be deleted.","Delete area?":"Delete area?","This selected area will be deleted.":"This selected area will be deleted.","Delete arrow?":"Delete arrow?","This selected arrow will be deleted.":"This selected arrow will be deleted.","Delete tag?":"Delete tag?","This selected tag will be deleted.":"This selected tag will be deleted.","Contact us":"Contact us","Let us know how can we help you!":"Let us know how can we help you!","Your email address":"Your email address","How can we help?":"How can we help?",Send:"Send","Allow mic permission to":"Allow mic permission to","enable your audio":"enable your audio","1. Click the":"1. Click the","page info icon in your browser\u2019s address bar":"page info icon in your browser\u2019s address bar","2. Turn on Microphone":"2. Turn on Microphone","2. Turn on Camera":"2. Turn on Camera","Allow camera permission":"Allow camera permission","to enable your video":"to enable your video",dropdown:"dropdown","assign dropdown":"assign dropdown","custom dropdown":"custom dropdown","options dropdown":"options dropdown","priority dropdown":"priority dropdown","status dropdown":"status dropdown","seen dropdown":"seen dropdown",menu:"menu","assign menu":"assign menu","custom menu":"custom menu","options menu":"options menu","priority menu":"priority menu","status menu":"status menu","seen menu":"seen menu","menu items":"menu items","assign menu items":"assign menu items","custom menu items":"custom menu items","options menu items":"options menu items","priority menu items":"priority menu items","status menu items":"status menu items","seen menu items":"seen menu items","Playback Speed":"Playback Speed","Subtitles not available":"Subtitles not available","Transcription not available":"Transcription not available",Feedback:"Feedback","Provide feedback on your Superflow experience.":"Provide feedback on your Superflow experience.","Tell us the details...":"Tell us the details...","You are following":"You are following","You are leading.":"You are leading.",Stop:"Stop",following:"following",leading:"leading","is editing.":"is editing.","requested edit access.":"requested edit access.","You are editing.":"You are editing.","You are editing on different tab.":"You are editing on different tab.","Access Requested":"Access Requested","Request access":"Request access","Edit here":"Edit here",Settings:"Settings",Audio:"Audio",Microphone:"Microphone",Video:"Video",Camera:"Camera","Save changes":"Save changes","Audio settings":"Audio settings","No device found":"No device found","Video settings":"Video settings","Media source settings":"Media source settings","Audio recording preview":"Audio recording preview","Cancel recording":"Cancel recording","Video recording icon":"Video recording icon","Screen recording icon":"Screen recording icon","Audio recording icon":"Audio recording icon","Recording preview bottom panel":"Recording preview bottom panel","Starting recording in":"Starting recording in","Recording control buttons":"Recording control buttons","Toggle camera":"Toggle camera",off:"off",on:"on","Camera is off":"Camera is off","Close recording preview":"Close recording preview","Toggle microphone":"Toggle microphone",Close:"Close",Open:"Open","recording settings":"recording settings","Start Recording":"Start Recording","Report bugs":"Report bugs","Let us know about any bugs so we can fix them ASAP!":"Let us know about any bugs so we can fix them ASAP!","Thank you! We will get back to you soon.":"Thank you! We will get back to you soon.","Thank you for your feedback!":"Thank you for your feedback!","Thanks for reporting the bug. We will get back to you soon.":"Thanks for reporting the bug. We will get back to you soon.","Invitation sent!":"Invitation sent!","User removed!":"User removed!",members:"members","Invalid contact":"Invalid contact","Invalid email":"Invalid email","Comment pin":"Comment pin","Add text comment":"Add text comment","Add comment annotation":"Add comment annotation","Use AI to rewrite selected text":"Use AI to rewrite selected text","Select a shorter text":"Select a shorter text","Select a longer text":"Select a longer text",Rewrite:"Rewrite","Ask ChatGPT":"Ask ChatGPT","Text comment tools":"Text comment tools","Avatar for comment author":"Avatar for comment author","comments in this thread":"comments in this thread","Assign To":"Assign To","Attach files":"Attach files","Attach files input":"Attach files input","All comments":"All comments","View all comments":"View all comments","Approve comment":"Approve comment",Approve:"Approve","Assign thread":"Assign thread",Search:"Search","Search users":"Search users","Avatar for assigned user":"Avatar for assigned user","Assigned to":"Assigned to","Comment assignment details":"Comment assignment details","Assigned to:":"Assigned to:","Comment dialog thread":"Comment dialog thread","Close comment dialog":"Close comment dialog","Comment Index":"Comment Index",Suggestion:"Suggestion","Comment tools and actions":"Comment tools and actions","Mention someone using @ symbol":"Mention someone using @ symbol","Mention someone using @ symbol while editing":"Mention someone using @ symbol while editing","Type @ to mention someone":"Type @ to mention someone","Type @ to mention someone while editing":"Type @ to mention someone while editing","Add file attachment to comment":"Add file attachment to comment","Record voice message":"Record voice message","Click to start voice recording":"Click to start voice recording","Record video message":"Record video message","Click to start screen recording":"Click to start screen recording","Record your screen":"Record your screen","Save new comment":"Save new comment","Save edited comment":"Save edited comment","Assign user":"Assign user","Remove File":"Remove File","Image attachment:":"Image attachment:","unnamed image":"unnamed image","Actions for image:":"Actions for image:","Uploading image:":"Uploading image:","Delete image:":"Delete image:","Preview of image:":"Preview of image:","Remove invalid file:":"Remove invalid file:","Error message:":"Error message:","Invalid file:":"Invalid file:","Actions for invalid file:":"Actions for invalid file:","File error:":"File error:","File cannot be uploaded":"File cannot be uploaded","Preview of invalid file:":"Preview of invalid file:","Invalid file":"Invalid file",unknown:"unknown","Delete file":"Delete file","File attachment:":"File attachment:","unnamed file":"unnamed file","File type icon for":"File type icon for","Details for file:":"Details for file:","Filename:":"Filename:","File size:":"File size:","Uploading file:":"Uploading file:","Actions for file:":"Actions for file:","Remove file:":"Remove file:","Attached files":"Attached files","total attachments":"total attachments","File attachments":"File attachments",valid:"valid","invalid files":"invalid files","User avatar for":"User avatar for","unknown user":"unknown user","New comment composer":"New comment composer","Comment or type @ to add others":"Comment or type @ to add others","Write a comment...":"Write a comment...","Edit comment composer":"Edit comment composer","Comment or add emails with @":"Comment or add emails with @","Private comment mode - only visible to your team":"Private comment mode - only visible to your team","Only for your team":"Only for your team","Screen recording":"Screen recording",unnamed:"unnamed","Screen recording controls":"Screen recording controls","Edit comment section":"Edit comment section","Add new comment section":"Add new comment section","Custom annotation options":"Custom annotation options","Toggle annotation options":"Toggle annotation options","Annotation:":"Annotation:",Select:"Select","Remaining count:":"Remaining count:","Delete comment controls":"Delete comment controls","Delete this comment":"Delete this comment","Ghost comment notification":"Ghost comment notification","Original content not found.":"Original content not found.","Comment dialog header":"Comment dialog header","Comment dialog header controls":"Comment dialog header controls","Comment metadata":"Comment metadata","1 more reply":"1 more reply","more replies":"more replies","Show 1 more reply":"Show 1 more reply","Navigate to comment location":"Navigate to comment location","Assign comment":"Assign comment","Delete thread":"Delete thread","Delete comment":"Delete comment","Edit comment":"Edit comment",Edit:"Edit","Make it private":"Make it private","Make it public":"Make it public",Subscribe:"Subscribe",Unsubscribe:"Unsubscribe","priority level":"priority level","Priority name":"Priority name",P0:"P0",P1:"P1",P2:"P2","Selected priority:":"Selected priority:","Selected priority indicator":"Selected priority indicator","Priority:":"Priority:","Priority item":"Priority item","Thread priority:":"Thread priority:","Private comment banner":"Private comment banner","Resolve thread":"Resolve thread","Sign In":"Sign In","Status dropdown for":"Status dropdown for",comment:"comment","Status name:":"Status name:","Status option:":"Status option:","Status:":"Status:","Accept suggestion":"Accept suggestion",Accept:"Accept","Reject suggestion":"Reject suggestion",Reject:"Reject","Suggestion actions":"Suggestion actions","Delete Attachment":"Delete Attachment","Download Attachment":"Download Attachment",Attachment:"Attachment",preview:"preview","Image attachment controls":"Image attachment controls","Image attachment actions":"Image attachment actions","Delete attachment":"Delete attachment","Download attachment":"Download attachment","File name:":"File name:","Attachment:":"Attachment:",Attachments:"Attachments","Avatar for":"Avatar for",user:"user","Draft comment status":"Draft comment status",Draft:"Draft",Comment:"Comment","Comment by":"Comment by",Me:"Me","Comment reactions":"Comment reactions","Comment recordings":"Comment recordings","Name for":"Name for","Time for":"Time for","Seen by":"Seen by","Users who viewed this comment":"Users who viewed this comment","List of users who have seen this comment":"List of users who have seen this comment","Seen By":"Seen By","Comment viewers list":"Comment viewers list","Show comment viewers":"Show comment viewers","Comment viewers dropdown":"Comment viewers dropdown",now:"now",Unread:"Unread","Comment thread":"Comment thread","Comment content":"Comment content","Author information":"Author information","Author details and status":"Author details and status","Comment device information":"Comment device information","Inline mode metadata":"Inline mode metadata","Comment actions":"Comment actions","Reaction options":"Reaction options","Comment message":"Comment message",of:"of","Show more replies":"Show more replies",replies:"replies",Reply:"Reply",reply:"reply",Show:"Show","Show reply":"Show reply","Unresolve comment":"Unresolve comment","Upgrade plan":"Upgrade plan",Upgrade:"Upgrade","Copy link to comment":"Copy link to comment","Link Copied!":"Link Copied!","Copy thread link":"Copy thread link","Emoji reactions menu":"Emoji reactions menu","Open emoji reactions menu":"Open emoji reactions menu",Priority:"Priority","Private Comment":"Private Comment",Resolve:"Resolve",Unresolve:"Unresolve","Comment bubble":"Comment bubble","Multi-thread comment dialog":"Multi-thread comment dialog","Comment dialog":"Comment dialog","Comment bottom sheet":"Comment bottom sheet","Comment inbox container":"Comment inbox container","Single comment dialog":"Single comment dialog","Ghost comment indicator":"Ghost comment indicator","Private comment":"Private comment","Comment icon":"Comment icon","Exit comment mode":"Exit comment mode","to exit":"to exit",exit:"exit","Private Comment Mode":"Private Comment Mode","Comment Mode":"Comment Mode","Comment mode icon":"Comment mode icon","Comments stream view":"Comments stream view","Comments inbox":"Comments inbox","Comments location overview":"Comments location overview","Comments minimap":"Comments minimap","Go to comments here.":"Go to comments here.","Close comments sidebar":"Close comments sidebar","Add your first comment":"Add your first comment","No comments to display":"No comments to display","filter section":"filter section",All:"All","Close filter panel":"Close filter panel","Apply filters and close panel":"Apply filters and close panel",Done:"Done","checkbox checked":"checkbox checked","checkbox unchecked":"checkbox unchecked",items:"items","Current viewing page":"Current viewing page","This page":"This page",selected:"selected","not selected":"not selected",pages:"pages",people:"people",priorities:"priorities",statuses:"statuses",Filters:"Filters",versions:"versions","View All":"View All","View all":"View all","Comment filters":"Comment filters","Available filters":"Available filters","Apply or cancel filters":"Apply or cancel filters","Filter comments":"Filter comments","filters applied":"filters applied","Return to all comments":"Return to all comments","Back to all comments":"Back to all comments","Search through comments":"Search through comments","Filter and status controls":"Filter and status controls","Unknown user":"Unknown user","Comment dialog for":"Comment dialog for",Collapse:"Collapse",Expand:"Expand","comment group":"comment group",arrow:"arrow","Comments list with":"Comments list with","Location filter options":"Location filter options",Pages:"Pages","Filter comments by location":"Filter comments by location","menu expanded":"menu expanded","menu collapsed":"menu collapsed","Location filter dropdown":"Location filter dropdown","Mark all comments as read":"Mark all comments as read","Mark all as read":"Mark all as read","Mark as read":"Mark as read","Mark as unread":"Mark as unread",Reset:"Reset","Show open comments only":"Show open comments only","Mark all comments as resolved":"Mark all comments as resolved","Mark all as resolved":"Mark all as resolved","Bulk actions for comments":"Bulk actions for comments","Actions menu":"Actions menu",expanded:"expanded",collapsed:"collapsed","Comment actions dropdown":"Comment actions dropdown","Show unread and read comments":"Show unread and read comments","Unread and read":"Unread and read","Show read comments only":"Show read comments only","Read only":"Read only","Show resolved comments only":"Show resolved comments only",Resolved:"Resolved","Show unread comments only":"Show unread comments only","Unread only":"Unread only","Selected indicator":"Selected indicator","Sort comments by date":"Sort comments by date","Sort by date":"Sort by date","Sort comments by unread status":"Sort comments by unread status","Sort by unread":"Sort by unread","Sort and filter comments":"Sort and filter comments","custom filter applied":"custom filter applied","Comment filters and sorting":"Comment filters and sorting",filtered:"filtered","Page comment composer":"Page comment composer","Add a comment to the page":"Add a comment to the page","Comments and feedback panel":"Comments and feedback panel","Reset all comment filters":"Reset all comment filters","Clear filters":"Clear filters","Loading comments":"Loading comments","Comment status filters":"Comment status filters",status:"status","status icon":"status icon","Status filter options":"Status filter options","Status filter dropdown":"Status filter dropdown","Comments sidebar":"Comments sidebar","Comments panel":"Comments panel","Comment composer":"Comment composer","Comments section panel":"Comments section panel",Comments:"Comments","Loading Comments":"Loading Comments","Comments section":"Comments section","No comments found for applied filters.":"No comments found for applied filters.","Comments list":"Comments list","Comment actions menu":"Comment actions menu","More actions":"More actions","Filter and sort options":"Filter and sort options","Collapse threads":"Collapse threads","Comments dialog":"Comments dialog","Clear all filters":"Clear all filters","Comments information":"Comments information","Toggle comments sidebar":"Toggle comments sidebar","Click to mute":"Click to mute","Click to unmute":"Click to unmute","Stop sharing":"Stop sharing","Share screen":"Share screen","Invite users to join this huddle":"Invite users to join this huddle","Please select a contact to invite":"Please select a contact to invite","Chat with everyone":"Chat with everyone","Enable audio or video to change the settings":"Enable audio or video to change the settings","Change audio/video settings":"Change audio/video settings",Leave:"Leave","In-call messages":"In-call messages","Type here...":"Type here...","Audio Huddle":"Audio Huddle","Video Huddle":"Video Huddle","Screen Huddle":"Screen Huddle","1 person is":"1 person is","people are":"people are","on a call now":"on a call now","You can join the call":"You can join the call","Stop Sharing":"Stop Sharing","is sharing now.":"is sharing now.",You:"You","Close notifications panel":"Close notifications panel","Notification item":"Notification item","All notifications list":"All notifications list","All notifications":"All notifications","All notifications read":"All notifications read","Document notification":"Document notification","Document name:":"Document name:",Untitled:"Untitled","Document ID:":"Document ID:",Document:"Document","unread notifications":"unread notifications","Document notifications panel":"Document notifications panel","For you notifications panel":"For you notifications panel","Notification message:":"Notification message:","Notification headline:":"Notification headline:","Notification time:":"Notification time:","Unread notification":"Unread notification",Notification:"Notification",unread:"unread",read:"read",Load:"Load","more notifications":"more notifications","Load More":"Load More","User notifications for":"User notifications for",notification:"notification",notifications:"notifications",available:"available",Notifications:"Notifications","User:":"User:","People notifications panel":"People notifications panel",Documents:"Documents","For You":"For You",People:"People","Notification categories":"Notification categories","Mark all notifications as read":"Mark all notifications as read","Notification actions":"Notification actions","View all notifications":"View all notifications","Notifications panel":"Notifications panel","Notifications bell icon - no unread notifications":"Notifications bell icon - no unread notifications","Notifications count":"Notifications count","Notification bell with":"Notification bell with","User online":"User online","mins ago.":"mins ago.","Reaction count":"Reaction count","Reaction with":"Reaction with","Reaction by":"Reaction by","Users who reacted":"Users who reacted","Reaction details":"Reaction details","React with":"React with",emoji:"emoji","Choose a reaction":"Choose a reaction","Available reactions":"Available reactions","Add reaction":"Add reaction","Reaction selector":"Reaction selector","Start audio recording":"Start audio recording","Audio Recording":"Audio Recording","Screen Recording":"Screen Recording","Start video recording":"Start video recording","Video Recording":"Video Recording","Recording options menu":"Recording options menu","Available recording types":"Available recording types",Record:"Record","Record audio":"Record audio","Record screen":"Record screen","Record video":"Record video","Recording controls for":"Recording controls for",recording:"recording","Stop recording":"Stop recording","Recording duration":"Recording duration","Resume recording":"Resume recording","Pause recording":"Pause recording","Currently recording:":"Currently recording:",none:"none","Audio waveform visualization":"Audio waveform visualization","Currently recording":"Currently recording","Recording paused":"Recording paused","Recording information":"Recording information","Recording controls":"Recording controls","Expand recording panel":"Expand recording panel","Collapse recording panel":"Collapse recording panel","Floating mode container for":"Floating mode container for","Screen recording preview":"Screen recording preview","Expanded view":"Expanded view","Mini preview":"Mini preview","Recording control panel":"Recording control panel","Draggable recording panel":"Draggable recording panel","Currently saving recording":"Currently saving recording","Saving Recording...":"Saving Recording...",Paused:"Paused","Video preview":"Video preview","Screen recording panel":"Screen recording panel","Draggable recording controls":"Draggable recording controls","Video recording preview":"Video recording preview","recording player":"recording player",Draggable:"Draggable",player:"player","recording pin":"recording pin","Created by":"Created by",Play:"Play","Draggable recording pin by":"Draggable recording pin by","Recording player":"Recording player","Audio recording":"Audio recording","Audio player":"Audio player","Audio player controls":"Audio player controls","Audio content and controls":"Audio content and controls","Playback controls":"Playback controls","Playback time":"Playback time","Audio waveform":"Audio waveform",Subtitles:"Subtitles","Additional controls and information":"Additional controls and information","Pause button":"Pause button","Pause audio":"Pause audio","Play audio":"Play audio","Audio progress":"Audio progress","Copy link to recording":"Copy link to recording","Delete recording":"Delete recording","Enter full screen mode":"Enter full screen mode","Recording name:":"Recording name:","Untitled recording":"Untitled recording","Recording player controls":"Recording player controls","Pause video":"Pause video","Play video":"Play video","Video subtitles":"Video subtitles","Toggle subtitles":"Toggle subtitles","Seek video playback":"Seek video playback","Video playback controls":"Video playback controls","Video transcription":"Video transcription","Video player":"Video player","Video player container":"Video player container","Video player with controls":"Video player with controls","Video information and controls":"Video information and controls","Video transcription summary":"Video transcription summary","Fullscreen video player":"Fullscreen video player","Expanded video player":"Expanded video player","Getting data ...":"Getting data ...","Get more options":"Get more options","Max 3 rewrites allowed":"Max 3 rewrites allowed",left:"left","Show original text":"Show original text","Select a rewritten text to create a task":"Select a rewritten text to create a task","Create Task":"Create Task","How would you like to change this copy?":"How would you like to change this copy?",Suggestions:"Suggestions","Selected users":"Selected users","additional users":"additional users",Reassign:"Reassign",Remove:"Remove","Please select a contact to assign":"Please select a contact to assign",Summary:"Summary","see more":"see more","see less":"see less","Invite users":"Invite users","No users are added.":"No users are added.",Invited:"Invited","General access":"General access","Copy Link":"Copy Link","Send invite":"Send invite","Go Back":"Go Back","Total Views":"Total Views","Views Today":"Views Today",View:"View",Views:"Views",Today:"Today","Search comments":"Search comments","In Progress":"In Progress",Status:"Status","Not set":"Not set","Comment Type":"Comment Type",Public:"Public",Private:"Private","Group By":"Group By","Assigned to Me":"Assigned to Me","Added by Me":"Added by Me",Other:"Other",Desktop:"Desktop",Mobile:"Mobile",Tablet:"Tablet",Others:"Others","Default - MacBook Pro Microphone (Built-in)":"Default - MacBook Pro Microphone (Built-in)","iPhone Microphone":"iPhone Microphone","MacBook Pro Microphone (Built-in)":"MacBook Pro Microphone (Built-in)","Sorting options":"Sorting options","Created First":"Created First","Created Last":"Created Last","Updated First":"Updated First","Updated Last":"Updated Last"}};var Ll=(()=>{let o=class o{constructor(e){this.loggingService=e,this.currentLanguageSignal=xe(navigator.language.split("-")[0]),this.autoTranslationSignal=xe(!1),this.translationsMap=new Map,this.translationCache=new Map,this.translationsUpdateSignal=xe(0),this.currentLanguage=this.currentLanguageSignal.asReadonly(),this.autoTranslation=this.autoTranslationSignal.asReadonly(),this.translationsVersion=this.translationsUpdateSignal.asReadonly(),this.currentTranslations=ki(()=>{let t=this.currentLanguageSignal(),r=this.translationsUpdateSignal();return this.translationsMap.get(t)||{}}),this.loggingService.log("%c[WB] Calling FUNCTION: constructor","color: green;"),this.setTranslations(sge),lo(()=>{let t=this.currentLanguageSignal();this.translationCache.clear(),this.translationsUpdateSignal.update(r=>r+1)},{allowSignalWrites:!0})}translate(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: translate","color: green;");let t=this.currentLanguageSignal(),r=this.translationsUpdateSignal(),a=`${t}:${e}:${r}`,s=this.translationCache.get(t);if(s?.has(a))return s.get(a)||e;let c=this.currentTranslations()[e];return this.translationCache.has(t)||this.translationCache.set(t,new Map),this.translationCache.get(t)?.set(a,c||e),oC(c)?e:c}catch{return e}}setTranslations(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setTranslations","color: green;");let t=!1;Object.entries(e).forEach(([r,a])=>{if(a&&typeof a=="object"){let s=this.translationsMap.get(r)||{};Object.keys(a).forEach(p=>{s.hasOwnProperty(p)||(t=!0)});let c=E(E({},s),a);this.translationsMap.set(r,c),this.translationCache.delete(r)}}),this.translationsUpdateSignal.update(r=>r+1),t&&setTimeout(()=>{this.translationsUpdateSignal.update(r=>r+1)},0)}catch(t){this.loggingService.catch("Error in setTranslations: ",t)}}setLanguage(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLanguage","color: green;"),this.currentLanguageSignal.set(e)}catch(t){this.loggingService.catch("Error in setLanguage: ",t)}})}enableAutoTranslation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableAutoTranslation","color: green;"),this.autoTranslationSignal.set(!0)}catch(e){this.loggingService.catch("Error in enableAutoTranslation: ",e)}}disableAutoTranslation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableAutoTranslation","color: green;"),this.autoTranslationSignal.set(!1),this.translationCache.clear()}catch(e){this.loggingService.catch("Error in disableAutoTranslation: ",e)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ge=(()=>{let o=class o{constructor(e,t){this.domService=e,this.translateService=t,this.sanitizedCache=new Map}transform(e){if(e==null)return"";let t=typeof e=="boolean"||typeof e=="number"?String(e):e;try{let r=this.translateService.currentLanguage(),a=this.translateService.translationsVersion(),s=`${r}:${t}:${a}`,c=this.sanitizedCache.get(s);if(c)return c;let p=this.translateService.translate(t),g=this.domService.sanitizeHtml(p);return this.sanitizedCache.set(s,g),this.sanitizedCache.size>1e3&&this.sanitizedCache.clear(),g}catch(r){return console.warn("Translation error:",r),t}}};o.\u0275fac=function(t){return new(t||o)(h(Be,16),h(Ll,16))},o.\u0275pipe=Ui({name:"translate",type:o,pure:!0,standalone:!1});let i=o;return i})();function zFe(i,o){if(i&1&&(y(0,"span",6),te(1),P(2,"translate"),b()),i&2){let n=l(2).ngIf;m(),br("",M(2,2,"You are following")," ",n.leaderName)}}function GFe(i,o){i&1&&(y(0,"span",6),te(1),P(2,"translate"),b()),i&2&&(m(),ze(M(2,1,"You are leading.")))}function WFe(i,o){if(i&1){let n=K();y(0,"div",2),W("click",function(){N(n);let t=l().ngIf,r=l();return F(t.type==="following"?r.closeOverlay():void 0)}),y(1,"div",3),u(2,zFe,3,4,"span",4)(3,GFe,3,3,"span",4),y(4,"button",5),W("click",function(){N(n);let t=l(2);return F(t.closeOverlay())}),te(5),P(6,"translate"),P(7,"translate"),b()()()}if(i&2){let n=l().ngIf;pe("no-pointer",n.type==="leading"),m(2),d("ngIf",n.type==="following"),m(),d("ngIf",n.type==="leading"),m(2),br("",M(6,6,"Stop")," ",M(7,8,n.type))}}function qFe(i,o){if(i&1&&(v(0),u(1,WFe,8,10,"div",1),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.leaderName!==""||n.type==="leading")}}var dq=(()=>{let o=class o extends nt{closeOverlay(){this.closeOverlayEvent.emit()}constructor(e,t,r){super(t,r),this.loggingService=e,this.elementRef=t,this.themeService=r,this.closeOverlayEvent=new Me,this.componentConfigSignal=xe({leaderName:"",type:"following"})}ngOnInit(){}setLeaderName(e){try{this.componentConfigSignal.update(t=>(t=D(E({},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=D(E({},t),{type:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setType: ",t)}}ngOnDestroy(){try{super.ngOnDestroy()}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(R),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["snippyly-follow-overlay"]],outputs:{closeOverlayEvent:"closeOverlayEvent"},standalone:!1,features:[L],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,r){t&1&&u(0,qFe,2,1,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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}.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}
|
|
485
|
+
`);for(var t=0;t<p.length;t++)if(p[t].indexOf("-->")!==-1){var r=p[t].split(" --> ")[0],a=p[t].split(" --> ")[1],s=p[t+1];c.push({startTime:r,endTime:a,startTimeInSeconds:this.getTimeInSecondsFromVttTime(r),endTimeInSeconds:this.getTimeInSecondsFromVttTime(a),text:s})}return c}catch(c){return this.loggingService.catch("Error in TranscriptionService getVttFileTextToArray: ",c),[]}}getTimeInSecondsFromVttTime(e){try{let t=e.split(":"),r=0;t.length===3&&(r=parseInt(t[0]),t.shift());let a=parseInt(t[0]),s=parseInt(t[1].split(".")[0]),c=parseInt(t[1].split(".")[1]);return((r*60*60+a*60+s)*1e3+c)/1e3}catch(t){return this.loggingService.catch("Error in TranscriptionService getTimeInSecondsFromVttTime: ",t),0}}};o.\u0275fac=function(t){return new(t||o)(ee(HP),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wi=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=c,this.domService=p,this.afAuth=g,this.iamService=f,this.functions=I,this.avatarService=x,this.contactService=B,this.storageService=z,this.dialog=G,this.loggingService=J,this.notificationService=ne,this.transcriptionService=ve,this.recorderService=_e,this.recorderUtilsService=Fe,this.userPermissionService=Ve,this.recorderAnnotationById$=new Ce({}),this.documentPaths=null,this.allowedElementIds$=new Ce([]),this.addRecorderMode$=new Ce(!1),this.recorderContainerDarkMode$=new Ce(!1),this.recordingTranscriptionEnabled$=new Ce(!0),this.draftRecordings$=new Ce([]),this.recorderNotesFound$=new Ce(!1),this.recordedData=null,this.videoEditorAutoOpen$=new Ce({}),this.commentService=null,this.getAllRecorderAnnotations().subscribe(be=>{}),this.loggingService.log("%c[WB] Creating CLASS: RecorderAnnotationService","color: blue;"),this.analyticsService.setRecorderAnnotationService(this),this.authService.setRecorderAnnotationService(this),this.databaseService.getDb().pipe(Le(be=>!!be),rt(1)).subscribe(be=>{be&&this.getDocumentPaths()},be=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",be)}),this.domService.onWindowPointerMove$().subscribe(be=>{if(this.addRecorderMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let Ie=this.domService.getBackgroundElement(be.clientX,be.clientY);Ie&&(this.isElementInsideAllowedElements(Ie)?zk(be.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=Ie):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowPointerMove$ subscription: ",be)}),this.domService.onWindowKeyupEsc$().subscribe(be=>{this.addRecorderMode$.value&&this.disableAddRecorderMode()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupEsc$ subscription: ",be)}),this.domService.onDocumentClick$().subscribe(be=>{if(be&&this.addRecorderMode$.value){if(be.preventDefault(),be.stopPropagation(),!zk(be.target)){let Ie=this.domService.getBackgroundElement(be.clientX,be.clientY);Ie&&this.isElementInsideAllowedElements(Ie)}this.disableAddRecorderMode()}},be=>{this.loggingService.catch("Error in RecorderAnnotationService onDocumentClick$ subscription: ",be)}),this.addRecorderMode$.subscribe(be=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),be?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"))},be=>{this.loggingService.catch("Error in RecorderAnnotationService addRecorderMode$ subscription: ",be)}),this.domService.onWindowKeyupBackspace$().subscribe(be=>{this.deleteRecorderPinAnnotations()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupBackspace$ subscription: ",be)}),this.domService.onWindowKeyupDelete$().subscribe(be=>{this.deleteRecorderPinAnnotations()},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",be)}),this.recorderService.onRecordedData().subscribe(be=>{this.recordedData=be},be=>{this.loggingService.catch("Error in RecorderAnnotationService onRecordedData subscription: ",be)}),this.domService.getDeleteCommmentAnnotations$().subscribe(be=>{be?.length&&be.forEach(Ie=>Q(this,null,function*(){}))},be=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",be)})}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(Qt(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(de(()=>this.getAnnotationById(e)),fe(t=>Q(this,null,function*(){return t?yield this.createRecorderData(t,!0):void 0})))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderId: ",t),le(void 0)}}getRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t={};return yield Promise.all(e.recorderIds.map(r=>Q(this,null,function*(){let a=this.getAnnotationById(r);if(!a)return;let s=yield this.createRecorderData(a,!0);s&&(t[r]=s)}))),{data:Object.keys(t).length>0?t:null}}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderIds: ",t),{data:null}}})}fetchRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t=this.recorderAnnotationById$.value,r=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(s=>e.recorderIds.includes(s.annotationId))),a.length===0?[]:(yield Promise.all(a.map(s=>Q(this,null,function*(){if(!s)return;let c=yield this.createRecorderData(s,!0);c&&r.push(c)}))),r)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService fetchRecorderDataByRecorderIds: ",t),[]}})}deleteRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let t=this.recorderAnnotationById$.value,r=[],a=Object.values(t),s=[];return e?.recorderIds?.length&&(s=a.filter(c=>e.recorderIds.includes(c.annotationId))),s.length===0?[]:(yield Promise.all(s.map(c=>Q(this,null,function*(){if(!c)return;let p=yield this.createRecorderData(c,!0);yield this.deleteRecorderPinAnnotation(c),p&&r.push(p)}))),r)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderDataByRecorderIds: ",t),[]}})}getRecordings(e){try{return this.recorderAnnotationById$.pipe(fe(t=>Q(this,null,function*(){let r=[],a=Object.values(t);return e?.recorderIds?.length&&(a=a.filter(s=>e.recorderIds.includes(s.annotationId))),a.length===0?[]:(yield Promise.all(a.map(s=>Q(this,null,function*(){if(!s)return;let c=yield this.createRecorderData(s,!0);c&&r.push(c)}))),r)})),Un(t=>(this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),le([]))))}catch(t){return this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",t),le([])}}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,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllRecorderAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in RecorderAnnotationService getAllRecorderAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>s?this.getDataFromDocumentIds([s]).pipe(de(g=>(p.annotations=g||[],E({},p)))):this.docService.getDocumentIds$().pipe(fe(g=>{let f=g?.length>0?g.map(I=>I.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(f).pipe(de(I=>(p.annotations=I||[],E({},p))))}))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(f=>f.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("RecorderAnnotationService getAllRecorderAnnotations").pipe(de(()=>p)):le(p)),de(p=>{let g=[];return p?.filteredAnnotations?.forEach(f=>{this.calculateRecorderAnnotationPosition(f),f?.targetElement||g.push(f)}),this.draftRecordings$.next(g),p}),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([]))):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.RECORDER)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Recorder feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:r}=e;if(t?.some(p=>!p)||!this.documentPaths)return le([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=le([]),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 p=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let f=0;f<(p?.length??0);f+=U.LISTENER_CONTEXT_BATCH_SIZE)g.push(p?.slice(f,f+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=mn(g.map(f=>this.commonDbService.dbListener({feature:"allRecorders",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",t),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[],...f?.length?[lt("context.accessFields","array-contains-any",f)]:[])]})}).pipe(Ar()))).pipe(de(f=>ia(f)))}else{let p=[];for(let g=0;g<(t?.length??0);g+=U.LISTENER_BATCH_SIZE)p.push(t?.slice(g,g+U.LISTENER_BATCH_SIZE)??[]);s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allRecorders",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",g),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}return s.pipe(de(p=>({data:p?.data,operation:p?.operation})),de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p).filter(I=>typeof I=="object")),{data:f,operation:g}}),de(({data:p,operation:g})=>{if(!t)return{data:p,documentMap:{},operation:g};let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),de(({data:p,documentMap:g,operation:f})=>{if(!r)if(f?.type==="removed"){if(f?.ids?.length){let I=this.recorderAnnotationById$.value;f?.ids?.forEach(x=>{delete I?.[x]}),this.recorderAnnotationById$.next(I)}}else Object.entries(g).forEach(([I,x])=>{this.setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:x})});return p}),Un(p=>(this.loggingService.catch("Error in RecorderAnnotationService getDataFromDocumentId: ",p),le([]))))}else return le([])}setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.recorderAnnotationById$.value),s);this.recorderAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in RecorderAnnotationService setRecorderAnnotationsByOrganizationIdAndDocumentId:",s)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(r=>t.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService filterAnnotationsByLocations:",r),[]}}calculateRecorderAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let r=t.iterateNext();if(r&&Pi(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:c}=Hg(r);e.position={top:s*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 r=this.recorderAnnotationById$.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in RecorderAnnotationService getAnnotationById: ",r);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(fe(()=>{let r=this.getAnnotationById(e,t);return r?le(r):le(null)}),Un(r=>(this.loggingService.catch("Error in RecorderAnnotationService getCommentAnnotationById: ",r),le(null))))}getRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};return Object.values(this.recorderAnnotationById$.value).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderAnnotationsByOrganizationIdAndDocumentId:",r),[]}}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 r=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)}}}catch{}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService setLocationToRecorderAnnotation:",t)}}addRecorder(e,t,r){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."),le(null);{t.from=a,t.color=U.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:s,topPositionY:c}=this.domService.getTopLeftPosition();t.positionX=s,t.positionY=c;let p=this.domService.getCurrentWindowSizeValue();if(t.screenWidth=p.screenWidth,t.screenHeight=p.screenHeight,t.screenScrollHeight=p.screenScrollHeight,t.recorderedElementPath="",e&&(t.targetElement=this.domService.getTargetElementForCursorPosition(e)),t?.targetElement?.xpath){let g=this.domService.getXPath(t.targetElement.xpath);if(g){let f=g.iterateNext();f&&(Pi(f)||(t.targetElement=null))}}return this.setLocationToRecorderAnnotation(t),t.pageInfo=Ni(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveRecorderToDb(t,r)}}else return le(null)}catch(a){return this.loggingService.catch("Error in RecorderAnnotationService addRecorder: ",a),le(null)}}saveRecorderToDb(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: saveRecorderToDb","color: green;");try{return this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.RECORDER)?this.docService.getDocumentPaths$().pipe(Le(r=>!!r),rt(1),fe(r=>(this.documentPaths=r,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(a=>!!a),rt(1),fe(a=>Q(this,null,function*(){if(this.documentPaths?.recorder){e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.recorderUrl=this.generateRecorderUrl(e));let s=JSON.parse(JSON.stringify(e));if(s.position=null,!s?.metadata?.documentId){s?.metadata||(s.metadata={});let g=this.docService.getBaseMetadata("recorder",{commentAnnotationId:e.commentAnnotationId});s.metadata=E(E({},s?.metadata),g)}let{documentId:c,organizationId:p}=s?.metadata||{};if(e.commentAnnotationId){let g=this.commentService?.getAnnotationById(e.commentAnnotationId??"");if(g?.context?.access&&g?.context?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:e.from?.userId,accessFields:g.context.accessFields}))return this.loggingService.catch("User does not have context access to add recorder annotation.",void 0,void 0,!0),null;s.context={access:g.context.access,accessFields:g.context.accessFields}}}return yield new Promise((g,f)=>Q(this,null,function*(){yield this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:c,organizationId:p},data:JSON.parse(JSON.stringify(s)),callback:()=>{g(!0)},errorCallback:I=>{f(I)}})})),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}),this.processRecording(e,"recording","merge"),this.updateNotificationsDatabase(e,Z0.ADDED),e}else return null})))))):le(null)}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService saveRecorderToDb: ",r),le(null)}}processRecording(e,t,r){return Q(this,null,function*(){try{let a=Ji(this.functions,eo({url:wn?.cloudFunction?.processRecording,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),s=this.docService.getDocumentPaths();e?.metadata?.documentId&&(s=new Sm({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:s?.recorder+e?.annotationId,fromUser:this.authService.getUser(),clientOrganizationId:s?.clientOrganizationId,clientDocumentId:s?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:s?.recorder,annotationId:e?.annotationId,sourceFeature:t||"recording",annotationData:e,skipMerge:!0,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:r,returnType:"transcription",generatePreviewImages:this.recorderService.getVideoEditor()&&this.recorderService.getVideoEditorTimelinePreview()};if(c?.useFirestore){let z=yield this.recorderUtilsService.encryptRecorderAnnotation(e);c.annotationData=z}let p=this.documentPaths?.organizationId,g=this.documentPaths?.documentId;e?.metadata?.documentId&&(g=e.metadata.documentId,p=e.metadata.organizationId);let f=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;p&&(f=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${p}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${g}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),c.bucketPath=f;let I;try{I=yield a(c)}catch(z){z?.details?.type==="recording"&&this.recorderActionsService?.onError({type:"recordingFailed",message:"Recording failed",recorderId:z.details.recorderId}),z?.details?.type==="transcription"&&this.recorderActionsService?.onError({type:"transcriptionFailed",message:"Transcription failed",recorderId:z.details.recorderId}),this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",z)}let x=this.getAnnotationById(e?.annotationId);if(!x)return;let B=yield this.createRecorderData(x,!1);if(B){if(I?.data?.transcriptedText&&(B.transcription.contentSummary=I.data.transcriptedText),I?.data?.vttUrl)try{let z=yield this.transcriptionService.getFileContent(I.data.vttUrl).toPromise();z&&(B.transcription.transcriptSegments=this.getVttFileTextToArray(z),B.transcription.vttFileUrl=I.data.vttUrl),B?.assets?.length&&B.assets.forEach(G=>{G.transcription=B.transcription}),B?.assetsAllVersions?.length&&(B.assetsAllVersions[0].transcription=B.transcription),this.recorderActionsService?.onTranscriptionDone(B)}catch(z){this.loggingService.catch("Error fetching VTT content: ",z)}x?.attachments?.length&&this.recordedData&&(this.recordedData.videoUrl=x.attachments[0].url),t==="recording"&&this.recorderActionsService?.onRecordingDone(B)}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 Q(this,null,function*(){try{if(!e)return null;let r=aC(e.metadata||{}),a=wr(e.from),s={recorderId:e.annotationId||"",from:a,assets:[],metadata:r,assetsAllVersions:[],transcription:{transcriptSegments:[],vttFileUrl:"",contentSummary:""}},c=e;e.latestVersion&&e.recordingEditVersions?.[e.latestVersion]&&(c=e.recordingEditVersions[e.latestVersion]);let p=f=>Q(this,null,function*(){let I={transcriptSegments:[],vttFileUrl:"",contentSummary:f?.transcription?.transcriptedText||""};if(t&&f?.transcription?.vttUrl)try{let x=yield this.transcriptionService.getFileContent(f.transcription.vttUrl).toPromise();x&&(I.transcriptSegments=this.getVttFileTextToArray(x),I.vttFileUrl=f.transcription.vttUrl)}catch(x){this.loggingService.catch("Error fetching VTT content: ",x)}return I}),g=yield p(c);if(s.transcription=g,c?.attachments?.length)for(let f of c.attachments)f?.url&&s.assets.push({version:e.latestVersion||1,url:f.url,mimeType:f.mimeType,fileName:f.name,fileSizeInBytes:f.size,fileFormat:f.type,transcription:E({},g),thumbnailUrl:e.attachments?.[0]?.thumbnail});if(e.recordingEditVersions){let f=Object.entries(e.recordingEditVersions).map(z=>Q(this,[z],function*([x,B]){let G=parseInt(x),J=yield p(B),ne=B?.attachments?.[0]||B?.attachment;return{version:G,url:ne?.url,mimeType:ne?.mimeType,fileName:ne?.name,fileSizeInBytes:ne?.size,fileFormat:ne?.type,transcription:J,thumbnailUrl:B?.attachments?.[0]?.thumbnail}})),I=yield Promise.all(f);s.assetsAllVersions=I.filter(x=>x.url)}else s.assetsAllVersions=[...s.assets];return s}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService createRecorderData: ",r),null}})}updateRecorder(e,t=!1,r){try{r&&this.setLocationToRecorderAnnotation(e),t&&this.updateNotificationsDatabase(e,Z0.UPDATED),this.updateRecorderToDb(e)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateRecorder: ",a)}}resolveRecorder(e){try{this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(e,Z0.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 r=t.iterateNext();r&&(Pi(r)||(e.targetElement=null))}}if(e.annotationId){let t=this.recorderAnnotationById$.value;this.recorderAnnotationById$.next(D(E({},t),{[e.annotationId]:E({},e)}))}if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.RECORDER)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata();t.metadata=E(E({},t?.metadata),s)}let{documentId:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:r,organizationId:a},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in RecorderAnnotationService updateRecorderToDb: ",t)}}deleteRecorderPinAnnotations(){try{let e=this.domService.getSelectedAnnotationsMap(),t=this.authService.getUser(),r=[];Object.keys(e).forEach(a=>Q(this,null,function*(){let s=e[a];s.type==="recorder"&&t&&s.from&&(t?.isAdmin||s.from.userId===t.userId)&&r.push(s)})),r?.length&&(this.analyticsService.trackEvent(Y.Events.Recording.RECORDING_DELETE_TRIGGERED,{annotationId:r.map(a=>a.annotationId).join()}),this.dialog.open(La,{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(rt(1)).subscribe(a=>{a&&(r.forEach(s=>Q(this,null,function*(){yield this.deleteRecorderPinAnnotation(s)})),setTimeout(()=>{document.querySelectorAll(`[${U.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(Ne.RECORDER)&&this.documentPaths?.recorder&&e?.annotationId){this.updateNotificationsDatabase(e,Z0.DELETED),e?.attachment&&this.storageService.deleteAttachment({attachment:e.attachment}),e?.attachments&&e.attachments.forEach(s=>{this.storageService.deleteAttachment({attachment:s}).catch(c=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete attachment: ",c)})}),e?.transcription&&(e?.transcription?.srtBucketPath&&this.storageService.deleteFileFromPath(e.transcription.srtBucketPath).catch(s=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete srt file: ",s)}),e?.transcription?.vttBucketPath&&this.storageService.deleteFileFromPath(e.transcription.vttBucketPath).catch(s=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete vtt file: ",s)})),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:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromRecorderAnnotation(e);return this.commonDbService.deleteData({feature:"recorder",properties:{id:e.annotationId,documentId:r,organizationId:a}}).then(s=>Q(this,null,function*(){let c=yield this.createRecorderData(e,!0);c&&this.recorderActionsService?.onDeleteRecording(c)}))}else return Promise.resolve()}enableAddRecorderMode(){this.authService.isFeatureAllowed(Ne.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:Ne.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:Ne.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 r=this.domService.getXPath(t),a=this.getRecorderPinAnnotationObject();a&&(a.targetElement={xpath:r,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 nu;t.from=e,t.color=U.DEFAULT_ANNOTATION_COLOR,t.lastUpdated=this.timestamp;let{topPositionX:r,topPositionY:a}=this.domService.getTopLeftPosition();t.positionX=r,t.positionY=a;let s=this.domService.getCurrentWindowSizeValue();t.screenWidth=s.screenWidth,t.screenHeight=s.screenHeight,t.screenScrollHeight=s.screenScrollHeight,t.recorderedElementPath="";let c=this.docService.getLocation();return c&&(t.locationId=c.locationId,t.location=c.location),t}return null}updateNotificationsDatabase(e,t,r={}){try{let a=E({annotationData:e,actionType:t,notificationSource:"recorder",recordingType:e?.recordingType},r);this.notificationService.updateNotificationDatabase(a)}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=Ni(),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 r=this.documentPaths?.organizationId,a=this.documentPaths?.documentId;t?.metadata?.documentId&&(a=t.metadata.documentId,r=t.metadata.organizationId);let s=`${U.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;return r&&(s=`${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${r}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),this.storageService.uploadFile({path:s,file:e})}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(U.URL_PARAMS.RECORDER_ID),t.searchParams.append(U.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),le(!1)}}getRecorderNotesFound(){try{return this.recorderNotesFound$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),!1}}editVideoRecording(e,t,r,a,s,c){return Q(this,null,function*(){try{let p=Ji(this.functions,eo({url:wn?.cloudFunction?.videoBackend,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),g=this.docService.getDocumentPaths();r?.metadata?.documentId&&(g=new Sm({apiKey:this.configService.getApiKey(),clientDocumentId:r.metadata.clientDocumentId,clientOrganizationId:r.metadata.clientOrganizationId,documentId:r.metadata.documentId,organizationId:r.metadata.organizationId}));let f={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:g?.recorder+(r?.annotationId||""),fromUser:this.authService.getUser(),clientOrganizationId:g?.clientOrganizationId,clientDocumentId:g?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:g?.recorder,annotationId:r?.annotationId,annotationData:r,videoUrl:e,segments:t,zoomOptions:a,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:s,backendUpload:!0};if(c){let G=yield c.arrayBuffer(),J=new Uint8Array(G),ne="";for(let _e=0;_e<J.length;_e++)ne+=String.fromCharCode(J[_e]);let ve=btoa(ne);f.videoBlobData=ve,f.videoBlobType=c.type,f.videoBlobSize=c.size}if(f?.useFirestore&&r){let G=yield this.recorderUtilsService.encryptRecorderAnnotation(r);f.annotationData=G}let I=this.documentPaths?.organizationId,x=this.documentPaths?.documentId;r?.metadata?.documentId&&(x=r.metadata.documentId,I=r.metadata.organizationId);let B=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${x}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`;I&&(B=`${this.configService.getApiKey()}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${I}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${x}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`),f.bucketPath=B;let z=yield p(f);if(s==="standalone"){let G=z?.data;if(G&&G?.videoData){let J=atob(G.videoData),ne=new ArrayBuffer(J.length),ve=new Uint8Array(ne);for(let Ve=0;Ve<J.length;Ve++)ve[Ve]=J.charCodeAt(Ve);let _e=new Blob([ve],{type:G.mimeType||"video/mp4"}),Fe=document.createElement("a");Fe.href=URL.createObjectURL(_e),Fe.download="edited-video.mp4",document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe)}}return z}catch(p){throw this.loggingService.catch("Error in RecorderAnnotationService editVideoRecording: ",p),p}})}setVideoEditorAutoOpen(e){try{this.videoEditorAutoOpen$.next(E(E({},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),le({})}}getVideoEditorAutoOpen(){try{return this.videoEditorAutoOpen$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),{}}}downloadLatestVideo(e){return Q(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 r,a,s=t.latestVersion;if(s&&t.recordingEditVersions?.[s]?(r=t.recordingEditVersions[s].attachments?.[0]?.url,a=t.recordingEditVersions[s].attachments?.[0]?.name):(r=t.attachments?.[0]?.url||t.attachment?.url,a=t.attachments?.[0]?.name||t.attachment?.name),!r)return this.loggingService.catch("No video URL found for recording: "+e),!1;let c=yield fetch(r);if(!c.ok)return this.loggingService.catch("Failed to fetch video: "+c.statusText),!1;let p=yield c.blob(),g=document.createElement("a");return g.href=URL.createObjectURL(p),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)(ee(Je),ee(Ft),ee(ot),ee(In),ee(un),ee(je),ee(Be),ee(Ri),ee(En),ee(Do),ee(ym),ee(Si),ee(su),ee(po),ee(_),ee(hn),ee(qC),ee(bn),ee(jC),ee(ss))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var we=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve,be,Ie,Ae,Se,he,Oe,Re,Zi){this.analyticsService=e,this.areaService=t,this.commonDbService=r,this.configService=a,this.docService=s,this.databaseService=c,this.authService=p,this.domService=g,this.afAuth=f,this.avatarService=I,this.contactService=x,this.storageService=B,this.functions=z,this.dialog=G,this.iamService=J,this.loggingService=ne,this.notificationService=ve,this.customFilterService=_e,this.reactionService=Fe,this.hotkeyService=Ve,this.recorderService=be,this.viewsService=Ie,this.buttonService=Ae,this.metadataService=Se,this.commonDbUtilsService=he,this.attachmentResolverService=Oe,this.userPermissionService=Re,this.recorderAnnotationService=Zi,this.customPinsById=new Map,this.commentAdded$=new Qe,this.commentUpdated$=new Qe,this.commentAccepted$=new Qe,this.commentRejected$=new Qe,this.commentAnnotationDeleted$=new Qe,this.multiThreadCommentAnnotationDeleted$=new Qe,this.commentAnnotationById$=new Ce(null),this.multiThreadCommentAnnotationById$=new Ce(null),this.ghostCommentAnnotationMap$=new Ce({}),this.unreadCommentsMap$=new Ce(null),this.documentPaths=null,this.user=null,this.customCategoryMap=U.CommentCategoryMap,this.allowedElementIds$=new Ce([]),this.allowedElementClassNames$=new Ce([]),this.allowedElementQuerySelectors$=new Ce([]),this.addCommentMode$=new Ce(!1),this.persistentCommentMode$=new Ce(!1),this.seenByUsers$=new Ce(!0),this.deleteReplyConfirmation$=new Ce(!1),this.persistentModeBanner$=new Ce(!0),this.commentAddedEmitter=null,this.commentContextProvider=null,this.textCommentMode$=new Ce(!0),this.sidebarVisible$=new Ce(!1),this.sidebarOpenedByCustomTrigger$=new Ce(!1),this.floatingCommentsEnabled$=new Ce(!0),this.moderatorMode$=new Ce(!1),this.streamMode$=new Ce(!1),this.enableSignInButton$=new Ce(!1),this.enableUpgradeButton$=new Ce(!1),this.onSignInClick$=new Qe,this.onUpgradeClick$=new Qe,this.enableAttachment$=new Ce(!0),this.enableReactions$=new Ce(!0),this.allowedRecordings$=new Ce(["audio","video","screen"]),this.openSidebar$=new Qe,this.showScreenSizeInfo$=new Ce(!1),this.showCommentIndex$=new Ce(!1),this.popoverMode$=new Ce(!1),this.popoverTriangleComponent$=new Ce(!0),this.draftMode$=new Ce(!0),this.enableDialogOnHover$=new Ce(!0),this.enableDialogOnTargetElementClick$=new Ce(!1),this.enablePriority$=new Ce(!1),this.enableStatus$=new Ce(!0),this.enableResolve$=new Ce(!0),this.enableGhostComments$=new Ce(!1),this.enableGhostCommentsMessage$=new Ce(!0),this.inboxMode$=new Ce(!1),this.enableAutoCategorize$=new Ce(!1),this.commentContainerDarkMode$=new Ce(!1),this.suggestionMode$=new Ce(!1),this.mobileMode$=new Ce(!0),this.inlineCommentMode$=new Ce(!1),this.minimap$=new Ce(!1),this.commentsOnDom$=new Ce(!0),this.commentToolEnabled$=new Ce(!0),this.totalMediaLength$=new Ce(0),this.sidebarUrlNavigationEnabled$=new Ce(!1),this.detectionStrategy$=new Ce(Fk.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Ce(!1),this.sidebarButtonOnCommentDialogClick$=new Qe,this.commentNavigationButtonClick$=new Qe,this.deviceIndicatorOnCommentPins$=new Ce(!1),this.sidebarCommentClick$=new Qe,this.privateCommentMode$=new Ce(!1),this.privateCommentAllowed$=new Ce(!1),this.scrollToComment$=new Ce(!0),this.userMentions$=new Ce(!0),this.paginatedContactList$=new Ce(!1),this.deleteOnBackspace$=new Ce(!0),this.hotkeyEnabled$=new Ce(!1),this.recordingSummaryEnabled$=new Ce(!0),this.unreadIndicatorMode$=new Ce(cf.MINIMAL),this.composerMode$=new Ce(df.DEFAULT),this.enterKeyToSubmit$=new Ce(!1),this.resolvedCommentsOnDom$=new Ce(!1),this.bubbleOnPinEnabled$=new Ce(!1),this.bubbleOnPinHoverEnabled$=new Ce(!0),this.excludeLocationIdsFromSidebar$=new Ce([]),this.multiThread$=new Ce(!1),this.groupMatchedComments$=new Ce(!1),this.shortUserName$=new Ce(!0),this.collapsedComments$=new Ce(!1),this.fullExpanded$=new Ce(!1),this.queryParamsComments$=new Ce(!1),this.resolveStatusAccessAdminOnly$=new Ce(!1),this.linkCallback$=new Ce(!1),this.svgAsImg$=new Ce(!1),this.commentToNearestAllowedElement$=new Ce(!1),this.filterCommentsOnDom$=new Ce(!1),this.maxReplyAvatars$=new Ce(3),this.replyAvatars$=new Ce(!1),this.commentplaceholder$=new Ce(void 0),this.replyplaceholder$=new Ce(void 0),this.screenshotEnabled$=new Ce(!1),this.pinShadowDOM$=new Ce(!0),this.dialogShadowDOM$=new Ce(!0),this.textCommentToolShadowDOM$=new Ce(!0),this.pinDarkMode$=new Ce(null),this.textCommentToolDarkMode$=new Ce(null),this.textCommentToolbarDarkMode$=new Ce(null),this.textCommentToolbarShadowDOM$=new Ce(!0),this.sidebarShadowDOM$=new Ce(!0),this.changeDetectionInCommentMode$=new Ce(!1),this.commentSelectionChange$=new Qe,this.commentsFromSidebarMap$=new Ce(null),this.sidebarButtonCountType$=new Ce("default"),this.filterGhostCommentsInSidebar$=new Ce(!1),this.commentSidebarFilters$=new Ce({}),this.commentSidebarSystemFiltersOperator$=new Ce(md.AND),this.bubbleCommentAnnotationIds$=new Ce([]),this.updateCommentDialogPositionTriggerSubject$=new Ce(void 0),this.areaCommentEnabled$=new Ce(!0),this.commentPinCursorImage$=new Ce(""),this.commentAnnotationsFromCommentsContainer$=new Ce([]),this.customChipDropdownData$=new Ce(null),this.originalCommentAnnotationsByDocumentId$=new Ce({}),this.draftCommentAnnotationsByAnnotationId$=new Ce(null),this.draftMultiThreadCommentAnnotationsByAnnotationId$=new Ce({}),this.copyLink$=new Ce(""),this.addCommentDragMode=!1,this.dragSubscriptions=[],this.hotkeySubscriptions=[],this.sidebarData$=new Ce(null),this.sidebarCustomActionEventData$=new Ce(null),this.sidebarCustomActionEventDataAllChanges$=new Ce(null),this.sidebarCustomActionEventDataOnInit$=new Ce(null),this.customActions$=new Ce(!1),this.focusedThreadMode$=new Ce(!1),this.openAnnotationInFocusMode$=new Ce(!1),this.customStatusesShown$=new Ce(!1),this.readOnly$=new Ce(!1),this.customAutocompleteSearch$=new Ce(!1),this.deleteThreadWithFirstComment$=new Ce(!0),this.transformContext$=new Ce(null),this.expandMentionGroups$=new Ce(!1),this.showMentionGroupsFirst$=new Ce(!1),this.showMentionGroupsOnly$=new Ce(!1),this.fullScreenInSidebar$=new Ce(!1),this.composerFileAttachments$=new Ce(null),this.attachmentNameInMessage$=new Ce(!1),this.allowedFileTypes$=new Ce([]),this.forceCloseAllOnEsc$=new Ce(!1),this.autoCompleteScrollConfig$=new Ce({itemSize:55,minBufferPx:350,maxBufferPx:600,templateCacheSize:350}),this.getCommentAnnotationForClient=bt=>{try{let It=["commentCategories","color","resolved","inProgress","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","screenScrollTop","taggedElementPath","taggedElementRect","targetElement","position","documentParamsId","documentParams","ghostComment","areaAnnotationId","iam","commentSource","involvedUserIds","mentionedUserIds","viewedByUserIds","views"],yt=JSON.parse(JSON.stringify(bt)),Lt={};return Object.keys(yt).forEach(Yt=>{It.includes(Yt)||(Lt[Yt]=yt[Yt])}),Lt?.comments?.forEach(Yt=>{let zt=[];Yt?.reactionAnnotationIds&&Yt?.reactionAnnotationIds?.forEach(tn=>{let Ii=this.reactionService.getAnnotationById(tn);if(Ii){let nn=this.reactionService.getReactionAnnotationForClient(Ii);zt.push(nn)}}),Yt.reactionAnnotations=zt}),yt?.viewedByUserIds?.forEach(Yt=>{let zt=this.contactService.getUserBySnippylyId(Yt);zt&&(Lt.viewedBy||(Lt.viewedBy=[]),Lt.viewedBy.push(zt))}),this.user?.userSnippylyId&&(Lt.unread=!yt?.viewedByUserIds?.includes(this.user.userSnippylyId)),JSON.parse(JSON.stringify(Lt))}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(Bi(100),Oi()).subscribe(([bt,It])=>{try{if(this.draftCommentAnnotationsByAnnotationId$.value){let yt=Object.keys(this.draftCommentAnnotationsByAnnotationId$.value||{}),Lt=[];Object.keys(bt||{}).forEach(zt=>{!It?.[zt]&&yt.includes(zt)&&Lt.push(zt)});let Yt=JSON.parse(JSON.stringify(this.draftCommentAnnotationsByAnnotationId$.value||{}));Lt.forEach(zt=>{delete Yt[zt]}),hi(Yt,this.draftCommentAnnotationsByAnnotationId$.value)||this.draftCommentAnnotationsByAnnotationId$.next(Yt)}}catch{}}),this.docService.getDocumentPaths$().pipe(Oi()).subscribe(([bt,It])=>{bt?.documentId!==It?.documentId&&this.unreadCommentsMap$.next(null),It&&this.shouldEnableReadOnly()},bt=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",bt)}),this.authService.getUser$().subscribe(bt=>{bt||this.resetCacheData()},bt=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",bt)}),this.authService.getUser$().pipe(fe(bt=>bt?mn([this.iamService.isUserAdmin$(),this.contactService.getUserOrganizationContacts$()]).pipe(de(([It,yt])=>{let Lt=!1;return yt?.find(Yt=>Yt.userId===bt?.userId)&&(Lt=!0),{isUserAdmin:It,isOrgUser:Lt}})):le({isUserAdmin:!1,isOrgUser:!1}))).subscribe(({isUserAdmin:bt,isOrgUser:It})=>{let yt=bt||It;yt!==this.privateCommentAllowed$.value&&this.privateCommentAllowed$.next(yt)}),this.databaseService.getDb().pipe(Le(bt=>!!bt),rt(1)).subscribe(bt=>{bt&&this.getDocumentPaths()},bt=>{this.loggingService.catch("Error in CommentService getDb subscription: ",bt)}),this.domService.onWindowPointerMove$().subscribe(bt=>{if(this.addCommentMode$.value){let It=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let yt=this.domService.getBackgroundElement(bt.clientX,bt.clientY,!0,!0);if(yt&&Ice(yt,{x:bt.clientX,y:bt.clientY})&&(yt=yt?.parentElement),yt)if(this.isElementInsideAllowedElements(yt))if(Ip(bt.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==yt&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=yt;let Lt=this.domService.getSelectedAnnotationsMap("comment")||{},Yt=this.commentPinCursorImage$.value||U.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,Yt,!!Object.keys(Lt)?.length),It=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&It&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},bt=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",bt)}),this.domService.onWindowKeyupEsc$().subscribe(bt=>{if(this.addCommentMode$.value){let It=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(It)?.length&&this.domService.resetSelectedAnnotationsMap(),this.disableAddCommentMode()}},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",bt)}),this.domService.onDocumentClick$().subscribe(bt=>{if(bt?.target&&!Ki(bt?.target)){let It=this.domService.getSelectedAnnotationsMap("comment")||{};if(It=E(E({},It),this.domService.getSelectedAnnotationsMap("multiThread")||{}),Object.keys(It)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),bt.preventDefault(),bt.stopPropagation();return}}if(bt&&this.addCommentMode$.value&&!Ip(bt.target)){let It=!1;if(this.addCommentDragMode)bt.preventDefault(),bt.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let yt=this.domService.getBackgroundElement(bt.clientX,bt.clientY);if((this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(bt.clientX,bt.clientY)||bt?.target&&Ki(bt?.target))&&(yt=null),yt&&(this.isElementInsideAllowedElements(yt)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement(yt))&&(It=this.isElementInsideManualCommentContainer(yt),!It)){bt.preventDefault(),bt.stopPropagation();let Lt=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(bt,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,Lt)}}this.persistentCommentMode$?.value?this.detectToAddAreaComment():It||this.disableAddCommentMode()}},bt=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",bt)}),this.addCommentMode$.subscribe(bt=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),bt?(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(It=>It.unsubscribe()),this.clearFreeStyleCommentContext())},bt=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",bt)}),this.domService.onWindowKeyupBackspace$().subscribe(bt=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",bt)}),this.domService.onWindowKeyupDelete$().subscribe(bt=>{this.deleteCommentPinAnnotations("keyupDelete")},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",bt)}),this.domService.getDeleteCommmentAnnotations$().subscribe(bt=>{bt?.length&&(bt?.filter(yt=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes(yt.type))).forEach(yt=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(yt)}))},bt=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",bt)}),this.getPopoverMode$().subscribe(bt=>{bt?document?.body?.setAttribute(U.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(U.ATTRIBUTES.VELT_POPOVER_MODE)},bt=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",bt)}),this.customFilterService.customCategoryMap$.subscribe(bt=>{this.customCategoryMap=bt},bt=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",bt)}),this.hotkeyEnabled$.subscribe(bt=>{bt?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},bt=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",bt)}),this.domService.getSelectedAnnotationsMap$().pipe(Oi()).subscribe(([bt,It])=>{try{let yt=Object.values(bt||{}).filter(Yt=>!["tag","recorder","rewriter","arrow","area"].includes(Yt.type)),Lt=Object.values(It||{}).filter(Yt=>!["tag","recorder","rewriter","arrow","area"].includes(Yt.type));yt?.forEach(Yt=>{Lt?.find(zt=>zt.annotationId===Yt.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(Yt),selected:!1})}),Lt?.forEach(Yt=>{yt?.find(zt=>zt.annotationId===Yt.annotationId)||this.commentSelectionChange$.next({annotation:this.getCommentAnnotationForClient(Yt),selected:!0})})}catch(yt){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",yt)}},bt=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",bt)})}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.customAutocompleteSearch$.next(!1),this.hightlightElement=null,this.addCommentMode$.next(!1),this.unreadCommentsMap$.next(null),this.documentPaths=null,this.commentsFromSidebarMap$.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 r,a,s,c=null,p=null;this.dragSubscriptions.forEach(g=>g.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe(Le(g=>!Ki(g?.target)),rt(1)).subscribe(g=>{c=null,p=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(f=>{if(c===null){let I=f?.startPoint?.event?.target,x=Ki(I),B=Ip(I),z=this.isElementInsideAllowedElements(I);c=!x&&!B&&z}if(c){this.addCommentDragMode=!0,r=f.startPoint,a=f.curPoint;let I=f?.curPoint?.event?.target,x=Ki(I),B=Ip(I),z=this.isElementInsideAllowedElements(I);p=!x&&!B&&z,p?s=this.domService.drawRectangle(r,a):s?.remove()}})),this.domService.onWindowPointerUp$().pipe(ml(1),rt(1)).subscribe(f=>{if(a={x:f.clientX,y:f.clientY},r&&a&&(s?.remove(),c&&p)){let I=[{x:r.x-window.scrollX,y:r.y-window.scrollY},{x:a.x,y:a.y}],x=this.freeStyleCommentContext&&typeof this.freeStyleCommentContext=="object"?JSON.parse(JSON.stringify(this.freeStyleCommentContext)):void 0;this.addComment(f,void 0,I,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,x)}this.dragSubscriptions.forEach(I=>I.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({})}catch(e){this.loggingService.catch("Error in CommentService resetCacheData: ",e)}}addAreaContainerTag(){try{if(!(document.querySelector(U.TAGS.VELT_AREAS)||document.querySelector(U.TAGS.SNIPPYLY_AREAS))){let t=document.createElement(U.TAGS.VELT_AREAS);document.body.appendChild(t)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${U.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(t=>{window.getComputedStyle(t).position==="static"&&t.setAttribute(U.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${U.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(t=>{t.removeAttribute(U.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:Ne.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:Ne.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:Ne.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:r,detectGhostComments:a,skipPositionCalculation:s,query:c,fromCommentSidebar:p,analytics:g,addFilterCommentsOnDomCheck:f}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let I,x,B;g?.enabled&&this.analyticsService.trackEvent(g?.eventName||Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,g?.properties);try{if(e&&(B=`${Nn(e)}`),t&&typeof t=="object"){let z=or(t);x=z?.id,I=Nn(JSON.stringify(z))}}catch(z){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",z)}return ei(this.afAuth).pipe(Le(z=>!!z),fe(z=>this.isFeatureAllowed({firebaseUser:z,annotations:[],filteredAnnotations:[]})),fe(z=>z.featureAllowed?this.iamService.isUserAllowed$().pipe(de(G=>(z.featureAllowed=G,z))):le(z)),fe(z=>z.featureAllowed?le(z).pipe(fe(G=>this.docService.getDocumentPaths$().pipe(de(J=>(this.documentPaths=J,G.documentPaths=J,G)))),fe(G=>c?.documentIds?.length||B?this.getDataFromDocumentIds({documentIds:B?[B]:c?.documentIds?.map(J=>`${Nn(J)}`),organizationId:this.documentPaths?.organizationId,query:c}).pipe(de(J=>({res:G,data:J}))):this.docService.getDocumentIds$().pipe(fe(J=>{let ne=J?.length>0?J.map(ve=>ve.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ne.length>0?ne:[B??""],organizationId:this.documentPaths?.organizationId,query:c}).pipe(de(ve=>({res:G,data:ve})))}))),fe(G=>G?.data?(G.res.annotations=G.data||[],le(G.res).pipe(fe(J=>this.docService.getLocation$().pipe(de(ne=>(J.location=ne,J)))),fe(J=>this.docService.getLocations$().pipe(de(ne=>(J.customLocations=ne,J)))),fe(J=>this.docService.getExcludedLocationIds$().pipe(de(ne=>(J.excludedLocationIds=ne,J)))),de(J=>{if(J.filteredAnnotations=[],c)return J.filteredAnnotations=J.annotations?.slice(),J;if(B&&!I||p)return J.filteredAnnotations=J.annotations?.slice(),J?.excludedLocationIds?.length&&(J.filteredAnnotations=J.filteredAnnotations?.filter(ne=>ne?.location?.id?!J.excludedLocationIds.includes(ne.location.id):!0)),J;{let ne=[],ve=[];return I?(ne.push(I),x&&ve.push(x)):(ne.push(J?.location?.locationId),ne.push(...Object.values(J?.customLocations||[]).map(_e=>_e.locationId)),J?.location?.location?.id&&ve.push(J?.location?.location?.id),ve.push(...Object.values(J?.customLocations||{}).map(_e=>_e.location?.id).filter(_e=>!!_e))),J.filteredAnnotations=this.filterAnnotationsByLocationIds(J?.annotations,ne,ve),J?.excludedLocationIds?.length&&(J.filteredAnnotations=J.filteredAnnotations?.filter(_e=>_e?.location?.id?!J.excludedLocationIds.includes(_e.location.id):!0)),J}}),fe(J=>this.isPrivateCommentAllowed$().pipe(de(ne=>(ne||(J.filteredAnnotations=J.filteredAnnotations?.filter(ve=>ve?.iam?.accessMode!==uo.PRIVATE)),J)))),fe(J=>this.draftCommentAnnotationsByAnnotationId$.pipe(de(ne=>(J.filteredAnnotations=J.filteredAnnotations?.filter(ve=>!ve.isDraft),ne&&J.filteredAnnotations.push(...Object.values(ne)),J)))),fe(J=>r?le(J):J?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(de(()=>J)):le(J)),fe(J=>r?le(J):this.addCommentMode$.pipe(fe(ne=>ne&&!this.getChangeDetectionInCommentMode()?le(J):J?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(de(()=>J)):le(J)))),de(J=>{if(!s){(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(J.filteredAnnotations=J.filteredAnnotations?.map(ve=>{let _e=Object.assign({},ve);return this.calculateCommentAnnotationPosition(_e,a),_e}));let ne={};J.filteredAnnotations?.forEach(ve=>{if(ve?.targetTextRange){let _e=this.domService.getElementFromTargetTextRange(ve?.targetTextRange);ne[ve.annotationId]=!!_e}}),J.textAnnotationsElementMap=ne}return J}),fe(J=>J?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(de(ne=>(this.updateUnreadAnnotationsMap(J?.annotations,ne),J))):le(J)))):le(null))):le(null)),de(z=>{try{return typeof z=="object"&&z?JSON.parse(JSON.stringify(z)):z}catch{return z}}),Ct((z,G)=>Xt(z?.filteredAnnotations,G?.filteredAnnotations)&&Xt(z?.textAnnotationsElementMap,G?.textAnnotationsElementMap)),fe(z=>z?z?.filteredAnnotations?le(z?.filteredAnnotations||[]):le([]):le(null)),fe(z=>f?this.filterCommentsUsingSidebarSettings(z):le(z)))}getAllMultiThreadCommentAnnotations(e,t,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let c,p;try{if(e&&(p=Nn(e)),t&&typeof t=="object"){let g=or(t);c=Nn(JSON.stringify(g))}}catch(g){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",g)}return ei(this.afAuth).pipe(Le(g=>!!g),fe(g=>this.isFeatureAllowed({firebaseUser:g,annotations:[],filteredAnnotations:[]})),fe(g=>g.featureAllowed?this.iamService.isUserAllowed$().pipe(de(f=>(g.featureAllowed=f,g))):le(g)),fe(g=>g.featureAllowed?le(g).pipe(fe(f=>this.docService.getDocumentPaths$().pipe(de(I=>(this.documentPaths=I,f.documentPaths=I,f)))),fe(f=>p?this.getMultiThreadDataFromDocumentIds([p]).pipe(de(I=>({res:f,data:I}))):this.docService.getDocumentIds$().pipe(fe(I=>{let x=I?.length>0?I.map(B=>B.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(x.length>0?x:[`${p}`]).pipe(de(B=>({res:f,data:B})))}))),fe(({res:f,data:I})=>I?(f.annotations=I||[],le(f).pipe(fe(x=>this.docService.getLocation$().pipe(de(B=>(x.location=B,x)))),fe(x=>this.docService.getLocations$().pipe(de(B=>(x.customLocations=B,x)))),fe(x=>this.docService.getExcludedLocationIds$().pipe(de(B=>(x.excludedLocationIds=B,x)))),de(x=>{if(x.filteredAnnotations=[],p&&!c)return x.filteredAnnotations=x.annotations?.slice(),x?.excludedLocationIds?.length&&(x.filteredAnnotations=x.filteredAnnotations?.filter(B=>B?.location?.id?!x.excludedLocationIds.includes(B.location.id):!0)),x;{let B=[],z=[];return c?B.push(c):(B.push(x?.location?.locationId),B.push(...Object.values(x?.customLocations||[]).map(G=>G.locationId)),x?.location?.location?.id&&z.push(x?.location?.location?.id),z.push(...Object.values(x?.customLocations||{}).map(G=>G.location?.id).filter(G=>!!G))),x.filteredAnnotations=this.filterAnnotationsByLocationIds(x?.annotations,B,z),x?.excludedLocationIds?.length&&(x.filteredAnnotations=x.filteredAnnotations?.filter(G=>G?.location?.id?!x.excludedLocationIds.includes(G.location.id):!0)),x}}),fe(x=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(de(B=>(x.filteredAnnotations=x.filteredAnnotations?.filter(z=>!z.isDraft),B&&x.filteredAnnotations.push(...Object.values(B)),x)))),fe(x=>r?le(x):x?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(de(()=>x)):le(x)),fe(x=>r?le(x):this.addCommentMode$.pipe(fe(B=>B&&!this.getChangeDetectionInCommentMode()?le(x):x?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(de(()=>x)):le(x)))),de(x=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(x.filteredAnnotations=x.filteredAnnotations?.map(B=>{let z=Object.assign({},B);return this.calculateCommentAnnotationPosition(z,a),z})),x)),fe(x=>x?.filteredAnnotations?le(x?.filteredAnnotations||[]):le([])))):le(null))):le(null)),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>(this.user=r,D(E({},t),{user:r}))))),fe(t=>ao(t.config,t.user,Ne.COMMENT)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocuments(e){let{documentIds:t,organizationId:r,query:a}=e;if(!this.configService?.getApiKey())return le(null);if(t?.some(I=>!I)||!this.documentPaths)return le(null);let s,c,p=[];if(a)a?.folderId&&(s=Ai(a?.folderId)),a?.locationId&&(p=[...p,a?.locationId]),a?.locationIds?.length&&(p=[...p,...a?.locationIds]),c=a?.statusIds;else{s=this.docService.getDocumentPaths()?.veltFolderId;let I=this.docService.getDocumentPaths()?.locationId;I&&(p=[...p,I])}let g=le([]),f={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(f.documentId=t?.length?t[0]:void 0,f.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let I=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()];this.loggingService.logContext("[CONTEXT] getDataFromDocuments called with docContextFields:",JSON.parse(JSON.stringify(I??"nil")));let x=[];for(let B=0;B<(I?.length??0);B+=U.LISTENER_CONTEXT_BATCH_SIZE)x.push(I?.slice(B,B+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);g=mn(x.map(B=>this.commonDbService.dbListener({feature:"allComments",properties:D(E({},f),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",r??this.documentPaths?.organizationId),lt("metadata.documentId","in",t),...c?.length?[lt("status.id","in",c)]:[],...s?[lt("metadata.veltFolderId","==",s)]:[],...p?.length?[lt("location.id","in",p)]:[],...B?.length?[lt("context.accessFields","array-contains-any",B)]:[]),to("lastUpdated","desc"),to("createdAt","desc")]})}).pipe(Ar()))).pipe(de(B=>ia(JSON.parse(JSON.stringify(B)))))}else{let I=[];for(let x=0;x<(t?.length??0);x+=U.LISTENER_BATCH_SIZE)I.push(t?.slice(x,x+U.LISTENER_BATCH_SIZE)??[]);g=mn(I.map(x=>this.commonDbService.dbListener({feature:"allComments",properties:D(E({},f),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",r??this.documentPaths?.organizationId),lt("metadata.documentId","in",x),...c?.length?[lt("status.id","in",c)]:[],...s?[lt("metadata.veltFolderId","==",s)]:[],...p?.length?[lt("location.id","in",p)]:[]),to("lastUpdated","desc"),to("createdAt","desc")]})}).pipe(Ar()))).pipe(de(x=>ia(JSON.parse(JSON.stringify(x)))))}return g.pipe(fe(I=>I?.data?le(I).pipe(fe(x=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:x,feature:"allComments"}).pipe(de(B=>({data:Object.values(B?.data||{}).filter(z=>typeof z=="object"),operation:B?.operation})))),de(({data:x,operation:B})=>{let z=x.reduce((G,J)=>{let ne=J.metadata?.documentId;return ne&&(G[ne]||(G[ne]=[]),G[ne].push(J)),G},{});return{data:x,documentMap:z,operation:B}}),de(({data:x,documentMap:B,operation:z})=>c?{data:x,documentMap:B,operation:z}:(x?.length&&(x?.forEach(G=>{this.sanitizeCommentAnnotation(G)}),this.setAnnotationIndex(x),this.updateAnnotationsForSelectAllContentMode(x),x.forEach(G=>{this.customFilterService.convertLegacyAnnotationStatus(G),this.customFilterService.convertLegacyPriority(G),this.customFilterService.convertLegacyCategory(G)})),{data:x,documentMap:B,operation:z})),Un(x=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",x),le([]))),Qt(({documentMap:x})=>{c||Object.entries(x??{}).forEach(([B,z])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(z)))})}),de(({data:x,documentMap:B,operation:z})=>({data:this.filterUserDraftComments(x),documentMap:B,operation:z})),de(({data:x,documentMap:B,operation:z})=>({data:this.removeDraftFlags(x),documentMap:B,operation:z})),fe(({data:x,documentMap:B,operation:z})=>c?le({data:x,documentMap:B,operation:z}):this.mergeDraftAnnotations(x).pipe(de(G=>({data:G,documentMap:B,operation:z})))),de(({data:x,documentMap:B,operation:z})=>{if(!c)if(z?.type==="removed"){if(z?.ids?.length){let G=this.commentAnnotationById$.value??{};z?.ids?.forEach(J=>{delete G?.[J]}),this.commentAnnotationById$.next(G)}}else Object.entries(B??{}).length?Object.entries(B??{}).forEach(([J,ne])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:J,annotations:ne})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return x})):le(null)))}fetchCommentAnnotations(e){return Q(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 r=this.configService?.getApiKey(),a=e?.organizationId??t?.clientOrganizationId,s=os(a??""),c=[];e?.allDocuments||(c=e?.documentIds?.map(z=>Dr(z??""))??this.docService.getDocumentIds()?.map(z=>z.documentId));let p=[];if(p.push(lt("metadata.organizationId","==",s)),p.push(lt("metadata.apiKey","==",r)),e?.folderId){let z=Ai(e?.folderId);p.push(lt("metadata.veltFolderId","==",z))}if(e?.locationId&&p.push(lt("location.id","==",e?.locationId)),c?.length&&p.push(lt("metadata.documentId","in",c)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");p.push(lt("resolvedByUserId","==",e?.resolvedBy))}if(e?.mentionedUserIds?.length){if(e?.order==="asc")throw new Error("Order by mentionedUserIds is not supported in ascending order.");p.push(lt("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.");p.push(lt("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.");p.push(lt("status.id","in",e?.statusIds))}let g=new Date().getTime();if(e?.createdAfter&&p.push(lt("createdAt",">=",e?.createdAfter)),e?.createdBefore&&p.push(lt("createdAt","<=",e?.createdBefore??g)),e?.updatedAfter&&p.push(lt("lastUpdated",">=",e?.updatedAfter??g)),e?.updatedBefore&&p.push(lt("lastUpdated","<=",e?.updatedBefore??g)),p.push(to("lastUpdated",e?.order??"desc"),to("createdAt",e?.order??"desc")),e?.pageToken){let z=yield lz(e?.pageToken??"","veltencrypttoken","veltencrypttoken");p.push(Spe(parseInt(z,10),"lastUpdated"))}let f=e?.pageSize??100;p.push(_m(f+1));let I=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:p,apiKey:r??"",organizationId:s}}),x=I.length>f;I=I.slice(0,f);let B=I?.reduce((z,G)=>(z[G?.annotationId]=G,z),{});return B=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:B,shouldAwait:!0}),B=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:B}),{data:Object.values(B??{}),hasMore:x}}catch(t){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",t),t}})}filterUserDraftComments(e){let t=this.authService.getUser();return e.filter(r=>(r.comments=r?.comments?.filter(a=>a?.from?.userId===t?.userId||!a?.isDraft),!!r?.comments?.length))}removeDraftFlags(e){return e.forEach(t=>delete t.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(de(t=>{let r=t||{};return e?.filter(a=>{r?.[a?.annotationId]&&delete r[a?.annotationId]}),r}),de(t=>{if(t){let r=e.slice();return r.push(...Object.values(t)),r}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:t,query:r}){return this.getDataFromDocuments({documentIds:e,organizationId:t,query:r})}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 le(null);let r=this.docService.getDocumentPaths()?.veltFolderId,a=le([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=t?.length?t[0]:void 0,s.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let c=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],p=[];for(let g=0;g<(c?.length??0);g+=U.LISTENER_CONTEXT_BATCH_SIZE)p.push(c?.slice(g,g+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);a=mn(p.map(g=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:D(E({},s),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",this.documentPaths?.organizationId),lt("metadata.documentId","in",t),...r?[lt("metadata.veltFolderId","==",r)]:[],...g?.length?[lt("context.accessFields","array-contains-any",g)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}else{let c=[];for(let p=0;p<(t?.length??0);p+=U.LISTENER_BATCH_SIZE)c.push(t?.slice(p,p+U.LISTENER_BATCH_SIZE)??[]);a=mn(c.map(p=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:D(E({},s),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",this.documentPaths?.organizationId),lt("metadata.documentId","in",p),...r?[lt("metadata.veltFolderId","==",r)]:[])]})}).pipe(Ar()))).pipe(de(p=>ia(p)))}return a.pipe(fe(c=>c?.data?le(c).pipe(de(p=>({data:p?.data,operation:p?.operation})),de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p??{}).filter(I=>typeof I=="object")),{data:f,operation:g}}),Un(p=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",p),le({data:[],operation:null}))),de(({data:p,operation:g})=>{p.forEach(I=>{delete I.isDraft});let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),fe(({data:p,documentMap:g,operation:f})=>{let I=[];return this.commentAnnotationById$.pipe(fe(()=>this.domService.getSelectedAnnotationsMap$().pipe(de(x=>({selectedAnnotationsMap:x})))),de(({selectedAnnotationsMap:x})=>{let B={};return Object.keys(g??{}).forEach(z=>{let G=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:z});G&&G?.forEach(J=>{B[J?.annotationId]=J})}),I=p.filter(z=>{let G=!1;if(z?.commentAnnotations){for(let J in z?.commentAnnotations)if(B?.[J]&&B?.[J]?.status?.id!==this.customFilterService.resolvedStatus.id){G=!0;break}}return G}),I.forEach(z=>{Object.keys(z?.commentAnnotations||{}).forEach(G=>{z.commentAnnotationsMap||(z.commentAnnotationsMap={}),z.commentAnnotationsMap[G]=B?.[G]})}),{data:I,operation:f}}))}),fe(({data:p,operation:g})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(de(f=>{let I=f||{};return p?.filter(x=>{I?.[x?.annotationId]&&delete I[x?.annotationId]}),I}),de(f=>{if(f){let I=p.slice();return I.push(...Object.values(f)),{data:I,operation:g}}return{data:p,operation:g}}))),de(({data:p,operation:g})=>{let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});if(g?.type==="removed"){if(g?.ids?.length){let I=this.multiThreadCommentAnnotationById$.value;g?.ids?.forEach(x=>{delete I?.[x]}),this.multiThreadCommentAnnotationById$.next(I)}}else Object.keys(f??{}).forEach(I=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:f[I]})});return p})):le(null)))}else return le(null)}updateUnreadAnnotationsMap(e,t){try{let r=new Date(U.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(s=>s?.lastUpdated>r);if(t){let s={},c=!1;a.forEach(p=>{let g=0,f=t?.[p?.annotationId];if(f){let I=f?.comments;I&&p?.comments?.forEach(x=>{I?.[x?.commentId]?.views?.[this.user?.userSnippylyId]||g++})}g?g!==s?.[p?.annotationId]&&(s[p?.annotationId]=g,c=!0):s?.[p?.annotationId]&&(delete s[p?.annotationId],c=!0)}),this.unreadCommentsMap$.next(s)}}catch(r){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",r)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(t=>{if(t?.selectAllContent&&t?.targetElementId){let r=ya(t.targetElementId,["id","data-id"]);if(r){let a=r.textContent;a&&(t.targetTextRange={commonAncestorContainer:this.domService.getXPath(r),text:a,occurrence:1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(r)??void 0},delete t?.targetElement)}}})}catch(t){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",t)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.commentAnnotationById$.value??{}),s);this.commentAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),de(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",r),le([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r=null;this.commentAnnotationById$.value&&(r={},Object.values(this.commentAnnotationById$.value).forEach(s=>{s?.metadata?.documentId==t&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)}));let a=this.draftCommentAnnotationsByAnnotationId$.value;return a&&(r===null&&(r={}),Object.values(a).forEach(s=>{s?.metadata?.documentId===t&&s?.metadata?.organizationId===e&&!r[s?.annotationId]&&(r[s?.annotationId]=s)})),r?Object.values(r):null}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getCommentAnnotationsByDocumentId$({clientDocumentId:e,documentId:t}){try{return e&&!t&&(t=this.docService.generateDocumentId(e)),t?this.docService.getDocumentPaths$().pipe(fe(r=>this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:r?.organizationId,documentId:t}))):le(null)}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByDocumentId$:",r),le(null)}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(fe(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):le([])))}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(r=>{r?.annotationId&&(t[r?.annotationId]=r)}),this.originalCommentAnnotationsByDocumentId$.next(E(E({},this.originalCommentAnnotationsByDocumentId$.value),t))}catch(t){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",t)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.multiThreadCommentAnnotationById$.value),s);this.multiThreadCommentAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:t}){return this.multiThreadCommentAnnotationById$.pipe(de(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(s=>{s?.metadata?.documentId==t&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(s=>{s?.metadata?.documentId===t&&s?.metadata?.organizationId===e&&!r[s?.annotationId]&&(r[s?.annotationId]=s)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in CommentService getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getMultiThreadCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(fe(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):le([])))}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(fe(e=>this.docService.getLocations$().pipe(de(t=>({location:e,locations:t})))),de(e=>{let t=[];return t.push(e?.location?.locationId),t.push(...Object.values(e.locations||[]).map(r=>r.locationId)),t||[]}))}filterAnnotationsByLocationIds(e,t,r){try{return e.filter(a=>t.includes(a.locationId)||r?.includes(a?.location?.id)||t?.find(s=>s==a?.location?.id)||r?.find(s=>s==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in CommentService filterAnnotationsByLocations:",a),[]}}setAnnotationIndex(e){try{e.forEach((t,r)=>{t?.annotationId&&(t.annotationIndex=r+1)})}catch(t){this.loggingService.catch("Error in CommentService setAnnotationIndex:",t)}}calculateCommentAnnotationPosition(e,t){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let r=ya(e.targetElementId,["id","data-id"]);if(r&&this.domService.isElementVisible(r)){let a=r.getAttribute(U.ATTRIBUTES.VELT_COMMENT_TYPE),s=!0;if(a)switch(a){case"popover":s=!0;break;default:s=!1;break}else{let c=document.querySelector(`${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${U.TAGS.VELT_INLINE_COMMENTS_SECTION}[${U.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);c&&r?.contains(c)&&(s=!1)}s?e.targetElement={xpath:this.domService.getXPath(r),fXpath:this.domService.getXPath(r,!0),cfXpath:this.domService.getXPath(r,!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 r=e.targetElement?.xpath,a=null,s=e?.targetElement?.anchor;if(s){let p=this.domService.resolveAnchorRecord(s);p?.element&&this.domService.isElementVisible(p.element)&&Pi(p.element)&&(a=p.element)}else r&&(a=this.domService.getElementFromXPath(r),this.domService.isXpathWithId(r)||((!a||!this.domService.isElementVisible(a))&&e.targetElement?.cfXpath&&(r=e.targetElement?.cfXpath,a=this.domService.getElementFromXPath(r)),this.getDetectionStrategy()===Fk.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(r=e.targetElement?.fXpath,r&&(a=this.domService.getElementFromXPath(r)))));(!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 p=this.docService.getLocation();if(!pf({location:p?.location,locationId:p?.locationId},{location:e?.location,locationId:e?.locationId})){let g=this.docService.getAdditionLocationFromElement(a),f=g?this.docService.genarateLocationId(g):void 0;e?.location?.id&&e?.location?.id===g?.id||f&&f===e?.locationId?c=!1:c=!0}}if(c&&(e.ghostComment=null),!c&&a&&Pi(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let g=this.popoverMode$?.value?0:e.targetElement?.topPercentage,f=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:I,width:x}=Hg(a);e.position={top:I*(g||0)/100,left:x*(f||0)/100};let B=window.getComputedStyle(a).transform;if(B&&B!=="none")try{let z=new DOMMatrixReadOnly(B),G=Math.sqrt(z.a*z.a+z.b*z.b)||1,J=Math.sqrt(z.c*z.c+z.d*z.d)||1;(Math.abs(G-1)>.01||Math.abs(J-1)>.01)&&(e.position.parentScaleX=G,e.position.parentScaleY=J)}catch{}if(this.transformContext$.value){let{containerSelector:z,transforms:G}=this.transformContext$.value,J=document.querySelector(z);J&&J.contains(a)&&(e.position.transformContext=G)}}!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(r){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",r)}}addComment(e,t,r,a,s,c=[],p,g,f,I,x,B,z,G,J,ne,ve,_e,Fe,Ve,be,Ie,Ae,Se){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let he=this.authService.getUser();if(he)if(he.isReadOnly||he.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{let Oe=new Zo;ve&&(Oe=E(E({},Oe),ve)),Oe.comments=[],ve?.comments?.length&&(Oe.comments=ve.comments.map(zt=>{let tn=new yd;return tn=E(E({},tn),zt),tn.from=he,tn.lastUpdated=new Date,tn.createdAt=this.timestamp,tn})),Oe.from=he,Oe.color=Oe?.color||U.DEFAULT_ANNOTATION_COLOR,Oe.lastUpdated=this.timestamp,Oe.createdAt=this.timestamp,Oe.sourceId=J,Oe.assignedTo=ve?.assignedTo||ne,Oe.customList=ve?.customList||[],Ie&&(Oe.targetElementId=Ie);let{topPositionX:Re,topPositionY:Zi}=this.domService.getTopLeftPosition();Oe.positionX=Re,Oe.positionY=Zi;let bt=this.domService.getCurrentWindowSizeValue();if(Oe.screenWidth=bt.screenWidth,Oe.screenHeight=bt.screenHeight,Oe.screenScrollHeight=bt.screenScrollHeight,Oe.taggedElementPath="",e&&(Oe.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,zt=>{if(this.getSvgAsImg()){let tn=zt?.closest(`[${U.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);tn&&tn instanceof HTMLElement&&(zt=tn)}if(this.getPopoverMode()){let tn=zt?.closest(`[${U.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(tn&&tn instanceof HTMLElement)return tn}return zt}),this.getCommentToNearestAllowedElement()&&Oe.targetElement?.xpath)){let zt=this.domService.getElementFromXPath(Oe.targetElement.xpath);if(zt&&!this.isElementInsideAllowedElements(zt)){let tn=this.getNearestAllowedElement(zt);if(tn)Oe.targetElement.xpath=this.domService.getXPath(tn),Oe.targetElement.fXpath=this.domService.getXPath(tn,!0),Oe.targetElement.cfXpath=this.domService.getXPath(tn,!0,!0),Oe.targetElement.anchor=this.domService.generateAnchorRecord(tn);else return}}if(t&&(Oe.targetTextRange=t),Oe?.targetElement?.xpath){let zt=this.domService.getXPath(Oe.targetElement.xpath);if(zt){let tn=zt.iterateNext();tn&&(Pi(tn)||(Oe.targetElement=null))}}this.customFilterService.defaultStatus&&!ve?.status&&(Oe.status=this.customFilterService.defaultStatus),Oe.pageInfo=Ni(),Oe.pageInfo&&(Oe.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let It=this.docService.getClientDocumentId(),yt=this.docService.getLocation()?.location;if(Fe&&(Oe.context=Fe&&dc(Fe),Oe.contextId=this.generateContextId(Oe.context)),this.commentContextProvider!==null){let zt=this.commentContextProvider(It,yt);zt&&(Oe.context=zt&&dc(zt),Oe.contextId=this.generateContextId(Oe.context))}if(a){Oe.sourceId=a?.sourceId;let zt=a?.targetElement,tn=a?.commentData;if(zt?.targetText)Oe.targetTextRange={commonAncestorContainer:"/html/body",text:zt.targetText,occurrence:zt?.occurrence||1,commonAncestorContainerAnchor:this.domService.generateAnchorRecord(document.body)??void 0};else if(zt?.elementId)if(Oe.targetElementId=zt.elementId,zt?.selectAllContent)Oe.selectAllContent=!!zt?.selectAllContent;else{let nn=ya(zt.elementId,["id","data-id"]);nn?Oe.targetElement={xpath:this.domService.getXPath(nn),fXpath:this.domService.getXPath(nn,!0),cfXpath:this.domService.getXPath(nn,!0,!0),anchor:this.domService.generateAnchorRecord(nn),topPercentage:50,leftPercentage:90}:Oe.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",anchor:this.domService.generateAnchorRecord(document.body),topPercentage:50,leftPercentage:90}}a?.status&&(Oe.status=a.status),a?.context&&(Oe.context=a.context?dc(a.context):a.context,Oe.contextId=this.generateContextId(Oe.context)),Oe.comments||(Oe.comments=[]);let Ii=this.authService.getUser();tn?.forEach(nn=>{let ti=new yd;ti.commentText=nn.commentText,ti.commentHtml=nn.commentHtml,ti.replaceContentHtml=nn.replaceContentHtml,ti.replaceContentText=nn.replaceContentText,ti.from=Ii,Oe.comments.push(ti)})}if(s&&(Oe.isPageAnnotation=!0),c?.length&&(Oe.comments=c),p&&(Oe.commentType="chart",Oe.metadata=p),f?.sourceId&&(Oe.sourceId=f.sourceId),Oe?.targetElement?.xpath&&!f){let zt=this.domService.getElementFromXPath(Oe.targetElement.xpath);zt&&(f=this.getInlineCommentSectionConfig(zt))}f?.targetInlineCommentElementId&&(Oe.targetInlineCommentElementId=f?.targetInlineCommentElementId,Oe.targetElementId=f.targetInlineCommentElementId,f?.config?.id&&(Oe.inlineCommentSectionConfig=f?.config));let Lt=!Oe?.comments?.length,Yt=!!(a?.openComment===!1||Ve);this.getPrivateCommentMode()&&(Oe?.iam||(Oe.iam=new BI),Oe.iam.accessMode=uo.PRIVATE),I&&(Oe.context=I.context?dc(I.context):I.context,Oe.commentType="manual",delete Oe.targetElement,Oe.contextId=this.generateContextId(Oe.context)),x&&(Oe.targetElementId=x.targetElementId,Oe.targetElement=x.targetElement),this.saveCommentToDb(Oe,r,Lt,Yt,g,B,z,_e,G,be,Ae,Se)}}catch(he){this.loggingService.catch("Error in CommentService addComment: ",he)}}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 r;e.targetElement?r=this.domService.getElementFromTargetElement(e.targetElement):e.targetElementId?r=ya(e.targetElementId,["id","data-id"]):e.targetTextRange&&(r=this.domService.getElementFromTargetTextRange(e.targetTextRange));let a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[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=ya(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,r=!1,a=!1,s,c,p,g,f,I,x,B){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.COMMENT)&&this.docService.getDocumentPaths$().pipe(Le(z=>!!z),rt(1),fe(z=>(this.documentPaths=z,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(G=>!!G),rt(1),fe(G=>Q(this,null,function*(){if(this.documentPaths?.comment){e.annotationId=this.commonDbService.generateDocumentId();let J=this.docService.getClientDocumentId(),ne=this.docService.getLocation()?.location;if(p)e.multiThreadAnnotationId=p;else if(this.getMultiThread()){let Se=mm();e.targetElementId&&(Se=mm(e.targetElementId),e?.location?.id?Se=mm([e?.location?.id,e.targetElementId]):e?.locationId&&(Se=mm([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=Se}let ve={addContext:Se=>{Se.access&&(Se.accessFields=Qk(Se)),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:Se}),e.context=Se&&dc(Se),e.contextId=this.generateContextId(e.context),Se?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&setTimeout(()=>{this.updateCommentAnnotationContext(e.annotationId,Se)},200)},documentId:J,location:ne,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?ve.elementRef={xpath:e.targetElement.xpath}:ve.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(ve),this.commentAdded$.next(ve),f&&f(ve);let _e=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(ve);_e&&this.commentActionsService?.triggerAddCommentAnnotationEvent(_e),this.setLocationToCommentAnnotation(e);let Fe=this.getElementForCommentAnnotation(e),Ve=this.docService.getBaseMetadata("comment",{element:Fe,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!Ve?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=E(E({},e.metadata),Ve),I&&(e.metadata=E(E({},e.metadata),I)),s&&typeof s=="object"&&(e.locationId=g||this.docService.genarateLocationId(s),e.location=s,B||this.docService.addLocation({location:s})),r)window.localStorage.setItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let Se=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);Se&&JSON.parse(Se).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let be=e.comments,Ie=JSON.parse(JSON.stringify(e));if(Ie?.context?.access||(Ie?.context||(Ie.context={}),Ie.context.access={default:"velt"},Ie.context.accessFields=[...Ie.context.accessFields||[],U.DEFAULT_VELT_CONTEXT]),Ie.position=null,t){Ie.targetElement=null,Ie.targetTextRange=null;let Se={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?Ne.MULTI_THREAD:Ne.COMMENT},he=yield this.areaService.generateAreaAnnotationId();Ie.areaAnnotationId=he;let Oe=this.areaService.addArea(void 0,t,Se,he,{locationId:Ie.locationId,location:Ie.location},Ie.context);Oe&&(Ie.metadata=E(E({},Ie.metadata),Oe?.metadata||{}))}!a&&!Ie?.targetInlineCommentElementId&&!Ie?.isPageAnnotation&&this.domService.toggleAnnotationSelection(Ie,c),e.targetTextRange&&sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),Ie?.comments?.length?this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e.annotationId,commentThreadId:Ie?.comments[0]?.commentId,commentType:this.getCommentType(Ie),commentMode:this.getCommentMode(),source:x??"internal"}):this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(Ie),commentMode:this.getCommentMode()});let Ae=this.getAnnotationNumber(e);Ae&&(Ie.annotationNumber=Ae),Ie?.comments?.length?Ie.comments=[]:Ie.isDraft=!0,Ie?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(Ie),Ie?.context&&(Ie.contextId=this.generateContextId(Ie.context)),be?.length?this.saveComment(Ie,{type:Wt.NEWLY_ADDED,updatedComment:be[0]}):this.draftCommentAnnotationsByAnnotationId$.next(D(E({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:Ie}))}})))))).subscribe(()=>{},z=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",z)})}catch(z){this.loggingService.catch("Error in CommentService saveCommentToDb: ",z)}}saveMultiThreadCommentAnnotation(e){return Q(this,null,function*(){try{if(e?.multiThreadAnnotationId){let t=this.docService.getDocumentPaths();if(this.databaseService.getDbValue()&&t?.multiThread){let r={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(s=>s.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,r=E(E({},a),r)),r?.commentAnnotations||(r.commentAnnotations={}),r.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(D(E({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[r.annotationId]:D(E({},r),{isDraft:!0})}));else{let c=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[r.annotationId];if(c&&(r=E(E({},r),c)),delete r.isDraft,r.commentAnnotationsMap={},!r?.metadata?.documentId){r?.metadata||(r.metadata={});let f=this.docService.getBaseMetadata();r.metadata=E(E({},r?.metadata),f)}let{documentId:p,organizationId:g}=r?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:r.annotationId,documentId:p,organizationId:g},data:JSON.parse(JSON.stringify(r)),callback:()=>{let f=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;f[e.annotationId]&&(delete f[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(f))}})}return r}}return null}catch(t){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",t),null}})}setCommentCategory(e){return Q(this,null,function*(){try{if(e?.comments?.length){let t=e.comments[0].commentText?.trim();if(t){let r=yield this.getCommentCategory(t).toPromise();if(r){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let s=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(c=>c.annotationId===e.annotationId);if(s||(s=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:e.annotationId}})),s?.annotationId){let c=s;c.commentCategories=[r];let{documentId:p,organizationId:g}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:p,organizationId:g,metadata:{apiKey:this.configService.getApiKey(),organizationId:g,veltFolderId:c?.metadata?.veltFolderId,documentId:p}},data:JSON.parse(JSON.stringify(c))})}}}}}}catch(t){this.loggingService.catch("Error in CommentService setCommentCategory: ",t)}})}getCommentCategory(e){try{let t=Ji(this.functions,eo({url:wn.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 io(t({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(de(s=>{if(s?.data){let c=s.data,p=c?.length?c[0]?.content?.trim():void 0;return p&&Object.keys(this.customCategoryMap).includes(p)?this.customCategoryMap[p]:void 0}else return}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentCategory: ",t),le(void 0)}}updateCommentAnnotationContext(e,t,r){return Q(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:t,merge:r?.merge});let a=this.authService.getUser(),s=this.docService.getDocumentPaths();if(a&&s?.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:s?.documentId??"",organizationId:s?.organizationId??"",id:e}})),c?.annotationId){let p=t,g=JSON.parse(JSON.stringify(c.context||{}));r?.merge&&(p=E(E({},g),t)),p&&typeof p=="object"&&("access"in t?t.access!==null&&t.access!==void 0?p.accessFields=Qk(p):(delete p.access,delete p.accessFields):(!r?.merge&&g?.access&&(p.access=g.access),p.access!==null&&p.access!==void 0&&(p.accessFields=Qk(p))));let f={context:JSON.parse(JSON.stringify(p||{}))},I=!1;if(f?.context?.commentType==="manual"&&(f.commentType="manual",f.targetElement=null,c?.targetElement&&(c.targetElement=null,I=!0)),c.context=f.context?dc(f.context):f.context,c.contextId=this.generateContextId(c.context),hi(g,p)&&!I)return Promise.resolve("Comment annotation context is already updated.");if(c?.comments?.length){let{documentId:x,organizationId:B}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(c);return this.commonDbService.setData({feature:"comment",properties:{id:e,documentId:x,organizationId:B,metadata:{apiKey:this.configService.getApiKey(),organizationId:B,veltFolderId:c?.metadata?.veltFolderId,documentId:x}},data:JSON.parse(JSON.stringify(c)),callback:()=>{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:f?.context,merge:r?.merge})}})}else return this.draftCommentAnnotationsByAnnotationId$.value?.[e]?(this.draftCommentAnnotationsByAnnotationId$.next(D(E({},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:r?.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:r?.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,r,a,s,c){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.COMMENT)){if(t&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let p=this.domService.getXPath(e.targetElement.xpath);if(p){let g=p.iterateNext();g&&(Pi(g)||(e.targetElement=null))}}if(e?.type==="multiThread"){let p=JSON.parse(JSON.stringify(e));if(p.position=null,p.ghostComment=null,!p?.metadata?.documentId){p?.metadata||(p.metadata={});let I=this.docService.getBaseMetadata();p.metadata=E(E({},p?.metadata),I)}let{documentId:g,organizationId:f}=p?.metadata||{};r?this.commonDbService.updateData({feature:"multiThread",properties:{id:p.annotationId,documentId:g,organizationId:f},data:JSON.parse(JSON.stringify(p))}):this.commonDbService.setData({feature:"multiThread",properties:{id:p.annotationId,documentId:g,organizationId:f},data:JSON.parse(JSON.stringify(p))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let p=JSON.parse(JSON.stringify(e));p.position=null,p.ghostComment=null,p.lastUpdated=this.timestamp,p.status||(p.status=this.customFilterService.defaultStatus),delete p.resolved,delete p.inProgress,this.setLocationFromDocumentParams(p);let g=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(g&&JSON.parse(g).annotationId===p.annotationId&&window.localStorage.removeItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),p?.multiThreadAnnotationId&&!s&&this.saveMultiThreadCommentAnnotation(p).then(f=>{}),p?.comments?.length){if(delete p?.isDraft,p?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[p?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(p),!p?.metadata?.documentId){p?.metadata||(p.metadata={});let B=this.docService.getBaseMetadata();p.metadata=E(E({},p?.metadata),B)}let{documentId:f,organizationId:I}=p?.metadata||{},x=a?E({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;this.viewsService.updateCommentAnnotationViews(p),this.commonDbService.setData({feature:"comment",properties:{id:p.annotationId,documentId:f,targetCommentId:c?.commentId,organizationId:I,metadata:{apiKey:this.configService.getApiKey(),organizationId:I,veltFolderId:p?.metadata?.veltFolderId,documentId:f}},extraData:x,data:JSON.parse(JSON.stringify(p)),callback:B=>{a&&!B?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{}),this.getScreenshotEnabled()&&a?.actionType===Wt.NEWLY_ADDED&&this.captureScreenshot(e)}})}else this.draftCommentAnnotationsByAnnotationId$.next(D(E({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:p}))}}}catch(p){this.loggingService.catch("Error in CommentService updateComment: ",p)}}captureScreenshot(e){return Q(this,null,function*(){try{if(this.getScreenshotEnabled()){let r=Ji(this.functions,eo({url:wn.cloudFunction.screenshot,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a,s={source:"velt",sourceData:{commentAnnotation:e},eventType:"screenshot"};e?.areaAnnotationId&&(a=this.areaService.getAnnotationById(e?.areaAnnotationId),a&&(s.sourceData||(s.sourceData={}),s.sourceData.areaAnnotation=a));let c=yield Dl(s,this.authService.getUser()?.userId??"");yield r({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,r)=>Q(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),s=this.authService.getUser(),c=[];Object.keys(a).forEach(p=>{let g=a[p];["tag","recorder","rewriter","arrow","area","multiThread"].includes(g.type)||s&&g.from&&(s?.isAdmin||g.from.userId===s.userId)&&c.push(g)}),c?.length?(this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:c.map(p=>p.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(La,{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"}}).afterClosed().pipe(rt(1)).subscribe(p=>{try{p?(c.forEach(g=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(g)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(f=>{this.domService.removeHighlightFromElement(f)}),t()},100)):t()}catch(g){r(g)}},p=>{r(p)})):t(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),r(a)}}))}deleteCommentPinAnnotation(e,t){return Q(this,null,function*(){try{if(setTimeout(()=>{if(this.draftCommentAnnotationsByAnnotationId$?.value?.[e.annotationId]){let r=this.draftCommentAnnotationsByAnnotationId$.value;delete r[e.annotationId],this.draftCommentAnnotationsByAnnotationId$.next(r)}},50),this.authService.isFeatureAllowed(Ne.COMMENT))if((t||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Wt.DELETED),e.comments?.forEach(r=>{r.reactionAnnotationIds&&r.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 r=window.localStorage.getItem(U.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);r&&JSON.parse(r).annotationId===e.annotationId&&window.localStorage.removeItem(U.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:s,organizationId:c}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);return e?.isDraft?Promise.resolve():this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:s,organizationId:c,metadata:{apiKey:this.configService.getApiKey(),organizationId:c,veltFolderId:e?.metadata?.veltFolderId,documentId:s}}})}else return Promise.resolve();return Promise.resolve()}catch(r){return this.loggingService.catch("Error in CommentService deleteCommentPinAnnotation: ",r),Promise.resolve()}})}removeCommentAnnotationFromMultiThread(e){return Q(this,null,function*(){try{let t=e?.multiThreadAnnotationId;if(t){let r=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(t);if(!a){let g=e?.metadata?.documentId||r?.documentId,f=e?.metadata?.organizationId||r?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:g,organizationId:f,id:t}})}let s=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t];a&&delete a?.commentAnnotations?.[e.annotationId],s&&(delete s?.commentAnnotations?.[e.annotationId],Object.keys(s?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[t],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:c,organizationId:p}=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:p}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:c,organizationId:p},data:JSON.parse(JSON.stringify(a))})}}catch(t){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",t)}})}getAnnotationById(e,t){try{let r=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in CommentService getAnnotationById: ",r);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 r=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=t||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in CommentService getAnnotationById: ",r);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 r=t?.targetElement?.xpath;if(r)return{xpath:r}}return}catch(t){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",t);return}}scrollToCommentByAnnotationId(e){try{let t=this.getAnnotationById(e),r=document.getElementById(`comment-pin-container-${e}`);r||(r=document.querySelector(`[data-velt-id='${e}']`)),r||(r=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),r&&(r.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 r=e?this.getAnnotationById(e):void 0;r?this.domService.toggleAnnotationSelection(r,void 0,void 0,!0):this.domService.resetSelectedAnnotationsMap()}catch(r){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",r)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(Ne.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([go.ADMIN,go.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:Ne.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:Ne.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()}showCommentIndex(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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,r=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(U.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),t&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||t||r)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1)),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: ",`<${U.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)):(document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(U.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: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${U.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(t){this.loggingService.catch("Error in CommentService setEnableStatus: ",t)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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 r=[...this.bubbleCommentAnnotationIds$.value||[],...e],a=[...new Set(r)];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 r=(this.bubbleCommentAnnotationIds$.value||[]).filter(a=>!e.includes(a));this.bubbleCommentAnnotationIds$.next(r)}catch(t){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",t)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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()}addCommentOnElement(e){this.addComment(void 0,void 0,void 0,e)}enablePrivateCommentMode(){return Q(this,null,function*(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.isPrivateCommentAllowed$().pipe(rt(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:Ne.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()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}enableSidebarShadowDOM(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;"),this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}setExcludeLocationIdsFromSidebar(e){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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()}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:Ne.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:Ne.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()}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,r){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(a=>(!r&&t&&(r=ya(t,["id","data-id"])),le(D(E({},a),{element:r})))),fe(a=>this.getLocations$().pipe(de(s=>D(E({},a),{locationIds:s})))),de(({locationIds:a,element:s})=>{let c=[],p=this.docService.getDocumentPaths();if(p?.documentId){let g=this.docService.getAdditionalDocumentIdFromElement(s),f=g?this.docService.generateDocumentId(g):p?.documentId,I=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:p?.organizationId,documentId:f||""});if(I)for(let x of I)(t&&x?.targetElementId===t||x?.targetElement?.xpath===e)&&a?.includes(x?.locationId)&&c.push(x)}return c.length?c:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),le(null)}}getCommentAnnotationsByContext({context:e,contextOptions:t,element:r,clientDocumentId:a}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$()),de(()=>{let s=null,c=this.docService.getDocumentPaths(),p=dc(e),g=this.generateContextId(p);if(c?.documentId){let f=a||this.docService.getAdditionalDocumentIdFromElement(r??null),I=f?this.docService.generateDocumentId(f):c?.documentId,x=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:c?.organizationId,documentId:I||""});if(x){s=[];for(let B of x)t?.partialMatch?Lk(B?.context,p)&&s.push(B):g&&B?.contextId===g&&s.push(B)}}return s}))}catch(s){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",s),le(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(de(()=>this.getAnnotationById(e)),fe(t=>t?t?.iam?.accessMode===uo.PRIVATE?this.isPrivateCommentAllowed$().pipe(de(r=>{if(r)return t})):le(t):le(t)),fe(t=>t?this.filterCommentsUsingSidebarSettings(t).pipe(de(r=>{if(r)return r})):le(t)))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",t),le(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(de(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let t=document.querySelector(`${U.TAGS.VELT_COMMENT_BUBBLE}[${U.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return t||(t=document.querySelector(`${U.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${U.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(fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,sectionId:e})))),fe(t=>{let r=ya(e,["id","data-id"]);if(r){let a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.genarateLocationId(a);return this.docService.getLocations$().pipe(de(c=>{let g=Object.values(c||{}).find(f=>f.locationId===s||a?.id&&f.location.id===a.id);return D(E({},t),{additionalLocation:g,locationOnElement:!!a})}))}}return le(D(E({},t),{additionalLocation:null,element:r}))}),fe(t=>t?.locationOnElement?le(t):this.docService.getLocation$().pipe(de(r=>D(E({},t),{location:r})))),de(({documentPaths:t,location:r,additionalLocation:a,locationOnElement:s,element:c})=>{let p=null;if(this.authService.getUser()&&t?.documentId){let f=this.docService.getAdditionalDocumentIdFromElement(c),I=f?this.docService.generateDocumentId(f):t?.documentId,x=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:t?.organizationId,documentId:I||""});if(x){p=[];let B=mm(e);s?a?.location?.id?B=mm([a?.location?.id,e]):a?.locationId&&(B=mm([a?.locationId+"",e])):r&&(r?.location?.id?B=mm([r?.location?.id,e]):r?.locationId&&(B=mm([r?.locationId+"",e])));for(let z of x)z?.multiThreadAnnotationId===B?p.push(z):(z?.targetInlineCommentElementId===e||z?.targetElementId===e)&&(s?a&&pf({location:a?.location,locationId:a?.locationId},{location:z.location,locationId:z.locationId})&&p.push(z):r?pf({location:r?.location,locationId:r?.locationId},{location:z.location,locationId:z.locationId})&&p.push(z):z?.locationId||p.push(z))}}return p}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),le(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(fe(()=>this.multiThreadCommentAnnotationById$),fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,multiThreadAnnotationId:e})))),de(({documentPaths:t,location:r,additionalLocation:a,locationOnElement:s})=>{let c=null;if(t?.documentId){let p=this.getMultiThreadAnnotationById(e),{documentId:g,organizationId:f}=p?.metadata||{documentId:t?.documentId,organizationId:t?.organizationId},I=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:f,documentId:g||""});if(I){c=[];for(let x of I)x?.multiThreadAnnotationId===e&&p?.commentAnnotations?.[x?.annotationId]&&c.push(x)}}return c}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",t),le(null)}}getCommentAnnotationsByAnnotationIds(e){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$().pipe(de(t=>({documentPaths:t,annotationIds:e})))),de(({documentPaths:t})=>{let r=null;if(t?.documentId){let a=this.commentAnnotationById$.value?Object.values(this.commentAnnotationById$.value):[],s=this.draftCommentAnnotationsByAnnotationId$.value?Object.values(this.draftCommentAnnotationsByAnnotationId$.value):[];if(a=[...a,...s],a){r=[];for(let c of a)e.includes(c?.annotationId)&&r.push(c)}}return r}))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByAnnotationIds: ",t),le(null)}}getCommentAnnotationsByFolderId({folderId:e,veltFolderId:t}){try{return this.commentAnnotationById$.pipe(fe(()=>this.draftCommentAnnotationsByAnnotationId$),fe(()=>this.docService.getDocumentPaths$()),de(()=>{e&&!t&&(t=Ai(e));let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=null;if(r&&a?.documentId){this.commentAnnotationById$.value&&(s={},Object.values(this.commentAnnotationById$.value).forEach(p=>{p?.metadata?.folderId==e&&p?.metadata?.veltFolderId==t&&(s[p?.annotationId]=p)}));let c=this.draftCommentAnnotationsByAnnotationId$.value;c&&(s===null&&(s={}),Object.values(c).forEach(p=>{p?.metadata?.folderId==e&&p?.metadata?.veltFolderId==t&&!s[p?.annotationId]&&(s[p?.annotationId]=p)}))}return s?Object.values(s):null}))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByFolderId: ",r),le(null)}}getCommentAnnotationsForCommentComponent(e){try{let{annotationId:t,folderId:r,veltFolderId:a,targetElementId:s,clientDocumentId:c,documentId:p,context:g,contextOptions:f,element:I,type:x,sectionId:B,locationId:z}=e||{};if(c&&!p&&(p=this.docService.generateDocumentId(c)),r&&!a&&(a=Ai(r)),t)return this.getCommentAnnotationByAnnotationId(t).pipe(de(J=>J?[J]:null));let G=[];if(s&&(x==="pin"||x==="tool"||x==="bubble")){let J=ya(s,["id","data-id"]);if(J){let ne=J,ve=this.domService.getXPath(J);G.push(this.getCommentAnnotationAvailableOnXPath(ve,s,ne))}}return B&&G.push(this.getCommentAnnotationsBySectionId(B)),g&&G.push(this.getCommentAnnotationsByContext({context:g,contextOptions:f,element:I,clientDocumentId:c})),p&&G.push(this.getCommentAnnotationsByDocumentId$({documentId:p})),r&&G.push(this.getCommentAnnotationsByFolderId({folderId:r,veltFolderId:a})),G.length===0?le(null):mn(G).pipe(de(J=>{let ne=J.filter(_e=>_e!==null&&Array.isArray(_e));if(ne.length===0)return null;if(ne.length===1){let _e=ne[0];return z&&_e?.length?_e.filter(Ve=>Ve?.location?.id===z):_e}let ve=ne[0];for(let _e=1;_e<ne.length;_e++){let Fe=ne[_e];ve=ve.filter(Ve=>Fe.some(Ie=>Ie.annotationId===Ve.annotationId))}return z&&ve?.length&&(ve=ve.filter(_e=>_e?.location?.id===z)),ve}),Ct(Xt))}catch(t){return this.loggingService.catch("Error in CommentService getCommentAnnotationsForCommentComponent: ",t),le(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 r=0;r<t.length;r++){let a=t[r];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,U.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(t){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",t),!1}}saveComment(e,t){return Q(this,null,function*(){try{t?.annotation&&(e=t.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let r=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(r?.comments?.length){let f=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],r.comments?.forEach(I=>{let x=f.find(B=>B.commentId===I.commentId);x?e.comments.push(x):e.comments.push(I)})}e.comments||(e.comments=[]);let a=!1,s=!1,c;switch(t.type){case Wt.NEWLY_ADDED:case Wt.ADDED:if(!t.updatedComment)break;e?.comments?.length||(s=!0),e.comments.push(t.updatedComment);let f=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:t.type,otherFields:{assigned:f}};break;case Wt.APPROVED:e.approved=!0,c={commentAnnotation:e,targetComment:null,actionType:Wt.APPROVED};break;case Wt.ASSIGNED:e.assignedTo=t.assignedTo,c={commentAnnotation:e,targetComment:null,actionType:Wt.ASSIGNED};break;case Wt.UPDATED:if(!t.updatedComment)break;let I=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);if(I>=0){e.comments[I]=t.updatedComment,e.comments[I].status=Wt.UPDATED;let ne=t?.assigned||void 0;c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.UPDATED,otherFields:{assigned:ne}}}break;case Wt.REACTION_ADDED:if(!t.updatedComment)break;let x=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);x>=0&&(e.comments[x]=t.updatedComment,e.comments[x].status=Wt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.REACTION_ADDED});break;case Wt.REACTION_DELETED:if(!t.updatedComment)break;let B=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);B>=0&&(e.comments[B]=t.updatedComment,e.comments[B].status=Wt.UPDATED,c={commentAnnotation:e,targetComment:t.updatedComment,actionType:Wt.REACTION_DELETED});break;case Wt.STATUS_CHANGED:e.status.type==="terminal"&&(this.domService.resetSelectedAnnotationsMap(!1,"comment"),e.resolvedByUserId=this.authService.getUser()?.userId),c={commentAnnotation:e,targetComment:null,actionType:Wt.STATUS_CHANGED,otherFields:{oldStatus:t.oldStatus,newStatus:t.newStatus}};break;case Wt.PRIORITY_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.PRIORITY_CHANGED,otherFields:{oldPriority:t.oldPriority,newPriority:t.newPriority}};break;case Wt.ACCESS_MODE_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:t.oldAccessMode,newAccessMode:t.newAccessMode}};break;case Wt.CUSTOM_LIST_CHANGED:c={commentAnnotation:e,targetComment:null,actionType:Wt.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:t.oldCustomList,newCustomList:t.newCustomList}};break;case Wt.SUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Wt.SUBSCRIBED};break;case Wt.UNSUBSCRIBED:c={commentAnnotation:e,targetComment:null,actionType:Wt.UNSUBSCRIBED};break;case Wt.DELETED:if(!t.updatedComment)break;let z=e.comments.findIndex(ne=>ne.commentId===t.updatedComment.commentId);if(z>=0){if((z===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!t.skipDeleteThreadConfirmation){let _e={};if(this.deleteReplyConfirmation$.value&&(z!==0||this.deleteThreadWithFirstComment$.value===!1)?_e={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply"}:_e={title:"Delete thread?",message:"All replies to this thread will be lost.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"comment"},!(yield this.dialog.open(La,{panelClass:["velt-confirm-dialog-overlay-pane","velt-mat-dialog-container"],data:_e}).afterClosed().toPromise()))return}let ne=e.comments.splice(z,1),ve=e.metadata;ne?.length&&ne.forEach(_e=>{_e?.attachments&&_e.attachments.forEach(Fe=>{let Ve={attachmentId:Fe.attachmentId,organizationId:ve?.organizationId??null,documentId:ve?.documentId??null,folderId:ve?.folderId??null,commentAnnotationId:e.annotationId,apiKey:ve?.apiKey??null};this.deleteAttachment({attachment:Fe,metadata:Ve})}),_e?.reactionAnnotationIds&&_e.reactionAnnotationIds.forEach(Fe=>{this.deleteReaction(Fe)})})}e.status=this.customFilterService.defaultStatus,z===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:Wt.DELETED});break;case Wt.ACCEPTED:let G={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Wt.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(G),c={commentAnnotation:e,targetComment:null,actionType:Wt.ACCEPTED};break;case Wt.REJECTED:let J={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Wt.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(J),this.domService.resetSelectedAnnotationsMap(),c={commentAnnotation:e,targetComment:null,actionType:Wt.REJECTED};break;default:break}if(e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null),t?.updatedComment?.isDraft&&(c=void 0),a)this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment");else{if(s&&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===Wt.ADDED||t.type===Wt.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e])}let p=this.getCustomPinById(e.annotationId),g={type:t.type,annotation:this.getCommentAnnotationForClient(e),targetAnnotationId:e.annotationId,targetCommentId:t.updatedComment?.commentId,updateContext:(f,I)=>{this.updateCommentAnnotationContext(e.annotationId,f,I)}};p!==void 0&&(g.element=p),delete g?.annotation?.pageInfo,delete g?.annotation?.targetElement,delete g?.annotation?.targetTextRange,g?.type===Wt.DELETED&&(e.comments?.length||(g.annotation=null)),a||this.commentUpdated$.next(g)}catch(r){this.loggingService.catch("Error in CommentService saveComment: ",r)}})}attachComment(e,t=[],r,a,s,c,p,g){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let f;if(e){let I=ya(e,t);I&&(f={targetElement:{xpath:this.domService.getXPath(I),topPercentage:50,leftPercentage:90},targetElementId:e})}(f||r||s)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,c,void 0,void 0,f,g,void 0,void 0,a,void 0,void 0,void 0,r,void 0,s,void 0,void 0,p)}catch(f){this.loggingService.catch("Error in CommentService attachComment: ",f)}}generateComponentIdFromObject(e){try{let t=dc(e||{});return Tt(JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CommentService generateComponentIdFromObject: ",t);return}}updateNotificationsDatabase(e,t,r,a={}){try{let s=E({annotationData:e,targetAnnotationData:t,actionType:r,notificationSource:"comment"},a);this.notificationService.updateNotificationDatabase(s)}catch(s){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",s)}}getUserContacts$(){return this.contactService.getUserContacts$()}addUserContact(e){this.contactService.addUserContact(e)}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 r=!1,a=e?.targetElement?.anchor;if(!t&&a){let s=this.domService.resolveAnchorRecord(a);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(t=s.element)}!t&&e?.targetElement?.xpath&&(r=this.domService.isXpathWithId(e?.targetElement?.xpath),t=this.domService.getElementFromXPath(e?.targetElement?.xpath),t&&!this.domService.isElementVisible(t)&&(t=null)),r||(!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&&!Pi(t)&&(t=null),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),null}}getElementFromComments(e){try{let t=[],r=null;if(e?.ghostComment)!r&&e.ghostComment?.targetElement?.fXpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e.ghostComment?.targetElement?.cfXpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e.ghostComment?.targetElement?.xpath&&(r=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),r&&!this.domService.isElementVisible(r)&&(r=null));else{let a=!1,s=e?.targetElement?.anchor;if(!r&&s){let c=this.domService.resolveAnchorRecord(s);c?.element&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(r=c.element)}!r&&e?.targetElement?.xpath&&(a=this.domService.isXpathWithId(e?.targetElement?.xpath),r=this.domService.getElementFromXPath(e?.targetElement?.xpath),r&&!this.domService.isElementVisible(r)&&(r=null)),a||(!r&&e?.targetElement?.cfXpath&&(r=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),r&&!this.domService.isElementVisible(r)&&(r=null)),!r&&e?.targetElement?.fXpath&&(r=this.domService.getElementFromXPath(e?.targetElement?.fXpath),r&&!this.domService.isElementVisible(r)&&(r=null)))}return r&&!Pi(r)&&(r=null),e?.targetElementId&&(t=Array.from(rce(e.targetElementId,["id","data-id"]))),r&&!t.includes(r)&&t.push(r),t}catch(t){return this.loggingService.catch("Error in CommentService getElementFromComment: ",t),[]}}getGhostCommentTargetElement(e){try{let t=e.targetElement?.fXpath||e.targetElement?.xpath,r=null;if(t)for(;!r&&t;)r=this.domService.getElementFromXPath(t),r&&(!this.domService.isElementVisible(r)||!Pi(r))&&(r=null),r||(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=Tl.ELEMENT_DELETED;let t=e?.pageInfo?.deviceInfo?.deviceType,r=new Yn().getDeviceType();t&&t!==r&&(e.ghostComment.type=Tl.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${t}.`,[mr.MOBILE,mr.TABLET].includes(t)&&[mr.MOBILE,mr.TABLET].includes(r)||[mr.DESKTOP,mr.MONITOR].includes(t)&&[mr.DESKTOP,mr.MONITOR].includes(r)?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||{},r=t[e?.annotationId]||{};hi(e.ghostComment,r)||(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(Ct(Xt))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>t?{count:t[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(de(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(de(e=>e?{count:Object.values(e).reduce((r,a)=>r+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>{if(t){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),a&&Object.keys(t).forEach(c=>{a?.find(g=>g.annotationId===c)?.location?.id===e&&(s+=t[c])})),{count:s}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(de(t=>{if(t){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),Object.keys(t).forEach(c=>{t[c]&&a?.find(g=>g.annotationId===c)?.location?.id===e&&(s+=1)})),{count:s}}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;if(t){for(let r of e)if(t?.id!==r?.status?.id){let a=JSON.parse(JSON.stringify(r||{}));r.status=this.customFilterService.resolvedStatus;let s={annotation:r,type:Wt.STATUS_CHANGED,oldStatus:a.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(r,s)}}}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:Ne.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:Ne.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 Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addManualComment","color: green;"),new Promise((t,r)=>{let a=this.domService.getLastDocumentClick()?.target,s=e?.location||this.docService.getAdditionLocationFromElement(a);if(s?.id){let c=this.docService.getLocationByClientLocationId(s.id);c&&(s=c)}this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,s,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=Ni(),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 r=`${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/${t.annotationId}`;this.documentPaths?.organizationId&&(r=`${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${U.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:r,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(U.URL_PARAMS.COMMENT_ID),t.searchParams.append(U.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(Ne.COMMENT)){let t=this.domService.getRange();if(window.getSelection()?.toString()&&!Kk()&&t?.commonAncestorContainer&&this.isElementInsideAllowedElements(t.commonAncestorContainer)&&!Ip(t.commonAncestorContainer)){let r=t?this.domService.getTargetTextRangeFromSelectionRange(t):void 0;this.domService.clearTextSelection(),setTimeout(()=>{this.addComment(void 0,r)},100)}}}catch(e){this.loggingService.catch("Error in CommentService addCommentOnSelectedText: ",e)}}getInlineCommentSectionConfig(e){try{let t;if(e){let r=e?.closest(`[${U.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(r){let a=r.getAttribute(U.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(t={},t.targetInlineCommentElementId=a,r.getAttribute(U.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(t.config=JSON.parse(r.getAttribute(U.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={},r=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(s=>{let c=e.subscribedUsers?.[s];c?.type==="manual"&&(t[s]=c)}),e?.assignedTo?.userId){let s=Tt(e?.assignedTo?.userId);r[s]||t[s]?.type!=="manual"&&(t[s]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(s=>!s?.isDraft)?.forEach(s=>{if(s?.from?.userId){let c=Tt(s?.from?.userId);r[c]||t[c]?.type!=="manual"&&(t[c]={user:s?.from,type:"auto"})}s?.to?.forEach(c=>{if(c?.userId){let p=Tt(c.userId);r[p]||t[p]?.type!=="manual"&&(t[p]={user:c,type:"auto"})}}),s?.toOrganizationUserGroup?.forEach(c=>{if(c?.groupId)a[c?.groupId]={type:"auto"};else if(c?.clientGroupId){let p=Tt(c.clientGroupId);a[p]={type:"auto"}}})}),e.subscribedUsers=t,e.unsubscribedUsers=r,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(fe(()=>{let{annotationId:t,documentId:r}=e;if(r){let a=Nn(r).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(de(s=>s.find(p=>p.annotationId===t)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let s=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(s){let c=s.find(p=>p.annotationId===t);return le(c||null)}}}return le(null)}),Un(t=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",t),le(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(de(t=>t?.data),de(t=>{let r=[];return t&&(r=Object.values(t??{}).filter(a=>typeof a=="object")),r})):le([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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,r,a,s){try{this.sidebarCustomActionEventData$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s})}catch(c){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",c)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,t){try{this.sidebarData$.next({data:e,options:t})}catch(r){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",r)}}getSidebarCustomData(){return this.sidebarData$.asObservable()}setSidebarCustomActionEventDataAllChanges(e,t,r,a,s){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s});let c=yield this.metadataService.getGlobalMetadata(),p={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:r,commentAnnotations:t,systemFilteredAnnotations:a,metadata:c,customFilters:s};this.commentActionsService?.triggerAction(zi.COMMENT_SIDEBAR_DATA_UPDATE,p)}catch(c){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",c)}})}setSidebarCustomActionEventDataOnInit(e,t,r,a,s){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:t,unreadDataMap:r,systemFilteredData:a,customFilters:s});let p={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:r,commentAnnotations:t,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()},customFilters:s};this.commentActionsService?.triggerAction(zi.COMMENT_SIDEBAR_DATA_INIT,p)}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?hi(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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:r}=e||{},a=null;t&&(a={},t.forEach(c=>{c?.annotationId&&a&&(a[c.annotationId]=c)}));let s={};t===void 0?s.data=this.commentsFromSidebarMap$.value?.data:s.data=a,r===void 0?s.sidebarVisible=this.commentsFromSidebarMap$.value?.sidebarVisible:s.sidebarVisible=r,hi(this.commentsFromSidebarMap$.value,s)||this.commentsFromSidebarMap$.next(s)}catch(t){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",t)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}setSidebarButtonCountType(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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),r;return t?r=e||[]:e?r=[e]:r=[],this.getFilterCommentsOnDom$().pipe(fe(a=>a?r.length===0?le(e):this.getCommentsFromSidebarMap$().pipe(de(s=>{if(!s?.sidebarVisible)return e;let c=r.filter(p=>p?.isDraft||!!s?.data?.[p?.annotationId]);return t?c:c.length>0?c[0]:null})):le(e)))}catch{return le(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:Ne.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:Ne.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:Ne.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:Ne.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 Q(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,r=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():r.forEach(s=>{a[e.userId]?.documents?.[s]?.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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||Ne.COMMENT,config:e})}catch(r){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",r)}}generateContextId(e){try{let t;if(e&&typeof e=="object"){let r=JSON.parse(JSON.stringify(e));if(delete r.accessFields,delete r.access,Object.keys(r).length){let a=dc(r),s=JSON.stringify(a);t=Tt(s)}}return t}catch{return}}setMaxReplyAvatars(e){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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}enableScreenshot(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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||{},r=-1,a=Object.values(t).filter(s=>{let c=s.metadata?.documentId===e.metadata?.documentId;return c&&s.annotationNumber&&(r=Math.max(r,s.annotationNumber)),c});return r===-1?a.length+1:r+1}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationNumber: ",t),null}}enableFullScreenInSidebar(){try{if(this.analyticsService.setFeatureConfig({feature:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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 Q(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 Q(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:Ne.COMMENT,config:{autoCompleteScrollConfig:e}});let t=this.autoCompleteScrollConfig$.value,r={itemSize:e.itemSize??t.itemSize,minBufferPx:e.minBufferPx??t.minBufferPx,maxBufferPx:e.maxBufferPx??t.maxBufferPx,templateCacheSize:e.templateCacheSize??t.templateCacheSize};this.autoCompleteScrollConfig$.next(r)}catch(t){this.loggingService.catch("Error in CommentService setAutoCompleteScrollConfig: ",t)}}getAutoCompleteScrollConfig(){return this.autoCompleteScrollConfig$.value}getAutoCompleteScrollConfig$(){return this.autoCompleteScrollConfig$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Id),ee(un),ee(Ft),ee(ot),ee(In),ee(je),ee(Be),ee(Ri),ee(ym),ee(Si),ee(su),ee(Do),ee(po),ee(En),ee(_),ee(hn),ee(Wo),ee(ur),ee(nge),ee(bn),ee(Ps),ee(WC),ee(ol),ee(Im),ee(ru),ee(ss),ee(Wi))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var S=(()=>{let _DynamicDataService=class _DynamicDataService{constructor(i,o,n,e,t,r){this.authService=i,this.commentService=o,this.loggingService=n,this.injector=e,this.docService=t,this.configService=r,this.subscriptions=[],this.commonData$=new Ce({}),this.evaluateConditionTriggered=new Me,this.conditionRegex=/\{(.*?)\}/g,this.extractedProps={},this.condition="",this.dataComponentConfigSignal=xe({});try{this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{user:a}))})),this.subscriptions.push(this.commentService.getUnreadCommentAnnotationCountOnCurrentDocument$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{unreadCommentAnnotationCount:a?.count||0}))})),this.subscriptions.push(this.commentService.getUnreadCommentCountOnCurrentDocument$().subscribe(a=>{this.commonData$.next(D(E({},this.commonData$.value),{unreadCommentCount:a?.count||0}))})),this.subscriptions.push(this.docService.getUIState$().subscribe(a=>{this.commonData$.next(E(E({},this.commonData$.value),a))})),this.subscriptions.push(this.getCommonData().subscribe(a=>{this.dataComponentConfigSignal.update(s=>(s=E(E({},s),a),s)),this.executeConditionalClasses()})),this.subscriptions.push(this.evaluateConditionTriggered.subscribe(a=>{this.extractedProps=a.extractedProps,this.evaluateCondition(a.className,a.elementRef,a.condition)}))}catch(a){this.loggingService.catch("Error in DynamicDataService constructor: ",a)}}ngOnDestroy(){try{this.subscriptions.forEach(i=>i.unsubscribe())}catch(i){this.loggingService.catch("Error in DynamicDataService ngOnDestroy: ",i)}}getCommonData(){return this.commonData$.asObservable()}getModifiedPathBasedOnCondition(i,o){try{return Object.keys(o).forEach(n=>{o[n].path=this.modifyPathBasedOnCondition(n,i)}),o}catch(n){this.loggingService.catch("Error in DynamicDataService getModifiedPathBasedOnCondition: ",n)}}getComputedValues(i,o,n,e,t,r){try{Object.keys(n).forEach(a=>{let s;if(Vi(i)?s=ki(()=>Na(i(),n[a].path)):s=ki(()=>Na(i,n[a].path)),Vi(s()))lo(()=>{try{let c=s()();n[a].value=c,this.evaluateConditionTriggered.emit({extractedProps:n,className:e,elementRef:t,condition:r})}catch{}},{injector:this.injector,allowSignalWrites:!0});else{let c=s();n[a].value=c,this.evaluateConditionTriggered.emit({extractedProps:n,className:e,elementRef:t,condition:r})}})}catch(a){this.loggingService.catch("Error in DynamicDataService getComputedValues: ",a)}}modifyPathBasedOnCondition(i,o){try{let n=i;if(i.startsWith("userContact."))n=i.replace("userContact","selectorItem.contact");else if(i.startsWith("comment."))n=i.replace("comment","commentObj");else if(i.startsWith("commentAnnotation."))n=i.replace("commentAnnotation","componentConfigSignal.annotation");else if(i.startsWith("commentAnnotations."))n=i.replace("commentAnnotations","componentConfigSignal.annotations");else{let e=i.match(/^([^.\[]+)/),t=e?e[1]:"";if(t&&o&&typeof o=="function"&&o()&&t in o()){let r=i.match(/\[(.*?)\]/);if(r&&r[1]){let a=r[1];if(a.includes(".")){let s=a.split(".")[0];s&&o()&&s in o()?n=i:n=i.replace(`[${a}]`,`[componentConfigSignal.${a}]`)}else n=i}else n=i}else n="componentConfigSignal."+i}return n}catch(n){return this.loggingService.catch("Error in DynamicDataService modifyPathBasedOnCondition: ",n),i}}applyConditionalClasses(i,o){try{this.elementRef=i,this.data=o}catch(n){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",n)}}executeConditionalClasses(){try{let i=this.getHostElementAttributes(this.elementRef),n=[...Object.keys(i).filter(e=>e.startsWith("velt-class-")).map(e=>({name:e,value:i[e]}))];if(i["velt-class"]){let e=i["velt-class"],t=/'([^']+)':\s*([^,]+)(?:,|$)/g,r=[],a=0,s=100,c;for(;(c=t.exec(e))!==null;){if(a++>s){this.loggingService.catch("Too many class definitions detected.");break}if(c.length<3)continue;let[,p,g]=c;!p||!g||p.split(" ").forEach(f=>{f.trim()&&r.push({name:`velt-class-${f.trim()}`,value:g.trim()})})}n=[...n,...r]}this.data&&typeof this.data=="object"&&Object.keys(this.data).forEach(e=>{this.updateDataComponentConfigSignal(e,this.data[e])}),n.forEach(e=>{let t=e.name.replace("velt-class-","");this.condition=e.value,this.condition&&(this.extractProps(),this.extractedProps=this.getModifiedPathBasedOnCondition(this.dataComponentConfigSignal,this.extractedProps),this.getComputedValues(this.dataComponentConfigSignal,this.evaluateCondition,this.extractedProps,t,this.elementRef,e.value))})}catch(i){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",i)}}updateDataComponentConfigSignal(i,o){try{i==="dataComponentConfigSignal"?this.dataComponentConfigSignal.set(o):this.dataComponentConfigSignal.update(n=>D(E({},n),{[i]:o}))}catch(n){this.loggingService.catch("Error in DataComponent updateDataComponentConfigSignal: ",n)}}extractProps(){try{this.extractedProps={},this.conditionRegex.lastIndex=0;let i;for(;(i=this.conditionRegex.exec(this.condition))!==null;){let o=i[1];this.extractedProps[o]={value:null,path:null,isDynamicPath:this.hasDynamicParts(o)}}}catch(i){this.loggingService.catch("Error in DynamicDataService extractProps: ",i)}}hasDynamicParts(i){try{let o=/\[[^\]'"]*[^\]'"]\]/.test(i),n=/\[[^[\]]*[\.\[][^[\]]*\]/.test(i);return o||n}catch(o){return this.loggingService.catch("Error checking for dynamic path: ",o),!1}}evaluateCondition(i,o,n){try{if(n){let e=this.extractedProps,t=n.replace(this.conditionRegex,(s,c)=>{let p=e[c];if(p&&p.value!==void 0){let g=p.value;return typeof g=="string"?`'${g}'`:typeof g=="boolean"||typeof g=="number"?String(g):g===null?"null":typeof g=="object"?g?"true":"false":String(g)}return"false"}),r=this.sanitizeCondition(t),a=this.safeEval(r);return i&&o&&(a?this.setHostElementClasses(o,i):this.removeHostElementClasses(o,i)),a}return!1}catch(e){return this.loggingService.catch("Error in IfComponent evaluateCondition: ",e),!1}}sanitizeCondition(i){try{return i.replace(/[^a-zA-Z0-9\s\+\-\*\/\%\(\)\!\=\<\>\|\&\.\[\]\{\},'"]/g,"")}catch(o){return this.loggingService.catch("Error in IfComponent sanitizeCondition: ",o),""}}safeEval(expression){try{if(this.configService.getSafeEval()){let i=this.tokenize(expression.trim());return this.evaluateTokens(i)}else return eval(expression)}catch(i){return this.loggingService.catch("safeEval error",i),!1}}tokenize(i){try{if(!i||i.trim()==="")return[];let o=[],n=0;for(;n<i.length;){let e=i[n];if(/\s/.test(e)){n++;continue}if(e==='"'||e==="'"){let t=e,r="";for(n++;n<i.length;)if(i[n]==="\\"&&n+1<i.length)r+=i[n+1],n+=2;else if(i[n]===t){n++;break}else r+=i[n],n++;o.push({type:"string",value:r});continue}if(e==="("){o.push({type:"lparen",value:"("}),n++;continue}if(e===")"){o.push({type:"rparen",value:")"}),n++;continue}if(n<i.length-2&&i.substring(n,n+3)==="==="){o.push({type:"operator",value:"===",precedence:4}),n+=3;continue}if(n<i.length-2&&i.substring(n,n+3)==="!=="){o.push({type:"operator",value:"!==",precedence:4}),n+=3;continue}if(n<i.length-1&&i.substring(n,n+2)==="&&"){o.push({type:"operator",value:"&&",precedence:2}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="||"){o.push({type:"operator",value:"||",precedence:1}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="<="){o.push({type:"operator",value:"<=",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)===">="){o.push({type:"operator",value:">=",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="=="){o.push({type:"operator",value:"==",precedence:4}),n+=2;continue}if(n<i.length-1&&i.substring(n,n+2)==="!="){o.push({type:"operator",value:"!=",precedence:4}),n+=2;continue}if(e==="!"){o.push({type:"unary",value:"!",precedence:5}),n++;continue}if(e==="<"){o.push({type:"operator",value:"<",precedence:4}),n++;continue}if(e===">"){o.push({type:"operator",value:">",precedence:4}),n++;continue}if(/[a-zA-Z0-9._]/.test(e)){let t="";for(;n<i.length&&/[a-zA-Z0-9._]/.test(i[n]);)t+=i[n],n++;/^-?\d+(\.\d+)?$/.test(t)?o.push({type:"number",value:parseFloat(t)}):t==="true"||t==="false"?o.push({type:"boolean",value:t==="true"}):t==="null"?o.push({type:"null",value:null}):t==="undefined"?o.push({type:"undefined",value:void 0}):o.push({type:"identifier",value:t});continue}n++}return o}catch(o){return this.loggingService.catch("tokenize error",o),[]}}evaluateTokens(i){try{if(!i||i.length===0)return!1;let o=this.infixToPostfix(i);return this.evaluatePostfix(o)}catch(o){return this.loggingService.catch("evaluateTokens error",o),!1}}infixToPostfix(i){try{let o=[],n=[];for(let e of i)if(e.type==="string"||e.type==="number"||e.type==="boolean"||e.type==="null"||e.type==="undefined"||e.type==="identifier")o.push(e);else if(e.type==="unary")n.push(e);else if(e.type==="operator"){for(;n.length>0;){let t=n[n.length-1];if(t.type==="lparen"||t.precedence!==void 0&&t.precedence<e.precedence)break;o.push(n.pop())}n.push(e)}else if(e.type==="lparen")n.push(e);else if(e.type==="rparen"){for(;n.length>0&&n[n.length-1].type!=="lparen";)o.push(n.pop());n.length>0&&n.pop()}for(;n.length>0;){let e=n.pop();e.type!=="lparen"&&e.type!=="rparen"&&o.push(e)}return o}catch(o){return this.loggingService.catch("infixToPostfix error",o),[]}}evaluatePostfix(i){try{let o=[];for(let n of i)if(n.type==="string"||n.type==="number"||n.type==="boolean"||n.type==="null"||n.type==="undefined"||n.type==="identifier")o.push(n.value);else if(n.type==="unary"){if(o.length>=1){let e=o.pop();n.value==="!"&&o.push(!this.isTruthy(e))}}else if(n.type==="operator"&&o.length>=2){let e=o.pop(),t=o.pop();n.value==="&&"?o.push(this.isTruthy(t)&&this.isTruthy(e)):n.value==="||"?o.push(this.isTruthy(t)||this.isTruthy(e)):o.push(this.compare(t,e,n.value))}return o.length===1?this.isTruthy(o[0]):!1}catch(o){return this.loggingService.catch("evaluatePostfix error",o),!1}}parseValue(i){try{let o=i.trim();return o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")?o.substring(1,o.length-1):/^-?\d+(\.\d+)?$/.test(o)?parseFloat(o):o==="true"?!0:o==="false"?!1:o==="null"?null:o==="undefined"?void 0:o}catch(o){return this.loggingService.catch("parseValue error",o),i}}compare(i,o,n){try{switch(n){case"===":return i===o;case"!==":return i!==o;case"==":return i==o;case"!=":return i!=o;case"<":return i<o;case">":return i>o;case"<=":return i<=o;case">=":return i>=o;default:return!1}}catch(e){return this.loggingService.catch("compare error",e),!1}}isTruthy(i){try{return i==null||i===""||i==="false"?!1:i==="true"?!0:typeof i=="number"?i!==0:!!i}catch(o){return this.loggingService.catch("isTruthy error",o),!1}}getHostElementAttributes(i){try{let o=i,n={};for(let e of o.attributes)n[e.name]=e.value;return n}catch{return{}}}setHostElementClasses(i,o){try{i.classList.add(o)}catch{}}removeHostElementClasses(i,o){try{i.classList.remove(o)}catch{}}};_DynamicDataService.\u0275fac=function(o){return new(o||_DynamicDataService)(ee(je),ee(we),ee(_),ee(St),ee(ot),ee(Ft))},_DynamicDataService.\u0275prov=Pe({token:_DynamicDataService,factory:_DynamicDataService.\u0275fac,providedIn:"root"});let DynamicDataService=_DynamicDataService;return DynamicDataService})();var H=(()=>{let o=class o{set veltIf(e){try{e&&this.setIfCondition(e)}catch(t){this._loggingService.catch("Error in BaseComponent set veltIf:",t)}}constructor(e,t,r){this._elementRef=e,this._dynamicDataService=t,this._loggingService=r,this.componentConfigSignal=xe({}),this.veltElement=!0,this.conditionSignal=xe(null)}initializeComponentConfigSignal(e){try{this.componentConfigSignal.set(e)}catch(t){this._loggingService.catch("Error in BaseComponent initializeComponentConfigSignal:",t)}}ngOnInit(){try{this._dynamicDataService.applyConditionalClasses(this._elementRef?.nativeElement,{componentConfigSignal:this.componentConfigSignal})}catch(e){this._loggingService.catch("Error in BaseComponent ngOnInit:",e)}}ngOnDestroy(){}setIfCondition(e){try{this.conditionSignal.set(e)}catch(t){this._loggingService.catch("Error in BaseComponent setIfCondition:",t)}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(S),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-base"]],hostVars:1,hostBindings:function(t,r){t&2&&T("data-velt-element",r.veltElement)},inputs:{componentConfigSignal:"componentConfigSignal",template:"template",wireframe:"wireframe",veltIf:"veltIf"},standalone:!1,decls:0,vars:0,template:function(t,r){},encapsulation:2});let i=o;return i})();var nt=(()=>{let o=class o extends H{onDarkModeChange(){return this.darkModeSubject$.asObservable()}constructor(e,t,r,a,s,c,p){super(e,c,p),this._elementRef=e,this._themeService=t,this._changeDetector=r,this._featureService=a,this._componentDarkModeObservable=s,this._componentDarkMode=null,this._globalDarkMode=!1,this._featureDarkMode=!1,this._themeSubscriptions=[],this._darkMode=!1,this.darkMode=!1,this.darkModeSubject$=new Ce(!1);try{this._themeSubscriptions.push(this._themeService.getDarkMode$().subscribe(g=>{this._globalDarkMode=g,this.setDarkMode()})),this._featureService&&(this._featureService instanceof we?this._themeSubscriptions.push(this._featureService.getCommentContainerDarkMode().subscribe(g=>{this._featureDarkMode=g,this.setDarkMode()})):this._featureService instanceof ur&&this._themeSubscriptions.push(this._featureService.getDarkMode$().subscribe(g=>{g!==null&&(this._featureDarkMode=g),this.setDarkMode()}))),this._componentDarkModeObservable&&this._componentDarkModeObservable instanceof $t&&this._themeSubscriptions.push(this._componentDarkModeObservable.subscribe(g=>{this._componentDarkMode=g,this.setDarkMode()}))}catch{}}ngOnInit(){super.ngOnInit()}ngOnChanges(e){try{if(e._darkMode){let t=e._darkMode.currentValue;typeof t=="string"&&(t=t==="true"),this._componentDarkMode=t,this.setDarkMode()}}catch{}}setComponentDarkMode(e){try{this._componentDarkMode=e,this.setDarkMode()}catch{}}setDarkMode(){try{this._componentDarkMode===null?this._featureDarkMode?this.darkMode=!0:this.darkMode=!!this._globalDarkMode:this.darkMode=!!this._componentDarkMode,this.darkMode?this._elementRef.nativeElement.hasAttribute("dark")||this._elementRef.nativeElement.setAttribute("dark",""):this._elementRef.nativeElement.hasAttribute("dark")&&this._elementRef.nativeElement.removeAttribute("dark"),this.darkModeSubject$.next(this.darkMode),this._changeDetector&&this._changeDetector.markForCheck()}catch{}}ngOnDestroy(){try{super.ngOnDestroy(),this._themeSubscriptions.forEach(e=>{e.unsubscribe()})}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Ke),h(an),h("FeatureService",8),h($t),h(S),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-themed"]],inputs:{_darkMode:[0,"darkMode","_darkMode"]},standalone:!1,features:[L,Xe],decls:0,vars:0,template:function(t,r){},encapsulation:2,changeDetection:0});let i=o;return i})();var Ge=(()=>{let o=class o{constructor(e){this.loggingService=e,this.wireframeMap=new Ce(new Map);try{this.loggingService.log("%c[WB] Creating CLASS: WireframeService","color: blue;")}catch(t){this.loggingService.catch("Error in WireframeService constructor: ",t)}}setWireframe(e,t){try{let r=this.wireframeMap.value;r.set(e,t),this.wireframeMap.next(r)}catch(r){this.loggingService.catch("Error in WireframeService setWireframe: ",r)}}setWireframeMap(e){try{let t=this.wireframeMap.value;e.forEach((r,a)=>{t.set(a,r)}),this.wireframeMap.next(t)}catch(t){this.loggingService.catch("Error in WireframeService setWireframeMap: ",t)}}getWireframe(e,t=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&t){let s=e?.split("---")[0];s&&(a=r.get(s))}return a&&(a?.children?.length>0||a?.innerHTML?.trim()?.length>0)?a:void 0}catch(r){this.loggingService.catch("Error in WireframeService getWireframe: ",r);return}}getConditionElement(e,t=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&t){let s=e?.split("---")[0];s&&(a=r.get(s))}return a}catch(r){this.loggingService.catch("Error in WireframeService getConditionElement: ",r);return}}getWireframe$(e,t=!0){return this.wireframeMap.asObservable().pipe(de(r=>this.getWireframe(e,t)))}setChildren(e){try{this.wireframeMap.next(e)}catch(t){this.loggingService.catch("Error in WireframeService setChildren: ",t)}}getWireframeMap(){return this.wireframeMap.value}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var oge=i=>({componentConfigSignal:i}),NFe=(i,o)=>({condition:i,data:o}),FFe=(i,o,n,e,t)=>({template:i,context:o,componentName:"velt-confirm-dialog-wireframe",variant:n,setIfCondition:e,componentElementRef:t});function LFe(i,o){if(i&1&&(v(0),w(1,"app-confirm-dialog-title",5)(2,"app-confirm-dialog-message",5),y(3,"div",6),w(4,"app-confirm-dialog-reject",5)(5,"app-confirm-dialog-approve",5),b(),C()),i&2){let n=l(3);m(),d("componentConfigSignal",n.componentConfigSignal),m(),d("componentConfigSignal",n.componentConfigSignal),m(2),d("componentConfigSignal",n.componentConfigSignal),m(),d("componentConfigSignal",n.componentConfigSignal)}}function BFe(i,o){if(i&1&&(v(0),u(1,LFe,6,4,"ng-container",4),C()),i&2){let n=l().ngIf,e=l();m(),d("veltDynamicTemplate",$(3,FFe,e.template,A(1,oge,e.componentConfigSignal),n.variant,e.setIfCondition.bind(e),e.elementRef))}}function VFe(i,o){if(i&1&&(v(0),u(1,BFe,2,9,"ng-container",3),C()),i&2){let n=l();m(),d("veltIf",k(3,NFe,n.conditionSignal(),A(1,oge,n.componentConfigSignal)))}}var La=(()=>{let o=class o extends nt{constructor(e,t,r,a,s,c,p){super(s,a,void 0,void 0,void 0,p,e),this.loggingService=e,this.dialogRef=t,this.wireframeService=r,this.themeService=a,this.elementRef=s,this.dynamicDataService=p,this.subscriptions=[],this.componentConfigSignal=xe({title:"",message:"",yesButton:"",noButton:"",variant:"",closeDialog:this.closeDialog.bind(this)}),this.componentId="velt-confirm-dialog",this.veltElement=!0;try{c&&(this.componentConfigSignal.update(g=>(g=E(E({},g),c),g)),c?.darkMode&&[!0,!1].includes(c?.darkMode)&&super.setComponentDarkMode(c?.darkMode)),this.setZIndex()}catch(g){this.loggingService.catch("Error in ConfirmDialogComponent constructor: ",g)}}ngOnInit(){try{this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");let e="velt-confirm-dialog-wireframe";super.ngOnInit(),this.componentConfigSignal().variant&&(e+=`---${this.componentConfigSignal().variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r}}))}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent OnInit: ",e)}}ngOnDestroy(){super.ngOnDestroy();try{this.subscriptions.forEach(e=>e.unsubscribe())}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent OnDestroy: ",e)}}setZIndex(){try{if(this.dialogRef){let e=this.dialogRef._overlayRef;e&&(e.backdropElement&&(e.backdropElement.style.zIndex="2147483647"),e.hostElement&&(e.hostElement.style.zIndex="2147483647"))}}catch(e){this.loggingService.catch("Error in ConfirmDialogComponent setZIndex: ",e)}}closeDialog(e){try{this.dialogRef.close(e)}catch(t){this.loggingService.catch("Error in ConfirmDialogComponent closeDialog: ",t)}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(dr),h(Ge),h(Ke),h(R),h(rc,8),h(S))},o.\u0275cmp=O({type:o,selectors:[["snippyly-confirm-dialog"]],hostVars:1,hostBindings:function(t,r){t&2&&T("data-velt-element",r.veltElement)},standalone:!1,features:[V([S]),L],decls:3,vars:5,consts:[["floatingConfirmationRef",""],[1,"velt-confirm-dialog",3,"snippylyOverlay","snippylyOverlayZIndex","snippylyOverlayBackdropZIndex"],[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[3,"componentConfigSignal"],["mat-dialog-actions","",1,"velt-confirm-dialog-actions"]],template:function(t,r){if(t&1&&(y(0,"div",1,0),u(2,VFe,2,6,"ng-container",2),b()),t&2){let a=me(1);d("snippylyOverlay",a)("snippylyOverlayZIndex",1200)("snippylyOverlayBackdropZIndex",1100),T("data-testid",r.componentId),m(2),d("ngIf",r.componentConfigSignal())}},styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}[_nghost-%COMP%] *[_ngcontent-%COMP%]{outline:0}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent)}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}.velt-confirm-dialog[_ngcontent-%COMP%]{width:455px;padding:40px;display:block;box-sizing:border-box;background-color:var(--velt-background-0)}.velt-confirm-dialog-actions[_ngcontent-%COMP%]{justify-content:space-between;gap:var(--velt-spacing-md);min-height:auto} .velt-mat-dialog-container mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface:has(snippyly-confirm-dialog){border-radius:var(--velt-border-radius-xl);padding:0}@media (max-width: 768px){.velt-confirm-dialog[_ngcontent-%COMP%]{width:auto;max-width:455px;padding:24px}}"],changeDetection:0});let i=o;return i})();var Id=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=c,this.domService=p,this.afAuth=g,this.iamService=f,this.dialog=I,this.loggingService=x,this.notificationService=B,this.userPermissionService=z,this.areaAnnotationById$=new Ce({}),this.documentPaths=null,this.areaEnabled$=new Ce(!0),this.allowedElementIds$=new Ce([]),this.addAreaMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.analyticsService.setAreaService(this),this.authService.setAreaService(this),this.databaseService.getDb().pipe(Le(G=>!!G),rt(1)).subscribe(G=>{G&&this.getDocumentPaths()},G=>{this.loggingService.catch("Error in AreaService getDb subscription: ",G)}),this.domService.onWindowPointerMove$().subscribe(G=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let J=this.domService.getBackgroundElement(G.clientX,G.clientY);J&&(this.isElementInsideAllowedElements(J)?Hk(G.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=J,this.domService.highlightElement(this.highlightElement,U.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},G=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",G)}),this.domService.onWindowKeyupEsc$().subscribe(G=>{this.addAreaMode$.value&&this.disableAddAreaMode()},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",G)}),this.domService.onDocumentClick$().subscribe(G=>{if(G&&this.addAreaMode$.value){if(G.preventDefault(),G.stopPropagation(),!Hk(G.target)){let J=this.domService.getBackgroundElement(G.clientX,G.clientY);J&&this.isElementInsideAllowedElements(J)&&this.addArea(G)}this.disableAddAreaMode()}},G=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",G)}),this.addAreaMode$.subscribe(G=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),G?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},G=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",G)}),this.domService.onWindowKeyupBackspace$().subscribe(G=>{this.deleteAreaPinAnnotations("keyupBackspace")},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",G)}),this.domService.onWindowKeyupDelete$().subscribe(G=>{this.deleteAreaPinAnnotations("keyupDelete")},G=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",G)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}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()}getAllAreaAnnotations(e,t,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>s?this.getDataFromDocumentIds([s]).pipe(de(g=>(p.annotations=g||[],E({},p)))):this.docService.getDocumentIds$().pipe(fe(g=>{let f=g?.length>0?g.map(I=>I.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(f).pipe(de(I=>(p.annotations=I||[],E({},p))))}))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[],f=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(I=>I.locationId)),p?.location?.location?.id&&f.push(p?.location?.location?.id)),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g,f),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(de(()=>p)):le(p)),de(p=>(p.filteredAnnotations=p.filteredAnnotations?.map(g=>{let f=Object.assign({},g);return f.areaProperties=this.calculateAreaAnnotationPosition(f),f}),p)),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([])),fe(p=>{if(this.authService.isFeatureAllowed(Ne.COMMENT))return le(p);{let g=p?.filter(f=>!f?.targetAnnotations?.filter(I=>I?.type===Ne.COMMENT)?.length);return le(g)}})):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.AREA)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:r}=e;if(t?.some(p=>!p)||!this.documentPaths)return le([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=le([]),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 p=[U.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],g=[];for(let f=0;f<(p?.length??0);f+=U.LISTENER_CONTEXT_BATCH_SIZE)g.push(p?.slice(f,f+U.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=mn(g.map(f=>this.commonDbService.dbListener({feature:"allAreas",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",t),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[],...f?.length?[lt("context.accessFields","array-contains-any",f)]:[])]})}).pipe(Ar()))).pipe(de(f=>ia(f)))}else{let p=[];for(let g=0;g<(t?.length??0);g+=U.LISTENER_BATCH_SIZE)p.push(t?.slice(g,g+U.LISTENER_BATCH_SIZE)??[]);s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allAreas",properties:D(E({},c),{firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.documentId","in",g),lt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[lt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Ar()))).pipe(de(g=>ia(g)))}return s.pipe(de(({data:p,operation:g})=>{let f=[];return p&&(f=Object.values(p??{}).filter(I=>typeof I=="object")),{data:f,operation:g}}),de(({data:p,operation:g})=>{if(!t)return{data:p,documentMap:{},operation:g};let f=p.reduce((I,x)=>{let B=x.metadata?.documentId;return B&&(I[B]||(I[B]=[]),I[B].push(x)),I},{});return{data:p,documentMap:f,operation:g}}),de(({data:p,documentMap:g,operation:f})=>{if(!r)if(f?.type==="removed"){if(f?.ids?.length){let I=this.areaAnnotationById$.value;f?.ids?.forEach(x=>{delete I?.[x]}),this.areaAnnotationById$.next(I)}}else Object.entries(g??{}).forEach(([I,x])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:I,annotations:x})});return p}))}else return le([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:r,queryHash:a}){try{if(t){e||(e=U.NO_ORGANIZATION_ID),a||(a=U.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let c=E(E({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(c)}}catch(s){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",s)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}filterAnnotationsByLocationIds(e,t,r){try{return e.filter(a=>t.includes(a.locationId)||r?.includes(a?.location?.id)||t?.find(s=>s==a?.location?.id)||r?.find(s=>s==a?.locationId+""))}catch(a){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",a),[]}}calculateAreaAnnotationPosition(e){try{if(e.targetElements?.length){let t=e.targetElements[0],r=e.targetElements[1];if(t?.xpath&&r?.xpath||t?.anchor&&r?.anchor){let a=null,s=null;if(t?.anchor){let c=this.domService.resolveAnchorRecord(t.anchor);c?.element&&c?.element instanceof HTMLElement&&!Ki(c.element)&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(a=c.element)}else t?.xpath&&(a=this.domService.getElementFromXPath(t.xpath),a&&Ki(a)&&(a=null),this.domService.isXpathWithId(t.xpath)||(!a&&t.cfXpath&&(a=this.domService.getElementFromXPath(t.cfXpath),a&&Ki(a)&&(a=null)),!a&&t.fXpath&&(a=this.domService.getElementFromXPath(t.fXpath),a&&Ki(a)&&(a=null))));if(r?.anchor){let c=this.domService.resolveAnchorRecord(r.anchor);c?.element&&c?.element instanceof HTMLElement&&!Ki(c.element)&&this.domService.isElementVisible(c.element)&&Pi(c.element)&&(s=c.element)}else r?.xpath&&(s=this.domService.getElementFromXPath(r.xpath),s&&Ki(s)&&(s=null),this.domService.isXpathWithId(r.xpath)||(!s&&r.cfXpath&&(s=this.domService.getElementFromXPath(r.cfXpath),s&&Ki(s)&&(s=null)),!s&&r.fXpath&&(s=this.domService.getElementFromXPath(r.fXpath),s&&Ki(s)&&(s=null))));if(a&&s){let c=hz(a,s);if(c){let p=a.getBoundingClientRect(),g={};p&&p.width&&p.height&&(g={top:p.height*t.topPercentage/100,left:p.width*t.leftPercentage/100});let f=s.getBoundingClientRect(),I={};f&&f.width&&f.height&&(I={top:f.height*r.topPercentage/100,left:f.width*r.leftPercentage/100});let x=fz(g.left,g.top,a,c),B=fz(I.left,I.top,s,c),z,G,J,ne,ve={};x.x>B.x?x.y>B.y?(ne={x:x.x,y:x.y},z={x:B.x,y:B.y},ve.handle1=ne,ve.handle2=z):(G={x:x.x,y:x.y},J={x:B.x,y:B.y},ve.handle1=G,ve.handle2=J):x.y>B.y?(J={x:x.x,y:x.y},G={x:B.x,y:B.y},ve.handle1=J,ve.handle2=G):(z={x:x.x,y:x.y},ne={x:B.x,y:B.y},ve.handle1=z,ve.handle2=ne);let _e={topLeft:z||{x:J?.x,y:G?.y},bottomRight:ne||{x:G?.x,y:J?.y},topRight:G||{x:ne?.x,y:z?.y},bottomLeft:J||{x:z?.x,y:ne?.y}};return ve.coordinates=_e,ve.targetElement=this.domService.getXPath(c),ve}}}}return}catch(t){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",t);return}}addArea(e,t=[],r,a,s,c){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let p=this.authService.getUser();if(p)if(p.isReadOnly||p.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let g=new t9;a&&(g.annotationId=a),g.from=p,g.color=U.DEFAULT_ANNOTATION_COLOR,g.lastUpdated=this.timestamp,r&&(g.targetAnnotations=[r]),g.props=new uc;let f=this.domService.getCurrentWindowSizeValue();if(g.props.screenWidth=f.screenWidth,g.props.screenHeight=f.screenHeight,g.props.screenScrollHeight=f.screenScrollHeight,g.props.viewportWidth=window.innerWidth,g.props.viewportHeight=window.innerHeight,e||t?.length>0){let B=e?this.getPointsForAreaPinAnnotation(e):t;g.targetElements=[],B.forEach(z=>{g.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(g),s&&(g.locationId=s.locationId,g.location=s.location),g.pageInfo=Ni(),g.pageInfo&&(g.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let I=this.getElementForAreaAnnotation(g),x=this.docService.getBaseMetadata("area",{element:I});if(g?.metadata||(g.metadata={}),g.metadata=E(E({},g.metadata),x),c?.access&&c?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:p.userId,accessFields:c.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}g.context={access:c.access,accessFields:c.accessFields}}return this.saveAreaToDb(g),g}return}catch(p){this.loggingService.catch("Error in AreaService addArea: ",p);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}getElementForAreaAnnotation(e){try{let t,r,a;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(r=s.element)}else e.targetElements[0]?.xpath&&(r=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);s?.element&&this.domService.isElementVisible(s.element)&&Pi(s.element)&&(a=s.element)}else e.targetElements[1]?.xpath&&(a=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return r&&a&&(t=hz(r,a)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.AREA)&&mn([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe(Le(([t,r])=>!!t&&!!r),rt(1),fe(([t,r])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let a=JSON.parse(JSON.stringify(e));if(a.position=null,!a?.metadata?.documentId){a?.metadata||(a.metadata={});let p=this.docService.getBaseMetadata();a.metadata=E(E({},a?.metadata),p)}this.domService.toggleAnnotationSelection(a),this.analyticsService.trackEvent(Y.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:s,organizationId:c}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:s,organizationId:c},data:JSON.parse(JSON.stringify(a))})}else return le(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,r){try{r&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,Nk.UPDATED),this.updateAreaToDb(e)}catch(a){this.loggingService.catch("Error in AreaService updateArea: ",a)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata();t.metadata=E(E({},t?.metadata),s)}let{documentId:r,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:r,organizationId:a},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(t??{}).forEach(s=>Q(this,null,function*(){let c=t[s];c.type==="area"&&r&&c.from&&(r?.isAdmin||c.from.userId===r.userId)&&a.push(c)})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(La,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(rt(1)).subscribe(s=>{s&&(a.forEach(c=>Q(this,null,function*(){yield this.deleteAreaPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let r={};return Object.values(this.areaAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==t&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r??{})}catch(r){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",r),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let a=Object.values(this.areaAnnotationById$.value||{}),s;t?s=a.find(c=>c?.annotationId===t):s=a.find(c=>c?.targetAnnotations?.find(p=>p?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(c=>c?.annotationId!==e),s.targetAnnotations?.length?this.updateAreaToDb(s):this.deleteAreaPinAnnotation(s))}}catch(r){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",r)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(Ne.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,Nk.DELETED),this.analyticsService.trackEvent(Y.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:r}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),le(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(Ne.AREA)?(this.analyticsService.trackEvent(Y.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(Y.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],r=e,a=r?.touches?.length?r.touches[0]?.clientX:r.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r.clientY;return t.push({x:a,y:s}),t.push({x:a+100,y:s+100}),t}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 AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let r={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",r)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=Ni(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t=new URL(window.location.href);return t.searchParams.delete(U.URL_PARAMS.TAG_ID),t.searchParams.append(U.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return Q(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield pm(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Ft),ee(ot),ee(In),ee(un),ee(je),ee(Be),ee(Ri),ee(En),ee(po),ee(_),ee(hn),ee(ss))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var gi=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,n={},e=!0){try{this.hideAnalytics||(n||(n={}),n=D(E({},n),{source:"external"}),this.getService(Je).trackAuthenticatedEvent(o,n,e))}catch(t){this.getService(_).catch("Error in _trackEvent: ",t);return}}};var M9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Id).enableArea()}catch(o){this.getService(_).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Id).disableArea()}catch(o){this.getService(_).catch("Error in _disableAreaComment: ",o)}}};var xm=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B){this.analyticsService=e,this.configService=t,this.docService=r,this.databaseService=a,this.authService=s,this.domService=c,this.afAuth=p,this.iamService=g,this.dialog=f,this.loggingService=I,this.notificationService=x,this.commonDbService=B,this.arrowAnnotations$=new Ce({}),this.arrowAnnotationsByDocumentId$=new Ce({}),this.documentPaths=null,this.allowedElementIds$=new Ce([]),this.addArrowMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(Le(z=>!!z),rt(1)).subscribe(z=>{z&&this.getDocumentPaths()},z=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",z)}),this.domService.onWindowPointerMove$().subscribe(z=>{if(this.addArrowMode$.value){let G=!0,J=this.domService.getBackgroundElement(z.clientX,z.clientY);J&&(this.isElementInsideAllowedElements(J)?$k(z.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==J&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=J,this.domService.highlightElement(this.highlightElement,U.CURSOR.ARROW_PIN),G=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&G&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},z=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",z)}),this.domService.onWindowKeyupEsc$().subscribe(z=>{this.addArrowMode$.value&&this.disableAddArrowMode()},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",z)}),this.domService.onDocumentClick$().subscribe(z=>{if(z&&this.addArrowMode$.value){if(!$k(z.target)){let G=this.domService.getBackgroundElement(z.clientX,z.clientY);G&&this.isElementInsideAllowedElements(G)&&(z.preventDefault(),z.stopPropagation(),this.addArrow(z))}this.disableAddArrowMode()}},z=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",z)}),this.addArrowMode$.subscribe(z=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),z?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"))},z=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",z)}),this.domService.onWindowKeyupBackspace$().subscribe(z=>{this.deleteArrowPinAnnotations("keyupBackspace")},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",z)}),this.domService.onWindowKeyupDelete$().subscribe(z=>{this.deleteArrowPinAnnotations("keyupDelete")},z=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",z)})}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,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,s;try{if(e&&(s=Nn(e)),t&&typeof t=="object"){let c=or(t);a=Nn(JSON.stringify(c))}}catch(c){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",c)}return ei(this.afAuth).pipe(Le(c=>!!c),fe(c=>this.isFeatureAllowed({firebaseUser:c,annotations:[],filteredAnnotations:[]})),fe(c=>c.featureAllowed?this.iamService.isUserAllowed$().pipe(de(p=>(c.featureAllowed=p,c))):le(c)),fe(c=>c.featureAllowed?this.authService.isPlanExpired$().pipe(de(p=>(c.featureAllowed=!p,c))):le(c)),fe(c=>c.featureAllowed?le(c).pipe(fe(p=>this.docService.getDocumentPaths$().pipe(de(g=>(this.documentPaths=g,p.documentPaths=g,p)))),fe(p=>this.getDataFromDocumentId(s).pipe(de(g=>(p.annotations=g||[],E({},p))))),fe(p=>this.docService.getLocation$().pipe(de(g=>(p.location=g,p)))),fe(p=>this.docService.getLocations$().pipe(de(g=>(p.customLocations=g,p)))),de(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let g=[];return a?g.push(a):(g.push(p?.location?.locationId),g.push(...Object.values(p?.customLocations||[]).map(f=>f.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,g),p}}),fe(p=>r?le(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(de(()=>p)):le(p)),fe(p=>r?le(p):p?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(de(()=>p)):le(p)),de(p=>(p?.filteredAnnotations?.forEach(g=>{this.calculateArrowAnnotationPosition(g)}),p)),fe(p=>p?.filteredAnnotations?le(p?.filteredAnnotations||[]):le([]))):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.ARROW)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),fe(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(de(r=>({data:r?.data,operation:r?.operation})),de(({data:r,operation:a})=>{let s=[];return r&&(s=Object.values(r).filter(c=>typeof c=="object")),{data:s,operation:a}}),Un(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),le({data:[],operation:null}))),de(({data:r,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let s=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(c=>{delete s?.[c]}),this.arrowAnnotationsByDocumentId$.next(s)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,r);return r})):le([])))}setArrowAnnotationsByDocumentId(e,t){try{if(e){let r=D(E({},this.arrowAnnotationsByDocumentId$.value),{[e]:t});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(e,t){try{return e.filter(r=>t.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let r=t.iterateNext();if(r&&Pi(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:c}=Hg(r);e.position={top:s*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 r=new n9;r.from=t,r.color=t?.color||U.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new uc;let a=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=a.screenWidth,r.props.screenHeight=a.screenHeight,r.props.screenScrollHeight=a.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=U.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>U.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,e&&(r.targetElement=this.domService.getTargetElementForCursorPosition(e)),r?.targetElement?.xpath){let s=this.domService.getXPath(r.targetElement.xpath);if(s){let c=s.iterateNext();c&&(Pi(c)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=Ni(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}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 r=this.domService.getElementFromXPath(e.targetElement.xpath),a=this.docService.getAdditionLocationFromElement(r);if(a){let s=this.docService.addLocation({location:a,source:"internal"});s?.[0]&&(e.locationId=s[0].locationId,e.location=s[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(Ne.ARROW)&&this.docService.getDocumentPaths$().pipe(Le(t=>!!t),rt(1),fe(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(r=>!!r),rt(1),fe(r=>{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 le(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,r){try{r&&this.setLocationToArrowAnnotation(e),t&&this.updateNotificationsDatabase(e,Rk.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 r=t.iterateNext();r&&(Pi(r)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(Ne.ARROW)&&this.docService.getDocumentPaths$().pipe(Le(t=>!!t),rt(1),fe(t=>(this.documentPaths=t,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Le(r=>!!r),rt(1),fe(r=>{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 le(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(),r=this.authService.getUser(),a=[];Object.keys(t).forEach(s=>Q(this,null,function*(){let c=t[s];if(c.type==="arrow"){let p=r&&!r?.isAnonymous&&!r?.isGuest;r&&c.from&&(p||c.from.userId===r.userId)&&a.push(c)}})),a?.length&&(this.analyticsService.trackEvent(Y.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(La,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(rt(1)).subscribe(s=>{s&&(a.forEach(c=>Q(this,null,function*(){yield this.deleteArrowPinAnnotation(c)})),setTimeout(()=>{document.querySelectorAll(`[${U.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(t){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",t)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(Ne.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,Rk.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(Ne.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 r={annotationData:e,actionType:t,notificationSource:"arrow"};this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(e){try{return e?.pageInfo?.arrowUrl?e.pageInfo.arrowUrl:(e?.pageInfo||(e.pageInfo=Ni(),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(U.URL_PARAMS.TAG_ID),t.searchParams.append(U.URL_PARAMS.TAG_ID,e.annotationId),t.href}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(Ft),ee(ot),ee(In),ee(je),ee(Be),ee(Ri),ee(En),ee(po),ee(_),ee(hn),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var R9=class extends gi{constructor(o){super(o),this.getService(_).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(xm).setAllowedElementIds(o)}catch(n){this.getService(_).catch("Error in allowedElementIds: ",n)}}};var Fl=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Ce({}),this.onAutocompleteChipClick$=new Qe;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)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var F9=class extends gi{constructor(o){super(o),this.getService(_).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(_).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(Fl).create(o)}catch(n){this.getService(_).catch("Error in _create: ",n)}}_onAutocompleteChipClick(){this.getService(_).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(Y.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(Fl).getOnAutocompleteChipClick$()}catch(o){return this.getService(_).catch("Error in _onAutocompleteChipClick: ",o),le(null)}}};var rge=(()=>{let o=class o{constructor(e,t,r,a,s,c,p){this.authService=e,this.iamService=t,this.docService=r,this.configService=a,this.commonDbService=s,this.loggingService=c,this.commentService=p,this.documentPaths=null,this.LISTENER_BATCH_SIZE=30}getAnnotationsCount(e){try{return this.authService.getUser$().pipe(Le(t=>!!t),fe(t=>this.commentService.isFeatureAllowed({firebaseUser:t,annotations:[],filteredAnnotations:[]})),fe(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(de(r=>(t.featureAllowed=r,t))):le(t)),fe(t=>t.featureAllowed?this.processRequest(t,e):le(null)),de(t=>t??{data:null}),Ct(Xt))}catch(t){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",t),le({data:null})}}processRequest(e,t){try{return le(e).pipe(fe(()=>this.initializeDocumentPaths(e)),fe(()=>this.getDocumentIds$(t)),fe(r=>{let a=this.authService.getUser()?.userSnippylyId,s=this.buildRequestContext(t,r);if(!this.validateRequestContext(s,t))return le({data:null,mode:s.mode,serverDocumentIds:s.serverDocumentIds});if(!s.organizationId)return le({data:null,mode:s.mode,serverDocumentIds:s.serverDocumentIds});let c=this.setupTriggers$(s.mode,s.organizationId,s.veltFolderId,s.serverDocumentIds);return this.shouldUseAggregateMode(s.mode)?this.handleAggregateCounts$({triggers$:c,serverDocumentIds:s.serverDocumentIds,request:t,userId:a,organizationId:s.organizationId,clientOrganizationId:s.clientOrganizationId,veltFolderId:s.veltFolderId,folderId:s.folderId,mode:s.mode}).pipe(de(p=>({data:p,mode:s.mode,serverDocumentIds:s.serverDocumentIds}))):this.handleGroupedCounts$(c,r,t,a,s.organizationId,s.veltFolderId).pipe(de(p=>({data:p,mode:s.mode,serverDocumentIds:s.serverDocumentIds})))}),fe(r=>{if(!r?.data)return le(null);let{data:a,mode:s,serverDocumentIds:c}=r;return t?.filterGhostComments?this.filterGhostComments$(a,s,c):le(a)}),Un(r=>(this.loggingService.catch("Error processing request: ",r),le(null))))}catch(r){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",r),le(null)}}initializeDocumentPaths(e){try{return this.docService.getDocumentPaths$().pipe(Le(t=>!!t),Qt(t=>{this.documentPaths=t,e.documentPaths=t}),de(()=>{}))}catch(t){return this.loggingService.catch("Error in CommentService initializeDocumentPaths: ",t),le(e)}}buildRequestContext(e,t){try{let r=this.documentPaths?.organizationId,a=this.documentPaths?.clientOrganizationId,s,c,p;if(e?.allDocuments||e?.documentIds||e?.folderId||e?.organizationId||e?.locationIds){if(e.organizationId&&(r=os(e.organizationId),a=e.organizationId),!r)throw new Error("organizationId is required for this request type");e.folderId&&(s=Ai(e.folderId),c=e.folderId),e.allDocuments&&(p=!0)}else s=this.documentPaths?.veltFolderId,c=this.documentPaths?.folderId,p=this.documentPaths?.allDocuments;let g=this.determineMode(e,s,p,t),f=g.isOrgMode?[]:t.length>0?t.map(I=>I.documentId):[this.documentPaths?.documentId??""];return{organizationId:r,clientOrganizationId:a,veltFolderId:s,folderId:c,allDocuments:p,mode:g,serverDocumentIds:f}}catch(r){return this.loggingService.catch("Error in CommentService buildRequestContext: ",r),{organizationId:void 0,clientOrganizationId:void 0,veltFolderId:void 0,folderId:void 0,allDocuments:void 0,mode:{isOrgMode:!1,isFolderMode:!1,isBatchMode:!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(r=>!r)||!this.documentPaths)}catch(r){return this.loggingService.catch("Error in CommentService validateRequestContext: ",r),!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?le(e.documentIds.map(t=>({clientDocumentId:t,documentId:Dr(t)}))):this.docService.getDocumentIds$().pipe(de(t=>t.length>0?t:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))}catch(t){return this.loggingService.catch("Error in CommentService getDocumentIds: ",t),le([])}}determineMode(e,t,r,a){try{let s=!!e?.organizationId&&!e?.documentIds?.length&&!t&&!r,c=!!t&&!!r,p=!!e?.aggregateDocuments&&!r&&!!a?.length;return{isOrgMode:s,isFolderMode:c,isBatchMode:p}}catch(s){return this.loggingService.catch("Error in CommentService determineMode: ",s),{isOrgMode:!1,isFolderMode:!1,isBatchMode:!1}}}setupTriggers$(e,t,r,a){try{if(e.isOrgMode)return[this.commonDbService.dbListener({feature:"organizationMetadata",properties:{useCollectionGroup:!1,isCollection:!1,organizationId:t}}).pipe(de(c=>c?.data?.commentViewsUpdatedAt??null),Le(c=>!!c),Ct(Xt))];if(e.isFolderMode)return[this.commonDbService.dbListener({feature:"folder",properties:{useCollectionGroup:!1,isCollection:!1,folderId:r,organizationId:t}}).pipe(de(c=>c?.data?.commentViewsUpdatedAt??null),Le(c=>!!c),Ct(Xt))];if(e.isBatchMode){let s=[];for(let c=0;c<a.length;c+=this.LISTENER_BATCH_SIZE)s.push(a.slice(c,c+this.LISTENER_BATCH_SIZE));return s.map(c=>this.commonDbService.dbListener({feature:"allDocuments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:[li(lt("metadata.apiKey","==",this.configService?.getApiKey()),lt("metadata.organizationId","==",t),lt("metadata.documentId","in",c))]}}).pipe(de(g=>Object.values(g?.data||{}).map(I=>I?.commentViewsUpdatedAt??null).sort().join(",")),Ct(Xt)))}else return a.map(s=>this.commonDbService.dbListener({feature:"documentMetadata",properties:{useCollectionGroup:!1,isCollection:!1,documentId:s,organizationId:t}}).pipe(de(p=>p?.data?.commentViewsUpdatedAt??null),Le(p=>!!p),Ct(Xt)))}catch(s){return this.loggingService.catch("Error in CommentService setupTriggers: ",s),[]}}handleGroupedCounts$(e,t,r,a,s,c){try{let p=t.map((g,f)=>e[f].pipe(so(void 0),fe(()=>io(this.getCountsForDocument$(g.documentId,g.clientDocumentId,r,a,s,c)))));return mn(p).pipe(de(g=>{let f={};return g.forEach(I=>{I&&(f[I.clientDocumentId]={total:I.total,unread:I.unread})}),{data:f}}),Un(g=>(this.loggingService.catch("Error in grouped counts: ",g),le(null))))}catch(p){return this.loggingService.catch("Error in CommentService handleGroupedCounts: ",p),le(null)}}handleAggregateCounts$(e){try{let{triggers$:t,serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}=e;return mn(t).pipe(de(()=>{})).pipe(so(void 0),fe(()=>io(this.getAggregateCounts({serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}))),Un(B=>(this.loggingService.catch("Error in aggregate counts: ",B),le(null))))}catch(t){return this.loggingService.catch("Error in CommentService handleAggregateCounts: ",t),le(null)}}getCountsForDocument$(e,t,r,a,s,c){return Q(this,null,function*(){try{let p=this.configService?.getApiKey(),g={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},f=[lt("metadata.apiKey","==",p),lt("metadata.organizationId","==",s),lt("metadata.documentId","in",[e]),...c?[lt("metadata.veltFolderId","==",c)]:[],...r?.statusIds?.length?[lt("status.id","in",r.statusIds)]:[],...r?.locationIds?.length?[lt("location.id","in",r.locationIds)]:[]],I=[li(...f),to("lastUpdated","desc"),to("createdAt","desc")],x=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},g),{firestoreQuery:I})}),B=[...f,lt("viewedByUserIds","array-contains",a)],z=[li(...B),to("lastUpdated","desc"),to("createdAt","desc")],G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},g),{firestoreQuery:z})});return{clientDocumentId:t,total:x,unread:x-G}}catch(p){return this.loggingService.catch("Error in CommentService getCountsForDocument: ",p),null}})}getAggregateCounts(e){return Q(this,null,function*(){try{let t="",{serverDocumentIds:r,request:a,userId:s,organizationId:c,clientOrganizationId:p,veltFolderId:g,folderId:f,mode:I}=e,x=this.configService?.getApiKey(),B={useCollectionGroup:!0,isCollection:!0,useQuery:!0,getCount:!0},z=[lt("metadata.apiKey","==",x),lt("metadata.organizationId","==",c),...a?.statusIds?.length?[lt("status.id","in",a.statusIds)]:[],...a?.locationIds?.length?[lt("location.id","in",a.locationIds)]:[]],G,J;if(I.isFolderMode){t=f??"",z.push(lt("metadata.veltFolderId","==",g));let ne=[li(...z),to("lastUpdated","desc"),to("createdAt","desc")];G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:ne})});let ve=[...z,lt("viewedByUserIds","array-contains",s)],_e=[li(...ve),to("lastUpdated","desc"),to("createdAt","desc")];J=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:_e})})}else if(I.isOrgMode){t=p??"";let ne=[li(...z),to("lastUpdated","desc"),to("createdAt","desc")];G=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:ne})});let ve=[...z,lt("viewedByUserIds","array-contains",s)],_e=[li(...ve),to("lastUpdated","desc"),to("createdAt","desc")];J=yield this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:_e})})}else{t="result";let ne=[];for(let be=0;be<r.length;be+=this.LISTENER_BATCH_SIZE)ne.push(r.slice(be,be+this.LISTENER_BATCH_SIZE));let ve=ne.map(be=>Q(this,null,function*(){let Ie=[...z,lt("metadata.documentId","in",be),...g?[lt("metadata.veltFolderId","==",g)]:[]],Ae=[li(...Ie),to("lastUpdated","desc"),to("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:Ae})})}));G=(yield Promise.allSettled(ve)).reduce((be,Ie)=>be+(Ie.status==="fulfilled"&&Ie.value||0),0);let Fe=ne.map(be=>Q(this,null,function*(){let Ie=[...z,lt("metadata.documentId","in",be),...g?[lt("metadata.veltFolderId","==",g)]:[],lt("viewedByUserIds","array-contains",s)],Ae=[li(...Ie),to("lastUpdated","desc"),to("createdAt","desc")];return this.commonDbService.queryData({feature:"allComments",properties:D(E({},B),{firestoreQuery:Ae})})}));J=(yield Promise.allSettled(Fe)).reduce((be,Ie)=>be+(Ie.status==="fulfilled"&&Ie.value||0),0)}return{data:{[t]:{total:G,unread:G-J}}}}catch(t){return this.loggingService.catch("Error in CommentService getAggregateCounts: ",t),null}})}filterGhostComments$(e,t,r){try{return e?this.commentService.getGhostCommentAnnotationMap$().pipe(de(a=>{if(!a)return e;let s=this.buildGhostCommentAnnotationMap(a),c=this.groupGhostCommentsByModeId(s,t,r);return this.adjustCountsForGhostComments(e,c),e})):le(null)}catch(a){return this.loggingService.catch("Error in CommentService filterGhostComments: ",a),le(null)}}buildGhostCommentAnnotationMap(e){let t={};return Object.keys(e).forEach(r=>{let a=this.commentService.getAnnotationById(r);a&&(t[r]=a)}),t}groupGhostCommentsByModeId(e,t,r){try{let a={};return Object.values(e).forEach(s=>{let c=this.getModeIdForAnnotation(s,t,r);c&&(a[c]||(a[c]=[]),a[c].push(s))}),a}catch(a){return this.loggingService.catch("Error in CommentService groupGhostCommentsByModeId: ",a),{}}}getModeIdForAnnotation(e,t,r){try{return t.isOrgMode?e?.metadata?.clientOrganizationId||null:t.isFolderMode?e?.metadata?.folderId||null:t.isBatchMode?r.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(s=>{let c=t[s];if(!(!c||!e?.data?.[s]?.total)&&(e.data[s].total=Math.max(0,e.data[s].total-c.length),a)){let p=c.filter(g=>g?.viewedByUserIds&&!g?.viewedByUserIds?.includes(a));p.length>0&&(e.data[s].unread=Math.max(0,e.data[s].unread-p.length))}})}catch(r){this.loggingService.catch("Error in CommentService adjustCountsForGhostComments: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(En),ee(ot),ee(Ft),ee(un),ee(_),ee(we))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Xn=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B){this.analyticsService=e,this.authService=t,this.commentService=r,this.commentViewsService=a,this.contactService=s,this.customFilterService=c,this.docService=p,this.iamService=g,this.loggingService=f,this.metadataService=I,this.reactionService=x,this.commonDbService=B,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(z=>{this.isUserAdmin=z})}catch(z){this.loggingService.catch("Error in CommentActionsService constructor: ",z)}}addCommentAnnotation(a,s){return Q(this,arguments,function*({annotation:e,options:t},r){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),new Promise(c=>{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,p=>Q(this,null,function*(){let g=yield this.getAddCommentAnnotationEventFromCommentAddEventData(p);c(g)}),void 0,void 0,e,void 0,void 0,void 0,void 0,void 0,r)})}catch(c){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",c),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return Q(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(zi.ADD_COMMENT_ANNOTATION,e)}catch(t){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",t)}}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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){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 p=this.commentService.getAnnotationById(e,t);if(p){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===p?.from?.userId){this.commentService.deleteCommentPinAnnotation(p);let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:p.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(p),metadata:f};return this.triggerAction(zi.DELETE_COMMENT_ANNOTATION,I),I}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(s,c){return Q(this,arguments,function*({annotationId:e,priority:t,options:r},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,r);if(g){g=JSON.parse(JSON.stringify(g));let f=g.priority?JSON.parse(JSON.stringify(g.priority)):null;f&&t&&f?.id===t?.id?g.priority=void 0:g.priority=t,this.commentService.saveComment(g,{type:Wt.PRIORITY_CHANGED,newPriority:t,oldPriority:f});let I=yield this.metadataService.getGlobalMetadata(),x={newPriority:t,oldPriority:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};return this.triggerAction(zi.UPDATE_PRIORITY,x),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}),x}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",p),null}})}updateStatus(s,c){return Q(this,arguments,function*({annotationId:e,status:t,options:r},a){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateStatus","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,r);if(g){g=JSON.parse(JSON.stringify(g));let f=g.status?JSON.parse(JSON.stringify(g.status)):null;g.status=t,this.commentService.saveComment(g,{type:Wt.STATUS_CHANGED,newStatus:t,oldStatus:f});let I=yield this.metadataService.getGlobalMetadata(),x={newStatus:t,oldStatus:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};return this.triggerAction(zi.UPDATE_STATUS,x),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(g),oldStatus:f,newStatus:t,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),x}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",p),null}})}updateAccess(s,c){return Q(this,arguments,function*({annotationId:e,accessMode:t,options:r},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,r);if(g)if(this.commentService.isPrivateCommentAllowed()){g=JSON.parse(JSON.stringify(g));let f=g.iam?.accessMode;g.iam.accessMode=t,this.commentService.saveComment(g,{type:Wt.ACCESS_MODE_CHANGED,newAccessMode:t,oldAccessMode:f});let I=yield this.metadataService.getGlobalMetadata(),x={newAccessMode:t,oldAccessMode:f,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:I};switch(this.triggerAction(zi.UPDATE_ACCESS,x),t){case uo.PRIVATE:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:uo.PRIVATE,source:a??this.defaultSource});break;case uo.PUBLIC:this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:uo.PUBLIC,source:a??this.defaultSource});break;default:break}return x}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(p){return this.loggingService.catch("Error in CommentActionsService updateAccess: ",p),null}})}resolveCommentAnnotation(r){return Q(this,arguments,function*({annotationId:e,options:t}){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: resolveCommentAnnotation","color: green;"),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;let s=this.commentService.getAnnotationById(e,t);if(s){s=JSON.parse(JSON.stringify(s));let c=this.customFilterService.resolvedStatus,p=s.status?JSON.parse(JSON.stringify(s.status)):null;c&&(s.status=c,this.commentService.saveComment(s,{type:Wt.STATUS_CHANGED,newStatus:c,oldStatus:p}));let g=yield this.metadataService.getGlobalMetadata(),f={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(s),metadata:g};return this.triggerAction(zi.RESOLVE_COMMENT,f),f}else this.triggerAnnotationNotFoundError(e);return null}catch(a){return this.loggingService.catch("Error in CommentActionsService resolveCommentAnnotation: ",a),null}})}getLink(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let c=this.commentService.getAnnotationById(e,t);if(c){let p=this.commentService.getCommentUrl(c)??null,g=yield this.metadataService.getGlobalMetadata();return{link:p,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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let c=yield this.getLink({annotationId:e,options:t},r);if(c?.link){Js(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:r??this.defaultSource,link:c.link});let p=yield this.metadataService.getGlobalMetadata(),g={link:c.link,annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c.commentAnnotation),metadata:p};return this.triggerAction(zi.COPY_LINK,g),g}return null}catch(c){return this.loggingService.catch("Error in CommentActionsService copyLink: ",c),null}})}addComment(p,g){return Q(this,arguments,function*({annotationId:e,comment:t,assignedTo:r,assigned:a,options:s},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let f=this.authService.getUser();if(!f)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(f){let I=this.commentService.getAnnotationById(e,s),x=I?.comments?.length?Wt.ADDED:Wt.NEWLY_ADDED;if(I){I.status.type==="terminal"&&(I.status=this.customFilterService.defaultStatus);let B=new yd;B=E(E({},B),t),B.lastUpdated=new Date,B.attachments||(B.attachments=[]),B.attachments=B.attachments.filter(J=>J?.attachmentId),B.createdAt=this.timestamp,B.from=f,r&&(I.assignedTo=r),this.commentService.saveComment(I,{type:x,updatedComment:B,assigned:a});let z=yield this.metadataService.getGlobalMetadata(),G={annotationId:e,commentId:B?.commentId,comment:B,commentAnnotation:this.commentService.getCommentAnnotationForClient(I),metadata:z};return this.triggerAction(zi.ADD_COMMENT,G),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:t?.commentId,commentType:this.commentService.getCommentType(I),commentMode:this.commentService.getCommentMode(),source:c??this.defaultSource}),G}else this.triggerAnnotationNotFoundError(e)}return null}catch(f){return this.loggingService.catch("Error in CommentActionsService addComment: ",f),null}})}approveCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){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:Wt.APPROVED}),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource});let p=yield this.metadataService.getGlobalMetadata(),g={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:p};return this.triggerAction(zi.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,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=U.CommentAcceptStatus,this.commentService.saveComment(c,{type:Wt.ACCEPTED,oldStatus:g,newStatus:U.CommentAcceptStatus});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:f,actionUser:p,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(zi.ACCEPT_COMMENT_ANNOTATION,I),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",c),null}})}rejectCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=c.status?JSON.parse(JSON.stringify(c.status)):null;c.status=U.CommentRejectStatus,this.commentService.saveComment(c,{type:Wt.REJECTED,oldStatus:g,newStatus:U.CommentRejectStatus});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:f,actionUser:p,replaceContentHtml:c?.comments?.length?c?.comments[0]?.replaceContentHtml:void 0,replaceContentText:c?.comments?.length?c?.comments[0]?.replaceContentText:void 0};return this.triggerAction(zi.REJECT_COMMENT_ANNOTATION,I),this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(c),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",c),null}})}toggleNotificationSubscription(a,s){return Q(this,arguments,function*({annotationId:e,options:t},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let c=this.commentService.getAnnotationById(e,t),p=this.authService.getUser();if(c&&p){let g=Tt(p.userId);if(g){c.subscribedUsers||(c.subscribedUsers={}),c.unsubscribedUsers||(c.unsubscribedUsers={});let f,I=!1;if(c?.unsubscribedUsers?.[g])I=!1;else if(c?.subscribedUsers?.[g])I=!0;else{let z=this.contactService.getCurrentOrganizationUserIAM();if(z){let G=z.groups||{};Object.keys(G).forEach(J=>{c?.subscribedGroups?.[J]&&(I=!0)})}}if(r==="subscribe"||!r&&!I)delete c.unsubscribedUsers[g],c.subscribedUsers[g]={user:p,type:"manual"},f=Wt.SUBSCRIBED;else if(r==="unsubscribe"||!r&&I)delete c.subscribedUsers[g],c.unsubscribedUsers[g]={user:p,type:"manual"},f=Wt.UNSUBSCRIBED;else return null;this.commentService.saveComment(c,{type:f});let x=yield this.metadataService.getGlobalMetadata(),B={annotationId:e,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:x};return f===Wt.SUBSCRIBED?this.triggerAction(zi.SUBSCRIBE_COMMENT_ANNOTATION,B):this.triggerAction(zi.UNSUBSCRIBE_COMMENT_ANNOTATION,B),B}}else this.triggerAnnotationNotFoundError(e);return null}catch(c){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",c),null}})}assignUser(s,c){return Q(this,arguments,function*({annotationId:e,assignedTo:t,options:r},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,r);if(g){g.assignedTo=t,this.commentService.saveComment(g,{type:Wt.ASSIGNED,assignedTo:t});let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,assignedTo:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:f};return this.triggerAction(zi.ASSIGN_USER,I),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}),I}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService assignUser: ",p),null}})}getComment(r){return Q(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,r,a,s){return Q(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=Wt.UPDATED,t.isEdited||(t.isEdited=!0,t.editedAt=new Date),this.commentService.saveComment(e,{type:Wt.UPDATED,updatedComment:t});let p=yield this.metadataService.getGlobalMetadata(),g={annotationId:e?.annotationId,commentId:t?.commentId,comment:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:p};return this.triggerAction(zi.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:s??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:r,options:a});return null}catch(c){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",c),null}})}updateComment(p,g){return Q(this,arguments,function*({annotationId:e,comment:t,skipDeleteThreadConfirmation:r,merge:a,options:s},c){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let f=this.commentService.getAnnotationById(e,s),I=this.authService.getUser();if(!I)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(f&&I){let x=t,B=f.comments?.find(z=>z.commentId===t.commentId);if(B){if(this.isUserAdmin||I?.userId===B?.from?.userId)return f?.status.type==="terminal"&&(f.status=this.customFilterService.defaultStatus),a&&(x=E(E({},B),t)),x.from=B.from,x.createdAt=B.createdAt,x.lastUpdated=new Date,yield this.updateOrDeleteComment(f,x,r,s,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(f){return this.loggingService.catch("Error in CommentActionsService updateComment: ",f),null}})}deleteComment(c,p){return Q(this,arguments,function*({annotationId:e,commentId:t,skipDeleteThreadConfirmation:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let g=this.commentService.getAnnotationById(e,a),f=this.authService.getUser();if(g){let I=g.comments?.find(x=>x?.commentId===t);if(I)if(this.isUserAdmin||f?.userId===I?.from?.userId){this.commentService.saveComment(g,{type:Wt.DELETED,updatedComment:I,skipDeleteThreadConfirmation:r});let x=yield this.metadataService.getGlobalMetadata(),B={annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),comment:I,metadata:x};return this.triggerAction(zi.DELETE_COMMENT,B),B}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(g){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",g),null}})}addAttachment(s,c){return Q(this,arguments,function*({annotationId:e,files:t,options:r},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let p=[],g=this.commentService.getAnnotationById(e,r);if(g||a==="internal"){let x=[];t.forEach(B=>{let{valid:z,file:G,maxAllowedSize:J,error:ne}=this.validateFile(B);z&&G?x.push(this.uploadFile(G,g||{}).then(ve=>({valid:z,file:G,maxAllowedSize:J,error:ne,attachment:ve||void 0}))):x.push(Promise.resolve({valid:z,file:G,maxAllowedSize:J,error:ne,attachment:void 0}))}),p=yield Promise.all(x)}else this.triggerAnnotationNotFoundError(e);let f=yield this.metadataService.getGlobalMetadata(),I={annotationId:e,commentAnnotation:g?this.commentService.getCommentAnnotationForClient(g):void 0,attachments:p,metadata:f};return this.triggerAction(zi.ADD_ATTACHMENT,I),p}catch(p){return this.loggingService.catch("Error in CommentActionsService addAttachment: ",p),[]}})}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 r=e.size<=t;return{valid:r,file:e,maxAllowedSize:t,maxAllowedSizeInMB:t/1024/1024,error:r?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(s){return Q(this,arguments,function*({annotationId:e,commentId:t,attachmentId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let p=c.comments?.find(f=>f?.commentId===t),g=c.metadata;if(p){let f=this.authService.getUser();if(this.isUserAdmin||f?.userId===p?.from?.userId){let I=p.attachments?.find(x=>x?.attachmentId===r);if(I){p.attachments=p.attachments?.filter(G=>G?.attachmentId!==r);let x={attachmentId:I.attachmentId,organizationId:g?.organizationId??null,documentId:g?.documentId??null,folderId:g?.folderId??null,commentAnnotationId:c.annotationId,apiKey:g?.apiKey??null};yield this.commentService.deleteAttachment({attachment:I,metadata:x});let B=yield this.metadataService.getGlobalMetadata(),z={attachment:I,annotationId:e,commentId:t,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:B};return this.triggerAction(zi.DELETE_ATTACHMENT,z),this.updateComment({annotationId:e,comment:p,options:a}),z}}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 Q(this,arguments,function*({annotationId:e,commentId:t,options:r}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getAttachment","color: green;");let s=this.commentService.getAnnotationById(e,r);return s?s.comments?.find(p=>p?.commentId===t)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",s),[]}})}uploadFile(e,t){return Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,t)}catch(r){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",r),null}})}getRecording(a){return Q(this,arguments,function*({annotationId:e,commentId:t,options:r}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getRecording","color: green;");let s=this.commentService.getAnnotationById(e,r);return s?s.comments?.find(p=>p?.commentId===t)?.recorders||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getRecording: ",s),[]}})}deleteRecording(s){return Q(this,arguments,function*({annotationId:e,commentId:t,recorderId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let c=this.commentService.getAnnotationById(e,a);if(c){let p=c.comments?.find(g=>g?.commentId===t);if(p){let g=this.authService.getUser();if(this.isUserAdmin||g?.userId===p?.from?.userId){let f=p.recorders?.find(I=>I?.id===r);if(f){p.recorders=p.recorders?.filter(B=>B?.id!==r);let I=yield this.metadataService.getGlobalMetadata(),x={annotationId:e,commentId:t,recording:f,commentAnnotation:this.commentService.getCommentAnnotationForClient(c),metadata:I};return this.triggerAction(zi.DELETE_RECORDING,x),this.updateComment({annotationId:e,comment:p,skipDeleteThreadConfirmation:!0,options:a}),x}}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 Q(this,null,function*(){try{let t=yield this.commentService.fetchCommentAnnotations(e),r;if(t?.hasMore){let s=t?.data[t?.data?.length-1];r=yield sz(s?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=t?.data?.reduce((s,c)=>(s[c.metadata.clientDocumentId??c.metadata.documentId]=s[c.metadata.clientDocumentId??c.metadata.documentId]||[],s[c.metadata.clientDocumentId??c.metadata.documentId].push(this.commentService.getCommentAnnotationForClient(c)),s),{});return E({data:a},t?.hasMore?{nextPageToken:r}:{})}catch(t){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",t),{data:null}}})}toggleReaction(c,p){return Q(this,arguments,function*({annotationId:e,commentId:t,reaction:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let g=this.commentService.getAnnotationById(e,a),f=this.authService.getUser();if(g&&f){let I=g.comments?.find(x=>x?.commentId===t);if(I){let x=yield this.reactionService.addOrUpdateReaction(r.reactionId,I?.reactionAnnotationIds||[],void 0,void 0,g?.annotationId,r.customReaction,s),B=Wt.REACTION_ADDED;if(x){x?.reactions?.find(J=>J.from?.userId===f?.userId)||(B=Wt.REACTION_DELETED),I.reactionAnnotationIds||(I.reactionAnnotationIds=[]),I.reactionAnnotationIds.includes(x.annotationId)||I.reactionAnnotationIds.push(x.annotationId),x?.reactions?.length||(I.reactionAnnotationIds=I.reactionAnnotationIds.filter(J=>J!==x.annotationId)),this.commentService.saveComment(g,{type:B,updatedComment:I});let z=yield this.metadataService.getGlobalMetadata(),G={annotationId:e,commentId:t,reaction:x,commentAnnotation:this.commentService.getCommentAnnotationForClient(g),metadata:z};return s==="add"?this.triggerAction(zi.ADD_REACTION,G):s==="delete"?this.triggerAction(zi.DELETE_REACTION,G):this.triggerAction(zi.TOGGLE_REACTION,G),G}}}else this.triggerAnnotationNotFoundError(e);return null}catch(g){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",g),null}})}onComposerClick(t){return Q(this,arguments,function*({commentAnnotation:e}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onComposerClick","color: green;");let r=yield this.metadataService.getGlobalMetadata(),a={commentAnnotation:e?.annotationId?this.commentService.getCommentAnnotationForClient(e):void 0,metadata:r};this.triggerAction(zi.COMPOSER_CLICKED,a)}catch(r){this.loggingService.catch("Error in CommentActionsService onComposerClick: ",r)}})}autocompleteSearch(e){return Q(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(zi.AUTOCOMPLETE_SEARCH,e)}catch(t){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",t)}})}onCommentPinClick(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentPinClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),r={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(zi.COMMENT_PIN_CLICKED,r),r}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentPinClick: ",t),null}})}onCommentBubbleClick(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: onCommentBubbleClick","color: green;");let t=yield this.metadataService.getGlobalMetadata(),r={annotationId:e.annotationId,commentAnnotation:this.commentService.getCommentAnnotationForClient(e),metadata:t};return this.triggerAction(zi.COMMENT_BUBBLE_CLICKED,r),r}catch(t){return this.loggingService.catch("Error in CommentActionsService onCommentBubbleClick: ",t),null}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:r}=this.docService.getServerId(e?.options);e.options=D(E({},e?.options),{documentId:t,organizationId:r})}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 Qe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in CommentActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in CommentActionsService onAction: ",t),le(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."),le({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),le({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(de(t=>t?t.reduce((r,a)=>{let s=a.metadata?.clientDocumentId;return!s||e?.documentIds&&!e?.documentIds?.includes(s)||(r[s]||(r[s]=[]),r[s].push(a)),r},{}):null),de(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),le({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentViewsService.getAnnotationsCount(e).pipe(de(t=>t||{data:null}))}catch(t){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",t),le({data:null})}}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(je),ee(we),ee(rge),ee(Si),ee(Wo),ee(ot),ee(En),ee(_),ee(ol),ee(ur),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var L9=class extends gi{constructor(o){super(o),this.getService(_).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.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.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.setRecordings=this._setRecordings,this.addCommentOnElement=this._addCommentOnElement,this.enablePrivateCommentMode=this._enablePrivateCommentMode,this.disablePrivateCommentMode=this._disablePrivateCommentMode,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.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.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.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.on=this._on}_getAllCommentAnnotations(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{documentId:o,location:n}}),this.getService(we).getAllCommentAnnotations({customClientDocumentId:o,params:n,excludeDomChanges:!0,skipPositionCalculation:!0,addFilterCommentsOnDomCheck:!0}).pipe(de(e=>e?.length?e?.map(t=>this.getService(we).getCommentAnnotationForClient(t)):e))}catch(e){return this.getService(_).catch("Error in _getLiveCommentsOnCurrentDocument: ",e),le(null)}}_deleteSelectedComment(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteSelectedComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_SELECTED_COMMENT_TRIGGERED),this.getService(we).deleteCommentPinAnnotations("commentElement")}catch(o){return this.getService(_).catch("Error in _deleteSelectedComment: ",o),Promise.resolve(null)}}_enableTextComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).enableTextComments()}catch(o){this.getService(_).catch("Error in _enableTextComments: ",o)}}_disableTextComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableTextComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).disableTextComments()}catch(o){this.getService(_).catch("Error in _disableTextComments: ",o)}}_allowedElementIds(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(we).setAllowedElementIds(o)}catch(n){this.getService(_).catch("Error in allowedElementIds: ",n)}}_allowedElementClassNames(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementClassNames","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_CLASS_NAMES_TRIGGERED,{payload:{classNames:o}}),this.getService(we).setAllowedElementClassNames(o)}catch(n){this.getService(_).catch("Error in allowedElementClassNames: ",n)}}_allowedElementQuerySelectors(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementQuerySelectors","color: green;");try{this.trackEvent(Y.Events.Comments.ALLOWED_ELEMENT_QUERY_SELECTORS_TRIGGERED,{payload:{querySelectors:o}}),this.getService(we).setAllowedElementQuerySelectors(o)}catch(n){this.getService(_).catch("Error in allowedElementQuerySelectors: ",n)}}_disableFloatingComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!0)}catch(o){this.getService(_).catch("Error in _disableFloatingComments: ",o)}}_enableFloatingComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFloatingComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!1)}catch(o){this.getService(_).catch("Error in _enableFloatingComments: ",o)}}_attachComment(o){this.getService(_).log("%c[WB] Calling FUNCTION: attachComment","color: green;");try{this.trackEvent(Y.Events.Comments.ATTACH_COMMENT_TRIGGERED,{payload:{elementId:o}}),this.getService(we).attachComment(o,["id","data-id"])}catch(n){this.getService(_).catch("Error in _attachComment: ",n)}}_openCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: openCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.OPEN_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!0,!0)}catch(o){this.getService(_).catch("Error in _openCommentSidebar: ",o)}}_closeCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: closeCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.CLOSE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!1,!0)}catch(o){this.getService(_).catch("Error in _closeCommentSidebar: ",o)}}_toggleCommentSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: toggleCommentSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.TOGGLE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).toggleSidebarVisibility(!0)}catch(o){this.getService(_).catch("Error in _toggleCommentSidebar: ",o)}}_enableModeratorMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!0)}catch(o){this.getService(_).catch("Error in _enableModeratorMode: ",o)}}_disableModeratorMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableModeratorMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!1)}catch(o){this.getService(_).catch("Error in _disableModeratorMode: ",o)}}_enableStreamMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!0)}catch(o){this.getService(_).catch("Error in _enableStreamMode: ",o)}}_disableStreamMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableStreamMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!1)}catch(o){this.getService(_).catch("Error in _disableStreamMode: ",o)}}_enableSignInButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!0)}catch(o){this.getService(_).catch("Error in _enableSignInButton: ",o)}}_disableSignInButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSignInButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!1)}catch(o){this.getService(_).catch("Error in _disableSignInButton: ",o)}}_enableUpgradeButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!0)}catch(o){this.getService(_).catch("Error in _enableUpgradeButton: ",o)}}_disableUpgradeButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableUpgradeButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!1)}catch(o){this.getService(_).catch("Error in _disableUpgradeButton: ",o)}}_onCommentModeChange(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentModeChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_MODE_CHANGE_TRIGGERED),this.getService(we).addCommentModeChange()}catch(o){return this.getService(_).catch("Error in _onCommentModeChange: ",o),le(!1)}}_enableAttachment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!0)}catch(o){this.getService(_).catch("Error in _enableAttachment: ",o)}}_disableAttachment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAttachment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!1)}catch(o){this.getService(_).catch("Error in _disableAttachment: ",o)}}_isUserGlobalContact(){this.getService(_).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Comments.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(we).isUserGlobalContact$()}catch(o){return this.getService(_).catch("Error in _isUserGlobalContact: ",o),le(!1)}}_enableDeviceInfo(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!0)}catch(o){this.getService(_).catch("Error in _enableDeviceInfo: ",o)}}_disableDeviceInfo(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeviceInfo","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!1)}catch(o){this.getService(_).catch("Error in _disableDeviceInfo: ",o)}}_enableCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_MODE_TRIGGERED),this.getService(we).enableAddCommentMode()}catch(o){this.getService(_).catch("Error in _enableCommentMode: ",o)}}_disableCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_MODE_TRIGGERED),this.getService(we).disableAddCommentMode()}catch(o){this.getService(_).catch("Error in _disableCommentMode: ",o)}}_enablePersistentCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).enablePersistentCommentMode()}catch(o){this.getService(_).catch("Error in _enablePersistentCommentMode: ",o)}}_disablePersistentCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePersistentCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).disablePersistentCommentMode()}catch(o){this.getService(_).catch("Error in _disablePersistentCommentMode: ",o)}}_showCommentIndex(o){this.getService(_).log("%c[WB] Calling FUNCTION: showCommentIndex","color: green;");try{this.getService(we).showCommentIndex(o)}catch(n){this.getService(_).catch("Error in _showCommentIndex: ",n)}}_enableCommentIndex(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!0)}catch(o){this.getService(_).catch("Error in _enableCommentIndex: ",o)}}_disableCommentIndex(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentIndex","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!1)}catch(o){this.getService(_).catch("Error in _disableCommentIndex: ",o)}}_enablePopoverMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_MODE_TRIGGERED),this.getService(we).enablePopoverMode()}catch(o){this.getService(_).catch("Error in _enablePopoverMode: ",o)}}_disablePopoverMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePopoverMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_MODE_TRIGGERED),this.getService(we).disablePopoverMode()}catch(o){this.getService(_).catch("Error in _disablePopoverMode: ",o)}}_enableDialogOnHover(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!0)}catch(o){this.getService(_).catch("Error in _enableDialogOnHover: ",o)}}_disableDialogOnHover(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogOnHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!1)}catch(o){this.getService(_).catch("Error in _disableDialogOnHover: ",o)}}_enablePopoverTriangleComponent(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).enablePopoverTriangleComponent()}catch(o){this.getService(_).catch("Error in _enablePopoverTriangleComponent: ",o)}}_disablePopoverTriangleComponent(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePopoverTriangleComponent","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).disablePopoverTriangleComponent()}catch(o){this.getService(_).catch("Error in _disablePopoverTriangleComponent: ",o)}}_enableDialogOnTargetElementClick(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!0)}catch(o){this.getService(_).catch("Error in _enableDialogOnTargetElementClick: ",o)}}_disableDialogOnTargetElementClick(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogOnTargetElementClick","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!1)}catch(o){this.getService(_).catch("Error in _disableDialogOnTargetElementClick: ",o)}}_enablePriority(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!0)}catch(o){this.getService(_).catch("Error in _enablePriority: ",o)}}_disablePriority(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePriority","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!1)}catch(o){this.getService(_).catch("Error in _disablePriority: ",o)}}_enableStatus(){this.getService(_).log("%c[WB] Calling FUNCTION: enableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!0)}catch(o){this.getService(_).catch("Error in _enableStatus: ",o)}}_disableStatus(){this.getService(_).log("%c[WB] Calling FUNCTION: disableStatus","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!1)}catch(o){this.getService(_).catch("Error in _disableStatus: ",o)}}_enableResolveButton(){this.getService(_).log("%c[WB] Calling FUNCTION: enableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!0)}catch(o){this.getService(_).catch("Error in _enableResolveButton: ",o)}}_disableResolveButton(){this.getService(_).log("%c[WB] Calling FUNCTION: disableResolveButton","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!1)}catch(o){this.getService(_).catch("Error in _disableResolveButton: ",o)}}_enableGhostComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).enableGhostComments()}catch(o){this.getService(_).catch("Error in _enableGhostCommentsInDOM: ",o)}}_disableGhostComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGhostComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).disableGhostComments()}catch(o){this.getService(_).catch("Error in _disableGhostComments: ",o)}}_enableGhostCommentsIndicator(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).enableGhostCommentsMessage()}catch(o){this.getService(_).catch("Error in _enableGhostCommentsIndicator: ",o)}}_disableGhostCommentsIndicator(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGhostCommentsIndicator","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).disableGhostCommentsMessage()}catch(o){this.getService(_).catch("Error in _disableGhostCommentsIndicator: ",o)}}_setCustomStatus(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomStatus","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_STATUS_TRIGGERED,{payload:{customStatuses:o}}),this.getService(we).setCustomStatuses(o)}catch(n){this.getService(_).catch("Error in _setCustomStatus: ",n)}}_enableInboxMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INBOX_MODE_TRIGGERED),this.getService(we).enableInboxMode()}catch(o){this.getService(_).catch("Error in _enableInboxMode: ",o)}}_setCustomPriority(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomPriority","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_PRIORITY_TRIGGERED,{payload:{customPriorities:o}}),this.getService(we).setCustomPriorities(o)}catch(n){this.getService(_).catch("Error in _setCustomPriority: ",n)}}_setCustomCategory(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomCategory","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_CATEGORY_TRIGGERED,{payload:{customCategories:o}}),this.getService(we).setCustomCategories(o)}catch(n){this.getService(_).catch("Error in _setCustomCategory: ",n)}}_disableInboxMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableInboxMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INBOX_MODE_TRIGGERED),this.getService(we).disableInboxMode()}catch(o){this.getService(_).catch("Error in _disableInboxMode: ",o)}}_enableAutoCategorize(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!0)}catch(o){this.getService(_).catch("Error in _enableAutoCategorize: ",o)}}_disableAutoCategorize(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAutoCategorize","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!1)}catch(o){this.getService(_).catch("Error in _disableAutoCategorize: ",o)}}_enableDarkMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!0)}catch(o){this.getService(_).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!1)}catch(o){this.getService(_).catch("Error in _disableDarkMode: ",o)}}_setContextProvider(o){try{this.trackEvent(Y.Events.Comments.SET_CONTEXT_PROVIDER_TRIGGERED,{payload:{documentId:fpe,location}}),this.getService(we).setContextProvider(o)}catch(n){this.getService(_).catch("Error in _setContextProvider: ",n)}}_enableSuggestionMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!0)}catch(o){this.getService(_).catch("Error in _enableSuggestionMode: ",o)}}_disableSuggestionMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSuggestionMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!1)}catch(o){this.getService(_).catch("Error in _disableSuggestionMode: ",o)}}_enableMobileMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!0)}catch(o){this.getService(_).catch("Error in _enableMobileMode: ",o)}}_disableMobileMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMobileMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!1)}catch(o){this.getService(_).catch("Error in _disableMobileMode: ",o)}}_enableInlineCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).enableInlineCommentMode()}catch(o){this.getService(_).catch("Error in _enableInlineCommentMode: ",o)}}_disableInlineCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableInlineCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).disableInlineCommentMode()}catch(o){this.getService(_).catch("Error in _disableInlineCommentMode: ",o)}}_enableMinimap(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MINIMAP_TRIGGERED),this.getService(we).enableMinimap()}catch(o){this.getService(_).catch("Error in _enableMinimap: ",o)}}_disableMinimap(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMinimap","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MINIMAP_TRIGGERED),this.getService(we).disableMinimap()}catch(o){this.getService(_).catch("Error in _disableMinimap: ",o)}}_showCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: showCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showCommentsOnDom()}catch(o){this.getService(_).catch("Error in _showCommentsOnDom: ",o)}}_hideCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: hideCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideCommentsOnDom()}catch(o){this.getService(_).catch("Error in _hideCommentsOnDom: ",o)}}_enableCommentTool(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).enableCommentTool()}catch(o){this.getService(_).catch("Error in _enableCommentTool: ",o)}}_disableCommentTool(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentTool","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).disableCommentTool()}catch(o){this.getService(_).catch("Error in _disableCommentTool: ",o)}}_setTotalMediaLength(o){this.getService(_).log("%c[WB] Calling FUNCTION: setTotalMediaLength","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TOTAL_MEDIA_LENGTH_TRIGGERED,{payload:{length:o}}),this.getService(we).setTotalMediaLength(o)}catch(n){this.getService(_).catch("Error in _setTotalMediaLength: ",n)}}_onCommentAdd(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentAdd","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_ADD_TRIGGERED),this.getService(we).onCommentAdd$()}catch(o){return this.getService(_).catch("Error in _onCommentAdd: ",o),le()}}_onCommentUpdate(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentUpdate","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_UPDATE_TRIGGERED),this.getService(we).onCommentUpdate$()}catch(o){return this.getService(_).catch("Error in _onCommentUpdate: ",o),le()}}_addCommentOnSelectedText(){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentOnSelectedText","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_SELECTED_TEXT_TRIGGERED),this.getService(we).addCommentOnSelectedText()}catch(o){this.getService(_).catch("Error in _addCommentOnSelectedText: ",o)}}_enableSidebarUrlNavigation(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).enableSidebarUrlNavigation()}catch(o){this.getService(_).catch("Error in _enableSidebarUrlNavigation: ",o)}}_disableSidebarUrlNavigation(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarUrlNavigation","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).disableSidebarUrlNavigation()}catch(o){this.getService(_).catch("Error in _disableSidebarUrlNavigation: ",o)}}_setDStrategy(o){this.getService(_).log("%c[WB] Calling FUNCTION: setDStrategy","color: green;");try{this.trackEvent(Y.Events.Comments.SET_D_STRATEGY_TRIGGERED,{payload:{strategy:o}}),this.getService(we).setDetectionStrategy(o)}catch(n){this.getService(_).catch("Error in _setDStrategy: ",n)}}_enableSidebarButtonOnCommentDialog(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).enableSidebarButtonOnCommentDialog()}catch(o){this.getService(_).catch("Error in _enableSidebarButtonOnCommentDialog: ",o)}}_disableSidebarButtonOnCommentDialog(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableSidebarButtonOnCommentDialog()}catch(o){this.getService(_).catch("Error in _disableSidebarButtonOnCommentDialog: ",o)}}_onSidebarButtonOnCommentDialogClick(){this.getService(_).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(we).getSidebarButtonOnCommentDialogClick$()}catch(o){return this.getService(_).catch("Error in _onSidebarButtonOnCommentDialogClick: ",o),le(null)}}_enableReactions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REACTIONS_TRIGGERED),this.getService(we).enableReactions()}catch(o){this.getService(_).catch("Error in _enableReactions: ",o)}}_disableReactions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReactions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REACTIONS_TRIGGERED),this.getService(we).disableReactions()}catch(o){this.getService(_).catch("Error in _disableReactions: ",o)}}_setRecordings(o){this.getService(_).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(n=>n.trim())),this.getService(we).setAllowedRecordings(o)}catch(n){this.getService(_).catch("Error in _setRecordings: ",n)}}_addCommentOnElement(o){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentOnElement","color: green;");try{this.trackEvent(Y.Events.Comments.ADD_COMMENT_ON_ELEMENT_TRIGGERED,{payload:{data:o}}),this.getService(we).addCommentOnElement(o)}catch(n){this.getService(_).catch("Error in _addCommentOnElement: ",n)}}_enablePrivateCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).enablePrivateCommentMode()}catch(o){this.getService(_).catch("Error in _enablePrivateCommentMode: ",o)}}_disablePrivateCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePrivateCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).disablePrivateCommentMode()}catch(o){this.getService(_).catch("Error in _disablePrivateCommentMode: ",o)}}_enableScrollToComment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).enableScrollToComment()}catch(o){this.getService(_).catch("Error in _enableScrollToComment: ",o)}}_disableScrollToComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableScrollToComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).disableScrollToComment()}catch(o){this.getService(_).catch("Error in _disableScrollToComment: ",o)}}_enableUserMentions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_USER_MENTIONS_TRIGGERED),this.getService(we).enableUserMentions()}catch(o){this.getService(_).catch("Error in _enableUserMentions: ",o)}}_disableUserMentions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_USER_MENTIONS_TRIGGERED),this.getService(we).disableUserMentions()}catch(o){this.getService(_).catch("Error in _disableUserMentions: ",o)}}_setCommentSidebarFilters(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_FILTERS_TRIGGERED,{payload:{filters:o}}),this.getService(we).setCommentSidebarFilters(o)}catch(n){this.getService(_).catch("Error in _setCommentSidebarFilters: ",n)}}_setSystemFiltersOperator(o){this.getService(_).log("%c[WB] Calling FUNCTION: setSystemFiltersOperator","color: green;");try{this.trackEvent(Y.Events.Comments.SET_SYSTEM_FILTERS_OPERATOR_TRIGGERED,{payload:{operator:o}}),this.getService(we).setCommentSidebarSystemFiltersOperator(o)}catch(n){this.getService(_).catch("Error in _setSystemFiltersOperator: ",n)}}_enableCommentPinHighlighter(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentPinHighlighter","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(we).enableCommentPinHighlighter()}catch(o){this.getService(_).catch("Error in _enableCommentPinHighlighter: ",o)}}_disableCommentPinHighlighter(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentPinHighlighter","color: green;");try{this.getService(we).disableCommentPinHighlighter()}catch(o){this.getService(_).catch("Error in _disableCommentPinHighlighter: ",o)}}_enableDeleteOnBackspace(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).enableDeleteOnBackspace()}catch(o){this.getService(_).catch("Error in _enableDeleteOnBackspace: ",o)}}_disableDeleteOnBackspace(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).disableDeleteOnBackspace()}catch(o){this.getService(_).catch("Error in _disableDeleteOnBackspace: ",o)}}_enableHotkey(){this.getService(_).log("%c[WB] Calling FUNCTION: enableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_HOTKEY_TRIGGERED),this.getService(we).enableHotkey()}catch(o){this.getService(_).catch("Error in _enableHotkey: ",o)}}_disableHotkey(){this.getService(_).log("%c[WB] Calling FUNCTION: disableHotkey","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_HOTKEY_TRIGGERED),this.getService(we).disableHotkey()}catch(o){this.getService(_).catch("Error in _disableHotkey: ",o)}}_enableDeviceIndicatorOnCommentPins(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).enableDeviceIndicatorOnCommentPins()}catch(o){this.getService(_).catch("Error in _enableDeviceIndicatorOnCommentPins: ",o)}}_disableDeviceIndicatorOnCommentPins(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).disableDeviceIndicatorOnCommentPins()}catch(o){this.getService(_).catch("Error in _disableDeviceIndicatorOnCommentPins: ",o)}}_getElementRefByAnnotationId(o){this.getService(_).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(we).getElementRefByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _getElementRefByAnnotationId: ",n);return}}_scrollToCommentByAnnotationId(o){this.getService(_).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(we).scrollToCommentByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _scrollToCommentByAnnotationId: ",n)}}_selectCommentByAnnotationId(o){this.getService(_).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(we).selectCommentByAnnotationId(o)}catch(n){this.getService(_).catch("Error in _selectCommentByAnnotationId: ",n)}}_enableRecordingSummary(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).enableRecordingSummary()}catch(o){this.getService(_).catch("Error in _enableRecordingSummary: ",o)}}_disableRecordingSummary(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).disableRecordingSummary()}catch(o){this.getService(_).catch("Error in _disableRecordingSummary: ",o)}}_enableRecordingTranscription(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(Wi).enableRecordingTranscription()}catch(o){this.getService(_).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(Wi).disableRecordingTranscription()}catch(o){this.getService(_).catch("Error in _disableRecordingTranscription: ",o)}}_enableRecordingCountdown(){this.getService(_).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).enableRecordingCountdown()}catch(o){this.getService(_).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(_).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).disableRecordingCountdown()}catch(o){this.getService(_).catch("Error in _disableRecordingCountdown: ",o)}}_setUnreadIndicatorMode(o){this.getService(_).log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;");try{this.trackEvent(Y.Events.Comments.SET_UNREAD_INDICATOR_MODE_TRIGGERED,{payload:{mode:o}}),this.getService(we).setUnreadIndicatorMode(o)}catch(n){this.getService(_).catch("Error in _setUnreadIndicatorMode: ",n)}}_enableEnterKeyToSubmit(){this.getService(_).log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).enableEnterKeyToSubmit()}catch(o){this.getService(_).catch("Error in _enableEnterKeyToSubmit: ",o)}}_disableEnterKeyToSubmit(){this.getService(_).log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).disableEnterKeyToSubmit()}catch(o){this.getService(_).catch("Error in _disableEnterKeyToSubmit: ",o)}}_enablePinShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).enablePinShadowDOM()}catch(o){this.getService(_).catch("Error in _enablePinShadowDOM: ",o)}}_disablePinShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).disablePinShadowDOM()}catch(o){this.getService(_).catch("Error in _disablePinShadowDOM: ",o)}}_enableDialogShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).enableDialogShadowDOM()}catch(o){this.getService(_).catch("Error in _enableDialogShadowDOM: ",o)}}_disableDialogShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).disableDialogShadowDOM()}catch(o){this.getService(_).catch("Error in _disableDialogShadowDOM: ",o)}}_enableSidebarShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).enableSidebarShadowDOM()}catch(o){this.getService(_).catch("Error in _enableSidebarShadowDOM: ",o)}}_disableSidebarShadowDOM(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).disableSidebarShadowDOM()}catch(o){this.getService(_).catch("Error in _disableSidebarShadowDOM: ",o)}}_enableChangeDetectionInCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).enableChangeDetectionInCommentMode()}catch(o){this.getService(_).catch("Error in _enableChangeDetectionInCommentMode: ",o)}}_disableChangeDetectionInCommentMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).disableChangeDetectionInCommentMode()}catch(o){this.getService(_).catch("Error in _disableChangeDetectionInCommentMode: ",o)}}_showResolvedCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: showResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.SHOW_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showResolvedCommentsOnDom()}catch(o){this.getService(_).catch("Error in _showResolvedCommentsOnDom: ",o)}}_hideResolvedCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: hideResolvedCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.HIDE_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideResolvedCommentsOnDom()}catch(o){this.getService(_).catch("Error in _hideResolvedCommentsOnDom: ",o)}}_setCustomReactions(o){this.getService(_).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(Y.Events.Comments.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(we).setCustomReactions(o)}catch(n){this.getService(_).catch("Error in _setCustomReactions: ",n)}}_onCommentSelectionChange(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSelectionChange","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SELECTION_CHANGE_TRIGGERED),this.getService(we).onCommentSelectionChange$()}catch(o){return this.getService(_).catch("Error in _onCommentSelectionChange: ",o),le(null)}}_getUnreadCommentCountByAnnotationId(o){this.getService(_).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(we).getUnreadCommentCountByAnnotationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentCountByAnnotationId: ",n),le(null)}}_getUnreadCommentAnnotationCountOnCurrentDocument(){this.getService(_).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(we).getUnreadCommentAnnotationCountOnCurrentDocument$()}catch(o){return this.getService(_).catch("Error in _getUnreadCommentAnnotationCountOnCurrentDocument: ",o),le(null)}}_getUnreadCommentCountOnCurrentDocument(){this.getService(_).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(we).getUnreadCommentCountOnCurrentDocument$()}catch(o){return this.getService(_).catch("Error in _getUnreadCommentCountOnCurrentDocument: ",o),le(null)}}_getUnreadCommentAnnotationCountByLocationId(o){this.getService(_).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(we).getUnreadCommentAnnotationCountByLocationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentAnnotationCountByLocationId: ",n),le(null)}}_getUnreadCommentCountByLocationId(o){this.getService(_).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(we).getUnreadCommentCountByLocationId$(o)}catch(n){return this.getService(_).catch("Error in _getUnreadCommentCountByLocationId: ",n),le(null)}}_updateCommentDialogPosition(){this.getService(_).log("%c[WB] Calling FUNCTION: updateCommentDialogPosition","color: green;");try{this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_DIALOG_POSITION_TRIGGERED),this.getService(we).updateCommentDialogPosition()}catch(o){this.getService(_).catch("Error in _updateCommentDialogPosition: ",o)}}_enableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(we).enableAreaComment()}catch(o){this.getService(_).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(we).disableAreaComment()}catch(o){this.getService(_).catch("Error in _disableAreaComment: ",o)}}_setPinCursorImage(o){this.getService(_).log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;");try{this.trackEvent(Y.Events.Comments.SET_PIN_CURSOR_IMAGE_TRIGGERED,{payload:{image:o}}),this.getService(we).setPinCursorImage(o)}catch(n){this.getService(_).catch("Error in _setPinCursorImage: ",n)}}_addManualComment(o){this.getService(_).log("%c[WB] Calling FUNCTION: addManualComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_MANUAL_COMMENT_TRIGGERED,{payload:{config:o}}),this.getService(we).addManualComment(o)}catch(n){return this.getService(_).catch("Error in _addManualComment: ",n),Promise.resolve()}}_createCustomListDataOnAnnotation(o){this.getService(_).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(we).createCustomListDataOnAnnotation(o)}catch(n){this.getService(_).catch("Error in _createCustomListDataOnAnnotation: ",n)}}_createCustomListDataOnComment(o){this.getService(_).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(Fl).create(o)}catch(n){this.getService(_).catch("Error in _createCustomListDataOnComment: ",n)}}_excludeLocationIdsFromSidebar(o){this.getService(_).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(we).setExcludeLocationIdsFromSidebar(o)}catch(n){this.getService(_).catch("Error in _excludeLocationIdsFromSidebar: ",n)}}_enableBubbleOnPin(){this.getService(_).log("%c[WB] Calling FUNCTION: enableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).enableBubbleOnPin()}catch(o){this.getService(_).catch("Error in _enableBubbleOnPin: ",o)}}_disableBubbleOnPin(){this.getService(_).log("%c[WB] Calling FUNCTION: disableBubbleOnPin","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).disableBubbleOnPin()}catch(o){this.getService(_).catch("Error in _disableBubbleOnPin: ",o)}}_enableBubbleOnPinHover(){this.getService(_).log("%c[WB] Calling FUNCTION: enableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).enableBubbleOnPinHover()}catch(o){this.getService(_).catch("Error in _enableBubbleOnPinHover: ",o)}}_disableBubbleOnPinHover(){this.getService(_).log("%c[WB] Calling FUNCTION: disableBubbleOnPinHover","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).disableBubbleOnPinHover()}catch(o){this.getService(_).catch("Error in _disableBubbleOnPinHover: ",o)}}_enableMultiThread(){this.getService(_).log("%c[WB] Calling FUNCTION: enableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_MULTI_THREAD_TRIGGERED),this.getService(we).enableMultiThread()}catch(o){this.getService(_).catch("Error in _enableMultiThread: ",o)}}_disableMultiThread(){this.getService(_).log("%c[WB] Calling FUNCTION: disableMultiThread","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_MULTI_THREAD_TRIGGERED),this.getService(we).disableMultiThread()}catch(o){this.getService(_).catch("Error in _disableMultiThread: ",o)}}_enableGroupMatchedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(we).enableGroupMatchedComments()}catch(o){this.getService(_).catch("Error in _enableGroupMatchedComments: ",o)}}_disableGroupMatchedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableGroupMatchedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_GROUP_MATCHED_COMMENTS_TRIGGERED),this.getService(we).disableGroupMatchedComments()}catch(o){this.getService(_).catch("Error in _disableGroupMatchedComments: ",o)}}_updateContext(o,n,e){this.getService(_).log("%c[WB] Calling FUNCTION: updateContext","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_CONTEXT_TRIGGERED,{payload:{annotationId:o,context:n,config:e}}),this.getService(we).updateCommentAnnotationContext(o,n,e)}catch(t){return this.getService(_).catch("Error in _updateContext: ",t),Promise.resolve()}}_getSelectedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: getSelectedComments","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_SELECTED_COMMENTS_TRIGGERED),this.getService(Be).getSelectedComments$()}catch(o){return this.getService(_).catch("Error in _getSelectedComments: ",o),le([])}}_enableDeleteReplyConfirmation(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDeleteReplyConfirmation","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(we).enableDeleteReplyConfirmation()}catch(o){this.getService(_).catch("Error in _enableDeleteReplyConfirmation: ",o)}}_disableDeleteReplyConfirmation(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDeleteReplyConfirmation","color: green;");try{this.getService(we).disableDeleteReplyConfirmation()}catch(o){this.getService(_).catch("Error in _disableDeleteReplyConfirmation: ",o)}}_onCopyLink(){this.getService(_).log("%c[WB] Calling FUNCTION: onCopyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COPY_LINK_TRIGGERED),this.getService(we).getCopyLink$()}catch(o){return this.getService(_).catch("Error in _onCopyLink: ",o),le("")}}_getCommentAnnotationById(o){this.getService(_).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(we).getCommentAnnotationById(o)}catch(n){return this.getService(_).catch("Error in _getCommentAnnotationById: ",n),le(null)}}_enableCollapsedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).enableCollapsedComments()}catch(o){this.getService(_).catch("Error in _enableCollapsedComments: ",o)}}_disableCollapsedComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCollapsedComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).disableCollapsedComments()}catch(o){this.getService(_).catch("Error in _disableCollapsedComments: ",o)}}_onCommentSidebarActionButtonClick(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarActionButtonClick","color: green;");try{return this.getService(we).getSidebarCustomActionEventData()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarActionButtonClick: ",o),le(null)}}_setCommentSidebarData(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: setCommentSidebarData","color: green;");try{this.trackEvent(Y.Events.Comments.SET_COMMENT_SIDEBAR_DATA_TRIGGERED,{payload:{data:o,options:n}}),this.getService(we).setCommentSidebarData(o,n)}catch(e){this.getService(_).catch("Error in _setCommentSidebarData: ",e)}}_onCommentSidebarInit(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarInit","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_INIT_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataOnInit()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarInit: ",o),le(null)}}_onCommentSidebarData(){this.getService(_).log("%c[WB] Calling FUNCTION: onCommentSidebarData","color: green;");try{return this.trackEvent(Y.Events.Comments.ON_COMMENT_SIDEBAR_DATA_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataAllChanges()}catch(o){return this.getService(_).catch("Error in _onCommentSidebarData: ",o),le(null)}}_setCommentSidebarDefaultCustomActions(o){this.getService(_).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(we).setSidebarCustomActionEventData(o,[],{},[],{})}catch(n){this.getService(_).catch("Error in _setCommentSidebarDefaultCustomActions: ",n)}}_enableSidebarCustomActions(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).enableSidebarCustomActions()}catch(o){this.getService(_).catch("Error in _enableSidebarCustomActions: ",o)}}_disableSidebarCustomActions(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSidebarCustomActions","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).disableSidebarCustomActions()}catch(o){this.getService(_).catch("Error in _disableSidebarCustomActions: ",o)}}_enableQueryParamsComments(){this.getService(_).log("%c[WB] Calling FUNCTION: enableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).enableQueryParamsComments()}catch(o){this.getService(_).catch("Error in _enableQueryParamsComments: ",o)}}_disableQueryParamsComments(){this.getService(_).log("%c[WB] Calling FUNCTION: disableQueryParamsComments","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).disableQueryParamsComments()}catch(o){this.getService(_).catch("Error in _disableQueryParamsComments: ",o)}}_enableResolveStatusAccessAdminOnly(){this.getService(_).log("%c[WB] Calling FUNCTION: enableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).enableResolveStatusAccessAdminOnly()}catch(o){this.getService(_).catch("Error in _enableResolveStatusAccessAdminOnly: ",o)}}_disableResolveStatusAccessAdminOnly(){this.getService(_).log("%c[WB] Calling FUNCTION: disableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).disableResolveStatusAccessAdminOnly()}catch(o){this.getService(_).catch("Error in _disableResolveStatusAccessAdminOnly: ",o)}}_enableLinkCallback(){this.getService(_).log("%c[WB] Calling FUNCTION: enableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_LINK_CALLBACK_TRIGGERED),this.getService(we).enableLinkCallback()}catch(o){this.getService(_).catch("Error in _enableLinkCallback: ",o)}}_disableLinkCallback(){this.getService(_).log("%c[WB] Calling FUNCTION: disableLinkCallback","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_LINK_CALLBACK_TRIGGERED),this.getService(we).disableLinkCallback()}catch(o){this.getService(_).catch("Error in _disableLinkCallback: ",o)}}_enableSeenByUsers(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).enableSeenByUsers()}catch(o){this.getService(_).catch("Error in _enableSeenByUsers: ",o)}}_disableSeenByUsers(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSeenByUsers","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).disableSeenByUsers()}catch(o){this.getService(_).catch("Error in _disableSeenByUsers: ",o)}}_enableShortUserName(){this.getService(_).log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).enableShortUserName()}catch(o){this.getService(_).catch("Error in _enableShortUserName: ",o)}}_disableShortUserName(){this.getService(_).log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).disableShortUserName()}catch(o){this.getService(_).catch("Error in _disableShortUserName: ",o)}}_addCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_ANNOTATION_TRIGGERED,{payload:{addCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).addCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _addCommentAnnotation: ",n),null}})}_approveCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: approveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.APPROVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{approveCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).approveCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _approveCommentAnnotation: ",n),null}})}_acceptCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: acceptCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.ACCEPT_COMMENT_ANNOTATION_TRIGGERED,{payload:{acceptCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).acceptCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _acceptCommentAnnotation: ",n),null}})}_rejectCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: rejectCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.REJECT_COMMENT_ANNOTATION_TRIGGERED,{payload:{rejectCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).rejectCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _rejectCommentAnnotation: ",n),null}})}_subscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: subscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.SUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{subscribeCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).toggleNotificationSubscription(o,"subscribe")}catch(n){return this.getService(_).catch("Error in _subscribeCommentAnnotation: ",n),null}})}_unsubscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: unsubscribeCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.UNSUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{unsubscribeCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).toggleNotificationSubscription(o,"unsubscribe")}catch(n){return this.getService(_).catch("Error in _unsubscribeCommentAnnotation: ",n),null}})}_deleteCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_ANNOTATION_TRIGGERED,{payload:{deleteCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).deleteCommentAnnotation(o,"external")}catch(n){return this.getService(_).catch("Error in _deleteCommentAnnotation: ",n),null}})}_getCommentAnnotations(o){this.getService(_).log("%c[WB] Calling FUNCTION: getCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{query:o}}),this.getService(Xn).getCommentAnnotations(o).pipe(de(n=>(n.data&&Object.keys(n.data).forEach(e=>{if(n.data?.[e]?.length){let t=n.data[e];n.data[e]=t?.map(r=>this.getService(we).getCommentAnnotationForClient(r))}}),n)))}catch(n){return this.getService(_).catch("Error in _getCommentAnnotations: ",n),le({data:null})}}_getCommentAnnotationsCount(o){this.getService(_).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(Xn).getCommentAnnotationsCount$(o)}catch(n){return this.getService(_).catch("Error in _getCommentAnnotationsCount: ",n),le({data:null})}}_assignUser(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: assignUser","color: green;");try{return this.trackEvent(Y.Events.Comments.ASSIGN_USER_TRIGGERED,{payload:{assignUserRequest:o}}),this.getService(Xn).convert(o).assignUser(o,"external")}catch(n){return this.getService(_).catch("Error in _assignUser: ",n),null}})}_updatePriority(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updatePriority","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_PRIORITY_TRIGGERED,{payload:{updatePriorityRequest:o}}),this.getService(Xn).convert(o).updatePriority(o,"external")}catch(n){return this.getService(_).catch("Error in _updatePriority: ",n),null}})}_updateStatus(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateStatus","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_STATUS_TRIGGERED,{payload:{updateStatusRequest:o}}),this.getService(Xn).convert(o).updateStatus(o,"external")}catch(n){return this.getService(_).catch("Error in _updateStatus: ",n),null}})}_updateAccess(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateAccess","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_ACCESS_TRIGGERED,{payload:{updateAccessRequest:o}}),this.getService(Xn).convert(o).updateAccess(o,"external")}catch(n){return this.getService(_).catch("Error in _updateAccess: ",n),null}})}_resolveCommentAnnotation(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: resolveCommentAnnotation","color: green;");try{return this.trackEvent(Y.Events.Comments.RESOLVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{resolveCommentAnnotationRequest:o}}),this.getService(Xn).convert(o).resolveCommentAnnotation(o)}catch(n){return this.getService(_).catch("Error in _resolveCommentAnnotation: ",n),null}})}_getLink(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getLink","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_LINK_TRIGGERED,{payload:{getLinkRequest:o}}),this.getService(Xn).convert(o).getLink(o,"external")}catch(n){return this.getService(_).catch("Error in _getLink: ",n),null}})}_copyLink(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: copyLink","color: green;");try{return this.trackEvent(Y.Events.Comments.COPY_LINK_TRIGGERED,{payload:{copyLinkRequest:o}}),this.getService(Xn).convert(o).copyLink(o,"external")}catch(n){return this.getService(_).catch("Error in _copyLink: ",n),null}})}_addComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addComment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_COMMENT_TRIGGERED,{payload:{addCommentRequest:o}}),this.getService(Xn).convert(o).addComment(o,"external")}catch(n){return this.getService(_).catch("Error in _addComment: ",n),null}})}_updateComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{return this.trackEvent(Y.Events.Comments.UPDATE_COMMENT_TRIGGERED,{payload:{updateCommentRequest:o}}),this.getService(Xn).convert(o).updateComment(o,"external")}catch(n){return this.getService(_).catch("Error in _updateComment: ",n),null}})}_deleteComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteComment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_COMMENT_TRIGGERED,{payload:{deleteCommentRequest:o}}),this.getService(Xn).convert(o).deleteComment(o,"external")}catch(n){return this.getService(_).catch("Error in _deleteComment: ",n),null}})}_getComment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getComment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_COMMENT_TRIGGERED,{payload:{getCommentRequest:o}}),this.getService(Xn).convert(o).getComment(o)}catch(n){return this.getService(_).catch("Error in _getComment: ",n),[]}})}_addAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_ATTACHMENT_TRIGGERED,{payload:{addAttachmentRequest:o}}),this.getService(Xn).convert(o).addAttachment(o)}catch(n){return this.getService(_).catch("Error in _addAttachment: ",n),Promise.resolve([])}})}_deleteAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_ATTACHMENT_TRIGGERED,{payload:{deleteAttachmentRequest:o}}),this.getService(Xn).convert(o).deleteAttachment(o)}catch(n){return this.getService(_).catch("Error in _deleteAttachment: ",n),null}})}_getAttachment(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getAttachment","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_ATTACHMENT_TRIGGERED,{payload:{getAttachmentRequest:o}}),this.getService(Xn).convert(o).getAttachment(o)}catch(n){return this.getService(_).catch("Error in _getAttachment: ",n),[]}})}_getRecording(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: getRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.GET_RECORDING_TRIGGERED,{payload:{getRecordingRequest:o}}),this.getService(Xn).convert(o).getRecording(o)}catch(n){return this.getService(_).catch("Error in _getRecording: ",n),[]}})}_deleteRecording(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_RECORDING_TRIGGERED,{payload:{deleteRecordingRequest:o}}),this.getService(Xn).convert(o).deleteRecording(o)}catch(n){return this.getService(_).catch("Error in _deleteRecording: ",n),null}})}_fetchCommentAnnotations(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: fetchCommentAnnotations","color: green;");try{return this.trackEvent(Y.Events.Comments.FETCH_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{fetchCommentAnnotationsRequest:o}}),this.getService(Xn).fetchCommentAnnotations(o)}catch(n){return this.getService(_).catch("Error in _fetchCommentAnnotations: ",n),{data:null}}})}_addReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.ADD_REACTION_TRIGGERED,{payload:{addReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o,"add")}catch(n){return this.getService(_).catch("Error in _addReaction: ",n),null}})}_deleteReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: deleteReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.DELETE_REACTION_TRIGGERED,{payload:{deleteReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o,"delete")}catch(n){return this.getService(_).catch("Error in _deleteReaction: ",n),null}})}_toggleReaction(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: toggleReaction","color: green;");try{return this.trackEvent(Y.Events.Comments.TOGGLE_REACTION_TRIGGERED,{payload:{toggleReactionRequest:o}}),this.getService(Xn).convert(o).toggleReaction(o)}catch(n){return this.getService(_).catch("Error in _toggleReaction: ",n),null}})}_on(o){this.getService(_).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(Xn).onAction(o)}catch(n){return this.getService(_).catch("Error in _on: ",n),le(null)}}_enableReadOnly(){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.ENABLE_READ_ONLY_TRIGGERED),this.getService(we).enableReadOnly()}catch(o){this.getService(_).catch("Error in _toggleReaction: ",o);return}})}_disableReadOnly(){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReadOnly","color: green;");try{return this.trackEvent(Y.Events.Comments.DISABLE_READ_ONLY_TRIGGERED),this.getService(we).disableReadOnly()}catch(o){this.getService(_).catch("Error in _disableReadOnly: ",o);return}})}_enableCustomAutocompleteSearch(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).enableCustomAutocompleteSearch()}catch(o){this.getService(_).catch("Error in _enableCustomAutocompleteSearch: ",o);return}}_disableCustomAutocompleteSearch(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCustomAutocompleteSearch","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).disableCustomAutocompleteSearch()}catch(o){this.getService(_).catch("Error in _disableCustomAutocompleteSearch: ",o);return}}_setTransformContext(o){this.getService(_).log("%c[WB] Calling FUNCTION: setTransformContext","color: green;");try{this.trackEvent(Y.Events.Comments.SET_TRANSFORM_CONTEXT_TRIGGERED,{payload:{transformContext:o}}),this.getService(we).setTransformContext(o)}catch(n){this.getService(_).catch("Error in _setTransformContext: ",n);return}}_enableSvgAsImg(){this.getService(_).log("%c[WB] Calling FUNCTION: enableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).enableSvgAsImg()}catch(o){this.getService(_).catch("Error in _enableSvgAsImg: ",o);return}}_disableSvgAsImg(){this.getService(_).log("%c[WB] Calling FUNCTION: disableSvgAsImg","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).disableSvgAsImg()}catch(o){this.getService(_).catch("Error in _disableSvgAsImg: ",o);return}}_enableFullExpanded(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).enableFullExpanded()}catch(o){this.getService(_).catch("Error in _enableFullExpanded: ",o);return}}_disableFullExpanded(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFullExpanded","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).disableFullExpanded()}catch(o){this.getService(_).catch("Error in _disableFullExpanded: ",o);return}}_enableCommentToNearestAllowedElement(){this.getService(_).log("%c[WB] Calling FUNCTION: enableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).enableCommentToNearestAllowedElement()}catch(o){this.getService(_).catch("Error in _enableCommentToNearestAllowedElement: ",o);return}}_disableCommentToNearestAllowedElement(){this.getService(_).log("%c[WB] Calling FUNCTION: disableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).disableCommentToNearestAllowedElement()}catch(o){this.getService(_).catch("Error in _disableCommentToNearestAllowedElement: ",o);return}}_enableDraftMode(){this.getService(_).log("%c[WB] Calling FUNCTION: enableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_DRAFT_MODE_TRIGGERED),this.getService(we).enableDraftMode()}catch(o){this.getService(_).catch("Error in _enableDraftMode: ",o);return}}_disableDraftMode(){this.getService(_).log("%c[WB] Calling FUNCTION: disableDraftMode","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_DRAFT_MODE_TRIGGERED),this.getService(we).disableDraftMode()}catch(o){this.getService(_).catch("Error in _disableDraftMode: ",o);return}}_enableFilterCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).enableFilterCommentsOnDom()}catch(o){this.getService(_).catch("Error in _enableFilterCommentsOnDom: ",o);return}}_disableFilterCommentsOnDom(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFilterCommentsOnDom","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).disableFilterCommentsOnDom()}catch(o){this.getService(_).catch("Error in _disableFilterCommentsOnDom: ",o);return}}_enableReplyAvatars(){this.getService(_).log("%c[WB] Calling FUNCTION: enableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_REPLY_AVATARS_TRIGGERED),this.getService(we).enableReplyAvatars()}catch(o){this.getService(_).catch("Error in _enableReplyAvatars: ",o);return}}_disableReplyAvatars(){this.getService(_).log("%c[WB] Calling FUNCTION: disableReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_REPLY_AVATARS_TRIGGERED),this.getService(we).disableReplyAvatars()}catch(o){this.getService(_).catch("Error in _disableReplyAvatars: ",o);return}}_setMaxReplyAvatars(o){this.getService(_).log("%c[WB] Calling FUNCTION: setMaxReplyAvatars","color: green;");try{this.trackEvent(Y.Events.Comments.SET_MAX_REPLY_AVATARS_TRIGGERED,{payload:{maxReplyAvatars:o}}),this.getService(we).setMaxReplyAvatars(o)}catch(n){this.getService(_).catch("Error in _setMaxReplyAvatars: ",n);return}}_setSidebarButtonCountType(o){this.getService(_).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(we).setSidebarButtonCountType(o)}catch(n){this.getService(_).catch("Error in _setSidebarButtonCountType: ",n);return}}_enableFilterGhostCommentsInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(we).enableFilterGhostCommentsInSidebar()}catch(o){this.getService(_).catch("Error in _enableFilterGhostCommentsInSidebar: ",o);return}}_disableFilterGhostCommentsInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFilterGhostCommentsInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FILTER_GHOST_COMMENTS_IN_SIDEBAR_TRIGGERED),this.getService(we).disableFilterGhostCommentsInSidebar()}catch(o){this.getService(_).catch("Error in _disableFilterGhostCommentsInSidebar: ",o);return}}_enableFullScreenInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: enableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(we).enableFullScreenInSidebar()}catch(o){this.getService(_).catch("Error in _enableFullScreenInSidebar: ",o);return}}_disableFullScreenInSidebar(){this.getService(_).log("%c[WB] Calling FUNCTION: disableFullScreenInSidebar","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FULL_SCREEN_IN_SIDEBAR_TRIGGERED),this.getService(we).disableFullScreenInSidebar()}catch(o){this.getService(_).catch("Error in _disableFullScreenInSidebar: ",o);return}}_setComposerFileAttachments(o){this.getService(_).log("%c[WB] Calling FUNCTION: setComposerFileAttachments","color: green;");try{this.getService(we).setComposerFileAttachments(o),this.trackEvent(Y.Events.Comments.SET_COMPOSER_FILE_ATTACHMENTS_TRIGGERED,{payload:{data:o}})}catch(n){this.getService(_).catch("Error in _setComposerFileAttachments: ",n);return}}_setAllowedFileTypes(o){this.getService(_).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(we).setAllowedFileTypes(o)}catch(n){this.getService(_).catch("Error in _setAllowedFileTypes: ",n);return}}_enableForceCloseAllOnEsc(){this.getService(_).log("%c[WB] Calling FUNCTION: enableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(we).enableForceCloseAllOnEsc()}catch(o){this.getService(_).catch("Error in _enableForceCloseAllOnEsc: ",o);return}}_disableForceCloseAllOnEsc(){this.getService(_).log("%c[WB] Calling FUNCTION: disableForceCloseAllOnEsc","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_FORCE_CLOSE_ALL_ON_ESC_TRIGGERED),this.getService(we).disableForceCloseAllOnEsc()}catch(o){this.getService(_).catch("Error in _disableForceCloseAllOnEsc: ",o);return}}_markAsRead(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: markAsRead","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_READ_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(we).markAsRead(o);return}catch(n){this.getService(_).catch("Error in _markAsRead: ",n);return}})}_markAsUnread(o){return Q(this,null,function*(){this.getService(_).log("%c[WB] Calling FUNCTION: markAsUnread","color: green;");try{this.trackEvent(Y.Events.Comments.MARK_AS_UNREAD_TRIGGERED,{payload:{annotationId:o}}),yield this.getService(we).markAsUnread(o)}catch(n){this.getService(_).catch("Error in _markAsUnread: ",n);return}})}_enableScreenshot(){this.getService(_).log("%c[WB] Calling FUNCTION: enableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_SCREENSHOT_TRIGGERED),this.getService(we).enableScreenshot()}catch(o){this.getService(_).catch("Error in _enableScreenshot: ",o);return}}_disableScreenshot(){this.getService(_).log("%c[WB] Calling FUNCTION: disableScreenshot","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_SCREENSHOT_TRIGGERED),this.getService(we).disableScreenshot()}catch(o){this.getService(_).catch("Error in _disableScreenshot: ",o);return}}_enablePaginatedContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: enablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.ENABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(we).enablePaginatedContactList()}catch(o){this.getService(_).catch("Error in _enablePaginatedContactList: ",o);return}}_disablePaginatedContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: disablePaginatedContactList","color: green;");try{this.trackEvent(Y.Events.Comments.DISABLE_PAGINATED_CONTACT_LIST_TRIGGERED),this.getService(we).disablePaginatedContactList()}catch(o){this.getService(_).catch("Error in _disablePaginatedContactList: ",o);return}}};var B9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(Y.Events.Contact.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(Si).isUserGlobalContact$()}catch(o){return this.getService(_).catch("Error in _isUserGlobalContact: ",o),le(!1)}}_onContactSelected(){this.getService(_).log("%c[WB] Calling FUNCTION: onContactSelected","color: green;");try{return this.trackEvent(Y.Events.Contact.ON_CONTACT_SELECTED_TRIGGERED),this.getService(Si).onContactSelected$()}catch(o){return this.getService(_).catch("Error in _onContactSelected: ",o),le(null)}}_enableAtHere(){this.getService(_).log("%c[WB] Calling FUNCTION: enableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.ENABLE_AT_HERE_TRIGGERED),this.getService(Si).enableAtHere()}catch(o){this.getService(_).catch("Error in _enableAtHere: ",o)}}_setAtHereLabel(o){this.getService(_).log("%c[WB] Calling FUNCTION: setAtHereLabel","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_LABEL_TRIGGERED,{payload:{label:o}}),this.getService(Si).setAtHereLabel(o)}catch(n){this.getService(_).catch("Error in setAtHereLabel: ",n)}}_setAtHereDescription(o){this.getService(_).log("%c[WB] Calling FUNCTION: setAtHereDescription","color: green;");try{this.trackEvent(Y.Events.Contact.SET_AT_HERE_DESCRIPTION_TRIGGERED,{payload:{description:o}}),this.getService(Si).setAtHereDescription(o)}catch(n){this.getService(_).catch("Error in setAtHereDescription: ",n)}}_disableAtHere(){this.getService(_).log("%c[WB] Calling FUNCTION: disableAtHere","color: green;");try{this.trackEvent(Y.Events.Contact.DISABLE_AT_HERE_TRIGGERED),this.getService(Si).disableAtHere()}catch(o){this.getService(_).catch("Error in _disableAtHere: ",o)}}_updateContactListScopeForOrganizationUsers(o){this.getService(_).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(Si).updateContactListScopeForOrganizationUsers(o)}catch(n){this.getService(_).catch("Error in _updateContactListScopeForOrganizationUsers: ",n)}}_updateContactList(o,n){this.getService(_).log("%c[WB] Calling FUNCTION: _updateContactList","color: green;");try{this.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{payload:{userContacts:o,config:n}}),typeof o=="object"&&o instanceof Array&&(!n||n&&typeof n=="object")&&(o=JSON.parse(JSON.stringify(o)),this.getService(Si).convert(n).updateContactList(o,n))}catch(e){this.getService(_).catch("Error in _updateContactList: ",e)}}_getContactList(){this.getService(_).log("%c[WB] Calling FUNCTION: getContactList","color: green;");try{return this.trackEvent(Y.Events.Contact.GET_CONTACT_LIST_TRIGGERED),this.getService(Si).getContactList$()}catch(o){return this.getService(_).catch("Error in _getContactList: ",o),le(null)}}};var V9=(()=>{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 Qe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in CrdtActionsService triggerAction: ",r)}}onAction(e){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe);let t=this.actionSubjects.get(e);return t?t.asObservable():le(null)}catch(t){return this.loggingService.catch("Error in CrdtActionsService onAction: ",t),le(null)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ed=(()=>{let o=class o{static generateKey(){return Q(this,null,function*(){try{return yield window.crypto.subtle.generateKey({name:"AES-GCM",length:this.KEY_LENGTH},!1,["encrypt","decrypt"])}catch(e){return Ze.catch("Failed to generate key: ",e),null}})}static deriveKeyFromPassword(e,t){return Q(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 r=new TextEncoder().encode(e),a=yield window.crypto.subtle.importKey("raw",r,"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(r){return Ze.catch("Failed to derive key from password: ",r),null}})}static resolveKey(e){return Q(this,null,function*(){try{if(e.customKey){if(e.customKey instanceof CryptoKey)return{key:e.customKey};if(typeof e.customKey=="string"){let r=yield this.deriveKeyFromPassword(e.customKey,e.customSalt);if(!r)return Ze.catch("Failed to derive key from password"),null;let{key:a,salt:s}=r;return{key:a,salt:s}}}let t=yield this.generateKey();return t?{key:t}:(Ze.catch("Failed to generate key"),null)}catch(t){return Ze.catch("Failed to resolve key: ",t),null}})}static encrypt(r){return Q(this,arguments,function*(e,t={}){try{if(t.customEncryptCallback)try{return yield t.customEncryptCallback(e)}catch(I){return Ze.catch("Custom encryption callback failed: ",I),""}let a=yield this.resolveKey(t);if(!a)return Ze.catch("Failed to resolve key"),"";let{key:s,salt:c}=a,p;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return Ze.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";p=t.customIV}else p=window.crypto.getRandomValues(new Uint8Array(this.IV_LENGTH));let g=new TextEncoder().encode(e),f={name:"AES-GCM",iv:p,tagLength:128};t.additionalData&&(f.additionalData=t.additionalData);try{let I=yield window.crypto.subtle.encrypt(f,s,g),x=new Uint8Array(p.length+I.byteLength);x.set(p,0),x.set(new Uint8Array(I),p.length);let B=8192,z=[];for(let G=0;G<x.length;G+=B){let J=x.slice(G,Math.min(G+B,x.length)),ne="";for(let ve=0;ve<J.length;ve++)ne+=String.fromCharCode(J[ve]);z.push(ne)}return btoa(z.join(""))}catch(I){return Ze.catch("Encryption failed: ",I),""}}catch(a){return Ze.catch("Failed to encrypt: ",a),null}})}static decrypt(r){return Q(this,arguments,function*(e,t={}){try{if(t.customDecryptCallback)try{return yield t.customDecryptCallback(e)}catch(I){return Ze.catch("Custom decryption callback failed: ",I),""}let a=yield this.resolveKey(t);if(!a)return Ze.catch("Failed to resolve key"),"";let{key:s}=a,c=new Uint8Array(atob(e).split("").map(I=>I.charCodeAt(0)));if(c.length<this.IV_LENGTH)return Ze.catch("Invalid encrypted data: Too short"),"";let p;if(t.customIV){if(t.customIV.length!==this.IV_LENGTH)return Ze.catch(`Custom IV must be exactly ${this.IV_LENGTH} bytes`),"";p=t.customIV}else p=c.slice(0,this.IV_LENGTH);let g=c.slice(this.IV_LENGTH),f={name:"AES-GCM",iv:p,tagLength:128};t.additionalData&&(f.additionalData=t.additionalData);try{let I=yield window.crypto.subtle.decrypt(f,s,g);return new TextDecoder().decode(I)}catch(I){return Ze.catch("Decryption failed: ",I),""}}catch(a){return Ze.catch("Failed to decrypt: ",a),""}})}static encryptData(r){return Q(this,arguments,function*(e,t={}){try{let a=JSON.stringify(e);return(yield this.encrypt(a,t))??""}catch(a){return Ze.catch("Failed to encrypt data: ",a),""}})}static decryptData(r){return Q(this,arguments,function*(e,t={}){try{let a=yield this.decrypt(e,t);return JSON.parse(a)}catch(a){return Ze.catch("Failed to decrypt data: ",a),null}})}};o.IV_LENGTH=12,o.SALT_LENGTH=16,o.PBKDF2_ITERATIONS=1e5,o.KEY_LENGTH=256;let i=o;return i})();var ds=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f){this.authService=e,this.commonDbService=t,this.commonDbUtilsService=r,this.configService=a,this.crdtActionsService=s,this.docService=c,this.domService=p,this.loggingService=g,this.notificationService=f,this.MIN_WEBHOOK_DEBOUNCE_TIME=5*1e3,this.webhookDebounceTime=this.MIN_WEBHOOK_DEBOUNCE_TIME,this.updateDataWebhookTrigger$=new Qe,this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null,this.webhookEnabled$=new Ce(!1);try{this.loggingService.log("%c[WB] Creating CLASS: CrdtService","color: blue;"),this.setupUpdateDataWebhookDebounce()}catch(I){this.loggingService.catch("Error in CrdtService constructor: ",I)}}setupUpdateDataWebhookDebounce(){try{this.updateDataWebhookDebounceSubscription&&(this.updateDataWebhookDebounceSubscription.unsubscribe(),this.updateDataWebhookDebounceSubscription=null,this.pendingWebhookEvent=null),this.updateDataWebhookDebounceSubscription=this.updateDataWebhookTrigger$.pipe(Qt(e=>{this.pendingWebhookEvent=e}),Bi(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 Q(this,arguments,function*({id:e,state:t,data:r}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateData","color: green;");let s=this.docService.getDocumentPaths(),c=this.authService.getUser(),p=this.domService.getTabId();if(c?.userId&&s){let g=Tt(e),f=c.userId,I=Tt(c.userId),x=new Date().toISOString(),B=null,z=this.configService.getEncryptionProvider();if(z?.encrypt&&typeof z.encrypt=="function")B=yield z.encrypt({data:t});else{let ve={};ve.customKey=g,B=yield Ed.encryptData(t,ve)}let G={id:e,veltId:g,encryptedState:B,lastUpdate:x,lastUpdatedBy:f,lastUpdatedByVeltUserId:I,sessionId:p},J={methodName:KW.UPDATE_DATA,uniqueId:vt(),timestamp:new Date().getTime(),source:YW.INTERNAL,payload:{id:e,data:r,lastUpdatedBy:f,sessionId:p,lastUpdate:x}},ne=yield this.commonDbService.updateData({feature:"crdtData",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:g,skipFirestore:!0},data:G});return this.crdtActionsService.triggerAction(qle.UPDATE_DATA,J),this.updateDataWebhookTrigger$.next(J?.payload),ne}return Promise.resolve(null)}catch(s){return this.loggingService.catch("Error in CrdtService updateData: ",s),Promise.resolve(null)}})}triggerUpdateDataWebhook(e){try{this.updateNotificationsDatabase(e,iz.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 r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"crdtData",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(fe(c=>Q(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.data.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.data.encryptedState,f)}c.data.state=p,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,delete c?.encryptedState}return c}}catch(p){return this.loggingService.catch("Error in CrdtService onDataChange subscription: ",p),null}}))):le(null))).subscribe(s=>{s&&(s.data?t(s.data):t(s))});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onDataChange: ",r),()=>{}}}getData(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getData","color: green;");let r=this.docService.getDocumentPaths();if(r){let a=Tt(e),s=yield this.commonDbService.getData({feature:"crdtData",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:a,skipFirestore:!0}});if(s?.encryptedState){let c=null,p=this.configService.getEncryptionProvider();if(p?.decrypt&&typeof p.decrypt=="function")c=yield p.decrypt({data:s.encryptedState});else{let g={};g.customKey=a,c=yield Ed.decryptData(s.encryptedState,g)}s.state=c,delete s?.encryptedState}return s}return Promise.resolve(null)}catch(r){return this.loggingService.catch("Error in CrdtService getData: ",r),Promise.resolve(null)}})}onStateChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onStateChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"crdtSyncState",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(fe(c=>Q(this,null,function*(){try{if(c?.data){if(c.data.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.data.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.data.encryptedState,f)}c.data.state=p,delete c.data?.encryptedState}return c}else{if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=r,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,delete c?.encryptedState}return c}}catch(p){return this.loggingService.catch("Error in CrdtService onStateChange subscription: ",p),null}}))):le(null))).subscribe(s=>{s&&(s.data?t(s.data):t(s))});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onStateChange: ",r),()=>{}}}updateState(r){return Q(this,arguments,function*({id:e,state:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: updateState","color: green;");let a=this.docService.getDocumentPaths(),s=this.authService.getUser(),c=this.domService.getTabId();if(s?.userId&&a){let p=Tt(e),g=s.userId,f=Tt(g),I=null,x=this.configService.getEncryptionProvider();if(x?.encrypt&&typeof x.encrypt=="function")I=yield x.encrypt({data:t});else{let B={};B.customKey=p,I=yield Ed.encryptData(t,B)}return this.commonDbService.setData({feature:"crdtSyncState",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:p,skipFirestore:!0},data:{id:e,veltId:p,encryptedState:I,lastUpdate:new Date().toISOString(),lastUpdatedBy:g,lastUpdatedByVeltUserId:f,sessionId:c}})}return Promise.resolve(null)}catch(a){return this.loggingService.catch("Error in CrdtService updateState: ",a),Promise.resolve(null)}})}registerSyncUser(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: registerSyncUser","color: green;");let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=this.configService.getApiKey(),c=Tt(e),p=this.domService.getTabId();if(r?.userId&&a&&s){let g=r.userId,f=Tt(g),I={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:f,apiKey:s,skipFirestore:!0},x={userId:g,veltUserId:f,status:"online",lastSeen:Date.now(),sessionId:p};yield this.commonDbService.setData({feature:"crdtSyncPresence",properties:I,data:x});let B=this.commonDbUtilsService.getDocumentPath({feature:"crdtSyncPresence",properties:I,defaultDocumentPaths:a,apiKey:s});B&&(yield this.commonDbService.setupOnDisconnect(B,{status:"offline",lastSeen:new Date().getTime(),sessionId:p}))}}catch(r){this.loggingService.catch("Error in CrdtService registerSyncUser: ",r)}})}onRegisteredUserChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onRegisteredUserChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"allCrdtSyncPresence",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(Qt(c=>{try{c?.data?t(c.data):t(c)}catch(p){this.loggingService.catch("Error in CrdtService onRegisteredUserChange subscription: ",p)}})):le(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onRegisteredUserChange: ",r),()=>{}}}setPresence(t){return Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: setPresence","color: green;");let r=this.authService.getUser(),a=this.docService.getDocumentPaths(),s=this.configService.getApiKey(),c=Tt(e),p=this.domService.getTabId();if(r?.userId&&a&&s){let g=r.userId,f=Tt(g),I={documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:c,userId:f,apiKey:s,skipFirestore:!0},x={userId:g,veltUserId:f,status:"online",lastSeen:Date.now(),sessionId:p};yield this.commonDbService.setData({feature:"crdtPresence",properties:I,data:x});let B=this.commonDbUtilsService.getDocumentPath({feature:"crdtPresence",properties:I,defaultDocumentPaths:a,apiKey:s});B&&(yield this.commonDbService.setupOnDisconnect(B,{status:"offline",lastSeen:new Date().getTime(),sessionId:p}))}}catch(r){this.loggingService.catch("Error in CrdtService setPresence: ",r)}})}onPresenceChange({id:e,callback:t}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: onPresenceChange","color: green;");let r=Tt(e),a=this.docService.getDocumentPaths$().pipe(fe(s=>s?this.commonDbService.dbListener({feature:"allCrdtPresence",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:r,skipFirestore:!0}}).pipe(Qt(c=>{try{c?.data?t(c.data):t(c)}catch(p){this.loggingService.catch("Error in CrdtService onPresenceChange subscription: ",p)}})):le(null))).subscribe(()=>{});return()=>a.unsubscribe()}catch(r){return this.loggingService.catch("Error in CrdtService onPresenceChange: ",r),()=>{}}}saveVersion(s){return Q(this,arguments,function*({id:e,versionId:t,versionName:r,state:a}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: saveVersion","color: green;");let c=this.docService.getDocumentPaths();if(c){let p=Tt(e),g="",f=this.configService.getEncryptionProvider();if(f?.encrypt&&typeof f.encrypt=="function")g=yield f.encrypt({data:a});else{let x={};x.customKey=p,g=yield Ed.encryptData(a,x)}let I={versionId:t,versionName:r,encryptedState:g,timestamp:new Date().getTime()};return this.commonDbService.setData({feature:"crdtVersion",properties:{documentId:c?.documentId??"",organizationId:c?.organizationId??"",id:p,versionId:t,skipFirestore:!0},data:E({id:e},I)})}return Promise.resolve(null)}catch(c){return this.loggingService.catch("Error in CrdtService saveVersion: ",c),Promise.resolve(null)}})}getVersion(r){return Q(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 s=Tt(e),c=yield this.commonDbService.getData({feature:"crdtVersion",properties:{documentId:a?.documentId??"",organizationId:a?.organizationId??"",id:s,versionId:t,skipFirestore:!0}});if(c?.encryptedState){let p=null,g=this.configService.getEncryptionProvider();if(g?.decrypt&&typeof g.decrypt=="function")p=yield g.decrypt({data:c.encryptedState});else{let f={};f.customKey=s,p=yield Ed.decryptData(c.encryptedState,f)}c.state=p,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 Q(this,arguments,function*({id:e}){try{this.loggingService.log("%c[WB] Calling CrdtService FUNCTION: getVersions","color: green;");let r=this.docService.getDocumentPaths();if(r){let a=Tt(e),s=yield this.commonDbService.getData({feature:"crdtVersions",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:a,skipFirestore:!0}}),c=null;if(s){c=[];for(let p of Object.values(s))if(p?.encryptedState){let g=null,f=this.configService.getEncryptionProvider();if(f?.decrypt&&typeof f.decrypt=="function")g=yield f.decrypt({data:p.encryptedState});else{let x={};x.customKey=a,g=yield Ed.decryptData(p.encryptedState,x)}let I=D(E({},p),{state:g});delete I?.encryptedState,c.push(I)}else c.push(p)}return c}return Promise.resolve(null)}catch(r){return this.loggingService.catch("Error in CrdtService getVersions: ",r),Promise.resolve(null)}})}updateNotificationsDatabase(e,t,r={}){try{let a=E({crdtData:e,actionType:t,notificationSource:"crdt"},r);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)}}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(un),ee(Im),ee(Ft),ee(V9),ee(ot),ee(Be),ee(_),ee(hn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var U9=class extends gi{constructor(o){super(o),this.getService(_).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.enableWebhook=this._enableWebhook,this.disableWebhook=this._disableWebhook,this.setWebhookDebounceTime=this._setWebhookDebounceTime,this.on=this._on}_updateData(o){this.getService(_).log("%c[WB] Calling FUNCTION: updateData","color: green;");try{return this.getService(ds).updateData(o)}catch(n){return this.getService(_).catch("Error in updateData: ",n),Promise.resolve(null)}}_onDataChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onDataChange","color: green;");try{return this.getService(ds).onDataChange(o)}catch(n){return this.getService(_).catch("Error in onDataChange: ",n),()=>{}}}_getData(o){this.getService(_).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.getService(ds).getData(o)}catch(n){return this.getService(_).catch("Error in getData: ",n),Promise.resolve(null)}}_onStateChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onStateChange","color: green;");try{return this.getService(ds).onStateChange(o)}catch(n){return this.getService(_).catch("Error in onStateChange: ",n),()=>{}}}_updateState(o){this.getService(_).log("%c[WB] Calling FUNCTION: updateState","color: green;");try{return this.getService(ds).updateState(o)}catch(n){return this.getService(_).catch("Error in updateState: ",n),Promise.resolve(null)}}_registerSyncUser(o){this.getService(_).log("%c[WB] Calling FUNCTION: registerSyncUser","color: green;");try{return this.getService(ds).registerSyncUser(o)}catch(n){return this.getService(_).catch("Error in registerSyncUser: ",n),Promise.resolve()}}_onRegisteredUserChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onRegisteredUserChange","color: green;");try{return this.getService(ds).onRegisteredUserChange(o)}catch(n){return this.getService(_).catch("Error in onRegisteredUserChange: ",n),()=>{}}}_setPresence(o){this.getService(_).log("%c[WB] Calling FUNCTION: setPresence","color: green;");try{return this.getService(ds).setPresence(o)}catch(n){return this.getService(_).catch("Error in setPresence: ",n),Promise.resolve()}}_onPresenceChange(o){this.getService(_).log("%c[WB] Calling FUNCTION: onPresenceChange","color: green;");try{return this.getService(ds).onPresenceChange(o)}catch(n){return this.getService(_).catch("Error in onPresenceChange: ",n),()=>{}}}_saveVersion(o){this.getService(_).log("%c[WB] Calling FUNCTION: saveVersion","color: green;");try{return this.getService(ds).saveVersion(o)}catch(n){return this.getService(_).catch("Error in saveVersion: ",n),Promise.resolve(null)}}_getVersion(o){this.getService(_).log("%c[WB] Calling FUNCTION: getVersion","color: green;");try{return this.getService(ds).getVersion(o)}catch(n){return this.getService(_).catch("Error in getVersion: ",n),Promise.resolve(null)}}_getVersions(o){this.getService(_).log("%c[WB] Calling FUNCTION: getVersions","color: green;");try{return this.getService(ds).getVersions(o)}catch(n){return this.getService(_).catch("Error in getVersions: ",n),Promise.resolve(null)}}_enableWebhook(){this.getService(_).log("%c[WB] Calling FUNCTION: enableWebhook","color: green;");try{return this.getService(ds).enableWebhook()}catch(o){this.getService(_).catch("Error in enableWebhook: ",o);return}}_disableWebhook(){this.getService(_).log("%c[WB] Calling FUNCTION: disableWebhook","color: green;");try{return this.getService(ds).disableWebhook()}catch(o){this.getService(_).catch("Error in disableWebhook: ",o);return}}_setWebhookDebounceTime(o){this.getService(_).log("%c[WB] Calling FUNCTION: setWebhookDebounceTime","color: green;");try{!isNaN(o)&&o>0?this.getService(ds).setWebhookDebounceTime(o):this.getService(_).catch("Error in setWebhookDebounceTime: ","Provided value must be a positive number greater than zero.")}catch(n){this.getService(_).catch("Error in setWebhookDebounceTime: ",n)}}_on(o){this.getService(_).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(V9).onAction(o)}catch(n){return this.getService(_).catch("Error in on: ",n),le(null)}}};var Ms=(function(i){return i.CLICK="click",i.HOVER="hover",i.SCROLL="scroll",i.NAVIGATE="navigate",i})(Ms||{}),Np=class{constructor(){this.type=Ms.HOVER,this.data=null,this.pageInfo=Ni(),this.timestamp=Date.now()}},j9=class{constructor(o,n){this.targetXpath=o,this.xpath=n}};var $9=class{constructor(){this.sessionId=null,this.isLeader=!1,this.lastProcessedActionTimestamp=null}};var Af=class{constructor(o){this.snippylyId=o,this.joinTimestamp=Date.now()}};var H9=class{constructor(o,n,e){this.followers=[],this.actionStack=[],this.id=vt(),this.leaderId=o,this.leaderName=n,this.followers.push(new Af(e))}};var age=(()=>{let o=class o{constructor(e,t,r,a,s){this.databaseService=e,this.docService=t,this.loggingService=r,this.authService=a,this.commonDbService=s,this.currentUser$=new Ce(null),this.currentSession$=new Ce(null);try{this.databaseService.getDb().pipe(Le(c=>!!c),rt(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,r){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(rt(1)).subscribe(s=>{s?.data&&s?.data?.sessionId?this.subscribeToCurrentSession(s?.data?.sessionId,r):this.createFlockSession(e,t,r)})}catch(a){this.loggingService.catch("Error in FlockSessionService provisionFlockSession: ",a)}return null}swapLeader(e,t,r){try{if(this.updateRemoteFlockUser(e,{isLeader:!1}),this.updateRemoteFlockUser(t,{isLeader:!0}),this.currentSession){this.currentSession.leaderId=t,this.currentSession.leaderName=r,this.currentSession.followers.push(new Af(e));let a=this.currentSession.followers.findIndex(s=>s.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,r){try{let a=new H9(e,t,r);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(r=>r.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 r=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];r&&this.db&&this.commonDbService.updateData({feature:"flockUser",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateRemoteFlockUser: ",r)}}subscribeToCurrentSession(e,t=void 0){try{let r=this.docService.getDocumentPaths();r&&this.db&&(this.sessionSub&&this.sessionSub.unsubscribe(),this.sessionSub=this.commonDbService.dbListener({feature:"flockSession",properties:{documentId:r?.documentId,organizationId:r?.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(s=>s.snippylyId===t)===-1&&(this.currentSession.followers.push(new Af(t)),this.updateSession(this.currentSession.id,this.currentSession)),this.currentSession$.next(this.currentSession??null)):(this.currentSession=void 0,this.currentSession$.next(null))}))}catch(r){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentSession: ",r)}}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(Un(r=>(this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",r),le(null)))).subscribe(r=>{r?.data&&typeof r?.data=="object"&&Object.keys(r?.data)?.length>0&&(this.currentUser$.next(r?.data),r?.data?.sessionId&&this.subscribeToCurrentSession(r?.data?.sessionId))},r=>{this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser subscription: ",r)}))}catch(t){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",t)}}updateSession(e,t={}){try{if(!e)return;let r=this.docService.getDocumentPaths();for(let a in t)t.hasOwnProperty(a)&&t[a]===void 0&&delete t[a];r&&this.db&&this.commonDbService.updateData({feature:"flockSession",properties:{documentId:r?.documentId??"",organizationId:r?.organizationId??"",id:e,skipFirestore:!0},data:JSON.parse(JSON.stringify(t))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateSession: ",r)}}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(r=>{this.updateRemoteFlockUser(r.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 r=this.docService.getDocumentPaths();if(r&&this.db&&e){let a=Ti(this.db,`${r.flock}/sessions/${e}/actionStack`);Kh(a,s=>s?(s.unshift(t),s.slice(0,5)):[t]),t.type===Ms.NAVIGATE&&this.updateSession(e,{pageInfo:t.pageInfo})}}catch(r){this.loggingService.catch("Error in FlockSessionService addActionToStack: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(In),ee(ot),ee(_),ee(je),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var sge={en:{"Action button":"Action button",Yes:"Yes",Delete:"Delete",Cancel:"Cancel","Delete thread?":"Delete thread?","All replies to this thread will be lost.":"All replies to this thread will be lost.","Delete comment?":"Delete comment?","This selected comment will be deleted.":"This selected comment will be deleted.","Delete recording?":"Delete recording?","This selected recording will be deleted.":"This selected recording will be deleted.","Delete area?":"Delete area?","This selected area will be deleted.":"This selected area will be deleted.","Delete arrow?":"Delete arrow?","This selected arrow will be deleted.":"This selected arrow will be deleted.","Delete tag?":"Delete tag?","This selected tag will be deleted.":"This selected tag will be deleted.","Contact us":"Contact us","Let us know how can we help you!":"Let us know how can we help you!","Your email address":"Your email address","How can we help?":"How can we help?",Send:"Send","Allow mic permission to":"Allow mic permission to","enable your audio":"enable your audio","1. Click the":"1. Click the","page info icon in your browser\u2019s address bar":"page info icon in your browser\u2019s address bar","2. Turn on Microphone":"2. Turn on Microphone","2. Turn on Camera":"2. Turn on Camera","Allow camera permission":"Allow camera permission","to enable your video":"to enable your video",dropdown:"dropdown","assign dropdown":"assign dropdown","custom dropdown":"custom dropdown","options dropdown":"options dropdown","priority dropdown":"priority dropdown","status dropdown":"status dropdown","seen dropdown":"seen dropdown",menu:"menu","assign menu":"assign menu","custom menu":"custom menu","options menu":"options menu","priority menu":"priority menu","status menu":"status menu","seen menu":"seen menu","menu items":"menu items","assign menu items":"assign menu items","custom menu items":"custom menu items","options menu items":"options menu items","priority menu items":"priority menu items","status menu items":"status menu items","seen menu items":"seen menu items","Playback Speed":"Playback Speed","Subtitles not available":"Subtitles not available","Transcription not available":"Transcription not available",Feedback:"Feedback","Provide feedback on your Superflow experience.":"Provide feedback on your Superflow experience.","Tell us the details...":"Tell us the details...","You are following":"You are following","You are leading.":"You are leading.",Stop:"Stop",following:"following",leading:"leading","is editing.":"is editing.","requested edit access.":"requested edit access.","You are editing.":"You are editing.","You are editing on different tab.":"You are editing on different tab.","Access Requested":"Access Requested","Request access":"Request access","Edit here":"Edit here",Settings:"Settings",Audio:"Audio",Microphone:"Microphone",Video:"Video",Camera:"Camera","Save changes":"Save changes","Audio settings":"Audio settings","No device found":"No device found","Video settings":"Video settings","Media source settings":"Media source settings","Audio recording preview":"Audio recording preview","Cancel recording":"Cancel recording","Video recording icon":"Video recording icon","Screen recording icon":"Screen recording icon","Audio recording icon":"Audio recording icon","Recording preview bottom panel":"Recording preview bottom panel","Starting recording in":"Starting recording in","Recording control buttons":"Recording control buttons","Toggle camera":"Toggle camera",off:"off",on:"on","Camera is off":"Camera is off","Close recording preview":"Close recording preview","Toggle microphone":"Toggle microphone",Close:"Close",Open:"Open","recording settings":"recording settings","Start Recording":"Start Recording","Report bugs":"Report bugs","Let us know about any bugs so we can fix them ASAP!":"Let us know about any bugs so we can fix them ASAP!","Thank you! We will get back to you soon.":"Thank you! We will get back to you soon.","Thank you for your feedback!":"Thank you for your feedback!","Thanks for reporting the bug. We will get back to you soon.":"Thanks for reporting the bug. We will get back to you soon.","Invitation sent!":"Invitation sent!","User removed!":"User removed!",members:"members","Invalid contact":"Invalid contact","Invalid email":"Invalid email","Comment pin":"Comment pin","Add text comment":"Add text comment","Add comment annotation":"Add comment annotation","Use AI to rewrite selected text":"Use AI to rewrite selected text","Select a shorter text":"Select a shorter text","Select a longer text":"Select a longer text",Rewrite:"Rewrite","Ask ChatGPT":"Ask ChatGPT","Text comment tools":"Text comment tools","Avatar for comment author":"Avatar for comment author","comments in this thread":"comments in this thread","Assign To":"Assign To","Attach files":"Attach files","Attach files input":"Attach files input","All comments":"All comments","View all comments":"View all comments","Approve comment":"Approve comment",Approve:"Approve","Assign thread":"Assign thread",Search:"Search","Search users":"Search users","Avatar for assigned user":"Avatar for assigned user","Assigned to":"Assigned to","Comment assignment details":"Comment assignment details","Assigned to:":"Assigned to:","Comment dialog thread":"Comment dialog thread","Close comment dialog":"Close comment dialog","Comment Index":"Comment Index",Suggestion:"Suggestion","Comment tools and actions":"Comment tools and actions","Mention someone using @ symbol":"Mention someone using @ symbol","Mention someone using @ symbol while editing":"Mention someone using @ symbol while editing","Type @ to mention someone":"Type @ to mention someone","Type @ to mention someone while editing":"Type @ to mention someone while editing","Add file attachment to comment":"Add file attachment to comment","Record voice message":"Record voice message","Click to start voice recording":"Click to start voice recording","Record video message":"Record video message","Click to start screen recording":"Click to start screen recording","Record your screen":"Record your screen","Save new comment":"Save new comment","Save edited comment":"Save edited comment","Assign user":"Assign user","Remove File":"Remove File","Image attachment:":"Image attachment:","unnamed image":"unnamed image","Actions for image:":"Actions for image:","Uploading image:":"Uploading image:","Delete image:":"Delete image:","Preview of image:":"Preview of image:","Remove invalid file:":"Remove invalid file:","Error message:":"Error message:","Invalid file:":"Invalid file:","Actions for invalid file:":"Actions for invalid file:","File error:":"File error:","File cannot be uploaded":"File cannot be uploaded","Preview of invalid file:":"Preview of invalid file:","Invalid file":"Invalid file",unknown:"unknown","Delete file":"Delete file","File attachment:":"File attachment:","unnamed file":"unnamed file","File type icon for":"File type icon for","Details for file:":"Details for file:","Filename:":"Filename:","File size:":"File size:","Uploading file:":"Uploading file:","Actions for file:":"Actions for file:","Remove file:":"Remove file:","Attached files":"Attached files","total attachments":"total attachments","File attachments":"File attachments",valid:"valid","invalid files":"invalid files","User avatar for":"User avatar for","unknown user":"unknown user","New comment composer":"New comment composer","Comment or type @ to add others":"Comment or type @ to add others","Write a comment...":"Write a comment...","Edit comment composer":"Edit comment composer","Comment or add emails with @":"Comment or add emails with @","Private comment mode - only visible to your team":"Private comment mode - only visible to your team","Only for your team":"Only for your team","Screen recording":"Screen recording",unnamed:"unnamed","Screen recording controls":"Screen recording controls","Edit comment section":"Edit comment section","Add new comment section":"Add new comment section","Custom annotation options":"Custom annotation options","Toggle annotation options":"Toggle annotation options","Annotation:":"Annotation:",Select:"Select","Remaining count:":"Remaining count:","Delete comment controls":"Delete comment controls","Delete this comment":"Delete this comment","Ghost comment notification":"Ghost comment notification","Original content not found.":"Original content not found.","Comment dialog header":"Comment dialog header","Comment dialog header controls":"Comment dialog header controls","Comment metadata":"Comment metadata","1 more reply":"1 more reply","more replies":"more replies","Show 1 more reply":"Show 1 more reply","Navigate to comment location":"Navigate to comment location","Assign comment":"Assign comment","Delete thread":"Delete thread","Delete comment":"Delete comment","Edit comment":"Edit comment",Edit:"Edit","Make it private":"Make it private","Make it public":"Make it public",Subscribe:"Subscribe",Unsubscribe:"Unsubscribe","priority level":"priority level","Priority name":"Priority name",P0:"P0",P1:"P1",P2:"P2","Selected priority:":"Selected priority:","Selected priority indicator":"Selected priority indicator","Priority:":"Priority:","Priority item":"Priority item","Thread priority:":"Thread priority:","Private comment banner":"Private comment banner","Resolve thread":"Resolve thread","Sign In":"Sign In","Status dropdown for":"Status dropdown for",comment:"comment","Status name:":"Status name:","Status option:":"Status option:","Status:":"Status:","Accept suggestion":"Accept suggestion",Accept:"Accept","Reject suggestion":"Reject suggestion",Reject:"Reject","Suggestion actions":"Suggestion actions","Delete Attachment":"Delete Attachment","Download Attachment":"Download Attachment",Attachment:"Attachment",preview:"preview","Image attachment controls":"Image attachment controls","Image attachment actions":"Image attachment actions","Delete attachment":"Delete attachment","Download attachment":"Download attachment","File name:":"File name:","Attachment:":"Attachment:",Attachments:"Attachments","Avatar for":"Avatar for",user:"user","Draft comment status":"Draft comment status",Draft:"Draft",Comment:"Comment","Comment by":"Comment by",Me:"Me","Comment reactions":"Comment reactions","Comment recordings":"Comment recordings","Name for":"Name for","Time for":"Time for","Seen by":"Seen by","Users who viewed this comment":"Users who viewed this comment","List of users who have seen this comment":"List of users who have seen this comment","Seen By":"Seen By","Comment viewers list":"Comment viewers list","Show comment viewers":"Show comment viewers","Comment viewers dropdown":"Comment viewers dropdown",now:"now",Unread:"Unread","Comment thread":"Comment thread","Comment content":"Comment content","Author information":"Author information","Author details and status":"Author details and status","Comment device information":"Comment device information","Inline mode metadata":"Inline mode metadata","Comment actions":"Comment actions","Reaction options":"Reaction options","Comment message":"Comment message",of:"of","Show more replies":"Show more replies",replies:"replies",Reply:"Reply",reply:"reply",Show:"Show","Show reply":"Show reply","Unresolve comment":"Unresolve comment","Upgrade plan":"Upgrade plan",Upgrade:"Upgrade","Copy link to comment":"Copy link to comment","Link Copied!":"Link Copied!","Copy thread link":"Copy thread link","Emoji reactions menu":"Emoji reactions menu","Open emoji reactions menu":"Open emoji reactions menu",Priority:"Priority","Private Comment":"Private Comment",Resolve:"Resolve",Unresolve:"Unresolve","Comment bubble":"Comment bubble","Multi-thread comment dialog":"Multi-thread comment dialog","Comment dialog":"Comment dialog","Comment bottom sheet":"Comment bottom sheet","Comment inbox container":"Comment inbox container","Single comment dialog":"Single comment dialog","Ghost comment indicator":"Ghost comment indicator","Private comment":"Private comment","Comment icon":"Comment icon","Exit comment mode":"Exit comment mode","to exit":"to exit",exit:"exit","Private Comment Mode":"Private Comment Mode","Comment Mode":"Comment Mode","Comment mode icon":"Comment mode icon","Comments stream view":"Comments stream view","Comments inbox":"Comments inbox","Comments location overview":"Comments location overview","Comments minimap":"Comments minimap","Go to comments here.":"Go to comments here.","Close comments sidebar":"Close comments sidebar","Add your first comment":"Add your first comment","No comments to display":"No comments to display","filter section":"filter section",All:"All","Close filter panel":"Close filter panel","Apply filters and close panel":"Apply filters and close panel",Done:"Done","checkbox checked":"checkbox checked","checkbox unchecked":"checkbox unchecked",items:"items","Current viewing page":"Current viewing page","This page":"This page",selected:"selected","not selected":"not selected",pages:"pages",people:"people",priorities:"priorities",statuses:"statuses",Filters:"Filters",versions:"versions","View All":"View All","View all":"View all","Comment filters":"Comment filters","Available filters":"Available filters","Apply or cancel filters":"Apply or cancel filters","Filter comments":"Filter comments","filters applied":"filters applied","Return to all comments":"Return to all comments","Back to all comments":"Back to all comments","Search through comments":"Search through comments","Filter and status controls":"Filter and status controls","Unknown user":"Unknown user","Comment dialog for":"Comment dialog for",Collapse:"Collapse",Expand:"Expand","comment group":"comment group",arrow:"arrow","Comments list with":"Comments list with","Location filter options":"Location filter options",Pages:"Pages","Filter comments by location":"Filter comments by location","menu expanded":"menu expanded","menu collapsed":"menu collapsed","Location filter dropdown":"Location filter dropdown","Mark all comments as read":"Mark all comments as read","Mark all as read":"Mark all as read","Mark as read":"Mark as read","Mark as unread":"Mark as unread",Reset:"Reset","Show open comments only":"Show open comments only","Mark all comments as resolved":"Mark all comments as resolved","Mark all as resolved":"Mark all as resolved","Bulk actions for comments":"Bulk actions for comments","Actions menu":"Actions menu",expanded:"expanded",collapsed:"collapsed","Comment actions dropdown":"Comment actions dropdown","Show unread and read comments":"Show unread and read comments","Unread and read":"Unread and read","Show read comments only":"Show read comments only","Read only":"Read only","Show resolved comments only":"Show resolved comments only",Resolved:"Resolved","Show unread comments only":"Show unread comments only","Unread only":"Unread only","Selected indicator":"Selected indicator","Sort comments by date":"Sort comments by date","Sort by date":"Sort by date","Sort comments by unread status":"Sort comments by unread status","Sort by unread":"Sort by unread","Sort and filter comments":"Sort and filter comments","custom filter applied":"custom filter applied","Comment filters and sorting":"Comment filters and sorting",filtered:"filtered","Page comment composer":"Page comment composer","Add a comment to the page":"Add a comment to the page","Comments and feedback panel":"Comments and feedback panel","Reset all comment filters":"Reset all comment filters","Clear filters":"Clear filters","Loading comments":"Loading comments","Comment status filters":"Comment status filters",status:"status","status icon":"status icon","Status filter options":"Status filter options","Status filter dropdown":"Status filter dropdown","Comments sidebar":"Comments sidebar","Comments panel":"Comments panel","Comment composer":"Comment composer","Comments section panel":"Comments section panel",Comments:"Comments","Loading Comments":"Loading Comments","Comments section":"Comments section","No comments found for applied filters.":"No comments found for applied filters.","Comments list":"Comments list","Comment actions menu":"Comment actions menu","More actions":"More actions","Filter and sort options":"Filter and sort options","Collapse threads":"Collapse threads","Comments dialog":"Comments dialog","Clear all filters":"Clear all filters","Comments information":"Comments information","Toggle comments sidebar":"Toggle comments sidebar","Click to mute":"Click to mute","Click to unmute":"Click to unmute","Stop sharing":"Stop sharing","Share screen":"Share screen","Invite users to join this huddle":"Invite users to join this huddle","Please select a contact to invite":"Please select a contact to invite","Chat with everyone":"Chat with everyone","Enable audio or video to change the settings":"Enable audio or video to change the settings","Change audio/video settings":"Change audio/video settings",Leave:"Leave","In-call messages":"In-call messages","Type here...":"Type here...","Audio Huddle":"Audio Huddle","Video Huddle":"Video Huddle","Screen Huddle":"Screen Huddle","1 person is":"1 person is","people are":"people are","on a call now":"on a call now","You can join the call":"You can join the call","Stop Sharing":"Stop Sharing","is sharing now.":"is sharing now.",You:"You","Close notifications panel":"Close notifications panel","Notification item":"Notification item","All notifications list":"All notifications list","All notifications":"All notifications","All notifications read":"All notifications read","Document notification":"Document notification","Document name:":"Document name:",Untitled:"Untitled","Document ID:":"Document ID:",Document:"Document","unread notifications":"unread notifications","Document notifications panel":"Document notifications panel","For you notifications panel":"For you notifications panel","Notification message:":"Notification message:","Notification headline:":"Notification headline:","Notification time:":"Notification time:","Unread notification":"Unread notification",Notification:"Notification",unread:"unread",read:"read",Load:"Load","more notifications":"more notifications","Load More":"Load More","User notifications for":"User notifications for",notification:"notification",notifications:"notifications",available:"available",Notifications:"Notifications","User:":"User:","People notifications panel":"People notifications panel",Documents:"Documents","For You":"For You",People:"People","Notification categories":"Notification categories","Mark all notifications as read":"Mark all notifications as read","Notification actions":"Notification actions","View all notifications":"View all notifications","Notifications panel":"Notifications panel","Notifications bell icon - no unread notifications":"Notifications bell icon - no unread notifications","Notifications count":"Notifications count","Notification bell with":"Notification bell with","User online":"User online","mins ago.":"mins ago.","Reaction count":"Reaction count","Reaction with":"Reaction with","Reaction by":"Reaction by","Users who reacted":"Users who reacted","Reaction details":"Reaction details","React with":"React with",emoji:"emoji","Choose a reaction":"Choose a reaction","Available reactions":"Available reactions","Add reaction":"Add reaction","Reaction selector":"Reaction selector","Start audio recording":"Start audio recording","Audio Recording":"Audio Recording","Screen Recording":"Screen Recording","Start video recording":"Start video recording","Video Recording":"Video Recording","Recording options menu":"Recording options menu","Available recording types":"Available recording types",Record:"Record","Record audio":"Record audio","Record screen":"Record screen","Record video":"Record video","Recording controls for":"Recording controls for",recording:"recording","Stop recording":"Stop recording","Recording duration":"Recording duration","Resume recording":"Resume recording","Pause recording":"Pause recording","Currently recording:":"Currently recording:",none:"none","Audio waveform visualization":"Audio waveform visualization","Currently recording":"Currently recording","Recording paused":"Recording paused","Recording information":"Recording information","Recording controls":"Recording controls","Expand recording panel":"Expand recording panel","Collapse recording panel":"Collapse recording panel","Floating mode container for":"Floating mode container for","Screen recording preview":"Screen recording preview","Expanded view":"Expanded view","Mini preview":"Mini preview","Recording control panel":"Recording control panel","Draggable recording panel":"Draggable recording panel","Currently saving recording":"Currently saving recording","Saving Recording...":"Saving Recording...",Paused:"Paused","Video preview":"Video preview","Screen recording panel":"Screen recording panel","Draggable recording controls":"Draggable recording controls","Video recording preview":"Video recording preview","recording player":"recording player",Draggable:"Draggable",player:"player","recording pin":"recording pin","Created by":"Created by",Play:"Play","Draggable recording pin by":"Draggable recording pin by","Recording player":"Recording player","Audio recording":"Audio recording","Audio player":"Audio player","Audio player controls":"Audio player controls","Audio content and controls":"Audio content and controls","Playback controls":"Playback controls","Playback time":"Playback time","Audio waveform":"Audio waveform",Subtitles:"Subtitles","Additional controls and information":"Additional controls and information","Pause button":"Pause button","Pause audio":"Pause audio","Play audio":"Play audio","Audio progress":"Audio progress","Copy link to recording":"Copy link to recording","Delete recording":"Delete recording","Enter full screen mode":"Enter full screen mode","Recording name:":"Recording name:","Untitled recording":"Untitled recording","Recording player controls":"Recording player controls","Pause video":"Pause video","Play video":"Play video","Video subtitles":"Video subtitles","Toggle subtitles":"Toggle subtitles","Seek video playback":"Seek video playback","Video playback controls":"Video playback controls","Video transcription":"Video transcription","Video player":"Video player","Video player container":"Video player container","Video player with controls":"Video player with controls","Video information and controls":"Video information and controls","Video transcription summary":"Video transcription summary","Fullscreen video player":"Fullscreen video player","Expanded video player":"Expanded video player","Getting data ...":"Getting data ...","Get more options":"Get more options","Max 3 rewrites allowed":"Max 3 rewrites allowed",left:"left","Show original text":"Show original text","Select a rewritten text to create a task":"Select a rewritten text to create a task","Create Task":"Create Task","How would you like to change this copy?":"How would you like to change this copy?",Suggestions:"Suggestions","Selected users":"Selected users","additional users":"additional users",Reassign:"Reassign",Remove:"Remove","Please select a contact to assign":"Please select a contact to assign",Summary:"Summary","see more":"see more","see less":"see less","Invite users":"Invite users","No users are added.":"No users are added.",Invited:"Invited","General access":"General access","Copy Link":"Copy Link","Send invite":"Send invite","Go Back":"Go Back","Total Views":"Total Views","Views Today":"Views Today",View:"View",Views:"Views",Today:"Today","Search comments":"Search comments","In Progress":"In Progress",Status:"Status","Not set":"Not set","Comment Type":"Comment Type",Public:"Public",Private:"Private","Group By":"Group By","Assigned to Me":"Assigned to Me","Added by Me":"Added by Me",Other:"Other",Desktop:"Desktop",Mobile:"Mobile",Tablet:"Tablet",Others:"Others","Default - MacBook Pro Microphone (Built-in)":"Default - MacBook Pro Microphone (Built-in)","iPhone Microphone":"iPhone Microphone","MacBook Pro Microphone (Built-in)":"MacBook Pro Microphone (Built-in)","Sorting options":"Sorting options","Created First":"Created First","Created Last":"Created Last","Updated First":"Updated First","Updated Last":"Updated Last"}};var Ll=(()=>{let o=class o{constructor(e){this.loggingService=e,this.currentLanguageSignal=xe(navigator.language.split("-")[0]),this.autoTranslationSignal=xe(!1),this.translationsMap=new Map,this.translationCache=new Map,this.translationsUpdateSignal=xe(0),this.currentLanguage=this.currentLanguageSignal.asReadonly(),this.autoTranslation=this.autoTranslationSignal.asReadonly(),this.translationsVersion=this.translationsUpdateSignal.asReadonly(),this.currentTranslations=ki(()=>{let t=this.currentLanguageSignal(),r=this.translationsUpdateSignal();return this.translationsMap.get(t)||{}}),this.loggingService.log("%c[WB] Calling FUNCTION: constructor","color: green;"),this.setTranslations(sge),lo(()=>{let t=this.currentLanguageSignal();this.translationCache.clear(),this.translationsUpdateSignal.update(r=>r+1)},{allowSignalWrites:!0})}translate(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: translate","color: green;");let t=this.currentLanguageSignal(),r=this.translationsUpdateSignal(),a=`${t}:${e}:${r}`,s=this.translationCache.get(t);if(s?.has(a))return s.get(a)||e;let c=this.currentTranslations()[e];return this.translationCache.has(t)||this.translationCache.set(t,new Map),this.translationCache.get(t)?.set(a,c||e),oC(c)?e:c}catch{return e}}setTranslations(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setTranslations","color: green;");let t=!1;Object.entries(e).forEach(([r,a])=>{if(a&&typeof a=="object"){let s=this.translationsMap.get(r)||{};Object.keys(a).forEach(p=>{s.hasOwnProperty(p)||(t=!0)});let c=E(E({},s),a);this.translationsMap.set(r,c),this.translationCache.delete(r)}}),this.translationsUpdateSignal.update(r=>r+1),t&&setTimeout(()=>{this.translationsUpdateSignal.update(r=>r+1)},0)}catch(t){this.loggingService.catch("Error in setTranslations: ",t)}}setLanguage(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLanguage","color: green;"),this.currentLanguageSignal.set(e)}catch(t){this.loggingService.catch("Error in setLanguage: ",t)}})}enableAutoTranslation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableAutoTranslation","color: green;"),this.autoTranslationSignal.set(!0)}catch(e){this.loggingService.catch("Error in enableAutoTranslation: ",e)}}disableAutoTranslation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableAutoTranslation","color: green;"),this.autoTranslationSignal.set(!1),this.translationCache.clear()}catch(e){this.loggingService.catch("Error in disableAutoTranslation: ",e)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ge=(()=>{let o=class o{constructor(e,t){this.domService=e,this.translateService=t,this.sanitizedCache=new Map}transform(e){if(e==null)return"";let t=typeof e=="boolean"||typeof e=="number"?String(e):e;try{let r=this.translateService.currentLanguage(),a=this.translateService.translationsVersion(),s=`${r}:${t}:${a}`,c=this.sanitizedCache.get(s);if(c)return c;let p=this.translateService.translate(t),g=this.domService.sanitizeHtml(p);return this.sanitizedCache.set(s,g),this.sanitizedCache.size>1e3&&this.sanitizedCache.clear(),g}catch(r){return console.warn("Translation error:",r),t}}};o.\u0275fac=function(t){return new(t||o)(h(Be,16),h(Ll,16))},o.\u0275pipe=Ui({name:"translate",type:o,pure:!0,standalone:!1});let i=o;return i})();function zFe(i,o){if(i&1&&(y(0,"span",6),te(1),P(2,"translate"),b()),i&2){let n=l(2).ngIf;m(),br("",M(2,2,"You are following")," ",n.leaderName)}}function GFe(i,o){i&1&&(y(0,"span",6),te(1),P(2,"translate"),b()),i&2&&(m(),ze(M(2,1,"You are leading.")))}function WFe(i,o){if(i&1){let n=K();y(0,"div",2),W("click",function(){N(n);let t=l().ngIf,r=l();return F(t.type==="following"?r.closeOverlay():void 0)}),y(1,"div",3),u(2,zFe,3,4,"span",4)(3,GFe,3,3,"span",4),y(4,"button",5),W("click",function(){N(n);let t=l(2);return F(t.closeOverlay())}),te(5),P(6,"translate"),P(7,"translate"),b()()()}if(i&2){let n=l().ngIf;pe("no-pointer",n.type==="leading"),m(2),d("ngIf",n.type==="following"),m(),d("ngIf",n.type==="leading"),m(2),br("",M(6,6,"Stop")," ",M(7,8,n.type))}}function qFe(i,o){if(i&1&&(v(0),u(1,WFe,8,10,"div",1),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.leaderName!==""||n.type==="leading")}}var dq=(()=>{let o=class o extends nt{closeOverlay(){this.closeOverlayEvent.emit()}constructor(e,t,r){super(t,r),this.loggingService=e,this.elementRef=t,this.themeService=r,this.closeOverlayEvent=new Me,this.componentConfigSignal=xe({leaderName:"",type:"following"})}ngOnInit(){}setLeaderName(e){try{this.componentConfigSignal.update(t=>(t=D(E({},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=D(E({},t),{type:e}),t))}catch(t){this.loggingService.catch("Error in FollowOverlayComponent setType: ",t)}}ngOnDestroy(){try{super.ngOnDestroy()}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(R),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["snippyly-follow-overlay"]],outputs:{closeOverlayEvent:"closeOverlayEvent"},standalone:!1,features:[L],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,r){t&1&&u(0,qFe,2,1,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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}.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}
|
|
486
486
|
`],encapsulation:3,changeDetection:0});let i=o;return i})();var lge=(()=>{let o=class o{constructor(e,t,r,a){this.componentFactoryResolver=e,this.applicationRef=t,this.injector=r,this.loggingService=a,this.darkMode=!1}createFollowOverlay(e,t){try{let a=this.componentFactoryResolver.resolveComponentFactory(dq).create(this.injector);a.instance.setLeaderName(e),a.instance.closeOverlayEvent.pipe(rt(1)).subscribe(()=>{this.removeOverlay(),t()}),this.applicationRef.attachView(a.hostView),this.overlayRef=a,this.overlayRef.instance.darkMode=this.darkMode;let s=this.overlayRef.location.nativeElement;s.id="snippyly-follow-overlay",s.setAttribute(U.ATTRIBUTES.VELT_IGNORE,""),document.body.appendChild(s)}catch(r){this.loggingService.catch("Error in FlockOverlayService createFollowOverlay: ",r)}}createLeaderOverlay(e){let r=this.componentFactoryResolver.resolveComponentFactory(dq).create(this.injector);r.instance.setType("leading"),r.instance.closeOverlayEvent.pipe(rt(1)).subscribe(()=>{this.removeOverlay(),e()}),this.applicationRef.attachView(r.hostView),this.overlayRef=r,this.overlayRef.instance.darkMode=this.darkMode;let a=this.overlayRef.location.nativeElement;a.id="snippyly-follow-overlay",a.setAttribute(U.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)(ee(ko),ee(ii),ee(St),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var xd=(()=>{let o=class o{constructor(e,t,r,a,s){this.authService=e,this.domService=t,this.loggingService=r,this.flockSessionService=a,this.flockOverlayService=s,this.flockLeader$=new Ce({userId:"",name:""}),this.flockMode$=new Ce(!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:p,name:g}=c,f=p;if(this.provisionFollowUser(),f&&this.currentFlockUser&&this.currentFlockUser.snippylyId)if(this.currentFlockUser.sessionId){if(this.currentFlockUser.snippylyId&&this.currentFlockUser.isLeader){this.flockSessionService.swapLeader(this.currentFlockUser.snippylyId,f,g);return}this.removeCurrentUserFromSession()}else this.flockSessionService.provisionFlockSession(f,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 p=c.actionStack[0];p&&this.currentFlockUser.lastProcessedActionTimestamp!==p.timestamp&&this.processAction(p)}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 p=Ni();if(c.pageInfo){if(p&&p.url!==c.pageInfo.url){let g=new Np;g.type=Ms.NAVIGATE,this.flockSessionService.addActionToStack(c.id,g)}}else{this.flockSessionService.updateSession(c.id,{pageInfo:p});let g=new Np;g.type=Ms.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(p=>p.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,p])=>{c&&c.userSnippylyId&&p?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 $9,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(r){this.loggingService.catch("Error in FlockService startFollowingUser: ",r)}}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=(...r)=>{e.apply(window.history,r),this.onUrlChange()},window.history.replaceState=(...r)=>{t.apply(window.history,r),this.onUrlChange()},this.domSubscriptions.push({unsubscribe:()=>{window.history.pushState=e,window.history.replaceState=t}}),this.domSubscriptions.push(vi(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 Np;e.type=Ms.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 Ms.CLICK:this.clickUserElement(e.data);break;case Ms.HOVER:this.scrollToHoveredElement(e.data);break;case Ms.SCROLL:this.scrollToFollowedUser(e.data);break;case Ms.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(vi(window,"mouseover").pipe(Bi(500)).subscribe(e=>{let t=e?.target;if(t){let r=window.getComputedStyle(t);if(r.position==="fixed"||r.position==="sticky"||t.hasAttribute(U.ATTRIBUTES.VELT_IGNORE))return;t=gz(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(U.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),r=tC(e),a=this.domService.getXPath(r),s={id:Math.random().toString(36).substring(2),xpath:t,parentXpath:a},c=new Np;c.type=Ms.CLICK,c.data=s,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),r=tC(e),a=this.domService.getXPath(r),s={id:Math.random().toString(36).substring(2),xpath:t,parentXpath:a},c=new Np;c.type=Ms.HOVER,c.data=s,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,c)}}catch(t){this.loggingService.catch("Error in FlockService updateHoveredElement: ",t)}}subscribeToScrollables(){try{let e=dce();e.push(document),e?.forEach(t=>{this.domSubscriptions.push(vi(t,"scroll").pipe(Bi(100)).subscribe(r=>{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 j9("","");if(e===document){let s=gce();if(s){let c=gz(s);c&&(t.targetXpath=this.domService.getXPath(c))}t.xpath=""}else{let s=pce(e);t.targetXpath=this.domService.getXPath(s),t.xpath=this.domService.getXPath(e)}let r=!1,a=!1;if(this.localScrollData.forEach((s,c)=>{s.xpath===s.xpath&&(t.targetXpath!==s.targetXpath&&(r=!0),this.localScrollData[c]=Object.assign(s,t),a=!0)}),a||this.localScrollData.push(t),r||!a){let s=new Np;s.type=Ms.SCROLL,s.data=t,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,s)}}}catch(t){this.loggingService.catch("Error in FlockService calculateScrollPositionOfAnElement: ",t)}}enableFlockMode(e){try{if(this.flockMode$.next(!0),e){let{useHistoryAPI:t,onNavigate:r,disableDefaultNavigation:a,darkMode:s}=e;t!==void 0&&(this.useHistoryAPI=t),r!==void 0&&typeof r=="function"&&(this.onNavigate=r),a!==void 0&&(this.disableDefaultNavigation=a),this.flockOverlayService.setDarkMode(s)}}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(r=>{r.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(r=>{r.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(r){this.loggingService.catch("Error in FlockService setFlockLeader: ",r)}}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 r=Ni()?.url,a=e.url;if(r!==a&&a!==void 0){let{url:s,path:c,baseUrl:p}=e;if(this.onNavigate!==void 0&&typeof this.onNavigate=="function"){this.onNavigate({url:s,path:c,baseUrl:p});return}if(this.onNavigateEmitter&&this.onNavigateEmitter.emit({url:s,path:c,baseUrl:p}),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&&Zk(t)}else{let t=this.domService.getElementFromXPath(e.xpath),r=this.domService.getElementFromXPath(e.targetXpath);t&&r&&(Zk(t),uz(t,r))}}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")Zk(t);else{let r=this.domService.getElementFromXPath(e.parentXpath);r&&uz(r,t,!0)}}catch(t){this.loggingService.catch("Error in FlockService clickUserElement: ",t)}}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Be),ee(_),ee(age),ee(lge))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var vc=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B){this.analyticsService=e,this.docService=t,this.domService=r,this.authService=a,this.afAuth=s,this.iamService=c,this.databaseService=p,this.configService=g,this.avatarService=f,this.loggingService=I,this.flockService=x,this.commonDbService=B,this.db=Is(),this.presenceUser$=new Ce(new m9),this.documentPaths=null,this.inactivityTime=300*1e3,this.offlineInactivityTime=600*1e3,this.presenceUsers$=new Ce([]),this.presenceUsersSubscription=null,this.includeSelf$=new Ce(!0),this.userIdleStateDetectionSubscription=null,this.userOfflineStateDetectionSubscription=null;try{this.loggingService.log("%c[WB] Creating CLASS: PresenceService","color: blue;"),this.databaseService.getDb().pipe(Le(z=>!!z),rt(1)).subscribe(z=>{z&&(this.db=z,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},G=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",G)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},G=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",G)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange())},z=>{this.loggingService.catch("Error in PresenceService constructor: ",z)}),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(Oi()).subscribe(([z,G])=>{try{G?.length>=0&&this.analyticsService.updateDefaultProperties({presenceUsersCount:G?.length}),sessionStorage.getItem(U.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE)||G?.length>1&&z.length!==G.length&&(sessionStorage.setItem(U.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE,"true"),this.presenceActionsService?.onMultipleUsersOnline({users:G}))}catch(J){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",J)}}),this.authService.getUser$().pipe(Le(z=>!!z),rt(1)).subscribe(z=>{z?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(z=>{try{z?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(z)),state:z?.onlineStatus})}catch(G){this.loggingService.catch("Error in presenceUser$ subscription: ",G)}},z=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",z)}),this.domService.onNetworkStatusChange$().subscribe(z=>{try{!z&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:D(E({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:U.PRESENCE_STATUS_OFFLINE}),state:U.PRESENCE_STATUS_OFFLINE})}catch(G){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",G)}},z=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",z)})}catch(z){this.loggingService.catch("Error in PresenceService constructor: ",z)}}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(Yp(2e3),Qt(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(U.PRESENCE_STATUS_ONLINE),e=!1)}),Bi(this.inactivityTime),Qt(()=>{this.setCurrentPresenceUserStatus(U.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(Yp(2e3),Bi(this.offlineInactivityTime),Qt(()=>{this.setCurrentPresenceUserStatus(U.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(Le(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(Qt(e=>{this.documentPaths=e}),Oi(),Qt(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(U.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(U.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(Qt(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;"),ei(this.afAuth).pipe(Le(t=>!!t),fe(t=>this.isFeatureAllowed({firebaseUser:t,users:[],filteredUsers:[]})),fe(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(de(r=>(t.featureAllowed=r,t))):le(t)),fe(t=>t.featureAllowed?this.authService.isPlanExpired$().pipe(de(r=>(t.featureAllowed=!r,t))):le(t)),fe(t=>t.featureAllowed?le(t).pipe(fe(r=>this.docService.getDocumentPaths$().pipe(de(a=>(this.documentPaths=a,r.documentPaths=a,r)))),fe(r=>this.getDataFromDocumentId(e).pipe(de(a=>(r.users=a||[],E({},r))))),de(r=>(e?e?.statuses?.length?r.filteredUsers=r?.users?.filter(a=>e?.statuses?.includes(a?.onlineStatus)):r.filteredUsers=r?.users?.slice():r.filteredUsers=this.filterOnlineUsers(r.users,r.firebaseUser),r)),fe(r=>this.getIncludeSelf$().pipe(de(a=>(a||(r.filteredUsers=r?.filteredUsers?.filter(s=>s?.userSnippylyId!==r.user?.userSnippylyId)),r)))),fe(r=>r?.filteredUsers?le(r?.filteredUsers||[]):le([]))):le([])),Ct(Xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.PRESENCE)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),fe(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.presence){let r=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:[Yh("timestamp"),E0(r)]}}).pipe(Un(a=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",a),le(null))),de(a=>a?.data),de(a=>{let s=[];return a&&(s=Object.values(a).filter(c=>typeof c=="object")),s}))}else return le([])}))}filterOnlineUsers(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(s=>{let c=$g(s.timestamp);return s.userSnippylyId&&(s.onlineStatus===U.PRESENCE_STATUS_ONLINE||s.onlineStatus===U.PRESENCE_STATUS_AWAY)&&c<this.offlineInactivityTime});return this.presenceUsers$.next(a),a}catch(r){return this.loggingService.catch("Error in filterOnlineUsers:",r),[]}}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(r=>r.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 Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateCurrentPresenceUser","color: green;");try{if(this.documentPaths?.presence&&e&&e.userId&&this.authService.isFeatureAllowed(Ne.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new ho,e?.onlineStatus===U.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(D(E({},t),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentPresenceUser:",t)}})}setCurrentPresenceUserStatus(e,t){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setCurrentPresenceUserStatus","color: green;");try{this.loggingService.log(e);let r=this.presenceUser$.value;if(r.onlineStatus!==e){this.presenceUsersSubscription&&this.presenceUsersSubscription?.unsubscribe();let a=r.onlineStatus,s=e;this.presenceUsersSubscription=this.getPresenceUsers$().pipe(Le(c=>!!c?.length),rt(1)).subscribe(c=>{c?.length>1&&this.analyticsService.trackEvent(Y.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:s,totalUsers:c?.length,presenceSnippylyUserIds:c?.map(p=>p.userSnippylyId),presenceClientUserIds:c?.map(p=>p.userId)})})}r.onlineStatus=e,t&&(r.isTabAway=t?.isTabAway,r.isUserIdle=t?.isUserIdle),e===U.PRESENCE_STATUS_ONLINE&&(r.isTabAway=!1,r.isUserIdle=!1),e===U.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.updateCurrentPresenceUser(r)}catch(r){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",r)}})}updateUserStatusOnDocumentChange(e,t){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let r=this.presenceUser$.value;if(r.onlineStatus=e,t?.presence&&r&&r.userId&&!r.isAnonymous&&this.authService.isFeatureAllowed(Ne.PRESENCE)){let a=JSON.parse(JSON.stringify(r));this.commonDbService.updateData({feature:"presence",properties:{documentId:t?.documentId,organizationId:t?.organizationId,userId:r.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}catch(r){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",r)}})}updateUserOnLocationChange(e){return Q(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(Ne.PRESENCE)){let r=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(r))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=Ti(this.db,".info/connected"),t=kM(e).pipe(de(r=>r?U.PRESENCE_STATUS_ONLINE:U.PRESENCE_STATUS_OFFLINE));return ei(this.afAuth).pipe(ml(1),fe(r=>r?t:le(U.PRESENCE_STATUS_OFFLINE)),Qt(r=>this.setCurrentPresenceUserStatus(r)))}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(U.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(U.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(U.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(U.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,r=!1;if(e.featureAllowList.includes(Ne.PRESENCE)?t?.onlineStatus!==U.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=U.PRESENCE_STATUS_ONLINE,r=!0):t?.onlineStatus!==U.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=U.PRESENCE_STATUS_OFFLINE,r=!0),r&&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;"),ei(this.afAuth).pipe(Le(e=>!!e),fe(e=>this.docService.getDocumentPaths$().pipe(de(t=>e))),Qt(e=>Q(this,null,function*(){try{if(this.documentPaths?.presence&&e){let t=yield td(e,!0).catch(a=>null);if(!t)return;let{user:r}=t.claims;if(!r?.isAnonymous&&this.documentPaths?.presence){this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession();let a=`${this.documentPaths.presence}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:U.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp}).catch(s=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",s)})}}}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 r=e?.name?.split(" ");if(r&&r.length>0){let a=r[0],s=r.length>1?r[r.length-1]:null,c=s?s[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,r)=>{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:s=>{r(s)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(D(E({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:U.PRESENCE_STATUS_OFFLINE})))})),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),r(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),r(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()}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(ot),ee(Be),ee(je),ee(Ri),ee(En),ee(In),ee(Ft),ee(ym),ee(_),ee(xd),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var KC=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x){this.analyticsService=e,this.configService=t,this.presenceService=r,this.docService=a,this.afAuth=s,this.iamService=c,this.domService=p,this.databaseService=g,this.authService=f,this.loggingService=I,this.commonDbService=x,this.cursorUser$=new Ce(new NC),this.documentPaths=null,this.inactivityTime=120*1e3,this.allowedElementIds$=new Ce([]),this.cursorTagAvailable$=new Ce(!1),this.cursorTagAvailable=!1,this.cursorUsers$=new Ce([]),this.loggingService.log("%c[WB] Creating CLASS: CursorService","color: blue;");try{this.checkCursorTagAvailable(),this.databaseService.getDb().pipe(Le(B=>!!B),fe(B=>this.cursorTagAvailable$.pipe(Le(z=>!!z),rt(1),de(()=>B))),rt(1)).subscribe(B=>{B&&this.cursorTagAvailable&&(this.getPresenceUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnDatabaseDisconnect().subscribe(()=>{},z=>{this.loggingService.catch("Error in CursorService constructor updateOnDatabaseDisconnect: ",z)}),this.addMouseMoveListener(),this.addScreenSizeChangeListener(),this.updateOnAllowedFeatureListChange())},B=>{this.loggingService.catch("Error in CursorService constructor getDb: ",B)}),this.cursorUsers$.pipe(Oi()).subscribe(([B,z])=>{sessionStorage.getItem(U.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED)||z?.length>1&&B.length!==z.length&&(this.analyticsService.trackEvent(Y.Events.Cursor.CURSOR_MULTIPLE_USERS_DETECTED,{totalUsers:z.length,cursorSnippylyUserIds:z.map(G=>G.userSnippylyId),cursorClientUserIds:z.map(G=>G.userId)}),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED,"true"))}),this.authService.addPreSignOutFuction("cursor-signout",this.signOutUser.bind(this))}catch(B){this.loggingService.catch("Error in CursorService constructor: ",B)}}checkCursorTagAvailable(){this.loggingService.log("%c[WB] Calling FUNCTION: checkCursorTagAvailable","color: green;");try{this.cursorTagAvailable=!!document.querySelector(U.TAGS.VELT_CURSOR)||!!document.querySelector(U.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(Le(e=>!!e),fe(e=>this.domService.getCurrentWindowSize$("CursorService addScreenSizeChangeListener").pipe(Le(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(Yp(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(Qt(e=>{this.documentPaths=e}),Oi(),Qt(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(U.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(U.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(Qt(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(Le(e=>!!e),Un(e=>le(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;"),ei(this.afAuth).pipe(Le(e=>!!e),fe(e=>this.isFeatureAllowed({firebaseUser:e,users:[],filteredUsers:[]})),fe(e=>e.featureAllowed?this.iamService.isUserAllowed$().pipe(de(t=>(e.featureAllowed=t,e))):le(e)),fe(e=>e.featureAllowed?this.authService.isPlanExpired$().pipe(de(t=>(e.featureAllowed=!t,e))):le(e)),fe(e=>!e.featureAllowed||e?.user?.isAnonymous?le([]):le(e).pipe(fe(t=>this.docService.getDocumentPaths$().pipe(de(r=>(this.documentPaths=r,t.documentPaths=r,t)))),fe(t=>this.getDataFromDocumentId().pipe(de(r=>(t.users=r||[],E({},t))))),de(t=>(t.filteredUsers=this.filterOnlineUsers(t.users,t.firebaseUser),t)),fe(t=>t?.filteredUsers?.length?this.domService.getCurrentWindowSize$("CursorService getLiveCursorsOnCurrentDocument").pipe(de(()=>t)):le(t)),de(t=>(t?.filteredUsers?.forEach(r=>{this.calculateCursorUserPosition(r)}),t)),fe(t=>t?.filteredUsers?le(t?.filteredUsers||[]):le([])))))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),fe(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),fe(t=>ao(t.config,t.user,Ne.CURSOR)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Cursor feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))),Ct((t,r)=>t?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),fe(t=>{if(this.configService?.getApiKey()&&this.documentPaths?.cursor){let r=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:[Yh("timestamp"),E0(r)]}}).pipe(Un(a=>(this.loggingService.catch("Error in CursorService getDataFromDocumentId: ",a),le(null))),de(a=>a?.data),de(a=>{let s=[];return a&&(s=Object.values(a).filter(c=>typeof c=="object")),s}))}else return le([])}))}calculateCursorUserPosition(e){try{if(e?.targetElement){let t=this.domService.getXPath(e.targetElement?.xpath);if(t){let r=t.iterateNext();if(r&&this.isElementInsideAllowedElements(r)){let a=r.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 p=$g(c.timestamp);return c.userSnippylyId&&c.onlineStatus===U.PRESENCE_STATUS_ONLINE&&p<this.inactivityTime});this.cursorUsers$.next(a),a=a.filter(c=>c?.userSnippylyId!==t?.uid);let s=this.docService.getLocation();return s&&s.locationId?a=a.filter(c=>c.locationId===s.locationId):a=a.filter(c=>!c.locationId),a}catch(r){return this.loggingService.catch("Error in filterOnlineUsers:",r),[]}}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(Ne.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 r=this.domService.getCurrentWindowSizeValue();t.screenWidth=r?.screenWidth,t.screenHeight=r?.screenHeight,t.screenScrollHeight=r?.screenScrollHeight,this.updateCurrentCursorUser(t)}catch(t){this.loggingService.catch("Error in setCursorUser:",t)}}setCurrentCursorUserPosition(e,t,r){try{let a=this.cursorUser$.value;a?.onlineStatus===U.PRESENCE_STATUS_ONLINE&&(a.positionX=e,a.positionY=t,r?a.targetElement=r: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===U.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 Q(this,null,function*(){try{if(this.documentPaths&&e&&e.userId&&this.authService.isFeatureAllowed(Ne.CURSOR)){if(!e.isAnonymous){e.pageInfo=new ho;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(D(E({},t),{timestamp:this.timestamp})))})}this.cursorUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentCursorUser:",t)}})}updateUserStatusOnDocumentChange(e,t){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let r=this.cursorUser$.value;if(r.onlineStatus=e,t&&r&&r.userId&&!r.isAnonymous&&this.authService.isFeatureAllowed(Ne.CURSOR)){let a=JSON.parse(JSON.stringify(r));this.commonDbService.updateData({feature:"cursor",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",id:r.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(D(E({},a),{timestamp:this.timestamp})))})}}catch(r){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",r)}})}updateUserOnLocationChange(e){return Q(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(Ne.CURSOR)){let r=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(D(E({},r),{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,r=!1;if(e.featureAllowList.includes(Ne.CURSOR)?t?.onlineStatus!==U.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=U.PRESENCE_STATUS_ONLINE,r=!0):t?.onlineStatus!==U.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=U.PRESENCE_STATUS_OFFLINE,r=!0),r&&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(D(E({},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;"),ei(this.afAuth).pipe(Le(e=>!!e),fe(e=>this.docService.getDocumentPaths$().pipe(de(t=>e))),Qt(e=>Q(this,null,function*(){try{if(this.documentPaths&&e){let t=yield td(e,!0).catch(a=>null);if(!t)return;let{user:r}=t.claims;if(!r?.isAnonymous&&this.documentPaths?.cursor){let a=`${this.documentPaths.cursor}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:U.PRESENCE_STATUS_OFFLINE,comment:"",timestamp:this.timestamp}).catch(s=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",s)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}signOutUser(e){return new Promise((t,r)=>{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(D(E({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:U.PRESENCE_STATUS_OFFLINE})))}),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),r(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),r(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)(ee(Je),ee(Ft),ee(vc),ee(ot),ee(Ri),ee(En),ee(Be),ee(In),ee(je),ee(_),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var G9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;");try{return this.trackEvent(Y.Events.Cursor.GET_LIVE_CURSORS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(KC).getLiveCursorsOnCurrentDocument()}catch(o){return this.getService(_).catch("Error in _getOnlineUsersOnCurrentDocument: ",o),le(null)}}_setInactivityTime(o){this.getService(_).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(_).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(KC).setInactivityTime(o)}catch(n){this.getService(_).catch("Error in setInactivityTime: ",n)}}_allowedElementIds(o){this.getService(_).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(Y.Events.Cursor.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(KC).setAllowedElementIds(o)}catch(n){this.getService(_).catch("Error in allowedElementIds: ",n)}}};var W9=class extends gi{constructor(o){super(o),this.getService(_).log("%c[WB] Creating CLASS: DocElement","color: blue;"),this.getDocumentMetadata=this._getDocumentMetadata}_getDocumentMetadata(){this.getService(_).log("%c[WB] Calling FUNCTION: getDocumentMetadata","color: green;");try{return this.trackEvent(Y.Events.Doc.GET_DOCUMENT_METADATA_TRIGGERED),this.getService(ot).getDocumentMetadata$()}catch(o){return this.getService(_).catch("Error in getDocumentMetadata: ",o),le(null)}}};var Or=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,x,B,z){this.afAuth=e,this.analyticsService=t,this.authService=r,this.databaseService=a,this.docService=s,this.configService=c,this.domService=p,this.huddleUtilsService=g,this.functions=f,this.loggingService=I,this.notificationService=x,this.commonDbService=B,this.usersService=z,this.documentPaths=null,this.localStream$=new Ce(null),this.peerConnectionMap={},this.localStream=new MediaStream,this.screenSharingStream=new MediaStream,this.screenSharingStream$=new Ce(null),this.remoteStreamMap={},this.remoteStreamMap$=new Ce(null),this.localStreamState$=new Ce({}),this.peerConnectionStateMap={},this.peerConnectionStateMap$=new Ce({}),this.hudleToolComponentId$=new Ce(null),this.attendees$=new Ce([]),this.invitees$=new Ce([]),this.huddleJoined$=new Ce(!1),this.userHuddleStartTime$=new Ce(null),this.messages$=new Ce([]),this.messagesPanelVisible$=new Ce(!1),this.huddleOnCursorMode$=new Ce(!1),this.flockModeOnAvatarClickEnabled$=new Ce(!1),this.chatEnabled$=new Ce(!0),this.serverFallback$=new Ce(!0),this.huddleOnCursorModeByAttendeeId$=new Ce({}),this.huddleCursorAvailableByAttendeeId$=new Ce({}),this.remoteStreamsByUserId$=new Ce({}),this.messagesSubscription=null,this.huddleJoined=!1,this.onAnswerConnectionIdHistory={},this.onOfferUidHistory={},this.senders={},this.db=Is(),this.dbRefsRemoveOnDropCall=[],this.servers={iceServers:[{urls:["stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302"]}]},this.databaseService.getDb().pipe(Le(G=>!!G),rt(1)).subscribe(G=>{try{G&&(this.db=G,this.isHuddleTagInstalled()&&this.getServerFallback()&&this.getTwilioIceServers(),this.getUser(),this.getDocumentPaths())}catch(J){this.loggingService.catch("Error in HuddleService getDb:",J)}},G=>{this.loggingService.catch("Error in HuddleService getDb subscription: ",G)}),this.docService.addPreDocumentIdChangeFunction("huddle-service",G=>Q(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(G=>{G&&(this.localStream=G)}),this.screenSharingStream$.subscribe(G=>{G&&(this.screenSharingStream=G)}),this.configService.getConfig$().subscribe(G=>{try{!G?.featureAllowList?.find(ne=>ne===Ne.CURSOR)&&this.huddleOnCursorMode$.next(!1)}catch(J){this.loggingService.catch("Error in HuddleService configService.getConfig$:",J)}},G=>{this.loggingService.catch("Error in HuddleService configService.getConfig$ subscription: ",G)}),this.attendees$.subscribe(G=>{try{if(G?.length){if(this.huddleOnCursorMode$?.value){let J=this.huddleOnCursorModeByAttendeeId$.getValue()||{};G.forEach(ne=>{J[ne.userSnippylyId]=!0}),this.huddleOnCursorModeByAttendeeId$.next(J)}this.huddleJoined$?.value&&(G?.find(J=>J?.huddleOnCursorMode)?this.addCursorTag():this.removeCursorTag())}}catch(J){this.loggingService.catch("Error in HuddleService attendees$:",J)}},G=>{this.loggingService.catch("Error in HuddleService attendees$ subscription: ",G)}),mn([this.huddleJoined$,this.huddleOnCursorMode$]).subscribe(([G,J])=>{try{if(G){if(J){let ne=this.attendees$.getValue()||[],ve=this.huddleOnCursorModeByAttendeeId$.getValue()||{};ne.forEach(_e=>{ve[_e.userSnippylyId]=!0}),document?.body?.setAttribute(U.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE,"true")}else this.huddleOnCursorModeByAttendeeId$.next({}),document?.body?.removeAttribute(U.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE);this.updateHuddleOnCursorMode()}else this.removeCursorTag(),document?.body?.removeAttribute(U.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE)}catch(ne){this.loggingService.catch("Error in HuddleService huddleJoined$:",ne)}},G=>{this.loggingService.catch("Error in HuddleService huddleJoined$ subscription: ",G)}),this.huddleOnCursorModeByAttendeeId$.subscribe(G=>{try{this.huddleJoined&&(Object.keys(G).length?this.addCursorTag():this.removeCursorTag())}catch(J){this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$:",J)}},G=>{this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$ subscription: ",G)}),this.authService.addPreSignOutFuction("huddle-signout",this.signOutUser.bind(this))}isHuddleTagInstalled(){try{return!!document?.querySelector(`${U.TAGS.VELT_HUDDLE}`)||!!document?.querySelector(`${U.TAGS.SNIPPYLY_HUDDLE}`)}catch(e){return this.loggingService.catch("Error in HuddleService isHuddleTagInstalled:",e),!1}}getTwilioIceServers(){return Q(this,null,function*(){try{let t=(yield Ji(this.functions,eo({url:wn.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 ei(this.afAuth).pipe(Le(e=>!!e),de(e=>({firebaseUser:e})),fe(e=>this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})))),fe(e=>this.authService.getUser$().pipe(de(t=>D(E({},e),{user:t})))),fe(e=>ao(e.config,e.user,Ne.HUDDLE)?le(D(E({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),le(D(E({},e),{allowed:!1})))),Ct((e,t)=>e?.allowed===t?.allowed),fe(e=>this.docService.getDocumentPaths$().pipe(de(t=>(this.documentPaths=t,e)))),fe(e=>e?.allowed?e?.user?.isAnonymous?le(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleAttendees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(t=>t?.data),de(t=>t?(this.attendees$.next(Object.values(t)),Object.values(t)):(this.attendees$.next([]),null))):le(null):le([])))}getInvitees(){try{return ei(this.afAuth).pipe(Le(e=>!!e),de(e=>({firebaseUser:e})),fe(e=>this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})))),fe(e=>this.authService.getUser$().pipe(de(t=>D(E({},e),{user:t})))),fe(e=>ao(e.config,e.user,Ne.HUDDLE)?le(D(E({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),le(D(E({},e),{allowed:!1})))),Ct((e,t)=>e?.allowed===t?.allowed),fe(e=>this.docService.getDocumentPaths$().pipe(de(t=>(this.documentPaths=t,e)))),fe(e=>e?.allowed?e?.user?.isAnonymous?le(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(t=>t?.data),de(t=>t?(this.invitees$.next(Object.values(t)),Object.values(t)):(this.invitees$.next([]),null))):le(null):le([])))}catch(e){return this.loggingService.catch("Error in HuddleService getInvitees:",e),le([])}}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(Le(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(Qt(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 Q(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=Ti(this.db,this.documentPaths?.huddle),this.iceCandidates=Ti(this.db,`${this.documentPaths?.huddle}/iceCandidates`),this.connections=Ti(this.db,`${this.documentPaths?.huddle}/connections`),this.attendees=Ti(this.db,`${this.documentPaths?.huddle}/attendees`),this.messages=Ti(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;"),kg(this.connections,e=>{try{if(e.exists()){let t=e.val();Object.values(t).forEach(a=>{let s=Object.values(a);if(s&&s.length>0){let p=s[0]?.connectionId;this.onHuddleSnapshot(p,a)}}),Object.keys(this.remoteStreamMap).forEach(a=>Q(this,null,function*(){t[a]||(this.remoteStreamMap[a]&&Object.values(this.remoteStreamMap[a]).forEach(s=>{s.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=>Q(this,null,function*(){Object.values(this.remoteStreamMap[t]).forEach(r=>{r.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)}}),h$(this.iceCandidates).subscribe(e=>{try{e.event==="child_added"&&this.onIceCandidateSnapshot(e.snapshot)}catch(t){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",t)}}),h$(this.attendees).subscribe(e=>{try{if(e.event==="child_removed"){let t=e?.snapshot?.val();if(t){delete this.onOfferUidHistory[t?.userSnippylyId];let r=this.getCombinedId(this.user.userSnippylyId,t?.userSnippylyId);delete this.onAnswerConnectionIdHistory[r],this.closeConnection(r)}}}catch(t){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",t)}}),this.messagesSubscription&&this.messagesSubscription.unsubscribe(),this.messagesSubscription=new $t(e=>{let t=kg(this.messages,r=>e.next(r),r=>e.error(r));return()=>t()}).pipe(fe(e=>this.usersService.getUserById$().pipe(de(()=>e))),fe(e=>{if(e.exists()){let t=e.val();return io(this.huddleUtilsService.resolveUsersFromHuddleMessages(Object.values(t||{})))}return le([])}),Un(e=>(this.loggingService.catch("Error in HuddleService messages onValue:",e),le([])))).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(r){this.loggingService.catch("Error in HuddleService onHuddleSnapshot:",r)}}onIceCandidateSnapshot(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: onIceCandidateSnapshot","color: green;"),this.loggingService.log("ice candidate received");let t=e.val(),r=t.connectionId;t?.from!==this.user.userSnippylyId&&r in this.peerConnectionMap&&this.onIceCandidateChange(r,t)}catch(t){this.loggingService.catch("Error in HuddleService onIceCandidateSnapshot:",t)}}onOffer(e,t){return Q(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(r){this.loggingService.catch("Error in HuddleService onOffer:",r)}})}sendAnswer(e,t){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendAnswer","color: green;"),this.loggingService.log(e),this.documentPaths?.huddle&&e){let r=yield this.peerConnectionMap[e].createAnswer();yield this.setLocalDescription(e,r);let s={answer:{type:r.type,sdp:r.sdp},from:this.user.userSnippylyId,connectionId:e,to:t},c=Ti(this.db,`${this.documentPaths?.huddle}/connections/${e}`);this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:c}),yield FM(c,{answerData:s}),Es(c).remove()}else this.loggingService.catch("Error in sendAnswer: documentPaths not found")}catch(r){this.loggingService.catch("Error in HuddleService onHuddleSnapshot:",r)}})}onAnswer(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onAnswer","color: green;");let r=t.answer;yield this.setRemoteDescription(e,r)}catch(r){this.loggingService.catch("Error in HuddleService onAnswer:",r)}})}onIceCandidateChange(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onIceCandidateChange","color: green;");let r=t.candidate;this.loggingService.log("onIceCandidateChange",r),yield this.peerConnectionMap[e].addIceCandidate(new RTCIceCandidate(r))}catch(r){this.loggingService.catch("Error in HuddleService onIceCandidateChange:",r)}})}setRemoteDescription(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRemoteDescription","color: green;"),yield this.peerConnectionMap[e].setRemoteDescription(new RTCSessionDescription(t))}catch(r){this.loggingService.catch("Error in HuddleService setRemoteDescription:",r)}})}addAttendee(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: addAttendee","color: green;"),this.documentPaths?.huddle&&this.user?.userSnippylyId){let e=D(E({},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=Ti(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}`);yield I0(t,JSON.parse(JSON.stringify(e))),this.dbRefsRemoveOnDropCall.push({type:"attendee",dbRef:t}),Es(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;"),Dre(this.attendees).pipe(rt(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 Q(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 Q(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=r=>{this.loggingService.log("Huddle: onicecandidateerror",r)},this.peerConnectionMap[e].onicecandidate=r=>{if(this.loggingService.log("pc onicecandidate"),r.candidate){let a={candidate:r.candidate.toJSON(),from:this.user.userSnippylyId,connectionId:e},s=Mre(this.iceCandidates,a);this.dbRefsRemoveOnDropCall.push({type:"iceCandidate",dbRef:s}),Es(s).remove()}},this.peerConnectionMap[e].ontrack=r=>{this.loggingService.log("pc ontrack"),this.onTrack(e,r)},this.peerConnectionMap[e].onconnectionstatechange=r=>Q(this,null,function*(){this.logStatuses("onconnectionstatechange",e,r),this.peerConnectionMap[e].connectionState==="failed"&&(this.removeConnection(e),this.closeConnection(e),this.checkForRemovingAttendee())}),this.peerConnectionMap[e].onicegatheringstatechange=r=>Q(this,null,function*(){this.logStatuses("onicegatheringstatechange",e,r)}),this.peerConnectionMap[e].onsignalingstatechange=r=>Q(this,null,function*(){this.logStatuses("onsignalingstatechange",e,r)}),this.peerConnectionMap[e].oniceconnectionstatechange=r=>Q(this,null,function*(){this.loggingService.log("pc oniceconnectionstatechange"),this.logStatuses("oniceconnectionstatechange",e,r);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(r){return this.loggingService.catch("Error in HuddleService createPeerConnection:",r),""}}logStatuses(e,t,r){let a={};["connectionState","iceConnectionState","iceGatheringState","signalingState"].forEach(c=>{a[c]=this.peerConnectionMap[t][c]}),this.loggingService.log("Huddle: logStatues: ",t,e,a,r,this.peerConnectionMap[t])}checkForRemovingAttendee(){return Q(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 r=e.split("__").find(a=>a!==this.user?.userSnippylyId);r&&delete this.onOfferUidHistory[r]}}catch(t){this.loggingService.catch("Error in HuddleService closeConnection:",t)}}removeConnection(e){return Q(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(r=>{this.peerConnectionMap[e].addTrack(r,this.localStream)}),this.screenSharingStream?.getVideoTracks()?.forEach(r=>{this.peerConnectionMap[e].addTrack(r,this.screenSharingStream)})):(this.localStream.getTracks().forEach(r=>{this.peerConnectionMap[e].addTrack(r,this.localStream)}),this.screenSharingStream?.getVideoTracks()?.forEach(r=>{this.peerConnectionMap[e].addTrack(r,this.screenSharingStream)}))}catch(r){this.loggingService.catch("Error in HuddleService addLocalStreamToPeerConnection:",r)}}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(r=>{this.loggingService.log(r.currentDirection),r.currentDirection!=="sendrecv"&&(r.direction="sendrecv"),this.senders[e]=r.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 r=0;r<20;r++)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(r){return this.loggingService.catch("Error in HuddleService getCombinedId:",r),""}}sendOffer(e,t){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendOffer","color: green;"),this.documentPaths?.huddle&&e){this.onOfferUidHistory[t]=!0;let r=yield this.peerConnectionMap[e].createOffer();yield this.setLocalDescription(e,r);let a={sdp:r.sdp,type:r.type};t||(t="all");let s={offer:a,from:this.user.userSnippylyId,connectionId:e,to:t},c=Ti(this.db,`${this.documentPaths?.huddle}/connections/${e}`);yield I0(c,{offerData:s}),this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:c}),Es(c).remove()}}catch(r){this.loggingService.catch("Error in HuddleService sendOffer:",r)}})}setLocalDescription(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocalDescription","color: green;"),yield this.peerConnectionMap[e].setLocalDescription(t)}catch(r){this.loggingService.catch("Error in HuddleService setLocalDescription:",r)}})}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 r=e.split("__").find(s=>s!==this.user?.userSnippylyId),a=this.attendees$.value?.find(s=>s?.userSnippylyId===r);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(r){this.loggingService.catch("Error in HuddleService onTrack:",r)}}toggleScreenSharing(e){return Q(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(s=>s?.track?.kind==this.screenSharingStream?.getVideoTracks()[0].kind)?.replaceTrack(this.screenSharingStream?.getVideoTracks()[0])});else{let t=this.localStream;Object.keys(this.peerConnectionMap).forEach(r=>{this.peerConnectionMap[r].getSenders().find(c=>c?.track?.kind==t.getVideoTracks()[0].kind)?.replaceTrack(t.getVideoTracks()[0])}),this.screenSharingStream?.getTracks().forEach(r=>r.stop())}}catch(t){this.loggingService.catch("Error in HuddleService toggleScreenSharing:",t)}})}setLocalStream(e){return Q(this,null,function*(){try{if(this.localStream=new MediaStream([this.silence(),this.black()]),e?.audio||e?.video){let t=e,r=ud();e?.audio&&(e?.audio instanceof Object?t.audio=D(E({},e?.audio),{deviceId:r?.selectedAudioDevice?.deviceId}):t.audio={deviceId:r?.selectedAudioDevice?.deviceId}),e?.video&&(e?.video instanceof Object?t.video=D(E({},e?.video),{deviceId:r?.selectedVideoDevice?.deviceId}):t.video={deviceId:r?.selectedVideoDevice?.deviceId});let a=yield navigator.mediaDevices.getUserMedia(t);a?.getAudioTracks()?.length&&(this.localStream.getAudioTracks().forEach(s=>this.localStream.removeTrack(s)),a.getAudioTracks().forEach(s=>this.localStream.addTrack(s))),a?.getVideoTracks()?.length&&(this.localStream.getVideoTracks().forEach(s=>this.localStream.removeTrack(s)),a.getVideoTracks().forEach(s=>this.localStream.addTrack(s)))}this.localStream$.next(this.localStream)}catch(t){this.loggingService.catch("Error in HuddleService setLocalStream:",t)}})}setScreenSharingStream(){return Q(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 Q(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 Q(this,null,function*(){try{let t=this.localStream$.value;if(t){let r=t.getAudioTracks()[0];if(r.enabled&&!e)r.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=ud(),s=yield navigator.mediaDevices.getUserMedia({audio:{deviceId:a?.selectAudioDevice?.deviceId}});s&&(t.getAudioTracks()?.forEach(c=>{t.removeTrack(c)}),s.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(p=>p?.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 Q(this,null,function*(){try{let t=this.localStream$.value;if(t){let r=t.getVideoTracks()[0];if(r.enabled&&!e)r.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=ud(),s=yield navigator.mediaDevices.getUserMedia({video:{deviceId:a?.selectedVideoDevice?.deviceId}});s&&(t.getVideoTracks()?.forEach(c=>{t.removeTrack(c)}),s.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(p=>p?.track?.kind==t?.getVideoTracks()[0].kind)?.replaceTrack(t?.getVideoTracks()[0])}),this.updateUserHuddleState()}}catch(t){this.loggingService.catch("Error in HuddleService toggleLocalStreamVideo:",t)}})}toggleLocalScreenSharing(){return Q(this,null,function*(){try{let e=this.screenSharingStream;if(e){if(e.getVideoTracks()[0].enabled)this.stopScreenSharingStream();else{let r=yield navigator.mediaDevices?.getDisplayMedia({video:!0});r&&(e.getVideoTracks()?.forEach(a=>{e.removeTrack(a)}),r.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 Q(this,null,function*(){let e=this.screenSharingStream;if(e){let t=e.getVideoTracks()[0];t.enabled&&(t.stop(),e.getVideoTracks()?.forEach(r=>{e.removeTrack(r)}),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(r=>r?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(r=>r?.userId)}))}})}updateScreenSharingTracksToPeers(){return Q(this,null,function*(){Object.keys(this.peerConnectionMap).forEach(e=>{let r=this.peerConnectionMap[e].getSenders().filter(a=>a?.track?.kind==this.screenSharingStream?.getVideoTracks()[0].kind);r?.length>1&&r[1]?.replaceTrack(this.screenSharingStream?.getVideoTracks()[0])})})}dropCall(){return Q(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(r=>{r.stop()}),t.getSenders()?.forEach(r=>{r.track?.stop()}),t.getReceivers()?.forEach(r=>{r.track?.stop()}),t.close()}),this.peerConnectionMap={},this.dbRefsRemoveOnDropCall.forEach(e=>Q(this,null,function*(){yield NM(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,r){try{let a=JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)||"{}");r?sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(r)):(a[e]=t,sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(a)))}catch(a){this.loggingService.catch("Error in HuddleService updateHuddleSessionData:",a)}}getHuddleSessionData(){try{return sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)?JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)):null}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleSessionData:",e),null}}removeHuddleSessionData(){try{sessionStorage.removeItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)}catch(e){this.loggingService.catch("Error in HuddleService removeHuddleSessionData:",e)}}removeAttendee(){return Q(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 Q(this,null,function*(){try{if(this.attendees&&this.user&&this.documentPaths?.huddle){let e=this.getAudioState(),t=this.getVideoState(),r=this.getScreenSharingState();this.localStreamState$.next({audioState:e,videoState:t,screenSharingState:r});let a={audioState:e,videoState:t,screenSharingState:r};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 Q(this,null,function*(){try{if(this.attendees&&this.user&&this.documentPaths?.huddle){let e=Ti(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}/huddleOnCursorMode`);yield I0(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 Q(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(r=>Q(this,null,function*(){t[r].connectionId===e&&this.commonDbService.deleteData({feature:"huddleIceCandidate",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:r,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(),r=t.connect(e.createMediaStreamDestination());return t.start(),Object.assign(r.stream.getAudioTracks()[0],{enabled:!1})}catch(e){this.loggingService.catch("Error in HuddleService silence:",e)}}black({width:e=640,height:t=480}={}){try{let r=Object.assign(document.createElement("canvas"),{width:e,height:t});r.getContext("2d")?.fillRect(0,0,e,t);let a=r.captureStream();return Object.assign(a.getVideoTracks()[0],{enabled:!1})}catch(r){this.loggingService.catch("Error in HuddleService black:",r)}}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),le([])}}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),le([])}}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(r=>{if(r?.email){let a=Tt(r.email);t[a]=r}}),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=E({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),le(!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),le({})}}updateHuddleCursorAvailableByAttendeeId(e,t){try{let r=this.huddleCursorAvailableByAttendeeId$.value;r[e]=t,this.huddleCursorAvailableByAttendeeId$.next(r)}catch(r){this.loggingService.catch("Error in HuddleService updateCursorUserAvailableByUserId:",r)}}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),le({})}}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),le(!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),le(!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),le(!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),le(!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),le({})}}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(`${U.TAGS.SNIPPYLY_CURSOR}`)){let e=document.createElement(U.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(`${U.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 l9;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),le([])}}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),le(!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 Q(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)(ee(Ri),ee(Je),ee(je),ee(In),ee(ot),ee(Ft),ee(Be),ee(x9),ee(Do),ee(_),ee(hn),ee(un),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var q9=class extends gi{constructor(o){super(o),this.getService(_).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(_).log("%c[WB] Calling FUNCTION: _enableCursorMode","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(Or).enableHuddleOnCursorMode()}catch(o){this.getService(_).catch("Error in enableCursorMode: ",o)}}_disableCursorMode(){this.getService(_).log("%c[WB] Calling FUNCTION: _disableCursorMode","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(Or).disableHuddleOnCursorMode()}catch(o){this.getService(_).catch("Error in disableCursorMode: ",o)}}_enableChat(){this.getService(_).log("%c[WB] Calling FUNCTION: _enableChat","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_CHAT_TRIGGERED),this.getService(Or).enableChat()}catch(o){this.getService(_).catch("Error in enableChat: ",o)}}_disableChat(){this.getService(_).log("%c[WB] Calling FUNCTION: _disableChat","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_CHAT_TRIGGERED),this.getService(Or).disableChat()}catch(o){this.getService(_).catch("Error in disableChat: ",o)}}_enableFlockModeOnAvatarClick(){this.getService(_).log("%c[WB] Calling FUNCTION: _enableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(Y.Events.Huddle.ENABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(Or).enableFlockModeOnAvatarClick()}catch(o){this.getService(_).catch("Error in enableFlockModeOnAvatarClick: ",o)}}_disableFlockModeOnAvatarClick(){this.getService(_).log("%c[WB] Calling FUNCTION: _disableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(Y.Events.Huddle.DISABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(Or).disableFlockModeOnAvatarClick()}catch(o){this.getService(_).catch("Error in disableFlockModeOnAvatarClick: ",o)}}};var Y9=(()=>{let o=class o{constructor(e,t){this.analyticsService=e,this.loggingService=t,this.actionSubjects=new Map,this.subscriptions=[]}onAccessRequested(e){try{this.triggerAction(Ug.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})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRequested: ",t)}}onAccessRequestCanceled(e){try{this.triggerAction(Ug.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})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRequestCanceled: ",t)}}onAccessAccepted(e){try{this.triggerAction(Ug.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})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessAccepted: ",t)}}onAccessRejected(e){try{this.triggerAction(Ug.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})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onAccessRejected: ",t)}}onEditorAssigned(e){try{this.triggerAction(Ug.EDITOR_ASSIGNED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_EDITOR_ASSIGNED,{editorUserId:e?.editor?.userId,timestamp:e?.timestamp,role:e?.role})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onEditorAssigned: ",t)}}onEditorOnDifferentTabDetected(e){try{this.triggerAction(Ug.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})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onEditorOnDifferentTabDetected: ",t)}}onViewerAssigned(e){try{this.triggerAction(Ug.VIEWER_ASSIGNED,e),this.analyticsService.trackEvent(Y.Events.LiveStateSync.SEM_VIEWER_ASSIGNED,{viewerUserId:e?.viewer?.userId,timestamp:e?.timestamp,role:e?.role})}catch(t){this.loggingService.catch("Error in LiveStateActionsService onViewerAssigned: ",t)}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in LiveStateActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in LiveStateActionsService onAction: ",t),le(null)}}};o.\u0275fac=function(t){return new(t||o)(ee(Je),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var K9=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f){this.authService=e,this.commonDbService=t,this.databaseService=r,this.docService=a,this.domService=s,this.loggingService=c,this.metadataService=p,this.commonDbUtils=g,this.configService=f,this.HEARTBEAT_DURATION=5*1e3,this.heartbeatEnabled$=new Ce(!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(Ct()).subscribe(I=>{I?this.setupHeartbeat():this.teardownHeartbeat()}),this.docService.addPreDocumentIdChangeFunction("heartbeat-service",I=>I?.documentId?this.removeDocumentHeartbeat(I):Promise.resolve())}catch(I){this.loggingService.catch("Error in HeartbeatService constructor: ",I)}}setupWebWorker(e){try{let t=`
|
|
487
487
|
let intervalId;
|
|
488
488
|
self.addEventListener('message', (event) => {
|