@veltdev/sdk 4.5.0-beta.21 → 4.5.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/velt.js +2 -2
package/velt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var SNIPPYLY_VERSION = '4.5.0-beta.
|
|
1
|
+
var SNIPPYLY_VERSION = '4.5.0-beta.22';
|
|
2
2
|
(function(m,w){"use strict";function rt(){var e=K.splice(0,K.length);for(ie=0;e.length;)e.shift().call(null,e.shift())}function me(e,t){for(var n=0,r=e.length;n<r;n++)Te(e[n],t)}function ot(e){for(var t,n=0,r=e.length;n<r;n++)t=e[n],U(t,q[pe(t)])}function fe(e){return function(t){Lt(t)&&(Te(t,e),L.length&&me(t.querySelectorAll(L),e))}}function pe(e){var t=le.call(e,"is"),n=e.nodeName.toUpperCase(),r=v.call(D,t?Y+t.toUpperCase():x+n);return t&&-1<r&&!De(n,t)?-1:r}function De(e,t){return-1<L.indexOf(e+'[is="'+t+'"]')}function Ie(e){var t=e.currentTarget,n=e.attrChange,r=e.attrName,o=e.target,l=e[W]||2,a=e[He]||3;!ce||o&&o!==t||!t[y]||r==="style"||e.prevValue===e.newValue&&(e.newValue!==""||n!==l&&n!==a)||t[y](r,n===l?null:e.prevValue,n===a?null:e.newValue)}function Fe(e){var t=fe(e);return function(n){K.push(t,n.target),ie&&clearTimeout(ie),ie=setTimeout(rt,1)}}function de(e){nt&&(nt=!1,e.currentTarget.removeEventListener(Ze,de)),L.length&&me((e.target||u).querySelectorAll(L),e.detail===E?E:b),R&&at()}function lt(e,t){var n=this;Ye.call(n,e,t),Me.call(n,{target:n})}function Se(e,t,n){var r=t.apply(e,n),o=pe(r);return-1<o&&U(r,q[o]),n.pop()&&L.length&&ot(r.querySelectorAll(L)),r}function he(e,t){Tt(e,t),$?$.observe(e,gt):(ue&&(e.setAttribute=lt,e[H]=Ee(e),e[g](st,Me)),e[g](N,Ie)),e[k]&&ce&&(e.created=!0,e[k](),e.created=!1)}function at(){for(var e,t=0,n=G.length;t<n;t++)e=G[t],V.contains(e)||(n--,G.splice(t--,1),Te(e,E))}function Ve(e){throw new Error("A "+e+" type is already registered")}function Te(e,t){var n,r,o=pe(e);-1<o&&!Mt.call(e,"TEMPLATE")&&(Q(e,q[o]),o=0,t!==b||e[b]?t!==E||e[E]||(e[b]=!1,e[E]=!0,r="disconnected",o=1):(e[E]=!1,e[b]=!0,r="connected",o=1,R&&v.call(G,e)<0&&G.push(e)),o&&(n=e[t+O]||e[r+O])&&n.call(e))}function z(){}function Pe(e,t,n){var r=n&&n[_]||"",o=t.prototype,l=Ce(o),a=t.observedAttributes||ye,s={prototype:l};oe(l,k,{value:function(){if(te)te=!1;else if(!this[B]){this[B]=!0,new t(this),o[k]&&o[k].call(this);var i=j[ne.get(t)];(!Z||i.create.length>1)&&_e(this)}}}),oe(l,y,{value:function(i){-1<v.call(a,i)&&o[y]&&o[y].apply(this,arguments)}}),o[qe]&&oe(l,ut,{value:o[qe]}),o[Be]&&oe(l,ct,{value:o[Be]}),r&&(s[_]=r),e=e.toUpperCase(),j[e]={constructor:t,create:r?[r,re(e)]:[e]},ne.set(t,e),u[S](e.toLowerCase(),s),Le(e),P[e].r()}function Re(e){var t=j[e.toUpperCase()];return t&&t.constructor}function Ue(e){return typeof e=="string"?e:e&&e.is||""}function _e(e){for(var t,n=e[y],r=n?e.attributes:ye,o=r.length;o--;)t=r[o],n.call(e,t.name||t.nodeName,null,t.value||t.nodeValue)}function Le(e){return e=e.toUpperCase(),e in P||(P[e]={},P[e].p=new Xe(function(t){P[e].r=t})),P[e].p}function ke(){C&&delete m.customElements,I(m,"customElements",{configurable:!0,value:new z}),I(m,"CustomElementRegistry",{configurable:!0,value:z});for(var e=it.get(/^HTML[A-Z]*[a-z]/),t=e.length;t--;function(n){var r=m[n];if(r){m[n]=function(o){var l,a;return o||(o=this),o[B]||(te=!0,l=j[ne.get(o.constructor)],a=Z&&l.create.length===1,o=a?Reflect.construct(r,ye,l.constructor):u.createElement.apply(u,l.create),o[B]=!0,te=!1,a||_e(o)),o},m[n].prototype=r.prototype;try{r.prototype.constructor=m[n]}catch{dt=!0,I(r,B,{value:m[n]})}}}(e[t]));u.createElement=function(n,r){var o=Ue(r);return o?Ae.call(this,n,re(o)):Ae.call(this,n)},et||(Oe=!0,u[S](""))}var u=m.document,T=m.Object,it=function(e){var t,n,r,o,l=/^[A-Z]+[a-z]/,a=function(p){var f,h=[];for(f in i)p.test(f)&&h.push(f);return h},s=function(p,f){(f=f.toLowerCase())in i||(i[p]=(i[p]||[]).concat(f),i[f]=i[f.toUpperCase()]=p)},i=(T.create||T)(null),c={};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 c.get=function(p){return typeof p=="string"?i[p]||(l.test(p)?[]:""):a(p)},c.set=function(p,f){return l.test(p)?s(p,f):s(f,p),c},c}({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 w!="object"&&(w={type:w||"auto"});var K,Me,X,Ee,$,ve,Q,U,A,S="registerElement",xe=1e5*m.Math.random()>>0,H="__"+S+xe,g="addEventListener",b="attached",O="Callback",E="detached",_="extends",y="attributeChanged"+O,ut=b+O,qe="connected"+O,Be="disconnected"+O,k="created"+O,ct=E+O,W="ADDITION",He="REMOVAL",N="DOMAttrModified",Ze="DOMContentLoaded",st="DOMSubtreeModified",x="<",Y="=",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=[],q=[],L="",V=u.documentElement,v=D.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},ge=T.prototype,be=ge.hasOwnProperty,J=ge.isPrototypeOf,I=T.defineProperty,ye=[],ee=T.getOwnPropertyDescriptor,je=T.getOwnPropertyNames,pt=T.getPrototypeOf,Ge=T.setPrototypeOf,ze=!!T.__proto__,dt=!1,B="__dreCEv1",C=m.customElements,Z=!/^force/.test(w.type)&&!!(C&&C.define&&C.get&&C.whenDefined),Ke=T.create||T,ht=m.Map||function(){var e,t=[],n=[];return{get:function(r){return n[v.call(t,r)]},set:function(r,o){e=v.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},Xe=m.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},te=!1,j=Ke(null),P=Ke(null),ne=new ht,re=function(e){return e.toLowerCase()},Ce=T.create||function e(t){return t?(e.prototype=t,new e):this},Tt=Ge||(ze?function(e,t){return e.__proto__=t,e}:je&&ee?function(){function e(t,n){for(var r,o=je(n),l=0,a=o.length;l<a;l++)r=o[l],be.call(t,r)||I(t,r,ee(n,r))}return function(t,n){do e(t,n);while((n=pt(n))&&!J.call(n,t));return t}}():function(e,t){for(var n in t)e[n]=t[n];return e}),F=m.MutationObserver||m.WebKitMutationObserver,$e=m.HTMLAnchorElement,d=(m.HTMLElement||m.Element||m.Node).prototype,R=!J.call(d,V),oe=R?function(e,t,n){return e[t]=n.value,e}:I,Lt=R?function(e){return e.nodeType===1}:function(e){return J.call(d,e)},G=R&&[],Qe=d.attachShadow,We=d.cloneNode,Mt=d.closest||function(e){for(var t=this;t&&t.nodeName!==e;)t=t.parentNode;return t},we=d.dispatchEvent,le=d.getAttribute,Et=d.hasAttribute,vt=d.removeAttribute,Ye=d.setAttribute,ae=u.createElement,Ht=u.importNode,Ae=ae,gt=F&&{attributes:!0,characterData:!0,attributeOldValue:!0},Je=F||function(e){ue=!1,V.removeEventListener(N,Je)},ie=0,et=S in u&&!/^force-all/.test(w.type),tt=!0,Oe=!1,ue=!0,nt=!0,ce=!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=ee(d,"innerHTML");var n=A&&A.set;n&&I(d,"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=""),et||(Ge||ze?(Q=function(e,t){J.call(t,e)||he(e,t)},U=he):(Q=function(e,t){e[H]||(e[H]=T(!0),he(e,t))},U=Q),R?(ue=!1,function(){var e=ee(d,g),t=e.value,n=function(l){var a=new CustomEvent(N,{bubbles:!0});a.attrName=l,a.prevValue=le.call(this,l),a.newValue=null,a[He]=a.attrChange=2,vt.call(this,l),we.call(this,a)},r=function(l,a){var s=Et.call(this,l),i=s&&le.call(this,l),c=new CustomEvent(N,{bubbles:!0});Ye.call(this,l,a),c.attrName=l,c.prevValue=s?i:null,c.newValue=a,s?c.MODIFICATION=c.attrChange=1:c[W]=c.attrChange=0,we.call(this,c)},o=function(l){var a,s=l.currentTarget,i=s[H],c=l.propertyName;i.hasOwnProperty(c)&&(i=i[c],a=new CustomEvent(N,{bubbles:!0}),a.attrName=i.name,a.prevValue=i.value||null,a.newValue=i.value=s[c]||null,a.prevValue==null?a[W]=a.attrChange=0:a.MODIFICATION=a.attrChange=1,we.call(s,a))};e.value=function(l,a,s){l===N&&this[y]&&this.setAttribute!==r&&(this[H]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,l,a,s)},I(d,g,e)}()):F||(V[g](N,Je),V.setAttribute(H,1),V.removeAttribute(H),ue&&(Me=function(e){var t,n,r,o=this;if(o===e.target){t=o[H],o[H]=n=Ee(o);for(r in n){if(!(r in t))return X(0,o,r,t[r],n[r],W);if(n[r]!==t[r])return X(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return X(2,o,r,t[r],n[r],He)}},X=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,Ie(a)},Ee=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(),tt&&(tt=!1,F?($=function(i,c){function p(f,h){for(var M=0,se=f.length;M<se;h(f[M++]));}return new F(function(f){for(var h,M,se,Ne=0,bt=f.length;Ne<bt;Ne++)h=f[Ne],h.type==="childList"?(p(h.addedNodes,i),p(h.removedNodes,c)):(M=h.target,ce&&M[y]&&h.attributeName!=="style"&&(se=le.call(M,h.attributeName))!==h.oldValue&&M[y](h.attributeName,h.oldValue,se))})}(fe(b),fe(E)),ve=function(i){return $.observe(i,{childList:!0,subtree:!0}),i},ve(u),Qe&&(d.attachShadow=function(){return ve(Qe.apply(this,arguments))})):(K=[],u[g]("DOMNodeInserted",Fe(b)),u[g]("DOMNodeRemoved",Fe(E))),u[g](Ze,de),u[g]("readystatechange",de),u.importNode=function(i,c){switch(i.nodeType){case 1:return Se(u,Ht,[i,!!c]);case 11:for(var p=u.createDocumentFragment(),f=i.childNodes,h=f.length,M=0;M<h;M++)p.appendChild(u.importNode(f[M],!!c));return p;default:return We.call(i,!!c)}},d.cloneNode=function(i){return Se(this,We,[!!i])}),Oe)return Oe=!1;if(-2<v.call(D,Y+n)+v.call(D,x+n)&&Ve(e),!mt.test(n)||-1<v.call(ft,n))throw new Error("The type "+e+" is invalid");var n,r,o=function(){return a?u.createElement(s,n):u.createElement(s)},l=t||ge,a=be.call(l,_),s=a?t[_].toUpperCase():n;return a&&-1<v.call(D,x+s)&&Ve(s),r=D.push((a?Y:x)+n)-1,L=L.concat(L.length?",":"",a?s+'[is="'+e.toLowerCase()+'"]':s),o.prototype=q[r]=be.call(l,"prototype")?l.prototype:Ce(d),L.length&&me(u.querySelectorAll(L),b),o},u.createElement=Ae=function(e,t){var n=Ue(t),r=n?ae.call(u,e,re(n)):ae.call(u,e),o=""+e,l=v.call(D,(n?Y:x)+(n||o).toUpperCase()),a=-1<l;return n&&(r.setAttribute("is",n=n.toLowerCase()),a&&(a=De(o.toUpperCase(),n))),ce=!u.createElement.innerHTMLHelper,a&&U(r,q[l]),r}),addEventListener("beforeunload",function(){delete u.createElement,delete u.importNode,delete u[S]},!1),z.prototype={constructor:z,define:Z?function(e,t,n){if(n)Pe(e,t,n);else{var r=e.toUpperCase();j[r]={constructor:t,create:[r]},ne.set(t,r),C.define(e,t)}}:Pe,get:Z?function(e){return C.get(e)||Re(e)}:Re,whenDefined:Z?function(e){return Xe.race([C.whenDefined(e),Le(e)])}:Le},!C||/^force/.test(w.type))ke();else if(!w.noBuiltIn)try{(function(e,t,n){var r=new RegExp(`^<a\\s+is=('|")`+n+"\\1></a>$");if(t[_]="a",e.prototype=Ce($e.prototype),e.prototype.constructor=e,m.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($e,[],e)},{},"document-register-element-a"+xe)}catch{ke()}if(!w.noBuiltIn)try{if(ae.call(u,"a","a").outerHTML.indexOf("is")<0)throw{}}catch{re=function(t){return{is:t.toLowerCase()}}}})(window);
|
|
3
3
|
|
|
4
4
|
var N0e=Object.create;var Tw=Object.defineProperty,F0e=Object.defineProperties,L0e=Object.getOwnPropertyDescriptor,B0e=Object.getOwnPropertyDescriptors,V0e=Object.getOwnPropertyNames,xw=Object.getOwnPropertySymbols,xG=Object.getPrototypeOf,S7=Object.prototype.hasOwnProperty,TG=Object.prototype.propertyIsEnumerable,U0e=Reflect.get;var EG=(n,o,t)=>o in n?Tw(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t,I=(n,o)=>{for(var t in o||={})S7.call(o,t)&&EG(n,t,o[t]);if(xw)for(var t of xw(o))TG.call(o,t)&&EG(n,t,o[t]);return n},T=(n,o)=>F0e(n,B0e(o));var b7=(n,o)=>{var t={};for(var e in n)S7.call(n,e)&&o.indexOf(e)<0&&(t[e]=n[e]);if(n!=null&&xw)for(var e of xw(n))o.indexOf(e)<0&&TG.call(n,e)&&(t[e]=n[e]);return t};var j0e=(n,o)=>()=>(o||n((o={exports:{}}).exports,o),o.exports),Dw=(n,o)=>{for(var t in o)Tw(n,t,{get:o[t],enumerable:!0})},$0e=(n,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of V0e(o))!S7.call(n,i)&&i!==t&&Tw(n,i,{get:()=>o[i],enumerable:!(e=L0e(o,i))||e.enumerable});return n};var DG=(n,o,t)=>(t=n!=null?N0e(xG(n)):{},$0e(o||!n||!n.__esModule?Tw(t,"default",{value:n,enumerable:!0}):t,n));var $d=(n,o,t)=>U0e(xG(n),t,o);var Q=(n,o,t)=>new Promise((e,i)=>{var r=m=>{try{s(t.next(m))}catch(p){i(p)}},a=m=>{try{s(t.throw(m))}catch(p){i(p)}},s=m=>m.done?e(m.value):Promise.resolve(m.value).then(r,a);s((t=t.apply(n,o)).next())});var Hz=j0e((fro,$z)=>{"use strict";var yt={};yt.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};yt.localCName=yt.generateIdentifier();yt.splitLines=function(n){return n.trim().split(`
|
|
@@ -378,7 +378,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
378
378
|
</radialGradient>
|
|
379
379
|
</defs>
|
|
380
380
|
</svg>
|
|
381
|
-
`},o.GIF_PATHS={CAT_JAM:"https://firebasestorage.googleapis.com/v0/b/snippyly-sdk-external/o/emojis%2Fcatjam.gif?alt=media&token=9868b4ec-0031-4751-bb2e-47bf0f9d9583"},o.\u0275fac=function(i){return new(i||o)(J(Ne),J(y),J(Ls))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var nr=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D){this.afAuth=e,this.analyticsService=i,this.authService=r,this.configService=a,this.databaseService=s,this.commonDbService=m,this.docService=p,this.domService=h,this.emojiService=_,this.iamService=E,this.loggingService=D,this.documentPaths=null,this.db=Ii(),this.reactionAnnotationById$=new Ce({}),this.customReactions$=new Ce({}),this.darkMode$=new Ce(null),this.loggingService.log("%c[WB] Creating CLASS: ReactionService","color: blue;"),this.analyticsService.setReactionService(this),this.authService.setReactionService(this),this.databaseService.getDb().pipe(Fe(L=>!!L),tt(1)).subscribe(L=>{L&&(this.db=L,this.getAllReactionAnnotations(void 0,void 0,!0).subscribe())},L=>{this.loggingService.catch("Error in ReactionService getDb subscription: ",L)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ReactionService","color: green;");try{this.reactionAnnotationById$.next({}),this.customReactions$.next({}),this.documentPaths=null}catch(e){this.loggingService.catch("Error in ReactionService clearCache: ",e)}}getAllReactionAnnotations(e,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllReactionAnnotations","color: green;");let m,p;try{if(e&&(p=`${yn(e)}`),i&&typeof i=="object"){let h=Jo(i);m=yn(JSON.stringify(h))}}catch(h){this.loggingService.catch("Error in ReactionService getAllReactionAnnotations: ",h)}return qn(this.afAuth).pipe(Fe(h=>!!h),he(h=>this.isFeatureAllowed({firebaseUser:h,annotations:[],filteredAnnotations:[]})),he(h=>h.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(_=>(h.featureAllowed=_,h))):se(h)),he(h=>h.featureAllowed?se(h).pipe(he(_=>this.docService.getDocumentPaths$().pipe(ce(E=>(this.documentPaths=E,_.documentPaths=E,_)))),he(_=>p?this.getDataFromDocumentIds([p]).pipe(ce(E=>(_.annotations=E||[],I({},_)))):this.docService.getDocumentIds$().pipe(he(E=>{let D=E?.length>0?E.map(L=>L.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(D).pipe(ce(L=>(_.annotations=L||[],I({},_))))}))),he(_=>this.docService.getLocation$().pipe(ce(E=>(_.location=E,_)))),he(_=>this.docService.getLocations$().pipe(ce(E=>(_.customLocations=E,_)))),ce(_=>{if(_.filteredAnnotations=[],p&&!m)return _.filteredAnnotations=_.annotations?.slice(),_;{let E=[];return m?E.push(m):(E.push(_?.location?.locationId),E.push(...Object.values(_?.customLocations||[]).map(D=>D.locationId))),_.filteredAnnotations=this.filterAnnotationsByLocationIds(_?.annotations,E),_}}),he(_=>r?se(_):_?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>_)):se(_)),he(_=>r?se(_):se(_)),ce(_=>_),he(_=>_?.filteredAnnotations?se(_?.filteredAnnotations||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.REACTION)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Reaction feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i,filters:r}=e;if(i?.some(h=>!h)||!this.documentPaths)return se([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=this.docService.getDocumentPaths()?.allDocuments,m=se([]),p={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(p.documentId=i?.length?i[0]:void 0,p.organizationId=this.documentPaths?.organizationId),a&&s)m=this.commonDbService.dbListener({feature:"allReactions",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",a),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let h=[];for(let _=0;_<(i?.length??0);_+=j.LISTENER_BATCH_SIZE)h.push(i?.slice(_,_+j.LISTENER_BATCH_SIZE)??[]);m=Rn(h.map(_=>this.commonDbService.dbListener({feature:"allReactions",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",_),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[gt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Gr()))).pipe(ce(_=>ua(_)))}return m.pipe(ce(h=>({data:h?.data,operation:h?.operation})),ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),E?.forEach(D=>{this.sanitizeReactionAnnotation(D)}),{data:E,operation:_}}),ce(({data:h,operation:_})=>{if(!i)return{data:h,documentMap:{},operation:_};let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),ce(({data:h,documentMap:_,operation:E})=>{if(!r)if(E?.type==="removed"){if(E?.ids?.length){let D=this.reactionAnnotationById$.value;E?.ids?.forEach(L=>{delete D?.[L]}),this.reactionAnnotationById$.next(D)}}else Object.entries(_??{}).forEach(([D,L])=>{this.setReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:L})});return h}),jn(h=>(this.loggingService.catch("Error in ReactionService getDataFromDocumentId: ",h),se([]))))}else return se([])}setReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.reactionAnnotationById$.value),s);this.reactionAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in ReactionService setReactionAnnotationsByOrganizationIdAndDocumentId:",s)}}getReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};return Object.values(this.reactionAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==i&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in ReactionService getReactionAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getLocations$(){return this.docService.getLocation$().pipe(he(e=>this.docService.getLocations$().pipe(ce(i=>({location:e,locations:i})))),ce(e=>{let i=[];return i.push(e?.location?.locationId),i.push(...Object.values(e.locations||[]).map(r=>r.locationId)),i||[]}))}filterAnnotationsByLocationIds(e,i){try{return e.filter(r=>i.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ReactionService filterAnnotationsByLocations:",r),[]}}getAnnotationById(e,i){try{let r=this.reactionAnnotationById$.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in ReactionService getAnnotationById: ",r);return}}getBaseMetadataFromReactionAnnotationId(e){try{let i=this.reactionAnnotationById$.value?.[e];return i?i.metadata:void 0}catch(i){this.loggingService.catch("Error in ReactionService getBaseMetadataFromReactionAnnotationId: ",i);return}}getReactionAnnotationByAnnotationId(e,i){try{return this.reactionAnnotationById$.pipe(ce(()=>this.getAnnotationById(e,i)),he(r=>r?se(r):se(r)))}catch(r){return this.loggingService.catch("Error in ReactionService getReactionAnnotationByAnnotationId: ",r),se(void 0)}}getReactionAnnotationsBySectionId(e){try{return this.reactionAnnotationById$.pipe(he(i=>this.docService.getDocumentPaths$().pipe(ce(r=>({documentPaths:r,sectionId:e,reactionAnnotationsMap:i})))),he(i=>{let r=dr(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(ce(m=>{let h=Object.values(m||{}).find(_=>_.locationId===s||a?.id&&_.location.id===a.id);return T(I({},i),{additionalLocation:h,locationOnElement:!!a})}))}}return se(T(I({},i),{additionalLocation:null,element:r}))}),he(i=>i?.locationOnElement?se(i):this.docService.getLocation$().pipe(ce(r=>T(I({},i),{location:r})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s,element:m})=>{let p=null,h=this.docService.getAdditionalDocumentIdFromElement(m),_=h?this.docService.generateDocumentId(h):i?.documentId,E=i?.organizationId;if(_){let D=this.getReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:E,documentId:_});if(D){p=[];for(let L of D)L?.targetElementId===e&&(s?a&&$u({location:a?.location,locationId:a?.locationId},{location:L.location,locationId:L.locationId})&&p.push(L):r?$u({location:r?.location,locationId:r?.locationId},{location:L.location,locationId:L.locationId})&&p.push(L):L?.locationId||p.push(L))}}return p}))}catch(i){return this.loggingService.catch("Error in ReactionService getReactionAnnotationsBySectionId: ",i),se(null)}}addOrUpdateReaction(e,i,r,a,s,m,p,h){return Q(this,null,function*(){try{let _=i?.map(E=>this.getAnnotationById(E)).find(E=>E?.icon===e);if(_){if(!p||p==="delete")return yield this.updateUserInReaction(_)}else if(!p||p==="add")return yield this.addReaction(void 0,e,r,a,s,m,h)}catch(_){this.loggingService.catch("Error in ReactionService addOrUpdateReaction: ",_)}})}addReaction(e,i,r,a,s,m,p){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{let h=this.authService.getUser();if(h)if(h.isReadOnly||h.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add reactions.");else{let _=new vM;if(_.from=h,_.lastUpdated=this.timestamp,_.reactions=[],_.reactions.push({from:h,lastUpdated:this.timestamp}),a&&(_.targetElementId=a),s&&(_.commentAnnotationId=s),this.setLocationToReactionAnnotation(_),_.pageInfo=Ei(),_.pageInfo&&(_.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),i)if(_.icon=i,m)_.iconUrl=m?.url,_.iconEmoji=m?.emoji;else{let E=this.customReactions$.value;if(E){let D=E[i];D?.url&&(_.iconUrl=D?.url),D?.emoji&&(_.iconEmoji=D?.emoji)}}return r&&(_.location={},_.location=I({},r),_.locationId=this.docService.genarateLocationId(_.location)),yield this.saveReactionToDb(_)}}catch(h){this.loggingService.catch("Error in ReactionService addReaction: ",h)}})}setLocationToReactionAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location);try{let r;e.targetElement?.xpath?r=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId&&(r=dr(e.targetElementId,["id","data-id"]));let a=this.docService.getAdditionLocationFromElement(r);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}catch{}}catch(i){this.loggingService.catch("Error in ReactionService setLocationToReactionAnnotation:",i)}}getElementForReactionAnnotation(e){try{let i;return e.targetElementId&&(i=dr(e.targetElementId,["id","data-id"])),i}catch(i){return this.loggingService.catch("Error in ReactionService getElementForReactionAnnotation: ",i),null}}saveReactionToDb(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: saveReactionToDb","color: green;");try{if(this.authService.getUser()){let i=yield this.docService.getDocumentPaths$().pipe(Fe(a=>!!a),tt(1)).toPromise();if(!i)throw new Error("Document paths not found.");this.documentPaths=i,this.loggingService.log(this.documentPaths);let r=yield this.databaseService.getDb().pipe(Fe(a=>!!a),tt(1)).toPromise();if(!r)throw new Error("Database not found.");if(this.db=r,this.loggingService.log(this.db),this.documentPaths?.reaction){let a=rn(this.db,`${this.documentPaths.reaction}`);if(e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo,!e?.metadata?.documentId){e?.metadata||(e.metadata={});let h=this.getElementForReactionAnnotation(e),_=this.docService.getBaseMetadata("reaction",{commentAnnotationId:e.commentAnnotationId,element:h});e.metadata=I(I({},e?.metadata),_)}let s=JSON.parse(JSON.stringify(e));s.position=null;let{documentId:m,organizationId:p}=this.getDocumentIdAndOrganizationIdFromReactionAnnotation(e);return yield this.commonDbService.setData({feature:"reaction",properties:{id:e.annotationId,documentId:m,organizationId:p},data:s}),s}else return}}catch(i){this.loggingService.catch("Error in ReactionService saveReactionToDb: ",i)}})}getDocumentIdAndOrganizationIdFromReactionAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in ReactionService getDocumentIdAndOrganizationIdFromReactionAnnotation: ",i),{}}}updateUserInReaction(e){return Q(this,null,function*(){try{let i=this.authService.getUser();if(i)return e?.reactions||(e.reactions=[]),e?.reactions?.find(a=>a?.from?.userId===i?.userId)?e.reactions=e?.reactions?.filter(a=>a?.from?.userId!==i?.userId):e.reactions.push({from:i,lastUpdated:this.timestamp}),e.reactions.length?yield this.updateReaction(e):yield this.deleteReactionPinAnnotation(e?.annotationId),e}catch(i){this.loggingService.catch("Error in ReactionService updateUserInReaction: ",i)}})}removeUserFromReaction(e){this.loggingService.log("%c[WB] Calling FUNCTION: removeUserFromReaction","color: green;");try{let i=this.authService.getUser();i&&(e?.reactions||(e.reactions=[]),e.reactions=e?.reactions?.filter(r=>r?.from?.userId!==i?.userId),this.updateReaction(e))}catch(i){this.loggingService.catch("Error in ReactionService removeUserFromReaction: ",i)}}updateReaction(e,i,r){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateReaction","color: green;");try{if(this.authService.getUser()){if(e?.targetElement?.xpath){let p=this.domService.getXPath(e.targetElement.xpath);if(p){let h=p.iterateNext();h&&(Do(h)||(e.targetElement=null))}}let a=JSON.parse(JSON.stringify(e));if(a.position=null,a.lastUpdated=this.timestamp,!a?.metadata?.documentId){a?.metadata||(a.metadata={});let p=this.docService.getBaseMetadata("reaction",{commentAnnotationId:e.commentAnnotationId});a.metadata=I(I({},a?.metadata),p)}let{documentId:s,organizationId:m}=a?.metadata||{};return r?yield this.commonDbService.updateData({feature:"reaction",properties:{id:e.annotationId,documentId:s,organizationId:m},data:JSON.parse(JSON.stringify(a))}):yield this.commonDbService.setData({feature:"reaction",properties:{id:e.annotationId,documentId:s,organizationId:m},data:JSON.parse(JSON.stringify(a))}),a}}catch(a){this.loggingService.catch("Error in ReactionService updateReaction: ",a)}})}deleteReactionPinAnnotation(e,i){return Q(this,null,function*(){try{let r=this.getAnnotationById(e),{documentId:a,organizationId:s}=this.getDocumentIdAndOrganizationIdFromReactionAnnotation(r);yield this.commonDbService.deleteData({feature:"reaction",properties:{id:e,documentId:a,organizationId:s}})}catch(r){this.loggingService.catch("Error in ReactionService deleteReactionPinAnnotation: ",r)}})}setCustomReactions(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;"),this.customReactions$.next(e),this.emojiService.setEmojiList(e)}catch(i){this.loggingService.catch("Error in ReactionService setCustomReactions: ",i)}}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 ReactionService 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 ReactionService disableDarkMode: ",e)}}getDarkMode(){return this.darkMode$.value}getDarkMode$(){return this.darkMode$.asObservable()}sanitizeReactionAnnotation(e){try{e&&(e.iconUrl&&(e.iconUrl=this.domService.sanitizeHtml(e.iconUrl)),e.iconEmoji&&(e.iconEmoji=this.domService.sanitizeHtml(e.iconEmoji)),e.icon&&(e.icon=this.domService.sanitizeHtml(e.icon)))}catch(i){this.loggingService.catch("Error in ReactionService sanitizeReactionAnnotation: ",i)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(Ze),J(He),J(jt),J(hn),J(Tn),J(lt),J(Ne),J(wc),J(fn),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Vle=(()=>{let o=class o{constructor(e,i){this.domService=e,this.loggingService=i,this.keyEventSubject$=new Ke;try{this.loggingService.log("%c[WB] Creating CLASS: HotkeyService","color: blue;"),this.keyEvent$=this.keyEventSubject$.asObservable().pipe(Fg()),this.domService.onWindowKeydown$().subscribe(r=>{this.keyEventSubject$.next(r)})}catch(r){this.loggingService.catch("Error in HotkeyService constructor: ",r)}}getKeyPressEvent(e,i={}){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getKeyPressEvent","color: green;"),this.keyEvent$.pipe(Fe(r=>r?.key===e),Fe(r=>!(!!i?.includeCtrl!==r.ctrlKey||!!i?.includeAlt!==r.altKey||!!i?.includeShift!==r.shiftKey||!!i?.includeMeta!==r.metaKey)),Fe(()=>this.isNoInputFocused()))}catch(r){return this.loggingService.catch("Error in HotkeyService getKeyPressEvent: ",r),new Lt}}isNoInputFocused(){try{let e=document.activeElement;for(;e&&e?.tagName!=="BODY";){if(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e?.isContentEditable)return!1;e=e?.parentElement}return!0}catch(e){return this.loggingService.catch("Error in HotkeyService isNoInputFocused: ",e),!1}}};o.\u0275fac=function(i){return new(i||o)(J(Ne),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Ye=(()=>{let o=class o{constructor(e,i){this.loggingService=e,this.configService=i,this.darkMode$=new Ce(!1)}setDarkMode(e){try{let i=document.documentElement;if(!i)return;e?i.setAttribute(j.ATTRIBUTES.VELT_THEME,"dark"):i.removeAttribute(j.ATTRIBUTES.VELT_THEME),this.darkMode$.next(e)}catch(i){this.loggingService.catch("Error in theme service setDarkMode: ",i)}}getDarkMode$(){return this.darkMode$.asObservable()}updateListenerOnConfigChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.usePrefersColorScheme){this.enablePrefersColorScheme();return}this.disablePrefersColorScheme()})}catch(e){this.loggingService.catch("Error in theme service updateListenerOnConfigChange: ",e)}}enablePrefersColorScheme(){try{if(this.disablePrefersColorScheme(),!window.matchMedia)return;this.darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.setDarkMode(this.darkModeQuery.matches),this.darkModeQueryListener=e=>{this.setDarkMode(e.matches)},this.darkModeQuery.addEventListener("change",this.darkModeQueryListener)}catch(e){this.loggingService.catch("Error in theme service enablePrefersColorScheme: ",e)}}disablePrefersColorScheme(){try{this.darkModeQuery&&this.darkModeQueryListener&&this.darkModeQuery.removeEventListener("change",this.darkModeQueryListener)}catch(e){this.loggingService.catch("Error in theme service disablePrefersColorScheme: ",e)}}};o.\u0275fac=function(i){return new(i||o)(J(y),J(jt))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();function Y7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",17)(2,"path",18)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function K7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",22)(2,"path",23)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function Z7e(n,o){if(n&1&&(f(0),C(1,"div",6)(2,"div",7),g(3,Y7e,6,0,"svg",8)(4,K7e,6,0,"ng-template",null,1,De),S(),C(6,"div",9),te(7),A(8,"translate"),w(9,"br"),te(10),A(11,"translate"),S(),C(12,"div",10)(13,"p"),te(14),A(15,"translate"),le(),C(16,"svg",11),w(17,"path",12)(18,"path",13)(19,"path",14)(20,"path",15),S(),te(21),A(22,"translate"),S(),mt(),C(23,"p"),te(24),A(25,"translate"),S()()(),v()),n&2){let t=pe(5),e=l();d(3),c("ngIf",e.darkMode)("ngIfElse",t),d(4),ve(" ",P(8,7,"Allow mic permission to"),""),d(3),ve("",P(11,9,"enable your audio")," "),d(4),ve(" ",P(15,11,"1. Click the")," "),d(7),ve(" ",P(22,13,"page info icon in your browser\u2019s address bar")," "),d(3),ve(" ",P(25,15,"2. Turn on Microphone")," ")}}function X7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",17)(2,"path",24)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function Q7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",22)(2,"path",25)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function J7e(n,o){if(n&1&&(f(0),C(1,"div",6)(2,"div",7),g(3,X7e,6,0,"svg",8)(4,Q7e,6,0,"ng-template",null,2,De),S(),C(6,"div",9),te(7),A(8,"translate"),w(9,"br"),te(10),A(11,"translate"),S(),C(12,"div",10)(13,"p"),te(14),A(15,"translate"),le(),C(16,"svg",11),w(17,"path",12)(18,"path",13)(19,"path",14)(20,"path",15),S(),te(21),A(22,"translate"),S(),mt(),C(23,"p"),te(24),A(25,"translate"),S()()(),v()),n&2){let t=pe(5),e=l();d(3),c("ngIf",e.darkMode)("ngIfElse",t),d(4),ve(" ",P(8,7,"Allow camera permission"),""),d(3),ve("",P(11,9,"to enable your video")," "),d(4),ve(" ",P(15,11,"1. Click the")," "),d(7),ve(" ",P(22,13,"page info icon in your browser\u2019s address bar")," "),d(3),ve(" ",P(25,15,"2. Turn on Camera")," ")}}var OM=(()=>{let o=class o{constructor(e,i,r,a,s){this.loggingService=e,this.themeService=i,this.elementRef=r,this.matDialogRef=a,this.data=s,this.veltElement=!0,this.darkMode=!0;try{this.loggingService.log("%c[WB] Creating CLASS: DevicePermissionDeniedDialogComponent","color: blue;"),this.type=this.data?.type,[!0,!1].includes(this.data?.darkMode)&&(this.darkMode=this.data?.darkMode)}catch(m){this.loggingService.catch("Error in DevicePermissionDeniedDialogComponent constructor: ",m)}}ngOnDestroy(){}};o.\u0275fac=function(i){return new(i||o)(u(y),u(Ye),u(k),u(Xo,8),u(bl,8))},o.\u0275cmp=O({type:o,selectors:[["velt-device-permission-denied-dialog-internal"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{type:"type"},standalone:!1,decls:5,vars:5,consts:[["devicePermissionDialogRef",""],["defaultAudioIcon",""],["defaultVideoIcon",""],[1,"velt-device-permission-denied-dialog--container",3,"snippylyOverlay","snippylyOverlayZIndex"],[3,"ngSwitch"],[4,"ngSwitchCase"],[1,"velt-device-permission-denied-dialog"],[1,"velt-device-permission-denied-dialog--icon"],["width","61","height","60","viewBox","0 0 61 60","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf","ngIfElse"],[1,"velt-device-permission-denied-dialog--header"],[1,"velt-device-permission-denied-dialog--content"],["width","13","height","12","viewBox","0 0 13 12","fill","none","xmlns","http://www.w3.org/2000/svg",1,"velt-device-permission-denied-dialog--page-info-icon"],["d","M4.375 2.5C4.375 3.53553 3.53553 4.375 2.5 4.375C1.46447 4.375 0.625 3.53553 0.625 2.5C0.625 1.46447 1.46447 0.625 2.5 0.625C3.53553 0.625 4.375 1.46447 4.375 2.5Z","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M5 2.5H12.5","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M0 8.75H7.5","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M11.875 8.75C11.875 9.78553 11.0355 10.625 10 10.625C8.96447 10.625 8.125 9.78553 8.125 8.75C8.125 7.71447 8.96447 6.875 10 6.875C11.0355 6.875 11.875 7.71447 11.875 8.75Z","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["width","61","height","60","viewBox","0 0 61 60","fill","none","xmlns","http://www.w3.org/2000/svg"],["x","0.5","y","4","width","56","height","56","rx","28","fill","white","fill-opacity","0.04"],["d","M23.5026 20.333C23.5026 19.0069 24.0294 17.7352 24.9671 16.7975C25.9048 15.8598 27.1765 15.333 28.5026 15.333C29.8287 15.333 31.1005 15.8598 32.0381 16.7975C32.9758 17.7352 33.5026 19.0069 33.5026 20.333V28.6663C33.5027 29.1599 33.4297 29.6508 33.2859 30.123M29.9526 33.4563C29.2054 33.6828 28.4155 33.7311 27.6463 33.5973C26.8771 33.4636 26.1499 33.1516 25.5229 32.6863C24.8959 32.2211 24.3866 31.6154 24.0358 30.9179C23.685 30.2204 23.5024 29.4504 23.5026 28.6697V27.003M16.8359 28.6663C16.8356 30.7719 17.405 32.8383 18.484 34.6465C19.5629 36.4546 21.111 37.9371 22.9642 38.9366C24.8174 39.9362 26.9066 40.4156 29.0102 40.324C31.1137 40.2324 33.1533 39.5732 34.9126 38.4163M38.2459 35.083C39.5023 33.1791 40.1701 30.9474 40.1659 28.6663M21.8359 46.9997H35.1693M28.5026 40.333V46.9997","stroke","white","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M13.5 17L43.5 47","stroke","currentColor","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["x","36.5","width","24","height","24","rx","12","fill","currentColor"],["d","M48.5 18.99V19M48.5 14V5","stroke","white","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["x","0.5","y","4","width","56","height","56","rx","28","fill","black","fill-opacity","0.04"],["d","M23.5026 20.333C23.5026 19.0069 24.0294 17.7352 24.9671 16.7975C25.9048 15.8598 27.1765 15.333 28.5026 15.333C29.8287 15.333 31.1005 15.8598 32.0381 16.7975C32.9758 17.7352 33.5026 19.0069 33.5026 20.333V28.6663C33.5027 29.1599 33.4297 29.6508 33.2859 30.123M29.9526 33.4563C29.2054 33.6828 28.4155 33.7311 27.6463 33.5973C26.8771 33.4636 26.1499 33.1516 25.5229 32.6863C24.8959 32.2211 24.3866 31.6154 24.0358 30.9179C23.685 30.2204 23.5024 29.4504 23.5026 28.6697V27.003M16.8359 28.6663C16.8356 30.7719 17.405 32.8383 18.484 34.6465C19.5629 36.4546 21.111 37.9371 22.9642 38.9366C24.8174 39.9362 26.9066 40.4156 29.0102 40.324C31.1137 40.2324 33.1533 39.5732 34.9126 38.4163M38.2459 35.083C39.5023 33.1791 40.1701 30.9474 40.1659 28.6663M21.8359 46.9997H35.1693M28.5026 40.333V46.9997","stroke","black","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M42.375 39.2135C42.7034 39.1007 42.9883 38.8881 43.19 38.6054C43.3917 38.3227 43.5001 37.9841 43.5 37.6369V26.3635C43.4998 26.0795 43.4271 25.8003 43.2888 25.5523C43.1504 25.3043 42.9509 25.0958 42.7093 24.9465C42.4677 24.7973 42.192 24.7122 41.9083 24.6994C41.6246 24.6867 41.3424 24.7466 41.0883 24.8735L33.5 28.6669V30.3335V25.3333C33.5 24.4493 33.1488 23.6014 32.5237 22.9763C31.8986 22.3512 31.0507 22 30.1667 22H25.1667M33.5 37V38.6667C33.5 39.5507 33.1488 40.3986 32.5237 41.0237C31.8986 41.6488 31.0507 42 30.1667 42H16.8333C15.9493 42 15.1014 41.6488 14.4763 41.0237C13.8512 40.3986 13.5 39.5507 13.5 38.6667V25.3333C13.5 24.4493 13.8512 23.6014 14.4763 22.9763C15.1014 22.3512 15.9493 22 16.8333 22H18.5","stroke","white","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M42.375 39.2135C42.7034 39.1007 42.9883 38.8881 43.19 38.6054C43.3917 38.3227 43.5001 37.9841 43.5 37.6369V26.3635C43.4998 26.0795 43.4271 25.8003 43.2888 25.5523C43.1504 25.3043 42.9509 25.0958 42.7093 24.9465C42.4677 24.7973 42.192 24.7122 41.9083 24.6994C41.6246 24.6867 41.3424 24.7466 41.0883 24.8735L33.5 28.6669V30.3335V25.3333C33.5 24.4493 33.1488 23.6014 32.5237 22.9763C31.8986 22.3512 31.0507 22 30.1667 22H25.1667M33.5 37V38.6667C33.5 39.5507 33.1488 40.3986 32.5237 41.0237C31.8986 41.6488 31.0507 42 30.1667 42H16.8333C15.9493 42 15.1014 41.6488 14.4763 41.0237C13.8512 40.3986 13.5 39.5507 13.5 38.6667V25.3333C13.5 24.4493 13.8512 23.6014 14.4763 22.9763C15.1014 22.3512 15.9493 22 16.8333 22H18.5","stroke","currentColor","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(i,r){if(i&1&&(C(0,"div",3,0),f(2,4),g(3,Z7e,26,17,"ng-container",5)(4,J7e,26,17,"ng-container",5),v(),S()),i&2){let a=pe(1);c("snippylyOverlay",a)("snippylyOverlayZIndex",3e3),d(2),c("ngSwitch",r.type),d(),c("ngSwitchCase","audio"),d(),c("ngSwitchCase","video")}},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%]{--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-device-permission-denied-dialog--panel mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{padding:0;background-color:transparent;box-shadow:none;overflow:unset}.velt-device-permission-denied-dialog[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--velt-spacing-lg);align-items:center;justify-content:center;padding:4rem;box-sizing:border-box;word-break:break-word;max-width:600px;max-height:400px;text-align:center;background-color:var(--velt-background-0);border-radius:var(--velt-border-radius-2xl);box-shadow:0 calc((4rem + 0px) * var(--velt-base-rem-unit)) calc((4rem + 0px) * var(--velt-base-rem-unit)) calc((-3rem + 0px) * var(--velt-base-rem-unit)) #1f2f461f}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--icon[_ngcontent-%COMP%]{color:var(--velt-error)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--header[_ngcontent-%COMP%]{font-size:var(--velt-font-size-lg);font-weight:600;line-height:36px;letter-spacing:-.02em;text-align:center;color:var(--velt-text-0)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--content[_ngcontent-%COMP%]{font-size:var(--velt-font-size-sm);font-weight:400;line-height:21px;text-align:center;color:var(--velt-text-0)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--content[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--page-info-icon[_ngcontent-%COMP%]{margin-left:var(--velt-spacing-sm);margin-right:var(--velt-spacing-sm);color:var(--velt-error)}"],changeDetection:0});let n=o;return n})();var Pm=(()=>{let o=class o{constructor(e,i){this.loggingService=e,this.matDialog=i,this.audioPermissionState$=new Ce(null),this.videoPermissionState$=new Ce(null);try{this.loggingService.log("%c[WB] Creating CLASS: DevicePermissionService","color: blue;"),this.checkPermissions()}catch(r){this.loggingService.catch("Error in DevicePermissionService constructor: ",r)}}checkPermissions(){try{this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: checkPermissions","color: green;"),new ei().browserName!=="Firefox"&&(navigator.permissions.query({name:"microphone"}).then(i=>{this.audioPermissionState$.next(i.state),i.onchange=()=>{this.audioPermissionState$.next(i.state)}}).catch(i=>{}),navigator.permissions.query({name:"camera"}).then(i=>{this.videoPermissionState$.next(i.state),i.onchange=()=>{this.videoPermissionState$.next(i.state)}}).catch(i=>{}))}catch(e){this.loggingService.catch("Error in DevicePermissionService checkPermissions: ",e)}}getPermissionState$(e){try{switch(this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: getPermissionState$","color: green;"),e){case"audio":return this.getAudioPermissionState$();case"video":return this.getVideoPermissionState$();default:return se(null)}}catch(i){return this.loggingService.catch("Error in DevicePermissionService getPermissionState$: ",i),se(null)}}getAudioPermissionState$(){return this.audioPermissionState$.asObservable()}getVideoPermissionState$(){return this.videoPermissionState$.asObservable()}openDevicePermissionDeniedDialog(e,i){try{this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: openDevicePermissionDeniedDialog","color: green;"),this.matDialog.open(OM,{panelClass:"velt-device-permission-denied-dialog--panel",backdropClass:["velt-device-permission-denied-dialog--backdrop","s-background-blur-1"],data:I({type:e},i||{})})}catch(r){this.loggingService.catch("Error in DevicePermissionService openDevicePermissionDeniedDialog: ",r)}}};o.\u0275fac=function(i){return new(i||o)(J(y),J(Ki))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var eke=()=>["video","screen"];function tke(n,o){if(n&1&&w(0,"app-recording-preview-steps-dialog-video",4),n&2){let t=l(2);c("componentConfigSignal",t.componentConfigSignal)}}function nke(n,o){if(n&1&&w(0,"app-recording-preview-steps-dialog-audio",4),n&2){let t=l(2);c("componentConfigSignal",t.componentConfigSignal)}}function ike(n,o){if(n&1&&(f(0),C(1,"div",2,0),g(3,tke,1,1,"app-recording-preview-steps-dialog-video",3)(4,nke,1,1,"app-recording-preview-steps-dialog-audio",3),S(),v()),n&2){let t=o.ngIf,e=pe(2),i=l();d(),c("snippylyOverlay",e)("snippylyOverlayZIndex",2e3),x("aria-label","Recording preview - "+t.type+" mode")("data-testid",i.componentId),d(2),c("ngIf",Nt(6,eke).includes(t.type)),d(),c("ngIf",t.type==="audio")}}var AM=(()=>{let o=class o{constructor(e,i,r,a,s,m,p){this.loggingService=e,this.recorderService=i,this.dialog=r,this.devicePermissionService=a,this.dialogRef=s,this.elementRef=m,this.data=p,this.darkMode=!1,this.shadowDom=!0,this.startCountdownFrom=3,this.defaultMediaSourceOptions=yc(),this.recordingCountdownEnabled=!1,this.subscriptions=[],this.veltElement=!0,this.componentId="velt-recording-preview-steps-dialog",this.componentConfigSignal=Te({closeDialog:this.closeDialog.bind(this),startCountdown:this.startCountdown.bind(this),toggleAudio:this.toggleAudio.bind(this),toggleVideo:this.toggleVideo.bind(this),toggleSettings:this.toggleSettings.bind(this),cancelCountdown:this.cancelCountdown.bind(this),updateMediaConfig:this.updateMediaConfig.bind(this),handleOverlayClick:this.handleOverlayClick.bind(this),countdownStarted:!1,mediaConfig:{audio:{enabled:!1},video:{enabled:!1}},mediaState:{audio:{enabled:!1},video:{enabled:!1}},type:"video",countdown:this.startCountdownFrom,mediaStream:void 0,isSettingsOpen:!1,darkMode:this.darkMode,shadowDom:this.shadowDom});try{this.devicePermissionService.getPermissionState$("video").subscribe(h=>{this.componentConfigSignal.update(_=>(_=T(I({},_),{mediaState:T(I({},_.mediaState),{video:{enabled:h!=="denied"}})}),_))}),this.devicePermissionService.getPermissionState$("audio").subscribe(h=>{this.componentConfigSignal.update(_=>(_=T(I({},_),{mediaState:T(I({},_.mediaState),{audio:{enabled:h!=="denied"}})}),_))}),this.subscriptions.push(this.recorderService.getRecordingCountdownEnabled$().subscribe(h=>{this.recordingCountdownEnabled=h})),p&&(p.type&&this.componentConfigSignal.update(h=>(h=T(I({},h),{type:p.type}),h)),p.recordingCountdown!==void 0&&(this.recordingCountdownEnabled=!!p.recordingCountdown),p.mediaConfig&&(p.mediaConfig?.audio?.enabled&&!p.mediaConfig?.audio?.deviceId&&(p.mediaConfig.audio.deviceId=this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId),p.mediaConfig?.video?.enabled&&!p.mediaConfig?.video?.deviceId&&(p.mediaConfig.video.deviceId=this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId),p?.darkMode?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark"),this.componentConfigSignal.update(h=>(h=T(I({},h),{shadowDom:p?.shadowDom!==!1,darkMode:p.darkMode||!1}),h)),this.updateMediaConfig(p.mediaConfig)))}catch(h){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent constructor: ",h)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnInit:",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Recording preview steps dialog")}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(i=>{this.componentConfigSignal.update(r=>(r=T(I({},r),{[i]:e[i].currentValue}),r))})}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnChanges: ",i)}}ngAfterViewInit(){try{this.dialogRef.addPanelClass("snippyly-recording-preview-steps-dialog"),this.dialogRef.disableClose=!0}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngAfterViewInit: ",e)}}toggleSettings(e){try{e.stopPropagation(),this.componentConfigSignal.update(i=>(i=T(I({},i),{isSettingsOpen:!i.isSettingsOpen}),i))}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleSettings: ",i)}}toggleAudio(){try{this.componentConfigSignal().mediaConfig.audio||this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:{enabled:!0}})}),r));let e=!this.componentConfigSignal().mediaConfig.audio?.enabled;this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:{enabled:e}})}),r));let i=this.componentConfigSignal().mediaStream?.getAudioTracks()[0];i?i.enabled=e:e&&(this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:T(I({},r.mediaConfig.audio),{deviceId:this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId})})}),r)),this.updateMediaConfig(this.componentConfigSignal().mediaConfig))}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleAudio: ",e)}}toggleVideo(){try{this.componentConfigSignal.update(e=>(e=I({},e),e.mediaConfig.video||(e.mediaConfig.video={enabled:!0}),e.mediaConfig.video.enabled=!e.mediaConfig.video.enabled,e.mediaConfig.video.deviceId=this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId,e)),this.updateMediaConfig(this.componentConfigSignal().mediaConfig)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleVideo: ",e)}}updateMediaConfig(e){try{this.stopMediaStream(),this.getMediaStream(e)}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent updateMediaConfig: ",i)}}getMediaStream(e){try{if(!navigator.mediaDevices){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ","No media devices");return}if(!navigator.mediaDevices.getUserMedia){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ","No getUserMedia");return}if(e.audio?.enabled||e.video?.enabled){let i={};e.audio?.enabled&&(i.audio={deviceId:e.audio.deviceId}),e.video?.enabled&&(i.video={deviceId:e.video.deviceId}),navigator.mediaDevices.getUserMedia(i).then(r=>{this.componentConfigSignal.update(a=>(a=T(I({},a),{mediaConfig:e,mediaStream:r}),a))}).catch(r=>{this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream catch: ",r)})}else this.componentConfigSignal.update(i=>(i=T(I({},i),{mediaStream:void 0,mediaConfig:e}),i))}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ",i)}}stopMediaStream(){try{this.componentConfigSignal.update(e=>(e=I({},e),e.mediaStream?.getTracks().forEach(i=>{i.stop()}),e.mediaStream=void 0,e))}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent stopMediaStream: ",e)}}startCountdown(){return Q(this,null,function*(){try{if(this.componentConfigSignal().type==="screen"){let e=yield navigator.mediaDevices.getDisplayMedia();this.componentConfigSignal.update(i=>(i=I({},i),i.mediaConfig.screen={enabled:!0,stream:e},i)),e?.getTracks().forEach(i=>{i&&(i.onended=()=>{this.cancelCountdown()})})}this.recordingCountdownEnabled?(this.componentConfigSignal.update(e=>(e=T(I({},e),{countdownStarted:!0}),e)),this.countdownInterval=setInterval(()=>{this.componentConfigSignal().countdown>1?this.componentConfigSignal.update(e=>(e=T(I({},e),{countdown:e.countdown-1}),e)):this.closeDialog(this.componentConfigSignal().mediaConfig)},1e3)):this.closeDialog(this.componentConfigSignal().mediaConfig)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent startCountdown: ",e)}})}cancelCountdown(){try{if(this.componentConfigSignal.update(e=>(e=T(I({},e),{countdownStarted:!1,countdown:this.startCountdownFrom}),e)),this.clearInterval(),this.componentConfigSignal().type==="screen"){let e=this.componentConfigSignal().mediaConfig.screen?.stream;e&&e.getTracks().forEach(i=>{i.stop()}),this.componentConfigSignal.update(i=>(i=I({},i),i.mediaConfig.screen=void 0,i))}}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent cancelCountdown: ",e)}}closeDialog(e){return Q(this,null,function*(){try{this.clearInterval(),this.stopMediaStream(),this.dialogRef.close(e)}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent closeDialog: ",i)}})}handleOverlayClick(e){try{this.componentConfigSignal.update(i=>(i=T(I({},i),{isSettingsOpen:!1}),i)),e.stopPropagation()}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent handleOverlayClick: ",i)}}clearInterval(){try{this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=void 0)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent clearInterval: ",e)}}ngOnDestroy(){try{this.clearInterval(),this.stopMediaStream(),this.subscriptions.forEach(e=>{e?.unsubscribe()})}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(i){return new(i||o)(u(y),u(ui),u(Ki),u(Pm),u(Xo),u(k),u(bl,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-recording-preview-steps-dialog"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{darkMode:"darkMode",shadowDom:"shadowDom"},standalone:!1,features:[Xe],decls:1,vars:1,consts:[["recordingPreviewDialogRef",""],[4,"ngIf"],["role","dialog","aria-modal","true",3,"snippylyOverlay","snippylyOverlayZIndex"],[3,"componentConfigSignal",4,"ngIf"],[3,"componentConfigSignal"]],template:function(i,r){i&1&&g(0,ike,5,7,"ng-container",1),i&2&&c("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%]{--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)} .snippyly-recording-preview-steps-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background:transparent;padding:0;margin:0;border-radius:var(--velt-border-radius-lg)}"],changeDetection:0});let n=o;return n})();var ui=(()=>{let o=class o{constructor(e,i,r,a,s,m,p){this.analyticsService=e,this.loggingService=i,this.matDialog=r,this.storageService=a,this.docService=s,this.databaseService=m,this.domService=p,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 Ke,this.recordedRawData$=new Ke,this.recordedData$=new Ke,this.onInitRecording$=new Ce(null),this.onRecordingAttributeRemovedFromBodySubject$=new Ke,this.videoEditor$=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.db=Ii(),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.onInitRecording$.subscribe(h=>{h?this.setRecordingAttributeAtBody():this.removeRecordingAttributeFromBody()}),this.databaseService.getDb().pipe(Fe(h=>!!h),tt(1)).subscribe(h=>{h&&(this.db=h,this.getDocumentPaths())},h=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",h)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(gn(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(j.ATTRIBUTES.VELT_ONGOING_RECORDING,e.type),e?.isCommentRecording&&document.body.setAttribute(j.ATTRIBUTES.VELT_COMMENT_RECORDING,"true"))}catch(e){this.loggingService.catch("Error in RecorderService setRecordingAttributeAtBody: ",e)}}removeRecordingAttributeFromBody(){try{document.body.removeAttribute(j.ATTRIBUTES.VELT_ONGOING_RECORDING),document.body.removeAttribute(j.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,i,r,a,s,m,p,h){return Q(this,null,function*(){try{let _={};switch(e){case"audio":_.audio={enabled:!0};break;case"video":_.video={enabled:!0},_.audio={enabled:!0};break;case"screen":_.screen={enabled:!0},_.video={enabled:!1},_.audio={enabled:!1};break;default:break}this.matDialog.open(AM,{data:{type:e,mediaConfig:_,darkMode:[!0,!1].includes(a)?a:this.darkMode$.value,shadowDom:s,recordingCountdown:h}}).afterClosed().subscribe(E=>{if(E){let D={};switch(e){case"audio":D.audio={enabled:!0,deviceId:E.audio?.deviceId},D.audio=E.audio;break;case"video":D.video={enabled:!0,deviceId:E.video?.deviceId},D.audio={enabled:!0,deviceId:E.audio?.deviceId},D.video=E.video,D.audio=E.audio;break;case"screen":D.screen={enabled:!0},D.audio=E.audio,D.video=E.video,D.screen=E.screen;break;default:break}this.onInitRecording$.next({type:e,panelId:i,mediaConfig:D,isCommentRecording:r,darkMode:[!0,!1].includes(a)?a:!!this.darkMode$.value,shadowDom:s,commentAnnotationId:m,clientDocumentId:p})}},E=>{this.loggingService.catch("Error in RecorderService initRecording afterClosed: ",E)})}catch(_){this.loggingService.catch("Error in RecorderService initRecording: ",_)}})}startRecording(e,i){return Q(this,null,function*(){try{this.loggingService.log("[startRecording] Starting with config:",e,"mediaConfig:",i);let r=new MediaStream,a=yield this.getBrowserSpecificOptions();return yield this.collectMediaTracks(r,e,i),yield this.initializeMediaRecorder(r,a),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},i=this.getSupportedMimeTypes();if(i.length>0){let r=i.find(a=>a.includes("mp4")&&a.includes("h264"))||i.find(a=>a.includes("mp4"))||i[0];e.mimeType=r}return e}catch(e){return this.loggingService.catch("Error in RecorderService getBrowserSpecificOptions: ",e),{}}})}collectMediaTracks(e,i,r){return Q(this,null,function*(){try{if(i.type.screen&&r?.screen?.stream){let a=this.getCommonVideoQualityConstraints(!0);r.screen.stream.getTracks().forEach(s=>{e.addTrack(s),s.onended=()=>this.stopRecording(),s.applyConstraints(I({},a))})}if(i?.type.audio||i?.type.video){let a=this.buildMediaConstraints(i,r),s=yield navigator.mediaDevices.getUserMedia(a);if(s)if(this.isSafari()){if(i?.type.audio&&(yield this.adjustSafariAudioTrack(e,s)),i?.type.video){let m=s.getVideoTracks();if(m.length>0){let p=m[0];p.enabled=!0;let h=p.clone();e.addTrack(h),r&&r.video&&(r.video.track=p)}}}else s.getTracks().forEach(m=>e.addTrack(m))}}catch(a){this.loggingService.catch("Error in RecorderService collectMediaTracks: ",a);return}})}buildMediaConstraints(e,i){try{let r=this.getCommonVideoQualityConstraints(!!e.type.video);return{audio:this.getCommonAudioConstraints(!!e.type.audio,i),video:e.type.video?T(I({deviceId:i?.video?.deviceId?{ideal:i.video.deviceId}:void 0},r),{facingMode:"user"}):!1}}catch(r){return this.loggingService.catch("Error in RecorderService buildMediaConstraints: ",r),{}}}getCommonAudioConstraints(e,i){try{if(!e)return!1;let r=this.recordingQualityConstraints.value[this.isSafari()?"safari":"other"]?.audio||{};return I({deviceId:i?.audio?.deviceId?{ideal:i.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(i){return this.loggingService.catch("Error in RecorderService getCommonVideoQualityConstraints: ",i),{}}}adjustSafariAudioTrack(e,i){return Q(this,null,function*(){try{let r=i.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}})}initializeMediaRecorder(e,i){return Q(this,null,function*(){try{this.mediaRecorder=new MediaRecorder(e,i),this.chunks=[],this.chunkUrls$.next({}),this.uploadPromises=[];let r=0;if(this.isSafari()){let s=e.getVideoTracks();s.length>0&&s.forEach(m=>{m.contentHint="detail",m.enabled=!0})}this.mediaRecorder.addEventListener("dataavailable",s=>{if(s.data?.size>0){let m=r++;this.chunks.push(s.data);let p=`recording_${new Date().getTime()}_${Math.random().toString(36).substring(2,9)}`,h=s.data,_=this.uploadChunk(h,p,m);this.uploadPromises||(this.uploadPromises=[]),this.uploadPromises.push({promise:_,index:m}),_.then(E=>{this.chunkUrls$.next(T(I({},this.chunkUrls$.value),{[m]:E}))}).catch(E=>{console.error("Chunk upload failed",E)})}}),this.mediaRecorder.addEventListener("stop",()=>this.onStopRecording()),this.mediaRecorder.start(4e3)}catch(r){this.loggingService.catch("Error in RecorderService initializeMediaRecorder: ",r);return}})}uploadChunk(e,i,r){return Q(this,null,function*(){try{let a="video/mp4",m=`chunk_${r}_${new Date().getTime()}.mp4`,p=new File([e],m,{type:a});return yield this.uploadChunkToStorage(p,i,r)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunk: ",a),a}})}uploadChunkToStorage(e,i,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,m=`${j.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${j.FIREBASE_PARTIAL_PATH_RECORDER}/${i}`;return a&&(m=`${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${a}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${j.FIREBASE_PARTIAL_PATH_RECORDER}/${i}`),this.storageService.uploadChunk(m,e,r)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunkToStorage: ",a),a}}setupRecorderData(e,i){try{return this.recorderInitData=new pM,this.recorderStatusSubject$.next("started"),this.isSafari()&&e.type.video&&i.getVideoTracks().forEach(r=>{r.enabled=!0}),this.recorderInitData.stream=i,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.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(i){return this.loggingService.catch("Error in RecorderService determineRecorderType: ",i),"audio"}}timeout(e){return new Promise(i=>setTimeout(i,e))}pauseRecording(){try{this.recorderStatusSubject$.next("paused"),this.mediaRecorder.pause(),this.recordingDurations?.length&&(this.recordingDurations[this.recordingDurations.length-1].end=new Date().getTime()),this.stopTimer()}catch(e){this.loggingService.catch("Error in RecorderService pauseRecording: ",e)}}resumeRecording(){try{this.recorderStatusSubject$.next("resumed"),this.mediaRecorder.resume(),this.recordingDurations.push({start:new Date().getTime()}),this.startTimer()}catch(e){this.loggingService.catch("Error in RecorderService resumeRecording: ",e)}}stopRecording(){try{this.mediaRecorder?.state!=="inactive"?(this.mediaRecorder.stop(),this.removeRecordingAttributeFromBody()):this.clearRecording()}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(i=>{i.stop()}),yield this.timeout(100);let e=new gM;if(this.chunks.length>0){let i=this.recorderInitData?.type==="audio"?"audio/mp4":"video/mp4";this.loggingService.log("[onStopRecording] Creating blob with type:",i),e.blob=new Blob(this.chunks,{type:i}),this.loggingService.log("[onStopRecording] Blob created, size:",e.blob.size);let r=yield this.getVideoDuration(e.blob);if(r){let a={};a.duration=r*1e3,a.display=this.convertMillisecondsToTime(r*1e3),this.recorderDurationSubject$.next(a),e.recordedTime=a}if(e.blob.size===0)throw new Error("Recorded blob has zero size");if(e.url=URL.createObjectURL(e.blob),e.type=this.recorderInitData?.type,e.recordedTime=this.recorderDurationSubject$.value,e?.type!=="audio")try{yield this.timeout(200);let a=yield qoe(e.blob,3);a&&(e.thumbnail=yield Yoe(a))}catch(a){this.loggingService.catch("Error in RecorderService onStopRecording getVideoCover: ",a)}this.recordedRawData$.next(e)}else throw new Error("No data chunks recorded")}catch(e){this.loggingService.catch("Error in RecorderService onStopRecording: ",e),this.recordedRawData$.error(e)}})}clearRecording(){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling RecorderService FUNCTION: clearRecording","color: green;"),this.recorderStatusSubject$.next(null),this.recorderDurationSubject$.next(null),this.onInitRecording$.next(null),this.recordingDurations=[],this.domService.resetRecordingInProgress(),this.mediaRecorder=null,this.recorderInitData?.stream?.getTracks()?.forEach(e=>{e.stop()}),this.recorderInitData=null,this.recorderInitData$.next(null),this.chunks=[],this.chunkUrls$.next({}),this.stopTimer()}catch(e){this.loggingService.catch("Error in RecorderService clearRecording: ",e)}})}startTimer(){try{this.stopTimer(),this.durationInterval=setInterval(()=>{this.calculateRecordedTime()},1e3)}catch(e){this.loggingService.catch("Error in RecorderService startTimer: ",e)}}stopTimer(){try{this.durationInterval&&clearInterval(this.durationInterval)}catch(e){this.loggingService.catch("Error in RecorderService stopTimer: ",e)}}calculateRecordedTime(){try{if(this?.recordingDurations?.length){let e=0;this.recordingDurations.forEach(i=>{i.end?e+=i?.end-i.start:e+=new Date().getTime()-i.start;let r={};r.duration=e,r.display=this.convertMillisecondsToTime(e),this.recorderDurationSubject$.next(r)})}else this.recorderDurationSubject$.next(null)}catch(e){this.loggingService.catch("Error in RecorderService calculateRecordedTime: ",e)}}convertMillisecondsToTime(e){try{let i=Math.floor(e/1e3),r=Math.floor(i/60),a=Math.floor(r/60);return i=i%60,r=r%60,`${a?a.toString().padStart(2,"0")+":":""}${r.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}catch(i){return this.loggingService.catch("Error in RecorderService convertMillisecondsToTime: ",i),""}}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}}getSupportedMimeTypes(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getSupportedMimeTypes","color: green;"),["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"].filter(i=>MediaRecorder.isTypeSupported(i))}catch(e){return this.loggingService.catch("Error in RecorderService getSupportedMimeTypes: ",e),[]}}enableVideoEditor(){try{if(this.videoEditor$.value===!0)return;this.videoEditor$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableVideoEditor: ",e)}}disableVideoEditor(){try{if(this.videoEditor$.value===!1)return;this.videoEditor$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableVideoEditor: ",e)}}getVideoEditor$(){return this.videoEditor$.asObservable()}getVideoEditor(){return this.videoEditor$.value}waitForChunksUpload(){return Q(this,null,function*(){try{if(this.uploadPromises.length===0)return{};let e=this.uploadPromises.map(i=>i.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(i){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",i)}}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 i=this.recordingQualityConstraints.value;i={other:{audio:I(I({},i.other?.audio),e.other?.audio),video:I(I({},i.other?.video),e.other?.video)},safari:{audio:I(I({},i.safari?.audio),e.safari?.audio),video:I(I({},i.safari?.video),e.safari?.video)}},this.recordingQualityConstraints.next(i)}catch(i){this.loggingService.catch("Error in RecorderService setRecordingQualityConstraints: ",i)}}setRecordingEncodingOptions(e){try{let i=this.recordingEncodingOptions.value;i={other:I(I({},i.other),e.other),safari:I(I({},i.safari),e.safari)},this.recordingEncodingOptions.next(i)}catch(i){this.loggingService.catch("Error in RecorderService setRecordingEncodingOptions: ",i)}}getVideoDuration(e){return Q(this,null,function*(){return new Promise((i,r)=>{try{let a=URL.createObjectURL(e),s=document.createElement("video");s.onloadedmetadata=()=>{let m=s.duration;URL.revokeObjectURL(a),i(m)},s.onerror=m=>{URL.revokeObjectURL(a),r(m)},s.src=a,s.load()}catch(a){this.loggingService.catch("Error in RecorderService getVideoDuration: ",a),r(a)}})})}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(y),J(Ki),J(Kp),J(lt),J(hn),J(Ne))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var es=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_){this.afAuth=e,this.authService=i,this.configService=r,this.databaseService=a,this.docService=s,this.commonDbService=m,this.iamService=p,this.loggingService=h,this.notificationService=_,this.documentPaths=null,this.db=Ii(),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(Fe(E=>!!E),tt(1)).subscribe(E=>{E&&(this.db=E,this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(D=>{this.notificationService.setNotificationViews(D)}),this.authService.getUser$().pipe(Fe(D=>!!D),he(D=>this.documentViewsEnabled$.pipe(Fe(L=>L),ce(()=>D))),he(D=>this.docService.getDocumentPaths$().pipe(qo(null),Pi(),ce(([L,H])=>(L?.documentId!==H?.documentId&&this.views$.next({}),H)),ce(L=>(this.documentPaths=L,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:D,_documentPaths:L})),he(L=>this.docService.getDocumentIds$().pipe(he(H=>(H?.length&&(H.find(K=>K.documentId===this.documentPaths?.documentId)||H.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),H.forEach(K=>{this.setDocumentAsRead({documentId:K.documentId,clientDocumentId:K.clientDocumentId})})),se(L))))))),he(D=>this.docService.getDocumentMetadata$().pipe(Fe(L=>!!L),ce(L=>T(I({},D),{_documentMetadata:L}))))).subscribe(),this.authService.getUser$().pipe(Fe(D=>!!D),he(D=>this.documentViewsEnabled$.pipe(Fe(L=>L),ce(()=>D))),he(D=>this.docService.getLocation$().pipe(Fe(L=>!!L))),he(D=>this.docService.getDocumentIds$().pipe(he(L=>(L.find(H=>H.documentId===this.documentPaths?.documentId)||L.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),L.forEach(H=>{this.setLocationAsRead({documentId:H.documentId,clientDocumentId:H.clientDocumentId})}),se(D)))))).subscribe())},E=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",E)})}catch(E){this.loggingService.catch("Error in ViewsService constructor: ",E)}}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,i){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let r,a;try{if(e&&(a=yn(e)),i&&typeof i=="object"){let s=Jo(i);r=yn(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return qn(this.afAuth).pipe(Fe(s=>!!s),he(s=>this.isFeatureAllowed({firebaseUser:s})),he(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(m=>(s.featureAllowed=m,s))):se(s)),he(s=>s.featureAllowed?se(s).pipe(he(m=>this.docService.getDocumentPaths$().pipe(ce(p=>(this.documentPaths=p,m.documentPaths=p,m)))),he(m=>a?this.getDataFromDocumentIds([a]):this.docService.getDocumentIds$().pipe(he(p=>{let h=p?.length>0?p.map(_=>_.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(h)})))):se([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>i.user?se(T(I({},i),{featureAllowed:!0})):se(T(I({},i),{featureAllowed:!1}))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getCommentViewsById(e){try{return this.commentViews$.value?.[e]?this.commentViews$.value?.[e]:void 0}catch(i){this.loggingService.catch("Error in ViewsService getCommentViewsById: ",i);return}}getDocumentViewsById(e){try{return this.documentViews$.value?.[e]}catch(i){this.loggingService.catch("Error in ViewsService getDocumentViewsById: ",i);return}}getLocationViewsById(e){try{return this.locationViews$.value?.[e]}catch(i){this.loggingService.catch("Error in ViewsService getLocationViewsById: ",i);return}}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i,filters:r}=e;return i?.some(a=>!a)||!this.documentPaths?se([]):this.documentViewsEnabled$.pipe(he(a=>a?Rn([this.getCommentViewsDataFromDocuments(i),this.getDocumentViewsDataFromDocuments(i),this.getLocationViewsDataFromDocuments(i)]):Rn([this.getCommentViewsDataFromDocuments(i)])))}else return se(null)}getCommentViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.commentViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.commentViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,commentViews:E})})}))}getDocumentViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allDocumentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.documentViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.documentViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,documentViews:E})})}))}getLocationViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allLocationViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allLocationViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.locationViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.locationViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,locationViews:E})})}))}setViewsData(e){try{this.views$.next(I(I({},this.views$.getValue()),e||{}))}catch(i){this.loggingService.catch("Error in ViewsService setViewsData:",i)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,commentViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.commentViews$.value),r);this.commentViews$.next(s),this.commentViewsByOrganizationIdAndDocumentId$.next(T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[i]:T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,documentViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.documentViews$.value),r);this.documentViews$.next(s),this.documentViewsByOrganizationIdAndDocumentId$.next(T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[i]:T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,locationViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.locationViews$.value),r);this.locationViews$.next(s),this.locationViewsByOrganizationIdAndLocationId$.next(T(I({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:T(I({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[i]:T(I({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentFeatureViews$(){return this.commentViews$.pipe(qt((e,i)=>JSON.stringify(e||{})===JSON.stringify(i||{})))}setCommentAnnotationAsRead(e){return Q(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){let r=this.getCommentViewsById(e.annotationId)??(yield this.commonDbService?.getData({feature:"commentViews",properties:{id:e.annotationId,documentId:e.metadata?.documentId??this.documentPaths?.documentId??"",organizationId:e?.metadata?.organizationId??this.documentPaths?.organizationId??""}})),a=this.updateCommentAnnotationViews(e,r||{});this.commonDbService.setData({feature:"commentViews",properties:{id:e.annotationId,documentId:e.metadata?.documentId??this.documentPaths?.documentId??"",organizationId:e?.metadata?.organizationId??this.documentPaths?.organizationId??""},data:a})}}catch(i){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",i)}})}updateCommentAnnotationViews(e,i){try{let r=this.authService.getUser(),a={views:{},comments:{}};if(r){let s={},m=i?.comments||{},p=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(_=>{m[_.commentId]||(m[_.commentId]={views:{}}),m[_.commentId].views||(m[_.commentId].views={}),m[_.commentId].views[r.userSnippylyId]||(m[_.commentId].views[r.userSnippylyId]={},m[_.commentId].views[r.userSnippylyId].timestamp=p)});let h=new Set(e.comments?.map(_=>_.commentId+""));if(Object.keys(m??{}).forEach(_=>{h.has(_)||delete m[_]}),e.comments?.length){let _=m[e.comments[0].commentId]?.views||{};Object.keys(_??{}).filter(D=>e.comments?.every(L=>m[L.commentId]?.views?.[D])).forEach(D=>{s[D]={timestamp:_[D].timestamp}})}a.views=s,a.comments=m}return e?.metadata?a.metadata=e.metadata:a.metadata=this.docService.getBaseMetadata(),a}catch(r){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",r),{views:{},comments:{}}}}deleteCommentAnnotationViews(a,s){return Q(this,arguments,function*(e,{documentId:i,organizationId:r}){try{yield this.commonDbService.deleteData({feature:"commentViews",properties:{id:e.annotationId,documentId:i,organizationId:r}})}catch(m){this.loggingService.catch("Error in ViewsService deleteCommentAnnotationViews:",m)}})}getNotificationFeatureViews$(){return this.views$.pipe(qt((e,i)=>JSON.stringify(e?.notification||{})===JSON.stringify(i?.notification||{})))}setNotificationsAsRead(e){try{let i=this.authService.getUser();if(i){let r=new Date().getTime()+this.commonDbService.getOffset();e.forEach(a=>{this.commonDbService.updateData({feature:"notificationViewsTimestamp",properties:{id:a,user:i.userSnippylyId,documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??""},data:{timestamp:r}})})}}catch(i){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",i)}}getDocumentViews$(){return this.views$.pipe(qt((e,i)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(i?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(he(i=>(this.documentPaths=i,e?this.locationViews$.pipe(ce(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.users||{}:{}})):this.documentViews$.pipe(ce(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.users||{}:{}})))),qt(Vi))}catch(i){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",i),se({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(he(i=>(this.documentPaths=i,e?this.locationViews$.pipe(ce(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.day||{}:{}})):this.documentViews$.pipe(ce(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.day||{}:{}})))))}catch(i){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",i),se({})}}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:i}){try{let a=this.authService.getUser();if(a&&e){if(this.documentViewsSetByDocumentId[e])return;this.documentViewsSetByDocumentId[e]=!0;let s=new Date().getTime()+this.commonDbService.getOffset(),m=new Date().toISOString().split("T")[0],p=this.getDocumentViewsById(e);if(p){let h=new Date().toISOString().split("T")[0];p?.users[a.userSnippylyId]||(p.users[a.userSnippylyId]={}),p.users[a.userSnippylyId][h]={timestamp:this.timestamp},p?.day[h]||(p.day[h]={}),p.day[h][a.userSnippylyId]={timestamp:this.timestamp},p.metadata=this.docService.getBaseMetadata("documentViews",{clientDocumentId:i}),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:h,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??""},data:p})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:m,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:m,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:i})}),this.docService.getDocumentMetadata$(e).pipe(Fe(h=>h!==null),tt(1)).subscribe(()=>{let h={day:{[m]:{[a.userSnippylyId]:{timestamp:s}}},users:{[a.userSnippylyId]:{[m]:{timestamp:s}}},metadata:this.docService.getBaseMetadata("documentViews",{clientDocumentId:i})};this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:m,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0},data:h})});this.checkAndTriggerNotification(a)}}catch(a){this.loggingService.catch("Error in ViewsService setDocumentAsRead:",a)}})}checkAndTriggerNotification(e){try{this.getUniqueViewsByUser().pipe(tt(1)).subscribe(i=>{if(Object.keys(i??{}).length===2){let r=this.docService.getDocumentMetadata();if(r?.creator?.email&&r?.creator?.email!==e.email){let a=[r.creator.email];this.updateNotificationsDatabase(vU.FIRST_VIEWED,{documentViews:{emails:a}})}}})}catch(i){this.loggingService.catch("Error in checkAndTriggerNotification:",i)}}setLocationAsRead(r){return Q(this,arguments,function*({documentId:e,clientDocumentId:i}){try{let a=this.authService.getUser(),s=this.docService.getLocation(),m=s?.locationId,p=s?.location;if(a&&m&&p){let h=new Date().getTime()+this.commonDbService.getOffset(),_=new Date().toISOString().split("T")[0],E=this.getLocationViewsById(m);if(E){let D=new Date().toISOString().split("T")[0];E?.users[a.userSnippylyId]||(E.users[a.userSnippylyId]={}),E.users[a.userSnippylyId][D]={timestamp:this.timestamp},E?.day[D]||(E.day[D]={}),E.day[D][a.userSnippylyId]={timestamp:this.timestamp},E.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:i}),this.commonDbService.updateData({feature:"location",data:E,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:p,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:m,user:a.userSnippylyId,date:_,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:h}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:m,date:_,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:h}}),this.commonDbService.updateData({feature:"locationMetadataViews",properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("locationViews",{clientDocumentId:i})});let D={day:{[_]:{[a.userSnippylyId]:{timestamp:h}}},users:{[a.userSnippylyId]:{[_]:{timestamp:h}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:i}),location:p};this.commonDbService.updateData({feature:"location",data:D,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0}})}}}catch(a){this.loggingService.catch("Error in ViewsService setLocationAsRead:",a)}})}updateNotificationsDatabase(e,i={}){try{let r=I({actionType:e,notificationSource:"documentViews"},i);this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",r)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(He),J(jt),J(hn),J(lt),J(Tn),J(fn),J(y),J(vn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Mm=(()=>{let o=class o{constructor(e,i,r){this.docService=e,this.loggingService=i,this.authService=r;try{this.loggingService.log("%c[WB] Creating CLASS: MetadataService","color: blue;")}catch(a){this.loggingService.catch("Error in MetadataService constructor: ",a)}}getGlobalMetadata(){return Q(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),{};let i=this.docService.getOrganizationMetadata(this.docService.getOrganizationConfig()?.organizationId),r=this.docService.getDocumentMetadataOfAvailableDocuments(),a=this.docService.getLocation();i&&(i=JSON.parse(JSON.stringify(i)),delete i?.organizationId,i.organizationId=i?.clientOrganizationId,delete i?.clientOrganizationId,delete i?.pageInfo),r&&(r=JSON.parse(JSON.stringify(r)),r.forEach(_=>{delete _?.locations,delete _?.location,delete _?.locationId,delete _?.pageInfo,delete _?.documentId,_.documentId=_?.clientDocumentId,delete _?.clientDocumentId,delete _?.veltFolderId,_?.clientOrganizationId&&(_.organizationId=_?.clientOrganizationId,delete _?.clientOrganizationId)}));let s=[];a&&(a=JSON.parse(JSON.stringify(a)),a?.location&&s.push(a?.location));let m=this.docService.getLocations();m&&Object.values(m).forEach(_=>{_?.location&&s.push(_?.location)});let p=this.docService.getDocumentPaths()?.folderId;return{organization:i,documents:r,locations:s,folderId:p}}catch(e){return this.loggingService.catch("Error in MetadataService getGlobalMetadata: ",e),{}}})}};o.\u0275fac=function(i){return new(i||o)(J(lt),J(y),J(He))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var o0=(()=>{let o=class o{constructor(e,i,r){this.coreActionsService=e,this.loggingService=i,this.metadataService=r,this.buttonClickSubject$=new Ke,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(s){return Q(this,arguments,function*({id:e,type:i,groupId:r,contextData:a}){try{this.buttonToggle(e,void 0,i,r);let m=this.extractButtonData(a),p=this.createButtonContext(e,i,r),h=yield this.metadataService.getGlobalMetadata(),_=T(I({buttonContext:p},m),{metadata:h});this.buttonClickSubject$.next(_),this.coreActionsService.triggerAction(Xi.VELT_BUTTON_CLICK,_)}catch(m){this.loggingService.catch("Error in ButtonService buttonClick: ",m)}})}buttonActive({id:e,type:i,groupId:r,contextData:a}){try{let s=this.buttonToggleMap$.value?.[r||"ungrouped"]?.[e]||!0;this.buttonToggle(e,s,i,r)}catch(s){this.loggingService.catch("Error in ButtonService buttonClick: ",s)}}buttonToggle(e,i,r,a){try{let s=this.buttonToggleMap$.value,m=this.createNewToggleMap(s,e,i,r,a);this.buttonToggleMap$.next(m)}catch(s){this.loggingService.catch("Error in ButtonService buttonToggle: ",s)}}extractButtonData(e){try{let i={};return Object.entries(this.contextDataMapping).forEach(([r,a])=>{let s=this.getNestedValue(e,a.source);s!==void 0&&(i[a.target]=s)}),i}catch(i){return this.loggingService.catch("Error in ButtonService extractContextData: ",i),{}}}getNestedValue(e,i){try{let r=e;for(let a of i){if(r?.[a]===void 0)return;Fi(r[a])?r=r[a]():r=r[a]}return r}catch(r){this.loggingService.catch("Error in ButtonService getNestedValue: ",r);return}}createButtonContext(e,i,r){try{let a={type:i,selections:this.buttonToggleMap$.value,clickedButtonId:e};return(i==="single-select"||i==="multi-select")&&r?T(I({},a),{groupId:r}):a}catch(a){return this.loggingService.catch("Error in ButtonService createButtonMetadata: ",a),{}}}createNewToggleMap(e,i,r,a,s){try{let m=I({},e);return a==="button-toggle"?T(I({},m),{ungrouped:T(I({},m.ungrouped),{[i]:r??!m.ungrouped?.[i]})}):a==="single-select"&&s?T(I({},m),{[s]:{[i]:r??!0}}):a==="multi-select"&&s?T(I({},m),{[s]:T(I({},m[s]),{[i]:r??!m[s]?.[i]})}):m}catch(m){return this.loggingService.catch("Error in ButtonService createNewToggleMap: ",m),{}}}buttonClickSubject(){return this.buttonClickSubject$.asObservable()}buttonToggleMap(){return this.buttonToggleMap$.asObservable()}resetVeltButtonState(e){return Q(this,null,function*(){try{if(e){let{id:s,group:m}=e,p=JSON.parse(JSON.stringify(this.buttonToggleMap$.value||{}));m&&s?delete p?.[m]?.[s]:m?delete p?.[m]:s&&Object.keys(p).forEach(h=>{Object.keys(p[h]).forEach(_=>{_===s&&delete p?.[h]?.[_]})}),this.buttonToggleMap$.next(p)}else this.buttonToggleMap$.next({});let i={selections:this.buttonToggleMap$.value},r=yield this.metadataService.getGlobalMetadata(),a={buttonContext:i,metadata:r};this.coreActionsService.triggerAction(Xi.VELT_BUTTON_CLICK,a)}catch(i){this.loggingService.catch("Error in ButtonService resetVeltButtonState: ",i)}})}buttonToggleMapValue(){return this.buttonToggleMap$.value}};o.\u0275fac=function(i){return new(i||o)(J(wm),J(y),J(Mm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var we=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L,H,K,oe,ue,be,Le,qe,Re,_e,Ee,Oe,ye,fe,Be){this.analyticsService=e,this.areaService=i,this.commonDbService=r,this.configService=a,this.docService=s,this.databaseService=m,this.authService=p,this.domService=h,this.afAuth=_,this.avatarService=E,this.contactService=D,this.storageService=L,this.functions=H,this.dialog=K,this.iamService=oe,this.loggingService=ue,this.notificationService=be,this.customFilterService=Le,this.reactionService=qe,this.hotkeyService=Re,this.recorderService=_e,this.viewsService=Ee,this.buttonService=Oe,this.metadataService=ye,this.commonDbUtilsService=fe,this.attachmentResolverService=Be,this.customPinsById=new Map,this.commentAdded$=new Ke,this.commentUpdated$=new Ke,this.commentAccepted$=new Ke,this.commentRejected$=new Ke,this.commentAnnotationDeleted$=new Ke,this.multiThreadCommentAnnotationDeleted$=new Ke,this.commentAnnotationById$=new Ce(null),this.multiThreadCommentAnnotationById$=new Ce(null),this.ghostCommentAnnotationMap$=new Ce({}),this.unreadCommentsMap$=new Ce(null),this.documentPaths=null,this.db=Ii(),this.user=null,this.customCategoryMap=j.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 Ke,this.onUpgradeClick$=new Ke,this.enableAttachment$=new Ce(!0),this.enableReactions$=new Ce(!0),this.allowedRecordings$=new Ce(["audio","video","screen"]),this.openSidebar$=new Ke,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(B6.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Ce(!1),this.sidebarButtonOnCommentDialogClick$=new Ke,this.commentNavigationButtonClick$=new Ke,this.deviceIndicatorOnCommentPins$=new Ce(!1),this.sidebarCommentClick$=new Ke,this.privateCommentMode$=new Ce(!1),this.scrollToComment$=new Ce(!0),this.userMentions$=new Ce(!0),this.deleteOnBackspace$=new Ce(!0),this.hotkeyEnabled$=new Ce(!1),this.recordingSummaryEnabled$=new Ce(!0),this.unreadIndicatorMode$=new Ce(Vu.MINIMAL),this.composerMode$=new Ce(Uu.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.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.svgAsImg$=new Ce(!1),this.commentToNearestAllowedElement$=new Ce(!1),this.filterCommentsOnDom$=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 Ke,this.commentsFromSidebarMap$=new Ce(null),this.commentSidebarFilters$=new Ce({}),this.commentSidebarSystemFiltersOperator$=new Ce(hc.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.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.loggingService.log("%c[WB] Creating CLASS: CommentService","color: blue;"),this.analyticsService.setCommentService(this),this.notificationService.setCommentService(this),this.docService.setCommentService(this),this.authService.setCommentService(this),this.docService.getDocumentPaths$().pipe(Pi()).subscribe(([xe,wn])=>{xe?.documentId!==wn?.documentId&&this.unreadCommentsMap$.next(null)},xe=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",xe)}),this.authService.getUser$().subscribe(xe=>{xe||this.resetCacheData()},xe=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",xe)}),this.databaseService.getDb().pipe(Fe(xe=>!!xe),tt(1)).subscribe(xe=>{xe&&(this.db=xe,this.getDocumentPaths())},xe=>{this.loggingService.catch("Error in CommentService getDb subscription: ",xe)}),this.domService.onWindowPointerMove$().subscribe(xe=>{if(this.addCommentMode$.value){let wn=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let $t=this.domService.getBackgroundElement(xe.clientX,xe.clientY,!0,!0);if($t)if(this.isElementInsideAllowedElements($t))if(wd(xe.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==$t&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=$t;let ft=this.domService.getSelectedAnnotationsMap("comment")||{},Ot=this.commentPinCursorImage$.value||j.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,Ot,!!Object.keys(ft)?.length),wn=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&wn&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},xe=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",xe)}),this.domService.onWindowKeyupEsc$().subscribe(xe=>{if(this.addCommentMode$.value){let wn=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(wn)?.length?this.domService.resetSelectedAnnotationsMap():this.disableAddCommentMode()}},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",xe)}),this.domService.onDocumentClick$().subscribe(xe=>{if(xe?.target&&!zi(xe?.target)){let wn=this.domService.getSelectedAnnotationsMap("comment")||{};if(wn=I(I({},wn),this.domService.getSelectedAnnotationsMap("multiThread")||{}),Object.keys(wn)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),xe.preventDefault(),xe.stopPropagation();return}}if(xe&&this.addCommentMode$.value&&!wd(xe.target)){let wn=!1;if(this.addCommentDragMode)xe.preventDefault(),xe.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let $t=this.domService.getBackgroundElement(xe.clientX,xe.clientY);(this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(xe.clientX,xe.clientY)||xe?.target&&zi(xe?.target))&&($t=null),$t&&(this.isElementInsideAllowedElements($t)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement($t))&&(wn=this.isElementInsideManualCommentContainer($t),wn||(xe.preventDefault(),xe.stopPropagation(),this.addComment(xe)))}this.persistentCommentMode$?.value?this.detectToAddAreaComment():wn||this.disableAddCommentMode()}},xe=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",xe)}),this.addCommentMode$.subscribe(xe=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),xe?(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(wn=>wn.unsubscribe()))},xe=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",xe)}),this.domService.onWindowKeyupBackspace$().subscribe(xe=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",xe)}),this.domService.onWindowKeyupDelete$().subscribe(xe=>{this.deleteCommentPinAnnotations("keyupDelete")},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",xe)}),this.domService.getDeleteCommmentAnnotations$().subscribe(xe=>{xe?.length&&(xe?.filter($t=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes($t.type))).forEach($t=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation($t)}))},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",xe)}),this.getPopoverMode$().subscribe(xe=>{xe?document?.body?.setAttribute(j.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(j.ATTRIBUTES.VELT_POPOVER_MODE)},xe=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",xe)}),this.customFilterService.customCategoryMap$.subscribe(xe=>{this.customCategoryMap=xe},xe=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",xe)}),this.hotkeyEnabled$.subscribe(xe=>{xe?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},xe=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",xe)}),this.domService.getSelectedAnnotationsMap$().pipe(Pi()).subscribe(([xe,wn])=>{try{let $t=Object.values(xe||{}).filter(Ot=>!["tag","recorder","rewriter","arrow","area"].includes(Ot.type)),ft=Object.values(wn||{}).filter(Ot=>!["tag","recorder","rewriter","arrow","area"].includes(Ot.type));$t?.forEach(Ot=>{ft?.find(Mt=>Mt.annotationId===Ot.annotationId)||this.commentSelectionChange$.next({annotation:zn(Ot),selected:!1})}),ft?.forEach(Ot=>{$t?.find(Mt=>Mt.annotationId===Ot.annotationId)||this.commentSelectionChange$.next({annotation:zn(Ot),selected:!0})})}catch($t){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",$t)}},xe=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",xe)})}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(i){this.loggingService.catch("Error in CommentService setCommentActionsService: ",i)}}detectToAddAreaComment(){try{let e=this.areaService.getAreaEnabled(),i=this.getAreaCommentEnabled();if(e&&i){let r,a,s,m=null,p=null;this.dragSubscriptions.forEach(h=>h.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe(Fe(h=>!zi(h?.target)),tt(1)).subscribe(h=>{m=null,p=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(_=>{if(m===null){let E=_?.startPoint?.event?.target,D=zi(E),L=wd(E),H=this.isElementInsideAllowedElements(E);m=!D&&!L&&H}if(m){this.addCommentDragMode=!0,r=_.startPoint,a=_.curPoint;let E=_?.curPoint?.event?.target,D=zi(E),L=wd(E),H=this.isElementInsideAllowedElements(E);p=!D&&!L&&H,p?s=this.domService.drawRectangle(r,a):s?.remove()}})),this.domService.onWindowPointerUp$().pipe(Ps(1),tt(1)).subscribe(_=>{if(a={x:_.clientX,y:_.clientY},r&&a&&(s?.remove(),m&&p)){let E=[{x:r.x-window.scrollX,y:r.y-window.scrollY},{x:a.x,y:a.y}];this.addComment(_,void 0,E)}this.dragSubscriptions.forEach(E=>E.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(j.TAGS.VELT_AREAS)||document.querySelector(j.TAGS.SNIPPYLY_AREAS))){let i=document.createElement(j.TAGS.VELT_AREAS);document.body.appendChild(i)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${j.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(i=>{window.getComputedStyle(i).position==="static"&&i.setAttribute(j.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${j.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(i=>{i.removeAttribute(j.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(i){this.loggingService.catch("Error in CommentService setCommentAddedEmitter: ",i)}}setContextProvider(e){try{this.commentContextProvider=e}catch(i){this.loggingService.catch("Error in CommentService setContextProvider: ",i)}}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:ke.COMMENT,config:{allowedElementIds:e}}),this.allowedElementIds$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementIds: ",i)}}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}setAllowedElementClassNames(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{allowedElementClassNames:e}}),this.allowedElementClassNames$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementClassNames: ",i)}}getAllowedElementClassNames(){return this.allowedElementClassNames$.asObservable()}setAllowedElementQuerySelectors(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{allowedElementQuerySelectors:e}}),this.allowedElementQuerySelectors$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementQuerySelectors: ",i)}}getAllowedElementQuerySelectors(){return this.allowedElementQuerySelectors$.asObservable()}getAnnotationsCount(e){try{return qn(this.afAuth).pipe(Fe(i=>!!i),he(i=>this.isFeatureAllowed({firebaseUser:i,annotations:[],filteredAnnotations:[]})),he(i=>i.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(r=>(i.featureAllowed=r,i))):se(i)),he(i=>i.featureAllowed?se(i).pipe(he(r=>this.docService.getDocumentPaths$().pipe(ce(a=>(this.documentPaths=a,r.documentPaths=a,r)))),he(()=>e?.documentIds?.length?se(e?.documentIds.map(r=>({clientDocumentId:r,documentId:`${yn(r)}`}))):this.docService.getDocumentIds$().pipe(ce(r=>r?.length>0?r:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))),he(r=>{let a=this.authService.getUser()?.userSnippylyId,s=this.documentPaths?.organizationId,m=r?.length>0?r.map(L=>L.documentId):[this.documentPaths?.documentId??""];if(m.some(L=>!L)||!this.documentPaths)return se();let p=this.docService.getDocumentPaths()?.veltFolderId,h=this.docService.getDocumentPaths()?.allDocuments,_=se(),E=se(),D={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(p&&h)_=this.commonDbService.dbListener({feature:"allComments",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.veltFolderId","==",p),...e?.statusIds?[gt("status.id","in",e.statusIds)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(ce(L=>L?.data)),E=this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.veltFolderId","==",p))]})}).pipe(ce(L=>L?.data));else{let L=[];for(let H=0;H<(m?.length??0);H+=j.LISTENER_BATCH_SIZE)L.push(m?.slice(H,H+j.LISTENER_BATCH_SIZE)??[]);_=Rn(L.map(H=>this.commonDbService.dbListener({feature:"allComments",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.documentId","in",H),...e?.statusIds?[gt("status.id","in",e.statusIds)]:[],...p?[gt("metadata.veltFolderId","==",p)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(Gr()))).pipe(ce(H=>ua(H)?.data)),E=Rn(L.map(H=>this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.documentId","in",H),...p?[gt("metadata.veltFolderId","==",p)]:[])]})}).pipe(Gr()))).pipe(ce(H=>ua(H)?.data))}return Rn([_,E]).pipe(he(([L,H])=>!L||!H?se(null):se([L,H]).pipe(ce(([K,oe])=>{let ue=Object.values(K||{});e?.locationIds?.length&&(ue=ue.filter(_e=>e.locationIds?.includes(_e.location?.id??"")));let be={};ue.forEach(_e=>{be[_e.annotationId]=_e});let Le={};Object.entries(oe||{}).forEach(([_e,Ee])=>{be[_e]&&(Ee?.views?.[a]||(Le[_e]=Ee))});let qe=ue.reduce((_e,Ee)=>{let Oe=Ee?.metadata?.clientDocumentId;return Oe&&(_e[Oe]||(_e[Oe]=[]),_e[Oe].push(Ee)),_e},{}),Re=Object.values(Le).reduce((_e,Ee)=>{let Oe=Ee?.metadata?.clientDocumentId;return Oe&&(_e[Oe]||(_e[Oe]=[]),_e[Oe].push(Ee)),_e},{});return r.reduce((_e,{clientDocumentId:Ee})=>{_e?.data||(_e.data={});let Oe=qe[Ee]?.length??0,ye=Re[Ee]?.length??0;return _e.data[Ee]={total:Oe,unread:ye},_e},{data:{}})}),jn(K=>(this.loggingService.catch("Error in CommentService getAnnotationsCount: ",K),se(null))))))})):se(null)),ce(i=>i||{data:null}),qt(Vi))}catch(i){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",i),se({data:null})}}getAllCommentAnnotations({customClientDocumentId:e,params:i,excludeDomChanges:r,detectGhostComments:a,skipPositionCalculation:s,query:m,fromCommentSidebar:p,analytics:h,addFilterCommentsOnDomCheck:_}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let E,D,L;h?.enabled&&this.analyticsService.trackEvent(h?.eventName||X.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,h?.properties);try{if(e&&(L=`${yn(e)}`),i&&typeof i=="object"){let H=Jo(i);D=H?.id,E=yn(JSON.stringify(H))}}catch(H){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",H)}return qn(this.afAuth).pipe(Fe(H=>!!H),he(H=>this.isFeatureAllowed({firebaseUser:H,annotations:[],filteredAnnotations:[]})),he(H=>H.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(K=>(H.featureAllowed=K,H))):se(H)),he(H=>H.featureAllowed?se(H).pipe(he(K=>this.docService.getDocumentPaths$().pipe(ce(oe=>(this.documentPaths=oe,K.documentPaths=oe,K)))),he(K=>m?.documentIds?.length||L?this.getDataFromDocumentIds({documentIds:L?[L]:m?.documentIds?.map(oe=>`${yn(oe)}`),organizationId:this.documentPaths?.organizationId,query:m}).pipe(ce(oe=>({res:K,data:oe}))):this.docService.getDocumentIds$().pipe(he(oe=>{let ue=oe?.length>0?oe.map(be=>be.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ue.length>0?ue:[L??""],organizationId:this.documentPaths?.organizationId,query:m}).pipe(ce(be=>({res:K,data:be})))}))),he(K=>K?.data?(K.res.annotations=K.data||[],se(K.res).pipe(he(oe=>this.docService.getLocation$().pipe(ce(ue=>(oe.location=ue,oe)))),he(oe=>this.docService.getLocations$().pipe(ce(ue=>(oe.customLocations=ue,oe)))),he(oe=>this.docService.getExcludedLocationIds$().pipe(ce(ue=>(oe.excludedLocationIds=ue,oe)))),ce(oe=>{if(oe.filteredAnnotations=[],m)return oe.filteredAnnotations=oe.annotations?.slice(),oe;if(L&&!E||p)return oe.filteredAnnotations=oe.annotations?.slice(),oe?.excludedLocationIds?.length&&(oe.filteredAnnotations=oe.filteredAnnotations?.filter(ue=>ue?.location?.id?!oe.excludedLocationIds.includes(ue.location.id):!0)),oe;{let ue=[],be=[];return E?(ue.push(E),D&&be.push(D)):(ue.push(oe?.location?.locationId),ue.push(...Object.values(oe?.customLocations||[]).map(Le=>Le.locationId)),oe?.location?.location?.id&&be.push(oe?.location?.location?.id),be.push(...Object.values(oe?.customLocations||{}).map(Le=>Le.location?.id).filter(Le=>!!Le))),oe.filteredAnnotations=this.filterAnnotationsByLocationIds(oe?.annotations,ue,be),oe?.excludedLocationIds?.length&&(oe.filteredAnnotations=oe.filteredAnnotations?.filter(Le=>Le?.location?.id?!oe.excludedLocationIds.includes(Le.location.id):!0)),oe}}),he(oe=>this.iamService.isUserAdmin$().pipe(ce(ue=>(ue||(oe.filteredAnnotations=oe.filteredAnnotations?.filter(be=>be?.iam?.accessMode!==Qi.PRIVATE)),oe)))),he(oe=>this.draftCommentAnnotationsByAnnotationId$.pipe(ce(ue=>(oe.filteredAnnotations=oe.filteredAnnotations?.filter(be=>!be.isDraft),ue&&oe.filteredAnnotations.push(...Object.values(ue)),oe)))),he(oe=>r?se(oe):oe?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ce(()=>oe)):se(oe)),he(oe=>r?se(oe):this.addCommentMode$.pipe(he(ue=>ue&&!this.getChangeDetectionInCommentMode()?se(oe):oe?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(ce(()=>oe)):se(oe)))),ce(oe=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(oe.filteredAnnotations=oe.filteredAnnotations?.map(ue=>{let be=Object.assign({},ue);return this.calculateCommentAnnotationPosition(be,a),be})),oe)),he(oe=>oe?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(ce(ue=>(this.updateUnreadAnnotationsMap(oe?.annotations,ue),oe))):se(oe)),he(oe=>oe?.filteredAnnotations?se(oe?.filteredAnnotations||[]):se([])))):se(null))):se(null)),qt((H,K)=>Vi(H,K)),he(H=>_?this.filterCommentsUsingSidebarSettings(H):se(H)))}getAllMultiThreadCommentAnnotations(e,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let m,p;try{if(e&&(p=yn(e)),i&&typeof i=="object"){let h=Jo(i);m=yn(JSON.stringify(h))}}catch(h){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",h)}return qn(this.afAuth).pipe(Fe(h=>!!h),he(h=>this.isFeatureAllowed({firebaseUser:h,annotations:[],filteredAnnotations:[]})),he(h=>h.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(_=>(h.featureAllowed=_,h))):se(h)),he(h=>h.featureAllowed?se(h).pipe(he(_=>this.docService.getDocumentPaths$().pipe(ce(E=>(this.documentPaths=E,_.documentPaths=E,_)))),he(_=>p?this.getMultiThreadDataFromDocumentIds([p]).pipe(ce(E=>({res:_,data:E}))):this.docService.getDocumentIds$().pipe(he(E=>{let D=E?.length>0?E.map(L=>L.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(D.length>0?D:[`${p}`]).pipe(ce(L=>({res:_,data:L})))}))),he(({res:_,data:E})=>E?(_.annotations=E||[],se(_).pipe(he(D=>this.docService.getLocation$().pipe(ce(L=>(D.location=L,D)))),he(D=>this.docService.getLocations$().pipe(ce(L=>(D.customLocations=L,D)))),he(D=>this.docService.getExcludedLocationIds$().pipe(ce(L=>(D.excludedLocationIds=L,D)))),ce(D=>{if(D.filteredAnnotations=[],p&&!m)return D.filteredAnnotations=D.annotations?.slice(),D?.excludedLocationIds?.length&&(D.filteredAnnotations=D.filteredAnnotations?.filter(L=>L?.location?.id?!D.excludedLocationIds.includes(L.location.id):!0)),D;{let L=[],H=[];return m?L.push(m):(L.push(D?.location?.locationId),L.push(...Object.values(D?.customLocations||[]).map(K=>K.locationId)),D?.location?.location?.id&&H.push(D?.location?.location?.id),H.push(...Object.values(D?.customLocations||{}).map(K=>K.location?.id).filter(K=>!!K))),D.filteredAnnotations=this.filterAnnotationsByLocationIds(D?.annotations,L,H),D?.excludedLocationIds?.length&&(D.filteredAnnotations=D.filteredAnnotations?.filter(K=>K?.location?.id?!D.excludedLocationIds.includes(K.location.id):!0)),D}}),he(D=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ce(L=>(D.filteredAnnotations=D.filteredAnnotations?.filter(H=>!H.isDraft),L&&D.filteredAnnotations.push(...Object.values(L)),D)))),he(D=>r?se(D):D?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ce(()=>D)):se(D)),he(D=>r?se(D):this.addCommentMode$.pipe(he(L=>L&&!this.getChangeDetectionInCommentMode()?se(D):D?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(ce(()=>D)):se(D)))),ce(D=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(D.filteredAnnotations=D.filteredAnnotations?.map(L=>{let H=Object.assign({},L);return this.calculateCommentAnnotationPosition(H,a),H})),D)),he(D=>D?.filteredAnnotations?se(D?.filteredAnnotations||[]):se([])))):se(null))):se(null)),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>(this.user=r,T(I({},i),{user:r}))))),he(i=>eo(i.config,i.user,ke.COMMENT)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocuments(e){let{documentIds:i,organizationId:r,query:a}=e;if(!this.configService?.getApiKey())return se(null);if(i?.some(D=>!D)||!this.documentPaths)return se(null);let s,m,p,h=[];if(a)a?.folderId&&(s=Tl(a?.folderId)),m=a?.allDocuments,a?.locationId&&(h=[...h,a?.locationId]),a?.locationIds?.length&&(h=[...h,...a?.locationIds]),p=a?.statusIds;else{s=this.docService.getDocumentPaths()?.veltFolderId,m=this.docService.getDocumentPaths()?.allDocuments;let D=this.docService.getDocumentPaths()?.locationId;D&&(h=[...h,D])}let _=se([]),E={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(E.documentId=i?.length?i[0]:void 0,E.organizationId=this.documentPaths?.organizationId),m)_=this.commonDbService.dbListener({feature:"allComments",properties:T(I({},E),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",r??this.documentPaths?.organizationId),...s?[gt("metadata.veltFolderId","==",s)]:[],...p?[gt("status.id","in",p)]:[],...h?.length?[gt("location.id","in",h)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})});else{let D=[];for(let L=0;L<(i?.length??0);L+=j.LISTENER_BATCH_SIZE)D.push(i?.slice(L,L+j.LISTENER_BATCH_SIZE)??[]);_=Rn(D.map(L=>this.commonDbService.dbListener({feature:"allComments",properties:T(I({},E),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",r??this.documentPaths?.organizationId),gt("metadata.documentId","in",L),...p?[gt("status.id","in",p)]:[],...s?[gt("metadata.veltFolderId","==",s)]:[],...h?.length?[gt("location.id","in",h)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(Gr()))).pipe(ce(L=>ua(JSON.parse(JSON.stringify(L)))))}return _.pipe(he(D=>D?.data?se(D).pipe(he(L=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:L,feature:"allComments"}).pipe(ce(H=>({data:Object.values(H?.data||{}).filter(K=>typeof K=="object"),operation:H?.operation})))),ce(({data:L,operation:H})=>{let K=L.reduce((oe,ue)=>{let be=ue.metadata?.documentId;return be&&(oe[be]||(oe[be]=[]),oe[be].push(ue)),oe},{});return{data:L,documentMap:K,operation:H}}),ce(({data:L,documentMap:H,operation:K})=>p?{data:L,documentMap:H,operation:K}:(L?.length&&(L?.forEach(oe=>{this.sanitizeCommentAnnotation(oe)}),this.setAnnotationIndex(L),this.updateAnnotationsForSelectAllContentMode(L),L.forEach(oe=>{this.customFilterService.convertLegacyAnnotationStatus(oe),this.customFilterService.convertLegacyPriority(oe),this.customFilterService.convertLegacyCategory(oe)})),{data:L,documentMap:H,operation:K})),jn(L=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",L),se([]))),gn(({documentMap:L})=>{p||Object.entries(L??{}).forEach(([H,K])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(K)))})}),ce(({data:L,documentMap:H,operation:K})=>({data:this.filterUserDraftComments(L),documentMap:H,operation:K})),ce(({data:L,documentMap:H,operation:K})=>({data:this.removeDraftFlags(L),documentMap:H,operation:K})),he(({data:L,documentMap:H,operation:K})=>p?se({data:L,documentMap:H,operation:K}):this.mergeDraftAnnotations(L).pipe(ce(oe=>({data:oe,documentMap:H,operation:K})))),ce(({data:L,documentMap:H,operation:K})=>{if(!p)if(K?.type==="removed"){if(K?.ids?.length){let oe=this.commentAnnotationById$.value??{};K?.ids?.forEach(ue=>{delete oe?.[ue]}),this.commentAnnotationById$.next(oe)}}else Object.entries(H??{}).length?Object.entries(H??{}).forEach(([ue,be])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:ue,annotations:be})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return L})):se(null)))}fetchCommentAnnotations(e){return Q(this,null,function*(){try{let i=this.authService.getUser();if(!i)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??i?.clientOrganizationId,s=_c(a??""),m=[];e?.allDocuments||(m=e?.documentIds?.map(H=>Cc(H??""))??this.docService.getDocumentIds()?.map(H=>H.documentId));let p=[];if(p.push(gt("metadata.organizationId","==",s)),p.push(gt("metadata.apiKey","==",r)),e?.folderId){let H=Tl(e?.folderId);p.push(gt("metadata.veltFolderId","==",H))}if(e?.locationId&&p.push(gt("location.id","==",e?.locationId)),m?.length&&p.push(gt("metadata.documentId","in",m)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");p.push(gt("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(gt("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(gt("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(gt("status.id","in",e?.statusIds))}let h=new Date().getTime();if(e?.createdAfter&&p.push(gt("createdAt",">=",e?.createdAfter)),e?.createdBefore&&p.push(gt("createdAt","<=",e?.createdBefore??h)),e?.updatedAfter&&p.push(gt("lastUpdated",">=",e?.updatedAfter??h)),e?.updatedBefore&&p.push(gt("lastUpdated","<=",e?.updatedBefore??h)),p.push(Ka("lastUpdated",e?.order??"desc"),Ka("createdAt",e?.order??"desc")),e?.pageToken){let H=yield bU(e?.pageToken??"","veltencrypttoken","veltencrypttoken");p.push(ole(parseInt(H,10),"lastUpdated"))}let _=e?.pageSize??100;p.push(qv(_+1));let E=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:p,apiKey:r??"",organizationId:s}}),D=E.length>_;E=E.slice(0,_);let L=E?.reduce((H,K)=>(H[K?.annotationId]=K,H),{});return L=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:L,shouldAwait:!0}),L=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:L}),{data:Object.values(L??{}),hasMore:D}}catch(i){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",i),i}})}filterUserDraftComments(e){let i=this.authService.getUser();return e.filter(r=>(r.comments=r?.comments?.filter(a=>a?.from?.userId===i?.userId||!a?.isDraft),!!r?.comments?.length))}removeDraftFlags(e){return e.forEach(i=>delete i.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(ce(i=>{let r=i||{};return e?.filter(a=>{r?.[a?.annotationId]&&delete r[a?.annotationId]}),r}),ce(i=>{if(i){let r=e.slice();return r.push(...Object.values(i)),r}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:i,query:r}){return this.getDataFromDocuments({documentIds:e,organizationId:i,query:r})}getMultiThreadDataFromDocumentIds(e){return this.getMultiThreadDataFromDocuments({documentIds:e})}getMultiThreadDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i}=e;if(i?.some(p=>!p)||!this.documentPaths)return se(null);let r=this.docService.getDocumentPaths()?.veltFolderId,a=this.docService.getDocumentPaths()?.allDocuments,s=se([]),m={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(m.documentId=i?.length?i[0]:void 0,m.organizationId=this.documentPaths?.organizationId),r&&a)s=this.commonDbService.dbListener({feature:"allMultiThreads",properties:T(I({},m),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",this.documentPaths?.organizationId),gt("metadata.veltFolderId","==",r))]})});else{let p=[];for(let h=0;h<(i?.length??0);h+=j.LISTENER_BATCH_SIZE)p.push(i?.slice(h,h+j.LISTENER_BATCH_SIZE)??[]);s=Rn(p.map(h=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:T(I({},m),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",this.documentPaths?.organizationId),gt("metadata.documentId","in",h),...r?[gt("metadata.veltFolderId","==",r)]:[])]})}).pipe(Gr()))).pipe(ce(h=>ua(h)))}return s.pipe(he(p=>p?.data?se(p).pipe(ce(h=>({data:h?.data,operation:h?.operation})),ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),{data:E,operation:_}}),jn(h=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",h),se({data:[],operation:null}))),ce(({data:h,operation:_})=>{h.forEach(D=>{delete D.isDraft});let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),he(({data:h,documentMap:_,operation:E})=>{let D=[];return this.commentAnnotationById$.pipe(he(()=>this.domService.getSelectedAnnotationsMap$().pipe(ce(L=>({selectedAnnotationsMap:L})))),ce(({selectedAnnotationsMap:L})=>{let H={};return Object.keys(_??{}).forEach(K=>{let oe=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:K});oe&&oe?.forEach(ue=>{H[ue?.annotationId]=ue})}),D=h.filter(K=>{let oe=!1;if(K?.commentAnnotations){for(let ue in K?.commentAnnotations)if(H?.[ue]&&H?.[ue]?.status?.id!==this.customFilterService.resolvedStatus.id){oe=!0;break}}return oe}),D.forEach(K=>{Object.keys(K?.commentAnnotations||{}).forEach(oe=>{K.commentAnnotationsMap||(K.commentAnnotationsMap={}),K.commentAnnotationsMap[oe]=H?.[oe]})}),{data:D,operation:E}}))}),he(({data:h,operation:_})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ce(E=>{let D=E||{};return h?.filter(L=>{D?.[L?.annotationId]&&delete D[L?.annotationId]}),D}),ce(E=>{if(E){let D=h.slice();return D.push(...Object.values(E)),{data:D,operation:_}}return{data:h,operation:_}}))),ce(({data:h,operation:_})=>{let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});if(_?.type==="removed"){if(_?.ids?.length){let D=this.multiThreadCommentAnnotationById$.value;_?.ids?.forEach(L=>{delete D?.[L]}),this.multiThreadCommentAnnotationById$.next(D)}}else Object.keys(E??{}).forEach(D=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:E[D]})});return h})):se(null)))}else return se(null)}updateUnreadAnnotationsMap(e,i){try{let r=new Date(j.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(s=>s?.lastUpdated>r);if(i){let s={},m=!1;a.forEach(p=>{let h=0,_=i?.[p?.annotationId];if(_){let E=_?.comments;E&&p?.comments?.forEach(D=>{!E?.[D?.commentId]?.views?.[this.user?.userSnippylyId]&&this.user?.userSnippylyId!==D?.from?.userSnippylyId&&h++})}h?h!==s?.[p?.annotationId]&&(s[p?.annotationId]=h,m=!0):s?.[p?.annotationId]&&(delete s[p?.annotationId],m=!0)}),this.unreadCommentsMap$.next(s)}}catch(r){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",r)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(i=>{if(i?.selectAllContent&&i?.targetElementId){let r=dr(i.targetElementId,["id","data-id"]);if(r){let a=r.textContent;a&&(i.targetTextRange={commonAncestorContainer:this.domService.getXPath(r),text:a,occurrence:1},delete i?.targetElement)}}})}catch(i){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",i)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.commentAnnotationById$.value??{}),s);this.commentAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:i}){try{return this.commentAnnotationById$.pipe(ce(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i})))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",r),se([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r=null;this.commentAnnotationById$.value&&(r={},Object.values(this.commentAnnotationById$.value).forEach(s=>{s?.metadata?.documentId==i&&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===i&&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),[]}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(he(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):se([])))}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 i={};e?.forEach(r=>{r?.annotationId&&(i[r?.annotationId]=r)}),this.originalCommentAnnotationsByDocumentId$.next(I(I({},this.originalCommentAnnotationsByDocumentId$.value),i))}catch(i){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",i)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.multiThreadCommentAnnotationById$.value),s);this.multiThreadCommentAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:i}){return this.multiThreadCommentAnnotationById$.pipe(ce(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(s=>{s?.metadata?.documentId==i&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(s=>{s?.metadata?.documentId===i&&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(he(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):se([])))}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(he(e=>this.docService.getLocations$().pipe(ce(i=>({location:e,locations:i})))),ce(e=>{let i=[];return i.push(e?.location?.locationId),i.push(...Object.values(e.locations||[]).map(r=>r.locationId)),i||[]}))}filterAnnotationsByLocationIds(e,i,r){try{return e.filter(a=>i.includes(a.locationId)||r?.includes(a?.location?.id)||i?.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((i,r)=>{i?.annotationId&&(i.annotationIndex=r+1)})}catch(i){this.loggingService.catch("Error in CommentService setAnnotationIndex:",i)}}calculateCommentAnnotationPosition(e,i){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let r=dr(e.targetElementId,["id","data-id"]);if(r&&this.domService.isElementVisible(r)){let a=r.getAttribute(j.ATTRIBUTES.VELT_COMMENT_TYPE),s=!0;if(a)switch(a){case"popover":s=!0;break;default:s=!1;break}else{let m=document.querySelector(`${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);m&&r?.contains(m)&&(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;if(r){let 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()===B6.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(r=e.targetElement?.fXpath,r&&(a=this.domService.getElementFromXPath(r)))),(!a||!this.domService.isElementVisible(a))&&i&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=this.getGhostCommentTargetElement(e),e?.ghostComment?.targetElement?.xpath&&(a=this.domService.getElementFromXPath(e?.ghostComment?.targetElement?.xpath)));let m=!1;if(e?.locationId){let p=this.docService.getLocation();if(!$u({location:p?.location,locationId:p?.locationId},{location:e?.location,locationId:e?.locationId})){let h=this.docService.getAdditionLocationFromElement(a),_=h?this.docService.genarateLocationId(h):void 0;e?.location?.id&&e?.location?.id===h?.id||_&&_===e?.locationId?m=!1:m=!0}}if(m&&(e.ghostComment=null),!m&&a&&Do(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let h=this.popoverMode$?.value?0:e.targetElement?.topPercentage,_=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:E,width:D}=Np(a);e.position={top:E*(h||0)/100,left:D*(_||0)/100};let L=window.getComputedStyle(a).transform;if(L&&L!=="none")try{let H=new DOMMatrixReadOnly(L),K=Math.sqrt(H.a*H.a+H.b*H.b)||1,oe=Math.sqrt(H.c*H.c+H.d*H.d)||1;(Math.abs(K-1)>.01||Math.abs(oe-1)>.01)&&(e.position.parentScaleX=K,e.position.parentScaleY=oe)}catch{}if(this.transformContext$.value){let{containerSelector:H,transforms:K}=this.transformContext$.value,oe=document.querySelector(H);oe&&oe.contains(a)&&(e.position.transformContext=K)}}!m&&i&&!e?.position&&!e?.ghostComment&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=e.targetElement)}}i&&(e.ghostComment?this.addAnnotationToGhostCommentAnnotationMap(e):this.removeAnnotationFromGhostCommentAnnotationMap(e))}catch(r){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",r)}}addComment(e,i,r,a,s,m=[],p,h,_,E,D,L,H,K,oe,ue,be,Le,qe){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let Re=this.authService.getUser();if(Re)if(Re.isReadOnly||Re.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{let _e=new Ro;be&&(_e=I(I({},_e),be)),_e.comments=[],be?.comments?.length&&(_e.comments=be.comments.map($t=>{let ft=new xc;return ft=I(I({},ft),$t),ft.from=Re,ft.lastUpdated=new Date,ft.createdAt=this.timestamp,ft})),_e.from=Re,_e.color=_e?.color||j.DEFAULT_ANNOTATION_COLOR,_e.lastUpdated=this.timestamp,_e.createdAt=this.timestamp,_e.sourceId=oe,_e.assignedTo=be?.assignedTo||ue,_e.customList=be?.customList||[];let{topPositionX:Ee,topPositionY:Oe}=this.domService.getTopLeftPosition();_e.positionX=Ee,_e.positionY=Oe;let ye=this.domService.getCurrentWindowSizeValue();if(_e.screenWidth=ye.screenWidth,_e.screenHeight=ye.screenHeight,_e.screenScrollHeight=ye.screenScrollHeight,_e.taggedElementPath="",e&&(_e.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,$t=>{if(this.getSvgAsImg()){let ft=$t?.closest(`[${j.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);ft&&ft instanceof HTMLElement&&($t=ft)}if(this.getPopoverMode()){let ft=$t?.closest(`[${j.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(ft&&ft instanceof HTMLElement)return ft}return $t}),this.getCommentToNearestAllowedElement()&&_e.targetElement?.xpath)){let $t=this.domService.getElementFromXPath(_e.targetElement.xpath);if($t&&!this.isElementInsideAllowedElements($t)){let ft=this.getNearestAllowedElement($t);if(ft)_e.targetElement.xpath=this.domService.getXPath(ft),_e.targetElement.fXpath=this.domService.getXPath(ft,!0),_e.targetElement.cfXpath=this.domService.getXPath(ft,!0,!0);else return}}if(i&&(_e.targetTextRange=i),_e?.targetElement?.xpath){let $t=this.domService.getXPath(_e.targetElement.xpath);if($t){let ft=$t.iterateNext();ft&&(Do(ft)||(_e.targetElement=null))}}this.customFilterService.defaultStatus&&!be?.status&&(_e.status=this.customFilterService.defaultStatus),_e.pageInfo=Ei(),_e.pageInfo&&(_e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let fe=this.docService.getClientDocumentId(),Be=this.docService.getLocation()?.location;if(qe&&(_e.context=qe&&vc(qe),_e.contextId=this.generateContextId(_e.context)),this.commentContextProvider!==null){let $t=this.commentContextProvider(fe,Be);$t&&(_e.context=$t&&vc($t),_e.contextId=this.generateContextId(_e.context))}if(a){_e.sourceId=a?.sourceId;let $t=a?.targetElement,ft=a?.commentData;if($t?.targetText)_e.targetTextRange={commonAncestorContainer:"/html/body",text:$t.targetText,occurrence:$t?.occurrence||1};else if($t?.elementId)if(_e.targetElementId=$t.elementId,$t?.selectAllContent)_e.selectAllContent=!!$t?.selectAllContent;else{let Mt=dr($t.elementId,["id","data-id"]);Mt?_e.targetElement={xpath:this.domService.getXPath(Mt),fXpath:this.domService.getXPath(Mt,!0),cfXpath:this.domService.getXPath(Mt,!0,!0),topPercentage:50,leftPercentage:90}:_e.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",topPercentage:50,leftPercentage:90}}a?.status&&(_e.status=a.status),a?.context&&(_e.context=a.context?vc(a.context):a.context,_e.contextId=this.generateContextId(_e.context)),_e.comments||(_e.comments=[]);let Ot=this.authService.getUser();ft?.forEach(Mt=>{let ln=new xc;ln.commentText=Mt.commentText,ln.commentHtml=Mt.commentHtml,ln.replaceContentHtml=Mt.replaceContentHtml,ln.replaceContentText=Mt.replaceContentText,ln.from=Ot,_e.comments.push(ln)})}if(s&&(_e.isPageAnnotation=!0),m?.length&&(_e.comments=m),p&&(_e.commentType="chart",_e.metadata=p),_?.sourceId&&(_e.sourceId=_.sourceId),_e?.targetElement?.xpath&&!_){let $t=this.domService.getElementFromXPath(_e.targetElement.xpath);$t&&(_=this.getInlineCommentSectionConfig($t))}_?.targetInlineCommentElementId&&(_e.targetInlineCommentElementId=_?.targetInlineCommentElementId,_e.targetElementId=_.targetInlineCommentElementId,_?.config?.id&&(_e.inlineCommentSectionConfig=_?.config));let xe=!_e?.comments?.length,wn=a?.openComment===!1;this.getPrivateCommentMode()&&(_e?.iam||(_e.iam=new ib),_e.iam.accessMode=Qi.PRIVATE),E&&(_e.context=E.context?vc(E.context):E.context,_e.commentType="manual",delete _e.targetElement,_e.contextId=this.generateContextId(_e.context)),D&&(_e.targetElementId=D.targetElementId,_e.targetElement=D.targetElement),this.saveCommentToDb(_e,r,xe,wn,h,L,H,Le,K)}}catch(Re){this.loggingService.catch("Error in CommentService addComment: ",Re)}}setLocationToCommentAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location);try{let r;e.targetElement?.xpath?r=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId?r=dr(e.targetElementId,["id","data-id"]):e.targetTextRange?.commonAncestorContainer&&(r=this.domService.getElementFromXPath(e.targetTextRange.commonAncestorContainer));let a=this.docService.getAdditionLocationFromElement(r);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}catch{}}catch(i){this.loggingService.catch("Error in CommentService setLocationToCommentAnnotation:",i)}}getElementForCommentAnnotation(e){try{let i;return e.targetElement?.xpath?i=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId?i=dr(e.targetElementId,["id","data-id"]):e.targetTextRange?.commonAncestorContainer&&(i=this.domService.getElementFromXPath(e.targetTextRange.commonAncestorContainer)),i}catch(i){return this.loggingService.catch("Error in CommentService getElementForCommentAnnotation: ",i),null}}saveCommentToDb(e,i,r=!1,a=!1,s,m,p,h,_){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.COMMENT)&&this.docService.getDocumentPaths$().pipe(Fe(E=>!!E),tt(1),he(E=>(this.documentPaths=E,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(D=>!!D),tt(1),he(D=>Q(this,null,function*(){if(this.db=D,this.loggingService.log(this.db),this.documentPaths?.comment){let L=rn(this.db,`${this.documentPaths?.comment}`);e.annotationId=this.commonDbService.generateDocumentId();let H=this.docService.getClientDocumentId(),K=this.docService.getLocation()?.location;if(p)e.multiThreadAnnotationId=p;else if(this.getMultiThread()){let _e=_m();e.targetElementId&&(_e=_m(e.targetElementId),e?.location?.id?_e=_m([e?.location?.id,e.targetElementId]):e?.locationId&&(_e=_m([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=_e}let oe={addContext:_e=>{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:_e}),e.context=_e&&vc(_e),e.contextId=this.generateContextId(e.context),_e?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&this.updateCommentAnnotationContext(e.annotationId,_e)},documentId:H,location:K,annotation:zn(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?oe.elementRef={xpath:e.targetElement.xpath}:oe.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(oe),this.commentAdded$.next(oe),_&&_(oe);let ue=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(oe);ue&&this.commentActionsService?.triggerAddCommentAnnotationEvent(ue),this.setLocationToCommentAnnotation(e);let be=this.getElementForCommentAnnotation(e),Le=this.docService.getBaseMetadata("comment",{element:be,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!Le?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=I(I({},e.metadata),Le),s&&typeof s=="object"&&(e.locationId=h||this.docService.genarateLocationId(s),e.location=s,this.docService.addLocation({location:s})),r)window.localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let _e=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);_e&&JSON.parse(_e).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let qe=e.comments,Re=JSON.parse(JSON.stringify(e));if(Re.position=null,i){Re.targetElement=null,Re.targetTextRange=null;let _e={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?ke.MULTI_THREAD:ke.COMMENT},Ee=yield this.areaService.generateAreaAnnotationId();Re.areaAnnotationId=Ee;let Oe=this.areaService.addArea(void 0,i,_e,Ee,{locationId:Re.locationId,location:Re.location});Oe&&(Re.metadata=I(I({},Re.metadata),Oe?.metadata||{}))}!a&&!Re?.targetInlineCommentElementId&&!Re?.isPageAnnotation&&this.domService.toggleAnnotationSelection(Re,m),e.targetTextRange&&sessionStorage.setItem(j.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(Re),commentMode:this.getCommentMode()}),Re?.comments?.length?Re.comments=[]:Re.isDraft=!0,Re?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(Re),Re?.context&&(Re.contextId=this.generateContextId(Re.context)),qe?.length?this.saveComment(Re,{type:Ut.NEWLY_ADDED,updatedComment:qe[0]}):this.draftCommentAnnotationsByAnnotationId$.next(T(I({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:Re}))}})))))).subscribe(()=>{},E=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",E)})}catch(E){this.loggingService.catch("Error in CommentService saveCommentToDb: ",E)}}saveMultiThreadCommentAnnotation(e){return Q(this,null,function*(){try{if(e?.multiThreadAnnotationId){let i=this.docService.getDocumentPaths();if(this.db&&i?.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};delete e?.targetElement,delete e?.areaAnnotationId,delete e?.targetTextRange;let a=this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId})?.find(s=>s.annotationId===e.multiThreadAnnotationId);if(a||(a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e.multiThreadAnnotationId}})),a&&(a=JSON.parse(JSON.stringify(a)),delete a.from,r=I(I({},a),r)),r?.commentAnnotations||(r.commentAnnotations={}),r.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(T(I({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[r.annotationId]:T(I({},r),{isDraft:!0})}));else{let m=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[r.annotationId];if(m&&(r=I(I({},r),m)),delete r.isDraft,r.commentAnnotationsMap={},!r?.metadata?.documentId){r?.metadata||(r.metadata={});let _=this.docService.getBaseMetadata();r.metadata=I(I({},r?.metadata),_)}let{documentId:p,organizationId:h}=r?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:r.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(r)),callback:()=>{let _=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;_[e.annotationId]&&(delete _[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(_))}})}return r}}return null}catch(i){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",i),null}})}setCommentCategory(e){return Q(this,null,function*(){try{if(e?.comments?.length){let i=e.comments[0].commentText?.trim();if(i){let r=yield this.getCommentCategory(i).toPromise();if(r){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let s=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(m=>m.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 m=s;m.commentCategories=[r];let{documentId:p,organizationId:h}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(m);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}}}}}}catch(i){this.loggingService.catch("Error in CommentService setCommentCategory: ",i)}})}getCommentCategory(e){try{let i=yr(this.functions,br({url:Xn.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 _o(i({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:ga(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(ce(s=>{if(s?.data){let m=s.data,p=m?.length?m[0]?.content?.trim():void 0;return p&&Object.keys(this.customCategoryMap).includes(p)?this.customCategoryMap[p]:void 0}else return}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentCategory: ",i),se(void 0)}}updateCommentAnnotationContext(e,i,r){return Q(this,null,function*(){try{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:i,merge:r?.merge});let a=this.authService.getUser(),s=this.docService.getDocumentPaths();if(a&&s?.comment&&e){let m=this.getAnnotationById(e);if(typeof m=="object"&&(m=JSON.parse(JSON.stringify(m))),m||(m=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:e}})),m?.annotationId){let p=i,h=JSON.parse(JSON.stringify(m.context||{}));r?.merge&&(p=I(I({},h),i));let _={context:JSON.parse(JSON.stringify(p||{}))};if(_?.context?.commentType==="manual"&&(_.commentType="manual",_.targetElement=null),m.context=_.context?vc(_.context):_.context,m.contextId=this.generateContextId(m.context),uo(h,p))return Promise.resolve("Comment annotation context is already updated.");{let{documentId:E,organizationId:D}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(m);return this.commonDbService.updateData({feature:"comment",properties:{id:e,documentId:E,organizationId:D},data:JSON.parse(JSON.stringify(m)),callback:()=>{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:_?.context,merge:r?.merge})}})}}else return this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:i,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,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(ke.COMMENT)){if(i&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let m=this.domService.getXPath(e.targetElement.xpath);if(m){let p=m.iterateNext();p&&(Do(p)||(e.targetElement=null))}}if(e?.type==="multiThread"){let m=JSON.parse(JSON.stringify(e));if(m.position=null,m.ghostComment=null,!m?.metadata?.documentId){m?.metadata||(m.metadata={});let _=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),_)}let{documentId:p,organizationId:h}=m?.metadata||{};r?this.commonDbService.updateData({feature:"multiThread",properties:{id:m.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))}):this.commonDbService.setData({feature:"multiThread",properties:{id:m.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let m=JSON.parse(JSON.stringify(e));m.position=null,m.ghostComment=null,m.lastUpdated=this.timestamp,m.status||(m.status=this.customFilterService.defaultStatus),delete m.resolved,delete m.inProgress,this.setLocationFromDocumentParams(m);let p=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(p&&JSON.parse(p).annotationId===m.annotationId&&window.localStorage.removeItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),m?.multiThreadAnnotationId&&!s&&this.saveMultiThreadCommentAnnotation(m).then(h=>{}),m?.comments?.length){if(delete m?.isDraft,m?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[m?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(m),!m?.metadata?.documentId){m?.metadata||(m.metadata={});let D=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),D)}let{documentId:h,organizationId:_}=m?.metadata||{},E=a?I({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;r?this.commonDbService.updateData({feature:"comment",properties:{id:m.annotationId,documentId:h,organizationId:_},extraData:E,data:JSON.parse(JSON.stringify(m)),callback:D=>{a&&!D?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{})}}):this.commonDbService.setData({feature:"comment",properties:{id:m.annotationId,documentId:h,organizationId:_},extraData:E,data:JSON.parse(JSON.stringify(m)),callback:D=>{a&&!D?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{})}}),this.viewsService.setCommentAnnotationAsRead(m)}else this.draftCommentAnnotationsByAnnotationId$.next(T(I({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:m}))}}}catch(m){this.loggingService.catch("Error in CommentService updateComment: ",m)}}getDocumentIdAndOrganizationIdFromCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromCommentAnnotation: ",i),{}}}getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation: ",i),{}}}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((i,r)=>Q(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),s=this.authService.getUser(),m=[];Object.keys(a).forEach(p=>{let h=a[p];["tag","recorder","rewriter","arrow","area","multiThread"].includes(h.type)||s&&h.from&&(s?.isAdmin||h.from.userId===s.userId)&&m.push(h)}),m?.length?(this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:m.map(p=>p.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(va,{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(tt(1)).subscribe(p=>{try{p?(m.forEach(h=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(h)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(_=>{this.domService.removeHighlightFromElement(_)}),i()},100)):i()}catch(h){r(h)}},p=>{r(p)})):i(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),r(a)}}))}deleteCommentPinAnnotation(e,i){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(ke.COMMENT))if((i||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Ut.DELETED),e.comments?.forEach(r=>{r.reactionAnnotationIds&&r.reactionAnnotationIds.forEach(a=>{this.deleteReaction(a)})}),e?.annotationId){this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DELETED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode()});let r=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);r&&JSON.parse(r).annotationId===e.annotationId&&window.localStorage.removeItem(j.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:m}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);return e?.isDraft?Promise.resolve():this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:s,organizationId:m}}).then(()=>{this.viewsService.deleteCommentAnnotationViews(e,{documentId:s,organizationId:m})})}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 i=e?.multiThreadAnnotationId;if(i){let r=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(i);if(!a){let h=e?.metadata?.documentId||r?.documentId,_=e?.metadata?.organizationId||r?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:h,organizationId:_,id:i}})}let s=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[i];a&&delete a?.commentAnnotations?.[e.annotationId],s&&(delete s?.commentAnnotations?.[e.annotationId],Object.keys(s?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[i],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:m,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:m,organizationId:p}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:m,organizationId:p},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",i)}})}getAnnotationById(e,i){try{let r=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};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 i=this.commentAnnotationById$.value?.[e];if(i)return i.metadata}catch(i){this.loggingService.catch("Error in CommentService getBaseMetadataFromCommentAnnotationId: ",i)}}getMultiThreadAnnotationById(e,i){try{let r=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};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 i=this.multiThreadCommentAnnotationById$.value?.[e];if(i)return i.metadata}catch(i){this.loggingService.catch("Error in CommentService getBaseMetadataFromMultiThreadCommentAnnotationId: ",i)}}getElementRefByAnnotationId(e){try{let i=this.getAnnotationById(e);if(i){let r=i?.targetElement?.xpath;if(r)return{xpath:r}}return}catch(i){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",i);return}}scrollToCommentByAnnotationId(e){try{let i=this.getAnnotationById(e),r=document.getElementById(`comment-pin-container-${e}`);r||(r=document.querySelector(`[data-velt-id='${e}']`)),r||(r=document.querySelector(`${j.TAGS.VELT_COMMENT_TEXT}[${j.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),r&&(r.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),i&&(this.domService.getSelectedAnnotationsMap()[e]||this.domService.toggleAnnotationSelection(i)))}catch(i){this.loggingService.catch("Error in CommentService scrollToCommentByAnnotationId: ",i)}}selectCommentByAnnotationId(e,i){try{this.loggingService.log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");let r=this.getAnnotationById(e);r&&this.domService.toggleAnnotationSelection(r,void 0,void 0,!0)}catch(r){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",r)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(ke.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([go.ADMIN,go.COMMENTER])?(this.analyticsService.trackEvent(X.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(X.Events.Comments.COMMENT_ADD_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!1)}addCommentModeChange(){return this.addCommentMode$.asObservable()}enablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.COMMENT,config:{commentIndex:e}}),this.showCommentIndex$.value===e)return;this.showCommentIndex$.next(e)}catch(i){this.loggingService.catch("Error in CommentService showCommentIndex: ",i)}}getShowCommentIndex(){return this.showCommentIndex$.asObservable()}enablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{popoverMode:!0}}),this.popoverMode$.value===!0)return;this.popoverMode$.next(!0),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{popoverMode:!1}}),this.popoverMode$.value===!1)return;this.popoverMode$.next(!1),this.analyticsService.trackEvent(X.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{textMode:!0}}),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{textMode:!1}}),this.analyticsService.trackEvent(X.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,i=!1,r=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(j.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(j.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),i&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||i||r)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1)),e?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_OPENED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_CLOSED,{commentMode:this.getCommentMode()})}catch{this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}toggleSidebarVisibility(e=!1,i=!1){try{this.domService.resetSelectedAnnotationsMap(),this.sidebarVisible$.value?(!this.sidebarOpenedByCustomTrigger$.value||e||i)&&(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarOpenedByCustomTrigger$.next(!1)):(document.querySelector(j.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(j.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarVisible$.value?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"closed"}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"opened"})):this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{floatingCommentDialog:!e}}),this.floatingCommentsEnabled$.value===!e)return;this.floatingCommentsEnabled$.next(!e)}catch(i){this.loggingService.catch("Error in CommentService disableFloatingComments: ",i)}}showFloatingComments$(){return this.floatingCommentsEnabled$.asObservable()}showFloatingComments(){return this.floatingCommentsEnabled$.value}setModeratorMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{moderatorMode:e}}),this.moderatorMode$.value===e)return;this.moderatorMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setModeratorMode: ",i)}}getModeratorMode(){return this.moderatorMode$.value}getModeratorMode$(){return this.moderatorMode$.asObservable()}setStreamMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{streamMode:e}}),this.streamMode$.value===e)return;this.streamMode$.next(e),e?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STREAM_MODE_ENABLED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STREAM_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(i){this.loggingService.catch("Error in CommentService setStreamMode: ",i)}}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:ke.COMMENT,config:{dialogOnHover:e}}),this.enableDialogOnHover$.value===e)return;this.enableDialogOnHover$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableDialogOnHover: ",i)}}getEnableDialogOnTargetElementClick(){return this.enableDialogOnTargetElementClick$.value}getEnableDialogOnTargetElementClick$(){return this.enableDialogOnTargetElementClick$.asObservable()}setEnableDialogOnTargetElementClick(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{dialogOnTargetElementClick:e}}),this.enableDialogOnTargetElementClick$.value===e)return;this.enableDialogOnTargetElementClick$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableDialogOnTargetElementClick: ",i)}}getEnablePriority(){return this.enablePriority$.value}getEnablePriority$(){return this.enablePriority$.asObservable()}setEnablePriority(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{priority:e}}),this.enablePriority$.value===e)return;this.enablePriority$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnablePriority: ",i)}}getEnableStatus(){return this.enableStatus$.value}getEnableStatus$(){return this.enableStatus$.asObservable()}setEnableStatus(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableStatus: ",i)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{resolveButton:e}}),this.getEnableResolve()===e)return;this.enableResolve$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableResolve: ",i)}}getEnableGhostComments(){return this.enableGhostComments$.value}getEnableGhostComments$(){return this.enableGhostComments$.asObservable()}enableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.COMMENT,config:{autoCategorize:e}}),this.enableAutoCategorize$.value===e)return;this.enableAutoCategorize$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableAutoCategorize: ",i)}}getEnableAutoCategorize(){return this.enableAutoCategorize$.value}getEnableAutoCategorize$(){return this.enableAutoCategorize$.asObservable()}setCommentContainerDarkMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{darkMode:e}}),this.commentContainerDarkMode$.value===e)return;this.commentContainerDarkMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentContainerDarkMode: ",i)}}getCommentContainerDarkMode(){return this.commentContainerDarkMode$.asObservable()}getSuggestionMode(){return this.suggestionMode$.value}getSuggestionMode$(){return this.suggestionMode$.asObservable()}setSuggestionMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{suggestionMode:e}}),this.getSuggestionMode()===e)return;this.suggestionMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setSuggestionMode: ",i)}}getMobileMode(){return this.mobileMode$.value}getMobileMode$(){return this.mobileMode$.asObservable()}setMobileMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{mobileMode:e}}),this.getMobileMode()===e)return;this.mobileMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setMobileMode: ",i)}}enableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setTotalMediaLength: ",i)}}getTotalMediaLength(){return this.totalMediaLength$.value}getTotalMediaLength$(){return this.totalMediaLength$.asObservable()}enableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{detectionStrategy:e}}),this.detectionStrategy$.value===e)return;this.detectionStrategy$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setDetectionStrategy: ",i)}}getDetectionStrategy(){return this.detectionStrategy$.value}getDetectionStrategy$(){return this.detectionStrategy$.asObservable()}enableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService addBubbleCommentAnnotationIds: ",i)}}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(i){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",i)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{signInButton:e}}),this.enableSignInButton$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableSignInButton: ",i)}}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:ke.COMMENT,config:{upgradeButton:e}}),this.enableUpgradeButton$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableUpgradeButton: ",i)}}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:ke.COMMENT,config:{attachments:e}}),this.enableAttachment$.value===e)return;this.enableAttachment$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableAttachment: ",i)}}getEnableAttachment$(){return this.enableAttachment$.asObservable()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{recordings:e}}),e?.includes("all")?this.allowedRecordings$.next(["audio","video","screen"]):e?.includes("none")?this.allowedRecordings$.next([]):this.allowedRecordings$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setAllowedRecordings: ",i)}}getAllowedRecordings(){return this.allowedRecordings$.value}getAllowedRecordings$(){return this.allowedRecordings$.asObservable()}enableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.iamService.isUserAdmin$().pipe(tt(1)).subscribe(e=>{e?(this.privateCommentMode$.next(!0),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{privateCommentMode:!1}}),this.privateCommentMode$.value===!1)return;this.privateCommentMode$.next(!1),this.analyticsService.trackEvent(X.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()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{deviceInfo:e}}),this.showScreenSizeInfo$.value===e)return;this.showScreenSizeInfo$.next(e)}catch(i){this.loggingService.catch("Error in CommentService showScreenSizeInfo: ",i)}}getShowScreenSizeInfo$(){return this.showScreenSizeInfo$.asObservable()}enableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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()}enableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{unreadIndicatorMode:e}}),this.unreadIndicatorMode$.value===e)return;this.unreadIndicatorMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setUnreadIndicatorMode: ",i)}}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:ke.COMMENT,config:{composerMode:e}}),this.composerMode$.value===e)return;this.composerMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setComposerMode: ",i)}}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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{excludeLocationIdsFromSidebar:e}}),this.excludeLocationIdsFromSidebar$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setExcludeLocationIdsFromSidebar: ",i)}}getExcludeLocationIdsFromSidebar(){return this.excludeLocationIdsFromSidebar$.value}getExcludeLocationIdsFromSidebar$(){return this.excludeLocationIdsFromSidebar$.asObservable()}enableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:ke.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()}enableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setCommentSidebarFilters: ",i)}}getCommentSidebarFilters(){return this.commentSidebarFilters$.value}getCommentSidebarFilters$(){return this.commentSidebarFilters$.asObservable()}setCommentSidebarSystemFiltersOperator(e){try{this.commentSidebarSystemFiltersOperator$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentSidebarSystemFiltersOperator: ",i)}}getCommentSidebarSystemFiltersOperator(){return this.commentSidebarSystemFiltersOperator$.value}getCommentSidebarSystemFiltersOperator$(){return this.commentSidebarSystemFiltersOperator$.asObservable()}enableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:ke.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(i){this.loggingService.catch("Error in CommentService setCustomReactions: ",i)}}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(i){return this.loggingService.catch("Error in CommentService getCommentType: ",i),""}}getCommentAnnotationAvailableOnXPath(e,i,r){try{return this.commentAnnotationById$.pipe(he(()=>this.draftCommentAnnotationsByAnnotationId$),he(a=>(!r&&i&&(r=dr(i,["id","data-id"])),se(T(I({},a),{element:r})))),he(a=>this.getLocations$().pipe(ce(s=>T(I({},a),{locationIds:s})))),ce(({locationIds:a,element:s})=>{let m=[],p=this.docService.getDocumentPaths();if(p?.documentId){let h=this.docService.getAdditionalDocumentIdFromElement(s),_=h?this.docService.generateDocumentId(h):p?.documentId,E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:p?.organizationId,documentId:_||""});if(E)for(let D of E)(i&&D?.targetElementId===i||D?.targetElement?.xpath===e)&&a?.includes(D?.locationId)&&m.push(D)}return m.length?m:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),se(null)}}getCommentAnnotationsByContext({context:e,contextOptions:i,element:r}){try{return this.commentAnnotationById$.pipe(he(()=>this.draftCommentAnnotationsByAnnotationId$),ce(()=>{let a=[],s=this.docService.getDocumentPaths(),m=vc(e),p=this.generateContextId(m);if(s?.documentId){let h=this.docService.getAdditionalDocumentIdFromElement(r??null),_=h?this.docService.generateDocumentId(h):s?.documentId,E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:s?.organizationId,documentId:_||""});if(E)for(let D of E)i?.partialMatch?V6(D?.context,m)&&a.push(D):p&&D?.contextId===p&&a.push(D)}return a.length?a:null}))}catch(a){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",a),se(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(ce(()=>this.getAnnotationById(e)),he(i=>i?i?.iam?.accessMode===Qi.PRIVATE?this.iamService.isUserAdmin$().pipe(ce(r=>{if(r)return i})):se(i):se(i)),he(i=>i?this.filterCommentsUsingSidebarSettings(i).pipe(ce(r=>{if(r)return r})):se(i)))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",i),se(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(ce(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let i=document.querySelector(`${j.TAGS.VELT_COMMENT_BUBBLE}[${j.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return i||(i=document.querySelector(`${j.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${j.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`)),i}catch(i){return this.loggingService.catch("Error in CommentService getCommentBubbleElement: ",i),null}}getCommentAnnotationsBySectionId(e){try{return this.commentAnnotationById$.pipe(he(()=>this.docService.getDocumentPaths$().pipe(ce(i=>({documentPaths:i,sectionId:e})))),he(i=>{let r=dr(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(ce(m=>{let h=Object.values(m||{}).find(_=>_.locationId===s||a?.id&&_.location.id===a.id);return T(I({},i),{additionalLocation:h,locationOnElement:!!a})}))}}return se(T(I({},i),{additionalLocation:null,element:r}))}),he(i=>i?.locationOnElement?se(i):this.docService.getLocation$().pipe(ce(r=>T(I({},i),{location:r})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s,element:m})=>{let p=null;if(this.authService.getUser()&&i?.documentId){let _=this.docService.getAdditionalDocumentIdFromElement(m),E=_?this.docService.generateDocumentId(_):i?.documentId,D=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:E||""});if(D){p=[];let L=_m(e);s?a?.location?.id?L=_m([a?.location?.id,e]):a?.locationId&&(L=_m([a?.locationId+"",e])):r&&(r?.location?.id?L=_m([r?.location?.id,e]):r?.locationId&&(L=_m([r?.locationId+"",e])));for(let H of D)H?.multiThreadAnnotationId===L?p.push(H):(H?.targetInlineCommentElementId===e||H?.targetElementId===e)&&(s?a&&$u({location:a?.location,locationId:a?.locationId},{location:H.location,locationId:H.locationId})&&p.push(H):r?$u({location:r?.location,locationId:r?.locationId},{location:H.location,locationId:H.locationId})&&p.push(H):H?.locationId||p.push(H))}}return p}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",i),se(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(he(()=>this.multiThreadCommentAnnotationById$),he(()=>this.docService.getDocumentPaths$().pipe(ce(i=>({documentPaths:i,multiThreadAnnotationId:e})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s})=>{let m=null;if(i?.documentId){let p=this.getMultiThreadAnnotationById(e),{documentId:h,organizationId:_}=p?.metadata||{documentId:i?.documentId,organizationId:i?.organizationId},E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:_,documentId:h||""});if(E){m=[];for(let D of E)D?.multiThreadAnnotationId===e&&p?.commentAnnotations?.[D?.annotationId]&&m.push(D)}}return m}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",i),se(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(i){return this.loggingService.catch("Error in CommentService isElementInsideAllowedElements: ",i),!1}}getNearestAllowedElement(e){try{let i=this.domService.getListedElements({elementIds:this.allowedElementIds$.value,elementClassNames:this.allowedElementClassNames$.value,elementQuerySelectors:this.allowedElementQuerySelectors$.value});if(i?.length){for(let r=0;r<i.length;r++){let a=i[r];if(e.contains(a))return a}return null}return null}catch(i){return this.loggingService.catch("Error in CommentService getNearestAllowedElement: ",i),null}}isElementInsideManualCommentContainer(e){try{return this.domService.isElementInsideParentWithAttribute(e,j.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(i){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",i),!1}}saveComment(e,i){return Q(this,null,function*(){try{i?.annotation&&(e=i.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let r=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(r?.comments?.length){let _=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],r.comments?.forEach(E=>{let D=_.find(L=>L.commentId===E.commentId);D?e.comments.push(D):e.comments.push(E)})}e.comments||(e.comments=[]);let a=!1,s=!1,m;switch(i.type){case Ut.NEWLY_ADDED:case Ut.ADDED:if(!i.updatedComment)break;e?.comments?.length||(s=!0),e.comments.push(i.updatedComment);let _=i?.assigned||void 0;m={commentAnnotation:e,targetComment:i.updatedComment,actionType:i.type,otherFields:{assigned:_}};break;case Ut.APPROVED:e.approved=!0,m={commentAnnotation:e,targetComment:null,actionType:Ut.APPROVED};break;case Ut.ASSIGNED:e.assignedTo=i.assignedTo,m={commentAnnotation:e,targetComment:null,actionType:Ut.ASSIGNED};break;case Ut.UPDATED:if(!i.updatedComment)break;let E=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);if(E>=0){e.comments[E]=i.updatedComment,e.comments[E].status=Ut.UPDATED;let ue=i?.assigned||void 0;m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.UPDATED,otherFields:{assigned:ue}}}break;case Ut.REACTION_ADDED:if(!i.updatedComment)break;let D=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);D>=0&&(e.comments[D]=i.updatedComment,e.comments[D].status=Ut.UPDATED,m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.REACTION_ADDED});break;case Ut.REACTION_DELETED:if(!i.updatedComment)break;let L=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);L>=0&&(e.comments[L]=i.updatedComment,e.comments[L].status=Ut.UPDATED,m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.REACTION_DELETED});break;case Ut.STATUS_CHANGED:e.status.type==="terminal"&&(this.domService.resetSelectedAnnotationsMap(!1,"comment"),e.resolvedByUserId=this.authService.getUser()?.userId),m={commentAnnotation:e,targetComment:null,actionType:Ut.STATUS_CHANGED,otherFields:{oldStatus:i.oldStatus,newStatus:i.newStatus}};break;case Ut.PRIORITY_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.PRIORITY_CHANGED,otherFields:{oldPriority:i.oldPriority,newPriority:i.newPriority}};break;case Ut.ACCESS_MODE_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:i.oldAccessMode,newAccessMode:i.newAccessMode}};break;case Ut.CUSTOM_LIST_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:i.oldCustomList,newCustomList:i.newCustomList}};break;case Ut.SUBSCRIBED:m={commentAnnotation:e,targetComment:null,actionType:Ut.SUBSCRIBED};break;case Ut.UNSUBSCRIBED:m={commentAnnotation:e,targetComment:null,actionType:Ut.UNSUBSCRIBED};break;case Ut.DELETED:if(!i.updatedComment)break;let H=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);if(H>=0){if((H===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!i.skipDeleteThreadConfirmation){let Le={};if(this.deleteReplyConfirmation$.value&&(H!==0||this.deleteThreadWithFirstComment$.value===!1)?Le={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply"}:Le={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(va,{data:Le}).afterClosed().toPromise()))return}let ue=e.comments.splice(H,1),be=e.metadata;ue?.length&&ue.forEach(Le=>{Le?.attachments&&Le.attachments.forEach(qe=>{let Re={attachmentId:qe.attachmentId,organizationId:be?.organizationId??null,documentId:be?.documentId??null,folderId:be?.folderId??null,commentAnnotationId:e.annotationId,apiKey:be?.apiKey??null};this.deleteAttachment({attachment:qe,metadata:Re})}),Le?.reactionAnnotationIds&&Le.reactionAnnotationIds.forEach(qe=>{this.deleteReaction(qe)})})}e.status=this.customFilterService.defaultStatus,H===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments?.length===0?a=!0:(this.analyticsService.trackEvent(X.Events.Comments.COMMENT_THREAD_DELETED,{annotationId:e.annotationId,commentThreadId:i.updatedComment.commentId,commentMode:this.getCommentMode()}),m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.DELETED});break;case Ut.ACCEPTED:let K={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Ut.ACCEPTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:zn(e)};this.commentAccepted$.next(K),m={commentAnnotation:e,targetComment:null,actionType:Ut.ACCEPTED};break;case Ut.REJECTED:let oe={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Ut.REJECTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:zn(e)};this.commentRejected$.next(oe),this.domService.resetSelectedAnnotationsMap(),m={commentAnnotation:e,targetComment:null,actionType:Ut.REJECTED};break;default:break}e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null),i?.updatedComment?.isDraft&&(m=void 0),a?(this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment")):(s&&e.comments?.length&&this.enableAutoCategorize$?.value&&this.setCommentCategory(e),this.updateComment(e,!1,!1,m,!0),e?.multiThreadAnnotationId&&(i.type===Ut.ADDED||i.type===Ut.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e]));let p=this.getCustomPinById(e.annotationId),h={type:i.type,annotation:zn(e),targetAnnotationId:e.annotationId,targetCommentId:i.updatedComment?.commentId,updateContext:(_,E)=>{this.updateCommentAnnotationContext(e.annotationId,_,E)}};p!==void 0&&(h.element=p),delete h?.annotation?.pageInfo,delete h?.annotation?.targetElement,delete h?.annotation?.targetTextRange,h?.type===Ut.DELETED&&(e.comments?.length||(h.annotation=null)),a||this.commentUpdated$.next(h)}catch(r){this.loggingService.catch("Error in CommentService saveComment: ",r)}})}attachComment(e,i=[],r,a){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let s;if(e){let m=dr(e,i);m&&(s={targetElement:{xpath:this.domService.getXPath(m),topPercentage:50,leftPercentage:90},targetElementId:e})}(s||r)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,void 0,void 0,a,void 0,void 0,void 0,r)}catch(s){this.loggingService.catch("Error in CommentService attachComment: ",s)}}updateNotificationsDatabase(e,i,r,a={}){try{let s=I({annotationData:e,targetAnnotationData:i,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 i=null;if(e?.ghostComment)!i&&e.ghostComment?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.xpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null));else{let r=!1;!i&&e?.targetElement?.xpath&&(r=this.domService.isXpathWithId(e?.targetElement?.xpath),i=this.domService.getElementFromXPath(e?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null)),r||(!i&&e?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)))}return i&&!Do(i)&&(i=null),i}catch(i){return this.loggingService.catch("Error in CommentService getElementFromComment: ",i),null}}getElementFromComments(e){try{let i=[],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;!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&&!Do(r)&&(r=null),e?.targetElementId&&(i=Array.from(Zoe(e.targetElementId,["id","data-id"]))),r&&!i.includes(r)&&i.push(r),i}catch(i){return this.loggingService.catch("Error in CommentService getElementFromComment: ",i),[]}}getGhostCommentTargetElement(e){try{let i=e.targetElement?.fXpath||e.targetElement?.xpath,r=null;if(i)for(;!r&&i;)r=this.domService.getElementFromXPath(i),r&&(!this.domService.isElementVisible(r)||!Do(r))&&(r=null),r||(i=i.substring(0,i.lastIndexOf("/")));return i==="/"&&(i=""),i?{xpath:i,topPercentage:e?.targetElement?.topPercentage||0,leftPercentage:e?.targetElement?.leftPercentage||0}:null}catch(i){return this.loggingService.catch("Error in CommentService getGhostCommentTargetElement: ",i),null}}setGhostCommentMessage(e){try{if(e?.ghostComment){e.ghostComment.message="Original content not found.",e.ghostComment.type=Ws.ELEMENT_DELETED;let i=e?.pageInfo?.deviceInfo?.deviceType,r=new ei().getDeviceType();i&&i!==r&&(e.ghostComment.type=Ws.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${i}.`,[Qo.MOBILE,Qo.TABLET].includes(i)&&[Qo.MOBILE,Qo.TABLET].includes(r)||[Qo.DESKTOP,Qo.MONITOR].includes(i)&&[Qo.DESKTOP,Qo.MONITOR].includes(r)?e.ghostComment.isSameGroup=!0:e.ghostComment.isSameGroup=!1)}}catch(i){this.loggingService.catch("Error in CommentService setGhostCommentMessage: ",i)}}addAnnotationToGhostCommentAnnotationMap(e){try{let i=this.ghostCommentAnnotationMap$.value||{},r=i[e?.annotationId]||{};uo(e.ghostComment,r)||(i[e?.annotationId]=e.ghostComment,this.ghostCommentAnnotationMap$.next(i))}catch(i){this.loggingService.catch("Error in CommentService addAnnotationToGhostCommentAnnotationMap: ",i)}}removeAnnotationFromGhostCommentAnnotationMap(e){try{let i=this.ghostCommentAnnotationMap$.value||{};i[e?.annotationId]&&(delete i[e?.annotationId],this.ghostCommentAnnotationMap$.next(i))}catch(i){this.loggingService.catch("Error in CommentService removeAnnotationFromGhostCommentAnnotationMap: ",i)}}getGhostCommentAnnotationMap$(){return this.ghostCommentAnnotationMap$.asObservable()}getGhostCommentAnnotationMap(){return this.ghostCommentAnnotationMap$.value||{}}getUnreadCommentsMap$(){return this.unreadCommentsMap$.asObservable().pipe(qt(Vi))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>i?{count:i[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ce(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ce(e=>e?{count:Object.values(e).reduce((r,a)=>r+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>{if(i){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),a&&Object.keys(i).forEach(m=>{a?.find(h=>h.annotationId===m)?.location?.id===e&&(s+=i[m])})),{count:s}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>{if(i){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),Object.keys(i).forEach(m=>{i[m]&&a?.find(h=>h.annotationId===m)?.location?.id===e&&(s+=1)})),{count:s}}else return null}))}setCommentAnnotationsAsRead(e){try{for(let i of e)this.viewsService.setCommentAnnotationAsRead(i)}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsRead: ",i)}}setCommentAnnotationsAsResolved(e){try{let i=this.customFilterService.resolvedStatus;if(i){for(let r of e)if(i?.id!==r?.status?.id){let a=JSON.parse(JSON.stringify(r||{}));r.status=this.customFilterService.resolvedStatus;let s={annotation:r,type:Ut.STATUS_CHANGED,oldStatus:a.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(r,s)}}}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsResolved: ",i)}}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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setPinCursorImage: ",i)}}getPinCursorImage$(){return this.commentPinCursorImage$.asObservable()}getPinCursorImage(){return this.commentPinCursorImage$.value}setCommentAnnotationsFromCommentsContainer(e){try{this.commentAnnotationsFromCommentsContainer$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsFromCommentsContainer: ",i)}}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((i,r)=>{let a=this.domService.getLastDocumentClick()?.target,s=e?.location||this.docService.getAdditionLocationFromElement(a);if(s?.id){let m=this.docService.getLocationByClientLocationId(s.id);m&&(s=m)}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,m=>{i(m)}),this.addCommentMode$?.value&&!this.persistentCommentMode$?.value&&this.disableAddCommentMode()})}catch(i){return this.loggingService.catch("Error in CommentService addManualComment: ",i),null}})}getCommentUrl(e){try{return e?.pageInfo?.commentUrl?e.pageInfo.commentUrl:(e?.pageInfo||(e.pageInfo=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.commentUrl=this.generateCommentUrl(e),this.updateComment(e),e.pageInfo?.commentUrl)}catch(i){this.loggingService.catch("Error in CommentService getCommentUrl: ",i);return}}uploadFile(e,i){let r=`${j.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${j.FIREBASE_PARTIAL_PATH_COMMENT}/${i.annotationId}`;this.documentPaths?.organizationId&&(r=`${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${j.FIREBASE_PARTIAL_PATH_COMMENT}/${i.annotationId}`);let a={organizationId:i.metadata?.clientOrganizationId??null,documentId:i.metadata?.clientDocumentId??null,commentAnnotationId:i.annotationId,apiKey:i.metadata?.apiKey??null,folderId:i.metadata?.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:i}){return this.storageService.deleteAttachment({attachment:e,metadata:i,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}deleteReaction(e){try{this.reactionService.deleteReactionPinAnnotation(e)}catch(i){this.loggingService.catch("Error in CommentService deleteReaction: ",i)}}generateCommentUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.COMMENT_ID),i.searchParams.append(j.URL_PARAMS.COMMENT_ID,e.annotationId),i.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(i){this.loggingService.catch("Error in CommentService setCustomStatuses: ",i)}}getCustomStatusesShown$(){return this.customStatusesShown$.asObservable()}getCustomStatusesShown(){return this.customStatusesShown$.value}setCustomPriorities(e){try{if(e===void 0)return;this.customFilterService.setCustomPriorityFilters(e)}catch(i){this.loggingService.catch("Error in CommentService setCustomPriorities: ",i)}}setCustomCategories(e){try{if(e===void 0)return;this.customFilterService.setCustomCategories(e)}catch(i){this.loggingService.catch("Error in CommentService setCustomCategories: ",i)}}addCommentOnSelectedText(){try{let e=this.authService.getUser();if(this.textCommentMode$.value&&e&&!(e?.isReadOnly||e?.isAnonymous)&&this.authService.isFeatureAllowed(ke.COMMENT)){let i=this.domService.getRange();if(window.getSelection()?.toString()&&!Y6()&&i?.commonAncestorContainer&&this.isElementInsideAllowedElements(i.commonAncestorContainer)&&!wd(i.commonAncestorContainer)){let r=i?this.domService.getTargetTextRangeFromSelectionRange(i):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 i;if(e){let r=e?.closest(`[${j.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(r){let a=r.getAttribute(j.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(i={},i.targetInlineCommentElementId=a,r.getAttribute(j.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(i.config=JSON.parse(r.getAttribute(j.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)||"{}")))}}return i}catch(i){this.loggingService.catch("Error in CommentService getInlineCommentSectionConfig: ",i)}}createCustomListDataOnAnnotation(e){try{if(e===void 0)return;this.customChipDropdownData$.next(e)}catch(i){this.loggingService.catch("Error in CommentService createCustomListDataOnAnnotation: ",i)}}getCustomChipDropdownData$(){return this.customChipDropdownData$.asObservable()}getCustomChipDropdownData(){return this.customChipDropdownData$.value}setSubscribedUsersDataInCommentAnnotation(e){try{let i={},r=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(s=>{let m=e.subscribedUsers?.[s];m?.type==="manual"&&(i[s]=m)}),e?.assignedTo?.userId){let s=Pt(e?.assignedTo?.userId);r[s]||i[s]?.type!=="manual"&&(i[s]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(s=>!s?.isDraft)?.forEach(s=>{if(s?.from?.userId){let m=Pt(s?.from?.userId);r[m]||i[m]?.type!=="manual"&&(i[m]={user:s?.from,type:"auto"})}s?.to?.forEach(m=>{if(m?.userId){let p=Pt(m.userId);r[p]||i[p]?.type!=="manual"&&(i[p]={user:m,type:"auto"})}}),s?.toOrganizationUserGroup?.forEach(m=>{if(m?.groupId)a[m?.groupId]={type:"auto"};else if(m?.clientGroupId){let p=Pt(m.clientGroupId);a[p]={type:"auto"}}})}),e.subscribedUsers=i,e.unsubscribedUsers=r,e.subscribedGroups=a}catch(i){this.loggingService.catch("Error in CommentService setSubscribeUsersDataInCommentAnnotation: ",i)}}getCopyLink$(){return this.copyLink$.asObservable()}setCopyLink(e){try{this.copyLink$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCopyLink: ",i)}}getCommentAnnotationById(e){return this.commentAnnotationById$.pipe(he(()=>{let{annotationId:i,documentId:r}=e;if(r){let a=yn(r).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(ce(s=>s.find(p=>p.annotationId===i)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let s=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(s){let m=s.find(p=>p.annotationId===i);return se(m||null)}}}return se(null)}),jn(i=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",i),se(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(ce(i=>i?.data),ce(i=>{let r=[];return i&&(r=Object.values(i??{}).filter(a=>typeof a=="object")),r})):se([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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,i,r,a){try{this.sidebarCustomActionEventData$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a})}catch(s){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",s)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,i){try{this.sidebarData$.next({data:e,options:i})}catch(r){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",r)}}getSidebarCustomData(){return this.sidebarData$.asObservable()}setSidebarCustomActionEventDataAllChanges(e,i,r,a){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a});let s=yield this.metadataService.getGlobalMetadata(),m={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:r,commentAnnotations:i,systemFilteredAnnotations:a,metadata:s};this.commentActionsService?.triggerAction(Zi.COMMENT_SIDEBAR_DATA_UPDATE,m)}catch(s){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",s)}})}setSidebarCustomActionEventDataOnInit(e,i,r,a){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a});let m={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:r,commentAnnotations:i,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()}};this.commentActionsService?.triggerAction(Zi.COMMENT_SIDEBAR_DATA_INIT,m)}catch(s){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataOnInit: ",s)}})}getSidebarCustomActionEventDataAllChanges(){return this.sidebarCustomActionEventDataAllChanges$.asObservable()}getSidebarCustomActionEventDataOnInit(){return this.sidebarCustomActionEventDataOnInit$.asObservable()}getSidebarCustomActionEventDataOnInitValue(){return this.sidebarCustomActionEventDataOnInit$.getValue()}setTransformContext(e){try{e?uo(this.transformContext$.value,e)||this.transformContext$.next(e):this.transformContext$.next(null)}catch(i){this.loggingService.catch("Error in CommentService setTransformContext: ",i)}}getTransformContext$(){return this.transformContext$.asObservable()}getTransformContext(){return this.transformContext$.value}enableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{resolveStatusAccessAdminOnly:!1}}),this.resolveStatusAccessAdminOnly$.value===!1)return;this.resolveStatusAccessAdminOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableResolveStatusAccessAdminOnly: ",e)}}getResolveStatusAccessAdminOnly$(){return this.resolveStatusAccessAdminOnly$.asObservable()}getResolveStatusAccessAdminOnly(){return this.resolveStatusAccessAdminOnly$.value}enableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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 i=null;e&&(i={},e.forEach(r=>{r?.annotationId&&i&&(i[r.annotationId]=r)})),uo(this.commentsFromSidebarMap$.value,i)||this.commentsFromSidebarMap$.next(i)}catch(i){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",i)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}filterCommentsUsingSidebarSettings(e){try{let i=Array.isArray(e),r;return i?r=e||[]:e?r=[e]:r=[],this.getFilterCommentsOnDom$().pipe(he(a=>a?r.length===0?se(e):this.getCommentsFromSidebarMap$().pipe(ce(s=>{if(!s)return e;let m=r.filter(p=>p?.isDraft||!!s[p?.annotationId]);return i?m:m.length>0?m[0]:null})):se(e)))}catch{return se(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()}enableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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}sanitizeCommentAnnotation(e){try{return e?.comments?.length&&e.comments.forEach(i=>{i?.commentHtml&&(i.commentHtml=this.domService.sanitizeHtml(i.commentHtml))}),e}catch(i){return this.loggingService.catch("Error in CommentService sanitizeCommentAnnotation: ",i),e}}enableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:i}){try{this.analyticsService.setFeatureConfig({feature:i||ke.COMMENT,config:e})}catch(r){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",r)}}generateContextId(e){try{let i;if(e&&typeof e=="object"){let r=vc(e),a=JSON.stringify(r);i=Pt(a)}return i}catch{return}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(Oc),J(Tn),J(jt),J(lt),J(hn),J(He),J(Ne),J(bi),J(Dm),J(Ci),J(Kp),J(jo),J(Ki),J(fn),J(y),J(vn),J(zo),J(nr),J(Vle),J(ui),J(es),J(o0),J(Mm),J(t0),J(Yp))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var b=(()=>{let _DynamicDataService=class _DynamicDataService{constructor(n,o,t,e,i){this.authService=n,this.commentService=o,this.loggingService=t,this.injector=e,this.docService=i,this.subscriptions=[],this.commonData$=new Ce({}),this.evaluateConditionTriggered=new Ae,this.conditionRegex=/\{(.*?)\}/g,this.extractedProps={},this.condition="",this.dataComponentConfigSignal=Te({});try{this.subscriptions.push(this.authService.getUser$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{user:r}))})),this.subscriptions.push(this.commentService.getUnreadCommentAnnotationCountOnCurrentDocument$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{unreadCommentAnnotationCount:r?.count||0}))})),this.subscriptions.push(this.commentService.getUnreadCommentCountOnCurrentDocument$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{unreadCommentCount:r?.count||0}))})),this.subscriptions.push(this.docService.getUIState$().subscribe(r=>{this.commonData$.next(I(I({},this.commonData$.value),r))})),this.subscriptions.push(this.getCommonData().subscribe(r=>{this.dataComponentConfigSignal.update(a=>(a=I(I({},a),r),a)),this.executeConditionalClasses()})),this.subscriptions.push(this.evaluateConditionTriggered.subscribe(r=>{this.extractedProps=r.extractedProps,this.evaluateCondition(r.className,r.elementRef,r.condition)}))}catch(r){this.loggingService.catch("Error in DynamicDataService constructor: ",r)}}ngOnDestroy(){try{this.subscriptions.forEach(n=>n.unsubscribe())}catch(n){this.loggingService.catch("Error in DynamicDataService ngOnDestroy: ",n)}}getCommonData(){return this.commonData$.asObservable()}getModifiedPathBasedOnCondition(n,o){try{return Object.keys(o).forEach(t=>{o[t].path=this.modifyPathBasedOnCondition(t,n)}),o}catch(t){this.loggingService.catch("Error in DynamicDataService getModifiedPathBasedOnCondition: ",t)}}getComputedValues(n,o,t,e,i,r){try{Object.keys(t).forEach(a=>{let s;if(Fi(n)?s=Mi(()=>pa(n(),t[a].path)):s=Mi(()=>pa(n,t[a].path)),Fi(s()))ur(()=>{try{let m=s()();t[a].value=m,this.evaluateConditionTriggered.emit({extractedProps:t,className:e,elementRef:i,condition:r})}catch{}},{injector:this.injector,allowSignalWrites:!0});else{let m=s();t[a].value=m,this.evaluateConditionTriggered.emit({extractedProps:t,className:e,elementRef:i,condition:r})}})}catch(a){this.loggingService.catch("Error in DynamicDataService getComputedValues: ",a)}}modifyPathBasedOnCondition(n,o){try{let t=n;if(n.startsWith("userContact."))t=n.replace("userContact","selectorItem.contact");else if(n.startsWith("comment."))t=n.replace("comment","commentObj");else if(n.startsWith("commentAnnotation."))t=n.replace("commentAnnotation","componentConfigSignal.annotation");else if(n.startsWith("commentAnnotations."))t=n.replace("commentAnnotations","componentConfigSignal.annotations");else{let e=n.match(/^([^.\[]+)/),i=e?e[1]:"";if(i&&o&&typeof o=="function"&&o()&&i in o()){let r=n.match(/\[(.*?)\]/);if(r&&r[1]){let a=r[1];if(a.includes(".")){let s=a.split(".")[0];s&&o()&&s in o()?t=n:t=n.replace(`[${a}]`,`[componentConfigSignal.${a}]`)}else t=n}else t=n}else t="componentConfigSignal."+n}return t}catch(t){return this.loggingService.catch("Error in DynamicDataService modifyPathBasedOnCondition: ",t),n}}applyConditionalClasses(n,o){try{this.elementRef=n,this.data=o}catch(t){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",t)}}executeConditionalClasses(){try{let n=this.getHostElementAttributes(this.elementRef),t=[...Object.keys(n).filter(e=>e.startsWith("velt-class-")).map(e=>({name:e,value:n[e]}))];if(n["velt-class"]){let e=n["velt-class"],i=/'([^']+)':\s*([^,]+)(?:,|$)/g,r=[],a=0,s=100,m;for(;(m=i.exec(e))!==null;){if(a++>s){this.loggingService.catch("Too many class definitions detected.");break}if(m.length<3)continue;let[,p,h]=m;!p||!h||p.split(" ").forEach(_=>{_.trim()&&r.push({name:`velt-class-${_.trim()}`,value:h.trim()})})}t=[...t,...r]}this.data&&typeof this.data=="object"&&Object.keys(this.data).forEach(e=>{this.updateDataComponentConfigSignal(e,this.data[e])}),t.forEach(e=>{let i=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,i,this.elementRef,e.value))})}catch(n){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",n)}}updateDataComponentConfigSignal(n,o){try{n==="dataComponentConfigSignal"?this.dataComponentConfigSignal.set(o):this.dataComponentConfigSignal.update(t=>T(I({},t),{[n]:o}))}catch(t){this.loggingService.catch("Error in DataComponent updateDataComponentConfigSignal: ",t)}}extractProps(){try{this.extractedProps={},this.conditionRegex.lastIndex=0;let n;for(;(n=this.conditionRegex.exec(this.condition))!==null;){let o=n[1];this.extractedProps[o]={value:null,path:null,isDynamicPath:this.hasDynamicParts(o)}}}catch(n){this.loggingService.catch("Error in DynamicDataService extractProps: ",n)}}hasDynamicParts(n){try{let o=/\[[^\]'"]*[^\]'"]\]/.test(n),t=/\[[^[\]]*[\.\[][^[\]]*\]/.test(n);return o||t}catch(o){return this.loggingService.catch("Error checking for dynamic path: ",o),!1}}evaluateCondition(n,o,t){try{if(t){let e=this.extractedProps,i=t.replace(this.conditionRegex,(s,m)=>{let p=e[m];return p&&p.value!==void 0?typeof p.value=="string"?`'${p.value}'`:p.value:"false"}),r=this.sanitizeCondition(i),a=this.safeEval(r);return n&&o&&(a?this.setHostElementClasses(o,n):this.removeHostElementClasses(o,n)),a}return!1}catch(e){return this.loggingService.catch("Error in IfComponent evaluateCondition: ",e),!1}}sanitizeCondition(n){try{return n.replace(/[^a-zA-Z0-9\s\+\-\*\/\%\(\)\!\=\<\>\|\&\.\[\]\{\},'"]/g,"")}catch(o){return this.loggingService.catch("Error in IfComponent sanitizeCondition: ",o),""}}safeEval(expression){try{return eval(expression)}catch(n){return!1}}getHostElementAttributes(n){try{let o=n,t={};for(let e of o.attributes)t[e.name]=e.value;return t}catch{return{}}}setHostElementClasses(n,o){try{n.classList.add(o)}catch{}}removeHostElementClasses(n,o){try{n.classList.remove(o)}catch{}}};_DynamicDataService.\u0275fac=function(o){return new(o||_DynamicDataService)(J(He),J(we),J(y),J(xt),J(lt))},_DynamicDataService.\u0275prov=Pe({token:_DynamicDataService,factory:_DynamicDataService.\u0275fac,providedIn:"root"});let DynamicDataService=_DynamicDataService;return DynamicDataService})();var z=(()=>{let o=class o{set veltIf(e){try{e&&this.setIfCondition(e)}catch(i){this._loggingService.catch("Error in BaseComponent set veltIf:",i)}}constructor(e,i,r){this._elementRef=e,this._dynamicDataService=i,this._loggingService=r,this.componentConfigSignal=Te({}),this.veltElement=!0,this.conditionSignal=Te(null)}initializeComponentConfigSignal(e){try{this.componentConfigSignal.set(e)}catch(i){this._loggingService.catch("Error in BaseComponent initializeComponentConfigSignal:",i)}}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(i){this._loggingService.catch("Error in BaseComponent setIfCondition:",i)}}};o.\u0275fac=function(i){return new(i||o)(u(k),u(b),u(y))},o.\u0275cmp=O({type:o,selectors:[["app-base"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{componentConfigSignal:"componentConfigSignal",template:"template",wireframe:"wireframe",veltIf:"veltIf"},standalone:!1,decls:0,vars:0,template:function(i,r){},encapsulation:2});let n=o;return n})();var nt=(()=>{let o=class o extends z{onDarkModeChange(){return this.darkModeSubject$.asObservable()}constructor(e,i,r,a,s,m,p){super(e,m,p),this._elementRef=e,this._themeService=i,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(h=>{this._globalDarkMode=h,this.setDarkMode()})),this._featureService&&(this._featureService instanceof we?this._themeSubscriptions.push(this._featureService.getCommentContainerDarkMode().subscribe(h=>{this._featureDarkMode=h,this.setDarkMode()})):this._featureService instanceof nr&&this._themeSubscriptions.push(this._featureService.getDarkMode$().subscribe(h=>{h!==null&&(this._featureDarkMode=h),this.setDarkMode()}))),this._componentDarkModeObservable&&this._componentDarkModeObservable instanceof Lt&&this._themeSubscriptions.push(this._componentDarkModeObservable.subscribe(h=>{this._componentDarkMode=h,this.setDarkMode()}))}catch{}}ngOnInit(){super.ngOnInit()}ngOnChanges(e){try{if(e._darkMode){let i=e._darkMode.currentValue;typeof i=="string"&&(i=i==="true"),this._componentDarkMode=i,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(i){return new(i||o)(u(k),u(Ye),u(Kt),u("FeatureService",8),u(Lt),u(b),u(y))},o.\u0275cmp=O({type:o,selectors:[["app-themed"]],inputs:{_darkMode:[0,"darkMode","_darkMode"]},standalone:!1,features:[B,Xe],decls:0,vars:0,template:function(i,r){},encapsulation:2,changeDetection:0});let n=o;return n})();var ze=(()=>{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(i){this.loggingService.catch("Error in WireframeService constructor: ",i)}}setWireframe(e,i){try{let r=this.wireframeMap.value;r.set(e,i),this.wireframeMap.next(r)}catch(r){this.loggingService.catch("Error in WireframeService setWireframe: ",r)}}setWireframeMap(e){try{let i=this.wireframeMap.value;e.forEach((r,a)=>{i.set(a,r)}),this.wireframeMap.next(i)}catch(i){this.loggingService.catch("Error in WireframeService setWireframeMap: ",i)}}getWireframe(e,i=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&i){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,i=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&i){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,i=!0){return this.wireframeMap.asObservable().pipe(ce(r=>this.getWireframe(e,i)))}setChildren(e){try{this.wireframeMap.next(e)}catch(i){this.loggingService.catch("Error in WireframeService setChildren: ",i)}}getWireframeMap(){return this.wireframeMap.value}};o.\u0275fac=function(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var jle=n=>({componentConfigSignal:n}),oke=(n,o)=>({condition:n,data:o}),rke=(n,o,t,e,i)=>({template:n,context:o,componentName:"velt-confirm-dialog-wireframe",variant:t,setIfCondition:e,componentElementRef:i});function ake(n,o){if(n&1&&(f(0),w(1,"app-confirm-dialog-title",5)(2,"app-confirm-dialog-message",5),C(3,"div",6),w(4,"app-confirm-dialog-reject",5)(5,"app-confirm-dialog-approve",5),S(),v()),n&2){let t=l(3);d(),c("componentConfigSignal",t.componentConfigSignal),d(),c("componentConfigSignal",t.componentConfigSignal),d(2),c("componentConfigSignal",t.componentConfigSignal),d(),c("componentConfigSignal",t.componentConfigSignal)}}function ske(n,o){if(n&1&&(f(0),g(1,ake,6,4,"ng-container",4),v()),n&2){let t=l().ngIf,e=l();d(),c("veltDynamicTemplate",$(3,rke,e.template,M(1,jle,e.componentConfigSignal),t.variant,e.setIfCondition.bind(e),e.elementRef))}}function lke(n,o){if(n&1&&(f(0),g(1,ske,2,9,"ng-container",3),v()),n&2){let t=l();d(),c("veltIf",R(3,oke,t.conditionSignal(),M(1,jle,t.componentConfigSignal)))}}var va=(()=>{let o=class o extends nt{constructor(e,i,r,a,s,m,p){super(s,a,void 0,void 0,void 0,p,e),this.loggingService=e,this.dialogRef=i,this.wireframeService=r,this.themeService=a,this.elementRef=s,this.dynamicDataService=p,this.subscriptions=[],this.componentConfigSignal=Te({title:"",message:"",yesButton:"",noButton:"",variant:"",closeDialog:this.closeDialog.bind(this)}),this.componentId="velt-confirm-dialog",this.veltElement=!0;try{m&&(this.componentConfigSignal.update(h=>(h=I(I({},h),m),h)),m?.darkMode&&[!0,!1].includes(m?.darkMode)&&super.setComponentDarkMode(m?.darkMode)),this.setZIndex()}catch(h){this.loggingService.catch("Error in ConfirmDialogComponent constructor: ",h)}}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(i=>{if(i){let r=document.createElement(i.tagName);r.innerHTML=i.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(i){this.loggingService.catch("Error in ConfirmDialogComponent closeDialog: ",i)}}};o.\u0275fac=function(i){return new(i||o)(u(y),u(Xo),u(ze),u(Ye),u(k),u(bl,8),u(b))},o.\u0275cmp=O({type:o,selectors:[["snippyly-confirm-dialog"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},standalone:!1,features:[U([b]),B],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",""]],template:function(i,r){if(i&1&&(C(0,"div",1,0),g(2,lke,2,6,"ng-container",2),S()),i&2){let a=pe(1);c("snippylyOverlay",a)("snippylyOverlayZIndex",1200)("snippylyOverlayBackdropZIndex",1100),x("data-testid",r.componentId),d(2),c("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}*[_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)}.mat-mdc-dialog-actions[_ngcontent-%COMP%]{justify-content:space-between;gap:var(--velt-spacing-md);min-height:auto} 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 n=o;return n})();var Oc=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L){this.analyticsService=e,this.configService=i,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=m,this.domService=p,this.afAuth=h,this.iamService=_,this.dialog=E,this.loggingService=D,this.notificationService=L,this.areaAnnotationById$=new Ce({}),this.documentPaths=null,this.db=Ii(),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(Fe(H=>!!H),tt(1)).subscribe(H=>{H&&(this.db=H,this.getDocumentPaths())},H=>{this.loggingService.catch("Error in AreaService getDb subscription: ",H)}),this.domService.onWindowPointerMove$().subscribe(H=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&(this.isElementInsideAllowedElements(K)?H6(H.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=K,this.domService.highlightElement(this.highlightElement,j.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},H=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",H)}),this.domService.onWindowKeyupEsc$().subscribe(H=>{this.addAreaMode$.value&&this.disableAddAreaMode()},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",H)}),this.domService.onDocumentClick$().subscribe(H=>{if(H&&this.addAreaMode$.value){if(H.preventDefault(),H.stopPropagation(),!H6(H.target)){let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&this.isElementInsideAllowedElements(K)&&this.addArea(H)}this.disableAddAreaMode()}},H=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",H)}),this.addAreaMode$.subscribe(H=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),H?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"))},H=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",H)}),this.domService.onWindowKeyupBackspace$().subscribe(H=>{this.deleteAreaPinAnnotations("keyupBackspace")},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",H)}),this.domService.onWindowKeyupDelete$().subscribe(H=>{this.deleteAreaPinAnnotations("keyupDelete")},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",H)})}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,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let a,s;try{if(e&&(s=yn(e)),i&&typeof i=="object"){let m=Jo(i);a=yn(JSON.stringify(m))}}catch(m){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",m)}return qn(this.afAuth).pipe(Fe(m=>!!m),he(m=>this.isFeatureAllowed({firebaseUser:m,annotations:[],filteredAnnotations:[]})),he(m=>m.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(p=>(m.featureAllowed=p,m))):se(m)),he(m=>m.featureAllowed?this.authService.isPlanExpired$().pipe(ce(p=>(m.featureAllowed=!p,m))):se(m)),he(m=>m.featureAllowed?se(m).pipe(he(p=>this.docService.getDocumentPaths$().pipe(ce(h=>(this.documentPaths=h,p.documentPaths=h,p)))),he(p=>s?this.getDataFromDocumentIds([s]).pipe(ce(h=>(p.annotations=h||[],I({},p)))):this.docService.getDocumentIds$().pipe(he(h=>{let _=h?.length>0?h.map(E=>E.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(_).pipe(ce(E=>(p.annotations=E||[],I({},p))))}))),he(p=>this.docService.getLocation$().pipe(ce(h=>(p.location=h,p)))),he(p=>this.docService.getLocations$().pipe(ce(h=>(p.customLocations=h,p)))),ce(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let h=[],_=[];return a?h.push(a):(h.push(p?.location?.locationId),h.push(...Object.values(p?.customLocations||[]).map(E=>E.locationId)),p?.location?.location?.id&&_.push(p?.location?.location?.id)),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,h,_),p}}),he(p=>r?se(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>p)):se(p)),he(p=>r?se(p):p?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(ce(()=>p)):se(p)),ce(p=>(p.filteredAnnotations=p.filteredAnnotations?.map(h=>{let _=Object.assign({},h);return _.areaProperties=this.calculateAreaAnnotationPosition(_),_}),p)),he(p=>p?.filteredAnnotations?se(p?.filteredAnnotations||[]):se([])),he(p=>{if(this.authService.isFeatureAllowed(ke.COMMENT))return se(p);{let h=p?.filter(_=>!_?.targetAnnotations?.filter(E=>E?.type===ke.COMMENT)?.length);return se(h)}})):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.AREA)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:i,filters:r}=e;if(i?.some(h=>!h)||!this.documentPaths)return se([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=this.docService.getDocumentPaths()?.allDocuments,m=se([]),p={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(p.documentId=i?.length?i[0]:void 0,p.organizationId=this.documentPaths?.organizationId),a&&s)m=this.commonDbService.dbListener({feature:"allAreas",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",a),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let h=[];for(let _=0;_<(i?.length??0);_+=j.LISTENER_BATCH_SIZE)h.push(i?.slice(_,_+j.LISTENER_BATCH_SIZE)??[]);m=Rn(h.map(_=>this.commonDbService.dbListener({feature:"allAreas",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",_),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[gt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Gr()))).pipe(ce(_=>ua(_)))}return m.pipe(ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),{data:E,operation:_}}),ce(({data:h,operation:_})=>{if(!i)return{data:h,documentMap:{},operation:_};let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),ce(({data:h,documentMap:_,operation:E})=>{if(!r)if(E?.type==="removed"){if(E?.ids?.length){let D=this.areaAnnotationById$.value;E?.ids?.forEach(L=>{delete D?.[L]}),this.areaAnnotationById$.next(D)}}else Object.entries(_??{}).forEach(([D,L])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:L})});return h}))}else return se([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(m)}}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(i){this.loggingService.catch("Error in AreaService getAnnotationById: ",i);return}}filterAnnotationsByLocationIds(e,i,r){try{return e.filter(a=>i.includes(a.locationId)||r?.includes(a?.location?.id)||i?.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 i=e.targetElements[0],r=e.targetElements[1];if(i?.xpath&&r?.xpath){let a=this.domService.getElementFromXPath(i.xpath);a&&zi(a)&&(a=null),!a&&i.cfXpath&&(a=this.domService.getElementFromXPath(i.cfXpath),a&&zi(a)&&(a=null)),!a&&i.fXpath&&(a=this.domService.getElementFromXPath(i.fXpath),a&&zi(a)&&(a=null));let s=this.domService.getElementFromXPath(r.xpath);if(s&&zi(s)&&(s=null),!s&&r.cfXpath&&(s=this.domService.getElementFromXPath(r.cfXpath),s&&zi(s)&&(s=null)),!s&&r.fXpath&&(s=this.domService.getElementFromXPath(r.fXpath),s&&zi(s)&&(s=null)),a&&s){let m=AU(a,s);if(m){let p=a.getBoundingClientRect(),h={};p&&p.width&&p.height&&(h={top:p.height*i.topPercentage/100,left:p.width*i.leftPercentage/100});let _=s.getBoundingClientRect(),E={};_&&_.width&&_.height&&(E={top:_.height*r.topPercentage/100,left:_.width*r.leftPercentage/100});let D=PU(h.left,h.top,a,m),L=PU(E.left,E.top,s,m),H,K,oe,ue,be={};D.x>L.x?D.y>L.y?(ue={x:D.x,y:D.y},H={x:L.x,y:L.y},be.handle1=ue,be.handle2=H):(K={x:D.x,y:D.y},oe={x:L.x,y:L.y},be.handle1=K,be.handle2=oe):D.y>L.y?(oe={x:D.x,y:D.y},K={x:L.x,y:L.y},be.handle1=oe,be.handle2=K):(H={x:D.x,y:D.y},ue={x:L.x,y:L.y},be.handle1=H,be.handle2=ue);let Le={topLeft:H||{x:oe?.x,y:K?.y},bottomRight:ue||{x:K?.x,y:oe?.y},topRight:K||{x:ue?.x,y:H?.y},bottomLeft:oe||{x:H?.x,y:ue?.y}};return be.coordinates=Le,be.targetElement=this.domService.getXPath(m),be}}}}return}catch(i){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",i);return}}addArea(e,i=[],r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let m=this.authService.getUser();if(m)if(m.isReadOnly||m.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let p=new tM;a&&(p.annotationId=a),p.from=m,p.color=j.DEFAULT_ANNOTATION_COLOR,p.lastUpdated=this.timestamp,r&&(p.targetAnnotations=[r]),p.props=new Ol;let h=this.domService.getCurrentWindowSizeValue();if(p.props.screenWidth=h.screenWidth,p.props.screenHeight=h.screenHeight,p.props.screenScrollHeight=h.screenScrollHeight,p.props.viewportWidth=window.innerWidth,p.props.viewportHeight=window.innerHeight,e||i?.length>0){let D=e?this.getPointsForAreaPinAnnotation(e):i;p.targetElements=[],D.forEach(L=>{p.targetElements.push(this.getTargetElementForAreaPinAnnotation(e,{clientX:L.x,clientY:L.y}))})}this.setLocationToAreaAnnotation(p),s&&(p.locationId=s.locationId,p.location=s.location),p.pageInfo=Ei(),p.pageInfo&&(p.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let _=this.getElementForAreaAnnotation(p),E=this.docService.getBaseMetadata("area",{element:_});return p?.metadata||(p.metadata={}),p.metadata=I(I({},p.metadata),E),this.saveAreaToDb(p),p}return}catch(m){this.loggingService.catch("Error in AreaService addArea: ",m);return}}setLocationToAreaAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location)}catch(i){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",i)}}getElementForAreaAnnotation(e){try{let i,r,a;return e.targetElements?.length&&(e.targetElements[0]?.xpath&&(r=this.domService.getElementFromXPath(e.targetElements[0].xpath)),e.targetElements[1]?.xpath&&(a=this.domService.getElementFromXPath(e.targetElements[1].xpath))),i=AU(r,a),i}catch(i){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",i),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.AREA)&&Rn([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe(Fe(([i,r])=>!!i&&!!r),tt(1),he(([i,r])=>{if(this.documentPaths=i,this.db=r,this.documentPaths?.area){let a=rn(this.db,`${this.documentPaths?.area}`),s;e.annotationId?s=rn(this.db,`${this.documentPaths?.area}/${e.annotationId}`):e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let m=JSON.parse(JSON.stringify(e));if(m.position=null,!m?.metadata?.documentId){m?.metadata||(m.metadata={});let _=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),_)}this.domService.toggleAnnotationSelection(m),this.analyticsService.trackEvent(X.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:p,organizationId:h}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}else return se(null)})).subscribe(()=>{},i=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in AreaService saveAreaToDb: ",i)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",i),{}}}updateArea(e,i=!1,r){try{r&&this.setLocationToAreaAnnotation(e),i&&this.updateNotificationsDatabase(e,L6.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(ke.AREA)){let i=JSON.parse(JSON.stringify(e));if(i.position=null,!i?.metadata?.documentId){i?.metadata||(i.metadata={});let s=this.docService.getBaseMetadata();i.metadata=I(I({},i?.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(i))})}}catch(i){this.loggingService.catch("Error in AreaService updateAreaToDb: ",i)}}deleteAreaPinAnnotations(e){try{let i=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(i??{}).forEach(s=>Q(this,null,function*(){let m=i[s];m.type==="area"&&r&&m.from&&(r?.isAdmin||m.from.userId===r.userId)&&a.push(m)})),a?.length&&(this.analyticsService.trackEvent(X.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(va,{data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(tt(1)).subscribe(s=>{s&&(a.forEach(m=>Q(this,null,function*(){yield this.deleteAreaPinAnnotation(m)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(i){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",i)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};return Object.values(this.areaAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==i&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r??{})}catch(r){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",r),[]}}onDeleteTargetAnnotation(e,i){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let a=Object.values(this.areaAnnotationById$.value||{}),s;i?s=a.find(m=>m?.annotationId===i):s=a.find(m=>m?.targetAnnotations?.find(p=>p?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(m=>m?.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(ke.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,L6.DELETED),this.analyticsService.trackEvent(X.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:i,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:i,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),se(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(ke.AREA)?(this.analyticsService.trackEvent(X.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(X.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getTargetElementForAreaPinAnnotation(e,i){try{let r=e,a=r?.touches?.length?r.touches[0]?.clientX:r?.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r?.clientY;i&&(a=i.clientX,s=i.clientY);let m=this.domService.getBackgroundElement(a,s);if(m){let p=this.domService.getXPath(m),h=this.domService.getXPath(m,!0),_=this.domService.getXPath(m,!0,!0),E=m.getBoundingClientRect(),D=a-E.x,L=s-E.y,H=D*100/(E.width||1),K=L*100/(E.height||1);return{xpath:p,fXpath:h,cfXpath:_,leftPercentage:H,topPercentage:K}}else return null}catch(r){return this.loggingService.catch("Error in AreaService getTargetElementForAreaPinAnnotation: ",r),null}}getPointsForAreaPinAnnotation(e){let i=[],r=e,a=r?.touches?.length?r.touches[0]?.clientX:r.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r.clientY;return i.push({x:a,y:s}),i.push({x:a+100,y:s+100}),i}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(i){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",i),!1}}updateNotificationsDatabase(e,i){try{let r={annotationData:e,actionType:i,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=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(i){this.loggingService.catch("Error in AreaService getAreaUrl: ",i);return}}generateAreaUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.TAG_ID),i.searchParams.append(j.URL_PARAMS.TAG_ID,e.annotationId),i.href}generateAreaAnnotationId(){return Q(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let i=this.commonDbService.generateDocumentId();return yield Rp(10),i||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(lt),J(hn),J(Tn),J(He),J(Ne),J(bi),J(fn),J(Ki),J(y),J(vn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ci=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,t={},e=!0){try{this.hideAnalytics||(t||(t={}),t=T(I({},t),{source:"external"}),this.getService(Ze).trackAuthenticatedEvent(o,t,e))}catch(i){this.getService(y).catch("Error in _trackEvent: ",i);return}}};var kM=class extends ci{constructor(o){super(o),this.getService(y).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(y).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(X.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Oc).enableArea()}catch(o){this.getService(y).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(X.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Oc).disableArea()}catch(o){this.getService(y).catch("Error in _disableAreaComment: ",o)}}};var km=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L){this.analyticsService=e,this.configService=i,this.docService=r,this.databaseService=a,this.authService=s,this.domService=m,this.afAuth=p,this.iamService=h,this.dialog=_,this.loggingService=E,this.notificationService=D,this.commonDbService=L,this.arrowAnnotations$=new Ce({}),this.arrowAnnotationsByDocumentId$=new Ce({}),this.documentPaths=null,this.db=Ii(),this.allowedElementIds$=new Ce([]),this.addArrowMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(Fe(H=>!!H),tt(1)).subscribe(H=>{H&&(this.db=H,this.getDocumentPaths())},H=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",H)}),this.domService.onWindowPointerMove$().subscribe(H=>{if(this.addArrowMode$.value){let K=!0,oe=this.domService.getBackgroundElement(H.clientX,H.clientY);oe&&(this.isElementInsideAllowedElements(oe)?$6(H.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==oe&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=oe,this.domService.highlightElement(this.highlightElement,j.CURSOR.ARROW_PIN),K=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&K&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},H=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",H)}),this.domService.onWindowKeyupEsc$().subscribe(H=>{this.addArrowMode$.value&&this.disableAddArrowMode()},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",H)}),this.domService.onDocumentClick$().subscribe(H=>{if(H&&this.addArrowMode$.value){if(!$6(H.target)){let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&this.isElementInsideAllowedElements(K)&&(H.preventDefault(),H.stopPropagation(),this.addArrow(H))}this.disableAddArrowMode()}},H=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",H)}),this.addArrowMode$.subscribe(H=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),H?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"))},H=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",H)}),this.domService.onWindowKeyupBackspace$().subscribe(H=>{this.deleteArrowPinAnnotations("keyupBackspace")},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",H)}),this.domService.onWindowKeyupDelete$().subscribe(H=>{this.deleteArrowPinAnnotations("keyupDelete")},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",H)})}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,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,s;try{if(e&&(s=yn(e)),i&&typeof i=="object"){let m=Jo(i);a=yn(JSON.stringify(m))}}catch(m){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",m)}return qn(this.afAuth).pipe(Fe(m=>!!m),he(m=>this.isFeatureAllowed({firebaseUser:m,annotations:[],filteredAnnotations:[]})),he(m=>m.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(p=>(m.featureAllowed=p,m))):se(m)),he(m=>m.featureAllowed?this.authService.isPlanExpired$().pipe(ce(p=>(m.featureAllowed=!p,m))):se(m)),he(m=>m.featureAllowed?se(m).pipe(he(p=>this.docService.getDocumentPaths$().pipe(ce(h=>(this.documentPaths=h,p.documentPaths=h,p)))),he(p=>this.getDataFromDocumentId(s).pipe(ce(h=>(p.annotations=h||[],I({},p))))),he(p=>this.docService.getLocation$().pipe(ce(h=>(p.location=h,p)))),he(p=>this.docService.getLocations$().pipe(ce(h=>(p.customLocations=h,p)))),ce(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let h=[];return a?h.push(a):(h.push(p?.location?.locationId),h.push(...Object.values(p?.customLocations||[]).map(_=>_.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,h),p}}),he(p=>r?se(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>p)):se(p)),he(p=>r?se(p):p?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(ce(()=>p)):se(p)),ce(p=>(p?.filteredAnnotations?.forEach(h=>{this.calculateArrowAnnotationPosition(h)}),p)),he(p=>p?.filteredAnnotations?se(p?.filteredAnnotations||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.ARROW)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>(this.db=i,this.loggingService.log(this.db),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(ce(r=>({data:r?.data,operation:r?.operation})),ce(({data:r,operation:a})=>{let s=[];return r&&(s=Object.values(r).filter(m=>typeof m=="object")),{data:s,operation:a}}),jn(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),se({data:[],operation:null}))),ce(({data:r,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let s=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(m=>{delete s?.[m]}),this.arrowAnnotationsByDocumentId$.next(s)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,r);return r})):se([]))))}setArrowAnnotationsByDocumentId(e,i){try{if(e){let r=T(I({},this.arrowAnnotationsByDocumentId$.value),{[e]:i});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(e,i){try{return e.filter(r=>i.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let i=this.domService.getXPath(e.targetElement?.xpath);if(i){let r=i.iterateNext();if(r&&Do(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:m}=Np(r);e.position={top:s*e.targetElement.topPercentage/100,left:m*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(i){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",i)}}addArrow(e){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let i=this.authService.getUser();if(i)if(i.isReadOnly||i.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new nM;r.from=i,r.color=i?.color||j.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new Ol;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=j.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>j.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 m=s.iterateNext();m&&(Do(m)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=Ei(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(i){this.loggingService.catch("Error in ArrowService addArrow: ",i)}}setLocationToArrowAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.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);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}}catch{}}catch(i){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",i)}}saveArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.ARROW)&&this.docService.getDocumentPaths$().pipe(Fe(i=>!!i),tt(1),he(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(r=>!!r),tt(1),he(r=>{if(this.db=r,this.loggingService.log(this.db),this.documentPaths?.arrow){let a=rn(this.db,`${this.documentPaths?.arrow}`);e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.arrowUrl=this.generateArrowUrl(e));let s=JSON.parse(JSON.stringify(e));return s.position=null,this.domService.toggleAnnotationSelection(s),this.analyticsService.trackEvent(X.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(s))})}else return se(null)}))))).subscribe(()=>{},i=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",i)}}updateArrow(e,i=!1,r){try{r&&this.setLocationToArrowAnnotation(e),i&&this.updateNotificationsDatabase(e,F6.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 i=this.domService.getXPath(e.targetElement.xpath);if(i){let r=i.iterateNext();r&&(Do(r)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(ke.ARROW)&&this.docService.getDocumentPaths$().pipe(Fe(i=>!!i),tt(1),he(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(r=>!!r),tt(1),he(r=>{if(this.db=r,this.loggingService.log(this.db),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 se(null)}))))).subscribe(()=>{},i=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",i)}}deleteArrowPinAnnotations(e){try{let i=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(i).forEach(s=>Q(this,null,function*(){let m=i[s];if(m.type==="arrow"){let p=r&&!r?.isAnonymous&&!r?.isGuest;r&&m.from&&(p||m.from.userId===r.userId)&&a.push(m)}})),a?.length&&(this.analyticsService.trackEvent(X.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(va,{data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(tt(1)).subscribe(s=>{s&&(a.forEach(m=>Q(this,null,function*(){yield this.deleteArrowPinAnnotation(m)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(i){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",i)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(ke.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,F6.DELETED),this.analyticsService.trackEvent(X.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(ke.ARROW)?(this.analyticsService.trackEvent(X.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(X.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(i){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",i),!1}}updateNotificationsDatabase(e,i){try{let r={annotationData:e,actionType:i,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=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.arrowUrl=this.generateArrowUrl(e),this.updateArrow(e),e.pageInfo?.arrowUrl)}catch(i){this.loggingService.catch("Error in ArrowService getArrowUrl: ",i);return}}generateArrowUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.TAG_ID),i.searchParams.append(j.URL_PARAMS.TAG_ID,e.annotationId),i.href}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(lt),J(hn),J(He),J(Ne),J(bi),J(fn),J(Ki),J(y),J(vn),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var NM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(X.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(km).setAllowedElementIds(o)}catch(t){this.getService(y).catch("Error in allowedElementIds: ",t)}}};var el=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Ce({}),this.onAutocompleteChipClick$=new Ke;try{this.loggingService.log("%c[WB] Creating CLASS: AutocompleteService","color: blue;"),this.create({hotkey:"@",type:"contact",data:[]})}catch(i){this.loggingService.catch("Error in AutocompleteService constructor: ",i)}}create(e){try{if(this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: create","color: green;"),e?.hotkey){let i=this.autocompleteDataMap$.value;i[e.hotkey]=e,this.autocompleteDataMap$.next(i)}}catch(i){this.loggingService.catch("Error in AutocompleteService create: ",i)}}remove(e){try{this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: remove","color: green;");let i=this.autocompleteDataMap$.value;delete i[e],this.autocompleteDataMap$.next(i)}catch(i){this.loggingService.catch("Error in AutocompleteService remove: ",i)}}getAutocompleteDataMap$(){return this.autocompleteDataMap$.asObservable()}getAutocompleteDataMap(){return this.autocompleteDataMap$.value}setOnAutocompleteChipClick(e){this.onAutocompleteChipClick$.next(e)}getOnAutocompleteChipClick$(){return this.onAutocompleteChipClick$.asObservable()}};o.\u0275fac=function(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var LM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(y).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(X.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(el).create(o)}catch(t){this.getService(y).catch("Error in _create: ",t)}}_onAutocompleteChipClick(){this.getService(y).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(X.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(el).getOnAutocompleteChipClick$()}catch(o){return this.getService(y).catch("Error in _onAutocompleteChipClick: ",o),se(null)}}};var ii=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D){this.analyticsService=e,this.authService=i,this.commentService=r,this.contactService=a,this.customFilterService=s,this.docService=m,this.iamService=p,this.loggingService=h,this.metadataService=_,this.reactionService=E,this.commonDbService=D,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(L=>{this.isUserAdmin=L})}catch(L){this.loggingService.catch("Error in CommentActionsService constructor: ",L)}}addCommentAnnotation(a,s){return Q(this,arguments,function*({annotation:e,options:i},r){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),new Promise(m=>{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 h=yield this.getAddCommentAnnotationEventFromCommentAddEventData(p);m(h)}),void 0,void 0,e)})}catch(m){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",m),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return Q(this,null,function*(){try{let i=yield this.metadataService.getGlobalMetadata();return{commentAnnotation:zn(e?.annotation),annotationId:e?.annotation?.annotationId,metadata:i,addContext:e?.addContext,elementRef:e?.elementRef}}catch(i){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",i),null}})}triggerAddCommentAnnotationEvent(e){try{this.triggerAction(Zi.ADD_COMMENT_ANNOTATION,e)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",i)}}triggerAnnotationNotFoundError(e){try{this.loggingService.catch("Annotation not found:","The annotation with the given id was not found.")}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAnnotationNotFoundError: ",i)}}deleteCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},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,i);if(p){let h=this.authService.getUser();if(this.isUserAdmin||h?.userId===p?.from?.userId){this.commentService.deleteCommentPinAnnotation(p);let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:p.annotationId,commentAnnotation:zn(p),metadata:_};return this.triggerAction(Zi.DELETE_COMMENT_ANNOTATION,E),E}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(m){return this.loggingService.catch("Error in CommentActionsService deleteCommentAnnotation: ",m),null}})}updatePriority(s,m){return Q(this,arguments,function*({annotationId:e,priority:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h=JSON.parse(JSON.stringify(h));let _=h.priority?JSON.parse(JSON.stringify(h.priority)):null;_&&i&&_?.id===i?.id?h.priority=void 0:h.priority=i,this.commentService.saveComment(h,{type:Ut.PRIORITY_CHANGED,newPriority:i,oldPriority:_});let E=yield this.metadataService.getGlobalMetadata(),D={newPriority:i,oldPriority:_,annotationId:e,commentAnnotation:zn(h),metadata:E};return this.triggerAction(Zi.UPDATE_PRIORITY,D),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_PRIORITY_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(h),oldPriority:h.priority,newPriority:i,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),D}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",p),null}})}updateStatus(s,m){return Q(this,arguments,function*({annotationId:e,status:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h=JSON.parse(JSON.stringify(h));let _=h.status?JSON.parse(JSON.stringify(h.status)):null;h.status=i,this.commentService.saveComment(h,{type:Ut.STATUS_CHANGED,newStatus:i,oldStatus:_});let E=yield this.metadataService.getGlobalMetadata(),D={newStatus:i,oldStatus:_,annotationId:e,commentAnnotation:zn(h),metadata:E};return this.triggerAction(Zi.UPDATE_STATUS,D),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(h),oldStatus:_,newStatus:i,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),D}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",p),null}})}updateAccess(s,m){return Q(this,arguments,function*({annotationId:e,accessMode:i,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 h=this.commentService.getAnnotationById(e,r);if(h)if(this.isUserAdmin){h=JSON.parse(JSON.stringify(h));let _=h.iam?.accessMode;h.iam.accessMode=i,this.commentService.saveComment(h,{type:Ut.ACCESS_MODE_CHANGED,newAccessMode:i,oldAccessMode:_});let E=yield this.metadataService.getGlobalMetadata(),D={newAccessMode:i,oldAccessMode:_,annotationId:e,commentAnnotation:zn(h),metadata:E};switch(this.triggerAction(Zi.UPDATE_ACCESS,D),i){case Qi.PRIVATE:this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:Qi.PRIVATE,source:a??this.defaultSource});break;case Qi.PUBLIC:this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:Qi.PUBLIC,source:a??this.defaultSource});break;default:break}return D}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:i}){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,i);if(s){s=JSON.parse(JSON.stringify(s));let m=this.customFilterService.resolvedStatus,p=s.status?JSON.parse(JSON.stringify(s.status)):null;m&&(s.status=m,this.commentService.saveComment(s,{type:Ut.STATUS_CHANGED,newStatus:m,oldStatus:p}));let h=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:zn(s),metadata:h};return this.triggerAction(Zi.RESOLVE_COMMENT,_),_}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:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let m=this.commentService.getAnnotationById(e,i);if(m){let p=this.commentService.getCommentUrl(m)??null,h=yield this.metadataService.getGlobalMetadata();return{link:p,annotationId:e,commentAnnotation:zn(m),metadata:h}}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService getLink: ",m),null}})}copyLink(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let m=yield this.getLink({annotationId:e,options:i},r);if(m?.link){bs(m.link),this.commentService.setCopyLink(m.link),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_LINK_COPIED,{annotationId:e,commentType:this.commentService.getCommentType(m.commentAnnotation),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource,link:m.link});let p=yield this.metadataService.getGlobalMetadata(),h={link:m.link,annotationId:e,commentAnnotation:zn(m.commentAnnotation),metadata:p};return this.triggerAction(Zi.COPY_LINK,h),h}return null}catch(m){return this.loggingService.catch("Error in CommentActionsService copyLink: ",m),null}})}addComment(p,h){return Q(this,arguments,function*({annotationId:e,comment:i,assignedTo:r,assigned:a,options:s},m){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let _=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_){let E=this.commentService.getAnnotationById(e,s),D=E?.comments?.length?Ut.ADDED:Ut.NEWLY_ADDED;if(E){E.status.type==="terminal"&&(E.status=this.customFilterService.defaultStatus);let L=new xc;L=I(I({},L),i),L.lastUpdated=new Date,L.attachments||(L.attachments=[]),L.attachments=L.attachments.filter(oe=>oe?.attachmentId),L.createdAt=this.timestamp,L.from=_,r&&(E.assignedTo=r),this.commentService.saveComment(E,{type:D,updatedComment:L,assigned:a});let H=yield this.metadataService.getGlobalMetadata(),K={annotationId:e,commentId:L?.commentId,comment:L,commentAnnotation:zn(E),metadata:H};return this.triggerAction(Zi.ADD_COMMENT,K),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:i?.commentId,commentType:this.commentService.getCommentType(E),commentMode:this.commentService.getCommentMode(),source:m??this.defaultSource}),K}else this.triggerAnnotationNotFoundError(e)}return null}catch(_){return this.loggingService.catch("Error in CommentActionsService addComment: ",_),null}})}approveCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: approveCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i);if(m){m.approved=!0,this.commentService.saveComment(m,{type:Ut.APPROVED}),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource});let p=yield this.metadataService.getGlobalMetadata(),h={annotationId:e,commentAnnotation:zn(m),metadata:p};return this.triggerAction(Zi.APPROVE_COMMENT_ANNOTATION,h),h}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService approveComment: ",m),null}})}acceptCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=m.status?JSON.parse(JSON.stringify(m.status)):null;m.status=j.CommentAcceptStatus,this.commentService.saveComment(m,{type:Ut.ACCEPTED,oldStatus:h,newStatus:j.CommentAcceptStatus});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:zn(m),metadata:_,actionUser:p,replaceContentHtml:m?.comments?.length?m?.comments[0]?.replaceContentHtml:void 0,replaceContentText:m?.comments?.length?m?.comments[0]?.replaceContentText:void 0};return this.triggerAction(Zi.ACCEPT_COMMENT_ANNOTATION,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),E}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",m),null}})}rejectCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=m.status?JSON.parse(JSON.stringify(m.status)):null;m.status=j.CommentRejectStatus,this.commentService.saveComment(m,{type:Ut.REJECTED,oldStatus:h,newStatus:j.CommentRejectStatus});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:zn(m),metadata:_,actionUser:p,replaceContentHtml:m?.comments?.length?m?.comments[0]?.replaceContentHtml:void 0,replaceContentText:m?.comments?.length?m?.comments[0]?.replaceContentText:void 0};return this.triggerAction(Zi.REJECT_COMMENT_ANNOTATION,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),E}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",m),null}})}toggleNotificationSubscription(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=Pt(p.userId);if(h){m.subscribedUsers||(m.subscribedUsers={}),m.unsubscribedUsers||(m.unsubscribedUsers={});let _,E=!1;if(m?.unsubscribedUsers?.[h])E=!1;else if(m?.subscribedUsers?.[h])E=!0;else{let H=this.contactService.getCurrentOrganizationUserIAM();if(H){let K=H.groups||{};Object.keys(K).forEach(oe=>{m?.subscribedGroups?.[oe]&&(E=!0)})}}if(r==="subscribe"||!r&&!E)delete m.unsubscribedUsers[h],m.subscribedUsers[h]={user:p,type:"manual"},_=Ut.SUBSCRIBED;else if(r==="unsubscribe"||!r&&E)delete m.subscribedUsers[h],m.unsubscribedUsers[h]={user:p,type:"manual"},_=Ut.UNSUBSCRIBED;else return null;this.commentService.saveComment(m,{type:_});let D=yield this.metadataService.getGlobalMetadata(),L={annotationId:e,commentAnnotation:zn(m),metadata:D};return _===Ut.SUBSCRIBED?this.triggerAction(Zi.SUBSCRIBE_COMMENT_ANNOTATION,L):this.triggerAction(Zi.UNSUBSCRIBE_COMMENT_ANNOTATION,L),L}}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",m),null}})}assignUser(s,m){return Q(this,arguments,function*({annotationId:e,assignedTo:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h.assignedTo=i,this.commentService.saveComment(h,{type:Ut.ASSIGNED,assignedTo:i});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,assignedTo:i,commentAnnotation:zn(h),metadata:_};return this.triggerAction(Zi.ASSIGN_USER,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ASSIGNED,{annotationId:e,commentType:this.commentService.getCommentType(h),commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,assignedToUserId:i?.userId}),E}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:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getComment","color: green;");let a=this.commentService.getAnnotationById(e,i);return a?a.comments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(a){return this.loggingService.catch("Error in CommentActionsService getComment: ",a),[]}})}updateOrDeleteComment(e,i,r,a,s){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateOrDeleteComment","color: green;"),i?.commentText?.trim()||i?.attachments?.length||i?.recorders?.length){let m=this.authService.getUser();if(this.isUserAdmin||m?.userId===i?.from?.userId){i.lastUpdated=new Date,i.status=Ut.UPDATED,i.isEdited||(i.isEdited=!0,i.editedAt=new Date),this.commentService.saveComment(e,{type:Ut.UPDATED,updatedComment:i});let p=yield this.metadataService.getGlobalMetadata(),h={annotationId:e?.annotationId,commentId:i?.commentId,comment:i,commentAnnotation:zn(e),metadata:p};return this.triggerAction(Zi.UPDATE_COMMENT,h),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_EDITED,{annotationId:e?.annotationId,commentThreadId:i?.commentId,commentType:this.commentService.getCommentType(e),commentMode:this.commentService.getCommentMode(),source:s??this.defaultSource}),h}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:i.commentId,skipDeleteThreadConfirmation:r,options:a});return null}catch(m){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",m),null}})}updateComment(p,h){return Q(this,arguments,function*({annotationId:e,comment:i,skipDeleteThreadConfirmation:r,merge:a,options:s},m){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let _=this.commentService.getAnnotationById(e,s),E=this.authService.getUser();if(!E)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_&&E){let D=i,L=_.comments?.find(H=>H.commentId===i.commentId);if(L){if(this.isUserAdmin||E?.userId===L?.from?.userId)return _?.status.type==="terminal"&&(_.status=this.customFilterService.defaultStatus),a&&(D=I(I({},L),i)),D.from=L.from,D.createdAt=L.createdAt,D.lastUpdated=new Date,yield this.updateOrDeleteComment(_,D,r,s,m);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(_){return this.loggingService.catch("Error in CommentActionsService updateComment: ",_),null}})}deleteComment(m,p){return Q(this,arguments,function*({annotationId:e,commentId:i,skipDeleteThreadConfirmation:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let h=this.commentService.getAnnotationById(e,a),_=this.authService.getUser();if(h){let E=h.comments?.find(D=>D?.commentId===i);if(E)if(this.isUserAdmin||_?.userId===E?.from?.userId){this.commentService.saveComment(h,{type:Ut.DELETED,updatedComment:E,skipDeleteThreadConfirmation:r});let D=yield this.metadataService.getGlobalMetadata(),L={annotationId:e,commentId:i,commentAnnotation:zn(h),comment:E,metadata:D};return this.triggerAction(Zi.DELETE_COMMENT,L),L}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(h){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",h),null}})}addAttachment(s,m){return Q(this,arguments,function*({annotationId:e,files:i,options:r},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let p=[],h=this.commentService.getAnnotationById(e,r);if(h||a==="internal"){let D=[];i.forEach(L=>{let{valid:H,file:K,maxAllowedSize:oe,error:ue}=this.validateFile(L);H&&K?D.push(this.uploadFile(K,h||{}).then(be=>({valid:H,file:K,maxAllowedSize:oe,error:ue,attachment:be||void 0}))):D.push(Promise.resolve({valid:H,file:K,maxAllowedSize:oe,error:ue,attachment:void 0}))}),p=yield Promise.all(D)}else this.triggerAnnotationNotFoundError(e);let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:h?zn(h):void 0,attachments:p,metadata:_};return this.triggerAction(Zi.ADD_ATTACHMENT,E),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 i=100*1024*1024;(e?.type?.includes("image")||e?.type?.includes("pdf"))&&(i=15*1024*1024);let r=e.size<=i;return{valid:r,file:e,maxAllowedSize:i,maxAllowedSizeInMB:i/1024/1024,error:r?void 0:`File size should be less than ${i/1024/1024} MB`}}catch(i){return this.loggingService.catch("Error in CommentActionsService validateFile: ",i),{valid:!1,maxAllowedSize:0,maxAllowedSizeInMB:0,error:"Error in validating file"}}}deleteAttachment(s){return Q(this,arguments,function*({annotationId:e,commentId:i,attachmentId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let m=this.commentService.getAnnotationById(e,a);if(m){let p=m.comments?.find(_=>_?.commentId===i),h=m.metadata;if(p){let _=this.authService.getUser();if(this.isUserAdmin||_?.userId===p?.from?.userId){let E=p.attachments?.find(D=>D?.attachmentId===r);if(E){p.attachments=p.attachments?.filter(K=>K?.attachmentId!==r);let D={attachmentId:E.attachmentId,organizationId:h?.organizationId??null,documentId:h?.documentId??null,folderId:h?.folderId??null,commentAnnotationId:m.annotationId,apiKey:h?.apiKey??null};yield this.commentService.deleteAttachment({attachment:E,metadata:D});let L=yield this.metadataService.getGlobalMetadata(),H={attachment:E,annotationId:e,commentId:i,commentAnnotation:zn(m),metadata:L};return this.triggerAction(Zi.DELETE_ATTACHMENT,H),this.updateComment({annotationId:e,comment:p,options:a}),H}}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(m){return this.loggingService.catch("Error in CommentActionsService deleteAttachment: ",m),null}})}getAttachment(a){return Q(this,arguments,function*({annotationId:e,commentId:i,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===i)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",s),[]}})}uploadFile(e,i){return Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,i)}catch(r){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",r),null}})}getRecording(a){return Q(this,arguments,function*({annotationId:e,commentId:i,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===i)?.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:i,recorderId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let m=this.commentService.getAnnotationById(e,a);if(m){let p=m.comments?.find(h=>h?.commentId===i);if(p){let h=this.authService.getUser();if(this.isUserAdmin||h?.userId===p?.from?.userId){let _=p.recorders?.find(E=>E?.id===r);if(_){p.recorders=p.recorders?.filter(L=>L?.id!==r);let E=yield this.metadataService.getGlobalMetadata(),D={annotationId:e,commentId:i,recording:_,commentAnnotation:zn(m),metadata:E};return this.triggerAction(Zi.DELETE_RECORDING,D),this.updateComment({annotationId:e,comment:p,skipDeleteThreadConfirmation:!0,options:a}),D}}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(m){return this.loggingService.catch("Error in CommentActionsService deleteRecording: ",m),null}})}fetchCommentAnnotations(e){return Q(this,null,function*(){try{let i=yield this.commentService.fetchCommentAnnotations(e),r;if(i?.hasMore){let s=i?.data[i?.data?.length-1];r=yield SU(s?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=i?.data?.reduce((s,m)=>(s[m.metadata.clientDocumentId??m.metadata.documentId]=s[m.metadata.clientDocumentId??m.metadata.documentId]||[],s[m.metadata.clientDocumentId??m.metadata.documentId].push(zn(m)),s),{});return I({data:a},i?.hasMore?{nextPageToken:r}:{})}catch(i){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",i),{data:null}}})}toggleReaction(m,p){return Q(this,arguments,function*({annotationId:e,commentId:i,reaction:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let h=this.commentService.getAnnotationById(e,a),_=this.authService.getUser();if(h&&_){let E=h.comments?.find(D=>D?.commentId===i);if(E){let D=yield this.reactionService.addOrUpdateReaction(r.reactionId,E?.reactionAnnotationIds||[],void 0,void 0,h?.annotationId,r.customReaction,s),L=Ut.REACTION_ADDED;if(D){D?.reactions?.find(oe=>oe.from?.userId===_?.userId)||(L=Ut.REACTION_DELETED),E.reactionAnnotationIds||(E.reactionAnnotationIds=[]),E.reactionAnnotationIds.includes(D.annotationId)||E.reactionAnnotationIds.push(D.annotationId),D?.reactions?.length||(E.reactionAnnotationIds=E.reactionAnnotationIds.filter(oe=>oe!==D.annotationId)),this.commentService.saveComment(h,{type:L,updatedComment:E});let H=yield this.metadataService.getGlobalMetadata(),K={annotationId:e,commentId:i,reaction:D,commentAnnotation:zn(h),metadata:H};return s==="add"?this.triggerAction(Zi.ADD_REACTION,K):s==="delete"?this.triggerAction(Zi.DELETE_REACTION,K):this.triggerAction(Zi.TOGGLE_REACTION,K),K}}}else this.triggerAnnotationNotFoundError(e);return null}catch(h){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",h),null}})}onComposerClick(i){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?zn(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 i=yield this.metadataService.getGlobalMetadata();e.metadata=i,this.triggerAction(Zi.AUTOCOMPLETE_SEARCH,e)}catch(i){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",i)}})}convert(e){try{if(e?.options){let{documentId:i,organizationId:r}=this.docService.getServerId(e?.options);e.options=T(I({},e?.options),{documentId:i,organizationId:r})}return this}catch(i){return this.loggingService.catch("Error in CommentActionsService convert: ",i),this}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in CommentActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in CommentActionsService onAction: ",i),se(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."),se({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),se({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(ce(i=>i?i.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),ce(i=>({data:i})))}catch(i){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",i),se({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentService.getAnnotationsCount(e).pipe(ce(i=>i||{data:null}))}catch(i){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",i),se({data:null})}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(He),J(we),J(Ci),J(zo),J(lt),J(fn),J(y),J(Mm),J(nr),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var r0=(()=>{let o=class o{constructor(e,i){this.httpClient=e,this.loggingService=i,this.fileContentMap$=new Ce({})}getFileContent(e){try{let i=yn(e);return this.fileContentMap$.value[i]?se(this.fileContentMap$.value[i]):this.httpClient.get(e,{responseType:"text"}).pipe(ce(r=>(this.fileContentMap$.next(T(I({},this.fileContentMap$.value),{[i]:r})),r)))}catch(i){return this.loggingService.catch("Error in TranscriptionService saveRecorderToDb: ",i),se(null)}}getVttFileTextToArray(e){try{let m=[],p=e.split(`
|
|
381
|
+
`},o.GIF_PATHS={CAT_JAM:"https://firebasestorage.googleapis.com/v0/b/snippyly-sdk-external/o/emojis%2Fcatjam.gif?alt=media&token=9868b4ec-0031-4751-bb2e-47bf0f9d9583"},o.\u0275fac=function(i){return new(i||o)(J(Ne),J(y),J(Ls))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var nr=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D){this.afAuth=e,this.analyticsService=i,this.authService=r,this.configService=a,this.databaseService=s,this.commonDbService=m,this.docService=p,this.domService=h,this.emojiService=_,this.iamService=E,this.loggingService=D,this.documentPaths=null,this.db=Ii(),this.reactionAnnotationById$=new Ce({}),this.customReactions$=new Ce({}),this.darkMode$=new Ce(null),this.loggingService.log("%c[WB] Creating CLASS: ReactionService","color: blue;"),this.analyticsService.setReactionService(this),this.authService.setReactionService(this),this.databaseService.getDb().pipe(Fe(L=>!!L),tt(1)).subscribe(L=>{L&&(this.db=L,this.getAllReactionAnnotations(void 0,void 0,!0).subscribe())},L=>{this.loggingService.catch("Error in ReactionService getDb subscription: ",L)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ReactionService","color: green;");try{this.reactionAnnotationById$.next({}),this.customReactions$.next({}),this.documentPaths=null}catch(e){this.loggingService.catch("Error in ReactionService clearCache: ",e)}}getAllReactionAnnotations(e,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllReactionAnnotations","color: green;");let m,p;try{if(e&&(p=`${yn(e)}`),i&&typeof i=="object"){let h=Jo(i);m=yn(JSON.stringify(h))}}catch(h){this.loggingService.catch("Error in ReactionService getAllReactionAnnotations: ",h)}return qn(this.afAuth).pipe(Fe(h=>!!h),he(h=>this.isFeatureAllowed({firebaseUser:h,annotations:[],filteredAnnotations:[]})),he(h=>h.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(_=>(h.featureAllowed=_,h))):se(h)),he(h=>h.featureAllowed?se(h).pipe(he(_=>this.docService.getDocumentPaths$().pipe(ce(E=>(this.documentPaths=E,_.documentPaths=E,_)))),he(_=>p?this.getDataFromDocumentIds([p]).pipe(ce(E=>(_.annotations=E||[],I({},_)))):this.docService.getDocumentIds$().pipe(he(E=>{let D=E?.length>0?E.map(L=>L.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(D).pipe(ce(L=>(_.annotations=L||[],I({},_))))}))),he(_=>this.docService.getLocation$().pipe(ce(E=>(_.location=E,_)))),he(_=>this.docService.getLocations$().pipe(ce(E=>(_.customLocations=E,_)))),ce(_=>{if(_.filteredAnnotations=[],p&&!m)return _.filteredAnnotations=_.annotations?.slice(),_;{let E=[];return m?E.push(m):(E.push(_?.location?.locationId),E.push(...Object.values(_?.customLocations||[]).map(D=>D.locationId))),_.filteredAnnotations=this.filterAnnotationsByLocationIds(_?.annotations,E),_}}),he(_=>r?se(_):_?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>_)):se(_)),he(_=>r?se(_):se(_)),ce(_=>_),he(_=>_?.filteredAnnotations?se(_?.filteredAnnotations||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.REACTION)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Reaction feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i,filters:r}=e;if(i?.some(h=>!h)||!this.documentPaths)return se([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=this.docService.getDocumentPaths()?.allDocuments,m=se([]),p={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(p.documentId=i?.length?i[0]:void 0,p.organizationId=this.documentPaths?.organizationId),a&&s)m=this.commonDbService.dbListener({feature:"allReactions",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",a),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let h=[];for(let _=0;_<(i?.length??0);_+=j.LISTENER_BATCH_SIZE)h.push(i?.slice(_,_+j.LISTENER_BATCH_SIZE)??[]);m=Rn(h.map(_=>this.commonDbService.dbListener({feature:"allReactions",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",_),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[gt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Gr()))).pipe(ce(_=>ua(_)))}return m.pipe(ce(h=>({data:h?.data,operation:h?.operation})),ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),E?.forEach(D=>{this.sanitizeReactionAnnotation(D)}),{data:E,operation:_}}),ce(({data:h,operation:_})=>{if(!i)return{data:h,documentMap:{},operation:_};let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),ce(({data:h,documentMap:_,operation:E})=>{if(!r)if(E?.type==="removed"){if(E?.ids?.length){let D=this.reactionAnnotationById$.value;E?.ids?.forEach(L=>{delete D?.[L]}),this.reactionAnnotationById$.next(D)}}else Object.entries(_??{}).forEach(([D,L])=>{this.setReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:L})});return h}),jn(h=>(this.loggingService.catch("Error in ReactionService getDataFromDocumentId: ",h),se([]))))}else return se([])}setReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.reactionAnnotationById$.value),s);this.reactionAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in ReactionService setReactionAnnotationsByOrganizationIdAndDocumentId:",s)}}getReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};return Object.values(this.reactionAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==i&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r)}catch(r){return this.loggingService.catch("Error in ReactionService getReactionAnnotationsByOrganizationIdAndDocumentId:",r),[]}}getLocations$(){return this.docService.getLocation$().pipe(he(e=>this.docService.getLocations$().pipe(ce(i=>({location:e,locations:i})))),ce(e=>{let i=[];return i.push(e?.location?.locationId),i.push(...Object.values(e.locations||[]).map(r=>r.locationId)),i||[]}))}filterAnnotationsByLocationIds(e,i){try{return e.filter(r=>i.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ReactionService filterAnnotationsByLocations:",r),[]}}getAnnotationById(e,i){try{let r=this.reactionAnnotationById$.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};if(a&&r.metadata?.documentId!==a||s&&r.metadata?.organizationId!==s)return}return r}catch(r){this.loggingService.catch("Error in ReactionService getAnnotationById: ",r);return}}getBaseMetadataFromReactionAnnotationId(e){try{let i=this.reactionAnnotationById$.value?.[e];return i?i.metadata:void 0}catch(i){this.loggingService.catch("Error in ReactionService getBaseMetadataFromReactionAnnotationId: ",i);return}}getReactionAnnotationByAnnotationId(e,i){try{return this.reactionAnnotationById$.pipe(ce(()=>this.getAnnotationById(e,i)),he(r=>r?se(r):se(r)))}catch(r){return this.loggingService.catch("Error in ReactionService getReactionAnnotationByAnnotationId: ",r),se(void 0)}}getReactionAnnotationsBySectionId(e){try{return this.reactionAnnotationById$.pipe(he(i=>this.docService.getDocumentPaths$().pipe(ce(r=>({documentPaths:r,sectionId:e,reactionAnnotationsMap:i})))),he(i=>{let r=dr(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(ce(m=>{let h=Object.values(m||{}).find(_=>_.locationId===s||a?.id&&_.location.id===a.id);return T(I({},i),{additionalLocation:h,locationOnElement:!!a})}))}}return se(T(I({},i),{additionalLocation:null,element:r}))}),he(i=>i?.locationOnElement?se(i):this.docService.getLocation$().pipe(ce(r=>T(I({},i),{location:r})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s,element:m})=>{let p=null,h=this.docService.getAdditionalDocumentIdFromElement(m),_=h?this.docService.generateDocumentId(h):i?.documentId,E=i?.organizationId;if(_){let D=this.getReactionAnnotationsByOrganizationIdAndDocumentId({organizationId:E,documentId:_});if(D){p=[];for(let L of D)L?.targetElementId===e&&(s?a&&$u({location:a?.location,locationId:a?.locationId},{location:L.location,locationId:L.locationId})&&p.push(L):r?$u({location:r?.location,locationId:r?.locationId},{location:L.location,locationId:L.locationId})&&p.push(L):L?.locationId||p.push(L))}}return p}))}catch(i){return this.loggingService.catch("Error in ReactionService getReactionAnnotationsBySectionId: ",i),se(null)}}addOrUpdateReaction(e,i,r,a,s,m,p,h){return Q(this,null,function*(){try{let _=i?.map(E=>this.getAnnotationById(E)).find(E=>E?.icon===e);if(_){if(!p||p==="delete")return yield this.updateUserInReaction(_)}else if(!p||p==="add")return yield this.addReaction(void 0,e,r,a,s,m,h)}catch(_){this.loggingService.catch("Error in ReactionService addOrUpdateReaction: ",_)}})}addReaction(e,i,r,a,s,m,p){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{let h=this.authService.getUser();if(h)if(h.isReadOnly||h.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add reactions.");else{let _=new vM;if(_.from=h,_.lastUpdated=this.timestamp,_.reactions=[],_.reactions.push({from:h,lastUpdated:this.timestamp}),a&&(_.targetElementId=a),s&&(_.commentAnnotationId=s),this.setLocationToReactionAnnotation(_),_.pageInfo=Ei(),_.pageInfo&&(_.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),i)if(_.icon=i,m)_.iconUrl=m?.url,_.iconEmoji=m?.emoji;else{let E=this.customReactions$.value;if(E){let D=E[i];D?.url&&(_.iconUrl=D?.url),D?.emoji&&(_.iconEmoji=D?.emoji)}}return r&&(_.location={},_.location=I({},r),_.locationId=this.docService.genarateLocationId(_.location)),yield this.saveReactionToDb(_)}}catch(h){this.loggingService.catch("Error in ReactionService addReaction: ",h)}})}setLocationToReactionAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location);try{let r;e.targetElement?.xpath?r=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId&&(r=dr(e.targetElementId,["id","data-id"]));let a=this.docService.getAdditionLocationFromElement(r);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}catch{}}catch(i){this.loggingService.catch("Error in ReactionService setLocationToReactionAnnotation:",i)}}getElementForReactionAnnotation(e){try{let i;return e.targetElementId&&(i=dr(e.targetElementId,["id","data-id"])),i}catch(i){return this.loggingService.catch("Error in ReactionService getElementForReactionAnnotation: ",i),null}}saveReactionToDb(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: saveReactionToDb","color: green;");try{if(this.authService.getUser()){let i=yield this.docService.getDocumentPaths$().pipe(Fe(a=>!!a),tt(1)).toPromise();if(!i)throw new Error("Document paths not found.");this.documentPaths=i,this.loggingService.log(this.documentPaths);let r=yield this.databaseService.getDb().pipe(Fe(a=>!!a),tt(1)).toPromise();if(!r)throw new Error("Database not found.");if(this.db=r,this.loggingService.log(this.db),this.documentPaths?.reaction){let a=rn(this.db,`${this.documentPaths.reaction}`);if(e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo,!e?.metadata?.documentId){e?.metadata||(e.metadata={});let h=this.getElementForReactionAnnotation(e),_=this.docService.getBaseMetadata("reaction",{commentAnnotationId:e.commentAnnotationId,element:h});e.metadata=I(I({},e?.metadata),_)}let s=JSON.parse(JSON.stringify(e));s.position=null;let{documentId:m,organizationId:p}=this.getDocumentIdAndOrganizationIdFromReactionAnnotation(e);return yield this.commonDbService.setData({feature:"reaction",properties:{id:e.annotationId,documentId:m,organizationId:p},data:s}),s}else return}}catch(i){this.loggingService.catch("Error in ReactionService saveReactionToDb: ",i)}})}getDocumentIdAndOrganizationIdFromReactionAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in ReactionService getDocumentIdAndOrganizationIdFromReactionAnnotation: ",i),{}}}updateUserInReaction(e){return Q(this,null,function*(){try{let i=this.authService.getUser();if(i)return e?.reactions||(e.reactions=[]),e?.reactions?.find(a=>a?.from?.userId===i?.userId)?e.reactions=e?.reactions?.filter(a=>a?.from?.userId!==i?.userId):e.reactions.push({from:i,lastUpdated:this.timestamp}),e.reactions.length?yield this.updateReaction(e):yield this.deleteReactionPinAnnotation(e?.annotationId),e}catch(i){this.loggingService.catch("Error in ReactionService updateUserInReaction: ",i)}})}removeUserFromReaction(e){this.loggingService.log("%c[WB] Calling FUNCTION: removeUserFromReaction","color: green;");try{let i=this.authService.getUser();i&&(e?.reactions||(e.reactions=[]),e.reactions=e?.reactions?.filter(r=>r?.from?.userId!==i?.userId),this.updateReaction(e))}catch(i){this.loggingService.catch("Error in ReactionService removeUserFromReaction: ",i)}}updateReaction(e,i,r){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateReaction","color: green;");try{if(this.authService.getUser()){if(e?.targetElement?.xpath){let p=this.domService.getXPath(e.targetElement.xpath);if(p){let h=p.iterateNext();h&&(Do(h)||(e.targetElement=null))}}let a=JSON.parse(JSON.stringify(e));if(a.position=null,a.lastUpdated=this.timestamp,!a?.metadata?.documentId){a?.metadata||(a.metadata={});let p=this.docService.getBaseMetadata("reaction",{commentAnnotationId:e.commentAnnotationId});a.metadata=I(I({},a?.metadata),p)}let{documentId:s,organizationId:m}=a?.metadata||{};return r?yield this.commonDbService.updateData({feature:"reaction",properties:{id:e.annotationId,documentId:s,organizationId:m},data:JSON.parse(JSON.stringify(a))}):yield this.commonDbService.setData({feature:"reaction",properties:{id:e.annotationId,documentId:s,organizationId:m},data:JSON.parse(JSON.stringify(a))}),a}}catch(a){this.loggingService.catch("Error in ReactionService updateReaction: ",a)}})}deleteReactionPinAnnotation(e,i){return Q(this,null,function*(){try{let r=this.getAnnotationById(e),{documentId:a,organizationId:s}=this.getDocumentIdAndOrganizationIdFromReactionAnnotation(r);yield this.commonDbService.deleteData({feature:"reaction",properties:{id:e,documentId:a,organizationId:s}})}catch(r){this.loggingService.catch("Error in ReactionService deleteReactionPinAnnotation: ",r)}})}setCustomReactions(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;"),this.customReactions$.next(e),this.emojiService.setEmojiList(e)}catch(i){this.loggingService.catch("Error in ReactionService setCustomReactions: ",i)}}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 ReactionService 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 ReactionService disableDarkMode: ",e)}}getDarkMode(){return this.darkMode$.value}getDarkMode$(){return this.darkMode$.asObservable()}sanitizeReactionAnnotation(e){try{e&&(e.iconUrl&&(e.iconUrl=this.domService.sanitizeHtml(e.iconUrl)),e.iconEmoji&&(e.iconEmoji=this.domService.sanitizeHtml(e.iconEmoji)),e.icon&&(e.icon=this.domService.sanitizeHtml(e.icon)))}catch(i){this.loggingService.catch("Error in ReactionService sanitizeReactionAnnotation: ",i)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(Ze),J(He),J(jt),J(hn),J(Tn),J(lt),J(Ne),J(wc),J(fn),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Vle=(()=>{let o=class o{constructor(e,i){this.domService=e,this.loggingService=i,this.keyEventSubject$=new Ke;try{this.loggingService.log("%c[WB] Creating CLASS: HotkeyService","color: blue;"),this.keyEvent$=this.keyEventSubject$.asObservable().pipe(Fg()),this.domService.onWindowKeydown$().subscribe(r=>{this.keyEventSubject$.next(r)})}catch(r){this.loggingService.catch("Error in HotkeyService constructor: ",r)}}getKeyPressEvent(e,i={}){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getKeyPressEvent","color: green;"),this.keyEvent$.pipe(Fe(r=>r?.key===e),Fe(r=>!(!!i?.includeCtrl!==r.ctrlKey||!!i?.includeAlt!==r.altKey||!!i?.includeShift!==r.shiftKey||!!i?.includeMeta!==r.metaKey)),Fe(()=>this.isNoInputFocused()))}catch(r){return this.loggingService.catch("Error in HotkeyService getKeyPressEvent: ",r),new Lt}}isNoInputFocused(){try{let e=document.activeElement;for(;e&&e?.tagName!=="BODY";){if(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e?.isContentEditable)return!1;e=e?.parentElement}return!0}catch(e){return this.loggingService.catch("Error in HotkeyService isNoInputFocused: ",e),!1}}};o.\u0275fac=function(i){return new(i||o)(J(Ne),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Ye=(()=>{let o=class o{constructor(e,i){this.loggingService=e,this.configService=i,this.darkMode$=new Ce(!1)}setDarkMode(e){try{let i=document.documentElement;if(!i)return;e?i.setAttribute(j.ATTRIBUTES.VELT_THEME,"dark"):i.removeAttribute(j.ATTRIBUTES.VELT_THEME),this.darkMode$.next(e)}catch(i){this.loggingService.catch("Error in theme service setDarkMode: ",i)}}getDarkMode$(){return this.darkMode$.asObservable()}updateListenerOnConfigChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.usePrefersColorScheme){this.enablePrefersColorScheme();return}this.disablePrefersColorScheme()})}catch(e){this.loggingService.catch("Error in theme service updateListenerOnConfigChange: ",e)}}enablePrefersColorScheme(){try{if(this.disablePrefersColorScheme(),!window.matchMedia)return;this.darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.setDarkMode(this.darkModeQuery.matches),this.darkModeQueryListener=e=>{this.setDarkMode(e.matches)},this.darkModeQuery.addEventListener("change",this.darkModeQueryListener)}catch(e){this.loggingService.catch("Error in theme service enablePrefersColorScheme: ",e)}}disablePrefersColorScheme(){try{this.darkModeQuery&&this.darkModeQueryListener&&this.darkModeQuery.removeEventListener("change",this.darkModeQueryListener)}catch(e){this.loggingService.catch("Error in theme service disablePrefersColorScheme: ",e)}}};o.\u0275fac=function(i){return new(i||o)(J(y),J(jt))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();function Y7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",17)(2,"path",18)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function K7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",22)(2,"path",23)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function Z7e(n,o){if(n&1&&(f(0),C(1,"div",6)(2,"div",7),g(3,Y7e,6,0,"svg",8)(4,K7e,6,0,"ng-template",null,1,De),S(),C(6,"div",9),te(7),A(8,"translate"),w(9,"br"),te(10),A(11,"translate"),S(),C(12,"div",10)(13,"p"),te(14),A(15,"translate"),le(),C(16,"svg",11),w(17,"path",12)(18,"path",13)(19,"path",14)(20,"path",15),S(),te(21),A(22,"translate"),S(),mt(),C(23,"p"),te(24),A(25,"translate"),S()()(),v()),n&2){let t=pe(5),e=l();d(3),c("ngIf",e.darkMode)("ngIfElse",t),d(4),ve(" ",P(8,7,"Allow mic permission to"),""),d(3),ve("",P(11,9,"enable your audio")," "),d(4),ve(" ",P(15,11,"1. Click the")," "),d(7),ve(" ",P(22,13,"page info icon in your browser\u2019s address bar")," "),d(3),ve(" ",P(25,15,"2. Turn on Microphone")," ")}}function X7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",17)(2,"path",24)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function Q7e(n,o){n&1&&(le(),C(0,"svg",16),w(1,"rect",22)(2,"path",25)(3,"path",19)(4,"rect",20)(5,"path",21),S())}function J7e(n,o){if(n&1&&(f(0),C(1,"div",6)(2,"div",7),g(3,X7e,6,0,"svg",8)(4,Q7e,6,0,"ng-template",null,2,De),S(),C(6,"div",9),te(7),A(8,"translate"),w(9,"br"),te(10),A(11,"translate"),S(),C(12,"div",10)(13,"p"),te(14),A(15,"translate"),le(),C(16,"svg",11),w(17,"path",12)(18,"path",13)(19,"path",14)(20,"path",15),S(),te(21),A(22,"translate"),S(),mt(),C(23,"p"),te(24),A(25,"translate"),S()()(),v()),n&2){let t=pe(5),e=l();d(3),c("ngIf",e.darkMode)("ngIfElse",t),d(4),ve(" ",P(8,7,"Allow camera permission"),""),d(3),ve("",P(11,9,"to enable your video")," "),d(4),ve(" ",P(15,11,"1. Click the")," "),d(7),ve(" ",P(22,13,"page info icon in your browser\u2019s address bar")," "),d(3),ve(" ",P(25,15,"2. Turn on Camera")," ")}}var OM=(()=>{let o=class o{constructor(e,i,r,a,s){this.loggingService=e,this.themeService=i,this.elementRef=r,this.matDialogRef=a,this.data=s,this.veltElement=!0,this.darkMode=!0;try{this.loggingService.log("%c[WB] Creating CLASS: DevicePermissionDeniedDialogComponent","color: blue;"),this.type=this.data?.type,[!0,!1].includes(this.data?.darkMode)&&(this.darkMode=this.data?.darkMode)}catch(m){this.loggingService.catch("Error in DevicePermissionDeniedDialogComponent constructor: ",m)}}ngOnDestroy(){}};o.\u0275fac=function(i){return new(i||o)(u(y),u(Ye),u(k),u(Xo,8),u(bl,8))},o.\u0275cmp=O({type:o,selectors:[["velt-device-permission-denied-dialog-internal"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{type:"type"},standalone:!1,decls:5,vars:5,consts:[["devicePermissionDialogRef",""],["defaultAudioIcon",""],["defaultVideoIcon",""],[1,"velt-device-permission-denied-dialog--container",3,"snippylyOverlay","snippylyOverlayZIndex"],[3,"ngSwitch"],[4,"ngSwitchCase"],[1,"velt-device-permission-denied-dialog"],[1,"velt-device-permission-denied-dialog--icon"],["width","61","height","60","viewBox","0 0 61 60","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf","ngIfElse"],[1,"velt-device-permission-denied-dialog--header"],[1,"velt-device-permission-denied-dialog--content"],["width","13","height","12","viewBox","0 0 13 12","fill","none","xmlns","http://www.w3.org/2000/svg",1,"velt-device-permission-denied-dialog--page-info-icon"],["d","M4.375 2.5C4.375 3.53553 3.53553 4.375 2.5 4.375C1.46447 4.375 0.625 3.53553 0.625 2.5C0.625 1.46447 1.46447 0.625 2.5 0.625C3.53553 0.625 4.375 1.46447 4.375 2.5Z","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M5 2.5H12.5","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M0 8.75H7.5","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["d","M11.875 8.75C11.875 9.78553 11.0355 10.625 10 10.625C8.96447 10.625 8.125 9.78553 8.125 8.75C8.125 7.71447 8.96447 6.875 10 6.875C11.0355 6.875 11.875 7.71447 11.875 8.75Z","stroke","currentColor","stroke-opacity","0.6","stroke-width","1.25"],["width","61","height","60","viewBox","0 0 61 60","fill","none","xmlns","http://www.w3.org/2000/svg"],["x","0.5","y","4","width","56","height","56","rx","28","fill","white","fill-opacity","0.04"],["d","M23.5026 20.333C23.5026 19.0069 24.0294 17.7352 24.9671 16.7975C25.9048 15.8598 27.1765 15.333 28.5026 15.333C29.8287 15.333 31.1005 15.8598 32.0381 16.7975C32.9758 17.7352 33.5026 19.0069 33.5026 20.333V28.6663C33.5027 29.1599 33.4297 29.6508 33.2859 30.123M29.9526 33.4563C29.2054 33.6828 28.4155 33.7311 27.6463 33.5973C26.8771 33.4636 26.1499 33.1516 25.5229 32.6863C24.8959 32.2211 24.3866 31.6154 24.0358 30.9179C23.685 30.2204 23.5024 29.4504 23.5026 28.6697V27.003M16.8359 28.6663C16.8356 30.7719 17.405 32.8383 18.484 34.6465C19.5629 36.4546 21.111 37.9371 22.9642 38.9366C24.8174 39.9362 26.9066 40.4156 29.0102 40.324C31.1137 40.2324 33.1533 39.5732 34.9126 38.4163M38.2459 35.083C39.5023 33.1791 40.1701 30.9474 40.1659 28.6663M21.8359 46.9997H35.1693M28.5026 40.333V46.9997","stroke","white","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M13.5 17L43.5 47","stroke","currentColor","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["x","36.5","width","24","height","24","rx","12","fill","currentColor"],["d","M48.5 18.99V19M48.5 14V5","stroke","white","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["x","0.5","y","4","width","56","height","56","rx","28","fill","black","fill-opacity","0.04"],["d","M23.5026 20.333C23.5026 19.0069 24.0294 17.7352 24.9671 16.7975C25.9048 15.8598 27.1765 15.333 28.5026 15.333C29.8287 15.333 31.1005 15.8598 32.0381 16.7975C32.9758 17.7352 33.5026 19.0069 33.5026 20.333V28.6663C33.5027 29.1599 33.4297 29.6508 33.2859 30.123M29.9526 33.4563C29.2054 33.6828 28.4155 33.7311 27.6463 33.5973C26.8771 33.4636 26.1499 33.1516 25.5229 32.6863C24.8959 32.2211 24.3866 31.6154 24.0358 30.9179C23.685 30.2204 23.5024 29.4504 23.5026 28.6697V27.003M16.8359 28.6663C16.8356 30.7719 17.405 32.8383 18.484 34.6465C19.5629 36.4546 21.111 37.9371 22.9642 38.9366C24.8174 39.9362 26.9066 40.4156 29.0102 40.324C31.1137 40.2324 33.1533 39.5732 34.9126 38.4163M38.2459 35.083C39.5023 33.1791 40.1701 30.9474 40.1659 28.6663M21.8359 46.9997H35.1693M28.5026 40.333V46.9997","stroke","black","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M42.375 39.2135C42.7034 39.1007 42.9883 38.8881 43.19 38.6054C43.3917 38.3227 43.5001 37.9841 43.5 37.6369V26.3635C43.4998 26.0795 43.4271 25.8003 43.2888 25.5523C43.1504 25.3043 42.9509 25.0958 42.7093 24.9465C42.4677 24.7973 42.192 24.7122 41.9083 24.6994C41.6246 24.6867 41.3424 24.7466 41.0883 24.8735L33.5 28.6669V30.3335V25.3333C33.5 24.4493 33.1488 23.6014 32.5237 22.9763C31.8986 22.3512 31.0507 22 30.1667 22H25.1667M33.5 37V38.6667C33.5 39.5507 33.1488 40.3986 32.5237 41.0237C31.8986 41.6488 31.0507 42 30.1667 42H16.8333C15.9493 42 15.1014 41.6488 14.4763 41.0237C13.8512 40.3986 13.5 39.5507 13.5 38.6667V25.3333C13.5 24.4493 13.8512 23.6014 14.4763 22.9763C15.1014 22.3512 15.9493 22 16.8333 22H18.5","stroke","white","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["d","M42.375 39.2135C42.7034 39.1007 42.9883 38.8881 43.19 38.6054C43.3917 38.3227 43.5001 37.9841 43.5 37.6369V26.3635C43.4998 26.0795 43.4271 25.8003 43.2888 25.5523C43.1504 25.3043 42.9509 25.0958 42.7093 24.9465C42.4677 24.7973 42.192 24.7122 41.9083 24.6994C41.6246 24.6867 41.3424 24.7466 41.0883 24.8735L33.5 28.6669V30.3335V25.3333C33.5 24.4493 33.1488 23.6014 32.5237 22.9763C31.8986 22.3512 31.0507 22 30.1667 22H25.1667M33.5 37V38.6667C33.5 39.5507 33.1488 40.3986 32.5237 41.0237C31.8986 41.6488 31.0507 42 30.1667 42H16.8333C15.9493 42 15.1014 41.6488 14.4763 41.0237C13.8512 40.3986 13.5 39.5507 13.5 38.6667V25.3333C13.5 24.4493 13.8512 23.6014 14.4763 22.9763C15.1014 22.3512 15.9493 22 16.8333 22H18.5","stroke","currentColor","stroke-opacity","0.52","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(i,r){if(i&1&&(C(0,"div",3,0),f(2,4),g(3,Z7e,26,17,"ng-container",5)(4,J7e,26,17,"ng-container",5),v(),S()),i&2){let a=pe(1);c("snippylyOverlay",a)("snippylyOverlayZIndex",3e3),d(2),c("ngSwitch",r.type),d(),c("ngSwitchCase","audio"),d(),c("ngSwitchCase","video")}},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%]{--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-device-permission-denied-dialog--panel mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{padding:0;background-color:transparent;box-shadow:none;overflow:unset}.velt-device-permission-denied-dialog[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--velt-spacing-lg);align-items:center;justify-content:center;padding:4rem;box-sizing:border-box;word-break:break-word;max-width:600px;max-height:400px;text-align:center;background-color:var(--velt-background-0);border-radius:var(--velt-border-radius-2xl);box-shadow:0 calc((4rem + 0px) * var(--velt-base-rem-unit)) calc((4rem + 0px) * var(--velt-base-rem-unit)) calc((-3rem + 0px) * var(--velt-base-rem-unit)) #1f2f461f}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--icon[_ngcontent-%COMP%]{color:var(--velt-error)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--header[_ngcontent-%COMP%]{font-size:var(--velt-font-size-lg);font-weight:600;line-height:36px;letter-spacing:-.02em;text-align:center;color:var(--velt-text-0)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--content[_ngcontent-%COMP%]{font-size:var(--velt-font-size-sm);font-weight:400;line-height:21px;text-align:center;color:var(--velt-text-0)}.velt-device-permission-denied-dialog[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--content[_ngcontent-%COMP%] .velt-device-permission-denied-dialog--page-info-icon[_ngcontent-%COMP%]{margin-left:var(--velt-spacing-sm);margin-right:var(--velt-spacing-sm);color:var(--velt-error)}"],changeDetection:0});let n=o;return n})();var Pm=(()=>{let o=class o{constructor(e,i){this.loggingService=e,this.matDialog=i,this.audioPermissionState$=new Ce(null),this.videoPermissionState$=new Ce(null);try{this.loggingService.log("%c[WB] Creating CLASS: DevicePermissionService","color: blue;"),this.checkPermissions()}catch(r){this.loggingService.catch("Error in DevicePermissionService constructor: ",r)}}checkPermissions(){try{this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: checkPermissions","color: green;"),new ei().browserName!=="Firefox"&&(navigator.permissions.query({name:"microphone"}).then(i=>{this.audioPermissionState$.next(i.state),i.onchange=()=>{this.audioPermissionState$.next(i.state)}}).catch(i=>{}),navigator.permissions.query({name:"camera"}).then(i=>{this.videoPermissionState$.next(i.state),i.onchange=()=>{this.videoPermissionState$.next(i.state)}}).catch(i=>{}))}catch(e){this.loggingService.catch("Error in DevicePermissionService checkPermissions: ",e)}}getPermissionState$(e){try{switch(this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: getPermissionState$","color: green;"),e){case"audio":return this.getAudioPermissionState$();case"video":return this.getVideoPermissionState$();default:return se(null)}}catch(i){return this.loggingService.catch("Error in DevicePermissionService getPermissionState$: ",i),se(null)}}getAudioPermissionState$(){return this.audioPermissionState$.asObservable()}getVideoPermissionState$(){return this.videoPermissionState$.asObservable()}openDevicePermissionDeniedDialog(e,i){try{this.loggingService.log("%c[WB] Calling DevicePermissionService FUNCTION: openDevicePermissionDeniedDialog","color: green;"),this.matDialog.open(OM,{panelClass:"velt-device-permission-denied-dialog--panel",backdropClass:["velt-device-permission-denied-dialog--backdrop","s-background-blur-1"],data:I({type:e},i||{})})}catch(r){this.loggingService.catch("Error in DevicePermissionService openDevicePermissionDeniedDialog: ",r)}}};o.\u0275fac=function(i){return new(i||o)(J(y),J(Ki))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var eke=()=>["video","screen"];function tke(n,o){if(n&1&&w(0,"app-recording-preview-steps-dialog-video",4),n&2){let t=l(2);c("componentConfigSignal",t.componentConfigSignal)}}function nke(n,o){if(n&1&&w(0,"app-recording-preview-steps-dialog-audio",4),n&2){let t=l(2);c("componentConfigSignal",t.componentConfigSignal)}}function ike(n,o){if(n&1&&(f(0),C(1,"div",2,0),g(3,tke,1,1,"app-recording-preview-steps-dialog-video",3)(4,nke,1,1,"app-recording-preview-steps-dialog-audio",3),S(),v()),n&2){let t=o.ngIf,e=pe(2),i=l();d(),c("snippylyOverlay",e)("snippylyOverlayZIndex",2e3),x("aria-label","Recording preview - "+t.type+" mode")("data-testid",i.componentId),d(2),c("ngIf",Nt(6,eke).includes(t.type)),d(),c("ngIf",t.type==="audio")}}var AM=(()=>{let o=class o{constructor(e,i,r,a,s,m,p){this.loggingService=e,this.recorderService=i,this.dialog=r,this.devicePermissionService=a,this.dialogRef=s,this.elementRef=m,this.data=p,this.darkMode=!1,this.shadowDom=!0,this.startCountdownFrom=3,this.defaultMediaSourceOptions=yc(),this.recordingCountdownEnabled=!1,this.subscriptions=[],this.veltElement=!0,this.componentId="velt-recording-preview-steps-dialog",this.componentConfigSignal=Te({closeDialog:this.closeDialog.bind(this),startCountdown:this.startCountdown.bind(this),toggleAudio:this.toggleAudio.bind(this),toggleVideo:this.toggleVideo.bind(this),toggleSettings:this.toggleSettings.bind(this),cancelCountdown:this.cancelCountdown.bind(this),updateMediaConfig:this.updateMediaConfig.bind(this),handleOverlayClick:this.handleOverlayClick.bind(this),countdownStarted:!1,mediaConfig:{audio:{enabled:!1},video:{enabled:!1}},mediaState:{audio:{enabled:!1},video:{enabled:!1}},type:"video",countdown:this.startCountdownFrom,mediaStream:void 0,isSettingsOpen:!1,darkMode:this.darkMode,shadowDom:this.shadowDom});try{this.devicePermissionService.getPermissionState$("video").subscribe(h=>{this.componentConfigSignal.update(_=>(_=T(I({},_),{mediaState:T(I({},_.mediaState),{video:{enabled:h!=="denied"}})}),_))}),this.devicePermissionService.getPermissionState$("audio").subscribe(h=>{this.componentConfigSignal.update(_=>(_=T(I({},_),{mediaState:T(I({},_.mediaState),{audio:{enabled:h!=="denied"}})}),_))}),this.subscriptions.push(this.recorderService.getRecordingCountdownEnabled$().subscribe(h=>{this.recordingCountdownEnabled=h})),p&&(p.type&&this.componentConfigSignal.update(h=>(h=T(I({},h),{type:p.type}),h)),p.recordingCountdown!==void 0&&(this.recordingCountdownEnabled=!!p.recordingCountdown),p.mediaConfig&&(p.mediaConfig?.audio?.enabled&&!p.mediaConfig?.audio?.deviceId&&(p.mediaConfig.audio.deviceId=this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId),p.mediaConfig?.video?.enabled&&!p.mediaConfig?.video?.deviceId&&(p.mediaConfig.video.deviceId=this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId),p?.darkMode?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark"),this.componentConfigSignal.update(h=>(h=T(I({},h),{shadowDom:p?.shadowDom!==!1,darkMode:p.darkMode||!1}),h)),this.updateMediaConfig(p.mediaConfig)))}catch(h){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent constructor: ",h)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnInit:",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Recording preview steps dialog")}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(i=>{this.componentConfigSignal.update(r=>(r=T(I({},r),{[i]:e[i].currentValue}),r))})}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnChanges: ",i)}}ngAfterViewInit(){try{this.dialogRef.addPanelClass("snippyly-recording-preview-steps-dialog"),this.dialogRef.disableClose=!0}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngAfterViewInit: ",e)}}toggleSettings(e){try{e.stopPropagation(),this.componentConfigSignal.update(i=>(i=T(I({},i),{isSettingsOpen:!i.isSettingsOpen}),i))}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleSettings: ",i)}}toggleAudio(){try{this.componentConfigSignal().mediaConfig.audio||this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:{enabled:!0}})}),r));let e=!this.componentConfigSignal().mediaConfig.audio?.enabled;this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:{enabled:e}})}),r));let i=this.componentConfigSignal().mediaStream?.getAudioTracks()[0];i?i.enabled=e:e&&(this.componentConfigSignal.update(r=>(r=T(I({},r),{mediaConfig:T(I({},r.mediaConfig),{audio:T(I({},r.mediaConfig.audio),{deviceId:this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId})})}),r)),this.updateMediaConfig(this.componentConfigSignal().mediaConfig))}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleAudio: ",e)}}toggleVideo(){try{this.componentConfigSignal.update(e=>(e=I({},e),e.mediaConfig.video||(e.mediaConfig.video={enabled:!0}),e.mediaConfig.video.enabled=!e.mediaConfig.video.enabled,e.mediaConfig.video.deviceId=this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId,e)),this.updateMediaConfig(this.componentConfigSignal().mediaConfig)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent toggleVideo: ",e)}}updateMediaConfig(e){try{this.stopMediaStream(),this.getMediaStream(e)}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent updateMediaConfig: ",i)}}getMediaStream(e){try{if(!navigator.mediaDevices){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ","No media devices");return}if(!navigator.mediaDevices.getUserMedia){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ","No getUserMedia");return}if(e.audio?.enabled||e.video?.enabled){let i={};e.audio?.enabled&&(i.audio={deviceId:e.audio.deviceId}),e.video?.enabled&&(i.video={deviceId:e.video.deviceId}),navigator.mediaDevices.getUserMedia(i).then(r=>{this.componentConfigSignal.update(a=>(a=T(I({},a),{mediaConfig:e,mediaStream:r}),a))}).catch(r=>{this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream catch: ",r)})}else this.componentConfigSignal.update(i=>(i=T(I({},i),{mediaStream:void 0,mediaConfig:e}),i))}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent getMediaStream: ",i)}}stopMediaStream(){try{this.componentConfigSignal.update(e=>(e=I({},e),e.mediaStream?.getTracks().forEach(i=>{i.stop()}),e.mediaStream=void 0,e))}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent stopMediaStream: ",e)}}startCountdown(){return Q(this,null,function*(){try{if(this.componentConfigSignal().type==="screen"){let e=yield navigator.mediaDevices.getDisplayMedia();this.componentConfigSignal.update(i=>(i=I({},i),i.mediaConfig.screen={enabled:!0,stream:e},i)),e?.getTracks().forEach(i=>{i&&(i.onended=()=>{this.cancelCountdown()})})}this.recordingCountdownEnabled?(this.componentConfigSignal.update(e=>(e=T(I({},e),{countdownStarted:!0}),e)),this.countdownInterval=setInterval(()=>{this.componentConfigSignal().countdown>1?this.componentConfigSignal.update(e=>(e=T(I({},e),{countdown:e.countdown-1}),e)):this.closeDialog(this.componentConfigSignal().mediaConfig)},1e3)):this.closeDialog(this.componentConfigSignal().mediaConfig)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent startCountdown: ",e)}})}cancelCountdown(){try{if(this.componentConfigSignal.update(e=>(e=T(I({},e),{countdownStarted:!1,countdown:this.startCountdownFrom}),e)),this.clearInterval(),this.componentConfigSignal().type==="screen"){let e=this.componentConfigSignal().mediaConfig.screen?.stream;e&&e.getTracks().forEach(i=>{i.stop()}),this.componentConfigSignal.update(i=>(i=I({},i),i.mediaConfig.screen=void 0,i))}}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent cancelCountdown: ",e)}}closeDialog(e){return Q(this,null,function*(){try{this.clearInterval(),this.stopMediaStream(),this.dialogRef.close(e)}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent closeDialog: ",i)}})}handleOverlayClick(e){try{this.componentConfigSignal.update(i=>(i=T(I({},i),{isSettingsOpen:!1}),i)),e.stopPropagation()}catch(i){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent handleOverlayClick: ",i)}}clearInterval(){try{this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=void 0)}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent clearInterval: ",e)}}ngOnDestroy(){try{this.clearInterval(),this.stopMediaStream(),this.subscriptions.forEach(e=>{e?.unsubscribe()})}catch(e){this.loggingService.catch("Error in RecordingPreviewStepsDialogComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(i){return new(i||o)(u(y),u(ui),u(Ki),u(Pm),u(Xo),u(k),u(bl,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-recording-preview-steps-dialog"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{darkMode:"darkMode",shadowDom:"shadowDom"},standalone:!1,features:[Xe],decls:1,vars:1,consts:[["recordingPreviewDialogRef",""],[4,"ngIf"],["role","dialog","aria-modal","true",3,"snippylyOverlay","snippylyOverlayZIndex"],[3,"componentConfigSignal",4,"ngIf"],[3,"componentConfigSignal"]],template:function(i,r){i&1&&g(0,ike,5,7,"ng-container",1),i&2&&c("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%]{--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)} .snippyly-recording-preview-steps-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background:transparent;padding:0;margin:0;border-radius:var(--velt-border-radius-lg)}"],changeDetection:0});let n=o;return n})();var ui=(()=>{let o=class o{constructor(e,i,r,a,s,m,p){this.analyticsService=e,this.loggingService=i,this.matDialog=r,this.storageService=a,this.docService=s,this.databaseService=m,this.domService=p,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 Ke,this.recordedRawData$=new Ke,this.recordedData$=new Ke,this.onInitRecording$=new Ce(null),this.onRecordingAttributeRemovedFromBodySubject$=new Ke,this.videoEditor$=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.db=Ii(),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.onInitRecording$.subscribe(h=>{h?this.setRecordingAttributeAtBody():this.removeRecordingAttributeFromBody()}),this.databaseService.getDb().pipe(Fe(h=>!!h),tt(1)).subscribe(h=>{h&&(this.db=h,this.getDocumentPaths())},h=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",h)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;");try{this.docService.getDocumentPaths$().pipe(gn(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(j.ATTRIBUTES.VELT_ONGOING_RECORDING,e.type),e?.isCommentRecording&&document.body.setAttribute(j.ATTRIBUTES.VELT_COMMENT_RECORDING,"true"))}catch(e){this.loggingService.catch("Error in RecorderService setRecordingAttributeAtBody: ",e)}}removeRecordingAttributeFromBody(){try{document.body.removeAttribute(j.ATTRIBUTES.VELT_ONGOING_RECORDING),document.body.removeAttribute(j.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,i,r,a,s,m,p,h){return Q(this,null,function*(){try{let _={};switch(e){case"audio":_.audio={enabled:!0};break;case"video":_.video={enabled:!0},_.audio={enabled:!0};break;case"screen":_.screen={enabled:!0},_.video={enabled:!1},_.audio={enabled:!1};break;default:break}this.matDialog.open(AM,{data:{type:e,mediaConfig:_,darkMode:[!0,!1].includes(a)?a:this.darkMode$.value,shadowDom:s,recordingCountdown:h}}).afterClosed().subscribe(E=>{if(E){let D={};switch(e){case"audio":D.audio={enabled:!0,deviceId:E.audio?.deviceId},D.audio=E.audio;break;case"video":D.video={enabled:!0,deviceId:E.video?.deviceId},D.audio={enabled:!0,deviceId:E.audio?.deviceId},D.video=E.video,D.audio=E.audio;break;case"screen":D.screen={enabled:!0},D.audio=E.audio,D.video=E.video,D.screen=E.screen;break;default:break}this.onInitRecording$.next({type:e,panelId:i,mediaConfig:D,isCommentRecording:r,darkMode:[!0,!1].includes(a)?a:!!this.darkMode$.value,shadowDom:s,commentAnnotationId:m,clientDocumentId:p})}},E=>{this.loggingService.catch("Error in RecorderService initRecording afterClosed: ",E)})}catch(_){this.loggingService.catch("Error in RecorderService initRecording: ",_)}})}startRecording(e,i){return Q(this,null,function*(){try{this.loggingService.log("[startRecording] Starting with config:",e,"mediaConfig:",i);let r=new MediaStream,a=yield this.getBrowserSpecificOptions();return yield this.collectMediaTracks(r,e,i),yield this.initializeMediaRecorder(r,a),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},i=this.getSupportedMimeTypes();if(i.length>0){let r=i.find(a=>a.includes("mp4")&&a.includes("h264"))||i.find(a=>a.includes("mp4"))||i[0];e.mimeType=r}return e}catch(e){return this.loggingService.catch("Error in RecorderService getBrowserSpecificOptions: ",e),{}}})}collectMediaTracks(e,i,r){return Q(this,null,function*(){try{if(i.type.screen&&r?.screen?.stream){let a=this.getCommonVideoQualityConstraints(!0);r.screen.stream.getTracks().forEach(s=>{e.addTrack(s),s.onended=()=>this.stopRecording(),s.applyConstraints(I({},a))})}if(i?.type.audio||i?.type.video){let a=this.buildMediaConstraints(i,r),s=yield navigator.mediaDevices.getUserMedia(a);if(s)if(this.isSafari()){if(i?.type.audio&&(yield this.adjustSafariAudioTrack(e,s)),i?.type.video){let m=s.getVideoTracks();if(m.length>0){let p=m[0];p.enabled=!0;let h=p.clone();e.addTrack(h),r&&r.video&&(r.video.track=p)}}}else s.getTracks().forEach(m=>e.addTrack(m))}}catch(a){this.loggingService.catch("Error in RecorderService collectMediaTracks: ",a);return}})}buildMediaConstraints(e,i){try{let r=this.getCommonVideoQualityConstraints(!!e.type.video);return{audio:this.getCommonAudioConstraints(!!e.type.audio,i),video:e.type.video?T(I({deviceId:i?.video?.deviceId?{ideal:i.video.deviceId}:void 0},r),{facingMode:"user"}):!1}}catch(r){return this.loggingService.catch("Error in RecorderService buildMediaConstraints: ",r),{}}}getCommonAudioConstraints(e,i){try{if(!e)return!1;let r=this.recordingQualityConstraints.value[this.isSafari()?"safari":"other"]?.audio||{};return I({deviceId:i?.audio?.deviceId?{ideal:i.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(i){return this.loggingService.catch("Error in RecorderService getCommonVideoQualityConstraints: ",i),{}}}adjustSafariAudioTrack(e,i){return Q(this,null,function*(){try{let r=i.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}})}initializeMediaRecorder(e,i){return Q(this,null,function*(){try{this.mediaRecorder=new MediaRecorder(e,i),this.chunks=[],this.chunkUrls$.next({}),this.uploadPromises=[];let r=0;if(this.isSafari()){let s=e.getVideoTracks();s.length>0&&s.forEach(m=>{m.contentHint="detail",m.enabled=!0})}this.mediaRecorder.addEventListener("dataavailable",s=>{if(s.data?.size>0){let m=r++;this.chunks.push(s.data);let p=`recording_${new Date().getTime()}_${Math.random().toString(36).substring(2,9)}`,h=s.data,_=this.uploadChunk(h,p,m);this.uploadPromises||(this.uploadPromises=[]),this.uploadPromises.push({promise:_,index:m}),_.then(E=>{this.chunkUrls$.next(T(I({},this.chunkUrls$.value),{[m]:E}))}).catch(E=>{console.error("Chunk upload failed",E)})}}),this.mediaRecorder.addEventListener("stop",()=>this.onStopRecording()),this.mediaRecorder.start(4e3)}catch(r){this.loggingService.catch("Error in RecorderService initializeMediaRecorder: ",r);return}})}uploadChunk(e,i,r){return Q(this,null,function*(){try{let a="video/mp4",m=`chunk_${r}_${new Date().getTime()}.mp4`,p=new File([e],m,{type:a});return yield this.uploadChunkToStorage(p,i,r)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunk: ",a),a}})}uploadChunkToStorage(e,i,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,m=`${j.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${j.FIREBASE_PARTIAL_PATH_RECORDER}/${i}`;return a&&(m=`${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${a}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${j.FIREBASE_PARTIAL_PATH_RECORDER}/${i}`),this.storageService.uploadChunk(m,e,r)}catch(a){throw this.loggingService.catch("Error in RecorderService uploadChunkToStorage: ",a),a}}setupRecorderData(e,i){try{return this.recorderInitData=new pM,this.recorderStatusSubject$.next("started"),this.isSafari()&&e.type.video&&i.getVideoTracks().forEach(r=>{r.enabled=!0}),this.recorderInitData.stream=i,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.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(i){return this.loggingService.catch("Error in RecorderService determineRecorderType: ",i),"audio"}}timeout(e){return new Promise(i=>setTimeout(i,e))}pauseRecording(){try{this.recorderStatusSubject$.next("paused"),this.mediaRecorder.pause(),this.recordingDurations?.length&&(this.recordingDurations[this.recordingDurations.length-1].end=new Date().getTime()),this.stopTimer()}catch(e){this.loggingService.catch("Error in RecorderService pauseRecording: ",e)}}resumeRecording(){try{this.recorderStatusSubject$.next("resumed"),this.mediaRecorder.resume(),this.recordingDurations.push({start:new Date().getTime()}),this.startTimer()}catch(e){this.loggingService.catch("Error in RecorderService resumeRecording: ",e)}}stopRecording(){try{this.mediaRecorder?.state!=="inactive"?(this.mediaRecorder.stop(),this.removeRecordingAttributeFromBody()):this.clearRecording()}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(i=>{i.stop()}),yield this.timeout(100);let e=new gM;if(this.chunks.length>0){let i=this.recorderInitData?.type==="audio"?"audio/mp4":"video/mp4";this.loggingService.log("[onStopRecording] Creating blob with type:",i),e.blob=new Blob(this.chunks,{type:i}),this.loggingService.log("[onStopRecording] Blob created, size:",e.blob.size);try{let r=yield this.getVideoDuration(e.blob);if(r){let a={};a.duration=r*1e3,a.display=this.convertMillisecondsToTime(r*1e3),this.recorderDurationSubject$.next(a),e.recordedTime=a}}catch(r){this.recorderInitData&&this.loggingService.catch("Error in RecorderService onStopRecording getVideoDuration: ",r)}if(e.blob.size===0)throw new Error("Recorded blob has zero size");if(e.url=URL.createObjectURL(e.blob),e.type=this.recorderInitData?.type,e.recordedTime=this.recorderDurationSubject$.value,e?.type!=="audio")try{yield this.timeout(200);let r=yield qoe(e.blob,3);r&&(e.thumbnail=yield Yoe(r))}catch(r){this.recorderInitData&&this.loggingService.catch("Error in RecorderService onStopRecording getVideoCover: ",r)}this.recordedRawData$.next(e)}else throw new Error("No data chunks recorded")}catch(e){this.loggingService.catch("Error in RecorderService onStopRecording: ",e),this.recordedRawData$.error(e)}})}clearRecording(){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling RecorderService FUNCTION: clearRecording","color: green;"),this.recorderStatusSubject$.next(null),this.recorderDurationSubject$.next(null),this.onInitRecording$.next(null),this.recordingDurations=[],this.domService.resetRecordingInProgress(),this.mediaRecorder=null,this.recorderInitData?.stream?.getTracks()?.forEach(e=>{e.stop()}),this.recorderInitData=null,this.recorderInitData$.next(null),this.chunks=[],this.chunkUrls$.next({}),this.stopTimer()}catch(e){this.loggingService.catch("Error in RecorderService clearRecording: ",e)}})}startTimer(){try{this.stopTimer(),this.durationInterval=setInterval(()=>{this.calculateRecordedTime()},1e3)}catch(e){this.loggingService.catch("Error in RecorderService startTimer: ",e)}}stopTimer(){try{this.durationInterval&&clearInterval(this.durationInterval)}catch(e){this.loggingService.catch("Error in RecorderService stopTimer: ",e)}}calculateRecordedTime(){try{if(this?.recordingDurations?.length){let e=0;this.recordingDurations.forEach(i=>{i.end?e+=i?.end-i.start:e+=new Date().getTime()-i.start;let r={};r.duration=e,r.display=this.convertMillisecondsToTime(e),this.recorderDurationSubject$.next(r)})}else this.recorderDurationSubject$.next(null)}catch(e){this.loggingService.catch("Error in RecorderService calculateRecordedTime: ",e)}}convertMillisecondsToTime(e){try{let i=Math.floor(e/1e3),r=Math.floor(i/60),a=Math.floor(r/60);return i=i%60,r=r%60,`${a?a.toString().padStart(2,"0")+":":""}${r.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}catch(i){return this.loggingService.catch("Error in RecorderService convertMillisecondsToTime: ",i),""}}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}}getSupportedMimeTypes(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getSupportedMimeTypes","color: green;"),["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"].filter(i=>MediaRecorder.isTypeSupported(i))}catch(e){return this.loggingService.catch("Error in RecorderService getSupportedMimeTypes: ",e),[]}}enableVideoEditor(){try{if(this.videoEditor$.value===!0)return;this.videoEditor$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableVideoEditor: ",e)}}disableVideoEditor(){try{if(this.videoEditor$.value===!1)return;this.videoEditor$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableVideoEditor: ",e)}}getVideoEditor$(){return this.videoEditor$.asObservable()}getVideoEditor(){return this.videoEditor$.value}waitForChunksUpload(){return Q(this,null,function*(){try{if(this.uploadPromises.length===0)return{};let e=this.uploadPromises.map(i=>i.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(i){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",i)}}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 i=this.recordingQualityConstraints.value;i={other:{audio:I(I({},i.other?.audio),e.other?.audio),video:I(I({},i.other?.video),e.other?.video)},safari:{audio:I(I({},i.safari?.audio),e.safari?.audio),video:I(I({},i.safari?.video),e.safari?.video)}},this.recordingQualityConstraints.next(i)}catch(i){this.loggingService.catch("Error in RecorderService setRecordingQualityConstraints: ",i)}}setRecordingEncodingOptions(e){try{let i=this.recordingEncodingOptions.value;i={other:I(I({},i.other),e.other),safari:I(I({},i.safari),e.safari)},this.recordingEncodingOptions.next(i)}catch(i){this.loggingService.catch("Error in RecorderService setRecordingEncodingOptions: ",i)}}getVideoDuration(e){return Q(this,null,function*(){return new Promise((i,r)=>{try{let a=URL.createObjectURL(e),s=document.createElement("video");s.onloadedmetadata=()=>{let m=s.duration;URL.revokeObjectURL(a),i(m)},s.onerror=m=>{URL.revokeObjectURL(a),r(m)},s.src=a,s.load()}catch(a){this.loggingService.catch("Error in RecorderService getVideoDuration: ",a),r(a)}})})}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(y),J(Ki),J(Kp),J(lt),J(hn),J(Ne))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var es=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_){this.afAuth=e,this.authService=i,this.configService=r,this.databaseService=a,this.docService=s,this.commonDbService=m,this.iamService=p,this.loggingService=h,this.notificationService=_,this.documentPaths=null,this.db=Ii(),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(Fe(E=>!!E),tt(1)).subscribe(E=>{E&&(this.db=E,this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(D=>{this.notificationService.setNotificationViews(D)}),this.authService.getUser$().pipe(Fe(D=>!!D),he(D=>this.documentViewsEnabled$.pipe(Fe(L=>L),ce(()=>D))),he(D=>this.docService.getDocumentPaths$().pipe(qo(null),Pi(),ce(([L,H])=>(L?.documentId!==H?.documentId&&this.views$.next({}),H)),ce(L=>(this.documentPaths=L,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:D,_documentPaths:L})),he(L=>this.docService.getDocumentIds$().pipe(he(H=>(H?.length&&(H.find(K=>K.documentId===this.documentPaths?.documentId)||H.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),H.forEach(K=>{this.setDocumentAsRead({documentId:K.documentId,clientDocumentId:K.clientDocumentId})})),se(L))))))),he(D=>this.docService.getDocumentMetadata$().pipe(Fe(L=>!!L),ce(L=>T(I({},D),{_documentMetadata:L}))))).subscribe(),this.authService.getUser$().pipe(Fe(D=>!!D),he(D=>this.documentViewsEnabled$.pipe(Fe(L=>L),ce(()=>D))),he(D=>this.docService.getLocation$().pipe(Fe(L=>!!L))),he(D=>this.docService.getDocumentIds$().pipe(he(L=>(L.find(H=>H.documentId===this.documentPaths?.documentId)||L.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),L.forEach(H=>{this.setLocationAsRead({documentId:H.documentId,clientDocumentId:H.clientDocumentId})}),se(D)))))).subscribe())},E=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",E)})}catch(E){this.loggingService.catch("Error in ViewsService constructor: ",E)}}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,i){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let r,a;try{if(e&&(a=yn(e)),i&&typeof i=="object"){let s=Jo(i);r=yn(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return qn(this.afAuth).pipe(Fe(s=>!!s),he(s=>this.isFeatureAllowed({firebaseUser:s})),he(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(m=>(s.featureAllowed=m,s))):se(s)),he(s=>s.featureAllowed?se(s).pipe(he(m=>this.docService.getDocumentPaths$().pipe(ce(p=>(this.documentPaths=p,m.documentPaths=p,m)))),he(m=>a?this.getDataFromDocumentIds([a]):this.docService.getDocumentIds$().pipe(he(p=>{let h=p?.length>0?p.map(_=>_.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(h)})))):se([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>i.user?se(T(I({},i),{featureAllowed:!0})):se(T(I({},i),{featureAllowed:!1}))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getCommentViewsById(e){try{return this.commentViews$.value?.[e]?this.commentViews$.value?.[e]:void 0}catch(i){this.loggingService.catch("Error in ViewsService getCommentViewsById: ",i);return}}getDocumentViewsById(e){try{return this.documentViews$.value?.[e]}catch(i){this.loggingService.catch("Error in ViewsService getDocumentViewsById: ",i);return}}getLocationViewsById(e){try{return this.locationViews$.value?.[e]}catch(i){this.loggingService.catch("Error in ViewsService getLocationViewsById: ",i);return}}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i,filters:r}=e;return i?.some(a=>!a)||!this.documentPaths?se([]):this.documentViewsEnabled$.pipe(he(a=>a?Rn([this.getCommentViewsDataFromDocuments(i),this.getDocumentViewsDataFromDocuments(i),this.getLocationViewsDataFromDocuments(i)]):Rn([this.getCommentViewsDataFromDocuments(i)])))}else return se(null)}getCommentViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.commentViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.commentViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,commentViews:E})})}))}getDocumentViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allDocumentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.documentViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.documentViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,documentViews:E})})}))}getLocationViewsDataFromDocuments(e){let i=this.docService.getDocumentPaths()?.veltFolderId,r=this.docService.getDocumentPaths()?.allDocuments,a=se([]),s={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(s.documentId=e?.length?e[0]:void 0,s.organizationId=this.documentPaths?.organizationId),i&&r)a=this.commonDbService.dbListener({feature:"allLocationViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",i),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let m=[];for(let p=0;p<(e?.length??0);p+=j.LISTENER_BATCH_SIZE)m.push(e?.slice(p,p+j.LISTENER_BATCH_SIZE)??[]);a=Rn(m.map(p=>this.commonDbService.dbListener({feature:"allLocationViews",properties:T(I({},s),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",p),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...i?[gt("metadata.veltFolderId","==",i)]:[])]})}).pipe(Gr()))).pipe(ce(p=>ua(p)))}return a.pipe(ce(m=>({data:m?.data,operation:m?.operation})),ce(({data:m,operation:p})=>{let h={};return e?(Object.entries(m??{}).forEach(([_,E])=>{let D=E.metadata?.documentId;D&&(h[D]||(h[D]={}),h[D][_]=E)}),{data:m,documentMap:h,operation:p}):{data:m,documentMap:h,operation:p}}),ce(({data:m,documentMap:p,operation:h})=>{if(h?.type==="removed"){if(h?.ids?.length){let _=this.locationViews$.value;h?.ids?.forEach(E=>{delete _?.[E]}),this.locationViews$.next(_)}}else Object.entries(p??{}).forEach(([_,E])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:_,locationViews:E})})}))}setViewsData(e){try{this.views$.next(I(I({},this.views$.getValue()),e||{}))}catch(i){this.loggingService.catch("Error in ViewsService setViewsData:",i)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,commentViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.commentViews$.value),r);this.commentViews$.next(s),this.commentViewsByOrganizationIdAndDocumentId$.next(T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[i]:T(I({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,documentViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.documentViews$.value),r);this.documentViews$.next(s),this.documentViewsByOrganizationIdAndDocumentId$.next(T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[i]:T(I({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,locationViews:r,queryHash:a}){try{if(r||(r={}),i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s=I(I({},this.locationViews$.value),r);this.locationViews$.next(s),this.locationViewsByOrganizationIdAndLocationId$.next(T(I({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:T(I({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[i]:T(I({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[i]),{[a]:r})})}))}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentFeatureViews$(){return this.commentViews$.pipe(qt((e,i)=>JSON.stringify(e||{})===JSON.stringify(i||{})))}setCommentAnnotationAsRead(e){return Q(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){let r=this.getCommentViewsById(e.annotationId)??(yield this.commonDbService?.getData({feature:"commentViews",properties:{id:e.annotationId,documentId:e.metadata?.documentId??this.documentPaths?.documentId??"",organizationId:e?.metadata?.organizationId??this.documentPaths?.organizationId??""}})),a=this.updateCommentAnnotationViews(e,r||{});this.commonDbService.setData({feature:"commentViews",properties:{id:e.annotationId,documentId:e.metadata?.documentId??this.documentPaths?.documentId??"",organizationId:e?.metadata?.organizationId??this.documentPaths?.organizationId??""},data:a})}}catch(i){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",i)}})}updateCommentAnnotationViews(e,i){try{let r=this.authService.getUser(),a={views:{},comments:{}};if(r){let s={},m=i?.comments||{},p=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(_=>{m[_.commentId]||(m[_.commentId]={views:{}}),m[_.commentId].views||(m[_.commentId].views={}),m[_.commentId].views[r.userSnippylyId]||(m[_.commentId].views[r.userSnippylyId]={},m[_.commentId].views[r.userSnippylyId].timestamp=p)});let h=new Set(e.comments?.map(_=>_.commentId+""));if(Object.keys(m??{}).forEach(_=>{h.has(_)||delete m[_]}),e.comments?.length){let _=m[e.comments[0].commentId]?.views||{};Object.keys(_??{}).filter(D=>e.comments?.every(L=>m[L.commentId]?.views?.[D])).forEach(D=>{s[D]={timestamp:_[D].timestamp}})}a.views=s,a.comments=m}return e?.metadata?a.metadata=e.metadata:a.metadata=this.docService.getBaseMetadata(),a}catch(r){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",r),{views:{},comments:{}}}}deleteCommentAnnotationViews(a,s){return Q(this,arguments,function*(e,{documentId:i,organizationId:r}){try{yield this.commonDbService.deleteData({feature:"commentViews",properties:{id:e.annotationId,documentId:i,organizationId:r}})}catch(m){this.loggingService.catch("Error in ViewsService deleteCommentAnnotationViews:",m)}})}getNotificationFeatureViews$(){return this.views$.pipe(qt((e,i)=>JSON.stringify(e?.notification||{})===JSON.stringify(i?.notification||{})))}setNotificationsAsRead(e){try{let i=this.authService.getUser();if(i){let r=new Date().getTime()+this.commonDbService.getOffset();e.forEach(a=>{this.commonDbService.updateData({feature:"notificationViewsTimestamp",properties:{id:a,user:i.userSnippylyId,documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??""},data:{timestamp:r}})})}}catch(i){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",i)}}getDocumentViews$(){return this.views$.pipe(qt((e,i)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(i?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(he(i=>(this.documentPaths=i,e?this.locationViews$.pipe(ce(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.users||{}:{}})):this.documentViews$.pipe(ce(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.users||{}:{}})))),qt(Vi))}catch(i){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",i),se({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(he(i=>(this.documentPaths=i,e?this.locationViews$.pipe(ce(r=>{let a=Object.keys(r||{}).find(s=>r?.[s]?.location?.id===e);return a?r?.[a]?.day||{}:{}})):this.documentViews$.pipe(ce(r=>{let a=this.documentPaths?.documentId;return a?r?.[a]?.day||{}:{}})))))}catch(i){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",i),se({})}}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:i}){try{let a=this.authService.getUser();if(a&&e){if(this.documentViewsSetByDocumentId[e])return;this.documentViewsSetByDocumentId[e]=!0;let s=new Date().getTime()+this.commonDbService.getOffset(),m=new Date().toISOString().split("T")[0],p=this.getDocumentViewsById(e);if(p){let h=new Date().toISOString().split("T")[0];p?.users[a.userSnippylyId]||(p.users[a.userSnippylyId]={}),p.users[a.userSnippylyId][h]={timestamp:this.timestamp},p?.day[h]||(p.day[h]={}),p.day[h][a.userSnippylyId]={timestamp:this.timestamp},p.metadata=this.docService.getBaseMetadata("documentViews",{clientDocumentId:i}),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:h,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??""},data:p})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:m,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:m,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:i})}),this.docService.getDocumentMetadata$(e).pipe(Fe(h=>h!==null),tt(1)).subscribe(()=>{let h={day:{[m]:{[a.userSnippylyId]:{timestamp:s}}},users:{[a.userSnippylyId]:{[m]:{timestamp:s}}},metadata:this.docService.getBaseMetadata("documentViews",{clientDocumentId:i})};this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:m,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0},data:h})});this.checkAndTriggerNotification(a)}}catch(a){this.loggingService.catch("Error in ViewsService setDocumentAsRead:",a)}})}checkAndTriggerNotification(e){try{this.getUniqueViewsByUser().pipe(tt(1)).subscribe(i=>{if(Object.keys(i??{}).length===2){let r=this.docService.getDocumentMetadata();if(r?.creator?.email&&r?.creator?.email!==e.email){let a=[r.creator.email];this.updateNotificationsDatabase(vU.FIRST_VIEWED,{documentViews:{emails:a}})}}})}catch(i){this.loggingService.catch("Error in checkAndTriggerNotification:",i)}}setLocationAsRead(r){return Q(this,arguments,function*({documentId:e,clientDocumentId:i}){try{let a=this.authService.getUser(),s=this.docService.getLocation(),m=s?.locationId,p=s?.location;if(a&&m&&p){let h=new Date().getTime()+this.commonDbService.getOffset(),_=new Date().toISOString().split("T")[0],E=this.getLocationViewsById(m);if(E){let D=new Date().toISOString().split("T")[0];E?.users[a.userSnippylyId]||(E.users[a.userSnippylyId]={}),E.users[a.userSnippylyId][D]={timestamp:this.timestamp},E?.day[D]||(E.day[D]={}),E.day[D][a.userSnippylyId]={timestamp:this.timestamp},E.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:i}),this.commonDbService.updateData({feature:"location",data:E,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:p,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:m,user:a.userSnippylyId,date:_,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:h}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:m,date:_,user:a.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:h}}),this.commonDbService.updateData({feature:"locationMetadataViews",properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("locationViews",{clientDocumentId:i})});let D={day:{[_]:{[a.userSnippylyId]:{timestamp:h}}},users:{[a.userSnippylyId]:{[_]:{timestamp:h}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:i}),location:p};this.commonDbService.updateData({feature:"location",data:D,properties:{id:m,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0}})}}}catch(a){this.loggingService.catch("Error in ViewsService setLocationAsRead:",a)}})}updateNotificationsDatabase(e,i={}){try{let r=I({actionType:e,notificationSource:"documentViews"},i);this.notificationService.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",r)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(He),J(jt),J(hn),J(lt),J(Tn),J(fn),J(y),J(vn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Mm=(()=>{let o=class o{constructor(e,i,r){this.docService=e,this.loggingService=i,this.authService=r;try{this.loggingService.log("%c[WB] Creating CLASS: MetadataService","color: blue;")}catch(a){this.loggingService.catch("Error in MetadataService constructor: ",a)}}getGlobalMetadata(){return Q(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),{};let i=this.docService.getOrganizationMetadata(this.docService.getOrganizationConfig()?.organizationId),r=this.docService.getDocumentMetadataOfAvailableDocuments(),a=this.docService.getLocation();i&&(i=JSON.parse(JSON.stringify(i)),delete i?.organizationId,i.organizationId=i?.clientOrganizationId,delete i?.clientOrganizationId,delete i?.pageInfo),r&&(r=JSON.parse(JSON.stringify(r)),r.forEach(_=>{delete _?.locations,delete _?.location,delete _?.locationId,delete _?.pageInfo,delete _?.documentId,_.documentId=_?.clientDocumentId,delete _?.clientDocumentId,delete _?.veltFolderId,_?.clientOrganizationId&&(_.organizationId=_?.clientOrganizationId,delete _?.clientOrganizationId)}));let s=[];a&&(a=JSON.parse(JSON.stringify(a)),a?.location&&s.push(a?.location));let m=this.docService.getLocations();m&&Object.values(m).forEach(_=>{_?.location&&s.push(_?.location)});let p=this.docService.getDocumentPaths()?.folderId;return{organization:i,documents:r,locations:s,folderId:p}}catch(e){return this.loggingService.catch("Error in MetadataService getGlobalMetadata: ",e),{}}})}};o.\u0275fac=function(i){return new(i||o)(J(lt),J(y),J(He))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var o0=(()=>{let o=class o{constructor(e,i,r){this.coreActionsService=e,this.loggingService=i,this.metadataService=r,this.buttonClickSubject$=new Ke,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(s){return Q(this,arguments,function*({id:e,type:i,groupId:r,contextData:a}){try{this.buttonToggle(e,void 0,i,r);let m=this.extractButtonData(a),p=this.createButtonContext(e,i,r),h=yield this.metadataService.getGlobalMetadata(),_=T(I({buttonContext:p},m),{metadata:h});this.buttonClickSubject$.next(_),this.coreActionsService.triggerAction(Xi.VELT_BUTTON_CLICK,_)}catch(m){this.loggingService.catch("Error in ButtonService buttonClick: ",m)}})}buttonActive({id:e,type:i,groupId:r,contextData:a}){try{let s=this.buttonToggleMap$.value?.[r||"ungrouped"]?.[e]||!0;this.buttonToggle(e,s,i,r)}catch(s){this.loggingService.catch("Error in ButtonService buttonClick: ",s)}}buttonToggle(e,i,r,a){try{let s=this.buttonToggleMap$.value,m=this.createNewToggleMap(s,e,i,r,a);this.buttonToggleMap$.next(m)}catch(s){this.loggingService.catch("Error in ButtonService buttonToggle: ",s)}}extractButtonData(e){try{let i={};return Object.entries(this.contextDataMapping).forEach(([r,a])=>{let s=this.getNestedValue(e,a.source);s!==void 0&&(i[a.target]=s)}),i}catch(i){return this.loggingService.catch("Error in ButtonService extractContextData: ",i),{}}}getNestedValue(e,i){try{let r=e;for(let a of i){if(r?.[a]===void 0)return;Fi(r[a])?r=r[a]():r=r[a]}return r}catch(r){this.loggingService.catch("Error in ButtonService getNestedValue: ",r);return}}createButtonContext(e,i,r){try{let a={type:i,selections:this.buttonToggleMap$.value,clickedButtonId:e};return(i==="single-select"||i==="multi-select")&&r?T(I({},a),{groupId:r}):a}catch(a){return this.loggingService.catch("Error in ButtonService createButtonMetadata: ",a),{}}}createNewToggleMap(e,i,r,a,s){try{let m=I({},e);return a==="button-toggle"?T(I({},m),{ungrouped:T(I({},m.ungrouped),{[i]:r??!m.ungrouped?.[i]})}):a==="single-select"&&s?T(I({},m),{[s]:{[i]:r??!0}}):a==="multi-select"&&s?T(I({},m),{[s]:T(I({},m[s]),{[i]:r??!m[s]?.[i]})}):m}catch(m){return this.loggingService.catch("Error in ButtonService createNewToggleMap: ",m),{}}}buttonClickSubject(){return this.buttonClickSubject$.asObservable()}buttonToggleMap(){return this.buttonToggleMap$.asObservable()}resetVeltButtonState(e){return Q(this,null,function*(){try{if(e){let{id:s,group:m}=e,p=JSON.parse(JSON.stringify(this.buttonToggleMap$.value||{}));m&&s?delete p?.[m]?.[s]:m?delete p?.[m]:s&&Object.keys(p).forEach(h=>{Object.keys(p[h]).forEach(_=>{_===s&&delete p?.[h]?.[_]})}),this.buttonToggleMap$.next(p)}else this.buttonToggleMap$.next({});let i={selections:this.buttonToggleMap$.value},r=yield this.metadataService.getGlobalMetadata(),a={buttonContext:i,metadata:r};this.coreActionsService.triggerAction(Xi.VELT_BUTTON_CLICK,a)}catch(i){this.loggingService.catch("Error in ButtonService resetVeltButtonState: ",i)}})}buttonToggleMapValue(){return this.buttonToggleMap$.value}};o.\u0275fac=function(i){return new(i||o)(J(wm),J(y),J(Mm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var we=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L,H,K,oe,ue,be,Le,qe,Re,_e,Ee,Oe,ye,fe,Be){this.analyticsService=e,this.areaService=i,this.commonDbService=r,this.configService=a,this.docService=s,this.databaseService=m,this.authService=p,this.domService=h,this.afAuth=_,this.avatarService=E,this.contactService=D,this.storageService=L,this.functions=H,this.dialog=K,this.iamService=oe,this.loggingService=ue,this.notificationService=be,this.customFilterService=Le,this.reactionService=qe,this.hotkeyService=Re,this.recorderService=_e,this.viewsService=Ee,this.buttonService=Oe,this.metadataService=ye,this.commonDbUtilsService=fe,this.attachmentResolverService=Be,this.customPinsById=new Map,this.commentAdded$=new Ke,this.commentUpdated$=new Ke,this.commentAccepted$=new Ke,this.commentRejected$=new Ke,this.commentAnnotationDeleted$=new Ke,this.multiThreadCommentAnnotationDeleted$=new Ke,this.commentAnnotationById$=new Ce(null),this.multiThreadCommentAnnotationById$=new Ce(null),this.ghostCommentAnnotationMap$=new Ce({}),this.unreadCommentsMap$=new Ce(null),this.documentPaths=null,this.db=Ii(),this.user=null,this.customCategoryMap=j.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 Ke,this.onUpgradeClick$=new Ke,this.enableAttachment$=new Ce(!0),this.enableReactions$=new Ce(!0),this.allowedRecordings$=new Ce(["audio","video","screen"]),this.openSidebar$=new Ke,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(B6.DEFAULT),this.sidebarButtonOnCommentDialogVisible$=new Ce(!1),this.sidebarButtonOnCommentDialogClick$=new Ke,this.commentNavigationButtonClick$=new Ke,this.deviceIndicatorOnCommentPins$=new Ce(!1),this.sidebarCommentClick$=new Ke,this.privateCommentMode$=new Ce(!1),this.scrollToComment$=new Ce(!0),this.userMentions$=new Ce(!0),this.deleteOnBackspace$=new Ce(!0),this.hotkeyEnabled$=new Ce(!1),this.recordingSummaryEnabled$=new Ce(!0),this.unreadIndicatorMode$=new Ce(Vu.MINIMAL),this.composerMode$=new Ce(Uu.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.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.svgAsImg$=new Ce(!1),this.commentToNearestAllowedElement$=new Ce(!1),this.filterCommentsOnDom$=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 Ke,this.commentsFromSidebarMap$=new Ce(null),this.commentSidebarFilters$=new Ce({}),this.commentSidebarSystemFiltersOperator$=new Ce(hc.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.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.loggingService.log("%c[WB] Creating CLASS: CommentService","color: blue;"),this.analyticsService.setCommentService(this),this.notificationService.setCommentService(this),this.docService.setCommentService(this),this.authService.setCommentService(this),this.docService.getDocumentPaths$().pipe(Pi()).subscribe(([xe,wn])=>{xe?.documentId!==wn?.documentId&&this.unreadCommentsMap$.next(null)},xe=>{this.loggingService.catch("Error in CommentService getDocumentPaths$ subscription: ",xe)}),this.authService.getUser$().subscribe(xe=>{xe||this.resetCacheData()},xe=>{this.loggingService.catch("Error in CommentService getUser$ subscription: ",xe)}),this.databaseService.getDb().pipe(Fe(xe=>!!xe),tt(1)).subscribe(xe=>{xe&&(this.db=xe,this.getDocumentPaths())},xe=>{this.loggingService.catch("Error in CommentService getDb subscription: ",xe)}),this.domService.onWindowPointerMove$().subscribe(xe=>{if(this.addCommentMode$.value){let wn=!0;if(this.addCommentDragMode)this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{let $t=this.domService.getBackgroundElement(xe.clientX,xe.clientY,!0,!0);if($t)if(this.isElementInsideAllowedElements($t))if(wd(xe.target))this.domService.removeClassFromElement(document.body,"show-pin-cursor");else{this.domService.addClassToElement(document.body,"show-pin-cursor"),this.hightlightElement&&this.hightlightElement!==$t&&this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=$t;let ft=this.domService.getSelectedAnnotationsMap("comment")||{},Ot=this.commentPinCursorImage$.value||j.CURSOR.COMMENT_PIN;this.domService.highlightElement(this.hightlightElement,Ot,!!Object.keys(ft)?.length),wn=!1}else this.domService.removeClassFromElement(document.body,"show-pin-cursor")}this.hightlightElement&&wn&&(this.domService.removeHighlightFromElement(this.hightlightElement),this.hightlightElement=null)}},xe=>{this.loggingService.catch("Error in CommentService onWindowPointerMove$ subscription: ",xe)}),this.domService.onWindowKeyupEsc$().subscribe(xe=>{if(this.addCommentMode$.value){let wn=this.domService.getSelectedAnnotationsMap("comment")||{};Object.keys(wn)?.length?this.domService.resetSelectedAnnotationsMap():this.disableAddCommentMode()}},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupEsc$ subscription: ",xe)}),this.domService.onDocumentClick$().subscribe(xe=>{if(xe?.target&&!zi(xe?.target)){let wn=this.domService.getSelectedAnnotationsMap("comment")||{};if(wn=I(I({},wn),this.domService.getSelectedAnnotationsMap("multiThread")||{}),Object.keys(wn)?.length&&(this.domService.resetSelectedAnnotationsMap(),this.persistentCommentMode$?.value)){this.addCommentMode$.value&&this.detectToAddAreaComment(),xe.preventDefault(),xe.stopPropagation();return}}if(xe&&this.addCommentMode$.value&&!wd(xe.target)){let wn=!1;if(this.addCommentDragMode)xe.preventDefault(),xe.stopPropagation(),this.addCommentDragMode=!1;else if(!this.domService.getDraftCommentAnnotationDialogs()?.length){let $t=this.domService.getBackgroundElement(xe.clientX,xe.clientY);(this.persistentCommentMode$?.value&&this.domService.getBackgroundVeltElement(xe.clientX,xe.clientY)||xe?.target&&zi(xe?.target))&&($t=null),$t&&(this.isElementInsideAllowedElements($t)||this.getCommentToNearestAllowedElement()&&this.getNearestAllowedElement($t))&&(wn=this.isElementInsideManualCommentContainer($t),wn||(xe.preventDefault(),xe.stopPropagation(),this.addComment(xe)))}this.persistentCommentMode$?.value?this.detectToAddAreaComment():wn||this.disableAddCommentMode()}},xe=>{this.loggingService.catch("Error in CommentService onDocumentClick$ subscription: ",xe)}),this.addCommentMode$.subscribe(xe=>{this.hightlightElement&&this.domService.removeHighlightFromElement(this.hightlightElement),xe?(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(wn=>wn.unsubscribe()))},xe=>{this.loggingService.catch("Error in CommentService addCommentMode$ subscription: ",xe)}),this.domService.onWindowKeyupBackspace$().subscribe(xe=>{this.getDeleteOnBackspace()&&this.deleteCommentPinAnnotations("keyupBackspace")},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupBackspace$ subscription: ",xe)}),this.domService.onWindowKeyupDelete$().subscribe(xe=>{this.deleteCommentPinAnnotations("keyupDelete")},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",xe)}),this.domService.getDeleteCommmentAnnotations$().subscribe(xe=>{xe?.length&&(xe?.filter($t=>!["tag","recorder","rewriter","arrow","area","multiThread"].includes($t.type))).forEach($t=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation($t)}))},xe=>{this.loggingService.catch("Error in CommentService onWindowKeyupDelete$ subscription: ",xe)}),this.getPopoverMode$().subscribe(xe=>{xe?document?.body?.setAttribute(j.ATTRIBUTES.VELT_POPOVER_MODE,"true"):document?.body?.removeAttribute(j.ATTRIBUTES.VELT_POPOVER_MODE)},xe=>{this.loggingService.catch("Error in CommentService getPopoverMode subscription: ",xe)}),this.customFilterService.customCategoryMap$.subscribe(xe=>{this.customCategoryMap=xe},xe=>{this.loggingService.catch("Error in CommentService customCategoryMap$ subscription: ",xe)}),this.hotkeyEnabled$.subscribe(xe=>{xe?this.subscribeHotkeyEvents():this.unsubscribeHotkeyEvents()},xe=>{this.loggingService.catch("Error in CommentService hotkeyEnabled$ subscription: ",xe)}),this.domService.getSelectedAnnotationsMap$().pipe(Pi()).subscribe(([xe,wn])=>{try{let $t=Object.values(xe||{}).filter(Ot=>!["tag","recorder","rewriter","arrow","area"].includes(Ot.type)),ft=Object.values(wn||{}).filter(Ot=>!["tag","recorder","rewriter","arrow","area"].includes(Ot.type));$t?.forEach(Ot=>{ft?.find(Mt=>Mt.annotationId===Ot.annotationId)||this.commentSelectionChange$.next({annotation:zn(Ot),selected:!1})}),ft?.forEach(Ot=>{$t?.find(Mt=>Mt.annotationId===Ot.annotationId)||this.commentSelectionChange$.next({annotation:zn(Ot),selected:!0})})}catch($t){this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$: ",$t)}},xe=>{this.loggingService.catch("Error in CommentService getSelectedAnnotationsMap$ subscription: ",xe)})}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(i){this.loggingService.catch("Error in CommentService setCommentActionsService: ",i)}}detectToAddAreaComment(){try{let e=this.areaService.getAreaEnabled(),i=this.getAreaCommentEnabled();if(e&&i){let r,a,s,m=null,p=null;this.dragSubscriptions.forEach(h=>h.unsubscribe()),this.dragSubscriptions.push(this.domService.onWindowMouseDown$().pipe(Fe(h=>!zi(h?.target)),tt(1)).subscribe(h=>{m=null,p=null,this.dragSubscriptions.push(this.domService.getClickAndDragPointsObservable().subscribe(_=>{if(m===null){let E=_?.startPoint?.event?.target,D=zi(E),L=wd(E),H=this.isElementInsideAllowedElements(E);m=!D&&!L&&H}if(m){this.addCommentDragMode=!0,r=_.startPoint,a=_.curPoint;let E=_?.curPoint?.event?.target,D=zi(E),L=wd(E),H=this.isElementInsideAllowedElements(E);p=!D&&!L&&H,p?s=this.domService.drawRectangle(r,a):s?.remove()}})),this.domService.onWindowPointerUp$().pipe(Ps(1),tt(1)).subscribe(_=>{if(a={x:_.clientX,y:_.clientY},r&&a&&(s?.remove(),m&&p)){let E=[{x:r.x-window.scrollX,y:r.y-window.scrollY},{x:a.x,y:a.y}];this.addComment(_,void 0,E)}this.dragSubscriptions.forEach(E=>E.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(j.TAGS.VELT_AREAS)||document.querySelector(j.TAGS.SNIPPYLY_AREAS))){let i=document.createElement(j.TAGS.VELT_AREAS);document.body.appendChild(i)}}catch(e){this.loggingService.catch("Error in CommentService addAreaContainerTag: ",e)}}addIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${j.ATTRIBUTES.VELT_IFRAME_CONTAINER}]`).forEach(i=>{window.getComputedStyle(i).position==="static"&&i.setAttribute(j.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC,"true")})}catch(e){this.loggingService.catch("Error in CommentService addIframeContainerStaticAttribute: ",e)}}removeIframeContainerStaticAttribute(){try{document.querySelectorAll(`[${j.ATTRIBUTES.VELT_IFRAME_CONTAINER_STATIC}]`).forEach(i=>{i.removeAttribute(j.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(i){this.loggingService.catch("Error in CommentService setCommentAddedEmitter: ",i)}}setContextProvider(e){try{this.commentContextProvider=e}catch(i){this.loggingService.catch("Error in CommentService setContextProvider: ",i)}}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:ke.COMMENT,config:{allowedElementIds:e}}),this.allowedElementIds$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementIds: ",i)}}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}setAllowedElementClassNames(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{allowedElementClassNames:e}}),this.allowedElementClassNames$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementClassNames: ",i)}}getAllowedElementClassNames(){return this.allowedElementClassNames$.asObservable()}setAllowedElementQuerySelectors(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{allowedElementQuerySelectors:e}}),this.allowedElementQuerySelectors$.next(e||[])}catch(i){this.loggingService.catch("Error in CommentService setAllowedElementQuerySelectors: ",i)}}getAllowedElementQuerySelectors(){return this.allowedElementQuerySelectors$.asObservable()}getAnnotationsCount(e){try{return qn(this.afAuth).pipe(Fe(i=>!!i),he(i=>this.isFeatureAllowed({firebaseUser:i,annotations:[],filteredAnnotations:[]})),he(i=>i.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(r=>(i.featureAllowed=r,i))):se(i)),he(i=>i.featureAllowed?se(i).pipe(he(r=>this.docService.getDocumentPaths$().pipe(ce(a=>(this.documentPaths=a,r.documentPaths=a,r)))),he(()=>e?.documentIds?.length?se(e?.documentIds.map(r=>({clientDocumentId:r,documentId:`${yn(r)}`}))):this.docService.getDocumentIds$().pipe(ce(r=>r?.length>0?r:[{documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId||""}]))),he(r=>{let a=this.authService.getUser()?.userSnippylyId,s=this.documentPaths?.organizationId,m=r?.length>0?r.map(L=>L.documentId):[this.documentPaths?.documentId??""];if(m.some(L=>!L)||!this.documentPaths)return se();let p=this.docService.getDocumentPaths()?.veltFolderId,h=this.docService.getDocumentPaths()?.allDocuments,_=se(),E=se(),D={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(p&&h)_=this.commonDbService.dbListener({feature:"allComments",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.veltFolderId","==",p),...e?.statusIds?[gt("status.id","in",e.statusIds)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(ce(L=>L?.data)),E=this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.veltFolderId","==",p))]})}).pipe(ce(L=>L?.data));else{let L=[];for(let H=0;H<(m?.length??0);H+=j.LISTENER_BATCH_SIZE)L.push(m?.slice(H,H+j.LISTENER_BATCH_SIZE)??[]);_=Rn(L.map(H=>this.commonDbService.dbListener({feature:"allComments",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.documentId","in",H),...e?.statusIds?[gt("status.id","in",e.statusIds)]:[],...p?[gt("metadata.veltFolderId","==",p)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(Gr()))).pipe(ce(H=>ua(H)?.data)),E=Rn(L.map(H=>this.commonDbService.dbListener({feature:"allCommentViews",properties:T(I({},D),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",s),gt("metadata.documentId","in",H),...p?[gt("metadata.veltFolderId","==",p)]:[])]})}).pipe(Gr()))).pipe(ce(H=>ua(H)?.data))}return Rn([_,E]).pipe(he(([L,H])=>!L||!H?se(null):se([L,H]).pipe(ce(([K,oe])=>{let ue=Object.values(K||{});e?.locationIds?.length&&(ue=ue.filter(_e=>e.locationIds?.includes(_e.location?.id??"")));let be={};ue.forEach(_e=>{be[_e.annotationId]=_e});let Le={};Object.entries(oe||{}).forEach(([_e,Ee])=>{be[_e]&&(Ee?.views?.[a]||(Le[_e]=Ee))});let qe=ue.reduce((_e,Ee)=>{let Oe=Ee?.metadata?.clientDocumentId;return Oe&&(_e[Oe]||(_e[Oe]=[]),_e[Oe].push(Ee)),_e},{}),Re=Object.values(Le).reduce((_e,Ee)=>{let Oe=Ee?.metadata?.clientDocumentId;return Oe&&(_e[Oe]||(_e[Oe]=[]),_e[Oe].push(Ee)),_e},{});return r.reduce((_e,{clientDocumentId:Ee})=>{_e?.data||(_e.data={});let Oe=qe[Ee]?.length??0,ye=Re[Ee]?.length??0;return _e.data[Ee]={total:Oe,unread:ye},_e},{data:{}})}),jn(K=>(this.loggingService.catch("Error in CommentService getAnnotationsCount: ",K),se(null))))))})):se(null)),ce(i=>i||{data:null}),qt(Vi))}catch(i){return this.loggingService.catch("Error in CommentService getAnnotationsCount: ",i),se({data:null})}}getAllCommentAnnotations({customClientDocumentId:e,params:i,excludeDomChanges:r,detectGhostComments:a,skipPositionCalculation:s,query:m,fromCommentSidebar:p,analytics:h,addFilterCommentsOnDomCheck:_}){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentAnnotations","color: green;");let E,D,L;h?.enabled&&this.analyticsService.trackEvent(h?.eventName||X.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED_INTERNAL,h?.properties);try{if(e&&(L=`${yn(e)}`),i&&typeof i=="object"){let H=Jo(i);D=H?.id,E=yn(JSON.stringify(H))}}catch(H){this.loggingService.catch("Error in CommentService getAllCommentAnnotations: ",H)}return qn(this.afAuth).pipe(Fe(H=>!!H),he(H=>this.isFeatureAllowed({firebaseUser:H,annotations:[],filteredAnnotations:[]})),he(H=>H.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(K=>(H.featureAllowed=K,H))):se(H)),he(H=>H.featureAllowed?se(H).pipe(he(K=>this.docService.getDocumentPaths$().pipe(ce(oe=>(this.documentPaths=oe,K.documentPaths=oe,K)))),he(K=>m?.documentIds?.length||L?this.getDataFromDocumentIds({documentIds:L?[L]:m?.documentIds?.map(oe=>`${yn(oe)}`),organizationId:this.documentPaths?.organizationId,query:m}).pipe(ce(oe=>({res:K,data:oe}))):this.docService.getDocumentIds$().pipe(he(oe=>{let ue=oe?.length>0?oe.map(be=>be.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds({documentIds:ue.length>0?ue:[L??""],organizationId:this.documentPaths?.organizationId,query:m}).pipe(ce(be=>({res:K,data:be})))}))),he(K=>K?.data?(K.res.annotations=K.data||[],se(K.res).pipe(he(oe=>this.docService.getLocation$().pipe(ce(ue=>(oe.location=ue,oe)))),he(oe=>this.docService.getLocations$().pipe(ce(ue=>(oe.customLocations=ue,oe)))),he(oe=>this.docService.getExcludedLocationIds$().pipe(ce(ue=>(oe.excludedLocationIds=ue,oe)))),ce(oe=>{if(oe.filteredAnnotations=[],m)return oe.filteredAnnotations=oe.annotations?.slice(),oe;if(L&&!E||p)return oe.filteredAnnotations=oe.annotations?.slice(),oe?.excludedLocationIds?.length&&(oe.filteredAnnotations=oe.filteredAnnotations?.filter(ue=>ue?.location?.id?!oe.excludedLocationIds.includes(ue.location.id):!0)),oe;{let ue=[],be=[];return E?(ue.push(E),D&&be.push(D)):(ue.push(oe?.location?.locationId),ue.push(...Object.values(oe?.customLocations||[]).map(Le=>Le.locationId)),oe?.location?.location?.id&&be.push(oe?.location?.location?.id),be.push(...Object.values(oe?.customLocations||{}).map(Le=>Le.location?.id).filter(Le=>!!Le))),oe.filteredAnnotations=this.filterAnnotationsByLocationIds(oe?.annotations,ue,be),oe?.excludedLocationIds?.length&&(oe.filteredAnnotations=oe.filteredAnnotations?.filter(Le=>Le?.location?.id?!oe.excludedLocationIds.includes(Le.location.id):!0)),oe}}),he(oe=>this.iamService.isUserAdmin$().pipe(ce(ue=>(ue||(oe.filteredAnnotations=oe.filteredAnnotations?.filter(be=>be?.iam?.accessMode!==Qi.PRIVATE)),oe)))),he(oe=>this.draftCommentAnnotationsByAnnotationId$.pipe(ce(ue=>(oe.filteredAnnotations=oe.filteredAnnotations?.filter(be=>!be.isDraft),ue&&oe.filteredAnnotations.push(...Object.values(ue)),oe)))),he(oe=>r?se(oe):oe?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ce(()=>oe)):se(oe)),he(oe=>r?se(oe):this.addCommentMode$.pipe(he(ue=>ue&&!this.getChangeDetectionInCommentMode()?se(oe):oe?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllCommentAnnotations").pipe(ce(()=>oe)):se(oe)))),ce(oe=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(oe.filteredAnnotations=oe.filteredAnnotations?.map(ue=>{let be=Object.assign({},ue);return this.calculateCommentAnnotationPosition(be,a),be})),oe)),he(oe=>oe?.annotations?.length?this.viewsService.getCommentFeatureViews$().pipe(ce(ue=>(this.updateUnreadAnnotationsMap(oe?.annotations,ue),oe))):se(oe)),he(oe=>oe?.filteredAnnotations?se(oe?.filteredAnnotations||[]):se([])))):se(null))):se(null)),qt((H,K)=>Vi(H,K)),he(H=>_?this.filterCommentsUsingSidebarSettings(H):se(H)))}getAllMultiThreadCommentAnnotations(e,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: getAllMultiThreadCommentAnnotations","color: green;");let m,p;try{if(e&&(p=yn(e)),i&&typeof i=="object"){let h=Jo(i);m=yn(JSON.stringify(h))}}catch(h){this.loggingService.catch("Error in CommentService getAllMultiThreadCommentAnnotations: ",h)}return qn(this.afAuth).pipe(Fe(h=>!!h),he(h=>this.isFeatureAllowed({firebaseUser:h,annotations:[],filteredAnnotations:[]})),he(h=>h.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(_=>(h.featureAllowed=_,h))):se(h)),he(h=>h.featureAllowed?se(h).pipe(he(_=>this.docService.getDocumentPaths$().pipe(ce(E=>(this.documentPaths=E,_.documentPaths=E,_)))),he(_=>p?this.getMultiThreadDataFromDocumentIds([p]).pipe(ce(E=>({res:_,data:E}))):this.docService.getDocumentIds$().pipe(he(E=>{let D=E?.length>0?E.map(L=>L.documentId):[this.documentPaths?.documentId??""];return this.getMultiThreadDataFromDocumentIds(D.length>0?D:[`${p}`]).pipe(ce(L=>({res:_,data:L})))}))),he(({res:_,data:E})=>E?(_.annotations=E||[],se(_).pipe(he(D=>this.docService.getLocation$().pipe(ce(L=>(D.location=L,D)))),he(D=>this.docService.getLocations$().pipe(ce(L=>(D.customLocations=L,D)))),he(D=>this.docService.getExcludedLocationIds$().pipe(ce(L=>(D.excludedLocationIds=L,D)))),ce(D=>{if(D.filteredAnnotations=[],p&&!m)return D.filteredAnnotations=D.annotations?.slice(),D?.excludedLocationIds?.length&&(D.filteredAnnotations=D.filteredAnnotations?.filter(L=>L?.location?.id?!D.excludedLocationIds.includes(L.location.id):!0)),D;{let L=[],H=[];return m?L.push(m):(L.push(D?.location?.locationId),L.push(...Object.values(D?.customLocations||[]).map(K=>K.locationId)),D?.location?.location?.id&&H.push(D?.location?.location?.id),H.push(...Object.values(D?.customLocations||{}).map(K=>K.location?.id).filter(K=>!!K))),D.filteredAnnotations=this.filterAnnotationsByLocationIds(D?.annotations,L,H),D?.excludedLocationIds?.length&&(D.filteredAnnotations=D.filteredAnnotations?.filter(K=>K?.location?.id?!D.excludedLocationIds.includes(K.location.id):!0)),D}}),he(D=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ce(L=>(D.filteredAnnotations=D.filteredAnnotations?.filter(H=>!H.isDraft),L&&D.filteredAnnotations.push(...Object.values(L)),D)))),he(D=>r?se(D):D?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onWindowResize$().pipe(ce(()=>D)):se(D)),he(D=>r?se(D):this.addCommentMode$.pipe(he(L=>L&&!this.getChangeDetectionInCommentMode()?se(D):D?.annotations?.length&&(!this.getPopoverMode()||this.getPopoverTriangleComponent())?this.domService.onDomChange$("CommentService getAllMultiThreadCommentAnnotations").pipe(ce(()=>D)):se(D)))),ce(D=>(s||(!this.getPopoverMode()||this.getPopoverTriangleComponent())&&(D.filteredAnnotations=D.filteredAnnotations?.map(L=>{let H=Object.assign({},L);return this.calculateCommentAnnotationPosition(H,a),H})),D)),he(D=>D?.filteredAnnotations?se(D?.filteredAnnotations||[]):se([])))):se(null))):se(null)),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>(this.user=r,T(I({},i),{user:r}))))),he(i=>eo(i.config,i.user,ke.COMMENT)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Comment feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocuments(e){let{documentIds:i,organizationId:r,query:a}=e;if(!this.configService?.getApiKey())return se(null);if(i?.some(D=>!D)||!this.documentPaths)return se(null);let s,m,p,h=[];if(a)a?.folderId&&(s=Tl(a?.folderId)),m=a?.allDocuments,a?.locationId&&(h=[...h,a?.locationId]),a?.locationIds?.length&&(h=[...h,...a?.locationIds]),p=a?.statusIds;else{s=this.docService.getDocumentPaths()?.veltFolderId,m=this.docService.getDocumentPaths()?.allDocuments;let D=this.docService.getDocumentPaths()?.locationId;D&&(h=[...h,D])}let _=se([]),E={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(E.documentId=i?.length?i[0]:void 0,E.organizationId=this.documentPaths?.organizationId),m)_=this.commonDbService.dbListener({feature:"allComments",properties:T(I({},E),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",r??this.documentPaths?.organizationId),...s?[gt("metadata.veltFolderId","==",s)]:[],...p?[gt("status.id","in",p)]:[],...h?.length?[gt("location.id","in",h)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})});else{let D=[];for(let L=0;L<(i?.length??0);L+=j.LISTENER_BATCH_SIZE)D.push(i?.slice(L,L+j.LISTENER_BATCH_SIZE)??[]);_=Rn(D.map(L=>this.commonDbService.dbListener({feature:"allComments",properties:T(I({},E),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",r??this.documentPaths?.organizationId),gt("metadata.documentId","in",L),...p?[gt("status.id","in",p)]:[],...s?[gt("metadata.veltFolderId","==",s)]:[],...h?.length?[gt("location.id","in",h)]:[]),Ka("lastUpdated","desc"),Ka("createdAt","desc")]})}).pipe(Gr()))).pipe(ce(L=>ua(JSON.parse(JSON.stringify(L)))))}return _.pipe(he(D=>D?.data?se(D).pipe(he(L=>this.commonDbUtilsService.mergeLocationMetadataWithData$({data:L,feature:"allComments"}).pipe(ce(H=>({data:Object.values(H?.data||{}).filter(K=>typeof K=="object"),operation:H?.operation})))),ce(({data:L,operation:H})=>{let K=L.reduce((oe,ue)=>{let be=ue.metadata?.documentId;return be&&(oe[be]||(oe[be]=[]),oe[be].push(ue)),oe},{});return{data:L,documentMap:K,operation:H}}),ce(({data:L,documentMap:H,operation:K})=>p?{data:L,documentMap:H,operation:K}:(L?.length&&(L?.forEach(oe=>{this.sanitizeCommentAnnotation(oe)}),this.setAnnotationIndex(L),this.updateAnnotationsForSelectAllContentMode(L),L.forEach(oe=>{this.customFilterService.convertLegacyAnnotationStatus(oe),this.customFilterService.convertLegacyPriority(oe),this.customFilterService.convertLegacyCategory(oe)})),{data:L,documentMap:H,operation:K})),jn(L=>(this.loggingService.catch("Error in CommentService getDataFromDocuments: ",L),se([]))),gn(({documentMap:L})=>{p||Object.entries(L??{}).forEach(([H,K])=>{this.setOriginalCommentAnnotationsByAnnotationId(JSON.parse(JSON.stringify(K)))})}),ce(({data:L,documentMap:H,operation:K})=>({data:this.filterUserDraftComments(L),documentMap:H,operation:K})),ce(({data:L,documentMap:H,operation:K})=>({data:this.removeDraftFlags(L),documentMap:H,operation:K})),he(({data:L,documentMap:H,operation:K})=>p?se({data:L,documentMap:H,operation:K}):this.mergeDraftAnnotations(L).pipe(ce(oe=>({data:oe,documentMap:H,operation:K})))),ce(({data:L,documentMap:H,operation:K})=>{if(!p)if(K?.type==="removed"){if(K?.ids?.length){let oe=this.commentAnnotationById$.value??{};K?.ids?.forEach(ue=>{delete oe?.[ue]}),this.commentAnnotationById$.next(oe)}}else Object.entries(H??{}).length?Object.entries(H??{}).forEach(([ue,be])=>{this.setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:ue,annotations:be})}):this.commentAnnotationById$.value||this.commentAnnotationById$.next({});return L})):se(null)))}fetchCommentAnnotations(e){return Q(this,null,function*(){try{let i=this.authService.getUser();if(!i)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??i?.clientOrganizationId,s=_c(a??""),m=[];e?.allDocuments||(m=e?.documentIds?.map(H=>Cc(H??""))??this.docService.getDocumentIds()?.map(H=>H.documentId));let p=[];if(p.push(gt("metadata.organizationId","==",s)),p.push(gt("metadata.apiKey","==",r)),e?.folderId){let H=Tl(e?.folderId);p.push(gt("metadata.veltFolderId","==",H))}if(e?.locationId&&p.push(gt("location.id","==",e?.locationId)),m?.length&&p.push(gt("metadata.documentId","in",m)),e?.resolvedBy){if(e?.order==="asc")throw new Error("Order by resolvedBy is not supported in ascending order.");p.push(gt("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(gt("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(gt("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(gt("status.id","in",e?.statusIds))}let h=new Date().getTime();if(e?.createdAfter&&p.push(gt("createdAt",">=",e?.createdAfter)),e?.createdBefore&&p.push(gt("createdAt","<=",e?.createdBefore??h)),e?.updatedAfter&&p.push(gt("lastUpdated",">=",e?.updatedAfter??h)),e?.updatedBefore&&p.push(gt("lastUpdated","<=",e?.updatedBefore??h)),p.push(Ka("lastUpdated",e?.order??"desc"),Ka("createdAt",e?.order??"desc")),e?.pageToken){let H=yield bU(e?.pageToken??"","veltencrypttoken","veltencrypttoken");p.push(ole(parseInt(H,10),"lastUpdated"))}let _=e?.pageSize??100;p.push(qv(_+1));let E=yield this.commonDbService.queryData({feature:"allComments",properties:{useCollectionGroup:!0,isCollection:!0,useQuery:!0,firestoreQuery:p,apiKey:r??"",organizationId:s}}),D=E.length>_;E=E.slice(0,_);let L=E?.reduce((H,K)=>(H[K?.annotationId]=K,H),{});return L=yield this.commonDbUtilsService.formatResponse({feature:"allComments",data:L,shouldAwait:!0}),L=this.commonDbUtilsService.mergeUsersWithData({feature:"allComments",data:L}),{data:Object.values(L??{}),hasMore:D}}catch(i){throw this.loggingService.catch("Error in CommentService fetchCommentAnnotations:",i),i}})}filterUserDraftComments(e){let i=this.authService.getUser();return e.filter(r=>(r.comments=r?.comments?.filter(a=>a?.from?.userId===i?.userId||!a?.isDraft),!!r?.comments?.length))}removeDraftFlags(e){return e.forEach(i=>delete i.isDraft),e}mergeDraftAnnotations(e){return this.draftCommentAnnotationsByAnnotationId$.pipe(ce(i=>{let r=i||{};return e?.filter(a=>{r?.[a?.annotationId]&&delete r[a?.annotationId]}),r}),ce(i=>{if(i){let r=e.slice();return r.push(...Object.values(i)),r}return e}))}getDataFromDocumentIds({documentIds:e,organizationId:i,query:r}){return this.getDataFromDocuments({documentIds:e,organizationId:i,query:r})}getMultiThreadDataFromDocumentIds(e){return this.getMultiThreadDataFromDocuments({documentIds:e})}getMultiThreadDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i}=e;if(i?.some(p=>!p)||!this.documentPaths)return se(null);let r=this.docService.getDocumentPaths()?.veltFolderId,a=this.docService.getDocumentPaths()?.allDocuments,s=se([]),m={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(m.documentId=i?.length?i[0]:void 0,m.organizationId=this.documentPaths?.organizationId),r&&a)s=this.commonDbService.dbListener({feature:"allMultiThreads",properties:T(I({},m),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",this.documentPaths?.organizationId),gt("metadata.veltFolderId","==",r))]})});else{let p=[];for(let h=0;h<(i?.length??0);h+=j.LISTENER_BATCH_SIZE)p.push(i?.slice(h,h+j.LISTENER_BATCH_SIZE)??[]);s=Rn(p.map(h=>this.commonDbService.dbListener({feature:"allMultiThreads",properties:T(I({},m),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.organizationId","==",this.documentPaths?.organizationId),gt("metadata.documentId","in",h),...r?[gt("metadata.veltFolderId","==",r)]:[])]})}).pipe(Gr()))).pipe(ce(h=>ua(h)))}return s.pipe(he(p=>p?.data?se(p).pipe(ce(h=>({data:h?.data,operation:h?.operation})),ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),{data:E,operation:_}}),jn(h=>(this.loggingService.catch("Error in CommentService getMultiThreadDataFromDocumentId: ",h),se({data:[],operation:null}))),ce(({data:h,operation:_})=>{h.forEach(D=>{delete D.isDraft});let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),he(({data:h,documentMap:_,operation:E})=>{let D=[];return this.commentAnnotationById$.pipe(he(()=>this.domService.getSelectedAnnotationsMap$().pipe(ce(L=>({selectedAnnotationsMap:L})))),ce(({selectedAnnotationsMap:L})=>{let H={};return Object.keys(_??{}).forEach(K=>{let oe=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:K});oe&&oe?.forEach(ue=>{H[ue?.annotationId]=ue})}),D=h.filter(K=>{let oe=!1;if(K?.commentAnnotations){for(let ue in K?.commentAnnotations)if(H?.[ue]&&H?.[ue]?.status?.id!==this.customFilterService.resolvedStatus.id){oe=!0;break}}return oe}),D.forEach(K=>{Object.keys(K?.commentAnnotations||{}).forEach(oe=>{K.commentAnnotationsMap||(K.commentAnnotationsMap={}),K.commentAnnotationsMap[oe]=H?.[oe]})}),{data:D,operation:E}}))}),he(({data:h,operation:_})=>this.draftMultiThreadCommentAnnotationsByAnnotationId$.pipe(ce(E=>{let D=E||{};return h?.filter(L=>{D?.[L?.annotationId]&&delete D[L?.annotationId]}),D}),ce(E=>{if(E){let D=h.slice();return D.push(...Object.values(E)),{data:D,operation:_}}return{data:h,operation:_}}))),ce(({data:h,operation:_})=>{let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});if(_?.type==="removed"){if(_?.ids?.length){let D=this.multiThreadCommentAnnotationById$.value;_?.ids?.forEach(L=>{delete D?.[L]}),this.multiThreadCommentAnnotationById$.next(D)}}else Object.keys(E??{}).forEach(D=>{this.setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:E[D]})});return h})):se(null)))}else return se(null)}updateUnreadAnnotationsMap(e,i){try{let r=new Date(j.UNREAD_COMMENTS_CHECK_FROM_DATE)?.getTime(),a=e.filter(s=>s?.lastUpdated>r);if(i){let s={},m=!1;a.forEach(p=>{let h=0,_=i?.[p?.annotationId];if(_){let E=_?.comments;E&&p?.comments?.forEach(D=>{!E?.[D?.commentId]?.views?.[this.user?.userSnippylyId]&&this.user?.userSnippylyId!==D?.from?.userSnippylyId&&h++})}h?h!==s?.[p?.annotationId]&&(s[p?.annotationId]=h,m=!0):s?.[p?.annotationId]&&(delete s[p?.annotationId],m=!0)}),this.unreadCommentsMap$.next(s)}}catch(r){this.loggingService.catch("Error in CommentService updateUnreadAnnotationsMap:",r)}}updateAnnotationsForSelectAllContentMode(e){try{e.forEach(i=>{if(i?.selectAllContent&&i?.targetElementId){let r=dr(i.targetElementId,["id","data-id"]);if(r){let a=r.textContent;a&&(i.targetTextRange={commonAncestorContainer:this.domService.getXPath(r),text:a,occurrence:1},delete i?.targetElement)}}})}catch(i){this.loggingService.catch("Error in CommentService updateAnnotationsForSelectAllContentMode:",i)}}setCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.commentAnnotationById$.value??{}),s);this.commentAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:i}){try{return this.commentAnnotationById$.pipe(ce(()=>this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i})))}catch(r){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByOrganizationIdAndDocumentId$:",r),se([])}}getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r=null;this.commentAnnotationById$.value&&(r={},Object.values(this.commentAnnotationById$.value).forEach(s=>{s?.metadata?.documentId==i&&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===i&&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),[]}}getCommentAnnotationsOnCurrentOrganizationAndDocument$(){return this.docService.getDocumentPaths$().pipe(he(e=>e?.documentId?this.getCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):se([])))}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 i={};e?.forEach(r=>{r?.annotationId&&(i[r?.annotationId]=r)}),this.originalCommentAnnotationsByDocumentId$.next(I(I({},this.originalCommentAnnotationsByDocumentId$.value),i))}catch(i){this.loggingService.catch("Error in CommentService setOriginalCommentAnnotationsByAnnotationId:",i)}}setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.multiThreadCommentAnnotationById$.value),s);this.multiThreadCommentAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in CommentService setMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId:",s)}}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e,documentId:i}){return this.multiThreadCommentAnnotationById$.pipe(ce(()=>this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i})))}getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};Object.values(this.multiThreadCommentAnnotationById$.value??{}).forEach(s=>{s?.metadata?.documentId==i&&s?.metadata?.organizationId==e&&(r[s?.annotationId]=s)});let a=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;return a&&Object.values(a??{}).forEach(s=>{s?.metadata?.documentId===i&&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(he(e=>e?.documentId?this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId$({organizationId:e.organizationId,documentId:e.documentId}):se([])))}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(he(e=>this.docService.getLocations$().pipe(ce(i=>({location:e,locations:i})))),ce(e=>{let i=[];return i.push(e?.location?.locationId),i.push(...Object.values(e.locations||[]).map(r=>r.locationId)),i||[]}))}filterAnnotationsByLocationIds(e,i,r){try{return e.filter(a=>i.includes(a.locationId)||r?.includes(a?.location?.id)||i?.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((i,r)=>{i?.annotationId&&(i.annotationIndex=r+1)})}catch(i){this.loggingService.catch("Error in CommentService setAnnotationIndex:",i)}}calculateCommentAnnotationPosition(e,i){try{if(e.multiThreadAnnotationId)return;if(e.targetElementId){let r=dr(e.targetElementId,["id","data-id"]);if(r&&this.domService.isElementVisible(r)){let a=r.getAttribute(j.ATTRIBUTES.VELT_COMMENT_TYPE),s=!0;if(a)switch(a){case"popover":s=!0;break;default:s=!1;break}else{let m=document.querySelector(`${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_INLINE_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_COMMENT_ELEMENT_ID}="${e.targetElementId}"], ${j.TAGS.VELT_INLINE_COMMENTS_SECTION}[${j.ATTRIBUTES.TARGET_ELEMENT_ID}="${e.targetElementId}"]`);m&&r?.contains(m)&&(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;if(r){let 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()===B6.DYNAMIC_ID&&(!a||!this.domService.isElementVisible(a))&&(r=e.targetElement?.fXpath,r&&(a=this.domService.getElementFromXPath(r)))),(!a||!this.domService.isElementVisible(a))&&i&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=this.getGhostCommentTargetElement(e),e?.ghostComment?.targetElement?.xpath&&(a=this.domService.getElementFromXPath(e?.ghostComment?.targetElement?.xpath)));let m=!1;if(e?.locationId){let p=this.docService.getLocation();if(!$u({location:p?.location,locationId:p?.locationId},{location:e?.location,locationId:e?.locationId})){let h=this.docService.getAdditionLocationFromElement(a),_=h?this.docService.genarateLocationId(h):void 0;e?.location?.id&&e?.location?.id===h?.id||_&&_===e?.locationId?m=!1:m=!0}}if(m&&(e.ghostComment=null),!m&&a&&Do(a)&&!a?.closest(".cdk-overlay-container")&&a?.getBoundingClientRect()){let h=this.popoverMode$?.value?0:e.targetElement?.topPercentage,_=this.popoverMode$?.value?100:e.targetElement?.leftPercentage,{height:E,width:D}=Np(a);e.position={top:E*(h||0)/100,left:D*(_||0)/100};let L=window.getComputedStyle(a).transform;if(L&&L!=="none")try{let H=new DOMMatrixReadOnly(L),K=Math.sqrt(H.a*H.a+H.b*H.b)||1,oe=Math.sqrt(H.c*H.c+H.d*H.d)||1;(Math.abs(K-1)>.01||Math.abs(oe-1)>.01)&&(e.position.parentScaleX=K,e.position.parentScaleY=oe)}catch{}if(this.transformContext$.value){let{containerSelector:H,transforms:K}=this.transformContext$.value,oe=document.querySelector(H);oe&&oe.contains(a)&&(e.position.transformContext=K)}}!m&&i&&!e?.position&&!e?.ghostComment&&(e.ghostComment={},this.setGhostCommentMessage(e),e.ghostComment.targetElement=e.targetElement)}}i&&(e.ghostComment?this.addAnnotationToGhostCommentAnnotationMap(e):this.removeAnnotationFromGhostCommentAnnotationMap(e))}catch(r){this.loggingService.catch("Error in CommentService calculateCommentAnnotationPosition:",r)}}addComment(e,i,r,a,s,m=[],p,h,_,E,D,L,H,K,oe,ue,be,Le,qe){this.loggingService.log("%c[WB] Calling FUNCTION: addComment","color: green;");try{let Re=this.authService.getUser();if(Re)if(Re.isReadOnly||Re.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add comments.");else{let _e=new Ro;be&&(_e=I(I({},_e),be)),_e.comments=[],be?.comments?.length&&(_e.comments=be.comments.map($t=>{let ft=new xc;return ft=I(I({},ft),$t),ft.from=Re,ft.lastUpdated=new Date,ft.createdAt=this.timestamp,ft})),_e.from=Re,_e.color=_e?.color||j.DEFAULT_ANNOTATION_COLOR,_e.lastUpdated=this.timestamp,_e.createdAt=this.timestamp,_e.sourceId=oe,_e.assignedTo=be?.assignedTo||ue,_e.customList=be?.customList||[];let{topPositionX:Ee,topPositionY:Oe}=this.domService.getTopLeftPosition();_e.positionX=Ee,_e.positionY=Oe;let ye=this.domService.getCurrentWindowSizeValue();if(_e.screenWidth=ye.screenWidth,_e.screenHeight=ye.screenHeight,_e.screenScrollHeight=ye.screenScrollHeight,_e.taggedElementPath="",e&&(_e.targetElement=this.domService.getTargetElementForCursorPosition(e,!0,!0,!0,$t=>{if(this.getSvgAsImg()){let ft=$t?.closest(`[${j.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);ft&&ft instanceof HTMLElement&&($t=ft)}if(this.getPopoverMode()){let ft=$t?.closest(`[${j.ATTRIBUTES.VELT_TARGET_COMMENT_ELEMENT_ID}]`);if(ft&&ft instanceof HTMLElement)return ft}return $t}),this.getCommentToNearestAllowedElement()&&_e.targetElement?.xpath)){let $t=this.domService.getElementFromXPath(_e.targetElement.xpath);if($t&&!this.isElementInsideAllowedElements($t)){let ft=this.getNearestAllowedElement($t);if(ft)_e.targetElement.xpath=this.domService.getXPath(ft),_e.targetElement.fXpath=this.domService.getXPath(ft,!0),_e.targetElement.cfXpath=this.domService.getXPath(ft,!0,!0);else return}}if(i&&(_e.targetTextRange=i),_e?.targetElement?.xpath){let $t=this.domService.getXPath(_e.targetElement.xpath);if($t){let ft=$t.iterateNext();ft&&(Do(ft)||(_e.targetElement=null))}}this.customFilterService.defaultStatus&&!be?.status&&(_e.status=this.customFilterService.defaultStatus),_e.pageInfo=Ei(),_e.pageInfo&&(_e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let fe=this.docService.getClientDocumentId(),Be=this.docService.getLocation()?.location;if(qe&&(_e.context=qe&&vc(qe),_e.contextId=this.generateContextId(_e.context)),this.commentContextProvider!==null){let $t=this.commentContextProvider(fe,Be);$t&&(_e.context=$t&&vc($t),_e.contextId=this.generateContextId(_e.context))}if(a){_e.sourceId=a?.sourceId;let $t=a?.targetElement,ft=a?.commentData;if($t?.targetText)_e.targetTextRange={commonAncestorContainer:"/html/body",text:$t.targetText,occurrence:$t?.occurrence||1};else if($t?.elementId)if(_e.targetElementId=$t.elementId,$t?.selectAllContent)_e.selectAllContent=!!$t?.selectAllContent;else{let Mt=dr($t.elementId,["id","data-id"]);Mt?_e.targetElement={xpath:this.domService.getXPath(Mt),fXpath:this.domService.getXPath(Mt,!0),cfXpath:this.domService.getXPath(Mt,!0,!0),topPercentage:50,leftPercentage:90}:_e.targetElement={xpath:"/html/body",fXpath:"/html/body",cfXpath:"/html/body",topPercentage:50,leftPercentage:90}}a?.status&&(_e.status=a.status),a?.context&&(_e.context=a.context?vc(a.context):a.context,_e.contextId=this.generateContextId(_e.context)),_e.comments||(_e.comments=[]);let Ot=this.authService.getUser();ft?.forEach(Mt=>{let ln=new xc;ln.commentText=Mt.commentText,ln.commentHtml=Mt.commentHtml,ln.replaceContentHtml=Mt.replaceContentHtml,ln.replaceContentText=Mt.replaceContentText,ln.from=Ot,_e.comments.push(ln)})}if(s&&(_e.isPageAnnotation=!0),m?.length&&(_e.comments=m),p&&(_e.commentType="chart",_e.metadata=p),_?.sourceId&&(_e.sourceId=_.sourceId),_e?.targetElement?.xpath&&!_){let $t=this.domService.getElementFromXPath(_e.targetElement.xpath);$t&&(_=this.getInlineCommentSectionConfig($t))}_?.targetInlineCommentElementId&&(_e.targetInlineCommentElementId=_?.targetInlineCommentElementId,_e.targetElementId=_.targetInlineCommentElementId,_?.config?.id&&(_e.inlineCommentSectionConfig=_?.config));let xe=!_e?.comments?.length,wn=a?.openComment===!1;this.getPrivateCommentMode()&&(_e?.iam||(_e.iam=new ib),_e.iam.accessMode=Qi.PRIVATE),E&&(_e.context=E.context?vc(E.context):E.context,_e.commentType="manual",delete _e.targetElement,_e.contextId=this.generateContextId(_e.context)),D&&(_e.targetElementId=D.targetElementId,_e.targetElement=D.targetElement),this.saveCommentToDb(_e,r,xe,wn,h,L,H,Le,K)}}catch(Re){this.loggingService.catch("Error in CommentService addComment: ",Re)}}setLocationToCommentAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location);try{let r;e.targetElement?.xpath?r=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId?r=dr(e.targetElementId,["id","data-id"]):e.targetTextRange?.commonAncestorContainer&&(r=this.domService.getElementFromXPath(e.targetTextRange.commonAncestorContainer));let a=this.docService.getAdditionLocationFromElement(r);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}catch{}}catch(i){this.loggingService.catch("Error in CommentService setLocationToCommentAnnotation:",i)}}getElementForCommentAnnotation(e){try{let i;return e.targetElement?.xpath?i=this.domService.getElementFromXPath(e.targetElement.xpath):e.targetElementId?i=dr(e.targetElementId,["id","data-id"]):e.targetTextRange?.commonAncestorContainer&&(i=this.domService.getElementFromXPath(e.targetTextRange.commonAncestorContainer)),i}catch(i){return this.loggingService.catch("Error in CommentService getElementForCommentAnnotation: ",i),null}}saveCommentToDb(e,i,r=!1,a=!1,s,m,p,h,_){this.loggingService.log("%c[WB] Calling FUNCTION: saveCommentToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.COMMENT)&&this.docService.getDocumentPaths$().pipe(Fe(E=>!!E),tt(1),he(E=>(this.documentPaths=E,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(D=>!!D),tt(1),he(D=>Q(this,null,function*(){if(this.db=D,this.loggingService.log(this.db),this.documentPaths?.comment){let L=rn(this.db,`${this.documentPaths?.comment}`);e.annotationId=this.commonDbService.generateDocumentId();let H=this.docService.getClientDocumentId(),K=this.docService.getLocation()?.location;if(p)e.multiThreadAnnotationId=p;else if(this.getMultiThread()){let _e=_m();e.targetElementId&&(_e=_m(e.targetElementId),e?.location?.id?_e=_m([e?.location?.id,e.targetElementId]):e?.locationId&&(_e=_m([e?.locationId+"",e.targetElementId]))),e.multiThreadAnnotationId=_e}let oe={addContext:_e=>{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ADD_CONTEXT_TRIGGERED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode(),context:_e}),e.context=_e&&vc(_e),e.contextId=this.generateContextId(e.context),_e?.commentType==="manual"&&(e.commentType="manual",delete e.targetElement),e?.annotationId&&this.updateCommentAnnotationContext(e.annotationId,_e)},documentId:H,location:K,annotation:zn(e),targetAnnotationId:e?.annotationId,targetCommentId:e?.comments?.length?e?.comments[0]?.commentId:void 0};e?.targetElement?.xpath?oe.elementRef={xpath:e.targetElement.xpath}:oe.elementRef=void 0,this.commentAddedEmitter!==null&&"emit"in this.commentAddedEmitter&&this.commentAddedEmitter.emit(oe),this.commentAdded$.next(oe),_&&_(oe);let ue=yield this.commentActionsService?.getAddCommentAnnotationEventFromCommentAddEventData(oe);ue&&this.commentActionsService?.triggerAddCommentAnnotationEvent(ue),this.setLocationToCommentAnnotation(e);let be=this.getElementForCommentAnnotation(e),Le=this.docService.getBaseMetadata("comment",{element:be,multiThreadAnnotationId:e.multiThreadAnnotationId});if(!Le?.apiKey)return;if(e?.metadata||(e.metadata={}),e.metadata=I(I({},e.metadata),Le),s&&typeof s=="object"&&(e.locationId=h||this.docService.genarateLocationId(s),e.location=s,this.docService.addLocation({location:s})),r)window.localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT,JSON.stringify(e));else{let _e=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);_e&&JSON.parse(_e).annotationId===e.annotationId&&e.comments!==void 0&&e.comments.length>0&&window.localStorage.removeItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT)}e.pageInfo&&(e.pageInfo.commentUrl=this.generateCommentUrl(e));let qe=e.comments,Re=JSON.parse(JSON.stringify(e));if(Re.position=null,i){Re.targetElement=null,Re.targetTextRange=null;let _e={annotationId:e.multiThreadAnnotationId?e.multiThreadAnnotationId:e.annotationId,type:e.multiThreadAnnotationId?ke.MULTI_THREAD:ke.COMMENT},Ee=yield this.areaService.generateAreaAnnotationId();Re.areaAnnotationId=Ee;let Oe=this.areaService.addArea(void 0,i,_e,Ee,{locationId:Re.locationId,location:Re.location});Oe&&(Re.metadata=I(I({},Re.metadata),Oe?.metadata||{}))}!a&&!Re?.targetInlineCommentElementId&&!Re?.isPageAnnotation&&this.domService.toggleAnnotationSelection(Re,m),e.targetTextRange&&sessionStorage.setItem(j.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.multiThreadAnnotationId?e?.multiThreadAnnotationId:e.annotationId),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DRAFT_ADDED,{annotationId:e.annotationId,commentType:this.getCommentType(Re),commentMode:this.getCommentMode()}),Re?.comments?.length?Re.comments=[]:Re.isDraft=!0,Re?.multiThreadAnnotationId&&this.saveMultiThreadCommentAnnotation(Re),Re?.context&&(Re.contextId=this.generateContextId(Re.context)),qe?.length?this.saveComment(Re,{type:Ut.NEWLY_ADDED,updatedComment:qe[0]}):this.draftCommentAnnotationsByAnnotationId$.next(T(I({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:Re}))}})))))).subscribe(()=>{},E=>{this.loggingService.catch("Error in CommentService saveCommentToDb subscription: ",E)})}catch(E){this.loggingService.catch("Error in CommentService saveCommentToDb: ",E)}}saveMultiThreadCommentAnnotation(e){return Q(this,null,function*(){try{if(e?.multiThreadAnnotationId){let i=this.docService.getDocumentPaths();if(this.db&&i?.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};delete e?.targetElement,delete e?.areaAnnotationId,delete e?.targetTextRange;let a=this.getMultiThreadCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:i?.documentId})?.find(s=>s.annotationId===e.multiThreadAnnotationId);if(a||(a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:e.multiThreadAnnotationId}})),a&&(a=JSON.parse(JSON.stringify(a)),delete a.from,r=I(I({},a),r)),r?.commentAnnotations||(r.commentAnnotations={}),r.commentAnnotations[e.annotationId]=!0,e?.isDraft)this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(T(I({},this.draftMultiThreadCommentAnnotationsByAnnotationId$.value),{[r.annotationId]:T(I({},r),{isDraft:!0})}));else{let m=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[r.annotationId];if(m&&(r=I(I({},r),m)),delete r.isDraft,r.commentAnnotationsMap={},!r?.metadata?.documentId){r?.metadata||(r.metadata={});let _=this.docService.getBaseMetadata();r.metadata=I(I({},r?.metadata),_)}let{documentId:p,organizationId:h}=r?.metadata||{};yield this.commonDbService.updateData({feature:"multiThread",properties:{id:r.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(r)),callback:()=>{let _=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value;_[e.annotationId]&&(delete _[e.annotationId],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(_))}})}return r}}return null}catch(i){return this.loggingService.catch("Error in CommentService saveMultiThreadCommentAnnotation: ",i),null}})}setCommentCategory(e){return Q(this,null,function*(){try{if(e?.comments?.length){let i=e.comments[0].commentText?.trim();if(i){let r=yield this.getCommentCategory(i).toPromise();if(r){let a=this.docService.getDocumentPaths();if(a?.comment&&e?.annotationId){let s=this.getCommentAnnotationsOnCurrentOrganizationAndDocument()?.find(m=>m.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 m=s;m.commentCategories=[r];let{documentId:p,organizationId:h}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(m);yield this.commonDbService.updateData({feature:"comment",properties:{id:e.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}}}}}}catch(i){this.loggingService.catch("Error in CommentService setCommentCategory: ",i)}})}getCommentCategory(e){try{let i=yr(this.functions,br({url:Xn.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 _o(i({messages:a,apiKey:this.configService.getApiKey(),sdkVersion:ga(),sdkType:this.configService.getSdkType(),numResponse:1})).pipe(ce(s=>{if(s?.data){let m=s.data,p=m?.length?m[0]?.content?.trim():void 0;return p&&Object.keys(this.customCategoryMap).includes(p)?this.customCategoryMap[p]:void 0}else return}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentCategory: ",i),se(void 0)}}updateCommentAnnotationContext(e,i,r){return Q(this,null,function*(){try{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_TRIGGERED,{annotationId:e,context:i,merge:r?.merge});let a=this.authService.getUser(),s=this.docService.getDocumentPaths();if(a&&s?.comment&&e){let m=this.getAnnotationById(e);if(typeof m=="object"&&(m=JSON.parse(JSON.stringify(m))),m||(m=yield this.commonDbService?.getData({feature:"comment",properties:{documentId:s?.documentId??"",organizationId:s?.organizationId??"",id:e}})),m?.annotationId){let p=i,h=JSON.parse(JSON.stringify(m.context||{}));r?.merge&&(p=I(I({},h),i));let _={context:JSON.parse(JSON.stringify(p||{}))};if(_?.context?.commentType==="manual"&&(_.commentType="manual",_.targetElement=null),m.context=_.context?vc(_.context):_.context,m.contextId=this.generateContextId(m.context),uo(h,p))return Promise.resolve("Comment annotation context is already updated.");{let{documentId:E,organizationId:D}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(m);return this.commonDbService.updateData({feature:"comment",properties:{id:e,documentId:E,organizationId:D},data:JSON.parse(JSON.stringify(m)),callback:()=>{this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_SUCCESS,{annotationId:e,context:_?.context,merge:r?.merge})}})}}else return this.analyticsService.trackEvent(X.Events.Comments.COMMENT_UPDATE_CONTEXT_FAILED,{annotationId:e,context:i,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,i,r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{if(this.authService.getUser()&&this.authService.isFeatureAllowed(ke.COMMENT)){if(i&&this.setLocationToCommentAnnotation(e),e?.targetElement?.xpath){let m=this.domService.getXPath(e.targetElement.xpath);if(m){let p=m.iterateNext();p&&(Do(p)||(e.targetElement=null))}}if(e?.type==="multiThread"){let m=JSON.parse(JSON.stringify(e));if(m.position=null,m.ghostComment=null,!m?.metadata?.documentId){m?.metadata||(m.metadata={});let _=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),_)}let{documentId:p,organizationId:h}=m?.metadata||{};r?this.commonDbService.updateData({feature:"multiThread",properties:{id:m.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))}):this.commonDbService.setData({feature:"multiThread",properties:{id:m.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}else{this.setSubscribedUsersDataInCommentAnnotation(e);let m=JSON.parse(JSON.stringify(e));m.position=null,m.ghostComment=null,m.lastUpdated=this.timestamp,m.status||(m.status=this.customFilterService.defaultStatus),delete m.resolved,delete m.inProgress,this.setLocationFromDocumentParams(m);let p=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);if(p&&JSON.parse(p).annotationId===m.annotationId&&window.localStorage.removeItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT),m?.multiThreadAnnotationId&&!s&&this.saveMultiThreadCommentAnnotation(m).then(h=>{}),m?.comments?.length){if(delete m?.isDraft,m?.multiThreadAnnotationId&&this.draftMultiThreadCommentAnnotationsByAnnotationId$.value[m?.multiThreadAnnotationId]&&this.saveMultiThreadCommentAnnotation(m),!m?.metadata?.documentId){m?.metadata||(m.metadata={});let D=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),D)}let{documentId:h,organizationId:_}=m?.metadata||{},E=a?I({annotationData:a?.commentAnnotation,targetAnnotationData:a?.targetComment,actionType:a?.actionType,notificationSource:"comment"},a?.otherFields||{}):null;r?this.commonDbService.updateData({feature:"comment",properties:{id:m.annotationId,documentId:h,organizationId:_},extraData:E,data:JSON.parse(JSON.stringify(m)),callback:D=>{a&&!D?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{})}}):this.commonDbService.setData({feature:"comment",properties:{id:m.annotationId,documentId:h,organizationId:_},extraData:E,data:JSON.parse(JSON.stringify(m)),callback:D=>{a&&!D?.firestoreAvailable&&this.updateNotificationsDatabase(a.commentAnnotation,a.targetComment,a.actionType,a.otherFields||{})}}),this.viewsService.setCommentAnnotationAsRead(m)}else this.draftCommentAnnotationsByAnnotationId$.next(T(I({},this.draftCommentAnnotationsByAnnotationId$.value),{[e.annotationId]:m}))}}}catch(m){this.loggingService.catch("Error in CommentService updateComment: ",m)}}getDocumentIdAndOrganizationIdFromCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromCommentAnnotation: ",i),{}}}getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in CommentService getDocumentIdAndOrganizationIdFromMultiThreadCommentAnnotation: ",i),{}}}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((i,r)=>Q(this,null,function*(){try{let a=this.domService.getSelectedAnnotationsMap(),s=this.authService.getUser(),m=[];Object.keys(a).forEach(p=>{let h=a[p];["tag","recorder","rewriter","arrow","area","multiThread"].includes(h.type)||s&&h.from&&(s?.isAdmin||h.from.userId===s.userId)&&m.push(h)}),m?.length?(this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DELETE_TRIGGERED,{triggerType:e,annotationId:m.map(p=>p.annotationId).join(),commentMode:this.getCommentMode()}),this.dialog.open(va,{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(tt(1)).subscribe(p=>{try{p?(m.forEach(h=>Q(this,null,function*(){yield this.deleteCommentPinAnnotation(h)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(_=>{this.domService.removeHighlightFromElement(_)}),i()},100)):i()}catch(h){r(h)}},p=>{r(p)})):i(),this.domService.resetSelectedAnnotationsMap(!0,"comment")}catch(a){this.loggingService.catch("Error in CommentService deleteCommentPinAnnotations: ",a),r(a)}}))}deleteCommentPinAnnotation(e,i){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(ke.COMMENT))if((i||e.comments?.length)&&this.updateNotificationsDatabase(e,null,Ut.DELETED),e.comments?.forEach(r=>{r.reactionAnnotationIds&&r.reactionAnnotationIds.forEach(a=>{this.deleteReaction(a)})}),e?.annotationId){this.analyticsService.trackEvent(X.Events.Comments.COMMENT_DELETED,{annotationId:e.annotationId,commentType:this.getCommentType(e),commentMode:this.getCommentMode()});let r=window.localStorage.getItem(j.LOCAL_STORAGE.SNIPPYLY_QUEUED_COMMENT);r&&JSON.parse(r).annotationId===e.annotationId&&window.localStorage.removeItem(j.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:m}=this.getDocumentIdAndOrganizationIdFromCommentAnnotation(e);return e?.isDraft?Promise.resolve():this.commonDbService.deleteData({feature:"comment",properties:{id:e.annotationId,documentId:s,organizationId:m}}).then(()=>{this.viewsService.deleteCommentAnnotationViews(e,{documentId:s,organizationId:m})})}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 i=e?.multiThreadAnnotationId;if(i){let r=this.docService.getDocumentPaths(),a=this.getMultiThreadAnnotationById(i);if(!a){let h=e?.metadata?.documentId||r?.documentId,_=e?.metadata?.organizationId||r?.organizationId;a=yield this.commonDbService?.getData({feature:"multiThread",properties:{documentId:h,organizationId:_,id:i}})}let s=this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[i];a&&delete a?.commentAnnotations?.[e.annotationId],s&&(delete s?.commentAnnotations?.[e.annotationId],Object.keys(s?.commentAnnotations||{}).length===0&&(delete this.draftMultiThreadCommentAnnotationsByAnnotationId$.value?.[i],this.draftMultiThreadCommentAnnotationsByAnnotationId$.next(this.draftMultiThreadCommentAnnotationsByAnnotationId$.value))),delete a.commentAnnotationsMap;let{documentId:m,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:m,organizationId:p}})):this.commonDbService.setData({feature:"multiThread",properties:{id:a?.annotationId,documentId:m,organizationId:p},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in CommentService removeCommentAnnotationFromMultiThread: ",i)}})}getAnnotationById(e,i){try{let r=this.commentAnnotationById$.value?.[e]||this.draftCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};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 i=this.commentAnnotationById$.value?.[e];if(i)return i.metadata}catch(i){this.loggingService.catch("Error in CommentService getBaseMetadataFromCommentAnnotationId: ",i)}}getMultiThreadAnnotationById(e,i){try{let r=this.multiThreadCommentAnnotationById$.value?.[e]||this.draftMultiThreadCommentAnnotationsByAnnotationId$?.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};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 i=this.multiThreadCommentAnnotationById$.value?.[e];if(i)return i.metadata}catch(i){this.loggingService.catch("Error in CommentService getBaseMetadataFromMultiThreadCommentAnnotationId: ",i)}}getElementRefByAnnotationId(e){try{let i=this.getAnnotationById(e);if(i){let r=i?.targetElement?.xpath;if(r)return{xpath:r}}return}catch(i){this.loggingService.catch("Error in CommentService getElementRefByAnnotationId: ",i);return}}scrollToCommentByAnnotationId(e){try{let i=this.getAnnotationById(e),r=document.getElementById(`comment-pin-container-${e}`);r||(r=document.querySelector(`[data-velt-id='${e}']`)),r||(r=document.querySelector(`${j.TAGS.VELT_COMMENT_TEXT}[${j.ATTRIBUTES.ANNOTATION_ID}="${e}"]`)),r&&(r.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),i&&(this.domService.getSelectedAnnotationsMap()[e]||this.domService.toggleAnnotationSelection(i)))}catch(i){this.loggingService.catch("Error in CommentService scrollToCommentByAnnotationId: ",i)}}selectCommentByAnnotationId(e,i){try{this.loggingService.log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");let r=this.getAnnotationById(e);r&&this.domService.toggleAnnotationSelection(r,void 0,void 0,!0)}catch(r){this.loggingService.catch("Error in CommentService selectCommentByAnnotationId: ",r)}}enableAddCommentMode(){try{this.authService.isFeatureAllowed(ke.COMMENT)?!this.authService.isPlanExpired()&&this.iamService.hasRoleAny([go.ADMIN,go.COMMENTER])?(this.analyticsService.trackEvent(X.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(X.Events.Comments.COMMENT_ADD_MODE_DISABLED,{commentMode:this.getCommentMode()}),this.addCommentMode$.next(!1)}addCommentModeChange(){return this.addCommentMode$.asObservable()}enablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{persistentCommentMode:!0}}),this.persistentCommentMode$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enablePersistentCommentMode: ",e)}}enableDeleteReplyConfirmation(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.COMMENT,config:{deleteReplyConfirmation:!1}}),this.deleteReplyConfirmation$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableDeleteReplyConfirmation: ",e)}}disablePersistentCommentMode(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.COMMENT,config:{commentIndex:e}}),this.showCommentIndex$.value===e)return;this.showCommentIndex$.next(e)}catch(i){this.loggingService.catch("Error in CommentService showCommentIndex: ",i)}}getShowCommentIndex(){return this.showCommentIndex$.asObservable()}enablePopoverMode(){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{popoverMode:!0}}),this.popoverMode$.value===!0)return;this.popoverMode$.next(!0),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{popoverMode:!1}}),this.popoverMode$.value===!1)return;this.popoverMode$.next(!1),this.analyticsService.trackEvent(X.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{textMode:!0}}),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{textMode:!1}}),this.analyticsService.trackEvent(X.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,i=!1,r=!1){try{this.domService.resetSelectedAnnotationsMap(),e?(document.querySelector(j.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(j.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?this.sidebarVisible$.next(e):this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),i&&this.sidebarOpenedByCustomTrigger$.next(!0)):(!this.sidebarOpenedByCustomTrigger$.value||i||r)&&(this.sidebarVisible$.next(e),this.sidebarOpenedByCustomTrigger$.next(!1)),e?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_OPENED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_CLOSED,{commentMode:this.getCommentMode()})}catch{this.loggingService.catch("Error in CommentService setSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}toggleSidebarVisibility(e=!1,i=!1){try{this.domService.resetSelectedAnnotationsMap(),this.sidebarVisible$.value?(!this.sidebarOpenedByCustomTrigger$.value||e||i)&&(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarOpenedByCustomTrigger$.next(!1)):(document.querySelector(j.TAGS.VELT_COMMENTS_SIDEBAR)||document.querySelector(j.TAGS.SNIPPYLY_COMMENTS_SIDEBAR)?(this.sidebarVisible$.next(!this.sidebarVisible$.value),this.sidebarVisible$.value?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"closed"}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_SIDEBAR_TOGGLED,{commentMode:this.getCommentMode(),action:"opened"})):this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`),e&&this.sidebarOpenedByCustomTrigger$.next(!0))}catch{this.loggingService.catch("Error in CommentService toggleSidebarVisibility: ",`<${j.TAGS.VELT_COMMENTS_SIDEBAR}> tag is not added.`)}}getSidebarVisibility$(){return this.sidebarVisible$.asObservable()}disableFloatingComments(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{floatingCommentDialog:!e}}),this.floatingCommentsEnabled$.value===!e)return;this.floatingCommentsEnabled$.next(!e)}catch(i){this.loggingService.catch("Error in CommentService disableFloatingComments: ",i)}}showFloatingComments$(){return this.floatingCommentsEnabled$.asObservable()}showFloatingComments(){return this.floatingCommentsEnabled$.value}setModeratorMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{moderatorMode:e}}),this.moderatorMode$.value===e)return;this.moderatorMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setModeratorMode: ",i)}}getModeratorMode(){return this.moderatorMode$.value}getModeratorMode$(){return this.moderatorMode$.asObservable()}setStreamMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{streamMode:e}}),this.streamMode$.value===e)return;this.streamMode$.next(e),e?this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STREAM_MODE_ENABLED,{commentMode:this.getCommentMode()}):this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STREAM_MODE_DISABLED,{commentMode:this.getCommentMode()})}catch(i){this.loggingService.catch("Error in CommentService setStreamMode: ",i)}}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:ke.COMMENT,config:{dialogOnHover:e}}),this.enableDialogOnHover$.value===e)return;this.enableDialogOnHover$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableDialogOnHover: ",i)}}getEnableDialogOnTargetElementClick(){return this.enableDialogOnTargetElementClick$.value}getEnableDialogOnTargetElementClick$(){return this.enableDialogOnTargetElementClick$.asObservable()}setEnableDialogOnTargetElementClick(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{dialogOnTargetElementClick:e}}),this.enableDialogOnTargetElementClick$.value===e)return;this.enableDialogOnTargetElementClick$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableDialogOnTargetElementClick: ",i)}}getEnablePriority(){return this.enablePriority$.value}getEnablePriority$(){return this.enablePriority$.asObservable()}setEnablePriority(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{priority:e}}),this.enablePriority$.value===e)return;this.enablePriority$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnablePriority: ",i)}}getEnableStatus(){return this.enableStatus$.value}getEnableStatus$(){return this.enableStatus$.asObservable()}setEnableStatus(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{status:e}}),this.getEnableStatus()===e)return;this.enableStatus$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableStatus: ",i)}}getEnableResolve(){return this.enableResolve$.value}getEnableResolve$(){return this.enableResolve$.asObservable()}setEnableResolve(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{resolveButton:e}}),this.getEnableResolve()===e)return;this.enableResolve$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableResolve: ",i)}}getEnableGhostComments(){return this.enableGhostComments$.value}getEnableGhostComments$(){return this.enableGhostComments$.asObservable()}enableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{ghostComments:!0}}),this.enableGhostComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableGhostComments: ",e)}}disableGhostComments(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.COMMENT,config:{ghostCommentsIndicator:!0}}),this.enableGhostCommentsMessage$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableShowGhostCommentsMessage: ",e)}}disableGhostCommentsMessage(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.COMMENT,config:{autoCategorize:e}}),this.enableAutoCategorize$.value===e)return;this.enableAutoCategorize$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setEnableAutoCategorize: ",i)}}getEnableAutoCategorize(){return this.enableAutoCategorize$.value}getEnableAutoCategorize$(){return this.enableAutoCategorize$.asObservable()}setCommentContainerDarkMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{darkMode:e}}),this.commentContainerDarkMode$.value===e)return;this.commentContainerDarkMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentContainerDarkMode: ",i)}}getCommentContainerDarkMode(){return this.commentContainerDarkMode$.asObservable()}getSuggestionMode(){return this.suggestionMode$.value}getSuggestionMode$(){return this.suggestionMode$.asObservable()}setSuggestionMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{suggestionMode:e}}),this.getSuggestionMode()===e)return;this.suggestionMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setSuggestionMode: ",i)}}getMobileMode(){return this.mobileMode$.value}getMobileMode$(){return this.mobileMode$.asObservable()}setMobileMode(e){try{if(this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{mobileMode:e}}),this.getMobileMode()===e)return;this.mobileMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setMobileMode: ",i)}}enableInlineCommentMode(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setTotalMediaLength: ",i)}}getTotalMediaLength(){return this.totalMediaLength$.value}getTotalMediaLength$(){return this.totalMediaLength$.asObservable()}enableSidebarUrlNavigation(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{detectionStrategy:e}}),this.detectionStrategy$.value===e)return;this.detectionStrategy$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setDetectionStrategy: ",i)}}getDetectionStrategy(){return this.detectionStrategy$.value}getDetectionStrategy$(){return this.detectionStrategy$.asObservable()}enableSidebarButtonOnCommentDialog(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService addBubbleCommentAnnotationIds: ",i)}}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(i){this.loggingService.catch("Error in CommentService removeBubbleCommentAnnotationIds: ",i)}}enableSignInButton(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{signInButton:e}}),this.enableSignInButton$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableSignInButton: ",i)}}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:ke.COMMENT,config:{upgradeButton:e}}),this.enableUpgradeButton$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableUpgradeButton: ",i)}}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:ke.COMMENT,config:{attachments:e}}),this.enableAttachment$.value===e)return;this.enableAttachment$.next(e)}catch(i){this.loggingService.catch("Error in CommentService enableAttachment: ",i)}}getEnableAttachment$(){return this.enableAttachment$.asObservable()}setAllowedRecordings(e){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{recordings:e}}),e?.includes("all")?this.allowedRecordings$.next(["audio","video","screen"]):e?.includes("none")?this.allowedRecordings$.next([]):this.allowedRecordings$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setAllowedRecordings: ",i)}}getAllowedRecordings(){return this.allowedRecordings$.value}getAllowedRecordings$(){return this.allowedRecordings$.asObservable()}enableReactions(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{privateCommentMode:!0}}),this.privateCommentMode$.value===!0)return;this.iamService.isUserAdmin$().pipe(tt(1)).subscribe(e=>{e?(this.privateCommentMode$.next(!0),this.analyticsService.trackEvent(X.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:ke.COMMENT,config:{privateCommentMode:!1}}),this.privateCommentMode$.value===!1)return;this.privateCommentMode$.next(!1),this.analyticsService.trackEvent(X.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()}enableScrollToComment(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.COMMENT,config:{deviceInfo:e}}),this.showScreenSizeInfo$.value===e)return;this.showScreenSizeInfo$.next(e)}catch(i){this.loggingService.catch("Error in CommentService showScreenSizeInfo: ",i)}}getShowScreenSizeInfo$(){return this.showScreenSizeInfo$.asObservable()}enableUserMentions(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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()}enableDeleteOnBackspace(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{unreadIndicatorMode:e}}),this.unreadIndicatorMode$.value===e)return;this.unreadIndicatorMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setUnreadIndicatorMode: ",i)}}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:ke.COMMENT,config:{composerMode:e}}),this.composerMode$.value===e)return;this.composerMode$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setComposerMode: ",i)}}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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{excludeLocationIdsFromSidebar:e}}),this.excludeLocationIdsFromSidebar$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setExcludeLocationIdsFromSidebar: ",i)}}getExcludeLocationIdsFromSidebar(){return this.excludeLocationIdsFromSidebar$.value}getExcludeLocationIdsFromSidebar$(){return this.excludeLocationIdsFromSidebar$.asObservable()}enableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{multiThread:!0}}),this.multiThread$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableMultiThread: ",e)}}disableMultiThread(){try{this.analyticsService.setFeatureConfig({feature:ke.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()}enableShortUserName(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;"),this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setCommentSidebarFilters: ",i)}}getCommentSidebarFilters(){return this.commentSidebarFilters$.value}getCommentSidebarFilters$(){return this.commentSidebarFilters$.asObservable()}setCommentSidebarSystemFiltersOperator(e){try{this.commentSidebarSystemFiltersOperator$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentSidebarSystemFiltersOperator: ",i)}}getCommentSidebarSystemFiltersOperator(){return this.commentSidebarSystemFiltersOperator$.value}getCommentSidebarSystemFiltersOperator$(){return this.commentSidebarSystemFiltersOperator$.asObservable()}enableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{commentPinHighlighter:!0}}),this.domService.enableCommentPinHighlighter()}catch(e){this.loggingService.catch("Error in CommentService enableCommentPinHighlighter: ",e)}}disableCommentPinHighlighter(){try{this.analyticsService.setFeatureConfig({feature:ke.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(i){this.loggingService.catch("Error in CommentService setCustomReactions: ",i)}}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(i){return this.loggingService.catch("Error in CommentService getCommentType: ",i),""}}getCommentAnnotationAvailableOnXPath(e,i,r){try{return this.commentAnnotationById$.pipe(he(()=>this.draftCommentAnnotationsByAnnotationId$),he(a=>(!r&&i&&(r=dr(i,["id","data-id"])),se(T(I({},a),{element:r})))),he(a=>this.getLocations$().pipe(ce(s=>T(I({},a),{locationIds:s})))),ce(({locationIds:a,element:s})=>{let m=[],p=this.docService.getDocumentPaths();if(p?.documentId){let h=this.docService.getAdditionalDocumentIdFromElement(s),_=h?this.docService.generateDocumentId(h):p?.documentId,E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:p?.organizationId,documentId:_||""});if(E)for(let D of E)(i&&D?.targetElementId===i||D?.targetElement?.xpath===e)&&a?.includes(D?.locationId)&&m.push(D)}return m.length?m:null}))}catch(a){return this.loggingService.catch("Error in CommentService isCommentAnnotationAvailableOnXPath: ",a),se(null)}}getCommentAnnotationsByContext({context:e,contextOptions:i,element:r}){try{return this.commentAnnotationById$.pipe(he(()=>this.draftCommentAnnotationsByAnnotationId$),ce(()=>{let a=[],s=this.docService.getDocumentPaths(),m=vc(e),p=this.generateContextId(m);if(s?.documentId){let h=this.docService.getAdditionalDocumentIdFromElement(r??null),_=h?this.docService.generateDocumentId(h):s?.documentId,E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:s?.organizationId,documentId:_||""});if(E)for(let D of E)i?.partialMatch?V6(D?.context,m)&&a.push(D):p&&D?.contextId===p&&a.push(D)}return a.length?a:null}))}catch(a){return this.loggingService.catch("Error in CommentService getCommentAnnotationsByContext: ",a),se(null)}}getCommentAnnotationByAnnotationId(e){try{return this.commentAnnotationById$.pipe(ce(()=>this.getAnnotationById(e)),he(i=>i?i?.iam?.accessMode===Qi.PRIVATE?this.iamService.isUserAdmin$().pipe(ce(r=>{if(r)return i})):se(i):se(i)),he(i=>i?this.filterCommentsUsingSidebarSettings(i).pipe(ce(r=>{if(r)return r})):se(i)))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationByAnnotationId: ",i),se(void 0)}}getMultiThreadCommentAnnotationByAnnotationId(e){return this.multiThreadCommentAnnotationById$.pipe(ce(()=>this.getMultiThreadAnnotationById(e)))}getCommentBubbleElement(e){try{let i=document.querySelector(`${j.TAGS.VELT_COMMENT_BUBBLE}[${j.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`);return i||(i=document.querySelector(`${j.TAGS.SNIPPYLY_COMMENT_BUBBLE}[${j.ATTRIBUTES.VELT_ANNOTATION_IDS}*="${e?.annotationId}"]`)),i}catch(i){return this.loggingService.catch("Error in CommentService getCommentBubbleElement: ",i),null}}getCommentAnnotationsBySectionId(e){try{return this.commentAnnotationById$.pipe(he(()=>this.docService.getDocumentPaths$().pipe(ce(i=>({documentPaths:i,sectionId:e})))),he(i=>{let r=dr(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(ce(m=>{let h=Object.values(m||{}).find(_=>_.locationId===s||a?.id&&_.location.id===a.id);return T(I({},i),{additionalLocation:h,locationOnElement:!!a})}))}}return se(T(I({},i),{additionalLocation:null,element:r}))}),he(i=>i?.locationOnElement?se(i):this.docService.getLocation$().pipe(ce(r=>T(I({},i),{location:r})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s,element:m})=>{let p=null;if(this.authService.getUser()&&i?.documentId){let _=this.docService.getAdditionalDocumentIdFromElement(m),E=_?this.docService.generateDocumentId(_):i?.documentId,D=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:i?.organizationId,documentId:E||""});if(D){p=[];let L=_m(e);s?a?.location?.id?L=_m([a?.location?.id,e]):a?.locationId&&(L=_m([a?.locationId+"",e])):r&&(r?.location?.id?L=_m([r?.location?.id,e]):r?.locationId&&(L=_m([r?.locationId+"",e])));for(let H of D)H?.multiThreadAnnotationId===L?p.push(H):(H?.targetInlineCommentElementId===e||H?.targetElementId===e)&&(s?a&&$u({location:a?.location,locationId:a?.locationId},{location:H.location,locationId:H.locationId})&&p.push(H):r?$u({location:r?.location,locationId:r?.locationId},{location:H.location,locationId:H.locationId})&&p.push(H):H?.locationId||p.push(H))}}return p}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",i),se(null)}}getCommentAnnotationsByMultiThreadAnnotationId(e){try{return this.commentAnnotationById$.pipe(he(()=>this.multiThreadCommentAnnotationById$),he(()=>this.docService.getDocumentPaths$().pipe(ce(i=>({documentPaths:i,multiThreadAnnotationId:e})))),ce(({documentPaths:i,location:r,additionalLocation:a,locationOnElement:s})=>{let m=null;if(i?.documentId){let p=this.getMultiThreadAnnotationById(e),{documentId:h,organizationId:_}=p?.metadata||{documentId:i?.documentId,organizationId:i?.organizationId},E=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:_,documentId:h||""});if(E){m=[];for(let D of E)D?.multiThreadAnnotationId===e&&p?.commentAnnotations?.[D?.annotationId]&&m.push(D)}}return m}))}catch(i){return this.loggingService.catch("Error in CommentService getCommentAnnotationsBySectionId: ",i),se(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(i){return this.loggingService.catch("Error in CommentService isElementInsideAllowedElements: ",i),!1}}getNearestAllowedElement(e){try{let i=this.domService.getListedElements({elementIds:this.allowedElementIds$.value,elementClassNames:this.allowedElementClassNames$.value,elementQuerySelectors:this.allowedElementQuerySelectors$.value});if(i?.length){for(let r=0;r<i.length;r++){let a=i[r];if(e.contains(a))return a}return null}return null}catch(i){return this.loggingService.catch("Error in CommentService getNearestAllowedElement: ",i),null}}isElementInsideManualCommentContainer(e){try{return this.domService.isElementInsideParentWithAttribute(e,j.ATTRIBUTES.VELT_MANUAL_COMMENT_CONTAINER,"true")}catch(i){return this.loggingService.catch("Error in CommentService isElementInsideManualCommentContainer: ",i),!1}}saveComment(e,i){return Q(this,null,function*(){try{i?.annotation&&(e=i.annotation),e&&(e=JSON.parse(JSON.stringify(e)));let r=this.originalCommentAnnotationsByDocumentId$.value[e.annotationId];if(r?.comments?.length){let _=JSON.parse(JSON.stringify(e.comments||[]));e.comments=[],r.comments?.forEach(E=>{let D=_.find(L=>L.commentId===E.commentId);D?e.comments.push(D):e.comments.push(E)})}e.comments||(e.comments=[]);let a=!1,s=!1,m;switch(i.type){case Ut.NEWLY_ADDED:case Ut.ADDED:if(!i.updatedComment)break;e?.comments?.length||(s=!0),e.comments.push(i.updatedComment);let _=i?.assigned||void 0;m={commentAnnotation:e,targetComment:i.updatedComment,actionType:i.type,otherFields:{assigned:_}};break;case Ut.APPROVED:e.approved=!0,m={commentAnnotation:e,targetComment:null,actionType:Ut.APPROVED};break;case Ut.ASSIGNED:e.assignedTo=i.assignedTo,m={commentAnnotation:e,targetComment:null,actionType:Ut.ASSIGNED};break;case Ut.UPDATED:if(!i.updatedComment)break;let E=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);if(E>=0){e.comments[E]=i.updatedComment,e.comments[E].status=Ut.UPDATED;let ue=i?.assigned||void 0;m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.UPDATED,otherFields:{assigned:ue}}}break;case Ut.REACTION_ADDED:if(!i.updatedComment)break;let D=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);D>=0&&(e.comments[D]=i.updatedComment,e.comments[D].status=Ut.UPDATED,m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.REACTION_ADDED});break;case Ut.REACTION_DELETED:if(!i.updatedComment)break;let L=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);L>=0&&(e.comments[L]=i.updatedComment,e.comments[L].status=Ut.UPDATED,m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.REACTION_DELETED});break;case Ut.STATUS_CHANGED:e.status.type==="terminal"&&(this.domService.resetSelectedAnnotationsMap(!1,"comment"),e.resolvedByUserId=this.authService.getUser()?.userId),m={commentAnnotation:e,targetComment:null,actionType:Ut.STATUS_CHANGED,otherFields:{oldStatus:i.oldStatus,newStatus:i.newStatus}};break;case Ut.PRIORITY_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.PRIORITY_CHANGED,otherFields:{oldPriority:i.oldPriority,newPriority:i.newPriority}};break;case Ut.ACCESS_MODE_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.ACCESS_MODE_CHANGED,otherFields:{oldAccessMode:i.oldAccessMode,newAccessMode:i.newAccessMode}};break;case Ut.CUSTOM_LIST_CHANGED:m={commentAnnotation:e,targetComment:null,actionType:Ut.CUSTOM_LIST_CHANGED,otherFields:{oldCustomList:i.oldCustomList,newCustomList:i.newCustomList}};break;case Ut.SUBSCRIBED:m={commentAnnotation:e,targetComment:null,actionType:Ut.SUBSCRIBED};break;case Ut.UNSUBSCRIBED:m={commentAnnotation:e,targetComment:null,actionType:Ut.UNSUBSCRIBED};break;case Ut.DELETED:if(!i.updatedComment)break;let H=e.comments.findIndex(ue=>ue.commentId===i.updatedComment.commentId);if(H>=0){if((H===0&&this.deleteThreadWithFirstComment$.value!==!1||this.deleteReplyConfirmation$.value)&&!i.skipDeleteThreadConfirmation){let Le={};if(this.deleteReplyConfirmation$.value&&(H!==0||this.deleteThreadWithFirstComment$.value===!1)?Le={title:"Delete comment?",message:"This selected comment will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.commentContainerDarkMode$.value,variant:"reply"}:Le={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(va,{data:Le}).afterClosed().toPromise()))return}let ue=e.comments.splice(H,1),be=e.metadata;ue?.length&&ue.forEach(Le=>{Le?.attachments&&Le.attachments.forEach(qe=>{let Re={attachmentId:qe.attachmentId,organizationId:be?.organizationId??null,documentId:be?.documentId??null,folderId:be?.folderId??null,commentAnnotationId:e.annotationId,apiKey:be?.apiKey??null};this.deleteAttachment({attachment:qe,metadata:Re})}),Le?.reactionAnnotationIds&&Le.reactionAnnotationIds.forEach(qe=>{this.deleteReaction(qe)})})}e.status=this.customFilterService.defaultStatus,H===0&&this.deleteThreadWithFirstComment$.value!==!1||e.comments?.length===0?a=!0:(this.analyticsService.trackEvent(X.Events.Comments.COMMENT_THREAD_DELETED,{annotationId:e.annotationId,commentThreadId:i.updatedComment.commentId,commentMode:this.getCommentMode()}),m={commentAnnotation:e,targetComment:i.updatedComment,actionType:Ut.DELETED});break;case Ut.ACCEPTED:let K={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Ut.ACCEPTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:zn(e)};this.commentAccepted$.next(K),m={commentAnnotation:e,targetComment:null,actionType:Ut.ACCEPTED};break;case Ut.REJECTED:let oe={annotationId:e.annotationId,actionUser:this.authService.getUser(),actionType:Ut.REJECTED,replaceContentHtml:e?.comments?.length?e?.comments[0]?.replaceContentHtml:void 0,replaceContentText:e?.comments?.length?e?.comments[0]?.replaceContentText:void 0,annotation:zn(e)};this.commentRejected$.next(oe),this.domService.resetSelectedAnnotationsMap(),m={commentAnnotation:e,targetComment:null,actionType:Ut.REJECTED};break;default:break}e.resolvedByUserId&&e.status.type!=="terminal"&&(e.resolvedByUserId=null),i?.updatedComment?.isDraft&&(m=void 0),a?(this.deleteCommentPinAnnotation(e,!0),this.domService.resetSelectedAnnotationsMap(!1,"comment")):(s&&e.comments?.length&&this.enableAutoCategorize$?.value&&this.setCommentCategory(e),this.updateComment(e,!1,!1,m,!0),e?.multiThreadAnnotationId&&(i.type===Ut.ADDED||i.type===Ut.NEWLY_ADDED)&&e.comments?.length===1?setTimeout(()=>{this.domService.resetSelectedAnnotationsMap(!1,"comment")},100):this.domService.updateSelectedAnnotationInMap([e]));let p=this.getCustomPinById(e.annotationId),h={type:i.type,annotation:zn(e),targetAnnotationId:e.annotationId,targetCommentId:i.updatedComment?.commentId,updateContext:(_,E)=>{this.updateCommentAnnotationContext(e.annotationId,_,E)}};p!==void 0&&(h.element=p),delete h?.annotation?.pageInfo,delete h?.annotation?.targetElement,delete h?.annotation?.targetTextRange,h?.type===Ut.DELETED&&(e.comments?.length||(h.annotation=null)),a||this.commentUpdated$.next(h)}catch(r){this.loggingService.catch("Error in CommentService saveComment: ",r)}})}attachComment(e,i=[],r,a){try{this.loggingService.log("%c[WB] Calling FUNCTION: attachComment","color: green;");let s;if(e){let m=dr(e,i);m&&(s={targetElement:{xpath:this.domService.getXPath(m),topPercentage:50,leftPercentage:90},targetElementId:e})}(s||r)&&this.addComment(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,void 0,void 0,a,void 0,void 0,void 0,r)}catch(s){this.loggingService.catch("Error in CommentService attachComment: ",s)}}updateNotificationsDatabase(e,i,r,a={}){try{let s=I({annotationData:e,targetAnnotationData:i,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 i=null;if(e?.ghostComment)!i&&e.ghostComment?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e.ghostComment?.targetElement?.xpath&&(i=this.domService.getElementFromXPath(e.ghostComment?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null));else{let r=!1;!i&&e?.targetElement?.xpath&&(r=this.domService.isXpathWithId(e?.targetElement?.xpath),i=this.domService.getElementFromXPath(e?.targetElement?.xpath),i&&!this.domService.isElementVisible(i)&&(i=null)),r||(!i&&e?.targetElement?.cfXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.cfXpath),i&&!this.domService.isElementVisible(i)&&(i=null)),!i&&e?.targetElement?.fXpath&&(i=this.domService.getElementFromXPath(e?.targetElement?.fXpath),i&&!this.domService.isElementVisible(i)&&(i=null)))}return i&&!Do(i)&&(i=null),i}catch(i){return this.loggingService.catch("Error in CommentService getElementFromComment: ",i),null}}getElementFromComments(e){try{let i=[],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;!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&&!Do(r)&&(r=null),e?.targetElementId&&(i=Array.from(Zoe(e.targetElementId,["id","data-id"]))),r&&!i.includes(r)&&i.push(r),i}catch(i){return this.loggingService.catch("Error in CommentService getElementFromComment: ",i),[]}}getGhostCommentTargetElement(e){try{let i=e.targetElement?.fXpath||e.targetElement?.xpath,r=null;if(i)for(;!r&&i;)r=this.domService.getElementFromXPath(i),r&&(!this.domService.isElementVisible(r)||!Do(r))&&(r=null),r||(i=i.substring(0,i.lastIndexOf("/")));return i==="/"&&(i=""),i?{xpath:i,topPercentage:e?.targetElement?.topPercentage||0,leftPercentage:e?.targetElement?.leftPercentage||0}:null}catch(i){return this.loggingService.catch("Error in CommentService getGhostCommentTargetElement: ",i),null}}setGhostCommentMessage(e){try{if(e?.ghostComment){e.ghostComment.message="Original content not found.",e.ghostComment.type=Ws.ELEMENT_DELETED;let i=e?.pageInfo?.deviceInfo?.deviceType,r=new ei().getDeviceType();i&&i!==r&&(e.ghostComment.type=Ws.DIFFERENT_DEVICE,e.ghostComment.message=`Original comment was added on ${i}.`,[Qo.MOBILE,Qo.TABLET].includes(i)&&[Qo.MOBILE,Qo.TABLET].includes(r)||[Qo.DESKTOP,Qo.MONITOR].includes(i)&&[Qo.DESKTOP,Qo.MONITOR].includes(r)?e.ghostComment.isSameGroup=!0:e.ghostComment.isSameGroup=!1)}}catch(i){this.loggingService.catch("Error in CommentService setGhostCommentMessage: ",i)}}addAnnotationToGhostCommentAnnotationMap(e){try{let i=this.ghostCommentAnnotationMap$.value||{},r=i[e?.annotationId]||{};uo(e.ghostComment,r)||(i[e?.annotationId]=e.ghostComment,this.ghostCommentAnnotationMap$.next(i))}catch(i){this.loggingService.catch("Error in CommentService addAnnotationToGhostCommentAnnotationMap: ",i)}}removeAnnotationFromGhostCommentAnnotationMap(e){try{let i=this.ghostCommentAnnotationMap$.value||{};i[e?.annotationId]&&(delete i[e?.annotationId],this.ghostCommentAnnotationMap$.next(i))}catch(i){this.loggingService.catch("Error in CommentService removeAnnotationFromGhostCommentAnnotationMap: ",i)}}getGhostCommentAnnotationMap$(){return this.ghostCommentAnnotationMap$.asObservable()}getGhostCommentAnnotationMap(){return this.ghostCommentAnnotationMap$.value||{}}getUnreadCommentsMap$(){return this.unreadCommentsMap$.asObservable().pipe(qt(Vi))}getUnreadCommentsMap(){return this.unreadCommentsMap$.value}getUnreadCommentCountByAnnotationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>i?{count:i[e]||0}:null))}getUnreadCommentAnnotationCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ce(e=>e?{count:Object.keys(e??{}).length||0}:null))}getUnreadCommentCountOnCurrentDocument$(){return this.getUnreadCommentsMap$().pipe(ce(e=>e?{count:Object.values(e).reduce((r,a)=>r+a,0)}:null))}getUnreadCommentCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>{if(i){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),a&&Object.keys(i).forEach(m=>{a?.find(h=>h.annotationId===m)?.location?.id===e&&(s+=i[m])})),{count:s}}else return null}))}getUnreadCommentAnnotationCountByLocationId$(e){return this.getUnreadCommentsMap$().pipe(ce(i=>{if(i){let r=this.docService.getDocumentPaths(),a=[],s=0;return r?.documentId&&(a=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:r?.organizationId,documentId:r?.documentId}),Object.keys(i).forEach(m=>{i[m]&&a?.find(h=>h.annotationId===m)?.location?.id===e&&(s+=1)})),{count:s}}else return null}))}setCommentAnnotationsAsRead(e){try{for(let i of e)this.viewsService.setCommentAnnotationAsRead(i)}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsRead: ",i)}}setCommentAnnotationsAsResolved(e){try{let i=this.customFilterService.resolvedStatus;if(i){for(let r of e)if(i?.id!==r?.status?.id){let a=JSON.parse(JSON.stringify(r||{}));r.status=this.customFilterService.resolvedStatus;let s={annotation:r,type:Ut.STATUS_CHANGED,oldStatus:a.status,newStatus:this.customFilterService.resolvedStatus};this.saveComment(r,s)}}}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsAsResolved: ",i)}}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:ke.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:ke.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(i){this.loggingService.catch("Error in CommentService setPinCursorImage: ",i)}}getPinCursorImage$(){return this.commentPinCursorImage$.asObservable()}getPinCursorImage(){return this.commentPinCursorImage$.value}setCommentAnnotationsFromCommentsContainer(e){try{this.commentAnnotationsFromCommentsContainer$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCommentAnnotationsFromCommentsContainer: ",i)}}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((i,r)=>{let a=this.domService.getLastDocumentClick()?.target,s=e?.location||this.docService.getAdditionLocationFromElement(a);if(s?.id){let m=this.docService.getLocationByClientLocationId(s.id);m&&(s=m)}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,m=>{i(m)}),this.addCommentMode$?.value&&!this.persistentCommentMode$?.value&&this.disableAddCommentMode()})}catch(i){return this.loggingService.catch("Error in CommentService addManualComment: ",i),null}})}getCommentUrl(e){try{return e?.pageInfo?.commentUrl?e.pageInfo.commentUrl:(e?.pageInfo||(e.pageInfo=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.commentUrl=this.generateCommentUrl(e),this.updateComment(e),e.pageInfo?.commentUrl)}catch(i){this.loggingService.catch("Error in CommentService getCommentUrl: ",i);return}}uploadFile(e,i){let r=`${j.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${j.FIREBASE_PARTIAL_PATH_COMMENT}/${i.annotationId}`;this.documentPaths?.organizationId&&(r=`${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentPaths?.documentId}/${j.FIREBASE_PARTIAL_PATH_COMMENT}/${i.annotationId}`);let a={organizationId:i.metadata?.clientOrganizationId??null,documentId:i.metadata?.clientDocumentId??null,commentAnnotationId:i.annotationId,apiKey:i.metadata?.apiKey??null,folderId:i.metadata?.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:i}){return this.storageService.deleteAttachment({attachment:e,metadata:i,useAttachmentResolver:this.attachmentResolverService.attachmentDataProviderAvailable()})}deleteReaction(e){try{this.reactionService.deleteReactionPinAnnotation(e)}catch(i){this.loggingService.catch("Error in CommentService deleteReaction: ",i)}}generateCommentUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.COMMENT_ID),i.searchParams.append(j.URL_PARAMS.COMMENT_ID,e.annotationId),i.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(i){this.loggingService.catch("Error in CommentService setCustomStatuses: ",i)}}getCustomStatusesShown$(){return this.customStatusesShown$.asObservable()}getCustomStatusesShown(){return this.customStatusesShown$.value}setCustomPriorities(e){try{if(e===void 0)return;this.customFilterService.setCustomPriorityFilters(e)}catch(i){this.loggingService.catch("Error in CommentService setCustomPriorities: ",i)}}setCustomCategories(e){try{if(e===void 0)return;this.customFilterService.setCustomCategories(e)}catch(i){this.loggingService.catch("Error in CommentService setCustomCategories: ",i)}}addCommentOnSelectedText(){try{let e=this.authService.getUser();if(this.textCommentMode$.value&&e&&!(e?.isReadOnly||e?.isAnonymous)&&this.authService.isFeatureAllowed(ke.COMMENT)){let i=this.domService.getRange();if(window.getSelection()?.toString()&&!Y6()&&i?.commonAncestorContainer&&this.isElementInsideAllowedElements(i.commonAncestorContainer)&&!wd(i.commonAncestorContainer)){let r=i?this.domService.getTargetTextRangeFromSelectionRange(i):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 i;if(e){let r=e?.closest(`[${j.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID}]`);if(r){let a=r.getAttribute(j.ATTRIBUTES.VELT_TARGET_INLINE_COMMENT_ELEMENT_ID);a&&(i={},i.targetInlineCommentElementId=a,r.getAttribute(j.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)&&(i.config=JSON.parse(r.getAttribute(j.ATTRIBUTES.VELT_INLINE_COMMENT_SECTION_CONFIG)||"{}")))}}return i}catch(i){this.loggingService.catch("Error in CommentService getInlineCommentSectionConfig: ",i)}}createCustomListDataOnAnnotation(e){try{if(e===void 0)return;this.customChipDropdownData$.next(e)}catch(i){this.loggingService.catch("Error in CommentService createCustomListDataOnAnnotation: ",i)}}getCustomChipDropdownData$(){return this.customChipDropdownData$.asObservable()}getCustomChipDropdownData(){return this.customChipDropdownData$.value}setSubscribedUsersDataInCommentAnnotation(e){try{let i={},r=e?.unsubscribedUsers||{},a={};if(e?.subscribedUsers&&Object.keys(e.subscribedUsers||{}).forEach(s=>{let m=e.subscribedUsers?.[s];m?.type==="manual"&&(i[s]=m)}),e?.assignedTo?.userId){let s=Pt(e?.assignedTo?.userId);r[s]||i[s]?.type!=="manual"&&(i[s]={user:e?.assignedTo,type:"auto"})}e?.comments?.filter(s=>!s?.isDraft)?.forEach(s=>{if(s?.from?.userId){let m=Pt(s?.from?.userId);r[m]||i[m]?.type!=="manual"&&(i[m]={user:s?.from,type:"auto"})}s?.to?.forEach(m=>{if(m?.userId){let p=Pt(m.userId);r[p]||i[p]?.type!=="manual"&&(i[p]={user:m,type:"auto"})}}),s?.toOrganizationUserGroup?.forEach(m=>{if(m?.groupId)a[m?.groupId]={type:"auto"};else if(m?.clientGroupId){let p=Pt(m.clientGroupId);a[p]={type:"auto"}}})}),e.subscribedUsers=i,e.unsubscribedUsers=r,e.subscribedGroups=a}catch(i){this.loggingService.catch("Error in CommentService setSubscribeUsersDataInCommentAnnotation: ",i)}}getCopyLink$(){return this.copyLink$.asObservable()}setCopyLink(e){try{this.copyLink$.next(e)}catch(i){this.loggingService.catch("Error in CommentService setCopyLink: ",i)}}getCommentAnnotationById(e){return this.commentAnnotationById$.pipe(he(()=>{let{annotationId:i,documentId:r}=e;if(r){let a=yn(r).toString();return this.getDataCommentAnnotationsFromDocumentId(a).pipe(ce(s=>s.find(p=>p.annotationId===i)||null))}else{let a=this.docService.getDocumentPaths();if(a?.documentId){let s=this.getCommentAnnotationsByOrganizationIdAndDocumentId({organizationId:a?.organizationId,documentId:a?.documentId});if(s){let m=s.find(p=>p.annotationId===i);return se(m||null)}}}return se(null)}),jn(i=>(this.loggingService.catch("Error in CommentService getCommentAnnotationById: ",i),se(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(ce(i=>i?.data),ce(i=>{let r=[];return i&&(r=Object.values(i??{}).filter(a=>typeof a=="object")),r})):se([])}enableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:ke.COMMENT,config:{collapsedComments:!0}}),this.collapsedComments$.next(!0)}catch(e){this.loggingService.catch("Error in CommentService enableCollapsedComments: ",e)}}disableCollapsedComments(){try{this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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,i,r,a){try{this.sidebarCustomActionEventData$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a})}catch(s){this.loggingService.catch("Error in CommentService emitOnSidebarCustomAction: ",s)}}getSidebarCustomActionEventData(){return this.sidebarCustomActionEventData$.asObservable()}setCommentSidebarData(e,i){try{this.sidebarData$.next({data:e,options:i})}catch(r){this.loggingService.catch("Error in CommentService setCommentSidebarData: ",r)}}getSidebarCustomData(){return this.sidebarData$.asObservable()}setSidebarCustomActionEventDataAllChanges(e,i,r,a){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataAllChanges$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a});let s=yield this.metadataService.getGlobalMetadata(),m={buttonContext:{selections:this.buttonService.buttonToggleMapValue()},unreadCommentAnnotationsMap:r,commentAnnotations:i,systemFilteredAnnotations:a,metadata:s};this.commentActionsService?.triggerAction(Zi.COMMENT_SIDEBAR_DATA_UPDATE,m)}catch(s){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataAllChanges: ",s)}})}setSidebarCustomActionEventDataOnInit(e,i,r,a){return Q(this,null,function*(){try{this.sidebarCustomActionEventDataOnInit$.next({actions:e,data:i,unreadDataMap:r,systemFilteredData:a});let m={metadata:yield this.metadataService.getGlobalMetadata(),unreadCommentAnnotationsMap:r,commentAnnotations:i,systemFilteredAnnotations:a,buttonContext:{selections:this.buttonService.buttonToggleMapValue()}};this.commentActionsService?.triggerAction(Zi.COMMENT_SIDEBAR_DATA_INIT,m)}catch(s){this.loggingService.catch("Error in CommentService setSidebarCustomActionEventDataOnInit: ",s)}})}getSidebarCustomActionEventDataAllChanges(){return this.sidebarCustomActionEventDataAllChanges$.asObservable()}getSidebarCustomActionEventDataOnInit(){return this.sidebarCustomActionEventDataOnInit$.asObservable()}getSidebarCustomActionEventDataOnInitValue(){return this.sidebarCustomActionEventDataOnInit$.getValue()}setTransformContext(e){try{e?uo(this.transformContext$.value,e)||this.transformContext$.next(e):this.transformContext$.next(null)}catch(i){this.loggingService.catch("Error in CommentService setTransformContext: ",i)}}getTransformContext$(){return this.transformContext$.asObservable()}getTransformContext(){return this.transformContext$.value}enableSidebarCustomActions(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.COMMENT,config:{resolveStatusAccessAdminOnly:!1}}),this.resolveStatusAccessAdminOnly$.value===!1)return;this.resolveStatusAccessAdminOnly$.next(!1)}catch(e){this.loggingService.catch("Error in CommentService disableResolveStatusAccessAdminOnly: ",e)}}getResolveStatusAccessAdminOnly$(){return this.resolveStatusAccessAdminOnly$.asObservable()}getResolveStatusAccessAdminOnly(){return this.resolveStatusAccessAdminOnly$.value}enableSvgAsImg(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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 i=null;e&&(i={},e.forEach(r=>{r?.annotationId&&i&&(i[r.annotationId]=r)})),uo(this.commentsFromSidebarMap$.value,i)||this.commentsFromSidebarMap$.next(i)}catch(i){this.loggingService.catch("Error in CommentService setCommentsFromSidebarMap: ",i)}}getCommentsFromSidebarMap$(){return this.commentsFromSidebarMap$.asObservable()}getCommentsFromSidebarMap(){return this.commentsFromSidebarMap$.value}filterCommentsUsingSidebarSettings(e){try{let i=Array.isArray(e),r;return i?r=e||[]:e?r=[e]:r=[],this.getFilterCommentsOnDom$().pipe(he(a=>a?r.length===0?se(e):this.getCommentsFromSidebarMap$().pipe(ce(s=>{if(!s)return e;let m=r.filter(p=>p?.isDraft||!!s[p?.annotationId]);return i?m:m.length>0?m[0]:null})):se(e)))}catch{return se(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()}enableReadOnly(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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}sanitizeCommentAnnotation(e){try{return e?.comments?.length&&e.comments.forEach(i=>{i?.commentHtml&&(i.commentHtml=this.domService.sanitizeHtml(i.commentHtml))}),e}catch(i){return this.loggingService.catch("Error in CommentService sanitizeCommentAnnotation: ",i),e}}enableCustomAutocompleteSearch(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:ke.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:i}){try{this.analyticsService.setFeatureConfig({feature:i||ke.COMMENT,config:e})}catch(r){this.loggingService.catch("Error in CommentService setAnalyticsFeatureConfig: ",r)}}generateContextId(e){try{let i;if(e&&typeof e=="object"){let r=vc(e),a=JSON.stringify(r);i=Pt(a)}return i}catch{return}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(Oc),J(Tn),J(jt),J(lt),J(hn),J(He),J(Ne),J(bi),J(Dm),J(Ci),J(Kp),J(jo),J(Ki),J(fn),J(y),J(vn),J(zo),J(nr),J(Vle),J(ui),J(es),J(o0),J(Mm),J(t0),J(Yp))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var b=(()=>{let _DynamicDataService=class _DynamicDataService{constructor(n,o,t,e,i){this.authService=n,this.commentService=o,this.loggingService=t,this.injector=e,this.docService=i,this.subscriptions=[],this.commonData$=new Ce({}),this.evaluateConditionTriggered=new Ae,this.conditionRegex=/\{(.*?)\}/g,this.extractedProps={},this.condition="",this.dataComponentConfigSignal=Te({});try{this.subscriptions.push(this.authService.getUser$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{user:r}))})),this.subscriptions.push(this.commentService.getUnreadCommentAnnotationCountOnCurrentDocument$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{unreadCommentAnnotationCount:r?.count||0}))})),this.subscriptions.push(this.commentService.getUnreadCommentCountOnCurrentDocument$().subscribe(r=>{this.commonData$.next(T(I({},this.commonData$.value),{unreadCommentCount:r?.count||0}))})),this.subscriptions.push(this.docService.getUIState$().subscribe(r=>{this.commonData$.next(I(I({},this.commonData$.value),r))})),this.subscriptions.push(this.getCommonData().subscribe(r=>{this.dataComponentConfigSignal.update(a=>(a=I(I({},a),r),a)),this.executeConditionalClasses()})),this.subscriptions.push(this.evaluateConditionTriggered.subscribe(r=>{this.extractedProps=r.extractedProps,this.evaluateCondition(r.className,r.elementRef,r.condition)}))}catch(r){this.loggingService.catch("Error in DynamicDataService constructor: ",r)}}ngOnDestroy(){try{this.subscriptions.forEach(n=>n.unsubscribe())}catch(n){this.loggingService.catch("Error in DynamicDataService ngOnDestroy: ",n)}}getCommonData(){return this.commonData$.asObservable()}getModifiedPathBasedOnCondition(n,o){try{return Object.keys(o).forEach(t=>{o[t].path=this.modifyPathBasedOnCondition(t,n)}),o}catch(t){this.loggingService.catch("Error in DynamicDataService getModifiedPathBasedOnCondition: ",t)}}getComputedValues(n,o,t,e,i,r){try{Object.keys(t).forEach(a=>{let s;if(Fi(n)?s=Mi(()=>pa(n(),t[a].path)):s=Mi(()=>pa(n,t[a].path)),Fi(s()))ur(()=>{try{let m=s()();t[a].value=m,this.evaluateConditionTriggered.emit({extractedProps:t,className:e,elementRef:i,condition:r})}catch{}},{injector:this.injector,allowSignalWrites:!0});else{let m=s();t[a].value=m,this.evaluateConditionTriggered.emit({extractedProps:t,className:e,elementRef:i,condition:r})}})}catch(a){this.loggingService.catch("Error in DynamicDataService getComputedValues: ",a)}}modifyPathBasedOnCondition(n,o){try{let t=n;if(n.startsWith("userContact."))t=n.replace("userContact","selectorItem.contact");else if(n.startsWith("comment."))t=n.replace("comment","commentObj");else if(n.startsWith("commentAnnotation."))t=n.replace("commentAnnotation","componentConfigSignal.annotation");else if(n.startsWith("commentAnnotations."))t=n.replace("commentAnnotations","componentConfigSignal.annotations");else{let e=n.match(/^([^.\[]+)/),i=e?e[1]:"";if(i&&o&&typeof o=="function"&&o()&&i in o()){let r=n.match(/\[(.*?)\]/);if(r&&r[1]){let a=r[1];if(a.includes(".")){let s=a.split(".")[0];s&&o()&&s in o()?t=n:t=n.replace(`[${a}]`,`[componentConfigSignal.${a}]`)}else t=n}else t=n}else t="componentConfigSignal."+n}return t}catch(t){return this.loggingService.catch("Error in DynamicDataService modifyPathBasedOnCondition: ",t),n}}applyConditionalClasses(n,o){try{this.elementRef=n,this.data=o}catch(t){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",t)}}executeConditionalClasses(){try{let n=this.getHostElementAttributes(this.elementRef),t=[...Object.keys(n).filter(e=>e.startsWith("velt-class-")).map(e=>({name:e,value:n[e]}))];if(n["velt-class"]){let e=n["velt-class"],i=/'([^']+)':\s*([^,]+)(?:,|$)/g,r=[],a=0,s=100,m;for(;(m=i.exec(e))!==null;){if(a++>s){this.loggingService.catch("Too many class definitions detected.");break}if(m.length<3)continue;let[,p,h]=m;!p||!h||p.split(" ").forEach(_=>{_.trim()&&r.push({name:`velt-class-${_.trim()}`,value:h.trim()})})}t=[...t,...r]}this.data&&typeof this.data=="object"&&Object.keys(this.data).forEach(e=>{this.updateDataComponentConfigSignal(e,this.data[e])}),t.forEach(e=>{let i=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,i,this.elementRef,e.value))})}catch(n){this.loggingService.catch("Error in DynamicDataService applyConditionalClasses: ",n)}}updateDataComponentConfigSignal(n,o){try{n==="dataComponentConfigSignal"?this.dataComponentConfigSignal.set(o):this.dataComponentConfigSignal.update(t=>T(I({},t),{[n]:o}))}catch(t){this.loggingService.catch("Error in DataComponent updateDataComponentConfigSignal: ",t)}}extractProps(){try{this.extractedProps={},this.conditionRegex.lastIndex=0;let n;for(;(n=this.conditionRegex.exec(this.condition))!==null;){let o=n[1];this.extractedProps[o]={value:null,path:null,isDynamicPath:this.hasDynamicParts(o)}}}catch(n){this.loggingService.catch("Error in DynamicDataService extractProps: ",n)}}hasDynamicParts(n){try{let o=/\[[^\]'"]*[^\]'"]\]/.test(n),t=/\[[^[\]]*[\.\[][^[\]]*\]/.test(n);return o||t}catch(o){return this.loggingService.catch("Error checking for dynamic path: ",o),!1}}evaluateCondition(n,o,t){try{if(t){let e=this.extractedProps,i=t.replace(this.conditionRegex,(s,m)=>{let p=e[m];return p&&p.value!==void 0?typeof p.value=="string"?`'${p.value}'`:p.value:"false"}),r=this.sanitizeCondition(i),a=this.safeEval(r);return n&&o&&(a?this.setHostElementClasses(o,n):this.removeHostElementClasses(o,n)),a}return!1}catch(e){return this.loggingService.catch("Error in IfComponent evaluateCondition: ",e),!1}}sanitizeCondition(n){try{return n.replace(/[^a-zA-Z0-9\s\+\-\*\/\%\(\)\!\=\<\>\|\&\.\[\]\{\},'"]/g,"")}catch(o){return this.loggingService.catch("Error in IfComponent sanitizeCondition: ",o),""}}safeEval(expression){try{return eval(expression)}catch(n){return!1}}getHostElementAttributes(n){try{let o=n,t={};for(let e of o.attributes)t[e.name]=e.value;return t}catch{return{}}}setHostElementClasses(n,o){try{n.classList.add(o)}catch{}}removeHostElementClasses(n,o){try{n.classList.remove(o)}catch{}}};_DynamicDataService.\u0275fac=function(o){return new(o||_DynamicDataService)(J(He),J(we),J(y),J(xt),J(lt))},_DynamicDataService.\u0275prov=Pe({token:_DynamicDataService,factory:_DynamicDataService.\u0275fac,providedIn:"root"});let DynamicDataService=_DynamicDataService;return DynamicDataService})();var z=(()=>{let o=class o{set veltIf(e){try{e&&this.setIfCondition(e)}catch(i){this._loggingService.catch("Error in BaseComponent set veltIf:",i)}}constructor(e,i,r){this._elementRef=e,this._dynamicDataService=i,this._loggingService=r,this.componentConfigSignal=Te({}),this.veltElement=!0,this.conditionSignal=Te(null)}initializeComponentConfigSignal(e){try{this.componentConfigSignal.set(e)}catch(i){this._loggingService.catch("Error in BaseComponent initializeComponentConfigSignal:",i)}}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(i){this._loggingService.catch("Error in BaseComponent setIfCondition:",i)}}};o.\u0275fac=function(i){return new(i||o)(u(k),u(b),u(y))},o.\u0275cmp=O({type:o,selectors:[["app-base"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},inputs:{componentConfigSignal:"componentConfigSignal",template:"template",wireframe:"wireframe",veltIf:"veltIf"},standalone:!1,decls:0,vars:0,template:function(i,r){},encapsulation:2});let n=o;return n})();var nt=(()=>{let o=class o extends z{onDarkModeChange(){return this.darkModeSubject$.asObservable()}constructor(e,i,r,a,s,m,p){super(e,m,p),this._elementRef=e,this._themeService=i,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(h=>{this._globalDarkMode=h,this.setDarkMode()})),this._featureService&&(this._featureService instanceof we?this._themeSubscriptions.push(this._featureService.getCommentContainerDarkMode().subscribe(h=>{this._featureDarkMode=h,this.setDarkMode()})):this._featureService instanceof nr&&this._themeSubscriptions.push(this._featureService.getDarkMode$().subscribe(h=>{h!==null&&(this._featureDarkMode=h),this.setDarkMode()}))),this._componentDarkModeObservable&&this._componentDarkModeObservable instanceof Lt&&this._themeSubscriptions.push(this._componentDarkModeObservable.subscribe(h=>{this._componentDarkMode=h,this.setDarkMode()}))}catch{}}ngOnInit(){super.ngOnInit()}ngOnChanges(e){try{if(e._darkMode){let i=e._darkMode.currentValue;typeof i=="string"&&(i=i==="true"),this._componentDarkMode=i,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(i){return new(i||o)(u(k),u(Ye),u(Kt),u("FeatureService",8),u(Lt),u(b),u(y))},o.\u0275cmp=O({type:o,selectors:[["app-themed"]],inputs:{_darkMode:[0,"darkMode","_darkMode"]},standalone:!1,features:[B,Xe],decls:0,vars:0,template:function(i,r){},encapsulation:2,changeDetection:0});let n=o;return n})();var ze=(()=>{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(i){this.loggingService.catch("Error in WireframeService constructor: ",i)}}setWireframe(e,i){try{let r=this.wireframeMap.value;r.set(e,i),this.wireframeMap.next(r)}catch(r){this.loggingService.catch("Error in WireframeService setWireframe: ",r)}}setWireframeMap(e){try{let i=this.wireframeMap.value;e.forEach((r,a)=>{i.set(a,r)}),this.wireframeMap.next(i)}catch(i){this.loggingService.catch("Error in WireframeService setWireframeMap: ",i)}}getWireframe(e,i=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&i){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,i=!0){try{let r=this.wireframeMap.value,a=r.get(e);if(!a&&i){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,i=!0){return this.wireframeMap.asObservable().pipe(ce(r=>this.getWireframe(e,i)))}setChildren(e){try{this.wireframeMap.next(e)}catch(i){this.loggingService.catch("Error in WireframeService setChildren: ",i)}}getWireframeMap(){return this.wireframeMap.value}};o.\u0275fac=function(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var jle=n=>({componentConfigSignal:n}),oke=(n,o)=>({condition:n,data:o}),rke=(n,o,t,e,i)=>({template:n,context:o,componentName:"velt-confirm-dialog-wireframe",variant:t,setIfCondition:e,componentElementRef:i});function ake(n,o){if(n&1&&(f(0),w(1,"app-confirm-dialog-title",5)(2,"app-confirm-dialog-message",5),C(3,"div",6),w(4,"app-confirm-dialog-reject",5)(5,"app-confirm-dialog-approve",5),S(),v()),n&2){let t=l(3);d(),c("componentConfigSignal",t.componentConfigSignal),d(),c("componentConfigSignal",t.componentConfigSignal),d(2),c("componentConfigSignal",t.componentConfigSignal),d(),c("componentConfigSignal",t.componentConfigSignal)}}function ske(n,o){if(n&1&&(f(0),g(1,ake,6,4,"ng-container",4),v()),n&2){let t=l().ngIf,e=l();d(),c("veltDynamicTemplate",$(3,rke,e.template,M(1,jle,e.componentConfigSignal),t.variant,e.setIfCondition.bind(e),e.elementRef))}}function lke(n,o){if(n&1&&(f(0),g(1,ske,2,9,"ng-container",3),v()),n&2){let t=l();d(),c("veltIf",R(3,oke,t.conditionSignal(),M(1,jle,t.componentConfigSignal)))}}var va=(()=>{let o=class o extends nt{constructor(e,i,r,a,s,m,p){super(s,a,void 0,void 0,void 0,p,e),this.loggingService=e,this.dialogRef=i,this.wireframeService=r,this.themeService=a,this.elementRef=s,this.dynamicDataService=p,this.subscriptions=[],this.componentConfigSignal=Te({title:"",message:"",yesButton:"",noButton:"",variant:"",closeDialog:this.closeDialog.bind(this)}),this.componentId="velt-confirm-dialog",this.veltElement=!0;try{m&&(this.componentConfigSignal.update(h=>(h=I(I({},h),m),h)),m?.darkMode&&[!0,!1].includes(m?.darkMode)&&super.setComponentDarkMode(m?.darkMode)),this.setZIndex()}catch(h){this.loggingService.catch("Error in ConfirmDialogComponent constructor: ",h)}}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(i=>{if(i){let r=document.createElement(i.tagName);r.innerHTML=i.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(i){this.loggingService.catch("Error in ConfirmDialogComponent closeDialog: ",i)}}};o.\u0275fac=function(i){return new(i||o)(u(y),u(Xo),u(ze),u(Ye),u(k),u(bl,8),u(b))},o.\u0275cmp=O({type:o,selectors:[["snippyly-confirm-dialog"]],hostVars:1,hostBindings:function(i,r){i&2&&x("data-velt-element",r.veltElement)},standalone:!1,features:[U([b]),B],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",""]],template:function(i,r){if(i&1&&(C(0,"div",1,0),g(2,lke,2,6,"ng-container",2),S()),i&2){let a=pe(1);c("snippylyOverlay",a)("snippylyOverlayZIndex",1200)("snippylyOverlayBackdropZIndex",1100),x("data-testid",r.componentId),d(2),c("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}*[_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)}.mat-mdc-dialog-actions[_ngcontent-%COMP%]{justify-content:space-between;gap:var(--velt-spacing-md);min-height:auto} 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 n=o;return n})();var Oc=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L){this.analyticsService=e,this.configService=i,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=m,this.domService=p,this.afAuth=h,this.iamService=_,this.dialog=E,this.loggingService=D,this.notificationService=L,this.areaAnnotationById$=new Ce({}),this.documentPaths=null,this.db=Ii(),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(Fe(H=>!!H),tt(1)).subscribe(H=>{H&&(this.db=H,this.getDocumentPaths())},H=>{this.loggingService.catch("Error in AreaService getDb subscription: ",H)}),this.domService.onWindowPointerMove$().subscribe(H=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&(this.isElementInsideAllowedElements(K)?H6(H.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=K,this.domService.highlightElement(this.highlightElement,j.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},H=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",H)}),this.domService.onWindowKeyupEsc$().subscribe(H=>{this.addAreaMode$.value&&this.disableAddAreaMode()},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",H)}),this.domService.onDocumentClick$().subscribe(H=>{if(H&&this.addAreaMode$.value){if(H.preventDefault(),H.stopPropagation(),!H6(H.target)){let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&this.isElementInsideAllowedElements(K)&&this.addArea(H)}this.disableAddAreaMode()}},H=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",H)}),this.addAreaMode$.subscribe(H=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),H?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"))},H=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",H)}),this.domService.onWindowKeyupBackspace$().subscribe(H=>{this.deleteAreaPinAnnotations("keyupBackspace")},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",H)}),this.domService.onWindowKeyupDelete$().subscribe(H=>{this.deleteAreaPinAnnotations("keyupDelete")},H=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",H)})}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,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let a,s;try{if(e&&(s=yn(e)),i&&typeof i=="object"){let m=Jo(i);a=yn(JSON.stringify(m))}}catch(m){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",m)}return qn(this.afAuth).pipe(Fe(m=>!!m),he(m=>this.isFeatureAllowed({firebaseUser:m,annotations:[],filteredAnnotations:[]})),he(m=>m.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(p=>(m.featureAllowed=p,m))):se(m)),he(m=>m.featureAllowed?this.authService.isPlanExpired$().pipe(ce(p=>(m.featureAllowed=!p,m))):se(m)),he(m=>m.featureAllowed?se(m).pipe(he(p=>this.docService.getDocumentPaths$().pipe(ce(h=>(this.documentPaths=h,p.documentPaths=h,p)))),he(p=>s?this.getDataFromDocumentIds([s]).pipe(ce(h=>(p.annotations=h||[],I({},p)))):this.docService.getDocumentIds$().pipe(he(h=>{let _=h?.length>0?h.map(E=>E.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(_).pipe(ce(E=>(p.annotations=E||[],I({},p))))}))),he(p=>this.docService.getLocation$().pipe(ce(h=>(p.location=h,p)))),he(p=>this.docService.getLocations$().pipe(ce(h=>(p.customLocations=h,p)))),ce(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let h=[],_=[];return a?h.push(a):(h.push(p?.location?.locationId),h.push(...Object.values(p?.customLocations||[]).map(E=>E.locationId)),p?.location?.location?.id&&_.push(p?.location?.location?.id)),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,h,_),p}}),he(p=>r?se(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>p)):se(p)),he(p=>r?se(p):p?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(ce(()=>p)):se(p)),ce(p=>(p.filteredAnnotations=p.filteredAnnotations?.map(h=>{let _=Object.assign({},h);return _.areaProperties=this.calculateAreaAnnotationPosition(_),_}),p)),he(p=>p?.filteredAnnotations?se(p?.filteredAnnotations||[]):se([])),he(p=>{if(this.authService.isFeatureAllowed(ke.COMMENT))return se(p);{let h=p?.filter(_=>!_?.targetAnnotations?.filter(E=>E?.type===ke.COMMENT)?.length);return se(h)}})):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.AREA)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:i,filters:r}=e;if(i?.some(h=>!h)||!this.documentPaths)return se([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=this.docService.getDocumentPaths()?.allDocuments,m=se([]),p={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(p.documentId=i?.length?i[0]:void 0,p.organizationId=this.documentPaths?.organizationId),a&&s)m=this.commonDbService.dbListener({feature:"allAreas",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",a),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let h=[];for(let _=0;_<(i?.length??0);_+=j.LISTENER_BATCH_SIZE)h.push(i?.slice(_,_+j.LISTENER_BATCH_SIZE)??[]);m=Rn(h.map(_=>this.commonDbService.dbListener({feature:"allAreas",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",_),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[gt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Gr()))).pipe(ce(_=>ua(_)))}return m.pipe(ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h??{}).filter(D=>typeof D=="object")),{data:E,operation:_}}),ce(({data:h,operation:_})=>{if(!i)return{data:h,documentMap:{},operation:_};let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),ce(({data:h,documentMap:_,operation:E})=>{if(!r)if(E?.type==="removed"){if(E?.ids?.length){let D=this.areaAnnotationById$.value;E?.ids?.forEach(L=>{delete D?.[L]}),this.areaAnnotationById$.next(D)}}else Object.entries(_??{}).forEach(([D,L])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:L})});return h}))}else return se([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(m)}}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(i){this.loggingService.catch("Error in AreaService getAnnotationById: ",i);return}}filterAnnotationsByLocationIds(e,i,r){try{return e.filter(a=>i.includes(a.locationId)||r?.includes(a?.location?.id)||i?.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 i=e.targetElements[0],r=e.targetElements[1];if(i?.xpath&&r?.xpath){let a=this.domService.getElementFromXPath(i.xpath);a&&zi(a)&&(a=null),!a&&i.cfXpath&&(a=this.domService.getElementFromXPath(i.cfXpath),a&&zi(a)&&(a=null)),!a&&i.fXpath&&(a=this.domService.getElementFromXPath(i.fXpath),a&&zi(a)&&(a=null));let s=this.domService.getElementFromXPath(r.xpath);if(s&&zi(s)&&(s=null),!s&&r.cfXpath&&(s=this.domService.getElementFromXPath(r.cfXpath),s&&zi(s)&&(s=null)),!s&&r.fXpath&&(s=this.domService.getElementFromXPath(r.fXpath),s&&zi(s)&&(s=null)),a&&s){let m=AU(a,s);if(m){let p=a.getBoundingClientRect(),h={};p&&p.width&&p.height&&(h={top:p.height*i.topPercentage/100,left:p.width*i.leftPercentage/100});let _=s.getBoundingClientRect(),E={};_&&_.width&&_.height&&(E={top:_.height*r.topPercentage/100,left:_.width*r.leftPercentage/100});let D=PU(h.left,h.top,a,m),L=PU(E.left,E.top,s,m),H,K,oe,ue,be={};D.x>L.x?D.y>L.y?(ue={x:D.x,y:D.y},H={x:L.x,y:L.y},be.handle1=ue,be.handle2=H):(K={x:D.x,y:D.y},oe={x:L.x,y:L.y},be.handle1=K,be.handle2=oe):D.y>L.y?(oe={x:D.x,y:D.y},K={x:L.x,y:L.y},be.handle1=oe,be.handle2=K):(H={x:D.x,y:D.y},ue={x:L.x,y:L.y},be.handle1=H,be.handle2=ue);let Le={topLeft:H||{x:oe?.x,y:K?.y},bottomRight:ue||{x:K?.x,y:oe?.y},topRight:K||{x:ue?.x,y:H?.y},bottomLeft:oe||{x:H?.x,y:ue?.y}};return be.coordinates=Le,be.targetElement=this.domService.getXPath(m),be}}}}return}catch(i){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",i);return}}addArea(e,i=[],r,a,s){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let m=this.authService.getUser();if(m)if(m.isReadOnly||m.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let p=new tM;a&&(p.annotationId=a),p.from=m,p.color=j.DEFAULT_ANNOTATION_COLOR,p.lastUpdated=this.timestamp,r&&(p.targetAnnotations=[r]),p.props=new Ol;let h=this.domService.getCurrentWindowSizeValue();if(p.props.screenWidth=h.screenWidth,p.props.screenHeight=h.screenHeight,p.props.screenScrollHeight=h.screenScrollHeight,p.props.viewportWidth=window.innerWidth,p.props.viewportHeight=window.innerHeight,e||i?.length>0){let D=e?this.getPointsForAreaPinAnnotation(e):i;p.targetElements=[],D.forEach(L=>{p.targetElements.push(this.getTargetElementForAreaPinAnnotation(e,{clientX:L.x,clientY:L.y}))})}this.setLocationToAreaAnnotation(p),s&&(p.locationId=s.locationId,p.location=s.location),p.pageInfo=Ei(),p.pageInfo&&(p.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let _=this.getElementForAreaAnnotation(p),E=this.docService.getBaseMetadata("area",{element:_});return p?.metadata||(p.metadata={}),p.metadata=I(I({},p.metadata),E),this.saveAreaToDb(p),p}return}catch(m){this.loggingService.catch("Error in AreaService addArea: ",m);return}}setLocationToAreaAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.location):(delete e.locationId,delete e.location)}catch(i){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",i)}}getElementForAreaAnnotation(e){try{let i,r,a;return e.targetElements?.length&&(e.targetElements[0]?.xpath&&(r=this.domService.getElementFromXPath(e.targetElements[0].xpath)),e.targetElements[1]?.xpath&&(a=this.domService.getElementFromXPath(e.targetElements[1].xpath))),i=AU(r,a),i}catch(i){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",i),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.AREA)&&Rn([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe(Fe(([i,r])=>!!i&&!!r),tt(1),he(([i,r])=>{if(this.documentPaths=i,this.db=r,this.documentPaths?.area){let a=rn(this.db,`${this.documentPaths?.area}`),s;e.annotationId?s=rn(this.db,`${this.documentPaths?.area}/${e.annotationId}`):e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let m=JSON.parse(JSON.stringify(e));if(m.position=null,!m?.metadata?.documentId){m?.metadata||(m.metadata={});let _=this.docService.getBaseMetadata();m.metadata=I(I({},m?.metadata),_)}this.domService.toggleAnnotationSelection(m),this.analyticsService.trackEvent(X.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:p,organizationId:h}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m))})}else return se(null)})).subscribe(()=>{},i=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in AreaService saveAreaToDb: ",i)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(i){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",i),{}}}updateArea(e,i=!1,r){try{r&&this.setLocationToAreaAnnotation(e),i&&this.updateNotificationsDatabase(e,L6.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(ke.AREA)){let i=JSON.parse(JSON.stringify(e));if(i.position=null,!i?.metadata?.documentId){i?.metadata||(i.metadata={});let s=this.docService.getBaseMetadata();i.metadata=I(I({},i?.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(i))})}}catch(i){this.loggingService.catch("Error in AreaService updateAreaToDb: ",i)}}deleteAreaPinAnnotations(e){try{let i=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(i??{}).forEach(s=>Q(this,null,function*(){let m=i[s];m.type==="area"&&r&&m.from&&(r?.isAdmin||m.from.userId===r.userId)&&a.push(m)})),a?.length&&(this.analyticsService.trackEvent(X.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(va,{data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(tt(1)).subscribe(s=>{s&&(a.forEach(m=>Q(this,null,function*(){yield this.deleteAreaPinAnnotation(m)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(i){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",i)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};return Object.values(this.areaAnnotationById$.value??{}).forEach(a=>{a?.metadata?.documentId==i&&a?.metadata?.organizationId==e&&(r[a?.annotationId]=a)}),Object.values(r??{})}catch(r){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",r),[]}}onDeleteTargetAnnotation(e,i){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let a=Object.values(this.areaAnnotationById$.value||{}),s;i?s=a.find(m=>m?.annotationId===i):s=a.find(m=>m?.targetAnnotations?.find(p=>p?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(m=>m?.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(ke.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,L6.DELETED),this.analyticsService.trackEvent(X.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:i,organizationId:r}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:i,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),se(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(ke.AREA)?(this.analyticsService.trackEvent(X.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(X.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getTargetElementForAreaPinAnnotation(e,i){try{let r=e,a=r?.touches?.length?r.touches[0]?.clientX:r?.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r?.clientY;i&&(a=i.clientX,s=i.clientY);let m=this.domService.getBackgroundElement(a,s);if(m){let p=this.domService.getXPath(m),h=this.domService.getXPath(m,!0),_=this.domService.getXPath(m,!0,!0),E=m.getBoundingClientRect(),D=a-E.x,L=s-E.y,H=D*100/(E.width||1),K=L*100/(E.height||1);return{xpath:p,fXpath:h,cfXpath:_,leftPercentage:H,topPercentage:K}}else return null}catch(r){return this.loggingService.catch("Error in AreaService getTargetElementForAreaPinAnnotation: ",r),null}}getPointsForAreaPinAnnotation(e){let i=[],r=e,a=r?.touches?.length?r.touches[0]?.clientX:r.clientX,s=r?.touches?.length?r.touches[0]?.clientY:r.clientY;return i.push({x:a,y:s}),i.push({x:a+100,y:s+100}),i}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(i){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",i),!1}}updateNotificationsDatabase(e,i){try{let r={annotationData:e,actionType:i,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=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(i){this.loggingService.catch("Error in AreaService getAreaUrl: ",i);return}}generateAreaUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.TAG_ID),i.searchParams.append(j.URL_PARAMS.TAG_ID,e.annotationId),i.href}generateAreaAnnotationId(){return Q(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let i=this.commonDbService.generateDocumentId();return yield Rp(10),i||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(lt),J(hn),J(Tn),J(He),J(Ne),J(bi),J(fn),J(Ki),J(y),J(vn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ci=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,t={},e=!0){try{this.hideAnalytics||(t||(t={}),t=T(I({},t),{source:"external"}),this.getService(Ze).trackAuthenticatedEvent(o,t,e))}catch(i){this.getService(y).catch("Error in _trackEvent: ",i);return}}};var kM=class extends ci{constructor(o){super(o),this.getService(y).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(y).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(X.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(Oc).enableArea()}catch(o){this.getService(y).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(X.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(Oc).disableArea()}catch(o){this.getService(y).catch("Error in _disableAreaComment: ",o)}}};var km=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L){this.analyticsService=e,this.configService=i,this.docService=r,this.databaseService=a,this.authService=s,this.domService=m,this.afAuth=p,this.iamService=h,this.dialog=_,this.loggingService=E,this.notificationService=D,this.commonDbService=L,this.arrowAnnotations$=new Ce({}),this.arrowAnnotationsByDocumentId$=new Ce({}),this.documentPaths=null,this.db=Ii(),this.allowedElementIds$=new Ce([]),this.addArrowMode$=new Ce(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(Fe(H=>!!H),tt(1)).subscribe(H=>{H&&(this.db=H,this.getDocumentPaths())},H=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",H)}),this.domService.onWindowPointerMove$().subscribe(H=>{if(this.addArrowMode$.value){let K=!0,oe=this.domService.getBackgroundElement(H.clientX,H.clientY);oe&&(this.isElementInsideAllowedElements(oe)?$6(H.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==oe&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=oe,this.domService.highlightElement(this.highlightElement,j.CURSOR.ARROW_PIN),K=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&K&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},H=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",H)}),this.domService.onWindowKeyupEsc$().subscribe(H=>{this.addArrowMode$.value&&this.disableAddArrowMode()},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",H)}),this.domService.onDocumentClick$().subscribe(H=>{if(H&&this.addArrowMode$.value){if(!$6(H.target)){let K=this.domService.getBackgroundElement(H.clientX,H.clientY);K&&this.isElementInsideAllowedElements(K)&&(H.preventDefault(),H.stopPropagation(),this.addArrow(H))}this.disableAddArrowMode()}},H=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",H)}),this.addArrowMode$.subscribe(H=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),H?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"))},H=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",H)}),this.domService.onWindowKeyupBackspace$().subscribe(H=>{this.deleteArrowPinAnnotations("keyupBackspace")},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",H)}),this.domService.onWindowKeyupDelete$().subscribe(H=>{this.deleteArrowPinAnnotations("keyupDelete")},H=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",H)})}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,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let a,s;try{if(e&&(s=yn(e)),i&&typeof i=="object"){let m=Jo(i);a=yn(JSON.stringify(m))}}catch(m){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",m)}return qn(this.afAuth).pipe(Fe(m=>!!m),he(m=>this.isFeatureAllowed({firebaseUser:m,annotations:[],filteredAnnotations:[]})),he(m=>m.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(p=>(m.featureAllowed=p,m))):se(m)),he(m=>m.featureAllowed?this.authService.isPlanExpired$().pipe(ce(p=>(m.featureAllowed=!p,m))):se(m)),he(m=>m.featureAllowed?se(m).pipe(he(p=>this.docService.getDocumentPaths$().pipe(ce(h=>(this.documentPaths=h,p.documentPaths=h,p)))),he(p=>this.getDataFromDocumentId(s).pipe(ce(h=>(p.annotations=h||[],I({},p))))),he(p=>this.docService.getLocation$().pipe(ce(h=>(p.location=h,p)))),he(p=>this.docService.getLocations$().pipe(ce(h=>(p.customLocations=h,p)))),ce(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let h=[];return a?h.push(a):(h.push(p?.location?.locationId),h.push(...Object.values(p?.customLocations||[]).map(_=>_.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,h),p}}),he(p=>r?se(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>p)):se(p)),he(p=>r?se(p):p?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(ce(()=>p)):se(p)),ce(p=>(p?.filteredAnnotations?.forEach(h=>{this.calculateArrowAnnotationPosition(h)}),p)),he(p=>p?.filteredAnnotations?se(p?.filteredAnnotations||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.ARROW)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>(this.db=i,this.loggingService.log(this.db),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(ce(r=>({data:r?.data,operation:r?.operation})),ce(({data:r,operation:a})=>{let s=[];return r&&(s=Object.values(r).filter(m=>typeof m=="object")),{data:s,operation:a}}),jn(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),se({data:[],operation:null}))),ce(({data:r,operation:a})=>{if(a?.type==="removed"){if(a?.ids?.length){let s=this.arrowAnnotationsByDocumentId$.value;a?.ids?.forEach(m=>{delete s?.[m]}),this.arrowAnnotationsByDocumentId$.next(s)}}else this.setArrowAnnotationsByDocumentId(e||this.documentPaths?.documentId,r);return r})):se([]))))}setArrowAnnotationsByDocumentId(e,i){try{if(e){let r=T(I({},this.arrowAnnotationsByDocumentId$.value),{[e]:i});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(e,i){try{return e.filter(r=>i.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(e){try{if(e.targetElement){let i=this.domService.getXPath(e.targetElement?.xpath);if(i){let r=i.iterateNext();if(r&&Do(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:m}=Np(r);e.position={top:s*e.targetElement.topPercentage/100,left:m*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(i){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",i)}}addArrow(e){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let i=this.authService.getUser();if(i)if(i.isReadOnly||i.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new nM;r.from=i,r.color=i?.color||j.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new Ol;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=j.VELT_MIN_ARROW_LENGTH,(e?.clientX||0)>j.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 m=s.iterateNext();m&&(Do(m)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=Ei(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(i){this.loggingService.catch("Error in ArrowService addArrow: ",i)}}setLocationToArrowAnnotation(e){try{let i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.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);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}}catch{}}catch(i){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",i)}}saveArrowToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(ke.ARROW)&&this.docService.getDocumentPaths$().pipe(Fe(i=>!!i),tt(1),he(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(r=>!!r),tt(1),he(r=>{if(this.db=r,this.loggingService.log(this.db),this.documentPaths?.arrow){let a=rn(this.db,`${this.documentPaths?.arrow}`);e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.arrowUrl=this.generateArrowUrl(e));let s=JSON.parse(JSON.stringify(e));return s.position=null,this.domService.toggleAnnotationSelection(s),this.analyticsService.trackEvent(X.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(s))})}else return se(null)}))))).subscribe(()=>{},i=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",i)}}updateArrow(e,i=!1,r){try{r&&this.setLocationToArrowAnnotation(e),i&&this.updateNotificationsDatabase(e,F6.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 i=this.domService.getXPath(e.targetElement.xpath);if(i){let r=i.iterateNext();r&&(Do(r)||(e.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(ke.ARROW)&&this.docService.getDocumentPaths$().pipe(Fe(i=>!!i),tt(1),he(i=>(this.documentPaths=i,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(r=>!!r),tt(1),he(r=>{if(this.db=r,this.loggingService.log(this.db),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 se(null)}))))).subscribe(()=>{},i=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",i)})}catch(i){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",i)}}deleteArrowPinAnnotations(e){try{let i=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),a=[];Object.keys(i).forEach(s=>Q(this,null,function*(){let m=i[s];if(m.type==="arrow"){let p=r&&!r?.isAnonymous&&!r?.isGuest;r&&m.from&&(p||m.from.userId===r.userId)&&a.push(m)}})),a?.length&&(this.analyticsService.trackEvent(X.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:e,annotationId:a.map(s=>s.annotationId).join()}),this.dialog.open(va,{data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(tt(1)).subscribe(s=>{s&&(a.forEach(m=>Q(this,null,function*(){yield this.deleteArrowPinAnnotation(m)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(p=>{this.domService.removeHighlightFromElement(p)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(i){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",i)}}deleteArrowPinAnnotation(e){return this.authService.isFeatureAllowed(ke.ARROW)&&this.documentPaths?.arrow&&e?.annotationId?(this.updateNotificationsDatabase(e,F6.DELETED),this.analyticsService.trackEvent(X.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(ke.ARROW)?(this.analyticsService.trackEvent(X.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(X.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(i){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",i),!1}}updateNotificationsDatabase(e,i){try{let r={annotationData:e,actionType:i,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=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.arrowUrl=this.generateArrowUrl(e),this.updateArrow(e),e.pageInfo?.arrowUrl)}catch(i){this.loggingService.catch("Error in ArrowService getArrowUrl: ",i);return}}generateArrowUrl(e){let i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.TAG_ID),i.searchParams.append(j.URL_PARAMS.TAG_ID,e.annotationId),i.href}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(lt),J(hn),J(He),J(Ne),J(bi),J(fn),J(Ki),J(y),J(vn),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var NM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(X.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(km).setAllowedElementIds(o)}catch(t){this.getService(y).catch("Error in allowedElementIds: ",t)}}};var el=(()=>{let o=class o{constructor(e){this.loggingService=e,this.autocompleteDataMap$=new Ce({}),this.onAutocompleteChipClick$=new Ke;try{this.loggingService.log("%c[WB] Creating CLASS: AutocompleteService","color: blue;"),this.create({hotkey:"@",type:"contact",data:[]})}catch(i){this.loggingService.catch("Error in AutocompleteService constructor: ",i)}}create(e){try{if(this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: create","color: green;"),e?.hotkey){let i=this.autocompleteDataMap$.value;i[e.hotkey]=e,this.autocompleteDataMap$.next(i)}}catch(i){this.loggingService.catch("Error in AutocompleteService create: ",i)}}remove(e){try{this.loggingService.log("%c[WB] Calling AutocompleteService FUNCTION: remove","color: green;");let i=this.autocompleteDataMap$.value;delete i[e],this.autocompleteDataMap$.next(i)}catch(i){this.loggingService.catch("Error in AutocompleteService remove: ",i)}}getAutocompleteDataMap$(){return this.autocompleteDataMap$.asObservable()}getAutocompleteDataMap(){return this.autocompleteDataMap$.value}setOnAutocompleteChipClick(e){this.onAutocompleteChipClick$.next(e)}getOnAutocompleteChipClick$(){return this.onAutocompleteChipClick$.asObservable()}};o.\u0275fac=function(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var LM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: AutocompleteElement","color: blue;"),this.create=this._create,this.onAutocompleteChipClick=this._onAutocompleteChipClick}_create(o){this.getService(y).log("%c[WB] Calling FUNCTION: create","color: green;");try{return this.trackEvent(X.Events.Autocomplete.CREATE_TRIGGERED,{payload:{data:o}}),this.getService(el).create(o)}catch(t){this.getService(y).catch("Error in _create: ",t)}}_onAutocompleteChipClick(){this.getService(y).log("%c[WB] Calling FUNCTION: onAutocompleteChipClick","color: green;");try{return this.trackEvent(X.Events.Autocomplete.ON_AUTOCOMPLETE_CHIP_CLICK_TRIGGERED),this.getService(el).getOnAutocompleteChipClick$()}catch(o){return this.getService(y).catch("Error in _onAutocompleteChipClick: ",o),se(null)}}};var ii=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D){this.analyticsService=e,this.authService=i,this.commentService=r,this.contactService=a,this.customFilterService=s,this.docService=m,this.iamService=p,this.loggingService=h,this.metadataService=_,this.reactionService=E,this.commonDbService=D,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(L=>{this.isUserAdmin=L})}catch(L){this.loggingService.catch("Error in CommentActionsService constructor: ",L)}}addCommentAnnotation(a,s){return Q(this,arguments,function*({annotation:e,options:i},r){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addCommentAnnotation","color: green;"),new Promise(m=>{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 h=yield this.getAddCommentAnnotationEventFromCommentAddEventData(p);m(h)}),void 0,void 0,e)})}catch(m){return this.loggingService.catch("Error in CommentActionsService addCommentAnnotation: ",m),null}})}getAddCommentAnnotationEventFromCommentAddEventData(e){return Q(this,null,function*(){try{let i=yield this.metadataService.getGlobalMetadata();return{commentAnnotation:zn(e?.annotation),annotationId:e?.annotation?.annotationId,metadata:i,addContext:e?.addContext,elementRef:e?.elementRef}}catch(i){return this.loggingService.catch("Error in CommentActionsService getAddCommentAnnotationEventFromData: ",i),null}})}triggerAddCommentAnnotationEvent(e){try{this.triggerAction(Zi.ADD_COMMENT_ANNOTATION,e)}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAddCommentAnnotationEvent: ",i)}}triggerAnnotationNotFoundError(e){try{this.loggingService.catch("Annotation not found:","The annotation with the given id was not found.")}catch(i){this.loggingService.catch("Error in CommentActionsService triggerAnnotationNotFoundError: ",i)}}deleteCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},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,i);if(p){let h=this.authService.getUser();if(this.isUserAdmin||h?.userId===p?.from?.userId){this.commentService.deleteCommentPinAnnotation(p);let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:p.annotationId,commentAnnotation:zn(p),metadata:_};return this.triggerAction(Zi.DELETE_COMMENT_ANNOTATION,E),E}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(m){return this.loggingService.catch("Error in CommentActionsService deleteCommentAnnotation: ",m),null}})}updatePriority(s,m){return Q(this,arguments,function*({annotationId:e,priority:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h=JSON.parse(JSON.stringify(h));let _=h.priority?JSON.parse(JSON.stringify(h.priority)):null;_&&i&&_?.id===i?.id?h.priority=void 0:h.priority=i,this.commentService.saveComment(h,{type:Ut.PRIORITY_CHANGED,newPriority:i,oldPriority:_});let E=yield this.metadataService.getGlobalMetadata(),D={newPriority:i,oldPriority:_,annotationId:e,commentAnnotation:zn(h),metadata:E};return this.triggerAction(Zi.UPDATE_PRIORITY,D),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_PRIORITY_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(h),oldPriority:h.priority,newPriority:i,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),D}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updatePriority: ",p),null}})}updateStatus(s,m){return Q(this,arguments,function*({annotationId:e,status:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h=JSON.parse(JSON.stringify(h));let _=h.status?JSON.parse(JSON.stringify(h.status)):null;h.status=i,this.commentService.saveComment(h,{type:Ut.STATUS_CHANGED,newStatus:i,oldStatus:_});let E=yield this.metadataService.getGlobalMetadata(),D={newStatus:i,oldStatus:_,annotationId:e,commentAnnotation:zn(h),metadata:E};return this.triggerAction(Zi.UPDATE_STATUS,D),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_STATUS_CHANGED,{annotationId:e,commentType:this.commentService.getCommentType(h),oldStatus:_,newStatus:i,commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource}),D}else this.triggerAnnotationNotFoundError(e);return null}catch(p){return this.loggingService.catch("Error in CommentActionsService updateStatus: ",p),null}})}updateAccess(s,m){return Q(this,arguments,function*({annotationId:e,accessMode:i,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 h=this.commentService.getAnnotationById(e,r);if(h)if(this.isUserAdmin){h=JSON.parse(JSON.stringify(h));let _=h.iam?.accessMode;h.iam.accessMode=i,this.commentService.saveComment(h,{type:Ut.ACCESS_MODE_CHANGED,newAccessMode:i,oldAccessMode:_});let E=yield this.metadataService.getGlobalMetadata(),D={newAccessMode:i,oldAccessMode:_,annotationId:e,commentAnnotation:zn(h),metadata:E};switch(this.triggerAction(Zi.UPDATE_ACCESS,D),i){case Qi.PRIVATE:this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:Qi.PRIVATE,source:a??this.defaultSource});break;case Qi.PUBLIC:this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCESS_MODE_CHANGED,{type:Qi.PUBLIC,source:a??this.defaultSource});break;default:break}return D}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:i}){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,i);if(s){s=JSON.parse(JSON.stringify(s));let m=this.customFilterService.resolvedStatus,p=s.status?JSON.parse(JSON.stringify(s.status)):null;m&&(s.status=m,this.commentService.saveComment(s,{type:Ut.STATUS_CHANGED,newStatus:m,oldStatus:p}));let h=yield this.metadataService.getGlobalMetadata(),_={annotationId:e,commentAnnotation:zn(s),metadata:h};return this.triggerAction(Zi.RESOLVE_COMMENT,_),_}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:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getLink","color: green;");let m=this.commentService.getAnnotationById(e,i);if(m){let p=this.commentService.getCommentUrl(m)??null,h=yield this.metadataService.getGlobalMetadata();return{link:p,annotationId:e,commentAnnotation:zn(m),metadata:h}}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService getLink: ",m),null}})}copyLink(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: copyLink","color: green;");let m=yield this.getLink({annotationId:e,options:i},r);if(m?.link){bs(m.link),this.commentService.setCopyLink(m.link),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_LINK_COPIED,{annotationId:e,commentType:this.commentService.getCommentType(m.commentAnnotation),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource,link:m.link});let p=yield this.metadataService.getGlobalMetadata(),h={link:m.link,annotationId:e,commentAnnotation:zn(m.commentAnnotation),metadata:p};return this.triggerAction(Zi.COPY_LINK,h),h}return null}catch(m){return this.loggingService.catch("Error in CommentActionsService copyLink: ",m),null}})}addComment(p,h){return Q(this,arguments,function*({annotationId:e,comment:i,assignedTo:r,assigned:a,options:s},m){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addComment","color: green;");let _=this.authService.getUser();if(!_)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_){let E=this.commentService.getAnnotationById(e,s),D=E?.comments?.length?Ut.ADDED:Ut.NEWLY_ADDED;if(E){E.status.type==="terminal"&&(E.status=this.customFilterService.defaultStatus);let L=new xc;L=I(I({},L),i),L.lastUpdated=new Date,L.attachments||(L.attachments=[]),L.attachments=L.attachments.filter(oe=>oe?.attachmentId),L.createdAt=this.timestamp,L.from=_,r&&(E.assignedTo=r),this.commentService.saveComment(E,{type:D,updatedComment:L,assigned:a});let H=yield this.metadataService.getGlobalMetadata(),K={annotationId:e,commentId:L?.commentId,comment:L,commentAnnotation:zn(E),metadata:H};return this.triggerAction(Zi.ADD_COMMENT,K),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ADDED,{annotationId:e,commentThreadId:i?.commentId,commentType:this.commentService.getCommentType(E),commentMode:this.commentService.getCommentMode(),source:m??this.defaultSource}),K}else this.triggerAnnotationNotFoundError(e)}return null}catch(_){return this.loggingService.catch("Error in CommentActionsService addComment: ",_),null}})}approveCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: approveCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i);if(m){m.approved=!0,this.commentService.saveComment(m,{type:Ut.APPROVED}),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_APPROVED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource});let p=yield this.metadataService.getGlobalMetadata(),h={annotationId:e,commentAnnotation:zn(m),metadata:p};return this.triggerAction(Zi.APPROVE_COMMENT_ANNOTATION,h),h}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService approveComment: ",m),null}})}acceptCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: acceptCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=m.status?JSON.parse(JSON.stringify(m.status)):null;m.status=j.CommentAcceptStatus,this.commentService.saveComment(m,{type:Ut.ACCEPTED,oldStatus:h,newStatus:j.CommentAcceptStatus});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:zn(m),metadata:_,actionUser:p,replaceContentHtml:m?.comments?.length?m?.comments[0]?.replaceContentHtml:void 0,replaceContentText:m?.comments?.length?m?.comments[0]?.replaceContentText:void 0};return this.triggerAction(Zi.ACCEPT_COMMENT_ANNOTATION,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ACCEPTED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),E}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService acceptCommentAnnotation: ",m),null}})}rejectCommentAnnotation(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: rejectCommentAnnotation","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=m.status?JSON.parse(JSON.stringify(m.status)):null;m.status=j.CommentRejectStatus,this.commentService.saveComment(m,{type:Ut.REJECTED,oldStatus:h,newStatus:j.CommentRejectStatus});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:zn(m),metadata:_,actionUser:p,replaceContentHtml:m?.comments?.length?m?.comments[0]?.replaceContentHtml:void 0,replaceContentText:m?.comments?.length?m?.comments[0]?.replaceContentText:void 0};return this.triggerAction(Zi.REJECT_COMMENT_ANNOTATION,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_REJECTED,{annotationId:e,commentType:this.commentService.getCommentType(m),commentMode:this.commentService.getCommentMode(),source:r??this.defaultSource}),E}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService rejectCommentAnnotation: ",m),null}})}toggleNotificationSubscription(a,s){return Q(this,arguments,function*({annotationId:e,options:i},r){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleNotificationSubscription","color: green;");let m=this.commentService.getAnnotationById(e,i),p=this.authService.getUser();if(m&&p){let h=Pt(p.userId);if(h){m.subscribedUsers||(m.subscribedUsers={}),m.unsubscribedUsers||(m.unsubscribedUsers={});let _,E=!1;if(m?.unsubscribedUsers?.[h])E=!1;else if(m?.subscribedUsers?.[h])E=!0;else{let H=this.contactService.getCurrentOrganizationUserIAM();if(H){let K=H.groups||{};Object.keys(K).forEach(oe=>{m?.subscribedGroups?.[oe]&&(E=!0)})}}if(r==="subscribe"||!r&&!E)delete m.unsubscribedUsers[h],m.subscribedUsers[h]={user:p,type:"manual"},_=Ut.SUBSCRIBED;else if(r==="unsubscribe"||!r&&E)delete m.subscribedUsers[h],m.unsubscribedUsers[h]={user:p,type:"manual"},_=Ut.UNSUBSCRIBED;else return null;this.commentService.saveComment(m,{type:_});let D=yield this.metadataService.getGlobalMetadata(),L={annotationId:e,commentAnnotation:zn(m),metadata:D};return _===Ut.SUBSCRIBED?this.triggerAction(Zi.SUBSCRIBE_COMMENT_ANNOTATION,L):this.triggerAction(Zi.UNSUBSCRIBE_COMMENT_ANNOTATION,L),L}}else this.triggerAnnotationNotFoundError(e);return null}catch(m){return this.loggingService.catch("Error in CommentActionsService toggleNotificationSubscription: ",m),null}})}assignUser(s,m){return Q(this,arguments,function*({annotationId:e,assignedTo:i,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 h=this.commentService.getAnnotationById(e,r);if(h){h.assignedTo=i,this.commentService.saveComment(h,{type:Ut.ASSIGNED,assignedTo:i});let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,assignedTo:i,commentAnnotation:zn(h),metadata:_};return this.triggerAction(Zi.ASSIGN_USER,E),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_ASSIGNED,{annotationId:e,commentType:this.commentService.getCommentType(h),commentMode:this.commentService.getCommentMode(),source:a??this.defaultSource,assignedToUserId:i?.userId}),E}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:i}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: getComment","color: green;");let a=this.commentService.getAnnotationById(e,i);return a?a.comments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(a){return this.loggingService.catch("Error in CommentActionsService getComment: ",a),[]}})}updateOrDeleteComment(e,i,r,a,s){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateOrDeleteComment","color: green;"),i?.commentText?.trim()||i?.attachments?.length||i?.recorders?.length){let m=this.authService.getUser();if(this.isUserAdmin||m?.userId===i?.from?.userId){i.lastUpdated=new Date,i.status=Ut.UPDATED,i.isEdited||(i.isEdited=!0,i.editedAt=new Date),this.commentService.saveComment(e,{type:Ut.UPDATED,updatedComment:i});let p=yield this.metadataService.getGlobalMetadata(),h={annotationId:e?.annotationId,commentId:i?.commentId,comment:i,commentAnnotation:zn(e),metadata:p};return this.triggerAction(Zi.UPDATE_COMMENT,h),this.analyticsService.trackEvent(X.Events.Comments.COMMENT_EDITED,{annotationId:e?.annotationId,commentThreadId:i?.commentId,commentType:this.commentService.getCommentType(e),commentMode:this.commentService.getCommentMode(),source:s??this.defaultSource}),h}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:i.commentId,skipDeleteThreadConfirmation:r,options:a});return null}catch(m){return this.loggingService.catch("Error in CommentActionsService updateOrDeleteComment: ",m),null}})}updateComment(p,h){return Q(this,arguments,function*({annotationId:e,comment:i,skipDeleteThreadConfirmation:r,merge:a,options:s},m){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: updateComment","color: green;");let _=this.commentService.getAnnotationById(e,s),E=this.authService.getUser();if(!E)return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),null;if(_&&E){let D=i,L=_.comments?.find(H=>H.commentId===i.commentId);if(L){if(this.isUserAdmin||E?.userId===L?.from?.userId)return _?.status.type==="terminal"&&(_.status=this.customFilterService.defaultStatus),a&&(D=I(I({},L),i)),D.from=L.from,D.createdAt=L.createdAt,D.lastUpdated=new Date,yield this.updateOrDeleteComment(_,D,r,s,m);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(_){return this.loggingService.catch("Error in CommentActionsService updateComment: ",_),null}})}deleteComment(m,p){return Q(this,arguments,function*({annotationId:e,commentId:i,skipDeleteThreadConfirmation:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteComment","color: green;");let h=this.commentService.getAnnotationById(e,a),_=this.authService.getUser();if(h){let E=h.comments?.find(D=>D?.commentId===i);if(E)if(this.isUserAdmin||_?.userId===E?.from?.userId){this.commentService.saveComment(h,{type:Ut.DELETED,updatedComment:E,skipDeleteThreadConfirmation:r});let D=yield this.metadataService.getGlobalMetadata(),L={annotationId:e,commentId:i,commentAnnotation:zn(h),comment:E,metadata:D};return this.triggerAction(Zi.DELETE_COMMENT,L),L}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(h){return this.loggingService.catch("Error in CommentActionsService deleteComment: ",h),null}})}addAttachment(s,m){return Q(this,arguments,function*({annotationId:e,files:i,options:r},a){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: addAttachment","color: green;");let p=[],h=this.commentService.getAnnotationById(e,r);if(h||a==="internal"){let D=[];i.forEach(L=>{let{valid:H,file:K,maxAllowedSize:oe,error:ue}=this.validateFile(L);H&&K?D.push(this.uploadFile(K,h||{}).then(be=>({valid:H,file:K,maxAllowedSize:oe,error:ue,attachment:be||void 0}))):D.push(Promise.resolve({valid:H,file:K,maxAllowedSize:oe,error:ue,attachment:void 0}))}),p=yield Promise.all(D)}else this.triggerAnnotationNotFoundError(e);let _=yield this.metadataService.getGlobalMetadata(),E={annotationId:e,commentAnnotation:h?zn(h):void 0,attachments:p,metadata:_};return this.triggerAction(Zi.ADD_ATTACHMENT,E),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 i=100*1024*1024;(e?.type?.includes("image")||e?.type?.includes("pdf"))&&(i=15*1024*1024);let r=e.size<=i;return{valid:r,file:e,maxAllowedSize:i,maxAllowedSizeInMB:i/1024/1024,error:r?void 0:`File size should be less than ${i/1024/1024} MB`}}catch(i){return this.loggingService.catch("Error in CommentActionsService validateFile: ",i),{valid:!1,maxAllowedSize:0,maxAllowedSizeInMB:0,error:"Error in validating file"}}}deleteAttachment(s){return Q(this,arguments,function*({annotationId:e,commentId:i,attachmentId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteAttachment","color: green;");let m=this.commentService.getAnnotationById(e,a);if(m){let p=m.comments?.find(_=>_?.commentId===i),h=m.metadata;if(p){let _=this.authService.getUser();if(this.isUserAdmin||_?.userId===p?.from?.userId){let E=p.attachments?.find(D=>D?.attachmentId===r);if(E){p.attachments=p.attachments?.filter(K=>K?.attachmentId!==r);let D={attachmentId:E.attachmentId,organizationId:h?.organizationId??null,documentId:h?.documentId??null,folderId:h?.folderId??null,commentAnnotationId:m.annotationId,apiKey:h?.apiKey??null};yield this.commentService.deleteAttachment({attachment:E,metadata:D});let L=yield this.metadataService.getGlobalMetadata(),H={attachment:E,annotationId:e,commentId:i,commentAnnotation:zn(m),metadata:L};return this.triggerAction(Zi.DELETE_ATTACHMENT,H),this.updateComment({annotationId:e,comment:p,options:a}),H}}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(m){return this.loggingService.catch("Error in CommentActionsService deleteAttachment: ",m),null}})}getAttachment(a){return Q(this,arguments,function*({annotationId:e,commentId:i,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===i)?.attachments||[]:(this.triggerAnnotationNotFoundError(e),[])}catch(s){return this.loggingService.catch("Error in CommentActionsService getAttachment: ",s),[]}})}uploadFile(e,i){return Q(this,null,function*(){try{return this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: uploadFile","color: green;"),this.commentService.uploadFile(e,i)}catch(r){return this.loggingService.catch("Error in CommentActionsService uploadFile: ",r),null}})}getRecording(a){return Q(this,arguments,function*({annotationId:e,commentId:i,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===i)?.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:i,recorderId:r,options:a}){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: deleteRecording","color: green;");let m=this.commentService.getAnnotationById(e,a);if(m){let p=m.comments?.find(h=>h?.commentId===i);if(p){let h=this.authService.getUser();if(this.isUserAdmin||h?.userId===p?.from?.userId){let _=p.recorders?.find(E=>E?.id===r);if(_){p.recorders=p.recorders?.filter(L=>L?.id!==r);let E=yield this.metadataService.getGlobalMetadata(),D={annotationId:e,commentId:i,recording:_,commentAnnotation:zn(m),metadata:E};return this.triggerAction(Zi.DELETE_RECORDING,D),this.updateComment({annotationId:e,comment:p,skipDeleteThreadConfirmation:!0,options:a}),D}}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(m){return this.loggingService.catch("Error in CommentActionsService deleteRecording: ",m),null}})}fetchCommentAnnotations(e){return Q(this,null,function*(){try{let i=yield this.commentService.fetchCommentAnnotations(e),r;if(i?.hasMore){let s=i?.data[i?.data?.length-1];r=yield SU(s?.lastUpdated?.toString()??"","veltencrypttoken","veltencrypttoken")}let a=i?.data?.reduce((s,m)=>(s[m.metadata.clientDocumentId??m.metadata.documentId]=s[m.metadata.clientDocumentId??m.metadata.documentId]||[],s[m.metadata.clientDocumentId??m.metadata.documentId].push(zn(m)),s),{});return I({data:a},i?.hasMore?{nextPageToken:r}:{})}catch(i){return this.loggingService.catch("Error in CommentActionsService fetchCommentAnnotations: ",i),{data:null}}})}toggleReaction(m,p){return Q(this,arguments,function*({annotationId:e,commentId:i,reaction:r,options:a},s){try{this.loggingService.log("%c[WB] Calling CommentActionsService FUNCTION: toggleReaction","color: green;");let h=this.commentService.getAnnotationById(e,a),_=this.authService.getUser();if(h&&_){let E=h.comments?.find(D=>D?.commentId===i);if(E){let D=yield this.reactionService.addOrUpdateReaction(r.reactionId,E?.reactionAnnotationIds||[],void 0,void 0,h?.annotationId,r.customReaction,s),L=Ut.REACTION_ADDED;if(D){D?.reactions?.find(oe=>oe.from?.userId===_?.userId)||(L=Ut.REACTION_DELETED),E.reactionAnnotationIds||(E.reactionAnnotationIds=[]),E.reactionAnnotationIds.includes(D.annotationId)||E.reactionAnnotationIds.push(D.annotationId),D?.reactions?.length||(E.reactionAnnotationIds=E.reactionAnnotationIds.filter(oe=>oe!==D.annotationId)),this.commentService.saveComment(h,{type:L,updatedComment:E});let H=yield this.metadataService.getGlobalMetadata(),K={annotationId:e,commentId:i,reaction:D,commentAnnotation:zn(h),metadata:H};return s==="add"?this.triggerAction(Zi.ADD_REACTION,K):s==="delete"?this.triggerAction(Zi.DELETE_REACTION,K):this.triggerAction(Zi.TOGGLE_REACTION,K),K}}}else this.triggerAnnotationNotFoundError(e);return null}catch(h){return this.loggingService.catch("Error in CommentActionsService toggleReaction: ",h),null}})}onComposerClick(i){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?zn(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 i=yield this.metadataService.getGlobalMetadata();e.metadata=i,this.triggerAction(Zi.AUTOCOMPLETE_SEARCH,e)}catch(i){this.loggingService.catch("Error in CommentActionsService autocompleteSearch: ",i)}})}convert(e){try{if(e?.options){let{documentId:i,organizationId:r}=this.docService.getServerId(e?.options);e.options=T(I({},e?.options),{documentId:i,organizationId:r})}return this}catch(i){return this.loggingService.catch("Error in CommentActionsService convert: ",i),this}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in CommentActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in CommentActionsService onAction: ",i),se(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."),se({data:null});if(!e?.allDocuments&&!e?.documentIds?.length)return this.loggingService.catch("documentIds is required."),se({data:null})}return this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,query:e,addFilterCommentsOnDomCheck:!0}).pipe(ce(i=>i?i.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),ce(i=>({data:i})))}catch(i){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",i),se({data:null})}}getCommentAnnotationsCount$(e){try{return this.commentService.getAnnotationsCount(e).pipe(ce(i=>i||{data:null}))}catch(i){return this.loggingService.catch("Error in CommentActionsService getCommentAnnotation: ",i),se({data:null})}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(He),J(we),J(Ci),J(zo),J(lt),J(fn),J(y),J(Mm),J(nr),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var r0=(()=>{let o=class o{constructor(e,i){this.httpClient=e,this.loggingService=i,this.fileContentMap$=new Ce({})}getFileContent(e){try{let i=yn(e);return this.fileContentMap$.value[i]?se(this.fileContentMap$.value[i]):this.httpClient.get(e,{responseType:"text"}).pipe(ce(r=>(this.fileContentMap$.next(T(I({},this.fileContentMap$.value),{[i]:r})),r)))}catch(i){return this.loggingService.catch("Error in TranscriptionService saveRecorderToDb: ",i),se(null)}}getVttFileTextToArray(e){try{let m=[],p=e.split(`
|
|
382
382
|
`);for(var i=0;i<p.length;i++)if(p[i].indexOf("-->")!==-1){var r=p[i].split(" --> ")[0],a=p[i].split(" --> ")[1],s=p[i+1];m.push({startTime:r,endTime:a,startTimeInSeconds:this.getTimeInSecondsFromVttTime(r),endTimeInSeconds:this.getTimeInSecondsFromVttTime(a),text:s})}return m}catch(m){return this.loggingService.catch("Error in TranscriptionService getVttFileTextToArray: ",m),[]}}getTimeInSecondsFromVttTime(e){try{let i=e.split(":"),r=0;i.length===3&&(r=parseInt(i[0]),i.shift());let a=parseInt(i[0]),s=parseInt(i[1].split(".")[0]),m=parseInt(i[1].split(".")[1]);return((r*60*60+a*60+s)*1e3+m)/1e3}catch(i){return this.loggingService.catch("Error in TranscriptionService getTimeInSecondsFromVttTime: ",i),0}}};o.\u0275fac=function(i){return new(i||o)(J(ZO),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ji=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L,H,K,oe,ue,be,Le,qe){this.analyticsService=e,this.configService=i,this.docService=r,this.databaseService=a,this.commonDbService=s,this.authService=m,this.domService=p,this.afAuth=h,this.iamService=_,this.functions=E,this.avatarService=D,this.contactService=L,this.storageService=H,this.dialog=K,this.loggingService=oe,this.notificationService=ue,this.transcriptionService=be,this.recorderService=Le,this.recorderUtilsService=qe,this.recorderAnnotationById$=new Ce({}),this.documentPaths=null,this.db=Ii(),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.getAllRecorderAnnotations().subscribe(Re=>{}),this.loggingService.log("%c[WB] Creating CLASS: RecorderAnnotationService","color: blue;"),this.analyticsService.setRecorderAnnotationService(this),this.authService.setRecorderAnnotationService(this),this.databaseService.getDb().pipe(Fe(Re=>!!Re),tt(1)).subscribe(Re=>{Re&&(this.db=Re,this.getDocumentPaths())},Re=>{this.loggingService.catch("Error in RecorderAnnotationService getDb subscription: ",Re)}),this.domService.onWindowPointerMove$().subscribe(Re=>{if(this.addRecorderMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let _e=this.domService.getBackgroundElement(Re.clientX,Re.clientY);_e&&(this.isElementInsideAllowedElements(_e)?z6(Re.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=_e):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowPointerMove$ subscription: ",Re)}),this.domService.onWindowKeyupEsc$().subscribe(Re=>{this.addRecorderMode$.value&&this.disableAddRecorderMode()},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupEsc$ subscription: ",Re)}),this.domService.onDocumentClick$().subscribe(Re=>{if(Re&&this.addRecorderMode$.value){if(Re.preventDefault(),Re.stopPropagation(),!z6(Re.target)){let _e=this.domService.getBackgroundElement(Re.clientX,Re.clientY);_e&&this.isElementInsideAllowedElements(_e)}this.disableAddRecorderMode()}},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onDocumentClick$ subscription: ",Re)}),this.addRecorderMode$.subscribe(Re=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),Re?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"))},Re=>{this.loggingService.catch("Error in RecorderAnnotationService addRecorderMode$ subscription: ",Re)}),this.domService.onWindowKeyupBackspace$().subscribe(Re=>{this.deleteRecorderPinAnnotations()},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupBackspace$ subscription: ",Re)}),this.domService.onWindowKeyupDelete$().subscribe(Re=>{this.deleteRecorderPinAnnotations()},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Re)}),this.recorderService.onRecordedData().subscribe(Re=>{this.recordedData=Re},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onRecordedData subscription: ",Re)}),this.domService.getDeleteCommmentAnnotations$().subscribe(Re=>{Re?.length&&Re.forEach(_e=>Q(this,null,function*(){}))},Re=>{this.loggingService.catch("Error in RecorderAnnotationService onWindowKeyupDelete$ subscription: ",Re)})}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(gn(e=>{this.documentPaths=e})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths subscription: ",e)})}catch(e){this.loggingService.catch("Error in CursorService getDocumentPaths: ",e)}}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(ce(()=>this.getAnnotationById(e)),he(i=>Q(this,null,function*(){return i?yield this.createRecorderData(i,!0):void 0})))}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderId: ",i),se(void 0)}}getRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let i={};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&&(i[r]=s)}))),{data:Object.keys(i).length>0?i:null}}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderDataByRecorderIds: ",i),{data:null}}})}fetchRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let i=this.recorderAnnotationById$.value,r=[],a=Object.values(i);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 m=yield this.createRecorderData(s,!0);m&&r.push(m)}))),r)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService fetchRecorderDataByRecorderIds: ",i),[]}})}deleteRecorderDataByRecorderIds(e){return Q(this,null,function*(){try{let i=this.recorderAnnotationById$.value,r=[],a=Object.values(i),s=[];return e?.recorderIds?.length&&(s=a.filter(m=>e.recorderIds.includes(m.annotationId))),s.length===0?[]:(yield Promise.all(s.map(m=>Q(this,null,function*(){if(!m)return;let p=yield this.createRecorderData(m,!0);yield this.deleteRecorderPinAnnotation(m),p&&r.push(p)}))),r)}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderDataByRecorderIds: ",i),[]}})}getRecordings(e){try{return this.recorderAnnotationById$.pipe(he(i=>Q(this,null,function*(){let r=[],a=Object.values(i);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 m=yield this.createRecorderData(s,!0);m&&r.push(m)}))),r)})),jn(i=>(this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",i),se([]))))}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService getRecordings: ",i),se([])}}setRecorderActionsService(e){try{this.recorderActionsService=e}catch(i){this.loggingService.catch("Error in RecorderAnnotationService setRecorderActionsService: ",i)}}getVttFileTextToArray(e){try{return this.transcriptionService.getVttFileTextToArray(e)}catch(i){this.loggingService.catch("Error in RecorderAnnotationService getVttFileTextToArray: ",i)}}getAllRecorderAnnotations(e,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllRecorderAnnotations","color: green;");let a,s;try{if(e&&(s=yn(e)),i&&typeof i=="object"){let m=Jo(i);a=yn(JSON.stringify(m))}}catch(m){this.loggingService.catch("Error in RecorderAnnotationService getAllRecorderAnnotations: ",m)}return qn(this.afAuth).pipe(Fe(m=>!!m),he(m=>this.isFeatureAllowed({firebaseUser:m,annotations:[],filteredAnnotations:[]})),he(m=>m.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(p=>(m.featureAllowed=p,m))):se(m)),he(m=>m.featureAllowed?this.authService.isPlanExpired$().pipe(ce(p=>(m.featureAllowed=!p,m))):se(m)),he(m=>m.featureAllowed?se(m).pipe(he(p=>this.docService.getDocumentPaths$().pipe(ce(h=>(this.documentPaths=h,p.documentPaths=h,p)))),he(p=>s?this.getDataFromDocumentIds([s]).pipe(ce(h=>(p.annotations=h||[],I({},p)))):this.docService.getDocumentIds$().pipe(he(h=>{let _=h?.length>0?h.map(E=>E.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(_).pipe(ce(E=>(p.annotations=E||[],I({},p))))}))),he(p=>this.docService.getLocation$().pipe(ce(h=>(p.location=h,p)))),he(p=>this.docService.getLocations$().pipe(ce(h=>(p.customLocations=h,p)))),ce(p=>{if(p.filteredAnnotations=[],s&&!a)return p.filteredAnnotations=p.annotations?.slice(),p;{let h=[];return a?h.push(a):(h.push(p?.location?.locationId),h.push(...Object.values(p?.customLocations||[]).map(_=>_.locationId))),p.filteredAnnotations=this.filterAnnotationsByLocationIds(p?.annotations,h),p}}),he(p=>r?se(p):p?.annotations?.length?this.domService.onWindowResize$().pipe(ce(()=>p)):se(p)),he(p=>r?se(p):p?.annotations?.length?this.domService.onDomChange$("RecorderAnnotationService getAllRecorderAnnotations").pipe(ce(()=>p)):se(p)),ce(p=>{let h=[];return p?.filteredAnnotations?.forEach(_=>{this.calculateRecorderAnnotationPosition(_),_?.targetElement||h.push(_)}),this.draftRecordings$.next(h),p}),he(p=>p?.filteredAnnotations?se(p?.filteredAnnotations||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.RECORDER)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Recorder feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentIds(e,i){return this.getDataFromDocuments({documentIds:e,filters:i})}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:i,filters:r}=e;if(i?.some(h=>!h)||!this.documentPaths)return se([]);let a=this.docService.getDocumentPaths()?.veltFolderId,s=this.docService.getDocumentPaths()?.allDocuments,m=se([]),p={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(p.documentId=i?.length?i[0]:void 0,p.organizationId=this.documentPaths?.organizationId),a&&s)m=this.commonDbService.dbListener({feature:"allRecorders",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.veltFolderId","==",a),gt("metadata.organizationId","==",this.documentPaths?.organizationId))]})});else{let h=[];for(let _=0;_<(i?.length??0);_+=j.LISTENER_BATCH_SIZE)h.push(i?.slice(_,_+j.LISTENER_BATCH_SIZE)??[]);m=Rn(h.map(_=>this.commonDbService.dbListener({feature:"allRecorders",properties:T(I({},p),{firestoreQuery:[Ui(gt("metadata.apiKey","==",this.configService?.getApiKey()),gt("metadata.documentId","in",_),gt("metadata.organizationId","==",this.documentPaths?.organizationId),...a?[gt("metadata.veltFolderId","==",a)]:[])]})}).pipe(Gr()))).pipe(ce(_=>ua(_)))}return m.pipe(ce(h=>({data:h?.data,operation:h?.operation})),ce(({data:h,operation:_})=>{let E=[];return h&&(E=Object.values(h).filter(D=>typeof D=="object")),{data:E,operation:_}}),ce(({data:h,operation:_})=>{if(!i)return{data:h,documentMap:{},operation:_};let E=h.reduce((D,L)=>{let H=L.metadata?.documentId;return H&&(D[H]||(D[H]=[]),D[H].push(L)),D},{});return{data:h,documentMap:E,operation:_}}),ce(({data:h,documentMap:_,operation:E})=>{if(!r)if(E?.type==="removed"){if(E?.ids?.length){let D=this.recorderAnnotationById$.value;E?.ids?.forEach(L=>{delete D?.[L]}),this.recorderAnnotationById$.next(D)}}else Object.entries(_).forEach(([D,L])=>{this.setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:D,annotations:L})});return h}),jn(h=>(this.loggingService.catch("Error in RecorderAnnotationService getDataFromDocumentId: ",h),se([]))))}else return se([])}setRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i,annotations:r,queryHash:a}){try{if(i){e||(e=j.NO_ORGANIZATION_ID),a||(a=j.DEFAULT_QUERY_HASH);let s={};r?.forEach(p=>{p?.annotationId&&(s[p?.annotationId]=p)});let m=I(I({},this.recorderAnnotationById$.value),s);this.recorderAnnotationById$.next(m)}}catch(s){this.loggingService.catch("Error in RecorderAnnotationService setRecorderAnnotationsByOrganizationIdAndDocumentId:",s)}}filterAnnotationsByLocationIds(e,i){try{return e.filter(r=>i.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService filterAnnotationsByLocations:",r),[]}}calculateRecorderAnnotationPosition(e){try{if(e.targetElement){let i=this.domService.getXPath(e.targetElement?.xpath);if(i){let r=i.iterateNext();if(r&&Do(r)){let a=r.getBoundingClientRect();if(a&&a.width&&a.height){let{height:s,width:m}=Np(r);e.position={top:s*e.targetElement.topPercentage/100,left:m*e.targetElement.leftPercentage/100}}else e.position=null}else e.position=null}else e.position=null}}catch(i){this.loggingService.catch("Error in RecorderAnnotationService calculateRecorderAnnotationPosition:",i)}}getAnnotationById(e,i){try{let r=this.recorderAnnotationById$.value?.[e];if(r){let{documentId:a,organizationId:s}=i||{};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 i=this.recorderAnnotationById$.value?.[e];if(i)return i.metadata}catch(i){this.loggingService.catch("Error in RecorderAnnotationService getBaseMetadataFromRecorderAnnotationId: ",i)}}getRecorderAnnotationById(e,i){return this.recorderAnnotationById$.pipe(he(()=>{let r=this.getAnnotationById(e,i);return r?se(r):se(null)}),jn(r=>(this.loggingService.catch("Error in RecorderAnnotationService getCommentAnnotationById: ",r),se(null))))}getRecorderAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:i}){try{let r={};return Object.values(this.recorderAnnotationById$.value).forEach(a=>{a?.metadata?.documentId==i&&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 i=this.docService.getLocation();i?(e.locationId=i.locationId,e.location=i.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);a&&this.docService.addLocation({location:a}).then(s=>{s?.[0]&&(e.locationId=s[0].locationId,e.location=s[0].location)})}}catch{}}catch(i){this.loggingService.catch("Error in RecorderAnnotationService setLocationToRecorderAnnotation:",i)}}addRecorder(e,i,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."),se(null);{i.from=a,i.color=j.DEFAULT_ANNOTATION_COLOR,i.lastUpdated=this.timestamp;let{topPositionX:s,topPositionY:m}=this.domService.getTopLeftPosition();i.positionX=s,i.positionY=m;let p=this.domService.getCurrentWindowSizeValue();if(i.screenWidth=p.screenWidth,i.screenHeight=p.screenHeight,i.screenScrollHeight=p.screenScrollHeight,i.recorderedElementPath="",e&&(i.targetElement=this.domService.getTargetElementForCursorPosition(e)),i?.targetElement?.xpath){let h=this.domService.getXPath(i.targetElement.xpath);if(h){let _=h.iterateNext();_&&(Do(_)||(i.targetElement=null))}}return this.setLocationToRecorderAnnotation(i),i.pageInfo=Ei(),i.pageInfo&&(i.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveRecorderToDb(i,r)}}else return se(null)}catch(a){return this.loggingService.catch("Error in RecorderAnnotationService addRecorder: ",a),se(null)}}saveRecorderToDb(e,i){this.loggingService.log("%c[WB] Calling FUNCTION: saveRecorderToDb","color: green;");try{return this.authService.getUser()&&this.authService.isFeatureAllowed(ke.RECORDER)?this.docService.getDocumentPaths$().pipe(Fe(r=>!!r),tt(1),he(r=>(this.documentPaths=r,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(Fe(a=>!!a),tt(1),he(a=>Q(this,null,function*(){if(this.db=a,this.loggingService.log(this.db),this.documentPaths?.recorder){let s=rn(this.db,`${this.documentPaths?.recorder}`);e.annotationId=this.commonDbService.generateDocumentId(),e.pageInfo&&(e.pageInfo.recorderUrl=this.generateRecorderUrl(e));let m=JSON.parse(JSON.stringify(e));if(m.position=null,!m?.metadata?.documentId){m?.metadata||(m.metadata={});let _=this.docService.getBaseMetadata("recorder",{commentAnnotationId:e.commentAnnotationId});m.metadata=I(I({},m?.metadata),_)}let{documentId:p,organizationId:h}=m?.metadata||{};return yield new Promise((_,E)=>Q(this,null,function*(){yield this.commonDbService.setData({feature:"recorder",properties:{id:e.annotationId,documentId:p,organizationId:h},data:JSON.parse(JSON.stringify(m)),callback:()=>{_(!0)},errorCallback:D=>{E(D)}})})),this.analyticsService.trackEvent(X.Events.Recording.RECORDING_ADDED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e?.attachment?.size,sourceFeature:i||"recording"}),this.setVideoEditorAutoOpen({[e.annotationId]:!0}),this.processRecording(e,"recording","merge"),this.updateNotificationsDatabase(e,pv.ADDED),e}else return null})))))):se(null)}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService saveRecorderToDb: ",r),se(null)}}processRecording(e,i,r){return Q(this,null,function*(){try{let a=yr(this.functions,br({url:Xn?.cloudFunction?.processRecording,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),s=this.docService.getDocumentPaths();e?.metadata?.documentId&&(s=new Om({apiKey:this.configService.getApiKey(),clientDocumentId:e.metadata.clientDocumentId,clientOrganizationId:e.metadata.clientOrganizationId,documentId:e.metadata.documentId,organizationId:e.metadata.organizationId}));let m={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:ga(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:s?.recorder,annotationId:e?.annotationId,sourceFeature:i||"recording",annotationData:e,skipMerge:!0,transcriptionEnabled:this.getRecordingTranscriptionEnabled(),type:r,returnType:"transcription"};if(m?.useFirestore){let H=yield this.recorderUtilsService.encryptRecorderAnnotation(e);m.annotationData=H}let p=this.documentPaths?.organizationId,h=this.documentPaths?.documentId;e?.metadata?.documentId&&(h=e.metadata.documentId,p=e.metadata.organizationId);let _=`${this.configService.getApiKey()}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${h}/${j.FIREBASE_PARTIAL_PATH_RECORDER}`;p&&(_=`${this.configService.getApiKey()}/${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${p}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${h}/${j.FIREBASE_PARTIAL_PATH_RECORDER}`),m.bucketPath=_;let E;try{E=yield a(m)}catch(H){H?.details?.type==="recording"&&this.recorderActionsService?.onError({type:"recordingFailed",message:"Recording failed",recorderId:H.details.recorderId}),H?.details?.type==="transcription"&&this.recorderActionsService?.onError({type:"transcriptionFailed",message:"Transcription failed",recorderId:H.details.recorderId}),this.loggingService.catch("Error in RecorderAnnotationService processRecording: ",H)}let D=this.getAnnotationById(e?.annotationId);if(!D)return;let L=yield this.createRecorderData(D,!1);if(L){if(E?.data?.transcriptedText&&(L.transcription.contentSummary=E.data.transcriptedText),E?.data?.vttUrl)try{let H=yield this.transcriptionService.getFileContent(E.data.vttUrl).toPromise();H&&(L.transcription.transcriptSegments=this.getVttFileTextToArray(H),L.transcription.vttFileUrl=E.data.vttUrl),this.recorderActionsService?.onTranscriptionDone(L)}catch(H){this.loggingService.catch("Error fetching VTT content: ",H)}D?.attachments?.length&&this.recordedData&&(this.recordedData.videoUrl=D.attachments[0].url),i==="recording"?this.recorderActionsService?.onRecordingDone(L):i==="trimmed"&&this.recorderActionsService?.onRecordingEditDone(L)}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(i){return this.loggingService.catch("Error in RecorderAnnotationService getDocumentIdAndOrganizationIdFromRecorderAnnotation: ",i),{}}}createRecorderData(e,i=!1){return Q(this,null,function*(){try{if(!e)return null;let r=_v(e.metadata||{}),a=ha(e.from),s={recorderId:e.annotationId||"",from:a,assets:[],metadata:r,assetsAllVersions:[],transcription:{transcriptSegments:[],vttFileUrl:"",contentSummary:""}},m=e;e.latestVersion&&e.recordingEditVersions?.[e.latestVersion]&&(m=e.recordingEditVersions[e.latestVersion]);let p=_=>Q(this,null,function*(){let E={transcriptSegments:[],vttFileUrl:"",contentSummary:_?.transcription?.transcriptedText||""};if(i&&_?.transcription?.vttUrl)try{let D=yield this.transcriptionService.getFileContent(_.transcription.vttUrl).toPromise();D&&(E.transcriptSegments=this.getVttFileTextToArray(D),E.vttFileUrl=_.transcription.vttUrl)}catch(D){this.loggingService.catch("Error fetching VTT content: ",D)}return E}),h=yield p(m);if(s.transcription=h,m?.attachments?.length)for(let _ of m.attachments)_?.url&&s.assets.push({version:e.latestVersion||1,url:_.url,mimeType:_.mimeType,fileName:_.name,fileSizeInBytes:_.size,fileFormat:_.type,transcription:I({},h),thumbnailUrl:e.attachments?.[0]?.thumbnail});if(e.recordingEditVersions){let _=Object.entries(e.recordingEditVersions).map(H=>Q(this,[H],function*([D,L]){let K=parseInt(D),oe=yield p(L),ue=L?.attachments?.[0]||L?.attachment;return{version:K,url:ue?.url,mimeType:ue?.mimeType,fileName:ue?.name,fileSizeInBytes:ue?.size,fileFormat:ue?.type,transcription:oe,thumbnailUrl:L?.attachments?.[0]?.thumbnail}})),E=yield Promise.all(_);s.assetsAllVersions=E.filter(D=>D.url)}else s.assetsAllVersions=[...s.assets];return s}catch(r){return this.loggingService.catch("Error in RecorderAnnotationService createRecorderData: ",r),null}})}updateRecorder(e,i=!1,r){try{r&&this.setLocationToRecorderAnnotation(e),i&&this.updateNotificationsDatabase(e,pv.UPDATED),this.updateRecorderToDb(e)}catch(a){this.loggingService.catch("Error in RecorderAnnotationService updateRecorder: ",a)}}resolveRecorder(e){try{this.domService.resetSelectedAnnotationsMap(!1),this.updateNotificationsDatabase(e,pv.RESOLVED),this.updateRecorderToDb(e),this.domService.updateSelectedAnnotationInMap([e])}catch(i){this.loggingService.catch("Error in RecorderAnnotationService resolveRecorder: ",i)}}updateRecorderToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateRecorderToDb","color: green;");try{if(e?.targetElement?.xpath){let i=this.domService.getXPath(e.targetElement.xpath);if(i){let r=i.iterateNext();r&&(Do(r)||(e.targetElement=null))}}if(e.annotationId){let i=this.recorderAnnotationById$.value;this.recorderAnnotationById$.next(T(I({},i),{[e.annotationId]:I({},e)}))}if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(ke.RECORDER)){let i=JSON.parse(JSON.stringify(e));if(i.position=null,!i?.metadata?.documentId){i?.metadata||(i.metadata={});let s=this.docService.getBaseMetadata();i.metadata=I(I({},i?.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(i))})}}catch(i){this.loggingService.catch("Error in RecorderAnnotationService updateRecorderToDb: ",i)}}deleteRecorderPinAnnotations(){try{let e=this.domService.getSelectedAnnotationsMap(),i=this.authService.getUser(),r=[];Object.keys(e).forEach(a=>Q(this,null,function*(){let s=e[a];s.type==="recorder"&&i&&s.from&&(i?.isAdmin||s.from.userId===i.userId)&&r.push(s)})),r?.length&&(this.analyticsService.trackEvent(X.Events.Recording.RECORDING_DELETE_TRIGGERED,{annotationId:r.map(a=>a.annotationId).join()}),this.dialog.open(va,{data:{title:"Delete recording?",message:"This selected recording will be deleted.",yesButton:"Delete",noButton:"Cancel",darkMode:this.recorderContainerDarkMode$.value,variant:"recorder"}}).afterClosed().pipe(tt(1)).subscribe(a=>{a&&(r.forEach(s=>Q(this,null,function*(){yield this.deleteRecorderPinAnnotation(s)})),setTimeout(()=>{document.querySelectorAll(`[${j.SNIPPYLY_HIGHLIGHT}]`).forEach(m=>{this.domService.removeHighlightFromElement(m)})},100))}),this.domService.resetSelectedAnnotationsMap(!0,"recorder"))}catch(e){this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotations: ",e)}}deleteRecorderPinAnnotation(e,i){if(this.authService.isFeatureAllowed(ke.RECORDER)&&this.documentPaths?.recorder&&e?.annotationId){this.updateNotificationsDatabase(e,pv.DELETED),e?.attachment&&this.storageService.deleteAttachment({attachment:e.attachment}),e?.attachments&&e.attachments.forEach(s=>{this.storageService.deleteAttachment({attachment:s}).catch(m=>{this.loggingService.catch("Error in RecorderAnnotationService deleteRecorderPinAnnotation delete attachment: ",m)})}),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(X.Events.Recording.RECORDING_DELETED,{annotationId:e.annotationId,recorderType:e.recordingType,recorderMode:e.mode,recorderSize:e?.attachments?.length?e?.attachments[0]?.size:e.attachment?.size,sourceFeature:i||"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 m=yield this.createRecorderData(e,!0);m&&this.recorderActionsService?.onDeleteRecording(m)}))}else return Promise.resolve()}enableAddRecorderMode(){this.authService.isFeatureAllowed(ke.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(i){this.loggingService.catch("Error in RecorderAnnotationService setRecorderContainerDarkMode: ",i)}}getRecorderContainerDarkMode(){return this.recorderContainerDarkMode$.asObservable()}enableRecordingTranscription(){try{if(this.analyticsService.setFeatureConfig({feature:ke.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:ke.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(i){return this.loggingService.catch("Error in RecorderAnnotationService isElementInsideAllowedElements: ",i),!1}}attachRecorder(e){let i=document.getElementById(e);if(i){let r=this.domService.getXPath(i),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 i=new zp;i.from=e,i.color=j.DEFAULT_ANNOTATION_COLOR,i.lastUpdated=this.timestamp;let{topPositionX:r,topPositionY:a}=this.domService.getTopLeftPosition();i.positionX=r,i.positionY=a;let s=this.domService.getCurrentWindowSizeValue();i.screenWidth=s.screenWidth,i.screenHeight=s.screenHeight,i.screenScrollHeight=s.screenScrollHeight,i.recorderedElementPath="";let m=this.docService.getLocation();return m&&(i.locationId=m.locationId,i.location=m.location),i}return null}updateNotificationsDatabase(e,i,r={}){try{let a=I({annotationData:e,actionType:i,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=Ei(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.recorderUrl=this.generateRecorderUrl(e),this.updateRecorder(e),e.pageInfo?.recorderUrl):""}catch(i){this.loggingService.catch("Error in RecorderAnnotationService getRecorderUrl: ",i);return}}uploadFile(e,i){let r=this.documentPaths?.organizationId,a=this.documentPaths?.documentId;i?.metadata?.documentId&&(a=i.metadata.documentId,r=i.metadata.organizationId);let s=`${j.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${j.FIREBASE_PARTIAL_PATH_RECORDER}`;return r&&(s=`${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${r}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${a}/${j.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 i=new URL(window.location.href);return i.searchParams.delete(j.URL_PARAMS.RECORDER_ID),i.searchParams.append(j.URL_PARAMS.RECORDER_ID,e.annotationId),i.href}setRecorderNotesFound(e){try{this.recorderNotesFound$.next(e)}catch(i){this.loggingService.catch("Error in RecorderAnnotationService setRecorderNotesFound: ",i)}}getRecorderNotesFound$(){try{return this.recorderNotesFound$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),se(!1)}}getRecorderNotesFound(){try{return this.recorderNotesFound$.value}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getRecorderNotesFound: ",e),!1}}editVideoRecording(e,i,r,a){return Q(this,null,function*(){try{let s=yr(this.functions,br({url:Xn?.cloudFunction?.videoBackend,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:36e5}),m=this.docService.getDocumentPaths();r?.metadata?.documentId&&(m=new Om({apiKey:this.configService.getApiKey(),clientDocumentId:r.metadata.clientDocumentId,clientOrganizationId:r.metadata.clientOrganizationId,documentId:r.metadata.documentId,organizationId:r.metadata.organizationId}));let p={databaseUrl:this.authService.getFirebaseConfig()?.firebaseOptions?.databaseURL,entirePath:m?.recorder+(r?.annotationId||""),fromUser:this.authService.getUser(),clientOrganizationId:m?.clientOrganizationId,clientDocumentId:m?.clientDocumentId,apiKey:this.configService.getApiKey(),sdkVersion:ga(),sdkType:this.configService.getSdkType(),useFirestore:this.commonDbService.shouldUseFirestore(),storageBucket:this.authService.getFirebaseConfig()?.firebaseOptions?.storageBucket,documentPath:m?.recorder,annotationId:r?.annotationId,annotationData:r,videoUrl:e,segments:i,zoomOptions:a};if(p?.useFirestore&&r){let H=yield this.recorderUtilsService.encryptRecorderAnnotation(r);p.annotationData=H}let h=this.documentPaths?.organizationId,_=this.documentPaths?.documentId;r?.metadata?.documentId&&(_=r.metadata.documentId,h=r.metadata.organizationId);let E=`${this.configService.getApiKey()}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${_}/${j.FIREBASE_PARTIAL_PATH_RECORDER}`;h&&(E=`${this.configService.getApiKey()}/${j.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${h}/${j.FIREBASE_PARTIAL_PATH_DOCS}/${_}/${j.FIREBASE_PARTIAL_PATH_RECORDER}`),p.bucketPath=E;let L=(yield s(p)).data;if(L&&L.videoData){let H=atob(L.videoData),K=new ArrayBuffer(H.length),oe=new Uint8Array(K);for(let ue=0;ue<H.length;ue++)oe[ue]=H.charCodeAt(ue);return new Blob([oe],{type:L.mimeType||"video/mp4"})}return null}catch(s){throw this.loggingService.catch("Error in RecorderAnnotationService editVideoRecording: ",s),s}})}setVideoEditorAutoOpen(e){try{this.videoEditorAutoOpen$.next(I(I({},this.videoEditorAutoOpen$.value),e))}catch(i){this.loggingService.catch("Error in RecorderAnnotationService setVideoEditorAutoOpen: ",i)}}getVideoEditorAutoOpen$(){try{return this.videoEditorAutoOpen$.asObservable()}catch(e){return this.loggingService.catch("Error in RecorderAnnotationService getVideoEditorAutoOpen: ",e),se({})}}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 i=this.getAnnotationById(e);if(!i)return this.loggingService.catch("Recording not found with ID: "+e),!1;let r,a,s=i.latestVersion;if(s&&i.recordingEditVersions?.[s]?(r=i.recordingEditVersions[s].attachments?.[0]?.url,a=i.recordingEditVersions[s].attachments?.[0]?.name):(r=i.attachments?.[0]?.url||i.attachment?.url,a=i.attachments?.[0]?.name||i.attachment?.name),!r)return this.loggingService.catch("No video URL found for recording: "+e),!1;let m=yield fetch(r);if(!m.ok)return this.loggingService.catch("Failed to fetch video: "+m.statusText),!1;let p=yield m.blob(),h=document.createElement("a");return h.href=URL.createObjectURL(p),h.download=a||`recording-${e}.mp4`,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(h.href),this.loggingService.log("Successfully downloaded video: "+a),!0}catch(i){return this.loggingService.catch("Error in RecorderAnnotationService downloadLatestVideo: ",i),!1}})}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(lt),J(hn),J(Tn),J(He),J(Ne),J(bi),J(fn),J(jo),J(Dm),J(Ci),J(Kp),J(Ki),J(y),J(vn),J(r0),J(ui),J(e0))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var BM=class extends ci{constructor(o){super(o),this.getService(y).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.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.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.on=this._on}_getAllCommentAnnotations(o,t){this.getService(y).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(X.Events.Comments.GET_ALL_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{documentId:o,location:t}}),this.getService(we).getAllCommentAnnotations({customClientDocumentId:o,params:t,excludeDomChanges:!0,skipPositionCalculation:!0,addFilterCommentsOnDomCheck:!0}).pipe(ce(e=>e?.length?e?.map(i=>zn(i)):e))}catch(e){return this.getService(y).catch("Error in _getLiveCommentsOnCurrentDocument: ",e),se(null)}}_deleteSelectedComment(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteSelectedComment","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_SELECTED_COMMENT_TRIGGERED),this.getService(we).deleteCommentPinAnnotations("commentElement")}catch(o){return this.getService(y).catch("Error in _deleteSelectedComment: ",o),Promise.resolve(null)}}_enableTextComments(){this.getService(y).log("%c[WB] Calling FUNCTION: enableTextComments","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).enableTextComments()}catch(o){this.getService(y).catch("Error in _enableTextComments: ",o)}}_disableTextComments(){this.getService(y).log("%c[WB] Calling FUNCTION: disableTextComments","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_TEXT_COMMENTS_TRIGGERED),this.getService(we).disableTextComments()}catch(o){this.getService(y).catch("Error in _disableTextComments: ",o)}}_allowedElementIds(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(X.Events.Comments.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(we).setAllowedElementIds(o)}catch(t){this.getService(y).catch("Error in allowedElementIds: ",t)}}_allowedElementClassNames(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementClassNames","color: green;");try{this.trackEvent(X.Events.Comments.ALLOWED_ELEMENT_CLASS_NAMES_TRIGGERED,{payload:{classNames:o}}),this.getService(we).setAllowedElementClassNames(o)}catch(t){this.getService(y).catch("Error in allowedElementClassNames: ",t)}}_allowedElementQuerySelectors(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementQuerySelectors","color: green;");try{this.trackEvent(X.Events.Comments.ALLOWED_ELEMENT_QUERY_SELECTORS_TRIGGERED,{payload:{querySelectors:o}}),this.getService(we).setAllowedElementQuerySelectors(o)}catch(t){this.getService(y).catch("Error in allowedElementQuerySelectors: ",t)}}_disableFloatingComments(){this.getService(y).log("%c[WB] Calling FUNCTION: disableFloatingComments","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!0)}catch(o){this.getService(y).catch("Error in _disableFloatingComments: ",o)}}_enableFloatingComments(){this.getService(y).log("%c[WB] Calling FUNCTION: enableFloatingComments","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_FLOATING_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableFloatingComments(!1)}catch(o){this.getService(y).catch("Error in _enableFloatingComments: ",o)}}_attachComment(o){this.getService(y).log("%c[WB] Calling FUNCTION: attachComment","color: green;");try{this.trackEvent(X.Events.Comments.ATTACH_COMMENT_TRIGGERED,{payload:{elementId:o}}),this.getService(we).attachComment(o,["id","data-id"])}catch(t){this.getService(y).catch("Error in _attachComment: ",t)}}_openCommentSidebar(){this.getService(y).log("%c[WB] Calling FUNCTION: openCommentSidebar","color: green;");try{this.trackEvent(X.Events.Comments.OPEN_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!0,!0)}catch(o){this.getService(y).catch("Error in _openCommentSidebar: ",o)}}_closeCommentSidebar(){this.getService(y).log("%c[WB] Calling FUNCTION: closeCommentSidebar","color: green;");try{this.trackEvent(X.Events.Comments.CLOSE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).setSidebarVisibility(!1,!0)}catch(o){this.getService(y).catch("Error in _closeCommentSidebar: ",o)}}_toggleCommentSidebar(){this.getService(y).log("%c[WB] Calling FUNCTION: toggleCommentSidebar","color: green;");try{this.trackEvent(X.Events.Comments.TOGGLE_COMMENT_SIDEBAR_TRIGGERED),this.getService(we).toggleSidebarVisibility(!0)}catch(o){this.getService(y).catch("Error in _toggleCommentSidebar: ",o)}}_enableModeratorMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableModeratorMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!0)}catch(o){this.getService(y).catch("Error in _enableModeratorMode: ",o)}}_disableModeratorMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableModeratorMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_MODERATOR_MODE_TRIGGERED),this.getService(we).setModeratorMode(!1)}catch(o){this.getService(y).catch("Error in _disableModeratorMode: ",o)}}_enableStreamMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableStreamMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!0)}catch(o){this.getService(y).catch("Error in _enableStreamMode: ",o)}}_disableStreamMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableStreamMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_STREAM_MODE_TRIGGERED),this.getService(we).setStreamMode(!1)}catch(o){this.getService(y).catch("Error in _disableStreamMode: ",o)}}_enableSignInButton(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSignInButton","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!0)}catch(o){this.getService(y).catch("Error in _enableSignInButton: ",o)}}_disableSignInButton(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSignInButton","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SIGN_IN_BUTTON_TRIGGERED),this.getService(we).enableSignInButton(!1)}catch(o){this.getService(y).catch("Error in _disableSignInButton: ",o)}}_enableUpgradeButton(){this.getService(y).log("%c[WB] Calling FUNCTION: enableUpgradeButton","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!0)}catch(o){this.getService(y).catch("Error in _enableUpgradeButton: ",o)}}_disableUpgradeButton(){this.getService(y).log("%c[WB] Calling FUNCTION: disableUpgradeButton","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_UPGRADE_BUTTON_TRIGGERED),this.getService(we).enableUpgradeButton(!1)}catch(o){this.getService(y).catch("Error in _disableUpgradeButton: ",o)}}_onCommentModeChange(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentModeChange","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_MODE_CHANGE_TRIGGERED),this.getService(we).addCommentModeChange()}catch(o){return this.getService(y).catch("Error in _onCommentModeChange: ",o),se(!1)}}_enableAttachment(){this.getService(y).log("%c[WB] Calling FUNCTION: enableAttachment","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!0)}catch(o){this.getService(y).catch("Error in _enableAttachment: ",o)}}_disableAttachment(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAttachment","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_ATTACHMENTS_TRIGGERED),this.getService(we).enableAttachment(!1)}catch(o){this.getService(y).catch("Error in _disableAttachment: ",o)}}_isUserGlobalContact(){this.getService(y).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(X.Events.Comments.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(we).isUserGlobalContact$()}catch(o){return this.getService(y).catch("Error in _isUserGlobalContact: ",o),se(!1)}}_enableDeviceInfo(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDeviceInfo","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!0)}catch(o){this.getService(y).catch("Error in _enableDeviceInfo: ",o)}}_disableDeviceInfo(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDeviceInfo","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DEVICE_INFO_TRIGGERED),this.getService(we).showScreenSizeInfo(!1)}catch(o){this.getService(y).catch("Error in _disableDeviceInfo: ",o)}}_enableCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COMMENT_MODE_TRIGGERED),this.getService(we).enableAddCommentMode()}catch(o){this.getService(y).catch("Error in _enableCommentMode: ",o)}}_disableCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_COMMENT_MODE_TRIGGERED),this.getService(we).disableAddCommentMode()}catch(o){this.getService(y).catch("Error in _disableCommentMode: ",o)}}_enablePersistentCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePersistentCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).enablePersistentCommentMode()}catch(o){this.getService(y).catch("Error in _enablePersistentCommentMode: ",o)}}_disablePersistentCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePersistentCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_PERSISTENT_COMMENT_MODE_TRIGGERED),this.getService(we).disablePersistentCommentMode()}catch(o){this.getService(y).catch("Error in _disablePersistentCommentMode: ",o)}}_showCommentIndex(o){this.getService(y).log("%c[WB] Calling FUNCTION: showCommentIndex","color: green;");try{this.getService(we).showCommentIndex(o)}catch(t){this.getService(y).catch("Error in _showCommentIndex: ",t)}}_enableCommentIndex(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCommentIndex","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!0)}catch(o){this.getService(y).catch("Error in _enableCommentIndex: ",o)}}_disableCommentIndex(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCommentIndex","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_COMMENT_INDEX_TRIGGERED),this.getService(we).showCommentIndex(!1)}catch(o){this.getService(y).catch("Error in _disableCommentIndex: ",o)}}_enablePopoverMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePopoverMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_POPOVER_MODE_TRIGGERED),this.getService(we).enablePopoverMode()}catch(o){this.getService(y).catch("Error in _enablePopoverMode: ",o)}}_disablePopoverMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePopoverMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_POPOVER_MODE_TRIGGERED),this.getService(we).disablePopoverMode()}catch(o){this.getService(y).catch("Error in _disablePopoverMode: ",o)}}_enableDialogOnHover(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDialogOnHover","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!0)}catch(o){this.getService(y).catch("Error in _enableDialogOnHover: ",o)}}_disableDialogOnHover(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDialogOnHover","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DIALOG_ON_HOVER_TRIGGERED),this.getService(we).setEnableDialogOnHover(!1)}catch(o){this.getService(y).catch("Error in _disableDialogOnHover: ",o)}}_enablePopoverTriangleComponent(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePopoverTriangleComponent","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).enablePopoverTriangleComponent()}catch(o){this.getService(y).catch("Error in _enablePopoverTriangleComponent: ",o)}}_disablePopoverTriangleComponent(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePopoverTriangleComponent","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_POPOVER_TRIANGLE_COMPONENT_TRIGGERED),this.getService(we).disablePopoverTriangleComponent()}catch(o){this.getService(y).catch("Error in _disablePopoverTriangleComponent: ",o)}}_enableDialogOnTargetElementClick(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDialogOnTargetElementClick","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!0)}catch(o){this.getService(y).catch("Error in _enableDialogOnTargetElementClick: ",o)}}_disableDialogOnTargetElementClick(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDialogOnTargetElementClick","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DIALOG_ON_TARGET_ELEMENT_CLICK_TRIGGERED),this.getService(we).setEnableDialogOnTargetElementClick(!1)}catch(o){this.getService(y).catch("Error in _disableDialogOnTargetElementClick: ",o)}}_enablePriority(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePriority","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!0)}catch(o){this.getService(y).catch("Error in _enablePriority: ",o)}}_disablePriority(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePriority","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_PRIORITY_TRIGGERED),this.getService(we).setEnablePriority(!1)}catch(o){this.getService(y).catch("Error in _disablePriority: ",o)}}_enableStatus(){this.getService(y).log("%c[WB] Calling FUNCTION: enableStatus","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!0)}catch(o){this.getService(y).catch("Error in _enableStatus: ",o)}}_disableStatus(){this.getService(y).log("%c[WB] Calling FUNCTION: disableStatus","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_STATUS_TRIGGERED),this.getService(we).setEnableStatus(!1)}catch(o){this.getService(y).catch("Error in _disableStatus: ",o)}}_enableResolveButton(){this.getService(y).log("%c[WB] Calling FUNCTION: enableResolveButton","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!0)}catch(o){this.getService(y).catch("Error in _enableResolveButton: ",o)}}_disableResolveButton(){this.getService(y).log("%c[WB] Calling FUNCTION: disableResolveButton","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_RESOLVE_BUTTON_TRIGGERED),this.getService(we).setEnableResolve(!1)}catch(o){this.getService(y).catch("Error in _disableResolveButton: ",o)}}_enableGhostComments(){this.getService(y).log("%c[WB] Calling FUNCTION: enableGhostComments","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).enableGhostComments()}catch(o){this.getService(y).catch("Error in _enableGhostCommentsInDOM: ",o)}}_disableGhostComments(){this.getService(y).log("%c[WB] Calling FUNCTION: disableGhostComments","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_GHOST_COMMENTS_TRIGGERED),this.getService(we).disableGhostComments()}catch(o){this.getService(y).catch("Error in _disableGhostComments: ",o)}}_enableGhostCommentsIndicator(){this.getService(y).log("%c[WB] Calling FUNCTION: enableGhostCommentsIndicator","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).enableGhostCommentsMessage()}catch(o){this.getService(y).catch("Error in _enableGhostCommentsIndicator: ",o)}}_disableGhostCommentsIndicator(){this.getService(y).log("%c[WB] Calling FUNCTION: disableGhostCommentsIndicator","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_GHOST_COMMENTS_INDICATOR_TRIGGERED),this.getService(we).disableGhostCommentsMessage()}catch(o){this.getService(y).catch("Error in _disableGhostCommentsIndicator: ",o)}}_setCustomStatus(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCustomStatus","color: green;");try{this.trackEvent(X.Events.Comments.SET_CUSTOM_STATUS_TRIGGERED,{payload:{customStatuses:o}}),this.getService(we).setCustomStatuses(o)}catch(t){this.getService(y).catch("Error in _setCustomStatus: ",t)}}_enableInboxMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableInboxMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_INBOX_MODE_TRIGGERED),this.getService(we).enableInboxMode()}catch(o){this.getService(y).catch("Error in _enableInboxMode: ",o)}}_setCustomPriority(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCustomPriority","color: green;");try{this.trackEvent(X.Events.Comments.SET_CUSTOM_PRIORITY_TRIGGERED,{payload:{customPriorities:o}}),this.getService(we).setCustomPriorities(o)}catch(t){this.getService(y).catch("Error in _setCustomPriority: ",t)}}_setCustomCategory(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCustomCategory","color: green;");try{this.trackEvent(X.Events.Comments.SET_CUSTOM_CATEGORY_TRIGGERED,{payload:{customCategories:o}}),this.getService(we).setCustomCategories(o)}catch(t){this.getService(y).catch("Error in _setCustomCategory: ",t)}}_disableInboxMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableInboxMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_INBOX_MODE_TRIGGERED),this.getService(we).disableInboxMode()}catch(o){this.getService(y).catch("Error in _disableInboxMode: ",o)}}_enableAutoCategorize(){this.getService(y).log("%c[WB] Calling FUNCTION: enableAutoCategorize","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!0)}catch(o){this.getService(y).catch("Error in _enableAutoCategorize: ",o)}}_disableAutoCategorize(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAutoCategorize","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_AUTO_CATEGORIZE_TRIGGERED),this.getService(we).setEnableAutoCategorize(!1)}catch(o){this.getService(y).catch("Error in _disableAutoCategorize: ",o)}}_enableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!0)}catch(o){this.getService(y).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DARK_MODE_TRIGGERED),this.getService(we).setCommentContainerDarkMode(!1)}catch(o){this.getService(y).catch("Error in _disableDarkMode: ",o)}}_setContextProvider(o){try{this.trackEvent(X.Events.Comments.SET_CONTEXT_PROVIDER_TRIGGERED,{payload:{documentId:Jse,location}}),this.getService(we).setContextProvider(o)}catch(t){this.getService(y).catch("Error in _setContextProvider: ",t)}}_enableSuggestionMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSuggestionMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!0)}catch(o){this.getService(y).catch("Error in _enableSuggestionMode: ",o)}}_disableSuggestionMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSuggestionMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SUGGESTION_MODE_TRIGGERED),this.getService(we).setSuggestionMode(!1)}catch(o){this.getService(y).catch("Error in _disableSuggestionMode: ",o)}}_enableMobileMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableMobileMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!0)}catch(o){this.getService(y).catch("Error in _enableMobileMode: ",o)}}_disableMobileMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableMobileMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_MOBILE_MODE_TRIGGERED),this.getService(we).setMobileMode(!1)}catch(o){this.getService(y).catch("Error in _disableMobileMode: ",o)}}_enableInlineCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableInlineCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).enableInlineCommentMode()}catch(o){this.getService(y).catch("Error in _enableInlineCommentMode: ",o)}}_disableInlineCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableInlineCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_INLINE_COMMENT_MODE_TRIGGERED),this.getService(we).disableInlineCommentMode()}catch(o){this.getService(y).catch("Error in _disableInlineCommentMode: ",o)}}_enableMinimap(){this.getService(y).log("%c[WB] Calling FUNCTION: enableMinimap","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_MINIMAP_TRIGGERED),this.getService(we).enableMinimap()}catch(o){this.getService(y).catch("Error in _enableMinimap: ",o)}}_disableMinimap(){this.getService(y).log("%c[WB] Calling FUNCTION: disableMinimap","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_MINIMAP_TRIGGERED),this.getService(we).disableMinimap()}catch(o){this.getService(y).catch("Error in _disableMinimap: ",o)}}_showCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: showCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.SHOW_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showCommentsOnDom()}catch(o){this.getService(y).catch("Error in _showCommentsOnDom: ",o)}}_hideCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: hideCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.HIDE_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideCommentsOnDom()}catch(o){this.getService(y).catch("Error in _hideCommentsOnDom: ",o)}}_enableCommentTool(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCommentTool","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).enableCommentTool()}catch(o){this.getService(y).catch("Error in _enableCommentTool: ",o)}}_disableCommentTool(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCommentTool","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_COMMENT_TOOL_TRIGGERED),this.getService(we).disableCommentTool()}catch(o){this.getService(y).catch("Error in _disableCommentTool: ",o)}}_setTotalMediaLength(o){this.getService(y).log("%c[WB] Calling FUNCTION: setTotalMediaLength","color: green;");try{this.trackEvent(X.Events.Comments.SET_TOTAL_MEDIA_LENGTH_TRIGGERED,{payload:{length:o}}),this.getService(we).setTotalMediaLength(o)}catch(t){this.getService(y).catch("Error in _setTotalMediaLength: ",t)}}_onCommentAdd(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentAdd","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_ADD_TRIGGERED),this.getService(we).onCommentAdd$()}catch(o){return this.getService(y).catch("Error in _onCommentAdd: ",o),se()}}_onCommentUpdate(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentUpdate","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_UPDATE_TRIGGERED),this.getService(we).onCommentUpdate$()}catch(o){return this.getService(y).catch("Error in _onCommentUpdate: ",o),se()}}_addCommentOnSelectedText(){this.getService(y).log("%c[WB] Calling FUNCTION: addCommentOnSelectedText","color: green;");try{this.trackEvent(X.Events.Comments.ADD_COMMENT_ON_SELECTED_TEXT_TRIGGERED),this.getService(we).addCommentOnSelectedText()}catch(o){this.getService(y).catch("Error in _addCommentOnSelectedText: ",o)}}_enableSidebarUrlNavigation(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSidebarUrlNavigation","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).enableSidebarUrlNavigation()}catch(o){this.getService(y).catch("Error in _enableSidebarUrlNavigation: ",o)}}_disableSidebarUrlNavigation(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSidebarUrlNavigation","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SIDEBAR_URL_NAVIGATION_TRIGGERED),this.getService(we).disableSidebarUrlNavigation()}catch(o){this.getService(y).catch("Error in _disableSidebarUrlNavigation: ",o)}}_setDStrategy(o){this.getService(y).log("%c[WB] Calling FUNCTION: setDStrategy","color: green;");try{this.trackEvent(X.Events.Comments.SET_D_STRATEGY_TRIGGERED,{payload:{strategy:o}}),this.getService(we).setDetectionStrategy(o)}catch(t){this.getService(y).catch("Error in _setDStrategy: ",t)}}_enableSidebarButtonOnCommentDialog(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).enableSidebarButtonOnCommentDialog()}catch(o){this.getService(y).catch("Error in _enableSidebarButtonOnCommentDialog: ",o)}}_disableSidebarButtonOnCommentDialog(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSidebarButtonOnCommentDialog","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_TRIGGERED),this.getService(we).disableSidebarButtonOnCommentDialog()}catch(o){this.getService(y).catch("Error in _disableSidebarButtonOnCommentDialog: ",o)}}_onSidebarButtonOnCommentDialogClick(){this.getService(y).log("%c[WB] Calling FUNCTION: onSidebarButtonOnCommentDialogClick","color: green;");try{return this.trackEvent(X.Events.Comments.ON_SIDEBAR_BUTTON_ON_COMMENT_DIALOG_CLICK_TRIGGERED),this.getService(we).getSidebarButtonOnCommentDialogClick$()}catch(o){return this.getService(y).catch("Error in _onSidebarButtonOnCommentDialogClick: ",o),se(null)}}_enableReactions(){this.getService(y).log("%c[WB] Calling FUNCTION: enableReactions","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_REACTIONS_TRIGGERED),this.getService(we).enableReactions()}catch(o){this.getService(y).catch("Error in _enableReactions: ",o)}}_disableReactions(){this.getService(y).log("%c[WB] Calling FUNCTION: disableReactions","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_REACTIONS_TRIGGERED),this.getService(we).disableReactions()}catch(o){this.getService(y).catch("Error in _disableReactions: ",o)}}_setRecordings(o){this.getService(y).log("%c[WB] Calling FUNCTION: setRecordings","color: green;");try{this.trackEvent(X.Events.Comments.SET_RECORDINGS_TRIGGERED,{payload:{allowedRecordings:o}}),typeof o=="string"&&(o=o?.split(",")?.map(t=>t.trim())),this.getService(we).setAllowedRecordings(o)}catch(t){this.getService(y).catch("Error in _setRecordings: ",t)}}_addCommentOnElement(o){this.getService(y).log("%c[WB] Calling FUNCTION: addCommentOnElement","color: green;");try{this.trackEvent(X.Events.Comments.ADD_COMMENT_ON_ELEMENT_TRIGGERED,{payload:{data:o}}),this.getService(we).addCommentOnElement(o)}catch(t){this.getService(y).catch("Error in _addCommentOnElement: ",t)}}_enablePrivateCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePrivateCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).enablePrivateCommentMode()}catch(o){this.getService(y).catch("Error in _enablePrivateCommentMode: ",o)}}_disablePrivateCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePrivateCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_PRIVATE_COMMENT_MODE_TRIGGERED),this.getService(we).disablePrivateCommentMode()}catch(o){this.getService(y).catch("Error in _disablePrivateCommentMode: ",o)}}_enableScrollToComment(){this.getService(y).log("%c[WB] Calling FUNCTION: enableScrollToComment","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).enableScrollToComment()}catch(o){this.getService(y).catch("Error in _enableScrollToComment: ",o)}}_disableScrollToComment(){this.getService(y).log("%c[WB] Calling FUNCTION: disableScrollToComment","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SCROLL_TO_COMMENT_TRIGGERED),this.getService(we).disableScrollToComment()}catch(o){this.getService(y).catch("Error in _disableScrollToComment: ",o)}}_enableUserMentions(){this.getService(y).log("%c[WB] Calling FUNCTION: enableUserMentions","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_USER_MENTIONS_TRIGGERED),this.getService(we).enableUserMentions()}catch(o){this.getService(y).catch("Error in _enableUserMentions: ",o)}}_disableUserMentions(){this.getService(y).log("%c[WB] Calling FUNCTION: disableUserMentions","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_USER_MENTIONS_TRIGGERED),this.getService(we).disableUserMentions()}catch(o){this.getService(y).catch("Error in _disableUserMentions: ",o)}}_setCommentSidebarFilters(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCommentSidebarFilters","color: green;");try{this.trackEvent(X.Events.Comments.SET_COMMENT_SIDEBAR_FILTERS_TRIGGERED,{payload:{filters:o}}),this.getService(we).setCommentSidebarFilters(o)}catch(t){this.getService(y).catch("Error in _setCommentSidebarFilters: ",t)}}_setSystemFiltersOperator(o){this.getService(y).log("%c[WB] Calling FUNCTION: setSystemFiltersOperator","color: green;");try{this.trackEvent(X.Events.Comments.SET_SYSTEM_FILTERS_OPERATOR_TRIGGERED,{payload:{operator:o}}),this.getService(we).setCommentSidebarSystemFiltersOperator(o)}catch(t){this.getService(y).catch("Error in _setSystemFiltersOperator: ",t)}}_enableCommentPinHighlighter(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCommentPinHighlighter","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COMMENT_PIN_HIGHLIGHTER_TRIGGERED),this.getService(we).enableCommentPinHighlighter()}catch(o){this.getService(y).catch("Error in _enableCommentPinHighlighter: ",o)}}_disableCommentPinHighlighter(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCommentPinHighlighter","color: green;");try{this.getService(we).disableCommentPinHighlighter()}catch(o){this.getService(y).catch("Error in _disableCommentPinHighlighter: ",o)}}_enableDeleteOnBackspace(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDeleteOnBackspace","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).enableDeleteOnBackspace()}catch(o){this.getService(y).catch("Error in _enableDeleteOnBackspace: ",o)}}_disableDeleteOnBackspace(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDeleteOnBackspace","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DELETE_ON_BACKSPACE_TRIGGERED),this.getService(we).disableDeleteOnBackspace()}catch(o){this.getService(y).catch("Error in _disableDeleteOnBackspace: ",o)}}_enableHotkey(){this.getService(y).log("%c[WB] Calling FUNCTION: enableHotkey","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_HOTKEY_TRIGGERED),this.getService(we).enableHotkey()}catch(o){this.getService(y).catch("Error in _enableHotkey: ",o)}}_disableHotkey(){this.getService(y).log("%c[WB] Calling FUNCTION: disableHotkey","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_HOTKEY_TRIGGERED),this.getService(we).disableHotkey()}catch(o){this.getService(y).catch("Error in _disableHotkey: ",o)}}_enableDeviceIndicatorOnCommentPins(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).enableDeviceIndicatorOnCommentPins()}catch(o){this.getService(y).catch("Error in _enableDeviceIndicatorOnCommentPins: ",o)}}_disableDeviceIndicatorOnCommentPins(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDeviceIndicatorOnCommentPins","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DEVICE_INDICATOR_ON_COMMENT_PINS_TRIGGERED),this.getService(we).disableDeviceIndicatorOnCommentPins()}catch(o){this.getService(y).catch("Error in _disableDeviceIndicatorOnCommentPins: ",o)}}_getElementRefByAnnotationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: getElementRefByAnnotationId","color: green;");try{return this.trackEvent(X.Events.Comments.GET_ELEMENT_REF_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(we).getElementRefByAnnotationId(o)}catch(t){this.getService(y).catch("Error in _getElementRefByAnnotationId: ",t);return}}_scrollToCommentByAnnotationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: scrollToCommentByAnnotationId","color: green;");try{this.trackEvent(X.Events.Comments.SCROLL_TO_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(we).scrollToCommentByAnnotationId(o)}catch(t){this.getService(y).catch("Error in _scrollToCommentByAnnotationId: ",t)}}_selectCommentByAnnotationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: selectCommentByAnnotationId","color: green;");try{this.trackEvent(X.Events.Comments.SELECT_COMMENT_BY_ANNOTATION_ID_TRIGGERED,{payload:{annotationId:o}}),this.getService(we).selectCommentByAnnotationId(o)}catch(t){this.getService(y).catch("Error in _selectCommentByAnnotationId: ",t)}}_enableRecordingSummary(){this.getService(y).log("%c[WB] Calling FUNCTION: enableRecordingSummary","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).enableRecordingSummary()}catch(o){this.getService(y).catch("Error in _enableRecordingSummary: ",o)}}_disableRecordingSummary(){this.getService(y).log("%c[WB] Calling FUNCTION: disableRecordingSummary","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_RECORDING_SUMMARY_TRIGGERED),this.getService(we).disableRecordingSummary()}catch(o){this.getService(y).catch("Error in _disableRecordingSummary: ",o)}}_enableRecordingTranscription(){this.getService(y).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(ji).enableRecordingTranscription()}catch(o){this.getService(y).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(y).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(ji).disableRecordingTranscription()}catch(o){this.getService(y).catch("Error in _disableRecordingTranscription: ",o)}}_enableRecordingCountdown(){this.getService(y).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).enableRecordingCountdown()}catch(o){this.getService(y).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(y).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(we).disableRecordingCountdown()}catch(o){this.getService(y).catch("Error in _disableRecordingCountdown: ",o)}}_setUnreadIndicatorMode(o){this.getService(y).log("%c[WB] Calling FUNCTION: setUnreadIndicatorMode","color: green;");try{this.trackEvent(X.Events.Comments.SET_UNREAD_INDICATOR_MODE_TRIGGERED,{payload:{mode:o}}),this.getService(we).setUnreadIndicatorMode(o)}catch(t){this.getService(y).catch("Error in _setUnreadIndicatorMode: ",t)}}_enableEnterKeyToSubmit(){this.getService(y).log("%c[WB] Calling FUNCTION: enableEnterKeyToSubmit","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).enableEnterKeyToSubmit()}catch(o){this.getService(y).catch("Error in _enableEnterKeyToSubmit: ",o)}}_disableEnterKeyToSubmit(){this.getService(y).log("%c[WB] Calling FUNCTION: disableEnterKeyToSubmit","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_ENTER_KEY_TO_SUBMIT_TRIGGERED),this.getService(we).disableEnterKeyToSubmit()}catch(o){this.getService(y).catch("Error in _disableEnterKeyToSubmit: ",o)}}_enablePinShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: enablePinShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).enablePinShadowDOM()}catch(o){this.getService(y).catch("Error in _enablePinShadowDOM: ",o)}}_disablePinShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: disablePinShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_PIN_SHADOW_DOM_TRIGGERED),this.getService(we).disablePinShadowDOM()}catch(o){this.getService(y).catch("Error in _disablePinShadowDOM: ",o)}}_enableDialogShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDialogShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).enableDialogShadowDOM()}catch(o){this.getService(y).catch("Error in _enableDialogShadowDOM: ",o)}}_disableDialogShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDialogShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DIALOG_SHADOW_DOM_TRIGGERED),this.getService(we).disableDialogShadowDOM()}catch(o){this.getService(y).catch("Error in _disableDialogShadowDOM: ",o)}}_enableSidebarShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSidebarShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).enableSidebarShadowDOM()}catch(o){this.getService(y).catch("Error in _enableSidebarShadowDOM: ",o)}}_disableSidebarShadowDOM(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSidebarShadowDOM","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SIDEBAR_SHADOW_DOM_TRIGGERED),this.getService(we).disableSidebarShadowDOM()}catch(o){this.getService(y).catch("Error in _disableSidebarShadowDOM: ",o)}}_enableChangeDetectionInCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).enableChangeDetectionInCommentMode()}catch(o){this.getService(y).catch("Error in _enableChangeDetectionInCommentMode: ",o)}}_disableChangeDetectionInCommentMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableChangeDetectionInCommentMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_CHANGE_DETECTION_IN_COMMENT_MODE_TRIGGERED),this.getService(we).disableChangeDetectionInCommentMode()}catch(o){this.getService(y).catch("Error in _disableChangeDetectionInCommentMode: ",o)}}_showResolvedCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: showResolvedCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.SHOW_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).showResolvedCommentsOnDom()}catch(o){this.getService(y).catch("Error in _showResolvedCommentsOnDom: ",o)}}_hideResolvedCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: hideResolvedCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.HIDE_RESOLVED_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).hideResolvedCommentsOnDom()}catch(o){this.getService(y).catch("Error in _hideResolvedCommentsOnDom: ",o)}}_setCustomReactions(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(X.Events.Comments.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(we).setCustomReactions(o)}catch(t){this.getService(y).catch("Error in _setCustomReactions: ",t)}}_onCommentSelectionChange(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentSelectionChange","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_SELECTION_CHANGE_TRIGGERED),this.getService(we).onCommentSelectionChange$()}catch(o){return this.getService(y).catch("Error in _onCommentSelectionChange: ",o),se(null)}}_getUnreadCommentCountByAnnotationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByAnnotationId","color: green;");try{return this.trackEvent(X.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_ANNOTATION_ID_TRIGGERED,{payload:{commentAnnotationId:o}}),this.getService(we).getUnreadCommentCountByAnnotationId$(o)}catch(t){return this.getService(y).catch("Error in _getUnreadCommentCountByAnnotationId: ",t),se(null)}}_getUnreadCommentAnnotationCountOnCurrentDocument(){this.getService(y).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountOnCurrentDocument","color: green;");try{return this.trackEvent(X.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(we).getUnreadCommentAnnotationCountOnCurrentDocument$()}catch(o){return this.getService(y).catch("Error in _getUnreadCommentAnnotationCountOnCurrentDocument: ",o),se(null)}}_getUnreadCommentCountOnCurrentDocument(){this.getService(y).log("%c[WB] Calling FUNCTION: getUnreadCommentCountOnCurrentDocument","color: green;");try{return this.trackEvent(X.Events.Comments.GET_UNREAD_COMMENT_COUNT_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(we).getUnreadCommentCountOnCurrentDocument$()}catch(o){return this.getService(y).catch("Error in _getUnreadCommentCountOnCurrentDocument: ",o),se(null)}}_getUnreadCommentAnnotationCountByLocationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: getUnreadCommentAnnotationCountByLocationId","color: green;");try{return this.trackEvent(X.Events.Comments.GET_UNREAD_COMMENT_ANNOTATION_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(we).getUnreadCommentAnnotationCountByLocationId$(o)}catch(t){return this.getService(y).catch("Error in _getUnreadCommentAnnotationCountByLocationId: ",t),se(null)}}_getUnreadCommentCountByLocationId(o){this.getService(y).log("%c[WB] Calling FUNCTION: getUnreadCommentCountByLocationId","color: green;");try{return this.trackEvent(X.Events.Comments.GET_UNREAD_COMMENT_COUNT_BY_LOCATION_ID_TRIGGERED,{payload:{locationId:o}}),this.getService(we).getUnreadCommentCountByLocationId$(o)}catch(t){return this.getService(y).catch("Error in _getUnreadCommentCountByLocationId: ",t),se(null)}}_updateCommentDialogPosition(){this.getService(y).log("%c[WB] Calling FUNCTION: updateCommentDialogPosition","color: green;");try{this.trackEvent(X.Events.Comments.UPDATE_COMMENT_DIALOG_POSITION_TRIGGERED),this.getService(we).updateCommentDialogPosition()}catch(o){this.getService(y).catch("Error in _updateCommentDialogPosition: ",o)}}_enableAreaComment(){this.getService(y).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(we).enableAreaComment()}catch(o){this.getService(y).catch("Error in _enableAreaComment: ",o)}}_disableAreaComment(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(we).disableAreaComment()}catch(o){this.getService(y).catch("Error in _disableAreaComment: ",o)}}_setPinCursorImage(o){this.getService(y).log("%c[WB] Calling FUNCTION: setPinCursorImage","color: green;");try{this.trackEvent(X.Events.Comments.SET_PIN_CURSOR_IMAGE_TRIGGERED,{payload:{image:o}}),this.getService(we).setPinCursorImage(o)}catch(t){this.getService(y).catch("Error in _setPinCursorImage: ",t)}}_addManualComment(o){this.getService(y).log("%c[WB] Calling FUNCTION: addManualComment","color: green;");try{return this.trackEvent(X.Events.Comments.ADD_MANUAL_COMMENT_TRIGGERED,{payload:{config:o}}),this.getService(we).addManualComment(o)}catch(t){return this.getService(y).catch("Error in _addManualComment: ",t),Promise.resolve()}}_createCustomListDataOnAnnotation(o){this.getService(y).log("%c[WB] Calling FUNCTION: createCustomListDataOnAnnotation","color: green;");try{this.trackEvent(X.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_ANNOTATION_TRIGGERED,{payload:{data:o}}),this.getService(we).createCustomListDataOnAnnotation(o)}catch(t){this.getService(y).catch("Error in _createCustomListDataOnAnnotation: ",t)}}_createCustomListDataOnComment(o){this.getService(y).log("%c[WB] Calling FUNCTION: createCustomListDataOnComment","color: green;");try{return this.trackEvent(X.Events.Comments.CREATE_CUSTOM_LIST_DATA_ON_COMMENT_TRIGGERED,{payload:{data:o}}),this.getService(el).create(o)}catch(t){this.getService(y).catch("Error in _createCustomListDataOnComment: ",t)}}_excludeLocationIdsFromSidebar(o){this.getService(y).log("%c[WB] Calling FUNCTION: excludeLocationIdsFromSidebar","color: green;");try{this.trackEvent(X.Events.Comments.EXCLUDE_LOCATION_IDS_FROM_SIDEBAR_TRIGGERED,{payload:{locationIds:o}}),this.getService(we).setExcludeLocationIdsFromSidebar(o)}catch(t){this.getService(y).catch("Error in _excludeLocationIdsFromSidebar: ",t)}}_enableBubbleOnPin(){this.getService(y).log("%c[WB] Calling FUNCTION: enableBubbleOnPin","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).enableBubbleOnPin()}catch(o){this.getService(y).catch("Error in _enableBubbleOnPin: ",o)}}_disableBubbleOnPin(){this.getService(y).log("%c[WB] Calling FUNCTION: disableBubbleOnPin","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_BUBBLE_ON_PIN_TRIGGERED),this.getService(we).disableBubbleOnPin()}catch(o){this.getService(y).catch("Error in _disableBubbleOnPin: ",o)}}_enableBubbleOnPinHover(){this.getService(y).log("%c[WB] Calling FUNCTION: enableBubbleOnPinHover","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).enableBubbleOnPinHover()}catch(o){this.getService(y).catch("Error in _enableBubbleOnPinHover: ",o)}}_disableBubbleOnPinHover(){this.getService(y).log("%c[WB] Calling FUNCTION: disableBubbleOnPinHover","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_BUBBLE_ON_PIN_HOVER_TRIGGERED),this.getService(we).disableBubbleOnPinHover()}catch(o){this.getService(y).catch("Error in _disableBubbleOnPinHover: ",o)}}_enableMultiThread(){this.getService(y).log("%c[WB] Calling FUNCTION: enableMultiThread","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_MULTI_THREAD_TRIGGERED),this.getService(we).enableMultiThread()}catch(o){this.getService(y).catch("Error in _enableMultiThread: ",o)}}_disableMultiThread(){this.getService(y).log("%c[WB] Calling FUNCTION: disableMultiThread","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_MULTI_THREAD_TRIGGERED),this.getService(we).disableMultiThread()}catch(o){this.getService(y).catch("Error in _disableMultiThread: ",o)}}_updateContext(o,t,e){this.getService(y).log("%c[WB] Calling FUNCTION: updateContext","color: green;");try{return this.trackEvent(X.Events.Comments.UPDATE_CONTEXT_TRIGGERED,{payload:{annotationId:o,context:t,config:e}}),this.getService(we).updateCommentAnnotationContext(o,t,e)}catch(i){return this.getService(y).catch("Error in _updateContext: ",i),Promise.resolve()}}_getSelectedComments(){this.getService(y).log("%c[WB] Calling FUNCTION: getSelectedComments","color: green;");try{return this.trackEvent(X.Events.Comments.GET_SELECTED_COMMENTS_TRIGGERED),this.getService(Ne).getSelectedComments$()}catch(o){return this.getService(y).catch("Error in _getSelectedComments: ",o),se([])}}_enableDeleteReplyConfirmation(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDeleteReplyConfirmation","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DELETE_REPLY_CONFIRMATION_TRIGGERED),this.getService(we).enableDeleteReplyConfirmation()}catch(o){this.getService(y).catch("Error in _enableDeleteReplyConfirmation: ",o)}}_disableDeleteReplyConfirmation(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDeleteReplyConfirmation","color: green;");try{this.getService(we).disableDeleteReplyConfirmation()}catch(o){this.getService(y).catch("Error in _disableDeleteReplyConfirmation: ",o)}}_onCopyLink(){this.getService(y).log("%c[WB] Calling FUNCTION: onCopyLink","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COPY_LINK_TRIGGERED),this.getService(we).getCopyLink$()}catch(o){return this.getService(y).catch("Error in _onCopyLink: ",o),se("")}}_getCommentAnnotationById(o){this.getService(y).log("%c[WB] Calling FUNCTION: getCommentAnnotationById","color: green;");try{return this.trackEvent(X.Events.Comments.GET_COMMENT_ANNOTATION_BY_ID_TRIGGERED,{payload:{config:o}}),this.getService(we).getCommentAnnotationById(o)}catch(t){return this.getService(y).catch("Error in _getCommentAnnotationById: ",t),se(null)}}_enableCollapsedComments(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCollapsedComments","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).enableCollapsedComments()}catch(o){this.getService(y).catch("Error in _enableCollapsedComments: ",o)}}_disableCollapsedComments(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCollapsedComments","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_COLLAPSED_COMMENTS_TRIGGERED),this.getService(we).disableCollapsedComments()}catch(o){this.getService(y).catch("Error in _disableCollapsedComments: ",o)}}_onCommentSidebarActionButtonClick(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentSidebarActionButtonClick","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_SIDEBAR_ACTION_BUTTON_CLICK_TRIGGERED),this.getService(we).getSidebarCustomActionEventData()}catch(o){return this.getService(y).catch("Error in _onCommentSidebarActionButtonClick: ",o),se(null)}}_setCommentSidebarData(o,t){this.getService(y).log("%c[WB] Calling FUNCTION: setCommentSidebarData","color: green;");try{this.trackEvent(X.Events.Comments.SET_COMMENT_SIDEBAR_DATA_TRIGGERED,{payload:{data:o,options:t}}),this.getService(we).setCommentSidebarData(o,t)}catch(e){this.getService(y).catch("Error in _setCommentSidebarData: ",e)}}_onCommentSidebarInit(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentSidebarInit","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_SIDEBAR_INIT_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataOnInit()}catch(o){return this.getService(y).catch("Error in _onCommentSidebarInit: ",o),se(null)}}_onCommentSidebarData(){this.getService(y).log("%c[WB] Calling FUNCTION: onCommentSidebarData","color: green;");try{return this.trackEvent(X.Events.Comments.ON_COMMENT_SIDEBAR_DATA_TRIGGERED),this.getService(we).getSidebarCustomActionEventDataAllChanges()}catch(o){return this.getService(y).catch("Error in _onCommentSidebarData: ",o),se(null)}}_setCommentSidebarDefaultCustomActions(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCommentSidebarDefaultCustomActions","color: green;");try{this.trackEvent(X.Events.Comments.SET_COMMENT_SIDEBAR_DEFAULT_CUSTOM_ACTIONS_TRIGGERED,{payload:{actions:o}}),this.getService(we).setSidebarCustomActionEventData(o,[],{},[])}catch(t){this.getService(y).catch("Error in _setCommentSidebarDefaultCustomActions: ",t)}}_enableSidebarCustomActions(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSidebarCustomActions","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).enableSidebarCustomActions()}catch(o){this.getService(y).catch("Error in _enableSidebarCustomActions: ",o)}}_disableSidebarCustomActions(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSidebarCustomActions","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SIDEBAR_CUSTOM_ACTIONS_TRIGGERED),this.getService(we).disableSidebarCustomActions()}catch(o){this.getService(y).catch("Error in _disableSidebarCustomActions: ",o)}}_enableQueryParamsComments(){this.getService(y).log("%c[WB] Calling FUNCTION: enableQueryParamsComments","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).enableQueryParamsComments()}catch(o){this.getService(y).catch("Error in _enableQueryParamsComments: ",o)}}_disableQueryParamsComments(){this.getService(y).log("%c[WB] Calling FUNCTION: disableQueryParamsComments","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_QUERY_PARAMS_COMMENTS_TRIGGERED),this.getService(we).disableQueryParamsComments()}catch(o){this.getService(y).catch("Error in _disableQueryParamsComments: ",o)}}_enableResolveStatusAccessAdminOnly(){this.getService(y).log("%c[WB] Calling FUNCTION: enableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).enableResolveStatusAccessAdminOnly()}catch(o){this.getService(y).catch("Error in _enableResolveStatusAccessAdminOnly: ",o)}}_disableResolveStatusAccessAdminOnly(){this.getService(y).log("%c[WB] Calling FUNCTION: disableResolveStatusAccessAdminOnly","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_RESOLVE_STATUS_ACCESS_ADMIN_ONLY_TRIGGERED),this.getService(we).disableResolveStatusAccessAdminOnly()}catch(o){this.getService(y).catch("Error in _disableResolveStatusAccessAdminOnly: ",o)}}_enableSeenByUsers(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSeenByUsers","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).enableSeenByUsers()}catch(o){this.getService(y).catch("Error in _enableSeenByUsers: ",o)}}_disableSeenByUsers(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSeenByUsers","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SEEN_BY_USERS_TRIGGERED),this.getService(we).disableSeenByUsers()}catch(o){this.getService(y).catch("Error in _disableSeenByUsers: ",o)}}_enableShortUserName(){this.getService(y).log("%c[WB] Calling FUNCTION: enableShortUserName","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).enableShortUserName()}catch(o){this.getService(y).catch("Error in _enableShortUserName: ",o)}}_disableShortUserName(){this.getService(y).log("%c[WB] Calling FUNCTION: disableShortUserName","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SHORT_USER_NAME_TRIGGERED),this.getService(we).disableShortUserName()}catch(o){this.getService(y).catch("Error in _disableShortUserName: ",o)}}_addCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: addCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.ADD_COMMENT_ANNOTATION_TRIGGERED,{payload:{addCommentAnnotationRequest:o}}),this.getService(ii).convert(o).addCommentAnnotation(o,"external")}catch(t){return this.getService(y).catch("Error in _addCommentAnnotation: ",t),null}})}_approveCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: approveCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.APPROVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{approveCommentAnnotationRequest:o}}),this.getService(ii).convert(o).approveCommentAnnotation(o,"external")}catch(t){return this.getService(y).catch("Error in _approveCommentAnnotation: ",t),null}})}_acceptCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: acceptCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.ACCEPT_COMMENT_ANNOTATION_TRIGGERED,{payload:{acceptCommentAnnotationRequest:o}}),this.getService(ii).convert(o).acceptCommentAnnotation(o,"external")}catch(t){return this.getService(y).catch("Error in _acceptCommentAnnotation: ",t),null}})}_rejectCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: rejectCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.REJECT_COMMENT_ANNOTATION_TRIGGERED,{payload:{rejectCommentAnnotationRequest:o}}),this.getService(ii).convert(o).rejectCommentAnnotation(o,"external")}catch(t){return this.getService(y).catch("Error in _rejectCommentAnnotation: ",t),null}})}_subscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: subscribeCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.SUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{subscribeCommentAnnotationRequest:o}}),this.getService(ii).convert(o).toggleNotificationSubscription(o,"subscribe")}catch(t){return this.getService(y).catch("Error in _subscribeCommentAnnotation: ",t),null}})}_unsubscribeCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: unsubscribeCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.UNSUBSCRIBE_COMMENT_ANNOTATION_TRIGGERED,{payload:{unsubscribeCommentAnnotationRequest:o}}),this.getService(ii).convert(o).toggleNotificationSubscription(o,"unsubscribe")}catch(t){return this.getService(y).catch("Error in _unsubscribeCommentAnnotation: ",t),null}})}_deleteCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_COMMENT_ANNOTATION_TRIGGERED,{payload:{deleteCommentAnnotationRequest:o}}),this.getService(ii).convert(o).deleteCommentAnnotation(o,"external")}catch(t){return this.getService(y).catch("Error in _deleteCommentAnnotation: ",t),null}})}_getCommentAnnotations(o){this.getService(y).log("%c[WB] Calling FUNCTION: getCommentAnnotations","color: green;");try{return this.trackEvent(X.Events.Comments.GET_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{query:o}}),this.getService(ii).getCommentAnnotations(o).pipe(ce(t=>(t.data&&Object.keys(t.data).forEach(e=>{if(t.data?.[e]?.length){let i=t.data[e];t.data[e]=i?.map(r=>zn(r))}}),t)))}catch(t){return this.getService(y).catch("Error in _getCommentAnnotations: ",t),se({data:null})}}_getCommentAnnotationsCount(o){this.getService(y).log("%c[WB] Calling FUNCTION: getCommentAnnotationsCount","color: green;");try{return this.trackEvent(X.Events.Comments.GET_COMMENT_ANNOTATIONS_COUNT_TRIGGERED,{payload:{query:o}}),this.getService(ii).getCommentAnnotationsCount$(o)}catch(t){return this.getService(y).catch("Error in _getCommentAnnotationsCount: ",t),se({data:null})}}_assignUser(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: assignUser","color: green;");try{return this.trackEvent(X.Events.Comments.ASSIGN_USER_TRIGGERED,{payload:{assignUserRequest:o}}),this.getService(ii).convert(o).assignUser(o,"external")}catch(t){return this.getService(y).catch("Error in _assignUser: ",t),null}})}_updatePriority(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: updatePriority","color: green;");try{return this.trackEvent(X.Events.Comments.UPDATE_PRIORITY_TRIGGERED,{payload:{updatePriorityRequest:o}}),this.getService(ii).convert(o).updatePriority(o,"external")}catch(t){return this.getService(y).catch("Error in _updatePriority: ",t),null}})}_updateStatus(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: updateStatus","color: green;");try{return this.trackEvent(X.Events.Comments.UPDATE_STATUS_TRIGGERED,{payload:{updateStatusRequest:o}}),this.getService(ii).convert(o).updateStatus(o,"external")}catch(t){return this.getService(y).catch("Error in _updateStatus: ",t),null}})}_updateAccess(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: updateAccess","color: green;");try{return this.trackEvent(X.Events.Comments.UPDATE_ACCESS_TRIGGERED,{payload:{updateAccessRequest:o}}),this.getService(ii).convert(o).updateAccess(o,"external")}catch(t){return this.getService(y).catch("Error in _updateAccess: ",t),null}})}_resolveCommentAnnotation(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: resolveCommentAnnotation","color: green;");try{return this.trackEvent(X.Events.Comments.RESOLVE_COMMENT_ANNOTATION_TRIGGERED,{payload:{resolveCommentAnnotationRequest:o}}),this.getService(ii).convert(o).resolveCommentAnnotation(o)}catch(t){return this.getService(y).catch("Error in _resolveCommentAnnotation: ",t),null}})}_getLink(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: getLink","color: green;");try{return this.trackEvent(X.Events.Comments.GET_LINK_TRIGGERED,{payload:{getLinkRequest:o}}),this.getService(ii).convert(o).getLink(o,"external")}catch(t){return this.getService(y).catch("Error in _getLink: ",t),null}})}_copyLink(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: copyLink","color: green;");try{return this.trackEvent(X.Events.Comments.COPY_LINK_TRIGGERED,{payload:{copyLinkRequest:o}}),this.getService(ii).convert(o).copyLink(o,"external")}catch(t){return this.getService(y).catch("Error in _copyLink: ",t),null}})}_addComment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: addComment","color: green;");try{return this.trackEvent(X.Events.Comments.ADD_COMMENT_TRIGGERED,{payload:{addCommentRequest:o}}),this.getService(ii).convert(o).addComment(o,"external")}catch(t){return this.getService(y).catch("Error in _addComment: ",t),null}})}_updateComment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: updateComment","color: green;");try{return this.trackEvent(X.Events.Comments.UPDATE_COMMENT_TRIGGERED,{payload:{updateCommentRequest:o}}),this.getService(ii).convert(o).updateComment(o,"external")}catch(t){return this.getService(y).catch("Error in _updateComment: ",t),null}})}_deleteComment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteComment","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_COMMENT_TRIGGERED,{payload:{deleteCommentRequest:o}}),this.getService(ii).convert(o).deleteComment(o,"external")}catch(t){return this.getService(y).catch("Error in _deleteComment: ",t),null}})}_getComment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: getComment","color: green;");try{return this.trackEvent(X.Events.Comments.GET_COMMENT_TRIGGERED,{payload:{getCommentRequest:o}}),this.getService(ii).convert(o).getComment(o)}catch(t){return this.getService(y).catch("Error in _getComment: ",t),[]}})}_addAttachment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: addAttachment","color: green;");try{return this.trackEvent(X.Events.Comments.ADD_ATTACHMENT_TRIGGERED,{payload:{addAttachmentRequest:o}}),this.getService(ii).convert(o).addAttachment(o)}catch(t){return this.getService(y).catch("Error in _addAttachment: ",t),Promise.resolve([])}})}_deleteAttachment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteAttachment","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_ATTACHMENT_TRIGGERED,{payload:{deleteAttachmentRequest:o}}),this.getService(ii).convert(o).deleteAttachment(o)}catch(t){return this.getService(y).catch("Error in _deleteAttachment: ",t),null}})}_getAttachment(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: getAttachment","color: green;");try{return this.trackEvent(X.Events.Comments.GET_ATTACHMENT_TRIGGERED,{payload:{getAttachmentRequest:o}}),this.getService(ii).convert(o).getAttachment(o)}catch(t){return this.getService(y).catch("Error in _getAttachment: ",t),[]}})}_getRecording(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: getRecording","color: green;");try{return this.trackEvent(X.Events.Comments.GET_RECORDING_TRIGGERED,{payload:{getRecordingRequest:o}}),this.getService(ii).convert(o).getRecording(o)}catch(t){return this.getService(y).catch("Error in _getRecording: ",t),[]}})}_deleteRecording(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_RECORDING_TRIGGERED,{payload:{deleteRecordingRequest:o}}),this.getService(ii).convert(o).deleteRecording(o)}catch(t){return this.getService(y).catch("Error in _deleteRecording: ",t),null}})}_fetchCommentAnnotations(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: fetchCommentAnnotations","color: green;");try{return this.trackEvent(X.Events.Comments.FETCH_COMMENT_ANNOTATIONS_TRIGGERED,{payload:{fetchCommentAnnotationsRequest:o}}),this.getService(ii).fetchCommentAnnotations(o)}catch(t){return this.getService(y).catch("Error in _fetchCommentAnnotations: ",t),{data:null}}})}_addReaction(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: addReaction","color: green;");try{return this.trackEvent(X.Events.Comments.ADD_REACTION_TRIGGERED,{payload:{addReactionRequest:o}}),this.getService(ii).convert(o).toggleReaction(o,"add")}catch(t){return this.getService(y).catch("Error in _addReaction: ",t),null}})}_deleteReaction(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: deleteReaction","color: green;");try{return this.trackEvent(X.Events.Comments.DELETE_REACTION_TRIGGERED,{payload:{deleteReactionRequest:o}}),this.getService(ii).convert(o).toggleReaction(o,"delete")}catch(t){return this.getService(y).catch("Error in _deleteReaction: ",t),null}})}_toggleReaction(o){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: toggleReaction","color: green;");try{return this.trackEvent(X.Events.Comments.TOGGLE_REACTION_TRIGGERED,{payload:{toggleReactionRequest:o}}),this.getService(ii).convert(o).toggleReaction(o)}catch(t){return this.getService(y).catch("Error in _toggleReaction: ",t),null}})}_on(o){this.getService(y).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.trackEvent(X.Events.Comments.ON_ACTION_TRIGGERED,{payload:{action:o}}),this.getService(ii).onAction(o)}catch(t){return this.getService(y).catch("Error in _on: ",t),se(null)}}_enableReadOnly(){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: enableReadOnly","color: green;");try{return this.trackEvent(X.Events.Comments.ENABLE_READ_ONLY_TRIGGERED),this.getService(we).enableReadOnly()}catch(o){this.getService(y).catch("Error in _toggleReaction: ",o);return}})}_disableReadOnly(){return Q(this,null,function*(){this.getService(y).log("%c[WB] Calling FUNCTION: disableReadOnly","color: green;");try{return this.trackEvent(X.Events.Comments.DISABLE_READ_ONLY_TRIGGERED),this.getService(we).disableReadOnly()}catch(o){this.getService(y).catch("Error in _disableReadOnly: ",o);return}})}_enableCustomAutocompleteSearch(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCustomAutocompleteSearch","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).enableCustomAutocompleteSearch()}catch(o){this.getService(y).catch("Error in _enableCustomAutocompleteSearch: ",o);return}}_disableCustomAutocompleteSearch(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCustomAutocompleteSearch","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_CUSTOM_AUTOCOMPLETE_SEARCH_TRIGGERED),this.getService(we).disableCustomAutocompleteSearch()}catch(o){this.getService(y).catch("Error in _disableCustomAutocompleteSearch: ",o);return}}_setTransformContext(o){this.getService(y).log("%c[WB] Calling FUNCTION: setTransformContext","color: green;");try{this.trackEvent(X.Events.Comments.SET_TRANSFORM_CONTEXT_TRIGGERED,{payload:{transformContext:o}}),this.getService(we).setTransformContext(o)}catch(t){this.getService(y).catch("Error in _setTransformContext: ",t);return}}_enableSvgAsImg(){this.getService(y).log("%c[WB] Calling FUNCTION: enableSvgAsImg","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).enableSvgAsImg()}catch(o){this.getService(y).catch("Error in _enableSvgAsImg: ",o);return}}_disableSvgAsImg(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSvgAsImg","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_SVG_AS_IMG_TRIGGERED),this.getService(we).disableSvgAsImg()}catch(o){this.getService(y).catch("Error in _disableSvgAsImg: ",o);return}}_enableFullExpanded(){this.getService(y).log("%c[WB] Calling FUNCTION: enableFullExpanded","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).enableFullExpanded()}catch(o){this.getService(y).catch("Error in _enableFullExpanded: ",o);return}}_disableFullExpanded(){this.getService(y).log("%c[WB] Calling FUNCTION: disableFullExpanded","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_FULL_EXPANDED_TRIGGERED),this.getService(we).disableFullExpanded()}catch(o){this.getService(y).catch("Error in _disableFullExpanded: ",o);return}}_enableCommentToNearestAllowedElement(){this.getService(y).log("%c[WB] Calling FUNCTION: enableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).enableCommentToNearestAllowedElement()}catch(o){this.getService(y).catch("Error in _enableCommentToNearestAllowedElement: ",o);return}}_disableCommentToNearestAllowedElement(){this.getService(y).log("%c[WB] Calling FUNCTION: disableCommentToNearestAllowedElement","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_COMMENT_TO_NEAREST_ALLOWED_ELEMENT_TRIGGERED),this.getService(we).disableCommentToNearestAllowedElement()}catch(o){this.getService(y).catch("Error in _disableCommentToNearestAllowedElement: ",o);return}}_enableDraftMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDraftMode","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_DRAFT_MODE_TRIGGERED),this.getService(we).enableDraftMode()}catch(o){this.getService(y).catch("Error in _enableDraftMode: ",o);return}}_disableDraftMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDraftMode","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_DRAFT_MODE_TRIGGERED),this.getService(we).disableDraftMode()}catch(o){this.getService(y).catch("Error in _disableDraftMode: ",o);return}}_enableFilterCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: enableFilterCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.ENABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).enableFilterCommentsOnDom()}catch(o){this.getService(y).catch("Error in _enableFilterCommentsOnDom: ",o);return}}_disableFilterCommentsOnDom(){this.getService(y).log("%c[WB] Calling FUNCTION: disableFilterCommentsOnDom","color: green;");try{this.trackEvent(X.Events.Comments.DISABLE_FILTER_COMMENTS_ON_DOM_TRIGGERED),this.getService(we).disableFilterCommentsOnDom()}catch(o){this.getService(y).catch("Error in _disableFilterCommentsOnDom: ",o);return}}};var VM=class extends ci{constructor(o){super(o),this.getService(y).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(y).log("%c[WB] Calling FUNCTION: isUserGlobalContact","color: green;");try{return this.trackEvent(X.Events.Contact.IS_USER_GLOBAL_CONTACT_TRIGGERED),this.getService(Ci).isUserGlobalContact$()}catch(o){return this.getService(y).catch("Error in _isUserGlobalContact: ",o),se(!1)}}_onContactSelected(){this.getService(y).log("%c[WB] Calling FUNCTION: onContactSelected","color: green;");try{return this.trackEvent(X.Events.Contact.ON_CONTACT_SELECTED_TRIGGERED),this.getService(Ci).onContactSelected$()}catch(o){return this.getService(y).catch("Error in _onContactSelected: ",o),se(null)}}_enableAtHere(){this.getService(y).log("%c[WB] Calling FUNCTION: enableAtHere","color: green;");try{this.trackEvent(X.Events.Contact.ENABLE_AT_HERE_TRIGGERED),this.getService(Ci).enableAtHere()}catch(o){this.getService(y).catch("Error in _enableAtHere: ",o)}}_setAtHereLabel(o){this.getService(y).log("%c[WB] Calling FUNCTION: setAtHereLabel","color: green;");try{this.trackEvent(X.Events.Contact.SET_AT_HERE_LABEL_TRIGGERED,{payload:{label:o}}),this.getService(Ci).setAtHereLabel(o)}catch(t){this.getService(y).catch("Error in setAtHereLabel: ",t)}}_setAtHereDescription(o){this.getService(y).log("%c[WB] Calling FUNCTION: setAtHereDescription","color: green;");try{this.trackEvent(X.Events.Contact.SET_AT_HERE_DESCRIPTION_TRIGGERED,{payload:{description:o}}),this.getService(Ci).setAtHereDescription(o)}catch(t){this.getService(y).catch("Error in setAtHereDescription: ",t)}}_disableAtHere(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAtHere","color: green;");try{this.trackEvent(X.Events.Contact.DISABLE_AT_HERE_TRIGGERED),this.getService(Ci).disableAtHere()}catch(o){this.getService(y).catch("Error in _disableAtHere: ",o)}}_updateContactListScopeForOrganizationUsers(o){this.getService(y).log("%c[WB] Calling FUNCTION: updateContactListScopeForOrganizationUsers","color: green;");try{this.trackEvent(X.Events.Contact.UPDATE_CONTACT_LIST_SCOPE_FOR_ORGANIZATION_USERS_TRIGGERED,{payload:{scope:o}}),this.getService(Ci).updateContactListScopeForOrganizationUsers(o)}catch(t){this.getService(y).catch("Error in _updateContactListScopeForOrganizationUsers: ",t)}}_updateContactList(o,t){this.getService(y).log("%c[WB] Calling FUNCTION: _updateContactList","color: green;");try{this.trackEvent(X.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{payload:{userContacts:o,config:t}}),typeof o=="object"&&o instanceof Array&&(!t||t&&typeof t=="object")&&(o=JSON.parse(JSON.stringify(o)),this.getService(Ci).convert(t).updateContactList(o,t))}catch(e){this.getService(y).catch("Error in _updateContactList: ",e)}}_getContactList(){this.getService(y).log("%c[WB] Calling FUNCTION: getContactList","color: green;");try{return this.trackEvent(X.Events.Contact.GET_CONTACT_LIST_TRIGGERED),this.getService(Ci).getContactList$()}catch(o){return this.getService(y).catch("Error in _getContactList: ",o),se(null)}}};var ts=function(n){return n.CLICK="click",n.HOVER="hover",n.SCROLL="scroll",n.NAVIGATE="navigate",n}(ts||{}),Fd=class{constructor(){this.type=ts.HOVER,this.data=null,this.pageInfo=Ei(),this.timestamp=Date.now()}},UM=class{constructor(o,t){this.targetXpath=o,this.xpath=t}};var jM=class{constructor(){this.sessionId=null,this.isLeader=!1,this.lastProcessedActionTimestamp=null}};var rh=class{constructor(o){this.snippylyId=o,this.joinTimestamp=Date.now()}};var $M=class{constructor(o,t,e){this.followers=[],this.actionStack=[],this.id=Pn(),this.leaderId=o,this.leaderName=t,this.followers.push(new rh(e))}};var $le=(()=>{let o=class o{constructor(e,i,r,a,s){this.databaseService=e,this.docService=i,this.loggingService=r,this.authService=a,this.commonDbService=s,this.currentUser$=new Ce(null),this.currentSession$=new Ce(null);try{this.databaseService.getDb().pipe(Fe(m=>!!m),tt(1)).subscribe(m=>{m&&(this.db=m)},m=>{this.loggingService.catch("Error in FlockSessionService getDb subscription: ",m)}),this.authService.getUser$().subscribe(m=>{m&&m.userSnippylyId&&(this.user=m)})}catch(m){this.loggingService.catch("Error in FlockSessionService constructor: ",m)}}startCurrentFlockUserSubscription(e){try{this.currentUserSub?.unsubscribe(),e&&e.userSnippylyId&&(this.user=e,this.subscribeToCurrentFlockUser(e?.userSnippylyId))}catch(i){this.loggingService.catch("Error in FlockSessionService startCurrentFlockUserSubscription: ",i)}}stopCurrentFlockUserSubscription(){try{this.currentUserSub?.unsubscribe()}catch(e){this.loggingService.catch("Error in FlockSessionService stopCurrentFlockUserSubscription: ",e)}}provisionFlockSession(e,i,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(tt(1)).subscribe(s=>{s?.data&&s?.data?.sessionId?this.subscribeToCurrentSession(s?.data?.sessionId,r):this.createFlockSession(e,i,r)})}catch(a){this.loggingService.catch("Error in FlockSessionService provisionFlockSession: ",a)}return null}swapLeader(e,i,r){try{if(this.updateRemoteFlockUser(e,{isLeader:!1}),this.updateRemoteFlockUser(i,{isLeader:!0}),this.currentSession){this.currentSession.leaderId=i,this.currentSession.leaderName=r,this.currentSession.followers.push(new rh(e));let a=this.currentSession.followers.findIndex(s=>s.snippylyId===i);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,i,r){try{let a=new $M(e,i,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 i=this.currentSession.followers.findIndex(r=>r.snippylyId===e);if(i>-1){if(this.currentSession.followers.splice(i,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(i){this.loggingService.catch("Error in FlockSessionService removeFollowerFromSession: ",i)}}updateRemoteFlockUser(e,i={}){try{if(!e)return;let r=this.docService.getDocumentPaths();for(let a in i)i.hasOwnProperty(a)&&i[a]===void 0&&delete i[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(i))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateRemoteFlockUser: ",r)}}subscribeToCurrentSession(e,i=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,i!==void 0&&this.currentSession?.followers.findIndex(s=>s.snippylyId===i)===-1&&(this.currentSession.followers.push(new rh(i)),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 i=this.docService.getDocumentPaths();i&&this.db&&(this.currentUserSub&&this.currentUserSub.unsubscribe(),this.currentUserSub=this.commonDbService.dbListener({feature:"flockUser",properties:{documentId:i?.documentId,organizationId:i?.organizationId,id:e,skipFirestore:!0}}).pipe(jn(r=>(this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",r),se(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(i){this.loggingService.catch("Error in FlockSessionService subscribeToCurrentFlockUser: ",i)}}updateSession(e,i={}){try{if(!e)return;let r=this.docService.getDocumentPaths();for(let a in i)i.hasOwnProperty(a)&&i[a]===void 0&&delete i[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(i))})}catch(r){this.loggingService.catch("Error in FlockSessionService updateSession: ",r)}}deleteSession(e){try{let i=this.docService.getDocumentPaths();i&&this.db&&(this.commonDbService.deleteData({feature:"flockSession",properties:{documentId:i?.documentId??"",organizationId:i?.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(i){this.loggingService.catch("Error in FlockSessionService deleteSession: ",i)}}addActionToStack(e,i){try{i=i&&JSON.parse(JSON.stringify(i));let r=this.docService.getDocumentPaths();if(r&&this.db&&e){let a=rn(this.db,`${r.flock}/sessions/${e}/actionStack`);B5(a,s=>s?(s.unshift(i),s.slice(0,5)):[i]),i.type===ts.NAVIGATE&&this.updateSession(e,{pageInfo:i.pageInfo})}}catch(r){this.loggingService.catch("Error in FlockSessionService addActionToStack: ",r)}}};o.\u0275fac=function(i){return new(i||o)(J(hn),J(lt),J(y),J(He),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Hle={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 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 tl=(()=>{let o=class o{constructor(e){this.loggingService=e,this.currentLanguageSignal=Te(navigator.language.split("-")[0]),this.autoTranslationSignal=Te(!1),this.translationsMap=new Map,this.translationCache=new Map,this.translationsUpdateSignal=Te(0),this.currentLanguage=this.currentLanguageSignal.asReadonly(),this.autoTranslation=this.autoTranslationSignal.asReadonly(),this.translationsVersion=this.translationsUpdateSignal.asReadonly(),this.currentTranslations=Mi(()=>{let i=this.currentLanguageSignal(),r=this.translationsUpdateSignal();return this.translationsMap.get(i)||{}}),this.loggingService.log("%c[WB] Calling FUNCTION: constructor","color: green;"),this.setTranslations(Hle),ur(()=>{let i=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 i=this.currentLanguageSignal(),r=this.translationsUpdateSignal(),a=`${i}:${e}:${r}`,s=this.translationCache.get(i);if(s?.has(a))return s.get(a)||e;let m=this.currentTranslations()[e];return this.translationCache.has(i)||this.translationCache.set(i,new Map),this.translationCache.get(i)?.set(a,m||e),vv(m)?e:m}catch{return e}}setTranslations(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setTranslations","color: green;");let i=!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)||(i=!0)});let m=I(I({},s),a);this.translationsMap.set(r,m),this.translationCache.delete(r)}}),this.translationsUpdateSignal.update(r=>r+1),i&&setTimeout(()=>{this.translationsUpdateSignal.update(r=>r+1)},0)}catch(i){this.loggingService.catch("Error in setTranslations: ",i)}}setLanguage(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLanguage","color: green;"),this.currentLanguageSignal.set(e)}catch(i){this.loggingService.catch("Error in setLanguage: ",i)}})}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(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var de=(()=>{let o=class o{constructor(e,i){this.domService=e,this.translateService=i,this.sanitizedCache=new Map}transform(e){if(e==null)return"";let i=typeof e=="boolean"||typeof e=="number"?String(e):e;try{let r=this.translateService.currentLanguage(),a=this.translateService.translationsVersion(),s=`${r}:${i}:${a}`,m=this.sanitizedCache.get(s);if(m)return m;let p=this.translateService.translate(i),h=this.domService.sanitizeHtml(p);return this.sanitizedCache.set(s,h),this.sanitizedCache.size>1e3&&this.sanitizedCache.clear(),h}catch(r){return console.warn("Translation error:",r),i}}};o.\u0275fac=function(i){return new(i||o)(u(Ne,16),u(tl,16))},o.\u0275pipe=Hi({name:"translate",type:o,pure:!0,standalone:!1});let n=o;return n})();function dke(n,o){if(n&1&&(C(0,"span",6),te(1),A(2,"translate"),S()),n&2){let t=l(2).ngIf;d(),gr("",P(2,2,"You are following")," ",t.leaderName,"")}}function pke(n,o){n&1&&(C(0,"span",6),te(1),A(2,"translate"),S()),n&2&&(d(),je(P(2,1,"You are leading.")))}function gke(n,o){if(n&1){let t=q();C(0,"div",2),G("click",function(){N(t);let i=l().ngIf,r=l();return F(i.type==="following"?r.closeOverlay():void 0)}),C(1,"div",3),g(2,dke,3,4,"span",4)(3,pke,3,3,"span",4),C(4,"button",5),G("click",function(){N(t);let i=l(2);return F(i.closeOverlay())}),te(5),A(6,"translate"),A(7,"translate"),S()()()}if(n&2){let t=l().ngIf;ge("no-pointer",t.type==="leading"),d(2),c("ngIf",t.type==="following"),d(),c("ngIf",t.type==="leading"),d(2),gr("",P(6,6,"Stop")," ",P(7,8,t.type),"")}}function uke(n,o){if(n&1&&(f(0),g(1,gke,8,10,"div",1),v()),n&2){let t=o.ngIf;d(),c("ngIf",t.leaderName!==""||t.type==="leading")}}var IH=(()=>{let o=class o extends nt{closeOverlay(){this.closeOverlayEvent.emit()}constructor(e,i,r){super(i,r),this.loggingService=e,this.elementRef=i,this.themeService=r,this.closeOverlayEvent=new Ae,this.componentConfigSignal=Te({leaderName:"",type:"following"})}ngOnInit(){}setLeaderName(e){try{this.componentConfigSignal.update(i=>(i=T(I({},i),{leaderName:e}),i))}catch(i){this.loggingService.catch("Error in FollowOverlayComponent setLeaderName: ",i)}}getLeaderName(){return this.componentConfigSignal().leaderName}setType(e){try{this.componentConfigSignal.update(i=>(i=T(I({},i),{type:e}),i))}catch(i){this.loggingService.catch("Error in FollowOverlayComponent setType: ",i)}}ngOnDestroy(){try{super.ngOnDestroy()}catch{}}};o.\u0275fac=function(i){return new(i||o)(u(y),u(k),u(Ye))},o.\u0275cmp=O({type:o,selectors:[["snippyly-follow-overlay"]],outputs:{closeOverlayEvent:"closeOverlayEvent"},standalone:!1,features:[B],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(i,r){i&1&&g(0,uke,2,1,"ng-container",0),i&2&&c("ngIf",r.componentConfigSignal())},dependencies:[Z,de],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}
|
|
383
383
|
`],encapsulation:3,changeDetection:0});let n=o;return n})();var zle=(()=>{let o=class o{constructor(e,i,r,a){this.componentFactoryResolver=e,this.applicationRef=i,this.injector=r,this.loggingService=a,this.darkMode=!1}createFollowOverlay(e,i){try{let a=this.componentFactoryResolver.resolveComponentFactory(IH).create(this.injector);a.instance.setLeaderName(e),a.instance.closeOverlayEvent.pipe(tt(1)).subscribe(()=>{this.removeOverlay(),i()}),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(j.ATTRIBUTES.VELT_IGNORE,""),document.body.appendChild(s)}catch(r){this.loggingService.catch("Error in FlockOverlayService createFollowOverlay: ",r)}}createLeaderOverlay(e){let r=this.componentFactoryResolver.resolveComponentFactory(IH).create(this.injector);r.instance.setType("leading"),r.instance.closeOverlayEvent.pipe(tt(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(j.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(i){this.loggingService.catch("Error in FlockOverlayService setDarkMode: ",i)}}};o.\u0275fac=function(i){return new(i||o)(J(xo),J(di),J(xt),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Ac=(()=>{let o=class o{constructor(e,i,r,a,s){this.authService=e,this.domService=i,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(m=>{let{userId:p,name:h}=m,_=p;if(this.provisionFollowUser(),_&&this.currentFlockUser&&this.currentFlockUser.snippylyId)if(this.currentFlockUser.sessionId){if(this.currentFlockUser.snippylyId&&this.currentFlockUser.isLeader){this.flockSessionService.swapLeader(this.currentFlockUser.snippylyId,_,h);return}this.removeCurrentUserFromSession()}else this.flockSessionService.provisionFlockSession(_,h,this.currentFlockUser.snippylyId)},m=>{this.loggingService.catch("Error in FlockService flockLeader$ subscription: ",m)}),this.flockSessionService.currentSession$.subscribe(m=>{if(m!==null){if(this.currentFlockUser&&(this.currentFlockUser.sessionId===null||this.currentFlockUser.sessionId===void 0)&&this.currentFlockUser.snippylyId&&(this.currentFlockUser.sessionId=m.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(m.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&&m.actionStack){let p=m.actionStack[0];p&&this.currentFlockUser.lastProcessedActionTimestamp!==p.timestamp&&this.processAction(p)}if(this.currentFlockUser&&!this.currentFlockUser.isLeader&&this.followOverlayCreated&&this.flockOverlayService.getLeaderName()!==null&&m.leaderName!==this.flockOverlayService.getLeaderName()&&this.flockOverlayService.changeLeaderName(m.leaderName),this.currentFlockUser&&this.currentFlockUser.isLeader){let p=Ei();if(m.pageInfo){if(p&&p.url!==m.pageInfo.url){let h=new Fd;h.type=ts.NAVIGATE,this.flockSessionService.addActionToStack(m.id,h)}}else{this.flockSessionService.updateSession(m.id,{pageInfo:p});let h=new Fd;h.type=ts.NAVIGATE,this.flockSessionService.addActionToStack(m.id,h)}}}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(m=>{if(m!==null&&(this.currentFlockUser&&this.currentFlockUser.isLeader!==m.isLeader&&(this.domSubscriptions.forEach(p=>p.unsubscribe()),this.domSubscriptions=[]),this.currentFlockUser=m,m.sessionId&&this.domSubscriptions.length===0))if(m.isLeader){if(!this.tabFocused||!this.windowFocused)return;this.subscribeToLeaderDOMEvents()}else this.subscribeToFollowerDOMEvents()}),Rn([this.authService.getUser$(),this.getFlockMode$()]).subscribe(([m,p])=>{m&&m.userSnippylyId&&p?this.flockSessionService.startCurrentFlockUserSubscription(m):this.flockSessionService.stopCurrentFlockUserSubscription()})}catch(m){this.loggingService.catch("Error in FlockService constructor: ",m)}}provisionFollowUser(){try{if(this.currentFlockUser===null){let e=this.authService.getUser();e&&e.userSnippylyId&&(this.currentFlockUser=new jM,this.currentFlockUser.snippylyId=e.userSnippylyId)}}catch(e){this.loggingService.catch("Error in FlockService provisionFollowUser: ",e)}}startFollowingUser(e,i){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,i);return}this.removeCurrentUserFromSession()}this.flockSessionService.provisionFlockSession(e,i,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,i=window.history.replaceState;window.history.pushState=(...r)=>{e.apply(window.history,r),this.onUrlChange()},window.history.replaceState=(...r)=>{i.apply(window.history,r),this.onUrlChange()},this.domSubscriptions.push({unsubscribe:()=>{window.history.pushState=e,window.history.replaceState=i}}),this.domSubscriptions.push(ri(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 Fd;e.type=ts.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 ts.CLICK:this.clickUserElement(e.data);break;case ts.HOVER:this.scrollToHoveredElement(e.data);break;case ts.SCROLL:this.scrollToFollowedUser(e.data);break;case ts.NAVIGATE:this.checkMatchingUrl(e.pageInfo);break}this.currentFlockUser&&this.currentFlockUser.snippylyId&&this.flockSessionService.updateRemoteFlockUser(this.currentFlockUser.snippylyId,{lastProcessedActionTimestamp:e.timestamp})}catch(i){this.loggingService.catch("Error in FlockService processAction: ",i)}}subscribeToLeaderDOMEvents(){try{this.domSubscriptions.length>0&&(this.domSubscriptions.forEach(e=>e.unsubscribe()),this.domSubscriptions=[]),this.domSubscriptions.push(ri(window,"mouseover").pipe(rr(500)).subscribe(e=>{let i=e?.target;if(i){let r=window.getComputedStyle(i);if(r.position==="fixed"||r.position==="sticky"||i.hasAttribute(j.ATTRIBUTES.VELT_IGNORE))return;i=wU(i,{x:e.clientX,y:e.clientY}),this.updateHoveredElement(i)}})),this.domSubscriptions.push(this.domService.onWindowClick$().subscribe(e=>{let i=e?.target;if(i){if(i.hasAttribute(j.ATTRIBUTES.VELT_IGNORE))return;this.updateClickedElement(i)}})),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 i=this.domService.getXPath(e),r=fv(e),a=this.domService.getXPath(r),s={id:Math.random().toString(36).substring(2),xpath:i,parentXpath:a},m=new Fd;m.type=ts.CLICK,m.data=s,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,m)}}catch(i){this.loggingService.catch("Error in FlockService updateClickedElement: ",i)}}updateHoveredElement(e){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId){let i=this.domService.getXPath(e),r=fv(e),a=this.domService.getXPath(r),s={id:Math.random().toString(36).substring(2),xpath:i,parentXpath:a},m=new Fd;m.type=ts.HOVER,m.data=s,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,m)}}catch(i){this.loggingService.catch("Error in FlockService updateHoveredElement: ",i)}}subscribeToScrollables(){try{let e=nre();e.push(document),e?.forEach(i=>{this.domSubscriptions.push(ri(i,"scroll").pipe(rr(100)).subscribe(r=>{this.currentFlockUser&&this.currentFlockUser.sessionId&&this.currentFlockUser.isLeader&&this.updateScrollPositionOfElement(i)}))})}catch(e){this.loggingService.catch("Error in FlockService getScrollableElements: ",e)}}updateScrollPositionOfElement(e){try{if(this.currentFlockUser&&this.currentFlockUser.sessionId){let i=new UM("","");if(e===document){let s=rre();if(s){let m=wU(s);m&&(i.targetXpath=this.domService.getXPath(m))}i.xpath=""}else{let s=ore(e);i.targetXpath=this.domService.getXPath(s),i.xpath=this.domService.getXPath(e)}let r=!1,a=!1;if(this.localScrollData.forEach((s,m)=>{s.xpath===s.xpath&&(i.targetXpath!==s.targetXpath&&(r=!0),this.localScrollData[m]=Object.assign(s,i),a=!0)}),a||this.localScrollData.push(i),r||!a){let s=new Fd;s.type=ts.SCROLL,s.data=i,this.flockSessionService.addActionToStack(this.currentFlockUser.sessionId,s)}}}catch(i){this.loggingService.catch("Error in FlockService calculateScrollPositionOfAnElement: ",i)}}enableFlockMode(e){try{if(this.flockMode$.next(!0),e){let{useHistoryAPI:i,onNavigate:r,disableDefaultNavigation:a,darkMode:s}=e;i!==void 0&&(this.useHistoryAPI=i),r!==void 0&&typeof r=="function"&&(this.onNavigate=r),a!==void 0&&(this.disableDefaultNavigation=a),this.flockOverlayService.setDarkMode(s)}}catch(i){this.loggingService.catch("Error in FlockService enableFlockMode: ",i)}}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(i){this.loggingService.catch("Error in FlockService setDisableFlockNavigation: ",i)}}getFlockMode$(){return this.flockMode$.asObservable()}getFlockMode(){return this.flockMode$.value}setNavigateEmitter(e){try{this.onNavigateEmitter=e}catch(i){this.loggingService.catch("Error in FlockService setNavigateEmitter: ",i)}}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(i){this.loggingService.catch("Error in FlockService setTabFocused: ",i)}}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(i){this.loggingService.catch("Error in FlockService setWindowFocused: ",i)}}setFlockLeader(e,i){try{this.flockLeader$.next({userId:e,name:i})}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=Ei()?.url,a=e.url;if(r!==a&&a!==void 0){let{url:s,path:m,baseUrl:p}=e;if(this.onNavigate!==void 0&&typeof this.onNavigate=="function"){this.onNavigate({url:s,path:m,baseUrl:p});return}if(this.onNavigateEmitter&&this.onNavigateEmitter.emit({url:s,path:m,baseUrl:p}),this.disableDefaultNavigation)return;window.location.href=a}}catch(i){this.loggingService.catch("Error in FlockService checkMatchingUrl: ",i)}}scrollToFollowedUser(e){try{if(e.xpath===""){let i=this.domService.getElementFromXPath(e.targetXpath);i&&K6(i)}else{let i=this.domService.getElementFromXPath(e.xpath),r=this.domService.getElementFromXPath(e.targetXpath);i&&r&&(K6(i),OU(i,r))}}catch(i){this.loggingService.catch("Error in FlockService scrollToFollowedUser: ",i)}}clickUserElement(e){try{let i=this.domService.getElementFromXPath(e.xpath);i&&this.lastClickedElement?.id!==e.id&&(i?.click(),this.lastClickedElement=e)}catch(i){this.loggingService.catch("Error in FlockService clickUserElement: ",i)}}scrollToHoveredElement(e){try{let i=this.domService.getElementFromXPath(e.xpath);if(i&&e.parentXpath)if(e.parentXpath==="/html")K6(i);else{let r=this.domService.getElementFromXPath(e.parentXpath);r&&OU(r,i,!0)}}catch(i){this.loggingService.catch("Error in FlockService clickUserElement: ",i)}}};o.\u0275fac=function(i){return new(i||o)(J(He),J(Ne),J(y),J($le),J(zle))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var xi=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E){this.afAuth=e,this.analyticsService=i,this.authService=r,this.configService=a,this.databaseService=s,this.docService=m,this.domService=p,this.iamService=h,this.loggingService=_,this.commonDbService=E,this.db=Ii(),this.liveStateDataMap$=new Ce({}),this.liveStateDataMapDraft={},this.singleEditorMode$=new Ce(!1),this.singleEditorModeConfig$=new Ce(null),this.singleEditorLiveStateData$=new Ce(null),this.singleEditorLiveStateData={},this.editorAccessTimeout$=new Ce(j.LIVE_STATE_REQUEST_EDITOR_ACCESS_WAIT_TIME),this.editorAccessTransferOnTimeOut$=new Ce(!0),this.defaultSingleEditorUIEnabled$=new Ce(!0),this.editorAccessTimer$=new Ce(new Zv),this.autoSyncState$=new Ce(!1),this.serverConnectionState$=new Ce(qs.PENDING_INIT),this.user=null,this.keydownSubscription=null,this.isEditor$=new Ce(null),this.preventEventsOnElementMap={},this.PREVENT_EVENTS=["click","mouseup","mousedown"],this.autoSyncStateHistory=null,this.singleEditorModeContainerIds$=new Ce([]),this.inputChangeSubscriptionMap={},this.childListMutationSubscription=null,this.tabId=this.domService.getTabId();try{this.loggingService.log("%c[WB] Creating CLASS: LiveStateService","color: blue;"),this.databaseService.getDb().pipe(Fe(D=>!!D),tt(1)).subscribe(D=>{D&&(this.db=D,this.getUser(),this.getDocumentPaths(),this.subscribeLiveStateData().subscribe(),this.singleEditorMode$.subscribe(L=>{L&&this.detectKeydownOnInput()}),this.autoSyncState$.subscribe(L=>{L?(this.detectLiveSyncInputs(),this.observeElementAddedOnDom()):(this.unsubscribeInputChanges(),this.childListMutationSubscription?.unsubscribe(),this.childListMutationSubscription=null)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},L=>{this.loggingService.catch("Error in LiveStateService constructor updateOnDatabaseDisconnect: ",L)}),this.updateServerStateOnDatabaseDisconnect().subscribe(()=>{},L=>{this.loggingService.catch("Error in LiveStateService constructor updateServerStateOnDatabaseDisconnect: ",L)}))},D=>{this.loggingService.catch("Error in LiveStateService getDb subscription: ",D)}),this.liveStateDataMap$.pipe(Fe(D=>!!D?.default?.autoSyncState),ce(D=>D.default?.autoSyncState),qt((D,L)=>JSON.stringify(D||{})===JSON.stringify(L||{}))).subscribe(D=>{D&&(this.getAutoSyncState()&&(!this.autoSyncStateHistory&&D?.history&&this.updateLiveStateSyncInputDataLocally(D.history),D?.current&&this.updateLiveStateSyncInputDataLocally({[D.current.liveStateDataId]:D.current})),!this.autoSyncStateHistory&&D?.history&&(this.autoSyncStateHistory=D.history))}),this.docService.addPreDocumentIdChangeFunction("live-state-service",D=>this.isUserEditor()?.isEditor&&(!this.getSingleEditorModeConfig()?.singleTabEditor||this.isUserEditor()?.isEditorOnCurrentTab)?this.removeEditorAccess():Promise.resolve()),this.singleEditorLiveStateData$.pipe(Pi()).subscribe(([D,L])=>{try{let H=L?.requestEditorAccess?.status,K=D?.requestEditorAccess?.status,oe=this.authService.getUser();if(H==="pending"){if(oe?.userId===L?.editor?.userId){let ue={viewer:ha(L?.requestEditorAccess?.user)??void 0,editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),status:"requested"};this.liveStateActionsService?.onAccessRequested(ue)}return}if(H==="cancelled"){if(oe?.userId===L?.editor?.userId){let ue={viewer:ha(L?.requestEditorAccess?.user)??void 0,editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),status:"canceled"};this.liveStateActionsService?.onAccessRequestCanceled(ue)}return}if(K==="pending"&&!H){if(D?.requestEditorAccess?.user?.userId===L?.editor?.userId){if(D?.requestEditorAccess?.user?.userId===oe?.userId){let ue={viewer:ha(D?.editor)??void 0,editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),status:"accepted"};this.liveStateActionsService?.onAccessAccepted(ue)}return}if(D?.requestEditorAccess?.user?.userId!==L?.editor?.userId){if(D?.requestEditorAccess?.user?.userId===oe?.userId){let ue={viewer:ha(D?.requestEditorAccess?.user)??void 0,editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),status:"rejected"};this.liveStateActionsService?.onAccessRejected(ue)}return}}}catch(H){this.loggingService.catch("Error in LiveStateService singleEditorLiveStateData$ subscription: ",H)}}),this.isUserEditor$().pipe(qt(Vi)).subscribe(D=>{try{if(D){let L=this.singleEditorLiveStateData$.value;if(D?.isEditor)if(D?.isEditorOnCurrentTab){let H={editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),role:"editor"};this.liveStateActionsService?.onEditorAssigned(H)}else{let H={editor:ha(L?.editor)??void 0,timestamp:new Date().getTime(),role:"editorOnDifferentTab"};this.liveStateActionsService?.onEditorOnDifferentTabDetected(H)}else{let H={viewer:ha(this.authService.getUser())??void 0,timestamp:new Date().getTime(),role:"viewer"};this.liveStateActionsService?.onViewerAssigned(H)}}}catch(L){this.loggingService.catch("Error in LiveStateService isUserEditor$ subscription: ",L)}})}catch(D){this.loggingService.catch("Error in LiveStateService constructor: ",D)}}setLiveStateActionsService(e){try{this.liveStateActionsService=e}catch(i){this.loggingService.catch("Error in LiveStateService setLiveStateActionsService: ",i)}}observeElementAddedOnDom(){try{this.loggingService.log("%c[WB] Calling FUNCTION: observeElementAddedOnDom","color: green;"),this.childListMutationSubscription&&(this.childListMutationSubscription.unsubscribe(),this.childListMutationSubscription=null),this.childListMutationSubscription=this.domService.getChildListMutation$().subscribe(e=>{e?.length&&e.forEach(i=>{let r=Array.from(i.addedNodes||[]).filter(a=>a instanceof HTMLElement);r?.forEach(a=>{MU(a,!0)?.forEach(p=>{typeof p?.getAttribute=="function"&&p?.getAttribute(j.ATTRIBUTES.VELT_SYNC_STATE)&&this.subscribeInputChanges(p)})}),r?.length&&this.isEditor$?.value?.isEditor===!1&&(this.disableInputElements(),this.disableElementEvents())})},e=>{this.loggingService.catch("Error in LiveStateService domService getChildListMutation$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in LiveStateService observeElementAddedOnDom: ",e)}}detectKeydownOnInput(){try{this.loggingService.log("%c[WB] Calling FUNCTION: detectKeydownOnInput","color: green;"),this.unsubscribeKeydownSubscription(),this.keydownSubscription=this.domService.onWindowKeydown$().pipe(Fe(e=>e?.target instanceof HTMLInputElement||e?.target instanceof HTMLTextAreaElement||e?.target instanceof HTMLSelectElement),Fe(e=>!!this.isElementInsideSingleEditorModeContainerElements(e?.target)),tt(1)).subscribe(e=>{this.unsubscribeKeydownSubscription(),this.getSingleEditorModeConfig()?.customMode||this.setUserAsEditor()},e=>{this.loggingService.catch("Error in LiveStateService detectKeydownOnInput subscription: ",e)})}catch(e){this.loggingService.catch("Error in LiveStateService detectKeydownOnInput: ",e)}}unsubscribeKeydownSubscription(){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribeKeydownSubscription","color: green;"),this.keydownSubscription&&(this.keydownSubscription.unsubscribe(),this.keydownSubscription=null)}catch(e){this.loggingService.catch("Error in LiveStateService unsubscribeKeydownSubscription: ",e)}}getDocumentPaths(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().subscribe(e=>{this.documentPaths=e,this.updateLiveStateDataFromDraft()})}catch(e){this.loggingService.catch("Error in LiveStateService getDocumentPaths: ",e)}}getUser(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().subscribe(e=>{this.user=e,this.updateLiveStateDataFromDraft()})}catch(e){this.loggingService.catch("Error in LiveStateService getUser: ",e)}}updateLiveStateDataFromDraft(){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateLiveStateDataFromDraft","color: green;"),this.liveStateDataMapDraft?.custom&&this.user&&this.documentPaths&&(Object.keys(this.liveStateDataMapDraft.custom).forEach(e=>{this.setLiveStateData(e,this.liveStateDataMapDraft.custom[e])}),this.liveStateDataMapDraft={})}catch(e){this.loggingService.catch("Error in LiveStateService updateLiveStateDataFromDraft: ",e)}}subscribeLiveStateData(){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),qn(this.afAuth).pipe(Fe(e=>!!e),he(e=>this.isFeatureAllowed({firebaseUser:e,liveStateData:{}})),he(e=>e.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(i=>(e.featureAllowed=i,e))):se(e)),he(e=>e.featureAllowed?this.authService.isPlanExpired$().pipe(ce(i=>(e.featureAllowed=!i,e))):se(e)),he(e=>e.featureAllowed?se(e).pipe(he(i=>this.docService.getDocumentPaths$().pipe(ce(r=>(this.documentPaths=r,i.documentPaths=r,i)))),gn(i=>{this.serverConnectionState$?.value===qs.PENDING_INIT&&i?.documentPaths?.liveState&&this.serverConnectionState$.next(qs.PENDING_DATA)}),he(i=>this.getDataFromDocumentId().pipe(ce(r=>(i.liveStateData=r,I({},i))))),he(i=>this.getSingleEditorMode$().pipe(ce(()=>i))),ce(i=>{if([qs.ONLINE,qs.OFFLINE].includes(this.serverConnectionState$?.value)||this.serverConnectionState$.next(qs.ONLINE),i.liveStateData)this.liveStateDataMap$.next(i.liveStateData);else{let r=this.liveStateDataMap$.value;r&&Object.keys(r).length>0&&this.liveStateDataMap$.next({})}this.getSingleEditorMode()&&this.updateSingleEditorLiveSyncData(i?.liveStateData?.default?.singleEditorMode||{})})):se({})))}updateSingleEditorLiveSyncData(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateSingleEditorLiveSyncData","color: green;"),uo(e,{})&&!this.keydownSubscription&&this.detectKeydownOnInput(),e&&!e?.editor&&this.isEditor$?.value!==void 0&&this.isEditor$.next(void 0),uo(this.singleEditorLiveStateData,e))return;if(this.singleEditorLiveStateData=e,this.singleEditorLiveStateData$.next(e),this.singleEditorLiveStateData?.editor){let i=this.authService.getUser();this.singleEditorLiveStateData?.editor?.userId!==i?.userId?this.makeReader():this.makeEditor()}else this.isEditor$?.value!==void 0&&this.isEditor$.next(void 0),this.enableInputElements(),this.enableElementEvents();this.editorAccessTimerInterval&&this.singleEditorLiveStateData?.requestEditorAccess?.status!=="pending"&&this.clearEditorAccessTimerInterval(),this.requestAccessTimer&&this.singleEditorLiveStateData?.requestEditorAccess?.status!=="pending"?this.clearRequestAccessTimer():this.singleEditorLiveStateData?.requestEditorAccess?.status==="pending"&&this.isUserEditor()?.isEditor&&this.isUserEditor()?.isEditorOnCurrentTab&&this.setRequestAccessTimer(this.singleEditorLiveStateData?.requestEditorAccess?.editorAccessTimeout||j.LIVE_STATE_REQUEST_EDITOR_ACCESS_WAIT_TIME)}catch{}}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.LIVE_STATE_SYNC)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Live state sync feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>(this.db=i,this.configService?.getApiKey()&&this.documentPaths?.liveState?this.commonDbService.dbListener({feature:"allLiveStates",properties:{documentId:e??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ce(r=>r?.data),jn(r=>(this.loggingService.catch("Error in LiveStateService getDataFromDocumentId: ",r),se({})))):se({}))))}getLiveStateData$(e,i){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getLiveStateData$","color: green;"),qn(this.afAuth).pipe(Fe(r=>!!r),he(r=>this.isFeatureAllowed({firebaseUser:r,liveStateData:{}})),he(r=>r.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(a=>(r.featureAllowed=a,r))):se(r)),he(r=>r.featureAllowed?this.authService.isPlanExpired$().pipe(ce(a=>(r.featureAllowed=!a,r))):se(r)),he(r=>r.featureAllowed?se(r).pipe(he(a=>this.docService.getDocumentPaths$().pipe(ce(s=>(this.documentPaths=s,a.documentPaths=s,a)))),he(a=>{let s=i?.listenToNewChangesOnly?1:0;return this.getLiveStateDataFromDatabase$(e).pipe(Ps(s))}),ce(a=>{if(a)if(e){let s=Pt(e+""),m=a?.[s];if(m){let p=m?.data;if(m?.tabId&&this.tabId&&m?.tabId===this.tabId)return;if(m?.isDataStringified&&typeof p=="string")try{p=JSON.parse(p)}catch{}return p}else return}else{let s={};return Object.keys(a||{}).forEach(m=>{if(a[m]?.liveStateDataId){let p=a[m],h=p?.data;if(p?.isDataStringified&&typeof h=="string")try{h=JSON.parse(h)}catch{}s[p.liveStateDataId]=h}}),s}return a})):se(void 0).pipe(Fe(Boolean))),qt((r,a)=>JSON.stringify(r||{})===JSON.stringify(a||{})),Fe(r=>r!==void 0),ce(r=>r))}catch(r){return this.loggingService.catch("Error in LiveStateService getLiveStateData$: ",r),se(null)}}getLiveStateDataFromDatabase$(e){try{return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>{this.db=i;let r=e?Pt(e+""):void 0;return this.configService?.getApiKey()&&this.documentPaths?.liveState?this.commonDbService.dbListener({feature:r?"liveStateCustom":"allLiveStateCustoms",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:r,skipFirestore:!0}}).pipe(ce(a=>a?.data),ce(a=>{if(a)return r?{[r]:a}:a}),jn(a=>(this.loggingService.catch("Error in LiveStateService getLiveStateDataFromDatabase$: ",a),se(null)))):se(void 0)}))}catch(i){return this.loggingService.catch("Error in LiveStateService getLiveStateDataFromDatabase$: ",i),se(void 0)}}setLiveStateData(e,i,r){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setLiveStateData","color: green;");try{let a=this.authService.getUser();if(e&&this.documentPaths?.liveState&&a){let s=Pt(e+""),m=!1;try{if(r?.merge&&typeof i=="object"){let h=yield this.commonDbService.getData({feature:"liveStateCustom",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:s,skipFirestore:!0}});if(h?.isDataStringified){let _=JSON.parse(h?.data);typeof i=="object"&&(i=I(I({},_),i))}}}catch{}try{typeof i=="object"&&(i=JSON.stringify(i),m=!0)}catch{}let p={id:s,lastUpdated:this.timestamp,liveStateDataId:e,data:i,updatedBy:a,tabId:this.tabId,isDataStringified:m};yield this.commonDbService.setData({feature:"liveStateCustom",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:s,skipFirestore:!0},data:JSON.parse(JSON.stringify(p))})}else this.loggingService.warn("liveStateDataId or documentPaths or user is null"),this.liveStateDataMapDraft?.custom||(this.liveStateDataMapDraft.custom={}),e&&(this.liveStateDataMapDraft.custom[e]=i)}catch(a){this.loggingService.catch("Error in LiveStateService _setLiveStateData: ",a)}})}getFormElements(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getInputElements","color: green;"),document.querySelectorAll("input, textarea, select, button, [contenteditable]")}catch(e){return this.loggingService.catch("Error in LiveStateService getInputElements: ",e),null}}disableInputElements(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableInputElements","color: green;"),this.getFormElements()?.forEach(i=>{if(this.isElementInsideSingleEditorModeContainerElements(i)&&!this.isSingleEditorModeDisabledForElement(i)&&!zi(i)){let r=i?.hasAttribute("disabled");i?.hasAttribute("contenteditable")&&(r=i?.getAttribute("contenteditable")==="false"),r||(i.setAttribute("disabled","true"),i.setAttribute(j.ATTRIBUTES.VELT_SYNC_ACCESS_AUTO,"true"),i?.hasAttribute("contenteditable")&&i.setAttribute("contenteditable","false"))}})}catch(e){this.loggingService.catch("Error in LiveStateService disableInputElements: ",e)}}enableInputElements(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableInputElements","color: green;"),this.getFormElements()?.forEach(i=>{i?.hasAttribute(j.ATTRIBUTES.VELT_SYNC_ACCESS_AUTO)&&(i.removeAttribute("disabled"),i.removeAttribute(j.ATTRIBUTES.VELT_SYNC_ACCESS_AUTO),i?.getAttribute("contenteditable")&&i.setAttribute("contenteditable","true"))})}catch(e){this.loggingService.catch("Error in LiveStateService enableInputElements: ",e)}}disableElementEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: disableElementEvents","color: green;"),document.querySelectorAll(`[${j.ATTRIBUTES.VELT_SYNC_ACCESS}]`)?.forEach(i=>{let r=this.domService.getXPath(i);r&&!this.preventEventsOnElementMap[r]&&(this.preventEventsOnElementMap[r]={element:i,events:{}},this.PREVENT_EVENTS.forEach(a=>{let s=ri(i,a,{capture:!0}).subscribe(m=>{try{m.preventDefault(),m.stopPropagation()}catch(p){this.loggingService.catch("Error in LiveStateService disableElementEvents subscription: ",p)}});this.preventEventsOnElementMap[r]?.events[a]?.unsubscribe(),this.preventEventsOnElementMap[r].events[a]=s}))})}catch(e){this.loggingService.catch("Error in LiveStateService disableElementClicks: ",e)}}enableElementEvents(){try{this.loggingService.log("%c[WB] Calling FUNCTION: enableElementEvents","color: green;"),Object.keys(this.preventEventsOnElementMap).forEach(e=>{let i=this.preventEventsOnElementMap[e];Object.keys(i.events||{}).forEach(r=>{i?.events[r]?.unsubscribe()})}),this.preventEventsOnElementMap={}}catch(e){this.loggingService.catch("Error in LiveStateService enableElementClicks: ",e)}}setUserAsEditor(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setUserAsEditor","color: green;"),this.user&&this.documentPaths?.liveStateSingleEditorMode){let e={editor:this.user,tabId:this.tabId,editorAt:this.timestamp};this.commonDbService.setData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(e))}),this.analyticsService.trackEvent(X.Events.LiveStateSync.SET_USER_AS_EDITOR_TRIGGERED,{editorUserId:this.user?.userSnippylyId,tabId:this.tabId})}}catch(e){this.loggingService.catch("Error in LiveStateService setUserAsEditor: ",e)}}setRequestAccessTimer(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRequestAccessTimer","color: green;"),this.requestAccessTimer||(this.requestAccessTimer=setTimeout(()=>{this.getEditorAccessTransferOnTimeOut()&&this.acceptEditorAccessRequest(),this.clearRequestAccessTimer()},e*1e3),this.setEditorAccessTimerInterval(e))}catch(i){this.loggingService.catch("Error in LiveStateService setRequestAccessTimer: ",i)}}clearRequestAccessTimer(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearRequestAccessTimer","color: green;"),this.requestAccessTimer&&(clearTimeout(this.requestAccessTimer),this.requestAccessTimer=null)}catch(e){this.loggingService.catch("Error in LiveStateService clearRequestAccessTimer: ",e)}}requestEditorAccess(){this.loggingService.log("%c[WB] Calling FUNCTION: requestEditorAccess","color: green;");try{return this.analyticsService.trackEvent(X.Events.LiveStateSync.REQUEST_EDITOR_ACCESS_TRIGGERED),new Lt(e=>{let i=null;try{if(this.user&&this.documentPaths?.liveStateSingleEditorMode){let r=this.getEditorAccessTimeout(),a=rn(this.db,`${this.documentPaths?.liveStateSingleEditorMode}`),s={requestEditorAccess:{user:this.user,requestedAt:this.timestamp,status:"pending",editorAccessTimeout:r,tabId:this.tabId}};this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},errorCallback:m=>{this.loggingService.catch("Error in LiveStateService requestEditorAccess: ",m),e.next(null),e.complete()},callback:()=>{r&&(this.requestAccessTimer=setTimeout(()=>{this.getEditorAccessTransferOnTimeOut()&&this.setUserAsEditor()},(r+3)*1e3),this.setEditorAccessTimerInterval(r+3)),i=this.getSingleEditorLiveStateData$().subscribe(m=>{m&&(m?.requestEditorAccess?m?.requestEditorAccess?.status==="cancelled"&&(e.next(null),e.complete()):m?.editor?.userId===this.user?.userId?(e.next(!0),e.complete()):(e.next(!1),e.complete()))})},data:JSON.parse(JSON.stringify(s))})}else e.next(!1),e.complete()}catch(r){this.loggingService.catch("Error in LiveStateService requestEditorAccess: ",r),e.next(null),e.complete()}return()=>{i&&i?.unsubscribe()}})}catch(e){return this.loggingService.catch("Error in LiveStateService requestEditorAccess: ",e),se(null)}}makeEditor(){try{this.loggingService.log("%c[WB] Calling FUNCTION: makeEditor","color: green;");let e=this.singleEditorLiveStateData?.tabId===this.tabId;this.isEditor$.next({isEditor:!0,isEditorOnCurrentTab:e}),this.getSingleEditorModeConfig()?.customMode||(!this.getSingleEditorModeConfig()?.singleTabEditor||e?(this.enableInputElements(),this.enableElementEvents()):(this.disableInputElements(),this.disableElementEvents()))}catch(e){this.loggingService.catch("Error in LiveStateService makeEditor: ",e)}}makeReader(){try{this.loggingService.log("%c[WB] Calling FUNCTION: makeReader","color: green;"),this.isEditor$.next({isEditor:!1,isEditorOnCurrentTab:!1}),this.getSingleEditorModeConfig()?.customMode||(this.disableInputElements(),this.disableElementEvents())}catch(e){this.loggingService.catch("Error in makeReader: ",e)}}acceptEditorAccessRequest(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: acceptEditorAccessRequest","color: green;"),this.user&&this.singleEditorLiveStateData?.requestEditorAccess&&this.isUserEditor()?.isEditor&&this.documentPaths?.liveStateSingleEditorMode){let e=this.singleEditorLiveStateData?.requestEditorAccess?.user,i=this.singleEditorLiveStateData?.requestEditorAccess?.tabId;if(e&&i){let r={editor:e,requestEditorAccess:null,tabId:i,editorAt:this.timestamp};this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}),this.analyticsService.trackEvent(X.Events.LiveStateSync.ACCEPT_EDITOR_ACCESS_REQUEST_TRIGGERED,{editorUserId:e?.userSnippylyId,tabId:i})}}}catch(e){this.loggingService.catch("Error in acceptEditorAccessRequest: ",e)}})}rejectEditorAccessRequest(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: rejectEditorAccessRequest","color: green;"),this.user&&this.singleEditorLiveStateData?.requestEditorAccess&&this.isUserEditor()?.isEditor&&this.documentPaths?.liveStateSingleEditorMode){let e={requestEditorAccess:null};this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(e))}),this.analyticsService.trackEvent(X.Events.LiveStateSync.REJECT_EDITOR_ACCESS_REQUEST_TRIGGERED)}}catch(e){this.loggingService.catch("Error in LiveStateService rejectEditorAccessRequest: ",e)}})}cancelEditorAccessRequest(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: cancelEditorAccessRequest","color: green;"),this.user&&this.singleEditorLiveStateData?.requestEditorAccess&&this.documentPaths?.liveStateSingleEditorMode){let e={requestEditorAccess:T(I({},this.singleEditorLiveStateData?.requestEditorAccess),{status:"cancelled"})};this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(e))}),e={requestEditorAccess:null},this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(e))}),this.analyticsService.trackEvent(X.Events.LiveStateSync.CANCEL_EDITOR_ACCESS_REQUEST_TRIGGERED)}}catch(e){this.loggingService.catch("Error in LiveStateService cancelEditorAccessRequest: ",e)}})}editCurrentTab(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: editCurrentTab","color: green;"),this.user&&this.isUserEditor()?.isEditor&&!this.isUserEditor()?.isEditorOnCurrentTab&&this.documentPaths?.liveStateSingleEditorMode){let e={tabId:this.tabId};this.commonDbService.updateData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(e))}),this.analyticsService.trackEvent(X.Events.LiveStateSync.EDIT_CURRENT_TAB_TRIGGERED,{tabId:this.tabId})}}catch(e){this.loggingService.catch("Error in LiveStateService editCurrentTab: ",e)}})}isUserEditor$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: isUserEditor$","color: green;"),this.isEditor$.asObservable()}catch(e){return this.loggingService.catch("Error in LiveStateService isUserEditor$: ",e),se(null)}}isUserEditor(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: isUserEditor","color: green;"),this.isEditor$.value}catch(e){return this.loggingService.catch("Error in LiveStateService isUserEditor: ",e),null}}getEditor$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getEditor$","color: green;"),this.getSingleEditorLiveStateData$().pipe(ce(e=>e?.editor||null),qt())}catch(e){return this.loggingService.catch("Error in LiveStateService getEditor$: ",e),se(null)}}isEditorAccessRequested$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: isEditorAccessRequested$","color: green;"),this.isUserEditor$().pipe(he(e=>e?.isEditor?this.singleEditorLiveStateData$.pipe(ce(i=>i?.requestEditorAccess?{requestStatus:"requested",requestedBy:i?.requestEditorAccess?.user}:null)):se(null)),qt((e,i)=>JSON.stringify(e||{})===JSON.stringify(i||{})))}catch(e){return this.loggingService.catch("Error in LiveStateService isEditorAccessRequested$: ",e),se(null)}}removeEditorAccess(){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeEditorAccess","color: green;"),(this.user||this.authService.getAuthUser())&&this.documentPaths?.liveStateSingleEditorMode&&(yield this.commonDbService.deleteData({feature:"liveStateSingleEditorMode",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}))}catch(e){this.loggingService.catch("Error in LiveStateService removeEditorAccess: ",e)}})}getSingleEditorLiveStateData$(){return this.singleEditorLiveStateData$.asObservable()}enableSingleEditorMode(e){try{if(this.singleEditorMode$.value===!0)return;this.singleEditorMode$.next(!0),e?this.singleEditorModeConfig$.next(e):this.singleEditorModeConfig$.next(new cM)}catch(i){this.loggingService.catch("Error in LiveStateService enableSingleEditorMode: ",i)}}disableSingleEditorMode(){try{if(this.singleEditorMode$.value===!1)return;this.singleEditorMode$.next(!1)}catch(e){this.loggingService.catch("Error in LiveStateService disableSingleEditorMode: ",e)}}getSingleEditorMode$(){return this.singleEditorMode$.asObservable()}getSingleEditorMode(){return this.singleEditorMode$.value}getSingleEditorModeConfig$(){return this.singleEditorModeConfig$.asObservable()}getSingleEditorModeConfig(){return this.singleEditorModeConfig$.value}enableAutoSyncState(){try{if(this.autoSyncState$.value===!0)return;this.autoSyncState$.next(!0)}catch(e){this.loggingService.catch("Error in LiveStateService enableAutoSyncState: ",e)}}disableAutoSyncState(){try{if(this.autoSyncState$.value===!1)return;this.autoSyncState$.next(!1)}catch(e){this.loggingService.catch("Error in LiveStateService disableAutoSyncState: ",e)}}getAutoSyncState$(){return this.autoSyncState$.asObservable()}getAutoSyncState(){return this.autoSyncState$.value}setEditorAccessTimeout(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setEditorAccessTimeout","color: green;"),e&&this.editorAccessTimeout$.next(e)}catch(i){this.loggingService.catch("Error in LiveStateService setEditorAccessTimeout: ",i)}}getEditorAccessTimeout$(){return this.editorAccessTimeout$.asObservable()}getEditorAccessTimeout(){return this.editorAccessTimeout$.value}enableEditorAccessTransferOnTimeOut(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableEditorAccessTransferOnTimeOut","color: green;"),this.editorAccessTransferOnTimeOut$.value===!0)return;this.editorAccessTransferOnTimeOut$.next(!0)}catch(e){this.loggingService.catch("Error in LiveStateService enableEditorAccessTransferOnTimeOut: ",e)}}disableEditorAccessTransferOnTimeOut(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableEditorAccessTransferOnTimeOut","color: green;"),this.editorAccessTransferOnTimeOut$.value===!1)return;this.editorAccessTransferOnTimeOut$.next(!1)}catch(e){this.loggingService.catch("Error in LiveStateService disableEditorAccessTransferOnTimeOut: ",e)}}getEditorAccessTransferOnTimeOut$(){return this.editorAccessTransferOnTimeOut$.asObservable()}getEditorAccessTransferOnTimeOut(){return this.editorAccessTransferOnTimeOut$.value}enableDefaultSingleEditorUI(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableDefaultSingleEditorUI","color: green;"),this.defaultSingleEditorUIEnabled$.value===!0)return;this.defaultSingleEditorUIEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in LiveStateService enableDefaultSingleEditorUI: ",e)}}disableDefaultSingleEditorUI(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableDefaultSingleEditorUI","color: green;"),this.defaultSingleEditorUIEnabled$.value===!1)return;this.defaultSingleEditorUIEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in LiveStateService disableDefaultSingleEditorUI: ",e)}}getDefaultSingleEditorUIEnabled$(){return this.defaultSingleEditorUIEnabled$.asObservable()}getDefaultSingleEditorUIEnabled(){return this.defaultSingleEditorUIEnabled$.value}setEditorAccessTimerInterval(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setEditorAccessTimerInterval","color: green;"),this.clearEditorAccessTimerInterval(),e>0&&(this.editorAccessTimer$.next({state:"inProgress",durationLeft:e}),this.editorAccessTimerInterval=setInterval(()=>{try{e-=1,e<0?this.clearEditorAccessTimerInterval():e?this.editorAccessTimer$.next({state:"inProgress",durationLeft:e}):this.editorAccessTimer$.next({state:"completed"})}catch(i){this.loggingService.catch("Error in LiveStateService setEditorAccessTimerCountdown interval: ",i),this.clearEditorAccessTimerInterval()}},1e3))}catch(i){this.loggingService.catch("Error in LiveStateService setEditorAccessTimerCountdown: ",i),this.clearEditorAccessTimerInterval()}}clearEditorAccessTimerInterval(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearEditorAccessTimerInterval","color: green;"),this.editorAccessTimerInterval&&(clearInterval(this.editorAccessTimerInterval),this.editorAccessTimerInterval=null,this.editorAccessTimer$.next({state:"idle"}))}catch(e){this.loggingService.catch("Error in LiveStateService clearEditorAccessTimerInterval: ",e)}}getEditorAccessTimer$(){return this.editorAccessTimer$.asObservable()}onServerConnectionStateChange$(){return this.serverConnectionState$.asObservable()}detectLiveSyncInputs(){try{document.querySelectorAll(`[${j.ATTRIBUTES.VELT_SYNC_STATE}]`)?.forEach(i=>{this.subscribeInputChanges(i)})}catch(e){this.loggingService.catch("Error in LiveStateService detectLiveSyncInputs: ",e)}}subscribeInputChanges(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: subscribeInputChanges","color: green;"),e){let i=e.tagName,r=this.domService.getXPath(e),a=Pt(r);if(this.inputChangeSubscriptionMap[a])this.loggingService.warn("subscription already exists",a,e);else{this.inputChangeSubscriptionMap[a]={id:a,element:e};let s;switch(i?.toLowerCase()){case"input":s=ri(e,"input").pipe(rr(300)).subscribe(p=>{let h={value:p?.target?.value,tagName:p?.target?.tagName,type:p?.target?.type};this.setLiveStateSyncInputData(p?.target,h)});break;case"textarea":s=ri(e,"input").pipe(rr(300)).subscribe(p=>{let h={value:p?.target?.value,tagName:p?.target?.tagName};this.setLiveStateSyncInputData(p?.target,h)});break;default:e.getAttribute("contenteditable")&&(s=ri(e,"input").pipe(rr(300)).subscribe(p=>{let h={innerText:p?.target?.innerText,innerHTML:this.domService.sanitizeHtml(p?.target?.innerHTML),tagName:p?.target?.tagName,isContentEditable:!0};this.setLiveStateSyncInputData(p?.target,h)}));break}s&&(this.inputChangeSubscriptionMap[a]?.subscriptions||(this.inputChangeSubscriptionMap[a]={subscriptions:[]}),this.inputChangeSubscriptionMap[a].subscriptions?.push(s))}}}catch(i){this.loggingService.catch("Error in LiveStateService subscribeInputChanges: ",i)}}unsubscribeInputChanges(){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribeInputChanges","color: green;"),Object.keys(this.inputChangeSubscriptionMap).forEach(e=>{this.inputChangeSubscriptionMap[e]?.subscriptions?.forEach(r=>{r.unsubscribe()})}),this.inputChangeSubscriptionMap={}}catch(e){this.loggingService.catch("Error in LiveStateService unsubscribeInputChanges: ",e)}}setLiveStateSyncInputData(e,i){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setLiveStateSyncInputData","color: green;"),this.user&&this.documentPaths?.liveState){let r=this.domService.getXPath(e),a=Pt(r),s={id:a,lastUpdated:this.timestamp,liveStateDataId:r,data:i,updatedBy:this.user,tabId:this.tabId};this.commonDbService.updateData({feature:"liveStateAutoSyncStateCurrent",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:JSON.parse(JSON.stringify(s))}),this.commonDbService.updateData({feature:"liveStateAutoSyncStateHistoryId",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:a,skipFirestore:!0},data:JSON.parse(JSON.stringify(s))})}}catch(r){this.loggingService.catch("Error in LiveStateService setLiveStateSyncInputData: ",r)}}updateLiveStateSyncInputDataLocally(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateLiveStateSyncInputDataLocally","color: green;"),this.user&&Object.keys(e).forEach(i=>{let r=e[i],a=this.domService.getElementFromXPath(r?.liveStateDataId),s=!1;if(r?.updatedBy?.userSnippylyId!==this.user?.userSnippylyId)s=!0;else{let m=r?.tabId&&this.tabId&&r?.tabId!==this.tabId,p=a?.contains(document.activeElement);m&&!mre()&&!p&&(s=!0)}if(s&&a)switch(a.value=r?.data?.value,a.tagName?.toLowerCase()){case"input":a.value=r?.data?.value;break;case"textarea":a.value=r?.data?.value;break;default:a.getAttribute("contenteditable")&&(a.innerHTML=this.domService.sanitizeHtml(r?.data?.innerHTML))}})}catch(i){this.loggingService.catch("Error in LiveStateService updateLiveStateSyncInputDataLocally: ",i)}}setSingleEditorModeContainerIds(e){this.singleEditorModeContainerIds$.next(e||[])}getSingleEditorModeContainerIds(){return this.singleEditorModeContainerIds$.asObservable()}isElementInsideSingleEditorModeContainerElements(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: isElementInsideSingleEditorModeContainerElements","color: green;");let i=this.singleEditorModeContainerIds$.value,r=document.querySelectorAll(`[${j.ATTRIBUTES.VELT_SINGLE_EDITOR_MODE_CONTAINER}]`);if(!i?.length&&!r?.length)return!0;if(i?.length)for(let a=0;a<i.length;a++){let s=document.getElementById(i[a]);if(s&&s.contains(e))return!0}if(r?.length)for(let a=0;a<r.length;a++){let s=r[a];if(s&&s.contains(e))return!0}return!1}catch(i){return this.loggingService.catch("Error in LiveStateService isElementInsideSingleEditorModeContainerElements: ",i),!1}}isSingleEditorModeDisabledForElement(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: isSingleEditorModeDisabledForElement","color: green;"),e){if(e.getAttribute(j.ATTRIBUTES.VELT_SYNC_ACCESS_DISABLED))return!0;{let r=e?.parentElement;if(r)return this.isSingleEditorModeDisabledForElement(r)}}return!1}catch(i){return this.loggingService.catch("Error in LiveStateService isSingleEditorModeDisabledForElement: ",i),!1}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),this.isUserEditor$().pipe(gn(e=>{try{if(this.documentPaths?.liveStateSingleEditorMode){let i=rn(this.db,`${this.documentPaths?.liveStateSingleEditorMode}`);e?.isEditor&&(!this.getSingleEditorModeConfig()?.singleTabEditor||e?.isEditorOnCurrentTab)?Sl(i).remove():Sl(i).cancel()}}catch(i){this.loggingService.catch("Error in LiveStateService updateOnDatabaseDisconnect tap: ",i)}}))}updateServerStateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateServerStateOnDatabaseDisconnect","color: green;"),qn(this.afAuth).pipe(Fe(e=>!!e),he(e=>this.docService.getDocumentPaths$().pipe(ce(i=>e))),gn(e=>Q(this,null,function*(){try{if(this.docService.getDocumentPaths()?.liveState&&e){let r=rn(this.db,".info/connected"),a=!0;Eu(r,s=>{let m=s.val();if(a&&m===!1){a=!1;return}a=!1,m===!1?this.serverConnectionState$.next(qs.OFFLINE):this.serverConnectionState$.value===qs.OFFLINE&&this.serverConnectionState$.next(qs.ONLINE)})}}catch(i){this.loggingService.catch("Error in updateServerStateOnDatabaseDisconnect:",i)}})))}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(Ze),J(He),J(jt),J(hn),J(lt),J(Ne),J(fn),J(y),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var Ml=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L,H){this.analyticsService=e,this.docService=i,this.domService=r,this.authService=a,this.afAuth=s,this.iamService=m,this.databaseService=p,this.configService=h,this.avatarService=_,this.loggingService=E,this.flockService=D,this.liveStateService=L,this.commonDbService=H,this.db=Ii(),this.presenceUser$=new Ce(new dM),this.documentPaths=null,this.inactivityTime=5*60*1e3,this.offlineInactivityTime=10*60*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(Fe(K=>!!K),tt(1)).subscribe(K=>{K&&(this.db=K,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},oe=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",oe)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},oe=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",oe)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange())},K=>{this.loggingService.catch("Error in PresenceService constructor: ",K)}),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(Pi()).subscribe(([K,oe])=>{try{sessionStorage.getItem(j.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_DETECTED)||oe?.length>1&&K.length!==oe.length&&(this.analyticsService.trackEvent(X.Events.Presence.PRESENCE_MULTIPLE_USERS_DETECTED,{totalUsers:oe.length,presenceSnippylyUserIds:oe.map(be=>be.userSnippylyId),presenceClientUserIds:oe.map(be=>be.userId)}),sessionStorage.setItem(j.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_DETECTED,"true"));let ue=this.authService.getUser();ue&&!K?.some(be=>be.userId===ue.userId)&&oe?.some(be=>be.userId===ue.userId)&&this.presenceActionsService?.onMultipleUsersOnline({users:oe})}catch(ue){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",ue)}}),this.authService.getUser$().pipe(Fe(K=>!!K),tt(1)).subscribe(K=>{K?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(K=>{try{K?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(K)),state:K?.onlineStatus})}catch(oe){this.loggingService.catch("Error in presenceUser$ subscription: ",oe)}},K=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",K)}),this.domService.onNetworkStatusChange$().subscribe(K=>{try{!K&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:T(I({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:j.PRESENCE_STATUS_OFFLINE}),state:j.PRESENCE_STATUS_OFFLINE})}catch(oe){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",oe)}},K=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",K)})}catch(K){this.loggingService.catch("Error in PresenceService constructor: ",K)}}setPresenceActionsService(e){try{this.presenceActionsService=e}catch(i){this.loggingService.catch("Error in setPresenceActionsService: ",i)}}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(Nh(2e3),gn(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(j.PRESENCE_STATUS_ONLINE),e=!1)}),rr(this.inactivityTime),gn(()=>{this.setCurrentPresenceUserStatus(j.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(Nh(2e3),rr(this.offlineInactivityTime),gn(()=>{this.setCurrentPresenceUserStatus(j.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(Fe(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(gn(e=>{this.documentPaths=e}),Pi(),gn(([e,i])=>{e&&this.updateUserStatusOnDocumentChange(j.PRESENCE_STATUS_OFFLINE,e),i&&this.updateUserStatusOnDocumentChange(j.PRESENCE_STATUS_ONLINE,i)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(gn(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()}getOnlineUsersOnCurrentDocument(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),qn(this.afAuth).pipe(Fe(i=>!!i),he(i=>this.isFeatureAllowed({firebaseUser:i,users:[],filteredUsers:[]})),he(i=>i.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(r=>(i.featureAllowed=r,i))):se(i)),he(i=>i.featureAllowed?this.authService.isPlanExpired$().pipe(ce(r=>(i.featureAllowed=!r,i))):se(i)),he(i=>i.featureAllowed?se(i).pipe(he(r=>this.docService.getDocumentPaths$().pipe(ce(a=>(this.documentPaths=a,r.documentPaths=a,r)))),he(r=>this.getDataFromDocumentId(e).pipe(ce(a=>(r.users=a||[],I({},r))))),ce(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)),he(r=>this.getIncludeSelf$().pipe(ce(a=>(a||(r.filteredUsers=r?.filteredUsers?.filter(s=>s?.userSnippylyId!==r.user?.userSnippylyId)),r)))),he(r=>r?.filteredUsers?se(r?.filteredUsers||[]):se([]))):se([])),qt(Vi))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.PRESENCE)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>(this.db=i,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.presence?this.commonDbService.dbListener({feature:"allPresence",properties:{documentId:e?.documentId??this.documentPaths?.documentId,organizationId:e?.organizationId??this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(jn(r=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",r),se(null))),ce(r=>r?.data),ce(r=>{let a=[];return r&&(a=Object.values(r).filter(s=>typeof s=="object")),a})):se([]))))}filterOnlineUsers(e,i){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(s=>{let m=Mp(s.timestamp);return s.userSnippylyId&&(s.onlineStatus===j.PRESENCE_STATUS_ONLINE||s.onlineStatus===j.PRESENCE_STATUS_AWAY)&&m<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 i=this.presenceUsers$.value.find(r=>r.userId===e);if(i)return i}return null}catch(i){return this.loggingService.catch("Error in getNameFromSnippylyId:",i),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(ke.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new Ji,e?.onlineStatus===j.PRESENCE_STATUS_ONLINE&&(e.isTabAway=!1,e.isUserIdle=!1);let i=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(T(I({},i),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(i){this.loggingService.catch("Error in updateCurrentPresenceUser:",i)}})}setCurrentPresenceUserStatus(e,i){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(Fe(m=>!!m?.length),tt(1)).subscribe(m=>{m?.length>1&&this.analyticsService.trackEvent(X.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:s,totalUsers:m?.length,presenceSnippylyUserIds:m?.map(p=>p.userSnippylyId),presenceClientUserIds:m?.map(p=>p.userId)})})}r.onlineStatus=e,i&&(r.isTabAway=i?.isTabAway,r.isUserIdle=i?.isUserIdle),e===j.PRESENCE_STATUS_ONLINE&&(r.isTabAway=!1,r.isUserIdle=!1),e===j.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),e===j.PRESENCE_STATUS_OFFLINE&&this.liveStateService.isUserEditor()?.isEditor&&(!this.liveStateService.getSingleEditorModeConfig()?.singleTabEditor||this.liveStateService.isUserEditor()?.isEditorOnCurrentTab)&&this.liveStateService.removeEditorAccess(),this.updateCurrentPresenceUser(r)}catch(r){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",r)}})}updateUserStatusOnDocumentChange(e,i){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,i?.presence&&r&&r.userId&&!r.isAnonymous&&this.authService.isFeatureAllowed(ke.PRESENCE)){let a=JSON.parse(JSON.stringify(r));this.commonDbService.updateData({feature:"presence",properties:{documentId:i?.documentId,organizationId:i?.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 i=this.presenceUser$.value;if(i.location=e?e.location:null,i.locationId=e?e?.locationId:null,this.documentPaths?.presence&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(ke.PRESENCE)){let r=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(r))})}}catch(i){this.loggingService.catch("Error in updateUserOnLocationChange:",i)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=rn(this.db,".info/connected"),i=$f(e).pipe(ce(r=>r?j.PRESENCE_STATUS_ONLINE:j.PRESENCE_STATUS_OFFLINE));return qn(this.afAuth).pipe(Ps(1),he(r=>r?i:se(j.PRESENCE_STATUS_OFFLINE)),gn(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(j.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(j.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(j.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(j.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 i=this.presenceUser$.value,r=!1;if(e.featureAllowList.includes(ke.PRESENCE)?i?.onlineStatus!==j.PRESENCE_STATUS_ONLINE&&(i.onlineStatus=j.PRESENCE_STATUS_ONLINE,r=!0):i?.onlineStatus!==j.PRESENCE_STATUS_OFFLINE&&(i.onlineStatus=j.PRESENCE_STATUS_OFFLINE,r=!0),r&&this.authService.getUser()&&this.documentPaths?.presence&&i&&i.userId&&!i.isAnonymous){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:i.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;"),qn(this.afAuth).pipe(Fe(e=>!!e),he(e=>this.docService.getDocumentPaths$().pipe(ce(i=>e))),gn(e=>Q(this,null,function*(){try{if(this.documentPaths?.presence&&e){let i=yield Sd(e,!0).catch(a=>null);if(!i)return;let{user:r}=i.claims;if(!r?.isAnonymous){let a=rn(this.db,`${this.documentPaths.presence}/${e.uid}`);this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.liveStateService.isUserEditor()?.isEditor&&(!this.liveStateService.getSingleEditorModeConfig()?.singleTabEditor||this.liveStateService.isUserEditor()?.isEditorOnCurrentTab)&&this.liveStateService.removeEditorAccess(),Sl(a).update({onlineStatus:j.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp}).catch(s=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",s)})}}}catch(i){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",i)}})))}setPresenceUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPresenceUser","color: green;");try{let i=this.presenceUser$.value;i.userId=e?.userId,i.name=e?.name,i.email=e?.email,i.photoUrl=e?.photoUrl,i.userSnippylyId=e?.userSnippylyId,i.color=e?.color,i.textColor=e?.textColor,i.initial=e?.initial,i.timestamp=this.timestamp,i.type=e?.type,i.isReadOnly=e?.isReadOnly,i.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,m=s?s[0]:null;a&&(i.name=`${a} ${m?m+".":""}`)}this.updateCurrentPresenceUser(i)}catch(i){this.loggingService.catch("Error in setPresenceUser:",i)}}signOutUser(e){return new Promise((i,r)=>{try{this.documentPaths?.presence&&e?this.commonDbService.dbListener({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).pipe(tt(1)).subscribe(a=>{a?.data?(this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.liveStateService.isUserEditor()?.isEditor&&(!this.liveStateService.getSingleEditorModeConfig()?.singleTabEditor||this.liveStateService.isUserEditor()?.isEditorOnCurrentTab)&&this.liveStateService.removeEditorAccess(),this.commonDbService.updateData({feature:"presence",errorCallback:s=>{r(s)},callback:()=>{i(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(T(I({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:j.PRESENCE_STATUS_OFFLINE})))})):i(null)},a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),r(a)}):i(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),r(a)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(X.Events.Presence.PRESENCE_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(i){this.loggingService.catch("Error in setInactivityTime: ",i)}}getInactivityTime(){return this.inactivityTime}setOfflineInactivityTime(e){try{e>=this.inactivityTime?(this.offlineInactivityTime=e,this.analyticsService.trackEvent(X.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(i){this.loggingService.catch("Error in setOfflineInactivityTime: ",i)}}getOfflineInactivityTime(){return this.offlineInactivityTime}getPresenceUsers$(){return this.presenceUsers$.asObservable()}getPresenceUsers(){return this.presenceUsers$.value}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(lt),J(Ne),J(He),J(bi),J(fn),J(hn),J(jt),J(Dm),J(y),J(Ac),J(xi),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var a0=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D){this.analyticsService=e,this.configService=i,this.presenceService=r,this.docService=a,this.afAuth=s,this.iamService=m,this.domService=p,this.databaseService=h,this.authService=_,this.loggingService=E,this.commonDbService=D,this.db=jf(),this.cursorUser$=new Ce(new Kv),this.documentPaths=null,this.inactivityTime=2*60*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(Fe(L=>!!L),he(L=>this.cursorTagAvailable$.pipe(Fe(H=>!!H),tt(1),ce(()=>L))),tt(1)).subscribe(L=>{L&&(this.db=L,this.cursorTagAvailable&&(this.getPresenceUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnDatabaseDisconnect().subscribe(()=>{},H=>{this.loggingService.catch("Error in CursorService constructor updateOnDatabaseDisconnect: ",H)}),this.addMouseMoveListener(),this.addScreenSizeChangeListener(),this.updateOnAllowedFeatureListChange()))},L=>{this.loggingService.catch("Error in CursorService constructor getDb: ",L)}),this.cursorUsers$.pipe(Pi()).subscribe(([L,H])=>{sessionStorage.getItem(j.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED)||H?.length>1&&L.length!==H.length&&(this.analyticsService.trackEvent(X.Events.Cursor.CURSOR_MULTIPLE_USERS_DETECTED,{totalUsers:H.length,cursorSnippylyUserIds:H.map(K=>K.userSnippylyId),cursorClientUserIds:H.map(K=>K.userId)}),sessionStorage.setItem(j.SESSION_STORAGE.VELT_CURSOR_MULTIPLE_USERS_DETECTED,"true"))}),this.authService.addPreSignOutFuction("cursor-signout",this.signOutUser.bind(this))}catch(L){this.loggingService.catch("Error in CursorService constructor: ",L)}}checkCursorTagAvailable(){this.loggingService.log("%c[WB] Calling FUNCTION: checkCursorTagAvailable","color: green;");try{this.cursorTagAvailable=!!document.querySelector(j.TAGS.VELT_CURSOR)||!!document.querySelector(j.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(Fe(e=>!!e),he(e=>this.domService.getCurrentWindowSize$("CursorService addScreenSizeChangeListener").pipe(Fe(i=>!!i)))).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(Nh(50)).subscribe(e=>{e&&this.setCurrentCursorUserPosition(e.pageX,e.pageY,this.domService.getTargetElementForCursorPosition(e,!0,!1,!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(gn(e=>{this.documentPaths=e}),Pi(),gn(([e,i])=>{e&&this.updateUserStatusOnDocumentChange(j.PRESENCE_STATUS_OFFLINE,e),i&&this.updateUserStatusOnDocumentChange(j.PRESENCE_STATUS_ONLINE,i)})).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(gn(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(Fe(e=>!!e),jn(e=>se(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;"),qn(this.afAuth).pipe(Fe(e=>!!e),he(e=>this.isFeatureAllowed({firebaseUser:e,users:[],filteredUsers:[]})),he(e=>e.featureAllowed?this.iamService.isUserAllowed$().pipe(ce(i=>(e.featureAllowed=i,e))):se(e)),he(e=>e.featureAllowed?this.authService.isPlanExpired$().pipe(ce(i=>(e.featureAllowed=!i,e))):se(e)),he(e=>!e.featureAllowed||e?.user?.isAnonymous?se([]):se(e).pipe(he(i=>this.docService.getDocumentPaths$().pipe(ce(r=>(this.documentPaths=r,i.documentPaths=r,i)))),he(i=>this.getDataFromDocumentId().pipe(ce(r=>(i.users=r||[],I({},i))))),ce(i=>(i.filteredUsers=this.filterOnlineUsers(i.users,i.firebaseUser),i)),he(i=>i?.filteredUsers?.length?this.domService.getCurrentWindowSize$("CursorService getLiveCursorsOnCurrentDocument").pipe(ce(()=>i)):se(i)),ce(i=>(i?.filteredUsers?.forEach(r=>{this.calculateCursorUserPosition(r)}),i)),he(i=>i?.filteredUsers?se(i?.filteredUsers||[]):se([])))))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})),he(i=>this.authService.getUser$().pipe(ce(r=>T(I({},i),{user:r})))),he(i=>eo(i.config,i.user,ke.CURSOR)?se(T(I({},i),{featureAllowed:!0})):(this.loggingService.warn("Cursor feature is not allowed."),se(T(I({},i),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Fe(i=>!!i),he(i=>(this.db=i,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.cursor?this.commonDbService.dbListener({feature:"allCursors",properties:{documentId:e??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(jn(r=>(this.loggingService.catch("Error in CursorService getDataFromDocumentId: ",r),se(null))),ce(r=>r?.data),ce(r=>{let a=[];return r&&(a=Object.values(r).filter(s=>typeof s=="object")),a})):se([]))))}calculateCursorUserPosition(e){try{if(e?.targetElement){let i=this.domService.getXPath(e.targetElement?.xpath);if(i){let r=i.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(i){this.loggingService.catch("Error in calculateCursorUserPosition:",i)}}filterOnlineUsers(e,i){try{let a=e.slice().filter(m=>{let p=Mp(m.timestamp);return m.userSnippylyId&&m.onlineStatus===j.PRESENCE_STATUS_ONLINE&&p<this.inactivityTime});this.cursorUsers$.next(a),a=a.filter(m=>m?.userSnippylyId!==i?.uid);let s=this.docService.getLocation();return s&&s.locationId?a=a.filter(m=>m.locationId===s.locationId):a=a.filter(m=>!m.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 i=this.cursorUser$.value;i.userId=e?.userId,i.name=e?.name,i.email=e?.email,i.photoUrl=e?.photoUrl,i.comment="",this.authService.isFeatureAllowed(ke.PRESENCE)&&(i.onlineStatus=e?.onlineStatus),i.userSnippylyId=e?.userSnippylyId,i.color=e?.color,i.textColor=e?.textColor,i.initial=e?.initial,i.timestamp=this.timestamp,i.type=e?.type,i.isReadOnly=e?.isReadOnly,i.isAnonymous=e?.isAnonymous;let r=this.domService.getCurrentWindowSizeValue();i.screenWidth=r?.screenWidth,i.screenHeight=r?.screenHeight,i.screenScrollHeight=r?.screenScrollHeight,this.updateCurrentCursorUser(i)}catch(i){this.loggingService.catch("Error in setCursorUser:",i)}}setCurrentCursorUserPosition(e,i,r){try{let a=this.cursorUser$.value;a?.onlineStatus===j.PRESENCE_STATUS_ONLINE&&(a.positionX=e,a.positionY=i,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 i=this.cursorUser$.value;i?.onlineStatus===j.PRESENCE_STATUS_ONLINE&&(i.screenWidth=e.screenWidth,i.screenHeight=e.screenHeight,i.screenScrollHeight=e.screenScrollHeight,this.updateCurrentCursorUser(i))}}catch(i){this.loggingService.catch("Error in setCurrentCursorUserScreenSize:",i)}}updateCurrentCursorUser(e){return Q(this,null,function*(){try{if(this.documentPaths&&e&&e.userId&&this.authService.isFeatureAllowed(ke.CURSOR)){if(!e.isAnonymous){e.pageInfo=new Ji;let i=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(T(I({},i),{timestamp:this.timestamp})))})}this.cursorUser$.next(e)}}catch(i){this.loggingService.catch("Error in updateCurrentCursorUser:",i)}})}updateUserStatusOnDocumentChange(e,i){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,i&&r&&r.userId&&!r.isAnonymous&&this.authService.isFeatureAllowed(ke.CURSOR)){let a=JSON.parse(JSON.stringify(r));this.commonDbService.updateData({feature:"cursor",properties:{documentId:i?.documentId??"",organizationId:i?.organizationId??"",id:r.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(T(I({},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 i=this.cursorUser$.value;if(i.location=e?e.location:null,i.locationId=e?e?.locationId:null,this.documentPaths&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(ke.CURSOR)){let r=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(T(I({},r),{timestamp:this.timestamp})))})}}catch(i){this.loggingService.catch("Error in updateUserOnLocationChange:",i)}})}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let i=this.cursorUser$.value,r=!1;if(e.featureAllowList.includes(ke.CURSOR)?i?.onlineStatus!==j.PRESENCE_STATUS_ONLINE&&(i.onlineStatus=j.PRESENCE_STATUS_ONLINE,r=!0):i?.onlineStatus!==j.PRESENCE_STATUS_OFFLINE&&(i.onlineStatus=j.PRESENCE_STATUS_OFFLINE,r=!0),r&&this.documentPaths&&i&&i.userId&&!i.isAnonymous){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(T(I({},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;"),qn(this.afAuth).pipe(Fe(e=>!!e),he(e=>this.docService.getDocumentPaths$().pipe(ce(i=>e))),gn(e=>Q(this,null,function*(){try{if(this.documentPaths&&e){let i=yield Sd(e,!0).catch(a=>null);if(!i)return;let{user:r}=i.claims;if(!r?.isAnonymous){let a=rn(this.db,`${this.documentPaths.cursor}/${e.uid}`);Sl(a).update({onlineStatus:j.PRESENCE_STATUS_OFFLINE,comment:"",timestamp:this.timestamp}).catch(s=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",s)})}}}catch(i){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",i)}})))}signOutUser(e){return new Promise((i,r)=>{try{this.documentPaths&&e?this.commonDbService.dbListener({feature:"cursor",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:e.uid,skipFirestore:!0}}).pipe(tt(1)).subscribe(a=>{a?.data?this.commonDbService.updateData({feature:"cursor",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:e.uid,skipFirestore:!0},callback:()=>{i(null)},data:JSON.parse(JSON.stringify(T(I({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:j.PRESENCE_STATUS_OFFLINE})))}):i(null)},a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),r(a)}):i(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),r(a)}})}setInactivityTime(e){this.inactivityTime=e,this.analyticsService.trackEvent(X.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(i){return this.loggingService.catch("Error in CursorService isElementInsideAllowedElements: ",i),!1}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(jt),J(Ml),J(lt),J(bi),J(fn),J(Ne),J(hn),J(He),J(y),J(Tn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var GM=class extends ci{constructor(o){super(o),this.getService(y).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(y).log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;");try{return this.trackEvent(X.Events.Cursor.GET_LIVE_CURSORS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(a0).getLiveCursorsOnCurrentDocument()}catch(o){return this.getService(y).catch("Error in _getOnlineUsersOnCurrentDocument: ",o),se(null)}}_setInactivityTime(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(X.Events.Cursor.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:o}}),isNaN(o)?this.getService(y).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(a0).setInactivityTime(o)}catch(t){this.getService(y).catch("Error in setInactivityTime: ",t)}}_allowedElementIds(o){this.getService(y).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(X.Events.Cursor.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:o}}),this.getService(a0).setAllowedElementIds(o)}catch(t){this.getService(y).catch("Error in allowedElementIds: ",t)}}};var WM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: DocElement","color: blue;"),this.getDocumentMetadata=this._getDocumentMetadata}_getDocumentMetadata(){this.getService(y).log("%c[WB] Calling FUNCTION: getDocumentMetadata","color: green;");try{return this.trackEvent(X.Events.Doc.GET_DOCUMENT_METADATA_TRIGGERED),this.getService(lt).getDocumentMetadata$()}catch(o){return this.getService(y).catch("Error in getDocumentMetadata: ",o),se(null)}}};var pr=(()=>{let o=class o{constructor(e,i,r,a,s,m,p,h,_,E,D,L,H){this.afAuth=e,this.analyticsService=i,this.authService=r,this.databaseService=a,this.docService=s,this.configService=m,this.domService=p,this.huddleUtilsService=h,this.functions=_,this.loggingService=E,this.notificationService=D,this.commonDbService=L,this.usersService=H,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.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=Ii(),this.dbRefsRemoveOnDropCall=[],this.servers={iceServers:[{urls:["stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302"]}]},this.databaseService.getDb().pipe(Fe(K=>!!K),tt(1)).subscribe(K=>{try{K&&(this.db=K,this.isHuddleTagInstalled()&&(sessionStorage.getItem("skipTwilioIceServers")||this.getTwilioIceServers()),this.getUser(),this.getDocumentPaths())}catch(oe){this.loggingService.catch("Error in HuddleService getDb:",oe)}},K=>{this.loggingService.catch("Error in HuddleService getDb subscription: ",K)}),this.docService.addPreDocumentIdChangeFunction("huddle-service",K=>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(K=>{K&&(this.localStream=K)}),this.screenSharingStream$.subscribe(K=>{K&&(this.screenSharingStream=K)}),this.configService.getConfig$().subscribe(K=>{try{!K?.featureAllowList?.find(ue=>ue===ke.CURSOR)&&this.huddleOnCursorMode$.next(!1)}catch(oe){this.loggingService.catch("Error in HuddleService configService.getConfig$:",oe)}},K=>{this.loggingService.catch("Error in HuddleService configService.getConfig$ subscription: ",K)}),this.attendees$.subscribe(K=>{try{if(K?.length){if(this.huddleOnCursorMode$?.value){let oe=this.huddleOnCursorModeByAttendeeId$.getValue()||{};K.forEach(ue=>{oe[ue.userSnippylyId]=!0}),this.huddleOnCursorModeByAttendeeId$.next(oe)}this.huddleJoined$?.value&&(K?.find(oe=>oe?.huddleOnCursorMode)?this.addCursorTag():this.removeCursorTag())}}catch(oe){this.loggingService.catch("Error in HuddleService attendees$:",oe)}},K=>{this.loggingService.catch("Error in HuddleService attendees$ subscription: ",K)}),Rn([this.huddleJoined$,this.huddleOnCursorMode$]).subscribe(([K,oe])=>{try{if(K){if(oe){let ue=this.attendees$.getValue()||[],be=this.huddleOnCursorModeByAttendeeId$.getValue()||{};ue.forEach(Le=>{be[Le.userSnippylyId]=!0}),document?.body?.setAttribute(j.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE,"true")}else this.huddleOnCursorModeByAttendeeId$.next({}),document?.body?.removeAttribute(j.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE);this.updateHuddleOnCursorMode()}else this.removeCursorTag(),document?.body?.removeAttribute(j.ATTRIBUTES.VELT_HUDDLE_ON_CURSOR_MODE)}catch(ue){this.loggingService.catch("Error in HuddleService huddleJoined$:",ue)}},K=>{this.loggingService.catch("Error in HuddleService huddleJoined$ subscription: ",K)}),this.huddleOnCursorModeByAttendeeId$.subscribe(K=>{try{this.huddleJoined&&(Object.keys(K).length?this.addCursorTag():this.removeCursorTag())}catch(oe){this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$:",oe)}},K=>{this.loggingService.catch("Error in HuddleService huddleOnCursorModeByAttendeeId$ subscription: ",K)}),this.authService.addPreSignOutFuction("huddle-signout",this.signOutUser.bind(this))}isHuddleTagInstalled(){try{return!!document?.querySelector(`${j.TAGS.VELT_HUDDLE}`)||!!document?.querySelector(`${j.TAGS.SNIPPYLY_HUDDLE}`)}catch(e){return this.loggingService.catch("Error in HuddleService isHuddleTagInstalled:",e),!1}}getTwilioIceServers(){return Q(this,null,function*(){try{let i=(yield yr(this.functions,br({url:Xn.cloudFunction.getIceServers,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5})())?.data;i&&i?.iceServers&&(this.servers.iceServers=i.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 qn(this.afAuth).pipe(Fe(e=>!!e),ce(e=>({firebaseUser:e})),he(e=>this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})))),he(e=>this.authService.getUser$().pipe(ce(i=>T(I({},e),{user:i})))),he(e=>eo(e.config,e.user,ke.HUDDLE)?se(T(I({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),se(T(I({},e),{allowed:!1})))),he(e=>this.docService.getDocumentPaths$().pipe(ce(i=>(this.documentPaths=i,e)))),he(e=>e?.allowed?e?.user?.isAnonymous?se(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleAttendees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ce(i=>i?.data),ce(i=>i?(this.attendees$.next(Object.values(i)),Object.values(i)):(this.attendees$.next([]),null))):se(null):se([])))}getInvitees(){try{return qn(this.afAuth).pipe(Fe(e=>!!e),ce(e=>({firebaseUser:e})),he(e=>this.configService.getConfig$().pipe(Fe(i=>!!i),ce(i=>T(I({},e),{config:i})))),he(e=>this.authService.getUser$().pipe(ce(i=>T(I({},e),{user:i})))),he(e=>eo(e.config,e.user,ke.HUDDLE)?se(T(I({},e),{allowed:!0})):(this.loggingService.warn("Huddle feature is not allowed."),se(T(I({},e),{allowed:!1})))),he(e=>this.docService.getDocumentPaths$().pipe(ce(i=>(this.documentPaths=i,e)))),he(e=>e?.allowed?e?.user?.isAnonymous?se(null):this.documentPaths?.huddle?this.commonDbService.dbListener({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(ce(i=>i?.data),ce(i=>i?(this.invitees$.next(Object.values(i)),Object.values(i)):(this.invitees$.next([]),null))):se(null):se([])))}catch(e){return this.loggingService.catch("Error in HuddleService getInvitees:",e),se([])}}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(Fe(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(gn(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=rn(this.db,this.documentPaths?.huddle),this.iceCandidates=rn(this.db,`${this.documentPaths?.huddle}/iceCandidates`),this.connections=rn(this.db,`${this.documentPaths?.huddle}/connections`),this.attendees=rn(this.db,`${this.documentPaths?.huddle}/attendees`),this.messages=rn(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(i){this.loggingService.catch("Error in HuddleService joinHuddle:",i)}})}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;"),Eu(this.connections,e=>{try{if(e.exists()){let i=e.val();Object.values(i).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*(){i[a]||(this.remoteStreamMap[a]&&Object.values(this.remoteStreamMap[a]).forEach(s=>{s.getTracks().forEach(m=>{m.stop()})}),delete this.remoteStreamMap[a],yield this.removeIceCandidates(a))})),this.remoteStreamMap$.next(this.remoteStreamMap)}else Object.keys(this.remoteStreamMap).forEach(i=>Q(this,null,function*(){Object.values(this.remoteStreamMap[i]).forEach(r=>{r.getTracks().forEach(a=>{a.stop()})}),yield this.removeIceCandidates(i)})),this.remoteStreamMap={},this.remoteStreamMap$.next(this.remoteStreamMap)}catch(i){this.loggingService.catch("Error in HuddleService setHuddleLister onValue:",i)}}),xB(this.iceCandidates).subscribe(e=>{try{e.event==="child_added"&&this.onIceCandidateSnapshot(e.snapshot)}catch(i){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",i)}}),xB(this.attendees).subscribe(e=>{try{if(e.event==="child_removed"){let i=e?.snapshot?.val();if(i){delete this.onOfferUidHistory[i?.userSnippylyId];let r=this.getCombinedId(this.user.userSnippylyId,i?.userSnippylyId);delete this.onAnswerConnectionIdHistory[r],this.closeConnection(r)}}}catch(i){this.loggingService.catch("Error in HuddleService iceCandidates stateChanges:",i)}}),this.messagesSubscription&&this.messagesSubscription.unsubscribe(),this.messagesSubscription=new Lt(e=>{let i=Eu(this.messages,r=>e.next(r),r=>e.error(r));return()=>i()}).pipe(he(e=>this.usersService.getUserById$().pipe(ce(()=>e))),he(e=>{if(e.exists()){let i=e.val();return _o(this.huddleUtilsService.resolveUsersFromHuddleMessages(Object.values(i||{})))}return se([])}),jn(e=>(this.loggingService.catch("Error in HuddleService messages onValue:",e),se([])))).subscribe(e=>{this.messages$.next(e)})}onHuddleSnapshot(e,i){try{this.loggingService.log("%c[WB] Calling FUNCTION: onHuddleSnapshot","color: green;"),i.offerData&&!i.answerData&&i.offerData.from!==this.user.userSnippylyId&&i.offerData.to===this.user.userSnippylyId&&!(e in this.peerConnectionMap)&&!this.onOfferUidHistory[i.offerData.from]?(this.loggingService.log("offer received"),this.loggingService.log(i),this.onOfferUidHistory[i.offerData.from]=!0,this.onOffer(e,i.offerData)):i.answerData&&i.answerData.from!==this.user.userSnippylyId&&i.answerData.to===this.user.userSnippylyId&&this.peerConnectionMap[e]&&this.peerConnectionMap[e]?.connectionState!=="connected"&&!this.onAnswerConnectionIdHistory[e]&&(this.loggingService.log("answer received"),this.loggingService.log(i),this.onAnswerConnectionIdHistory[e]=!0,this.onAnswer(e,i.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 i=e.val(),r=i.connectionId;i?.from!==this.user.userSnippylyId&&r in this.peerConnectionMap&&this.onIceCandidateChange(r,i)}catch(i){this.loggingService.catch("Error in HuddleService onIceCandidateSnapshot:",i)}}onOffer(e,i){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: onOffer","color: green;"),this.createPeerConnection(e,i.from)){this.addLocalStreamToPeerConnection(e,!0);let a=i.offer;yield this.setRemoteDescription(e,a),yield this.sendAnswer(e,i.from)}}catch(r){this.loggingService.catch("Error in HuddleService onOffer:",r)}})}sendAnswer(e,i){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:i},m=rn(this.db,`${this.documentPaths?.huddle}/connections/${e}`);this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:m}),yield V5(m,{answerData:s}),Sl(m).remove()}else this.loggingService.catch("Error in sendAnswer: documentPaths not found")}catch(r){this.loggingService.catch("Error in HuddleService onHuddleSnapshot:",r)}})}onAnswer(e,i){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onAnswer","color: green;");let r=i.answer;yield this.setRemoteDescription(e,r)}catch(r){this.loggingService.catch("Error in HuddleService onAnswer:",r)}})}onIceCandidateChange(e,i){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onIceCandidateChange","color: green;");let r=i.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,i){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRemoteDescription","color: green;"),yield this.peerConnectionMap[e].setRemoteDescription(new RTCSessionDescription(i))}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=T(I({},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 i=rn(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}`);yield Hf(i,JSON.parse(JSON.stringify(e))),this.dbRefsRemoveOnDropCall.push({type:"attendee",dbRef:i}),Sl(i).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;"),Ete(this.attendees).pipe(tt(1)).subscribe(e=>{e&&e.length>1?(e.forEach(i=>{i.userSnippylyId!==this.user.userSnippylyId&&!this.onOfferUidHistory[i.userSnippylyId]&&(this.loggingService.log("calling"),this.loggingService.log(i),this.initOffer(i.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(i=>{this.loggingService.log(i),this.senders[e].replaceTrack(i)})})}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 i=this.createPeerConnection(null,e);i&&(this.addLocalStreamToPeerConnection(i,!1),yield this.sendOffer(i,e))}catch(i){this.loggingService.catch("Error in HuddleService initOffer:",i)}})}createPeerConnection(e,i){try{return this.loggingService.log("%c[WB] Calling FUNCTION: createPeerConnection","color: green;"),e||(e=this.getCombinedId(this.user?.userSnippylyId,i)),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=xte(this.iceCandidates,a);this.dbRefsRemoveOnDropCall.push({type:"iceCandidate",dbRef:s}),Sl(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,i,r){let a={};["connectionState","iceConnectionState","iceGatheringState","signalingState"].forEach(m=>{a[m]=this.peerConnectionMap[i][m]}),this.loggingService.log("Huddle: logStatues: ",i,e,a,r,this.peerConnectionMap[i])}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 i=this.peerConnectionMap[e];i.getTransceivers()?.forEach(a=>{a.stop()}),i.getReceivers()?.forEach(a=>{a.track?.stop()}),i.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(i){this.loggingService.catch("Error in HuddleService closeConnection:",i)}}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(i){this.loggingService.catch("Error in HuddleService removeConnection:",i)}})}addLocalStreamToPeerConnection(e,i){try{this.loggingService.log("%c[WB] Calling FUNCTION: addLocalStreamToPeerConnection","color: green;"),i?(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 i=this.peerConnectionMap[e].getTransceivers();this.loggingService.log(i),i.map(r=>{this.loggingService.log(r.currentDirection),r.currentDirection!=="sendrecv"&&(r.direction="sendrecv"),this.senders[e]=r.sender})}catch(i){this.loggingService.catch("Error in HuddleService updateTransceiverDirection:",i)}}generateKey(){this.loggingService.log("%c[WB] Calling FUNCTION: generateKey","color: green;");let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i="";for(let r=0;r<20;r++)i+=e.charAt(Math.floor(Math.random()*e.length));return i}getCombinedId(e,i){try{return e.localeCompare(i)===-1?`${e}__${i}`:`${i}__${e}`}catch(r){return this.loggingService.catch("Error in HuddleService getCombinedId:",r),""}}sendOffer(e,i){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: sendOffer","color: green;"),this.documentPaths?.huddle&&e){this.onOfferUidHistory[i]=!0;let r=yield this.peerConnectionMap[e].createOffer();yield this.setLocalDescription(e,r);let a={sdp:r.sdp,type:r.type};i||(i="all");let s={offer:a,from:this.user.userSnippylyId,connectionId:e,to:i},m=rn(this.db,`${this.documentPaths?.huddle}/connections/${e}`);yield Hf(m,{offerData:s}),this.dbRefsRemoveOnDropCall.push({type:"connection",dbRef:m}),Sl(m).remove()}}catch(r){this.loggingService.catch("Error in HuddleService sendOffer:",r)}})}setLocalDescription(e,i){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocalDescription","color: green;"),yield this.peerConnectionMap[e].setLocalDescription(i)}catch(r){this.loggingService.catch("Error in HuddleService setLocalDescription:",r)}})}onTrack(e,i){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: onTrack","color: green;"),this.remoteStreamMap[e]||(this.remoteStreamMap[e]={}),this.loggingService.log(i.receiver.track),i?.streams?.length){this.remoteStreamMap[e][i.streams[0].id]=i.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===i.streams[0].id&&(this.remoteStreamMap[e].webcam=i.streams[0]),a?.streamMetadata?.screen===i.streams[0].id&&(this.remoteStreamMap[e].screen=i.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(i=>{this.peerConnectionMap[i].getSenders().find(s=>s?.track?.kind==this.screenSharingStream?.getVideoTracks()[0].kind)?.replaceTrack(this.screenSharingStream?.getVideoTracks()[0])});else{let i=this.localStream;Object.keys(this.peerConnectionMap).forEach(r=>{this.peerConnectionMap[r].getSenders().find(m=>m?.track?.kind==i.getVideoTracks()[0].kind)?.replaceTrack(i.getVideoTracks()[0])}),this.screenSharingStream?.getTracks().forEach(r=>r.stop())}}catch(i){this.loggingService.catch("Error in HuddleService toggleScreenSharing:",i)}})}setLocalStream(e){return Q(this,null,function*(){try{if(this.localStream=new MediaStream([this.silence(),this.black()]),e?.audio||e?.video){let i=e,r=yc();e?.audio&&(e?.audio instanceof Object?i.audio=T(I({},e?.audio),{deviceId:r?.selectedAudioDevice?.deviceId}):i.audio={deviceId:r?.selectedAudioDevice?.deviceId}),e?.video&&(e?.video instanceof Object?i.video=T(I({},e?.video),{deviceId:r?.selectedVideoDevice?.deviceId}):i.video={deviceId:r?.selectedVideoDevice?.deviceId});let a=yield navigator.mediaDevices.getUserMedia(i);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(i){this.loggingService.catch("Error in HuddleService setLocalStream:",i)}})}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(i=>{i.stop()}),this.localStream$.next(null))}catch(e){this.loggingService.catch("Error in HuddleService removeLocalStream:",e)}})}toggleLocalStreamAudio(e){return Q(this,null,function*(){try{let i=this.localStream$.value;if(i){let r=i.getAudioTracks()[0];if(r.enabled&&!e)r.stop(),i.getAudioTracks()?.forEach(a=>{i.removeTrack(a)}),i.addTrack(this.silence()),this.analyticsService.trackEvent(X.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=yc(),s=yield navigator.mediaDevices.getUserMedia({audio:{deviceId:a?.selectAudioDevice?.deviceId}});s&&(i.getAudioTracks()?.forEach(m=>{i.removeTrack(m)}),s.getAudioTracks()?.forEach(m=>{i.addTrack(m)}),this.analyticsService.trackEvent(X.Events.Huddle.HUDDLE_AUDIO_UNMUTED,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(m=>m?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(m=>m?.userId)}))}Object.keys(this.peerConnectionMap).forEach(a=>{this.peerConnectionMap[a].getSenders().find(p=>p?.track?.kind==i?.getAudioTracks()[0].kind)?.replaceTrack(i?.getAudioTracks()[0])}),this.updateUserHuddleState()}}catch(i){this.loggingService.catch("Error in HuddleService toggleLocalStreamAudio:",i)}})}toggleLocalStreamVideo(e){return Q(this,null,function*(){try{let i=this.localStream$.value;if(i){let r=i.getVideoTracks()[0];if(r.enabled&&!e)r.stop(),i.getVideoTracks()?.forEach(a=>{i.removeTrack(a)}),i.addTrack(this.black()),this.analyticsService.trackEvent(X.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=yc(),s=yield navigator.mediaDevices.getUserMedia({video:{deviceId:a?.selectedVideoDevice?.deviceId}});s&&(i.getVideoTracks()?.forEach(m=>{i.removeTrack(m)}),s.getVideoTracks()?.forEach(m=>{i.addTrack(m)}),this.analyticsService.trackEvent(X.Events.Huddle.HUDDLE_VIDEO_TURNED_ON,{huddleType:this.initialHuddleType,totalUsers:this.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.getHuddleAttendees()?.map(m=>m?.userSnippylyId),huddleClientUserIds:this.getHuddleAttendees()?.map(m=>m?.userId)}))}Object.keys(this.peerConnectionMap).forEach(a=>{this.peerConnectionMap[a].getSenders().find(p=>p?.track?.kind==i?.getVideoTracks()[0].kind)?.replaceTrack(i?.getVideoTracks()[0])}),this.updateUserHuddleState()}}catch(i){this.loggingService.catch("Error in HuddleService toggleLocalStreamVideo:",i)}})}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(X.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 i=e.getVideoTracks()[0];i.enabled&&(i.stop(),e.getVideoTracks()?.forEach(r=>{e.removeTrack(r)}),e.addTrack(this.black()),this.analyticsService.trackEvent(X.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 i=this.peerConnectionMap[e];i.getTransceivers()?.forEach(r=>{r.stop()}),i.getSenders()?.forEach(r=>{r.track?.stop()}),i.getReceivers()?.forEach(r=>{r.track?.stop()}),i.close()}),this.peerConnectionMap={},this.dbRefsRemoveOnDropCall.forEach(e=>Q(this,null,function*(){yield L5(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(X.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,i,r){try{let a=JSON.parse(sessionStorage.getItem(j.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)||"{}");r?sessionStorage.setItem(j.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(r)):(a[e]=i,sessionStorage.setItem(j.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA,JSON.stringify(a)))}catch(a){this.loggingService.catch("Error in HuddleService updateHuddleSessionData:",a)}}getHuddleSessionData(){try{return sessionStorage.getItem(j.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)?JSON.parse(sessionStorage.getItem(j.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA)):null}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleSessionData:",e),null}}removeHuddleSessionData(){try{sessionStorage.removeItem(j.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(),i=this.getVideoState(),r=this.getScreenSharingState();this.localStreamState$.next({audioState:e,videoState:i,screenSharingState:r});let a={audioState:e,videoState:i,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=rn(this.db,`${this.documentPaths?.huddle}/attendees/${this.user.userSnippylyId}/huddleOnCursorMode`);yield Hf(e,!!this.huddleOnCursorMode$.value)}}catch(e){this.loggingService.catch("Error in HuddleService updateHuddleOnCursorMode:",e)}})}getAudioState(){try{let e=this.localStream$.value;if(e){let i=e?.getAudioTracks();return!!(i?.length?i[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 i=e?.getVideoTracks();return!!(i?.length?i[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 i=e?.getVideoTracks();return!!(i?.length?i[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 i=yield this.commonDbService?.getData({feature:"allHuddleIceCandidates",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}});Object.keys(i).length>0&&Object.keys(i).forEach(r=>Q(this,null,function*(){i[r].connectionId===e&&this.commonDbService.deleteData({feature:"huddleIceCandidate",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:r,skipFirestore:!0}})}))}}catch(i){this.loggingService.catch("Error in HuddleService dropCall:",i)}})}get timestamp(){return this.commonDbService.getServerTimestamp()}silence(){try{let e=new AudioContext,i=e.createOscillator(),r=i.connect(e.createMediaStreamDestination());return i.start(),Object.assign(r.stream.getAudioTracks()[0],{enabled:!1})}catch(e){this.loggingService.catch("Error in HuddleService silence:",e)}}black({width:e=640,height:i=480}={}){try{let r=Object.assign(document.createElement("canvas"),{width:e,height:i});r.getContext("2d")?.fillRect(0,0,e,i);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),se([])}}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),se([])}}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 i={};i.notificationSource="huddleInvite",i.huddleInvitees=e,i.huddleType=this.getInitialHuddleType(),this.updateNotificationsDatabase(i)}catch(i){this.loggingService.catch("Error in HuddleService inviteUsers:",i)}}updateInvitees(e){try{if(this.documentPaths?.huddle){let i={};e.forEach(r=>{if(r?.email){let a=Pt(r.email);i[a]=r}}),this.commonDbService.setData({feature:"allHuddleInvitees",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0},data:i})}}catch(i){this.loggingService.catch("Error in HuddleService updateInvitees:",i)}}updateNotificationsDatabase(e={}){try{let i=I({notificationSource:"huddle"},e);this.notificationService.updateNotificationDatabase(i)}catch(i){this.loggingService.catch("Error in HuddleService updateNotificationsDatabase: ",i)}}getHuddleJoined$(){try{return this.huddleJoined$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleJoined$:",e),se(!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),se({})}}updateHuddleCursorAvailableByAttendeeId(e,i){try{let r=this.huddleCursorAvailableByAttendeeId$.value;r[e]=i,this.huddleCursorAvailableByAttendeeId$.next(r)}catch(r){this.loggingService.catch("Error in HuddleService updateCursorUserAvailableByUserId:",r)}}setRemoteStreamsByUserId(e){try{this.remoteStreamsByUserId$.next(e)}catch(i){this.loggingService.catch("Error in HuddleService setRemoteStreamsByUserId:",i)}}getRemoteStreamsByUserId$(){try{return this.remoteStreamsByUserId$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getRemoteStreamsByUserId$:",e),se({})}}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),se(!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),se(!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),se(!1)}}getChatEnabled(){try{return this.chatEnabled$.value}catch(e){return this.loggingService.catch("Error in HuddleService getChatEnabled:",e),!1}}getHuddleOnCursorModeByAttendeeId$(){try{return this.huddleOnCursorModeByAttendeeId$.asObservable()}catch(e){return this.loggingService.catch("Error in HuddleService getHuddleOnCursorModeByAttendeeId$:",e),se({})}}toggleHuddleOnCursorModeByAttendeeId(e){try{let i=this.huddleOnCursorModeByAttendeeId$.value;i[e]?delete i[e]:i[e]=!0,this.huddleOnCursorModeByAttendeeId$.next(i)}catch(i){this.loggingService.catch("Error in HuddleService toggleHuddleOnCursorModeByAttendeeId:",i)}}addCursorTag(){try{if(!document.querySelector(`${j.TAGS.SNIPPYLY_CURSOR}`)){let e=document.createElement(j.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(`${j.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 i=new lM;i.message=e,i.from=this.user,i.timestamp=this.timestamp,this.commonDbService.setData({feature:"huddleMessage",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,id:i.id,skipFirestore:!0},data:i})}}catch(i){this.loggingService.catch("Error in HuddleService sendMessage:",i)}}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),se([])}}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),se(!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(i){this.loggingService.catch("Error in HuddleService signOutUser:",i)}})}};o.\u0275fac=function(i){return new(i||o)(J(bi),J(Ze),J(He),J(hn),J(lt),J(jt),J(Ne),J(TM),J(jo),J(y),J(vn),J(Tn),J(Gn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var qM=class extends ci{constructor(o){super(o),this.getService(y).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(y).log("%c[WB] Calling FUNCTION: _enableCursorMode","color: green;");try{this.trackEvent(X.Events.Huddle.ENABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(pr).enableHuddleOnCursorMode()}catch(o){this.getService(y).catch("Error in enableCursorMode: ",o)}}_disableCursorMode(){this.getService(y).log("%c[WB] Calling FUNCTION: _disableCursorMode","color: green;");try{this.trackEvent(X.Events.Huddle.DISABLE_HUDDLE_ON_CURSOR_MODE_TRIGGERED),this.getService(pr).disableHuddleOnCursorMode()}catch(o){this.getService(y).catch("Error in disableCursorMode: ",o)}}_enableChat(){this.getService(y).log("%c[WB] Calling FUNCTION: _enableChat","color: green;");try{this.trackEvent(X.Events.Huddle.ENABLE_CHAT_TRIGGERED),this.getService(pr).enableChat()}catch(o){this.getService(y).catch("Error in enableChat: ",o)}}_disableChat(){this.getService(y).log("%c[WB] Calling FUNCTION: _disableChat","color: green;");try{this.trackEvent(X.Events.Huddle.DISABLE_CHAT_TRIGGERED),this.getService(pr).disableChat()}catch(o){this.getService(y).catch("Error in disableChat: ",o)}}_enableFlockModeOnAvatarClick(){this.getService(y).log("%c[WB] Calling FUNCTION: _enableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(X.Events.Huddle.ENABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(pr).enableFlockModeOnAvatarClick()}catch(o){this.getService(y).catch("Error in enableFlockModeOnAvatarClick: ",o)}}_disableFlockModeOnAvatarClick(){this.getService(y).log("%c[WB] Calling FUNCTION: _disableFlockModeOnAvatarClick","color: green;");try{this.trackEvent(X.Events.Huddle.DISABLE_FLOCK_MODE_ON_AVATAR_CLICK_TRIGGERED),this.getService(pr).disableFlockModeOnAvatarClick()}catch(o){this.getService(y).catch("Error in disableFlockModeOnAvatarClick: ",o)}}};var Gle=(()=>{let o=class o{constructor(e,i,r){this.analyticsService=e,this.liveStateService=i,this.loggingService=r,this.actionSubjects=new Map,this.subscriptions=[];try{this.liveStateService.setLiveStateActionsService(this)}catch(a){this.loggingService.catch("Error in LiveStateActionsService constructor: ",a)}}onAccessRequested(e){try{this.triggerAction(Ap.ACCESS_REQUESTED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_ACCESS_REQUESTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onAccessRequested: ",i)}}onAccessRequestCanceled(e){try{this.triggerAction(Ap.ACCESS_REQUEST_CANCELED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_ACCESS_REQUEST_CANCELED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onAccessRequestCanceled: ",i)}}onAccessAccepted(e){try{this.triggerAction(Ap.ACCESS_ACCEPTED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_ACCESS_ACCEPTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onAccessAccepted: ",i)}}onAccessRejected(e){try{this.triggerAction(Ap.ACCESS_REJECTED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_ACCESS_REJECTED,{viewerUserId:e?.viewer?.userId,editorUserId:e?.editor?.userId,timestamp:e?.timestamp,status:e?.status})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onAccessRejected: ",i)}}onEditorAssigned(e){try{this.triggerAction(Ap.EDITOR_ASSIGNED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_EDITOR_ASSIGNED,{editorUserId:e?.editor?.userId,timestamp:e?.timestamp,role:e?.role})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onEditorAssigned: ",i)}}onEditorOnDifferentTabDetected(e){try{this.triggerAction(Ap.EDITOR_ON_DIFFERENT_TAB_DETECTED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_EDITOR_ON_DIFFERENT_TAB_DETECTED,{editorUserId:e?.editor?.userId,timestamp:e?.timestamp,role:e?.role})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onEditorOnDifferentTabDetected: ",i)}}onViewerAssigned(e){try{this.triggerAction(Ap.VIEWER_ASSIGNED,e),this.analyticsService.trackEvent(X.Events.LiveStateSync.SEM_VIEWER_ASSIGNED,{viewerUserId:e?.viewer?.userId,timestamp:e?.timestamp,role:e?.role})}catch(i){this.loggingService.catch("Error in LiveStateActionsService onViewerAssigned: ",i)}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in LiveStateActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in LiveStateActionsService onAction: ",i),se(null)}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(xi),J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var YM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: LiveStateElement","color: blue;"),this.getLiveStateData$=this._getLiveStateData,this.getLiveStateData=this._getLiveStateData,this.setLiveStateData=this._setLiveStateData,this.enableSingleEditorMode=this._enableSingleEditorMode,this.disableSingleEditorMode=this._disableSingleEditorMode,this.isUserEditor$=this._isUserEditor,this.isUserEditor=this._isUserEditor,this.getEditor=this._getEditor,this.setUserAsEditor=this._setUserAsEditor,this.resetUserAccess=this._resetUserAccess,this.singleEditorModeContainerIds=this._singleEditorModeContainerIds,this.enableAutoSyncState=this._enableAutoSyncState,this.disableAutoSyncState=this._disableAutoSyncState,this.requestEditorAccess=this._requestEditorAccess,this.isEditorAccessRequested=this._isEditorAccessRequested,this.acceptEditorAccessRequest=this._acceptEditorAccessRequest,this.rejectEditorAccessRequest=this._rejectEditorAccessRequest,this.cancelEditorAccessRequest=this._cancelEditorAccessRequest,this.editCurrentTab=this._editCurrentTab,this.setEditorAccessTimeout=this._setEditorAccessTimeout,this.enableEditorAccessTransferOnTimeOut=this._enableEditorAccessTransferOnTimeOut,this.disableEditorAccessTransferOnTimeOut=this._disableEditorAccessTransferOnTimeOut,this.enableDefaultSingleEditorUI=this._enableDefaultSingleEditorUI,this.disableDefaultSingleEditorUI=this._disableDefaultSingleEditorUI,this.getEditorAccessTimer=this._getEditorAccessTimer,this.onServerConnectionStateChange=this._onServerConnectionStateChange,this.on=this._on}_getLiveStateData(o,t){this.getService(y).log("%c[WB] Calling FUNCTION: getLiveStateData","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.GET_LIVE_STATE_DATA_TRIGGERED),this.getService(xi).getLiveStateData$(o,t)}catch(e){return this.getService(y).catch("Error in _getLiveStateData: ",e),se(null)}}_setLiveStateData(o,t,e){this.getService(y).log("%c[WB] Calling FUNCTION: setLiveStateData","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.SET_LIVE_STATE_DATA_TRIGGERED),this.getService(xi).setLiveStateData(o,t,e)}catch(i){return this.getService(y).catch("Error in _setLiveStateData: ",i),Promise.resolve()}}_enableSingleEditorMode(o){this.getService(y).log("%c[WB] Calling FUNCTION: enableSingleEditorMode","color: green;");try{this.trackEvent(X.Events.LiveStateSync.ENABLE_SINGLE_EDITOR_MODE_TRIGGERED),this.getService(xi).enableSingleEditorMode(o)}catch(t){this.getService(y).catch("Error in _enableSingleEditorMode: ",t)}}_disableSingleEditorMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableSingleEditorMode","color: green;");try{this.trackEvent(X.Events.LiveStateSync.DISABLE_SINGLE_EDITOR_MODE_TRIGGERED),this.getService(xi).disableSingleEditorMode()}catch(o){this.getService(y).catch("Error in _disableSingleEditorMode: ",o)}}_isUserEditor(){this.getService(y).log("%c[WB] Calling FUNCTION: isUserEditor$","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.IS_USER_EDITOR_TRIGGERED),this.getService(xi).isUserEditor$()}catch(o){return this.getService(y).catch("Error in _isUserEditor$: ",o),se(null)}}_getEditor(){this.getService(y).log("%c[WB] Calling FUNCTION: getEditor","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.GET_EDITOR_TRIGGERED),this.getService(xi).getEditor$()}catch(o){return this.getService(y).catch("Error in _getEditor: ",o),se(null)}}_setUserAsEditor(){this.getService(y).log("%c[WB] Calling FUNCTION: setUserAsEditor","color: green;");try{this.trackEvent(X.Events.LiveStateSync.SET_USER_AS_EDITOR_TRIGGERED),this.getService(xi).setUserAsEditor()}catch(o){this.getService(y).catch("Error in _setUserAsEditor: ",o)}}_resetUserAccess(){this.getService(y).log("%c[WB] Calling FUNCTION: resetUserAccess","color: green;");try{this.trackEvent(X.Events.LiveStateSync.RESET_USER_ACCESS_TRIGGERED),this.getService(xi).removeEditorAccess()}catch(o){this.getService(y).catch("Error in _resetUserAccess: ",o)}}_singleEditorModeContainerIds(o){this.getService(y).log("%c[WB] Calling FUNCTION: singleEditorModeContainerIds","color: green;");try{this.trackEvent(X.Events.LiveStateSync.SINGLE_EDITOR_MODE_CONTAINER_IDS_TRIGGERED),this.getService(xi).setSingleEditorModeContainerIds(o)}catch(t){this.getService(y).catch("Error in _singleEditorModeContainerIds: ",t)}}_enableAutoSyncState(){this.getService(y).log("%c[WB] Calling FUNCTION: enableAutoSyncState","color: green;");try{this.trackEvent(X.Events.LiveStateSync.ENABLE_AUTO_SYNC_STATE_TRIGGERED),this.getService(xi).enableAutoSyncState()}catch(o){this.getService(y).catch("Error in _enableAutoSyncState: ",o)}}_disableAutoSyncState(){this.getService(y).log("%c[WB] Calling FUNCTION: disableAutoSyncState","color: green;");try{this.trackEvent(X.Events.LiveStateSync.DISABLE_AUTO_SYNC_STATE_TRIGGERED),this.getService(xi).disableAutoSyncState()}catch(o){this.getService(y).catch("Error in _disableAutoSyncState: ",o)}}_requestEditorAccess(){this.getService(y).log("%c[WB] Calling FUNCTION: requestEditorAccess","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.REQUEST_EDITOR_ACCESS_TRIGGERED),this.getService(xi).requestEditorAccess()}catch(o){return this.getService(y).catch("Error in _requestEditorAccess: ",o),se(null)}}_isEditorAccessRequested(){this.getService(y).log("%c[WB] Calling FUNCTION: isEditorAccessRequested","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.IS_EDITOR_ACCESS_REQUESTED_TRIGGERED),this.getService(xi).isEditorAccessRequested$()}catch(o){return this.getService(y).catch("Error in _isEditorAccessRequested: ",o),se(null)}}_acceptEditorAccessRequest(){this.getService(y).log("%c[WB] Calling FUNCTION: acceptEditorAccessRequest","color: green;");try{this.trackEvent(X.Events.LiveStateSync.ACCEPT_EDITOR_ACCESS_REQUEST_TRIGGERED),this.getService(xi).acceptEditorAccessRequest()}catch(o){this.getService(y).catch("Error in _acceptEditorAccessRequest: ",o)}}_rejectEditorAccessRequest(){this.getService(y).log("%c[WB] Calling FUNCTION: rejectEditorAccessRequest","color: green;");try{this.trackEvent(X.Events.LiveStateSync.REJECT_EDITOR_ACCESS_REQUEST_TRIGGERED),this.getService(xi).rejectEditorAccessRequest()}catch(o){this.getService(y).catch("Error in _rejectEditorAccessRequest: ",o)}}_cancelEditorAccessRequest(){this.getService(y).log("%c[WB] Calling FUNCTION: cancelEditorAccessRequest","color: green;");try{this.trackEvent(X.Events.LiveStateSync.CANCEL_EDITOR_ACCESS_REQUEST_TRIGGERED),this.getService(xi).cancelEditorAccessRequest()}catch(o){this.getService(y).catch("Error in _cancelEditorAccessRequest: ",o)}}_editCurrentTab(){this.getService(y).log("%c[WB] Calling FUNCTION: editCurrentTab","color: green;");try{this.trackEvent(X.Events.LiveStateSync.EDIT_CURRENT_TAB_TRIGGERED),this.getService(xi).editCurrentTab()}catch(o){this.getService(y).catch("Error in _editCurrentTab: ",o)}}_setEditorAccessTimeout(o){this.getService(y).log("%c[WB] Calling FUNCTION: setEditorAccessTimeout","color: green;");try{this.trackEvent(X.Events.LiveStateSync.SET_EDITOR_ACCESS_TIMEOUT_TRIGGERED),this.getService(xi).setEditorAccessTimeout(o)}catch(t){this.getService(y).catch("Error in _setEditorAccessTimeout: ",t)}}_enableEditorAccessTransferOnTimeOut(){this.getService(y).log("%c[WB] Calling FUNCTION: enableEditorAccessTransferOnTimeOut","color: green;");try{this.trackEvent(X.Events.LiveStateSync.ENABLE_EDITOR_ACCESS_TRANSFER_ON_TIMEOUT_TRIGGERED),this.getService(xi).enableEditorAccessTransferOnTimeOut()}catch(o){this.getService(y).catch("Error in _enableEditorAccessTransferOnTimeOut: ",o)}}_disableEditorAccessTransferOnTimeOut(){this.getService(y).log("%c[WB] Calling FUNCTION: disableEditorAccessTransferOnTimeOut","color: green;");try{this.trackEvent(X.Events.LiveStateSync.DISABLE_EDITOR_ACCESS_TRANSFER_ON_TIMEOUT_TRIGGERED),this.getService(xi).disableEditorAccessTransferOnTimeOut()}catch(o){this.getService(y).catch("Error in _disableEditorAccessTransferOnTimeOut: ",o)}}_enableDefaultSingleEditorUI(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDefaultSingleEditorUI","color: green;");try{this.trackEvent(X.Events.LiveStateSync.ENABLE_DEFAULT_SINGLE_EDITOR_UI_TRIGGERED),this.getService(xi).enableDefaultSingleEditorUI()}catch(o){this.getService(y).catch("Error in _enableDefaultSingleEditorUI: ",o)}}_disableDefaultSingleEditorUI(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDefaultSingleEditorUI","color: green;");try{this.trackEvent(X.Events.LiveStateSync.DISABLE_DEFAULT_SINGLE_EDITOR_UI_TRIGGERED),this.getService(xi).disableDefaultSingleEditorUI()}catch(o){this.getService(y).catch("Error in _disableDefaultSingleEditorUI: ",o)}}_getEditorAccessTimer(){this.getService(y).log("%c[WB] Calling FUNCTION: getEditorAccessTimer","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.GET_EDITOR_ACCESS_TIMER_TRIGGERED),this.getService(xi).getEditorAccessTimer$()}catch(o){return this.getService(y).catch("Error in _getEditorAccessTimer: ",o),se(new Zv)}}_onServerConnectionStateChange(){this.getService(y).log("%c[WB] Calling FUNCTION: onServerConnectionStateChange","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.ON_SERVER_CONNECTION_STATE_CHANGE_TRIGGERED),this.getService(xi).onServerConnectionStateChange$()}catch(o){return this.getService(y).catch("Error in _onServerConnectionStateChange: ",o),se(qs.PENDING_INIT)}}_on(o){this.getService(y).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.trackEvent(X.Events.LiveStateSync.ON_ACTION_TRIGGERED,{payload:{action:o}}),this.getService(Gle).onAction(o)}catch(t){return this.getService(y).catch("Error in _on: ",t),se(null)}}};var KM=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map,this.defaultSource="internal",this.isUserAdmin=!1,this.subscriptions=[],this.loggingService.log("%c[WB] Creating CLASS: CommentActionsService","color: blue;")}triggerSettingsUpdatedEvent(e){try{this.triggerAction(Uoe.SETTINGS_UPDATED,e)}catch(i){this.loggingService.catch("Error in NotificationsActionsService triggerAddCommentAnnotationEvent: ",i)}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in NotificationsActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in NotificationsActionsService onAction: ",i),se(null)}}};o.\u0275fac=function(i){return new(i||o)(J(y))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var ZM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: ViewsElement","color: blue;"),this.openHistoryPanel=this._openHistoryPanel,this.closeHistoryPanel=this._closeHistoryPanel,this.toggleHistoryPanel=this._toggleHistoryPanel,this.getNotificationsData=this._getNotificationsData,this.setMaxDays=this._setMaxDays,this.setTabConfig=this._setTabConfig,this.enableReadNotificationsOnForYouTab=this._enableReadNotificationsOnForYouTab,this.disableReadNotificationsOnForYouTab=this._disableReadNotificationsOnForYouTab,this.setAllNotificationsAsRead=this._setAllNotificationsAsRead,this.getUnreadNotificationsCount=this._getUnreadNotificationsCount,this.markNotificationAsReadById=this._markNotificationAsReadById,this.setSettings=this._setSettings,this.getSettings=this._getSettings,this.muteAllNotifications=this._muteAllNotifications,this.enableSettings=this._enableSettings,this.disableSettings=this._disableSettings,this.setSettingsInitialConfig=this._setSettingsInitialConfig,this.on=this._on}_openHistoryPanel(){this.getService(y).log("%c[WB] Calling FUNCTION: _openHistoryPanel","color: green;");try{this.trackEvent(X.Events.Notifications.OPEN_HISTORY_PANEL_TRIGGERED),this.getService(vn).setHistoryPanelVisibility(!0,!0)}catch(o){this.getService(y).catch("Error in openHistoryPanel: ",o)}}_closeHistoryPanel(){this.getService(y).log("%c[WB] Calling FUNCTION: _closeHistoryPanel","color: green;");try{this.trackEvent(X.Events.Notifications.CLOSE_HISTORY_PANEL_TRIGGERED),this.getService(vn).setHistoryPanelVisibility(!1,!0)}catch(o){this.getService(y).catch("Error in closeHistoryPanel: ",o)}}_toggleHistoryPanel(){this.getService(y).log("%c[WB] Calling FUNCTION: _toggleHistoryPanel","color: green;");try{this.trackEvent(X.Events.Notifications.TOGGLE_HISTORY_PANEL_TRIGGERED),this.getService(vn).toggleHistoryPanelVisibility(!0)}catch(o){this.getService(y).catch("Error in toggleHistoryPanel: ",o)}}_getNotificationsData(){this.getService(y).log("%c[WB] Calling FUNCTION: _getNotificationsData","color: green;");try{return this.trackEvent(X.Events.Notifications.GET_NOTIFICATIONS_DATA_TRIGGERED),this.getService(vn).getNotifications$()}catch(o){return this.getService(y).catch("Error in getNotificationsData: ",o),se([])}}_setMaxDays(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setMaxDays","color: green;");try{this.trackEvent(X.Events.Notifications.SET_MAX_DAYS_TRIGGERED,{payload:{days:o}}),this.getService(vn).setMaxDays(o)}catch(t){this.getService(y).catch("Error in setMaxDays: ",t)}}_setTabConfig(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setTabConfig","color: green;");try{this.trackEvent(X.Events.Notifications.SET_TAB_CONFIG_TRIGGERED,{payload:{tabConfig:o}}),this.getService(vn).setTabConfig(o)}catch(t){this.getService(y).catch("Error in setTabConfig: ",t)}}_enableReadNotificationsOnForYouTab(){this.getService(y).log("%c[WB] Calling FUNCTION: _enableReadNotificationsOnForYouTab","color: green;");try{this.trackEvent(X.Events.Notifications.ENABLE_READ_NOTIFICATIONS_ON_FOR_YOU_TAB_TRIGGERED),this.getService(vn).enableReadNotificationsOnForYouTab()}catch(o){this.getService(y).catch("Error in enableReadNotificationsOnForYouTab: ",o)}}_disableReadNotificationsOnForYouTab(){this.getService(y).log("%c[WB] Calling FUNCTION: _disableReadNotificationsOnForYouTab","color: green;");try{this.trackEvent(X.Events.Notifications.DISABLE_READ_NOTIFICATIONS_ON_FOR_YOU_TAB_TRIGGERED),this.getService(vn).disableReadNotificationsOnForYouTab()}catch(o){this.getService(y).catch("Error in disableReadNotificationsOnForYouTab: ",o)}}_setAllNotificationsAsRead(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setAllNotificationsAsRead","color: green;");try{this.trackEvent(X.Events.Notifications.SET_ALL_NOTIFICATIONS_AS_READ_TRIGGERED,{payload:{config:o}}),this.getService(vn).setAllNotificationsAsRead(o)}catch(t){this.getService(y).catch("Error in setAllNotificationsAsRead: ",t)}}_getUnreadNotificationsCount(){this.getService(y).log("%c[WB] Calling FUNCTION: _getUnreadNotificationsCount","color: green;");try{return this.trackEvent(X.Events.Notifications.GET_UNREAD_NOTIFICATIONS_COUNT_TRIGGERED),this.getService(vn).getUnreadNotificationsCount$()}catch(o){return this.getService(y).catch("Error in getUnreadNotificationsCount: ",o),se({forYou:null,all:null})}}_markNotificationAsReadById(o){this.getService(y).log("%c[WB] Calling FUNCTION: _markNotificationAsReadById","color: green;");try{this.trackEvent(X.Events.Notifications.MARK_NOTIFICATION_AS_READ_BY_ID_TRIGGERED,{payload:{notificationId:o}}),this.getService(vn).markNotificationAsReadById(o)}catch(t){this.getService(y).catch("Error in markNotificationAsReadById: ",t)}}_setSettings(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setSettings","color: green;");try{this.trackEvent(X.Events.Notifications.SET_SETTINGS_TRIGGERED,{payload:{config:o}}),this.getService(vn).setSettingsConfigWithDB(o)}catch(t){this.getService(y).catch("Error in setSettings: ",t)}}_getSettings(){this.getService(y).log("%c[WB] Calling FUNCTION: _getSettings","color: green;");try{return this.trackEvent(X.Events.Notifications.GET_SETTINGS_TRIGGERED),this.getService(vn).getSettingsConfig()}catch(o){return this.getService(y).catch("Error in getSettings: ",o),{}}}_muteAllNotifications(){this.getService(y).log("%c[WB] Calling FUNCTION: _muteAllNotifications","color: green;");try{this.trackEvent(X.Events.Notifications.MUTE_ALL_NOTIFICATIONS_TRIGGERED),this.getService(vn).setMuteAllNotifications()}catch(o){this.getService(y).catch("Error in muteAllNotifications: ",o)}}_enableSettings(){this.getService(y).log("%c[WB] Calling FUNCTION: _enableSettings","color: green;");try{this.trackEvent(X.Events.Notifications.ENABLE_SETTINGS_TRIGGERED),this.getService(vn).enableSettings()}catch(o){this.getService(y).catch("Error in enableSettings: ",o)}}_disableSettings(){this.getService(y).log("%c[WB] Calling FUNCTION: _disableSettings","color: green;");try{this.trackEvent(X.Events.Notifications.DISABLE_SETTINGS_TRIGGERED),this.getService(vn).disableSettings()}catch(o){this.getService(y).catch("Error in disableSettings: ",o)}}_setSettingsInitialConfig(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setSettingsInitialConfig","color: green;");try{this.trackEvent(X.Events.Notifications.SET_SETTINGS_INITIAL_CONFIG_TRIGGERED,{payload:{settings:o}}),this.getService(vn).setSettingsInitialConfig(o)}catch(t){this.getService(y).catch("Error in setSettingsInitialConfig: ",t)}}_on(o){this.getService(y).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.trackEvent(X.Events.Notifications.ON_ACTION_TRIGGERED,{payload:{action:o}}),this.getService(KM).onAction(o)}catch(t){return this.getService(y).catch("Error in _on: ",t),se(null)}}};var TH=(()=>{let o=class o{constructor(e,i,r){this.analyticsService=e,this.loggingService=i,this.presenceService=r,this.actionSubjects=new Map,this.subscriptions=[];try{this.presenceService.setPresenceActionsService(this)}catch(a){this.loggingService.catch("Error in PresenceActionsService constructor: ",a)}}onMultipleUsersOnline(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onMultipleUsersOnline","color: green;"),this.triggerAction(hU.MULTIPLE_USERS_ONLINE,e),this.analyticsService.trackEvent(X.Events.Presence.MULTIPLE_USERS_ONLINE,{totalUsers:e?.users?.length,presenceSnippylyUserIds:e?.users?.map(i=>i.userSnippylyId),presenceClientUserIds:e?.users?.map(i=>i.userId)})}catch(i){this.loggingService.catch("Error in PresenceActionsService onMultipleUsersOnline: ",i)}}onUserStateChange(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onUserStateChange","color: green;"),this.triggerAction(hU.USER_STATE_CHANGE,e),this.analyticsService.trackEvent(X.Events.Presence.ON_USER_STATE_CHANGE,{userSnippylyId:e?.user?.userSnippylyId,userId:e?.user?.userId,state:e?.state})}catch(i){this.loggingService.catch("Error in PresenceActionsService onUserStateChange: ",i)}}getData(e){try{return this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: getData","color: green;"),this.presenceService.getOnlineUsersOnCurrentDocument(e).pipe(ce(i=>({data:i})))}catch(i){return this.loggingService.catch("Error in PresenceActionsService getData: ",i),se({data:null})}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in PresenceActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in PresenceActionsService onAction: ",i),se(null)}}};o.\u0275fac=function(i){return new(i||o)(J(Ze),J(y),J(Ml))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var XM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: PresenceElement","color: blue;"),this.getOnlineUsersOnCurrentDocument=this._getOnlineUsersOnCurrentDocument,this.setInactivityTime=this._setInactivityTime,this.enableFlockMode=this._enableFlockMode,this.disableFlockMode=this._disableFlockMode,this.startFollowingUser=this._startFollowingUser,this.stopFollowingUser=this._stopFollowingUser,this.enableSelf=this._enableSelf,this.disableSelf=this._disableSelf,this.getData=this._getData,this.on=this._on}_getOnlineUsersOnCurrentDocument(){this.getService(y).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(X.Events.Presence.GET_ONLINE_USERS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(Ml).getOnlineUsersOnCurrentDocument()}catch(o){return this.getService(y).catch("Error in _getOnlineUsersOnCurrentDocument: ",o),se(null)}}_setInactivityTime(o){this.getService(y).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(X.Events.Presence.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:o}}),isNaN(o)?this.getService(y).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(Ml).setInactivityTime(o)}catch(t){this.getService(y).catch("Error in setInactivityTime: ",t)}}_disableFlockMode(){try{this.trackEvent(X.Events.Presence.DISABLE_FLOCK_MODE_TRIGGERED),this.getService(Ac).disableFlockMode()}catch(o){this.getService(y).catch("Error in _disableFlockMode: ",o)}}_enableFlockMode(o){try{this.trackEvent(X.Events.Presence.ENABLE_FLOCK_MODE_TRIGGERED,{payload:{options:o}}),this.getService(Ac).enableFlockMode(o)}catch(t){this.getService(y).catch("Error in _enableFlockMode: ",t)}}_stopFollowingUser(){try{this.trackEvent(X.Events.Presence.STOP_FOLLOWING_USER_TRIGGERED),this.getService(Ac).stopFollowingUser()}catch(o){this.getService(y).catch("Error in _stopFollowingUser: ",o)}}_startFollowingUser(o){try{this.trackEvent(X.Events.Presence.START_FOLLOWING_USER_TRIGGERED,{payload:{externalId:o}});let t=this.getService(Ml).getPresenceUserFromExternalId(o);return t&&t.userSnippylyId&&t.name!==void 0?(this.getService(Ac).startFollowingUser(t.userSnippylyId,t.name),{success:!0,msg:"Joined flock session."}):{success:!1,msg:"User could not be found."}}catch(t){return this.getService(y).catch("Error in _startFollowingUser: ",t),{success:!1,msg:"Unknown error.",raw:t}}}_enableSelf(){try{this.trackEvent(X.Events.Presence.ENABLE_SELF_TRIGGERED),this.getService(Ml).enableIncludeSelf()}catch(o){this.getService(y).catch("Error in _enableSelf: ",o)}}_disableSelf(){try{this.trackEvent(X.Events.Presence.DISABLE_SELF_TRIGGERED),this.getService(Ml).disableIncludeSelf()}catch(o){this.getService(y).catch("Error in _disableSelf: ",o)}}_getData(o){this.getService(y).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.trackEvent(X.Events.Presence.GET_PRESENCE_DATA_TRIGGERED,{payload:{query:o}}),o&&typeof o=="object"&&(o=I({},o),o?.documentId&&(o.documentId=Cc(o.documentId)),o?.organizationId&&(o.organizationId=_c(o.organizationId))),this.getService(TH).getData(o)}catch(t){return this.getService(y).catch("Error in _getData: ",t),se({data:null})}}_on(o){this.getService(y).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.trackEvent(X.Events.Presence.ON_ACTION_TRIGGERED,{payload:{action:o}}),this.getService(TH).onAction(o)}catch(t){return this.getService(y).catch("Error in _on: ",t),se(null)}}};var QM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: ReactionElement","color: blue;"),this.enableDarkMode=this._enableDarkMode,this.disableDarkMode=this._disableDarkMode,this.setCustomReactions=this._setCustomReactions}_enableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(X.Events.Reactions.ENABLE_DARK_MODE_TRIGGERED),this.getService(nr).enableDarkMode()}catch(o){this.getService(y).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(X.Events.Reactions.DISABLE_DARK_MODE_TRIGGERED),this.getService(nr).disableDarkMode()}catch(o){this.getService(y).catch("Error in _disableDarkMode: ",o)}}_setCustomReactions(o){this.getService(y).log("%c[WB] Calling FUNCTION: setCustomReactions","color: green;");try{this.trackEvent(X.Events.Reactions.SET_CUSTOM_REACTIONS_TRIGGERED,{payload:{reactions:o}}),this.getService(nr).setCustomReactions(o)}catch(t){this.getService(y).catch("Error in _setCustomReactions: ",t)}}};var s0=(()=>{let o=class o{constructor(e,i,r){this.loggingService=e,this.recorderAnnotationService=i,this.recorderService=r,this.actionSubjects=new Map,this.subscriptions=[];try{this.recorderAnnotationService.setRecorderActionsService(this),this.recorderService.setRecorderActionsService(this)}catch(a){this.loggingService.catch("Error in RecorderActionsService constructor: ",a)}}onTranscriptionDone(e){try{this.triggerAction(Lu.TRANSCRIPTION_DONE,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onTranscriptionDone: ",i)}}onRecordingDone(e){try{this.triggerAction(Lu.RECORDING_DONE,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onRecordingDone: ",i)}}onRecordingEditDone(e){try{this.triggerAction(Lu.RECORDING_EDIT_DONE,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onRecordingEditDone: ",i)}}onDeleteRecording(e){try{this.triggerAction(Lu.DELETE_RECORDING,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onDeleteRecording: ",i)}}onError(e){try{this.triggerAction(Lu.ERROR,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onError: ",i)}}onRecordingSaveInitiated(e){try{this.triggerAction(Lu.RECORDING_SAVE_INITIATED,e)}catch(i){this.loggingService.catch("Error in RecorderActionsService onRecordingSaveInitiated: ",i)}}triggerAction(e,i){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.next(i)}catch(r){this.loggingService.catch("Error in RecorderActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Ke),this.actionSubjects.get(e)?.asObservable()}catch(i){return this.loggingService.catch("Error in RecorderActionsService onAction: ",i),se(null)}}};o.\u0275fac=function(i){return new(i||o)(J(y),J(ji),J(ui))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let n=o;return n})();var JM=class extends ci{constructor(o){super(o),this.getService(y).log("%c[WB] Creating CLASS: RecorderElement","color: blue;"),this.initRecording=this._initRecording,this.onRecordedData=this._onRecordedData,this.enableDarkMode=this._enableDarkMode,this.disableDarkMode=this._disableDarkMode,this.enableRecordingCountdown=this._enableRecordingCountdown,this.disableRecordingCountdown=this._disableRecordingCountdown,this.getRecordingDataByRecorderId=this._getRecordingDataByRecorderId,this.enableRecordingTranscription=this._enableRecordingTranscription,this.disableRecordingTranscription=this._disableRecordingTranscription,this.getRecordingData=this._getRecordingData,this.enableVideoEditor=this._enableVideoEditor,this.disableVideoEditor=this._disableVideoEditor,this.getRecordings=this._getRecordings,this.fetchRecordings=this._fetchRecordings,this.deleteRecordings=this._deleteRecordings,this.setRecordingQualityConstraints=this._setRecordingQualityConstraints,this.setRecordingEncodingOptions=this._setRecordingEncodingOptions,this.downloadLatestVideo=this._downloadLatestVideo,this.on=this._on}_initRecording(o,t){this.getService(y).log("%c[WB] Calling FUNCTION: initRecording","color: green;");try{return this.trackEvent(X.Events.Recording.INIT_RECORDING_TRIGGERED,{payload:{type:o,panelId:t}}),this.getService(ui).initRecording(o,t)}catch(e){return this.getService(y).catch("Error in _initRecording: ",e),se(null)}}_onRecordedData(){this.getService(y).log("%c[WB] Calling FUNCTION: onRecordedData","color: green;");try{return this.trackEvent(X.Events.Recording.ON_RECORDED_DATA_TRIGGERED),this.getService(ui).onRecordedData()}catch(o){return this.getService(y).catch("Error in _onRecordedData: ",o),se(null)}}_enableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: enableDarkMode","color: green;");try{this.trackEvent(X.Events.Recording.ENABLE_DARK_MODE_TRIGGERED),this.getService(ji).setRecorderContainerDarkMode(!0)}catch(o){this.getService(y).catch("Error in _enableDarkMode: ",o)}}_disableDarkMode(){this.getService(y).log("%c[WB] Calling FUNCTION: disableDarkMode","color: green;");try{this.trackEvent(X.Events.Recording.DISABLE_DARK_MODE_TRIGGERED),this.getService(ji).setRecorderContainerDarkMode(!1)}catch(o){this.getService(y).catch("Error in _disableDarkMode: ",o)}}_enableRecordingCountdown(){this.getService(y).log("%c[WB] Calling FUNCTION: enableRecordingCountdown","color: green;");try{this.trackEvent(X.Events.Recording.ENABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(ui).enableRecordingCountdown()}catch(o){this.getService(y).catch("Error in _enableRecordingCountdown: ",o)}}_disableRecordingCountdown(){this.getService(y).log("%c[WB] Calling FUNCTION: disableRecordingCountdown","color: green;");try{this.trackEvent(X.Events.Recording.DISABLE_RECORDING_COUNTDOWN_TRIGGERED),this.getService(ui).disableRecordingCountdown()}catch(o){this.getService(y).catch("Error in _disableRecordingCountdown: ",o)}}_getRecordingDataByRecorderId(o){this.getService(y).log("%c[WB] Calling FUNCTION: getRecordingDataByRecorderId","color: green;");try{return this.trackEvent(X.Events.Recording.GET_RECORDING_DATA_BY_RECORDER_ID_TRIGGERED,{payload:{recorderId:o}}),this.getService(ji).getRecorderDataByRecorderId(o)}catch(t){return this.getService(y).catch("Error in _getRecordingDataByRecorderId: ",t),se(null)}}_getRecordings(o){this.getService(y).log("%c[WB] Calling FUNCTION: getRecordings","color: green;");try{return this.trackEvent(X.Events.Recording.GET_RECORDINGS_TRIGGERED,{payload:{query:o}}),this.getService(ji).getRecordings(o)}catch(t){return this.getService(y).catch("Error in _getRecordings: ",t),se([])}}_getRecordingData(o){this.getService(y).log("%c[WB] Calling FUNCTION: getRecordingData","color: green;");try{return this.trackEvent(X.Events.Recording.GET_RECORDING_DATA_TRIGGERED,{payload:{query:o}}),this.getService(ji).getRecorderDataByRecorderIds(o)}catch(t){return this.getService(y).catch("Error in _getRecordingData: ",t),Promise.resolve({data:null})}}_fetchRecordings(o){this.getService(y).log("%c[WB] Calling FUNCTION: fetchRecordings","color: green;");try{return this.trackEvent(X.Events.Recording.FETCH_RECORDINGS_TRIGGERED,{payload:{query:o}}),this.getService(ji).fetchRecorderDataByRecorderIds(o)}catch(t){return this.getService(y).catch("Error in _fetchRecordings: ",t),Promise.resolve([])}}_deleteRecordings(o){this.getService(y).log("%c[WB] Calling FUNCTION: deleteRecording","color: green;");try{return this.trackEvent(X.Events.Recording.DELETE_RECORDING_TRIGGERED,{payload:{query:o}}),this.getService(ji).deleteRecorderDataByRecorderIds(o)}catch(t){return this.getService(y).catch("Error in _deleteRecording: ",t),Promise.resolve([])}}_enableRecordingTranscription(){this.getService(y).log("%c[WB] Calling FUNCTION: enableRecordingTranscription","color: green;");try{this.trackEvent(X.Events.Recording.ENABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(ji).enableRecordingTranscription()}catch(o){this.getService(y).catch("Error in _enableRecordingTranscription: ",o)}}_disableRecordingTranscription(){this.getService(y).log("%c[WB] Calling FUNCTION: disableRecordingTranscription","color: green;");try{this.trackEvent(X.Events.Recording.DISABLE_RECORDING_TRANSCRIPTION_TRIGGERED),this.getService(ji).disableRecordingTranscription()}catch(o){this.getService(y).catch("Error in _disableRecordingTranscription: ",o)}}_on(o){this.getService(y).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.trackEvent(X.Events.Recording.ON_ACTION_TRIGGERED,{payload:{action:o}}),this.getService(s0).onAction(o)}catch(t){return this.getService(y).catch("Error in _on: ",t),se(null)}}_enableVideoEditor(){this.getService(y).log("%c[WB] Calling FUNCTION: enableVideoEditor","color: green;");try{this.trackEvent(X.Events.Recording.ENABLE_VIDEO_EDITOR_TRIGGERED),this.getService(ui).enableVideoEditor()}catch(o){this.getService(y).catch("Error in _enableVideoEditor: ",o)}}_disableVideoEditor(){this.getService(y).log("%c[WB] Calling FUNCTION: disableVideoEditor","color: green;");try{this.trackEvent(X.Events.Recording.DISABLE_VIDEO_EDITOR_TRIGGERED),this.getService(ui).disableVideoEditor()}catch(o){this.getService(y).catch("Error in _disableVideoEditor: ",o)}}_setRecordingQualityConstraints(o){this.getService(y).log("%c[WB] Calling FUNCTION: setRecordingQualityConstraints","color: green;");try{this.trackEvent(X.Events.Recording.SET_RECORDING_QUALITY_CONSTRAINTS_TRIGGERED,{payload:{constraints:o}}),this.getService(ui).setRecordingQualityConstraints(o)}catch(t){this.getService(y).catch("Error in _setRecordingQualityConstraints: ",t)}}_setRecordingEncodingOptions(o){this.getService(y).log("%c[WB] Calling FUNCTION: setRecordingEncodingOptions","color: green;");try{this.trackEvent(X.Events.Recording.SET_RECORDING_ENCODING_OPTIONS_TRIGGERED,{payload:{options:o}}),this.getService(ui).setRecordingEncodingOptions(o)}catch(t){this.getService(y).catch("Error in _setRecordingEncodingOptions: ",t)}}_downloadLatestVideo(o){this.getService(y).log("%c[WB] Calling FUNCTION: downloadLatestVideo","color: green;");try{return this.trackEvent(X.Events.Recording.DOWNLOAD_LATEST_VIDEO_TRIGGERED,{payload:{recorderId:o}}),this.getService(ji).downloadLatestVideo(o)}catch(t){return this.getService(y).catch("Error in _downloadLatestVideo: ",t),Promise.resolve(!1)}}};var Pc=(()=>{let o=class o{constructor(e,i,r,a,s,m){this.analyticsService=e,this.authService=i,this.configService=r,this.domService=a,this.loggingService=s,this.functions=m,this.rewriterAnnotations$=new Ce([]),this.rewriterOptions$=new Ce({}),this.rewriterEnabled$=new Ce(!1),this.lastOpenAIPromptCalledAt=0,this.getRewriterEnabled$().subscribe(p=>{try{if(p){let h=document.querySelectorAll(j.TAGS.SNIPPYLY_REWRITER);if(!document.querySelectorAll(j.TAGS.VELT_REWRITER)?.length&&!h?.length){let E=document.createElement(j.TAGS.VELT_REWRITER);document.body.appendChild(E),this.authService.getUser$().pipe(Fe(D=>!!D),tt(1)).subscribe(D=>{this.analyticsService.trackEvent(X.Events.Rewriter.REWRITER_ENABLED,{isMobileDevice:this.domService.isMobileDevice()})})}}else{let h=document.querySelectorAll(j.TAGS.SNIPPYLY_REWRITER);h?.length&&h.forEach(E=>{E.remove()});let _=document.querySelectorAll(j.TAGS.VELT_REWRITER);_?.length&&_.forEach(E=>{E.remove()})}}catch(h){this.loggingService.catch("Error in rewriterEnabled$: ",h)}},p=>{this.loggingService.catch("Error in rewriterEnabled$ subscription: ",p)})}getRewriterAnnotations$(){try{return this.rewriterAnnotations$.asObservable()}catch(e){return this.loggingService.catch("Error in getRewriterAnnotations$(): ",e),se([])}}addRewriter(e,i,r){this.loggingService.log("%c[WB] Calling FUNCTION: addRewriter","color: green;");try{let a=this.authService.getUser();if(a)if(a.isReadOnly||a.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add rewriters.");else{let s=new hM;s.from=a,s.color=j.DEFAULT_ANNOTATION_COLOR,i&&(s.targetTextRange=i),r&&(s.rewriterType=r),this.saveRewriterToDb(s)}}catch(a){this.loggingService.catch("Error in RewriterService addRewriter: ",a)}}saveRewriterToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveRewriterToDb","color: green;");try{e?.annotationId||(e.annotationId=Math.random().toString(36).substring(2)+Date.now().toString(36));let i=this.rewriterAnnotations$.getValue();i.push(e),this.rewriterAnnotations$.next(i),this.domService.toggleAnnotationSelection(e)}catch(i){this.loggingService.catch("Error in RewriterService saveRewriterToDb: ",i)}}removeRewriter(e){try{let i=this.rewriterAnnotations$.getValue(),r=i.findIndex(a=>a.annotationId===e.annotationId);r>-1&&(i.splice(r,1),this.rewriterAnnotations$.next(i))}catch(i){this.loggingService.catch("Error in RewriterService removeRewriter: ",i)}}getRewriterOptions(e,i,r){try{if(this.lastOpenAIPromptCalledAt&&Date.now()-this.lastOpenAIPromptCalledAt<1e3)return this.lastOpenAIPromptCalledAt=Date.now(),se([]);this.lastOpenAIPromptCalledAt=Date.now();let a=yr(this.functions,br({url:Xn.cloudFunction.chatgptCompletion,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:20*60*1e3}),s=i?.[0]?.role==="system"?i?.[0]?.content:null;return this.analyticsService.trackEvent(X.Events.Rewriter.REWRITE_PROMPT_SUBMITTED,{isMobileDevice:this.domService.isMobileDevice(),prompt:s,type:e}),_o(a({messages:i,type:e,apiKey:this.configService.getApiKey(),sdkVersion:ga(),sdkType:this.configService.getSdkType()})).pipe(ce(m=>m?.data?m.data:[]))}catch(a){return this.loggingService.catch("Error in RewriterService getRewriterOptions: ",a),se([])}}enableRewriter(){try{this.rewriterEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in RewriterService enableRewriter: ",e)}}disableRewriter(){try{this.rewriterEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in RewriterService disableRewriter: ",e)}}getRewriterEnabled$(){try{return this.rewriterEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in RewriterService getRewriterEnabled$: ",e),se(!1)}}resetRewriter(){try{this.domService.resetSelectedAnnotationsMap(!1,"rewriter"),this.rewriterAnnotations$.next([])}catch(e){this.loggingService.catch("Error in RewriterService resetRewriter: ",e)}}getChatGPTInput(e,i,r=[]){try{let a="";return e&&(a=`
|
|
384
384
|
${a}
|