@veltdev/sdk-staging 4.7.0-beta.3 → 4.7.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/velt.js +4 -4
package/velt.js CHANGED
@@ -1,5 +1,5 @@
1
- var SNIPPYLY_VERSION = '4.7.0-beta.3';
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);
1
+ var SNIPPYLY_VERSION = '4.7.0-beta.5';
2
+ (function(c,E){"use strict";function U(){var e=X.splice(0,X.length);for(ue=0;e.length;)e.shift().call(null,e.shift())}function fe(e,t){for(var n=0,r=e.length;n<r;n++)Le(e[n],t)}function ot(e){for(var t,n=0,r=e.length;n<r;n++)t=e[n],_(t,B[pe(t)])}function de(e){return function(t){Lt(t)&&(Le(t,e),L.length&&fe(t.querySelectorAll(L),e))}}function pe(e){var t=ae.call(e,"is"),n=e.nodeName.toUpperCase(),r=H.call(D,t?J+t.toUpperCase():q+n);return t&&-1<r&&!Ie(n,t)?-1:r}function Ie(e,t){return-1<L.indexOf(e+'[is="'+t+'"]')}function Fe(e){var t=e.currentTarget,n=e.attrChange,r=e.attrName,o=e.target,l=e[Y]||2,a=e[ge]||3;!se||o&&o!==t||!t[C]||r==="style"||e.prevValue===e.newValue&&(e.newValue!==""||n!==l&&n!==a)||t[C](r,n===l?null:e.prevValue,n===a?null:e.newValue)}function Se(e){var t=de(e);return function(n){X.push(t,n.target),ue&&clearTimeout(ue),ue=setTimeout(U,1)}}function he(e){rt&&(rt=!1,e.currentTarget.removeEventListener(Ze,he)),L.length&&fe((e.target||u).querySelectorAll(L),e.detail===v?v:y),R&&at()}function lt(e,t){var n=this;Je.call(n,e,t),Ee.call(n,{target:n})}function Pe(e,t,n){var r=t.apply(e,n),o=pe(r);return-1<o&&_(r,B[o]),n.pop()&&L.length&&ot(r.querySelectorAll(L)),r}function Te(e,t){Tt(e,t),Q?Q.observe(e,gt):(ce&&(e.setAttribute=lt,e[g]=ve(e),e[b](st,Ee)),e[b](N,Fe)),e[x]&&se&&(e.created=!0,e[x](),e.created=!1)}function at(){for(var e,t=0,n=z.length;t<n;t++)e=z[t],P.contains(e)||(n--,z.splice(t--,1),Le(e,v))}function Ve(e){throw new Error("A "+e+" type is already registered")}function Le(e,t){var n,r,o=pe(e);-1<o&&!Mt.call(e,"TEMPLATE")&&(W(e,B[o]),o=0,t!==y||e[y]?t!==v||e[v]||(e[y]=!1,e[v]=!0,r="disconnected",o=1):(e[v]=!1,e[y]=!0,r="connected",o=1,R&&H.call(z,e)<0&&z.push(e)),o&&(n=e[t+O]||e[r+O])&&n.call(e))}function K(){}function Re(e,t,n){var r=n&&n[k]||"",o=t.prototype,l=we(o),a=t.observedAttributes||Ce,m={prototype:l};le(l,x,{value:function(){if(ne)ne=!1;else if(!this[j]){this[j]=!0,new t(this),o[x]&&o[x].call(this);var i=G[re.get(t)];(!Z||i.create.length>1)&&ke(this)}}}),le(l,C,{value:function(i){-1<H.call(a,i)&&o[C]&&o[C].apply(this,arguments)}}),o[Be]&&le(l,ut,{value:o[Be]}),o[je]&&le(l,ct,{value:o[je]}),r&&(m[k]=r),e=e.toUpperCase(),G[e]={constructor:t,create:r?[r,oe(e)]:[e]},re.set(t,e),u[S](e.toLowerCase(),m),Me(e),V[e].r()}function Ue(e){var t=G[e.toUpperCase()];return t&&t.constructor}function _e(e){return typeof e=="string"?e:e&&e.is||""}function ke(e){for(var t,n=e[C],r=n?e.attributes:Ce,o=r.length;o--;)t=r[o],n.call(e,t.name||t.nodeName,null,t.value||t.nodeValue)}function Me(e){return e=e.toUpperCase(),e in V||(V[e]={},V[e].p=new $e(function(t){V[e].r=t})),V[e].p}function xe(){w&&delete c.customElements,I(c,"customElements",{configurable:!0,value:new K}),I(c,"CustomElementRegistry",{configurable:!0,value:K});for(var e=it.get(/^HTML[A-Z]*[a-z]/),t=e.length;t--;(function(n){var r=c[n];if(r){c[n]=function(o){var l,a;return o||(o=this),o[j]||(ne=!0,l=G[re.get(o.constructor)],a=Z&&l.create.length===1,o=a?Reflect.construct(r,Ce,l.constructor):u.createElement.apply(u,l.create),o[j]=!0,ne=!1,a||ke(o)),o},c[n].prototype=r.prototype;try{r.prototype.constructor=c[n]}catch{pt=!0,I(r,j,{value:c[n]})}}})(e[t]));u.createElement=function(n,r){var o=_e(r);return o?Oe.call(this,n,oe(o)):Oe.call(this,n)},tt||(Ne=!0,u[S](""))}var u=c.document,T=c.Object,it=(function(e){var t,n,r,o,l=/^[A-Z]+[a-z]/,a=function(d){var f,h=[];for(f in i)d.test(f)&&h.push(f);return h},m=function(d,f){(f=f.toLowerCase())in i||(i[d]=(i[d]||[]).concat(f),i[f]=i[f.toUpperCase()]=d)},i=(T.create||T)(null),s={};for(n in e)for(o in e[n])for(r=e[n][o],i[o]=r,t=0;t<r.length;t++)i[r[t].toLowerCase()]=i[r[t].toUpperCase()]=o;return s.get=function(d){return typeof d=="string"?i[d]||(l.test(d)?[]:""):a(d)},s.set=function(d,f){return l.test(d)?m(d,f):m(f,d),s},s})({collections:{HTMLAllCollection:["all"],HTMLCollection:["forms"],HTMLFormControlsCollection:["elements"],HTMLOptionsCollection:["options"]},elements:{Element:["element"],HTMLAnchorElement:["a"],HTMLAppletElement:["applet"],HTMLAreaElement:["area"],HTMLAttachmentElement:["attachment"],HTMLAudioElement:["audio"],HTMLBRElement:["br"],HTMLBaseElement:["base"],HTMLBodyElement:["body"],HTMLButtonElement:["button"],HTMLCanvasElement:["canvas"],HTMLContentElement:["content"],HTMLDListElement:["dl"],HTMLDataElement:["data"],HTMLDataListElement:["datalist"],HTMLDetailsElement:["details"],HTMLDialogElement:["dialog"],HTMLDirectoryElement:["dir"],HTMLDivElement:["div"],HTMLDocument:["document"],HTMLElement:["element","abbr","address","article","aside","b","bdi","bdo","cite","code","command","dd","dfn","dt","em","figcaption","figure","footer","header","i","kbd","mark","nav","noscript","rp","rt","ruby","s","samp","section","small","strong","sub","summary","sup","u","var","wbr"],HTMLEmbedElement:["embed"],HTMLFieldSetElement:["fieldset"],HTMLFontElement:["font"],HTMLFormElement:["form"],HTMLFrameElement:["frame"],HTMLFrameSetElement:["frameset"],HTMLHRElement:["hr"],HTMLHeadElement:["head"],HTMLHeadingElement:["h1","h2","h3","h4","h5","h6"],HTMLHtmlElement:["html"],HTMLIFrameElement:["iframe"],HTMLImageElement:["img"],HTMLInputElement:["input"],HTMLKeygenElement:["keygen"],HTMLLIElement:["li"],HTMLLabelElement:["label"],HTMLLegendElement:["legend"],HTMLLinkElement:["link"],HTMLMapElement:["map"],HTMLMarqueeElement:["marquee"],HTMLMediaElement:["media"],HTMLMenuElement:["menu"],HTMLMenuItemElement:["menuitem"],HTMLMetaElement:["meta"],HTMLMeterElement:["meter"],HTMLModElement:["del","ins"],HTMLOListElement:["ol"],HTMLObjectElement:["object"],HTMLOptGroupElement:["optgroup"],HTMLOptionElement:["option"],HTMLOutputElement:["output"],HTMLParagraphElement:["p"],HTMLParamElement:["param"],HTMLPictureElement:["picture"],HTMLPreElement:["pre"],HTMLProgressElement:["progress"],HTMLQuoteElement:["blockquote","q","quote"],HTMLScriptElement:["script"],HTMLSelectElement:["select"],HTMLShadowElement:["shadow"],HTMLSlotElement:["slot"],HTMLSourceElement:["source"],HTMLSpanElement:["span"],HTMLStyleElement:["style"],HTMLTableCaptionElement:["caption"],HTMLTableCellElement:["td","th"],HTMLTableColElement:["col","colgroup"],HTMLTableElement:["table"],HTMLTableRowElement:["tr"],HTMLTableSectionElement:["thead","tbody","tfoot"],HTMLTemplateElement:["template"],HTMLTextAreaElement:["textarea"],HTMLTimeElement:["time"],HTMLTitleElement:["title"],HTMLTrackElement:["track"],HTMLUListElement:["ul"],HTMLUnknownElement:["unknown","vhgroupv","vkeygen"],HTMLVideoElement:["video"]},nodes:{Attr:["node"],Audio:["audio"],CDATASection:["node"],CharacterData:["node"],Comment:["#comment"],Document:["#document"],DocumentFragment:["#document-fragment"],DocumentType:["node"],HTMLDocument:["#document"],Image:["img"],Option:["option"],ProcessingInstruction:["node"],ShadowRoot:["#shadow-root"],Text:["#text"],XMLDocument:["xml"]}});typeof E!="object"&&(E={type:E||"auto"});var X,Ee,$,ve,Q,He,W,_,A,S="registerElement",qe=1e5*c.Math.random()>>0,g="__"+S+qe,b="addEventListener",y="attached",O="Callback",v="detached",k="extends",C="attributeChanged"+O,ut=y+O,Be="connected"+O,je="disconnected"+O,x="created"+O,ct=v+O,Y="ADDITION",ge="REMOVAL",N="DOMAttrModified",Ze="DOMContentLoaded",st="DOMSubtreeModified",q="<",J="=",mt=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,ft=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],D=[],B=[],L="",P=u.documentElement,H=D.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},be=T.prototype,ye=be.hasOwnProperty,ee=be.isPrototypeOf,I=T.defineProperty,Ce=[],te=T.getOwnPropertyDescriptor,Ge=T.getOwnPropertyNames,dt=T.getPrototypeOf,ze=T.setPrototypeOf,Ke=!!T.__proto__,pt=!1,j="__dreCEv1",w=c.customElements,Z=!/^force/.test(E.type)&&!!(w&&w.define&&w.get&&w.whenDefined),Xe=T.create||T,ht=c.Map||function(){var e,t=[],n=[];return{get:function(r){return n[H.call(t,r)]},set:function(r,o){e=H.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},$e=c.Promise||function(e){function t(l){for(r=!0;n.length;)n.shift()(l)}var n=[],r=!1,o={catch:function(){return o},then:function(l){return n.push(l),r&&setTimeout(t,1),o}};return e(t),o},ne=!1,G=Xe(null),V=Xe(null),re=new ht,oe=function(e){return e.toLowerCase()},we=T.create||function e(t){return t?(e.prototype=t,new e):this},Tt=ze||(Ke?function(e,t){return e.__proto__=t,e}:Ge&&te?(function(){function e(t,n){for(var r,o=Ge(n),l=0,a=o.length;l<a;l++)r=o[l],ye.call(t,r)||I(t,r,te(n,r))}return function(t,n){do e(t,n);while((n=dt(n))&&!ee.call(n,t));return t}})():function(e,t){for(var n in t)e[n]=t[n];return e}),F=c.MutationObserver||c.WebKitMutationObserver,Qe=c.HTMLAnchorElement,p=(c.HTMLElement||c.Element||c.Node).prototype,R=!ee.call(p,P),le=R?function(e,t,n){return e[t]=n.value,e}:I,Lt=R?function(e){return e.nodeType===1}:function(e){return ee.call(p,e)},z=R&&[],We=p.attachShadow,Ye=p.cloneNode,Mt=p.closest||function(e){for(var t=this;t&&t.nodeName!==e;)t=t.parentNode;return t},Ae=p.dispatchEvent,ae=p.getAttribute,Et=p.hasAttribute,vt=p.removeAttribute,Je=p.setAttribute,ie=u.createElement,Ht=u.importNode,Oe=ie,gt=F&&{attributes:!0,characterData:!0,attributeOldValue:!0},et=F||function(e){ce=!1,P.removeEventListener(N,et)},ue=0,tt=S in u&&!/^force-all/.test(E.type),nt=!0,Ne=!1,ce=!0,rt=!0,se=!0;if(F&&(A=u.createElement("div"),A.innerHTML="<div><div></div></div>",new F(function(e,t){if(e[0]&&e[0].type=="childList"&&!e[0].removedNodes[0].childNodes.length){A=te(p,"innerHTML");var n=A&&A.set;n&&I(p,"innerHTML",{set:function(r){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,r)}})}t.disconnect(),A=null}).observe(A,{childList:!0,subtree:!0}),A.innerHTML=""),tt||(ze||Ke?(W=function(e,t){ee.call(t,e)||Te(e,t)},_=Te):(W=function(e,t){e[g]||(e[g]=T(!0),Te(e,t))},_=W),R?(ce=!1,(function(){var e=te(p,b),t=e.value,n=function(l){var a=new CustomEvent(N,{bubbles:!0});a.attrName=l,a.prevValue=ae.call(this,l),a.newValue=null,a[ge]=a.attrChange=2,vt.call(this,l),Ae.call(this,a)},r=function(l,a){var m=Et.call(this,l),i=m&&ae.call(this,l),s=new CustomEvent(N,{bubbles:!0});Je.call(this,l,a),s.attrName=l,s.prevValue=m?i:null,s.newValue=a,m?s.MODIFICATION=s.attrChange=1:s[Y]=s.attrChange=0,Ae.call(this,s)},o=function(l){var a,m=l.currentTarget,i=m[g],s=l.propertyName;i.hasOwnProperty(s)&&(i=i[s],a=new CustomEvent(N,{bubbles:!0}),a.attrName=i.name,a.prevValue=i.value||null,a.newValue=i.value=m[s]||null,a.prevValue==null?a[Y]=a.attrChange=0:a.MODIFICATION=a.attrChange=1,Ae.call(m,a))};e.value=function(l,a,m){l===N&&this[C]&&this.setAttribute!==r&&(this[g]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,l,a,m)},I(p,b,e)})()):F||(P[b](N,et),P.setAttribute(g,1),P.removeAttribute(g),ce&&(Ee=function(e){var t,n,r,o=this;if(o===e.target){t=o[g],o[g]=n=ve(o);for(r in n){if(!(r in t))return $(0,o,r,t[r],n[r],Y);if(n[r]!==t[r])return $(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return $(2,o,r,t[r],n[r],ge)}},$=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,Fe(a)},ve=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l<a;l++)t=o[l],(n=t.name)!=="setAttribute"&&(r[n]=t.value);return r})),u[S]=function(e,t){if(n=e.toUpperCase(),nt&&(nt=!1,F?(Q=(function(i,s){function d(f,h){for(var M=0,me=f.length;M<me;h(f[M++]));}return new F(function(f){for(var h,M,me,De=0,bt=f.length;De<bt;De++)h=f[De],h.type==="childList"?(d(h.addedNodes,i),d(h.removedNodes,s)):(M=h.target,se&&M[C]&&h.attributeName!=="style"&&(me=ae.call(M,h.attributeName))!==h.oldValue&&M[C](h.attributeName,h.oldValue,me))})})(de(y),de(v)),He=function(i){return Q.observe(i,{childList:!0,subtree:!0}),i},He(u),We&&(p.attachShadow=function(){return He(We.apply(this,arguments))})):(X=[],u[b]("DOMNodeInserted",Se(y)),u[b]("DOMNodeRemoved",Se(v))),u[b](Ze,he),u[b]("readystatechange",he),u.importNode=function(i,s){switch(i.nodeType){case 1:return Pe(u,Ht,[i,!!s]);case 11:for(var d=u.createDocumentFragment(),f=i.childNodes,h=f.length,M=0;M<h;M++)d.appendChild(u.importNode(f[M],!!s));return d;default:return Ye.call(i,!!s)}},p.cloneNode=function(i){return Pe(this,Ye,[!!i])}),Ne)return Ne=!1;if(-2<H.call(D,J+n)+H.call(D,q+n)&&Ve(e),!mt.test(n)||-1<H.call(ft,n))throw new Error("The type "+e+" is invalid");var n,r,o=function(){return a?u.createElement(m,n):u.createElement(m)},l=t||be,a=ye.call(l,k),m=a?t[k].toUpperCase():n;return a&&-1<H.call(D,q+m)&&Ve(m),r=D.push((a?J:q)+n)-1,L=L.concat(L.length?",":"",a?m+'[is="'+e.toLowerCase()+'"]':m),o.prototype=B[r]=ye.call(l,"prototype")?l.prototype:we(p),L.length&&fe(u.querySelectorAll(L),y),o},u.createElement=Oe=function(e,t){var n=_e(t),r=n?ie.call(u,e,oe(n)):ie.call(u,e),o=""+e,l=H.call(D,(n?J:q)+(n||o).toUpperCase()),a=-1<l;return n&&(r.setAttribute("is",n=n.toLowerCase()),a&&(a=Ie(o.toUpperCase(),n))),se=!u.createElement.innerHTMLHelper,a&&_(r,B[l]),r}),addEventListener("beforeunload",function(){delete u.createElement,delete u.importNode,delete u[S]},!1),K.prototype={constructor:K,define:Z?function(e,t,n){if(n)Re(e,t,n);else{var r=e.toUpperCase();G[r]={constructor:t,create:[r]},re.set(t,r),w.define(e,t)}}:Re,get:Z?function(e){return w.get(e)||Ue(e)}:Ue,whenDefined:Z?function(e){return $e.race([w.whenDefined(e),Me(e)])}:Me},!w||/^force/.test(E.type))xe();else if(!E.noBuiltIn)try{(function(e,t,n){var r=new RegExp(`^<a\\s+is=('|")`+n+"\\1></a>$");if(t[k]="a",e.prototype=we(Qe.prototype),e.prototype.constructor=e,c.customElements.define(n,e,t),!r.test(u.createElement("a",{is:n}).outerHTML)||!r.test(new e().outerHTML))throw t})(function e(){return Reflect.construct(Qe,[],e)},{},"document-register-element-a"+qe)}catch{xe()}if(!E.noBuiltIn)try{if(ie.call(u,"a","a").outerHTML.indexOf("is")<0)throw{}}catch{oe=function(t){return{is:t.toLowerCase()}}}})(window);Promise.allSettled||(Promise.allSettled=function(c){return Promise.all(c.map(function(E){return Promise.resolve(E).then(function(U){return{status:"fulfilled",value:U}}).catch(function(U){return{status:"rejected",reason:U}})}))});
3
3
 
4
4
  var YSe=Object.create;var l4=Object.defineProperty,KSe=Object.defineProperties,ZSe=Object.getOwnPropertyDescriptor,XSe=Object.getOwnPropertyDescriptors,QSe=Object.getOwnPropertyNames,s4=Object.getOwnPropertySymbols,cK=Object.getPrototypeOf,P8=Object.prototype.hasOwnProperty,dK=Object.prototype.propertyIsEnumerable,JSe=Reflect.get;var lK=(i,o,n)=>o in i?l4(i,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[o]=n,E=(i,o)=>{for(var n in o||={})P8.call(o,n)&&lK(i,n,o[n]);if(s4)for(var n of s4(o))dK.call(o,n)&&lK(i,n,o[n]);return i},D=(i,o)=>KSe(i,XSe(o));var yy=(i,o)=>{var n={};for(var e in i)P8.call(i,e)&&o.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&s4)for(var e of s4(i))o.indexOf(e)<0&&dK.call(i,e)&&(n[e]=i[e]);return n};var ebe=(i,o)=>()=>(o||i((o={exports:{}}).exports,o),o.exports),c4=(i,o)=>{for(var n in o)l4(i,n,{get:o[n],enumerable:!0})},tbe=(i,o,n,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of QSe(o))!P8.call(i,t)&&t!==n&&l4(i,t,{get:()=>o[t],enumerable:!(e=ZSe(o,t))||e.enumerable});return i};var mK=(i,o,n)=>(n=i!=null?YSe(cK(i)):{},tbe(o||!i||!i.__esModule?l4(n,"default",{value:i,enumerable:!0}):n,i));var jp=(i,o,n)=>JSe(cK(i),n,o);var Q=(i,o,n)=>new Promise((e,t)=>{var r=c=>{try{s(n.next(c))}catch(p){t(p)}},a=c=>{try{s(n.throw(c))}catch(p){t(p)}},s=c=>c.done?e(c.value):Promise.resolve(c.value).then(r,a);s((n=n.apply(i,o)).next())});var wY=ebe((UOo,DY)=>{"use strict";var Ot={};Ot.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};Ot.localCName=Ot.generateIdentifier();Ot.splitLines=function(i){return i.trim().split(`
5
5
  `).map(o=>o.trim())};Ot.splitSections=function(i){return i.split(`
@@ -204,7 +204,7 @@ This typically indicates that your device does not have a healthy Internet conne
204
204
  <img src="${o||this.thumbnailWithPlayIconUrl||this.thumbnailUrl}" />
205
205
  </a>
206
206
  `}};var tu=class{constructor(){this.type="recorder",this.recordingType="audio",this.mode="floating",this.attachment=null,this.attachments=[],this.pageInfo=new ho}};var p9=class{constructor(){this.type="rewriter",this.rewriterType="copywriter",this.pageInfo=new ho}};var GI=class{constructor(){this.screenWidth=0,this.screenHeight=0,this.screenScrollHeight=0}};var nu=class{constructor(){this.pageInfo=new ho}},WI=(function(i){return i.Start="start",i.End="end",i})(WI||{}),LC=(function(i){return i.Avatar="avatar",i.Label="label",i})(LC||{});var g9=class{constructor(){this.sources=[],this.playerState=new qI}},qI=class{constructor(){this.volume=1}};var YI=class{constructor(){this.to=[],this.resolved=!1,this.type="tag",this.pageInfo=new ho}};var Pp=class{constructor(){this.visibility="private"}};var u9=class{constructor(){this.reactions=[],this.type="reaction",this.pageInfo=new ho,this.isReactionResolverUsed=!1}};var h9=class{};var tl=(function(i){return i.EDITOR="editor",i.VIEWER="viewer",i})(tl||{}),Lo=(function(i){return i.DOES_NOT_EXIST="does_not_exist",i.PERMISSION_DENIED="permission_denied",i.SOMETHING_WENT_WRONG="something_went_wrong",i})(Lo||{});var WW=(function(i){return i.INTERNAL="internal",i.EXTERNAL="external",i})(WW||{}),qW=(function(i){return i.UPDATE_DATA="updateData",i})(qW||{});var Ft=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.analyticsService=t,this.config$=new Ce(null),this.disableLogsConfig$=new Ce({warnings:!0,suppressAll:!1}),this.apiKey$=new Ce(""),this.baseFeatureAllowList=[],this.sf$=new Ce(!1),this.sdkType$=new Ce("core"),this.logsEnabled$=new Ce(!0),this.safeEval$=new Ce(!1),this.encryptionProvider$=new Ce(null);try{this.analyticsService.setConfigService(this),this.sdkType$.subscribe(r=>{this.analyticsService.updateDefaultProperties({sdkType:r})},r=>{this.loggingService.catch("Error in ConfigService sdkType$: ",r)}),this.logsEnabled$.subscribe(r=>{r?this.loggingService.enableLogs():this.loggingService.disableLogs(),nt.logsEnabled=r},r=>{this.loggingService.catch("Error in ConfigService logsEnabled$: ",r)})}catch(r){this.loggingService.catch("Error in ConfigService constructor: ",r)}}initConfig(e){try{e.featureAllowList?.length||(e.featureAllowList=Object.values(Re)),this.baseFeatureAllowList=e.featureAllowList?.slice(),this.config$.next(e)}catch(t){this.loggingService.catch("Error in ConfigService initConfig: ",t)}}setApiKey(e){this.apiKey$.next(e)}getApiKey(){return this.apiKey$.value}getApiKey$(){return this.apiKey$.asObservable()}getConfig(){return this.config$.value}getConfig$(){return this.config$.asObservable()}disableFeatures(e){try{let t=this.config$.value;t&&(e?.length?t.featureAllowList=this.baseFeatureAllowList.filter(r=>!e.includes(r)):t.featureAllowList=this.baseFeatureAllowList.slice()),this.config$.next(t)}catch(t){this.loggingService.catch("Error in ConfigService disableFeatures: ",t)}}setSF(e){try{this.sf$.next(e),this.analyticsService.setSF(e)}catch(t){this.loggingService.catch("Error in ConfigService setSF: ",t)}}getSF(){try{return this.sf$.value}catch(e){return this.loggingService.catch("Error in ConfigService getSF: ",e),!1}}getSF$(){try{return this.sf$.asObservable().pipe(Ct(Xt))}catch(e){return this.loggingService.catch("Error in ConfigService getSF$: ",e),le(!1)}}setSdkType(e){try{this.sdkType$.next(e)}catch(t){this.loggingService.catch("Error in ConfigService setSdkType: ",t)}}getSdkType(){try{return this.sdkType$.value}catch(e){return this.loggingService.catch("Error in ConfigService getSdkType: ",e),"core"}}getSdkType$(){try{return this.sdkType$.asObservable()}catch(e){return this.loggingService.catch("Error in ConfigService getSdkType$: ",e),le("core")}}enableLogs(){try{if(this.logsEnabled$.value===!0)return;this.logsEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ConfigService enableLogs: ",e)}}disableLogs(e){try{e&&this.disableLogsConfig$.next({warnings:e.warnings??!0,suppressAll:e.suppressAll??!1}),e?.warnings!==!1&&this.logsEnabled$.next(!1)}catch(t){this.loggingService.catch("Error in ConfigService disableLogs: ",t)}}getDisableLogsConfig(){return this.disableLogsConfig$.value}getDisableLogsConfig$(){return this.disableLogsConfig$.asObservable()}getApiProxyDomain(){try{return this.config$.value?.apiProxyDomain}catch(e){this.loggingService.catch("Error in ConfigService getApiProxyDomain: ",e);return}}enableSafeEval(){try{this.safeEval$.next(!0)}catch(e){this.loggingService.catch("Error in ConfigService enableSafeEval: ",e)}}disableSafeEval(){try{this.safeEval$.next(!1)}catch(e){this.loggingService.catch("Error in ConfigService disableSafeEval: ",e)}}getSafeEval(){try{return this.safeEval$.value}catch(e){return this.loggingService.catch("Error in ConfigService getSafeEval: ",e),!1}}getSafeEval$(){try{return this.safeEval$.asObservable()}catch(e){return this.loggingService.catch("Error in ConfigService getSafeEval$: ",e),le(!1)}}setEncryptionProvider(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setEncryptionProvider","color: green;"),this.encryptionProvider$.next(e)}catch(t){this.loggingService.catch("Error in ConfigService setEncryptionProvider: ",t)}}getEncryptionProvider(){try{return this.encryptionProvider$.value}catch(e){return this.loggingService.catch("Error in ConfigService getEncryptionProvider: ",e),null}}getEncryptionProvider$(){try{return this.encryptionProvider$.asObservable()}catch(e){return this.loggingService.catch("Error in ConfigService getEncryptionProvider$: ",e),le(null)}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var bpe=(()=>{let o=class o{constructor(e){this.loggingService=e,this.initLocalStorageData()}initLocalStorageData(){this.loggingService.log("%c[WB] Calling FUNCTION: initLocalStorageData","color: green;"),this.getLocalStorageData(),this.getSessionStorageData()}getLocalStorageData(){this.loggingService.log("%c[WB] Calling FUNCTION: getLocalStorageData","color: green;");try{let e=localStorage?.getItem(U.LOCALSTORAGE_DATA_ID);if(e)return JSON.parse(e);{let t=new wf;return this.setLocalStorageData(t),t}}catch(e){return this.loggingService.catch("Error in getLocalStorageData:",e),new wf}}setLocalStorageData(e){this.loggingService.log("%c[WB] Calling FUNCTION: setLocalStorageData","color: green;");try{if(e){let t=JSON.stringify(e);localStorage?.setItem(U.LOCALSTORAGE_DATA_ID,t)}}catch(t){this.loggingService.catch("Error in setLocalStorageData:",t)}}deleteLocalStorageData(){this.loggingService.log("%c[WB] Calling FUNCTION: deleteLocalStorageData","color: green;"),localStorage?.removeItem(U.LOCALSTORAGE_DATA_ID)}getSessionStorageData(){this.loggingService.log("%c[WB] Calling FUNCTION: getSessionStorageData","color: green;");try{let e=sessionStorage?.getItem(U.LOCALSTORAGE_DATA_ID);if(e)return JSON.parse(e);{let t=new wf;return this.setSessionStorageData(t),t}}catch(e){return this.loggingService.catch("Error in getSessionStorageData:",e),new wf}}setSessionStorageData(e){this.loggingService.log("%c[WB] Calling FUNCTION: setSessionStorageData","color: green;");try{if(e){let t=JSON.stringify(e);sessionStorage?.setItem(U.LOCALSTORAGE_DATA_ID,t)}}catch(t){this.loggingService.catch("Error in setSessionStorageData:",t)}}deleteSessionStorageData(){this.loggingService.log("%c[WB] Calling FUNCTION: deleteSessionStorageData","color: green;");try{sessionStorage?.removeItem(U.LOCALSTORAGE_DATA_ID)}catch(e){this.loggingService.catch("Error in deleteSessionStorageData:",e)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ym=(()=>{let o=class o{constructor(e,t){this.localStorageService=e,this.loggingService=t,this.avatarList=[{userId:"1",name:"Bear",photoUrl:"https://snippyly.com/assets/avatars/avatar-bear.svg",type:"anonymous"},{userId:"2",name:"Beaver",photoUrl:"https://snippyly.com/assets/avatars/avatar-beaver.svg",type:"anonymous"},{userId:"3",name:"Bunny",photoUrl:"https://snippyly.com/assets/avatars/avatar-bunny.svg",type:"anonymous"},{userId:"4",name:"Cat",photoUrl:"https://snippyly.com/assets/avatars/avatar-cat.svg",type:"anonymous"},{userId:"5",name:"Cow",photoUrl:"https://snippyly.com/assets/avatars/avatar-cow.svg",type:"anonymous"},{userId:"6",name:"Dinosaur",photoUrl:"https://snippyly.com/assets/avatars/avatar-dinosaur.svg",type:"anonymous"},{userId:"7",name:"Elephant",photoUrl:"https://snippyly.com/assets/avatars/avatar-elephant.svg",type:"anonymous"},{userId:"8",name:"Monkey",photoUrl:"https://snippyly.com/assets/avatars/avatar-monkey.svg",type:"anonymous"},{userId:"9",name:"Hedgehog",photoUrl:"https://snippyly.com/assets/avatars/avatar-hedgehog.svg",type:"anonymous"},{userId:"10",name:"Hippo",photoUrl:"https://snippyly.com/assets/avatars/avatar-hippo.svg",type:"anonymous"},{userId:"11",name:"Horse",photoUrl:"https://snippyly.com/assets/avatars/avatar-horse.svg",type:"anonymous"},{userId:"12",name:"Kitten",photoUrl:"https://snippyly.com/assets/avatars/avatar-kitten.svg",type:"anonymous"},{userId:"13",name:"Octopus",photoUrl:"https://snippyly.com/assets/avatars/avatar-octopus.svg",type:"anonymous"},{userId:"14",name:"Oink",photoUrl:"https://snippyly.com/assets/avatars/avatar-oink.svg",type:"anonymous"},{userId:"15",name:"Panda",photoUrl:"https://snippyly.com/assets/avatars/avatar-panda.svg",type:"anonymous"},{userId:"16",name:"Penguin",photoUrl:"https://snippyly.com/assets/avatars/avatar-penguin.svg",type:"anonymous"},{userId:"17",name:"Rabbit",photoUrl:"https://snippyly.com/assets/avatars/avatar-rabbit.svg",type:"anonymous"},{userId:"18",name:"Tiger",photoUrl:"https://snippyly.com/assets/avatars/avatar-tiger.svg",type:"anonymous"}],this.loggingService.log("%c[WB] Creating SERVICE AvatarService","color: blue;")}getSessionAvatar(){this.loggingService.log("%c[WB] Calling FUNCTION: getSessionAvatar","color: green;");try{let e=new zo,t=this.localStorageService.getSessionStorageData();if(t.snippylyAvatar)e=t.snippylyAvatar;else{let r=this.generateUserAvatar();t.snippylyAvatar=r,this.localStorageService.setSessionStorageData(t)}return e}catch(e){return this.loggingService.catch("Error in getSessionAvatar:",e),new zo}}generateUserAvatar(){this.loggingService.log("%c[WB] Calling FUNCTION: generateUserAvatar","color: green;");try{let e=Math.floor(Math.random()*this.avatarList.length),t=this.avatarList[e];return t.color=this.generateUserColor(),t}catch(e){return this.loggingService.catch("Error in generateUserAvatar:",e),this.avatarList[0]}}generateUserColor(e){this.loggingService.log("%c[WB] Calling FUNCTION: generateUserColor","color: green;");try{if(e)return U.AVATAR_COLOR_LIST[e%U.AVATAR_COLOR_LIST.length];let t=Math.floor(Math.random()*U.AVATAR_COLOR_LIST.length);return U.AVATAR_COLOR_LIST[t]}catch(t){return this.loggingService.catch("Error in generateUserColor:",t),""}}generateUserImage(){this.loggingService.log("%c[WB] Calling FUNCTION: generateUserImage","color: green;");try{return this.getSessionAvatar().photoUrl}catch(e){return this.loggingService.catch("Error in generateUserImage:",e),""}}};o.\u0275fac=function(t){return new(t||o)(ee(bpe),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ni=(()=>{let o=class o{constructor(e){this.loggingService=e,this.actionSubjects=new Map,this.subscriptions=[]}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Xe),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in CoreActionsService triggerAction: ",r)}}onAction(e){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Xe);let t=this.actionSubjects.get(e);return t?t.asObservable():le(null)}catch(t){return this.loggingService.catch("Error in CoreActionsService onAction: ",t),le(null)}}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var{entries:Ppe,setPrototypeOf:Ipe,isFrozen:WNe,getPrototypeOf:qNe,getOwnPropertyDescriptor:YNe}=Object,{freeze:ws,seal:uc,create:eq}=Object,{apply:tq,construct:nq}=typeof Reflect<"u"&&Reflect;ws||(ws=function(o){return o});uc||(uc=function(o){return o});tq||(tq=function(o,n){for(var e=arguments.length,t=new Array(e>2?e-2:0),r=2;r<e;r++)t[r-2]=arguments[r];return o.apply(n,t)});nq||(nq=function(o){for(var n=arguments.length,e=new Array(n>1?n-1:0),t=1;t<n;t++)e[t-1]=arguments[t];return new o(...e)});var f9=Os(Array.prototype.forEach),KNe=Os(Array.prototype.lastIndexOf),Epe=Os(Array.prototype.pop),ZI=Os(Array.prototype.push),ZNe=Os(Array.prototype.splice),C9=Os(String.prototype.toLowerCase),YW=Os(String.prototype.toString),KW=Os(String.prototype.match),XI=Os(String.prototype.replace),XNe=Os(String.prototype.indexOf),QNe=Os(String.prototype.trim),yd=Os(Object.prototype.hasOwnProperty),Ds=Os(RegExp.prototype.test),QI=JNe(TypeError);function Os(i){return function(o){o instanceof RegExp&&(o.lastIndex=0);for(var n=arguments.length,e=new Array(n>1?n-1:0),t=1;t<n;t++)e[t-1]=arguments[t];return tq(i,o,e)}}function JNe(i){return function(){for(var o=arguments.length,n=new Array(o),e=0;e<o;e++)n[e]=arguments[e];return nq(i,n)}}function fi(i,o){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:C9;Ipe&&Ipe(i,null);let e=o.length;for(;e--;){let t=o[e];if(typeof t=="string"){let r=n(t);r!==t&&(WNe(o)||(o[e]=r),t=r)}i[t]=!0}return i}function eFe(i){for(let o=0;o<i.length;o++)yd(i,o)||(i[o]=null);return i}function Mp(i){let o=eq(null);for(let[n,e]of Ppe(i))yd(i,n)&&(Array.isArray(e)?o[n]=eFe(e):e&&typeof e=="object"&&e.constructor===Object?o[n]=Mp(e):o[n]=e);return o}function JI(i,o){for(;i!==null;){let e=YNe(i,o);if(e){if(e.get)return Os(e.get);if(typeof e.value=="function")return Os(e.value)}i=qNe(i)}function n(){return null}return n}var xpe=ws(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ZW=ws(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),XW=ws(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),tFe=ws(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),QW=ws(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),nFe=ws(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Tpe=ws(["#text"]),Dpe=ws(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),JW=ws(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),wpe=ws(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),v9=ws(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),iFe=uc(/\{\{[\w\W]*|[\w\W]*\}\}/gm),oFe=uc(/<%[\w\W]*|[\w\W]*%>/gm),rFe=uc(/\$\{[\w\W]*/gm),aFe=uc(/^data-[\-\w.\u00B7-\uFFFF]+$/),sFe=uc(/^aria-[\-\w]+$/),Mpe=uc(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lFe=uc(/^(?:\w+script|data):/i),cFe=uc(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kpe=uc(/^html$/i),dFe=uc(/^[a-z][.\w]*(-[.\w]+)+$/i),Ope=Object.freeze({__proto__:null,ARIA_ATTR:sFe,ATTR_WHITESPACE:cFe,CUSTOM_ELEMENT:dFe,DATA_ATTR:aFe,DOCTYPE_NAME:kpe,ERB_EXPR:oFe,IS_ALLOWED_URI:Mpe,IS_SCRIPT_OR_DATA:lFe,MUSTACHE_EXPR:iFe,TMPLIT_EXPR:rFe}),e2={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mFe=function(){return typeof window>"u"?null:window},pFe=function(o,n){if(typeof o!="object"||typeof o.createPolicy!="function")return null;let e=null,t="data-tt-policy-suffix";n&&n.hasAttribute(t)&&(e=n.getAttribute(t));let r="dompurify"+(e?"#"+e:"");try{return o.createPolicy(r,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Ape=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rpe(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mFe(),o=cn=>Rpe(cn);if(o.version="3.3.0",o.removed=[],!i||!i.document||i.document.nodeType!==e2.document||!i.Element)return o.isSupported=!1,o;let{document:n}=i,e=n,t=e.currentScript,{DocumentFragment:r,HTMLTemplateElement:a,Node:s,Element:c,NodeFilter:p,NamedNodeMap:g=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:f,DOMParser:I,trustedTypes:T}=i,B=c.prototype,z=JI(B,"cloneNode"),G=JI(B,"remove"),J=JI(B,"nextSibling"),ne=JI(B,"childNodes"),ve=JI(B,"parentNode");if(typeof a=="function"){let cn=n.createElement("template");cn.content&&cn.content.ownerDocument&&(n=cn.content.ownerDocument)}let ye,Ne="",{implementation:Ve,createNodeIterator:Ie,createDocumentFragment:be,getElementsByTagName:Ae}=n,{importNode:_e}=e,fe=Ape();o.isSupported=typeof Ppe=="function"&&typeof ve=="function"&&Ve&&Ve.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:Oe,ERB_EXPR:Fe,TMPLIT_EXPR:ao,DATA_ATTR:bt,ARIA_ATTR:It,IS_SCRIPT_OR_DATA:yt,ATTR_WHITESPACE:Lt,CUSTOM_ELEMENT:Yt}=Ope,{IS_ALLOWED_URI:zt}=Ope,tn=null,Ii=fi({},[...xpe,...ZW,...XW,...QW,...Tpe]),nn=null,ti=fi({},[...Dpe,...JW,...wpe,...v9]),Ei=Object.seal(eq(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Rm=null,Ao=null,Ua=Object.seal(eq(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ta=!0,cl=!0,Ec=!1,Uf=!0,wd=!1,Fp=!0,xc=!1,jf=!1,$f=!1,Lp=!1,Ou=!1,Au=!1,Hf=!0,ny=!1,I8="user-content-",Pu=!0,Nm=!1,Od={},Jo=null,ra=fi({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Mu=null,iy=fi({},["audio","video","img","source","image","track"]),zf=null,GA=fi({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ad="http://www.w3.org/1998/Math/MathML",ku="http://www.w3.org/2000/svg",Vl="http://www.w3.org/1999/xhtml",Pd=Vl,oy=!1,ry=null,ay=fi({},[Ad,ku,Vl],YW),Ru=fi({},["mi","mo","mn","ms","mtext"]),Nu=fi({},["annotation-xml"]),Fu=fi({},["title","style","font","a","script"]),Fm=null,sy=["application/xhtml+xml","text/html"],Lm="text/html",fr=null,Tc=null,WA=n.createElement("form"),Bp=function(Ue){return Ue instanceof RegExp||Ue instanceof Function},Gf=function(){let Ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Tc&&Tc===Ue)){if((!Ue||typeof Ue!="object")&&(Ue={}),Ue=Mp(Ue),Fm=sy.indexOf(Ue.PARSER_MEDIA_TYPE)===-1?Lm:Ue.PARSER_MEDIA_TYPE,fr=Fm==="application/xhtml+xml"?YW:C9,tn=yd(Ue,"ALLOWED_TAGS")?fi({},Ue.ALLOWED_TAGS,fr):Ii,nn=yd(Ue,"ALLOWED_ATTR")?fi({},Ue.ALLOWED_ATTR,fr):ti,ry=yd(Ue,"ALLOWED_NAMESPACES")?fi({},Ue.ALLOWED_NAMESPACES,YW):ay,zf=yd(Ue,"ADD_URI_SAFE_ATTR")?fi(Mp(GA),Ue.ADD_URI_SAFE_ATTR,fr):GA,Mu=yd(Ue,"ADD_DATA_URI_TAGS")?fi(Mp(iy),Ue.ADD_DATA_URI_TAGS,fr):iy,Jo=yd(Ue,"FORBID_CONTENTS")?fi({},Ue.FORBID_CONTENTS,fr):ra,Rm=yd(Ue,"FORBID_TAGS")?fi({},Ue.FORBID_TAGS,fr):Mp({}),Ao=yd(Ue,"FORBID_ATTR")?fi({},Ue.FORBID_ATTR,fr):Mp({}),Od=yd(Ue,"USE_PROFILES")?Ue.USE_PROFILES:!1,Ta=Ue.ALLOW_ARIA_ATTR!==!1,cl=Ue.ALLOW_DATA_ATTR!==!1,Ec=Ue.ALLOW_UNKNOWN_PROTOCOLS||!1,Uf=Ue.ALLOW_SELF_CLOSE_IN_ATTR!==!1,wd=Ue.SAFE_FOR_TEMPLATES||!1,Fp=Ue.SAFE_FOR_XML!==!1,xc=Ue.WHOLE_DOCUMENT||!1,Lp=Ue.RETURN_DOM||!1,Ou=Ue.RETURN_DOM_FRAGMENT||!1,Au=Ue.RETURN_TRUSTED_TYPE||!1,$f=Ue.FORCE_BODY||!1,Hf=Ue.SANITIZE_DOM!==!1,ny=Ue.SANITIZE_NAMED_PROPS||!1,Pu=Ue.KEEP_CONTENT!==!1,Nm=Ue.IN_PLACE||!1,zt=Ue.ALLOWED_URI_REGEXP||Mpe,Pd=Ue.NAMESPACE||Vl,Ru=Ue.MATHML_TEXT_INTEGRATION_POINTS||Ru,Nu=Ue.HTML_INTEGRATION_POINTS||Nu,Ei=Ue.CUSTOM_ELEMENT_HANDLING||{},Ue.CUSTOM_ELEMENT_HANDLING&&Bp(Ue.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ei.tagNameCheck=Ue.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Ue.CUSTOM_ELEMENT_HANDLING&&Bp(Ue.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ei.attributeNameCheck=Ue.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Ue.CUSTOM_ELEMENT_HANDLING&&typeof Ue.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Ei.allowCustomizedBuiltInElements=Ue.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),wd&&(cl=!1),Ou&&(Lp=!0),Od&&(tn=fi({},Tpe),nn=[],Od.html===!0&&(fi(tn,xpe),fi(nn,Dpe)),Od.svg===!0&&(fi(tn,ZW),fi(nn,JW),fi(nn,v9)),Od.svgFilters===!0&&(fi(tn,XW),fi(nn,JW),fi(nn,v9)),Od.mathMl===!0&&(fi(tn,QW),fi(nn,wpe),fi(nn,v9))),Ue.ADD_TAGS&&(typeof Ue.ADD_TAGS=="function"?Ua.tagCheck=Ue.ADD_TAGS:(tn===Ii&&(tn=Mp(tn)),fi(tn,Ue.ADD_TAGS,fr))),Ue.ADD_ATTR&&(typeof Ue.ADD_ATTR=="function"?Ua.attributeCheck=Ue.ADD_ATTR:(nn===ti&&(nn=Mp(nn)),fi(nn,Ue.ADD_ATTR,fr))),Ue.ADD_URI_SAFE_ATTR&&fi(zf,Ue.ADD_URI_SAFE_ATTR,fr),Ue.FORBID_CONTENTS&&(Jo===ra&&(Jo=Mp(Jo)),fi(Jo,Ue.FORBID_CONTENTS,fr)),Pu&&(tn["#text"]=!0),xc&&fi(tn,["html","head","body"]),tn.table&&(fi(tn,["tbody"]),delete Rm.tbody),Ue.TRUSTED_TYPES_POLICY){if(typeof Ue.TRUSTED_TYPES_POLICY.createHTML!="function")throw QI('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Ue.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw QI('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ye=Ue.TRUSTED_TYPES_POLICY,Ne=ye.createHTML("")}else ye===void 0&&(ye=pFe(T,t)),ye!==null&&typeof Ne=="string"&&(Ne=ye.createHTML(""));ws&&ws(Ue),Tc=Ue}},aa=fi({},[...ZW,...XW,...tFe]),ly=fi({},[...QW,...nFe]),Lu=function(Ue){let Mt=ve(Ue);(!Mt||!Mt.tagName)&&(Mt={namespaceURI:Pd,tagName:"template"});let Jt=C9(Ue.tagName),Co=C9(Mt.tagName);return ry[Ue.namespaceURI]?Ue.namespaceURI===ku?Mt.namespaceURI===Vl?Jt==="svg":Mt.namespaceURI===Ad?Jt==="svg"&&(Co==="annotation-xml"||Ru[Co]):!!aa[Jt]:Ue.namespaceURI===Ad?Mt.namespaceURI===Vl?Jt==="math":Mt.namespaceURI===ku?Jt==="math"&&Nu[Co]:!!ly[Jt]:Ue.namespaceURI===Vl?Mt.namespaceURI===ku&&!Nu[Co]||Mt.namespaceURI===Ad&&!Ru[Co]?!1:!ly[Jt]&&(Fu[Jt]||!aa[Jt]):!!(Fm==="application/xhtml+xml"&&ry[Ue.namespaceURI]):!1},ja=function(Ue){ZI(o.removed,{element:Ue});try{ve(Ue).removeChild(Ue)}catch{G(Ue)}},Bm=function(Ue,Mt){try{ZI(o.removed,{attribute:Mt.getAttributeNode(Ue),from:Mt})}catch{ZI(o.removed,{attribute:null,from:Mt})}if(Mt.removeAttribute(Ue),Ue==="is")if(Lp||Ou)try{ja(Mt)}catch{}else try{Mt.setAttribute(Ue,"")}catch{}},qA=function(Ue){let Mt=null,Jt=null;if($f)Ue="<remove></remove>"+Ue;else{let Bo=KW(Ue,/^[\r\n\t ]+/);Jt=Bo&&Bo[0]}Fm==="application/xhtml+xml"&&Pd===Vl&&(Ue='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Ue+"</body></html>");let Co=ye?ye.createHTML(Ue):Ue;if(Pd===Vl)try{Mt=new I().parseFromString(Co,Fm)}catch{}if(!Mt||!Mt.documentElement){Mt=Ve.createDocument(Pd,"template",null);try{Mt.documentElement.innerHTML=oy?Ne:Co}catch{}}let sa=Mt.body||Mt.documentElement;return Ue&&Jt&&sa.insertBefore(n.createTextNode(Jt),sa.childNodes[0]||null),Pd===Vl?Ae.call(Mt,xc?"html":"body")[0]:xc?Mt.documentElement:sa},Vm=function(Ue){return Ie.call(Ue.ownerDocument||Ue,Ue,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},cy=function(Ue){return Ue instanceof f&&(typeof Ue.nodeName!="string"||typeof Ue.textContent!="string"||typeof Ue.removeChild!="function"||!(Ue.attributes instanceof g)||typeof Ue.removeAttribute!="function"||typeof Ue.setAttribute!="function"||typeof Ue.namespaceURI!="string"||typeof Ue.insertBefore!="function"||typeof Ue.hasChildNodes!="function")},YA=function(Ue){return typeof s=="function"&&Ue instanceof s};function Fs(cn,Ue,Mt){f9(cn,Jt=>{Jt.call(o,Ue,Mt,Tc)})}let dy=function(Ue){let Mt=null;if(Fs(fe.beforeSanitizeElements,Ue,null),cy(Ue))return ja(Ue),!0;let Jt=fr(Ue.nodeName);if(Fs(fe.uponSanitizeElement,Ue,{tagName:Jt,allowedTags:tn}),Fp&&Ue.hasChildNodes()&&!YA(Ue.firstElementChild)&&Ds(/<[/\w!]/g,Ue.innerHTML)&&Ds(/<[/\w!]/g,Ue.textContent)||Ue.nodeType===e2.progressingInstruction||Fp&&Ue.nodeType===e2.comment&&Ds(/<[/\w]/g,Ue.data))return ja(Ue),!0;if(!(Ua.tagCheck instanceof Function&&Ua.tagCheck(Jt))&&(!tn[Jt]||Rm[Jt])){if(!Rm[Jt]&&Bu(Jt)&&(Ei.tagNameCheck instanceof RegExp&&Ds(Ei.tagNameCheck,Jt)||Ei.tagNameCheck instanceof Function&&Ei.tagNameCheck(Jt)))return!1;if(Pu&&!Jo[Jt]){let Co=ve(Ue)||Ue.parentNode,sa=ne(Ue)||Ue.childNodes;if(sa&&Co){let Bo=sa.length;for(let Da=Bo-1;Da>=0;--Da){let dl=z(sa[Da],!0);dl.__removalCount=(Ue.__removalCount||0)+1,Co.insertBefore(dl,J(Ue))}}}return ja(Ue),!0}return Ue instanceof c&&!Lu(Ue)||(Jt==="noscript"||Jt==="noembed"||Jt==="noframes")&&Ds(/<\/no(script|embed|frames)/i,Ue.innerHTML)?(ja(Ue),!0):(wd&&Ue.nodeType===e2.text&&(Mt=Ue.textContent,f9([Oe,Fe,ao],Co=>{Mt=XI(Mt,Co," ")}),Ue.textContent!==Mt&&(ZI(o.removed,{element:Ue.cloneNode()}),Ue.textContent=Mt)),Fs(fe.afterSanitizeElements,Ue,null),!1)},Wf=function(Ue,Mt,Jt){if(Hf&&(Mt==="id"||Mt==="name")&&(Jt in n||Jt in WA))return!1;if(!(cl&&!Ao[Mt]&&Ds(bt,Mt))){if(!(Ta&&Ds(It,Mt))){if(!(Ua.attributeCheck instanceof Function&&Ua.attributeCheck(Mt,Ue))){if(!nn[Mt]||Ao[Mt]){if(!(Bu(Ue)&&(Ei.tagNameCheck instanceof RegExp&&Ds(Ei.tagNameCheck,Ue)||Ei.tagNameCheck instanceof Function&&Ei.tagNameCheck(Ue))&&(Ei.attributeNameCheck instanceof RegExp&&Ds(Ei.attributeNameCheck,Mt)||Ei.attributeNameCheck instanceof Function&&Ei.attributeNameCheck(Mt,Ue))||Mt==="is"&&Ei.allowCustomizedBuiltInElements&&(Ei.tagNameCheck instanceof RegExp&&Ds(Ei.tagNameCheck,Jt)||Ei.tagNameCheck instanceof Function&&Ei.tagNameCheck(Jt))))return!1}else if(!zf[Mt]){if(!Ds(zt,XI(Jt,Lt,""))){if(!((Mt==="src"||Mt==="xlink:href"||Mt==="href")&&Ue!=="script"&&XNe(Jt,"data:")===0&&Mu[Ue])){if(!(Ec&&!Ds(yt,XI(Jt,Lt,"")))){if(Jt)return!1}}}}}}}return!0},Bu=function(Ue){return Ue!=="annotation-xml"&&KW(Ue,Yt)},Dc=function(Ue){Fs(fe.beforeSanitizeAttributes,Ue,null);let{attributes:Mt}=Ue;if(!Mt||cy(Ue))return;let Jt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:nn,forceKeepAttr:void 0},Co=Mt.length;for(;Co--;){let sa=Mt[Co],{name:Bo,namespaceURI:Da,value:dl}=sa,Ul=fr(Bo),wc=dl,vr=Bo==="value"?wc:QNe(wc);if(Jt.attrName=Ul,Jt.attrValue=vr,Jt.keepAttr=!0,Jt.forceKeepAttr=void 0,Fs(fe.uponSanitizeAttribute,Ue,Jt),vr=Jt.attrValue,ny&&(Ul==="id"||Ul==="name")&&(Bm(Bo,Ue),vr=I8+vr),Fp&&Ds(/((--!?|])>)|<\/(style|title|textarea)/i,vr)){Bm(Bo,Ue);continue}if(Ul==="attributename"&&KW(vr,"href")){Bm(Bo,Ue);continue}if(Jt.forceKeepAttr)continue;if(!Jt.keepAttr){Bm(Bo,Ue);continue}if(!Uf&&Ds(/\/>/i,vr)){Bm(Bo,Ue);continue}wd&&f9([Oe,Fe,ao],my=>{vr=XI(vr,my," ")});let ZA=fr(Ue.nodeName);if(!Wf(ZA,Ul,vr)){Bm(Bo,Ue);continue}if(ye&&typeof T=="object"&&typeof T.getAttributeType=="function"&&!Da)switch(T.getAttributeType(ZA,Ul)){case"TrustedHTML":{vr=ye.createHTML(vr);break}case"TrustedScriptURL":{vr=ye.createScriptURL(vr);break}}if(vr!==wc)try{Da?Ue.setAttributeNS(Da,Bo,vr):Ue.setAttribute(Bo,vr),cy(Ue)?ja(Ue):Epe(o.removed)}catch{Bm(Bo,Ue)}}Fs(fe.afterSanitizeAttributes,Ue,null)},KA=function cn(Ue){let Mt=null,Jt=Vm(Ue);for(Fs(fe.beforeSanitizeShadowDOM,Ue,null);Mt=Jt.nextNode();)Fs(fe.uponSanitizeShadowNode,Mt,null),dy(Mt),Dc(Mt),Mt.content instanceof r&&cn(Mt.content);Fs(fe.afterSanitizeShadowDOM,Ue,null)};return o.sanitize=function(cn){let Ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Mt=null,Jt=null,Co=null,sa=null;if(oy=!cn,oy&&(cn="<!-->"),typeof cn!="string"&&!YA(cn))if(typeof cn.toString=="function"){if(cn=cn.toString(),typeof cn!="string")throw QI("dirty is not a string, aborting")}else throw QI("toString is not a function");if(!o.isSupported)return cn;if(jf||Gf(Ue),o.removed=[],typeof cn=="string"&&(Nm=!1),Nm){if(cn.nodeName){let dl=fr(cn.nodeName);if(!tn[dl]||Rm[dl])throw QI("root node is forbidden and cannot be sanitized in-place")}}else if(cn instanceof s)Mt=qA("<!---->"),Jt=Mt.ownerDocument.importNode(cn,!0),Jt.nodeType===e2.element&&Jt.nodeName==="BODY"||Jt.nodeName==="HTML"?Mt=Jt:Mt.appendChild(Jt);else{if(!Lp&&!wd&&!xc&&cn.indexOf("<")===-1)return ye&&Au?ye.createHTML(cn):cn;if(Mt=qA(cn),!Mt)return Lp?null:Au?Ne:""}Mt&&$f&&ja(Mt.firstChild);let Bo=Vm(Nm?cn:Mt);for(;Co=Bo.nextNode();)dy(Co),Dc(Co),Co.content instanceof r&&KA(Co.content);if(Nm)return cn;if(Lp){if(Ou)for(sa=be.call(Mt.ownerDocument);Mt.firstChild;)sa.appendChild(Mt.firstChild);else sa=Mt;return(nn.shadowroot||nn.shadowrootmode)&&(sa=_e.call(e,sa,!0)),sa}let Da=xc?Mt.outerHTML:Mt.innerHTML;return xc&&tn["!doctype"]&&Mt.ownerDocument&&Mt.ownerDocument.doctype&&Mt.ownerDocument.doctype.name&&Ds(kpe,Mt.ownerDocument.doctype.name)&&(Da="<!DOCTYPE "+Mt.ownerDocument.doctype.name+`>
207
- `+Da),wd&&f9([Oe,Fe,ao],dl=>{Da=XI(Da,dl," ")}),ye&&Au?ye.createHTML(Da):Da},o.setConfig=function(){let cn=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Gf(cn),jf=!0},o.clearConfig=function(){Tc=null,jf=!1},o.isValidAttribute=function(cn,Ue,Mt){Tc||Gf({});let Jt=fr(cn),Co=fr(Ue);return Wf(Jt,Co,Mt)},o.addHook=function(cn,Ue){typeof Ue=="function"&&ZI(fe[cn],Ue)},o.removeHook=function(cn,Ue){if(Ue!==void 0){let Mt=KNe(fe[cn],Ue);return Mt===-1?void 0:ZNe(fe[cn],Mt,1)[0]}return Epe(fe[cn])},o.removeHooks=function(cn){fe[cn]=[]},o.removeAllHooks=function(){fe=Ape()},o}var t2=Rpe();var Npe={ADD_TAGS:["velt-skeleton-loader"],ADD_ATTR:["border-radius","target"]},Be=(()=>{let o=class o{constructor(e,t,r,a){this.analyticsService=e,this.rendererFactory2=t,this.loggingService=r,this.sanitizer=a,this.isVideoEditorHandlingDelete=!1,this.pageScrollHeight=0,this.enableRectSelectionSubject$=new Ce(!1),this.enableRectSelection$=this.enableRectSelectionSubject$.asObservable(),this.scrollableElementsIds$=new Ce([]),this.mousedown=!1,this.windowMouseDown$=new Xe,this.windowPointerMove$=new Ce(null),this.windowPointerUp$=new Ce(null),this.documentSelectionChange$=new Ce(null),this.windowClick$=new Ce(null),this.windowScroll$=new Ce(null),this.windowResize$=new Ce(null),this.windowKeyupBackspace$=new Ce(null),this.windowKeyupDelete$=new Ce(null),this.windowKeyupEsc$=new Ce(null),this.windowPopState$=new Ce(null),this.documentClick$=new Ce(null),this.documentClickSubject$=new Xe,this.documentFocus$=new Ce(null),this.windowKeydownShift$=new Ce(null),this.windowKeyupShift$=new Ce(null),this.mutation$=new Ce(null),this.childListMutation$=new Ce(null),this.networkStatus$=new Ce(!1),this.xpathCache=new Map,this.xpathCacheId=new Map,this.selectedAnnotationsMap$=new Ce({}),this.selectedAnnotationsLocationMap$=new Ce({}),this.recordingInProgress$=new Ce({}),this.deleteAnnotations$=new Ce([]),this.pinHighlighterClass$=new Ce(null),this.dialogOpenedInSidebar$=new Ce(!1),this.textHighlighterClass$=new Ce(null),this.commentPinHighlighter$=new Ce(!1),this.deviceInfo$=new Ce(new Yn),this.customCss$=new Ce(null),this.mutationObserver=null,this.previousMousePosition={pageX:0,pageY:0,clientX:0,clientY:0},this.currentMousePosition={pageX:0,pageY:0,clientX:0,clientY:0,element:{xpath:"",topPercentage:0,leftPercentage:0}},this.nodeMap={},this.unlistenElementScroll={},this.tabId=null,this.dynamicIdPatterns=[/^yui_[a-z0-9_]+$/i],this.excludeClassList=["show-pin-cursor"],this.filterSnippylyNodes=s=>{try{let c=[];return s.forEach(p=>{if(!Ki(p))if(p instanceof HTMLElement){if(p.className.includes("cdk-overlay-container")||p.className.includes("cdk-overlay-connected-position-bounding-box"))return;if(p.className.includes("cdk-overlay")){let g=!1;p.childNodes.forEach(f=>{Ki(f)&&(g=!0)}),g||c.push(p)}else c.push(p)}else c.push(p)}),c}catch(c){return this.loggingService.catch("Error in DomService filterSnippylyNodes: ",c),[]}},this.loggingService.log("%c[WB] Creating CLASS: DomService","color: blue;");try{this.analyticsService.setDomService(this),this.renderer=this.rendererFactory2.createRenderer(null,null);let s=this.calculateScreenSize();this.currentScreenSize$=new Ce(s),this.currentMousePosition$=new Ce(this.currentMousePosition),this.detectNetworkStatusChange(),this.getScrollableElementsIds$().pipe(Oi(),Qt(([c,p])=>{try{let g=p.filter(I=>!c.includes(I)),f=c.filter(I=>!p.includes(I));f.length&&f.map(T=>document.getElementById(T)).filter(T=>T).forEach(T=>{this.unlistenElementScroll&&this.unlistenElementScroll[T.id]&&this.unlistenElementScroll[T.id]()}),g.length&&g.map(T=>document.getElementById(T)).filter(T=>T).forEach(T=>{this.unlistenElementScroll[T.id]=this.renderer.listen(T,"scroll",B=>{let z=this.calculateScreenSize();this.currentScreenSize$.next(z)})})}catch(g){this.loggingService.catch("Error in DomService getScrollableElementsIds subscription: ",g)}})).subscribe(()=>{},c=>{this.loggingService.catch("Error in DomService getScrollableElementsIds subscription: ",c)}),this.getSelectedAnnotationsMap$().subscribe(c=>{Object.keys(c||{})?.length?oce("snippylyUserScalableNo","viewport","width=device-width, user-scalable=no"):rce("snippylyUserScalableNo")},c=>{this.loggingService.catch("Error in DomService getSelectedAnnotationsMap$ subscription: ",c)})}catch(s){this.loggingService.catch("Error in DomService constructor: ",s)}}setDocService(e){try{this.docService=e,this.subscribeToDomEvents()}catch(t){this.loggingService.catch("Error in DomService setDocService: ",t)}}setDynamicIdPatterns(e){try{let t=e.map(r=>typeof r=="string"?new RegExp(r):r).filter(Boolean);t.length&&(this.dynamicIdPatterns=t)}catch(t){this.loggingService.catch("Error in DomService setDynamicIdPatterns: ",t)}}isLikelyDynamicId(e){try{return e?this.dynamicIdPatterns.some(t=>t.test(e)):!1}catch{return!1}}getStableAttributes(e){try{let t={};if(!e.getAttributeNames)return t;let r=new Set(["id","class","style"]);return e.getAttributeNames().forEach(s=>{if(r.has(s)||s.includes("snippyly")||s.includes("velt"))return;let c=e.getAttribute(s);c&&c.length<=256&&(t[s]=c)}),t}catch{return{}}}buildStableElementSelector(e,t){try{if(Object.keys(t).length===0)return;let a=[e.tagName?.toLowerCase()],s=["data-","aria-","role","name","title","type"];return Object.keys(t).sort((p,g)=>{let f=s.findIndex(T=>p.startsWith(T)),I=s.findIndex(T=>g.startsWith(T));return(f===-1?99:f)-(I===-1?99:I)}).slice(0,4).forEach(p=>{let g=CSS.escape(t[p]);a.push(`[${p}="${g}"]`)}),a.join("")}catch{return}}getVisibleText(e,t=400){try{let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a="",s,c=0;for(;(s=r.nextNode())&&a.length<t;){let p=(s.textContent||"").replace(/\s+/g," ").trim();if(p&&(a+=(a?" ":"")+p),c++,c>100)break}return a.slice(0,t)}catch{return""}}hashText(e){try{return Wle(e)}catch{return}}generateRobustXPath(e,t){try{let r=t?.maxDepth||10,a=t?.useAbsolutePath||!1,s=[],c=e,p=0;for(;c&&c!==document.documentElement&&p<r;){let T=this.buildRobustXPathSegment(c);if(T&&(s.unshift(T),this.isStrongAnchorSegment(T)))break;c=c.parentElement,p++}if(s.length===0)return;let f=(a?"/":"//")+s.join("/");return s.some(T=>T.includes("[@")||T.includes("[contains(@class"))?f:void 0}catch{return}}buildRobustXPathSegment(e){try{let t=e.tagName.toLowerCase(),r=e.id;if(r&&!this.isLikelyDynamicId(r)&&document.querySelectorAll(`[id="${CSS.escape(r)}"]`).length===1)return`*[@id=${this.escapeXPathValue(r)}]`;let a=["data-region","data-instanceid","data-action","data-key","data-block","data-activityid"];for(let T of a){let B=e.getAttribute(T);if(B)return`${t}[@${T}=${this.escapeXPathValue(B)}]`}let s=Array.from(e.attributes).filter(T=>T.name.startsWith("data-")&&!T.name.includes("snippyly")&&!T.name.includes("velt")&&T.value.length<100).sort((T,B)=>T.value.length-B.value.length);if(s.length>0){let T=s[0];return`${t}[@${T.name}=${this.escapeXPathValue(T.value)}]`}let c=e.getAttribute("role");if(c)return`${t}[@role=${this.escapeXPathValue(c)}]`;let p=e.getAttribute("aria-label");if(p&&p.length<50)return`${t}[@aria-label=${this.escapeXPathValue(p)}]`;let g=e.getAttribute("name");if(g)return`${t}[@name=${this.escapeXPathValue(g)}]`;let f=e.getAttribute("type");if(f)return`${t}[@type=${this.escapeXPathValue(f)}]`;let I=Array.from(e.classList||[]).filter(T=>T.length>0&&T.length<40&&!T.includes("yui")&&!T.includes("velt")&&!T.includes("snippyly")&&!this.excludeClassList.includes(T)).slice(0,2);if(I.length>0){let T=I.map(B=>`contains(@class, ${this.escapeXPathValue(B)})`).join(" and ");return`${t}[${T}]`}if(e.parentElement){let T=Array.from(e.parentElement.children).filter(B=>B.tagName===e.tagName);if(T.length>1){let B=T.indexOf(e)+1;return`${t}[${B}]`}}return t}catch{return}}isStrongAnchorSegment(e){try{return!!(e.includes("[@id=")||["main","navigation","banner","contentinfo","complementary","search"].some(a=>e.includes(`[@role='${a}']`))||["data-region","data-instanceid","data-activityid"].some(a=>e.includes(`[@${a}=`)))}catch{return!1}}escapeXPathValue(e,t=!0){try{return e.includes("'")?e.includes('"')?`concat(${e.split("'").map(s=>`'${s}'`).join(`,"'",`)})`:t?`"${e}"`:e:t?`'${e}'`:e}catch{try{return`concat(${e.split("'").map(c=>`'${c}'`).join(`,"'",`)})`}catch{return t?`'${e}'`:e}}}getElementFromRobustXPath(e){try{return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch{return null}}getAllElementsFromRobustXPath(e){try{let t=document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),r=[];for(let a=0;a<t.snapshotLength;a++){let s=t.snapshotItem(a);s instanceof Element&&r.push(s)}return r}catch{return[]}}generateAnchorRecord(e,t){try{let r=this.generateAnchorRecordForElement(e,t),a=null;if(e.parentElement&&e.parentElement instanceof HTMLElement&&Pi(e.parentElement)&&e.parentElement!==document.body&&(a=e.parentElement),r&&a){let s=this.generateAnchorRecordForElement(a,t);s&&(r.parent=s)}return r}catch(r){return this.loggingService.catch("Error in DomService generateAnchorRecord: ",r),null}}generateAnchorRecordForElement(e,t){try{if(!e)return null;let r=e,a=r.tagName?.toUpperCase();if(!a)return null;let s=r.id&&!this.isLikelyDynamicId(r.id)?r.id:void 0,c=this.getStableAttributes(r),p=this.buildStableElementSelector(r,c),g=this.getVisibleText(r),f=this.hashText(g||""),I=this.generateRobustXPath(r),T=this.getXPath(r),B=this.getXPath(r,!0),z=this.getXPath(r,!0,!0);return{version:"1.0",id:s,tagName:a,elementSelector:p,robustXPath:I||void 0,xPath:T||void 0,fXPath:B||void 0,cfXPath:z||void 0,contentHash:f?{value:f,algorithm:"md5",source:"textContent"}:void 0,createdAt:Date.now()}}catch(r){return this.loggingService.catch("Error in DomService generateAnchorRecordForElement: ",r),null}}resolveAnchorRecord(e){try{let t=[],r=null,a=(f,I,T=0)=>{let B=[],z=T;if(B.push({method:I,score:T}),e.tagName&&f.tagName?.toUpperCase()===e.tagName&&(z+=10,B.push({method:"tagName-match",score:10})),e.contentHash?.value){let G=this.getVisibleText(f);this.hashText(G)===e.contentHash.value&&(z+=30,B.push({method:"contentHash-match",score:30}))}t.push({el:f,score:z,by:I,scoreBreakdown:B})};if(e.id){let f=document.querySelectorAll(`#${CSS.escape(e.id)}`);if(f.length===1)return{element:f[0],matchedBy:"id",score:90};f.length>1&&f.forEach(I=>a(I,"id-duplicate",70))}if(e.elementSelector){let f=document.querySelectorAll(e.elementSelector);if(f.length===1)return{element:f[0],matchedBy:"element-selector",score:80};f.forEach(I=>a(I,"element-selector-duplicate",60))}e.robustXPath&&this.getAllElementsFromRobustXPath(e.robustXPath).slice(0,20).forEach(B=>a(B,"robustXPath",50)),e?.parent&&(r=this.resolveAnchorRecord(e.parent),r.element&&r.element.querySelectorAll(e.tagName?.toLowerCase()||"*").forEach(I=>a(I,"parent+tag",40)));let s=(f,I,T)=>{if(!f)return;let B=this.getElementFromXPath(f);B&&a(B,I||"xpath",T||30)};if(s(e.xPath,"xPath",30),s(e.cfXPath,"cfXPath",30),s(e.fXPath,"fXPath",30),e.contentHash?.value&&t.length===0){let I=T=>{let B=0;for(let z=0;z<T.length&&B<400;z++){let G=T[z];if(B++,!this.isElementVisible(G))continue;let J=this.getVisibleText(G),ne=this.hashText(J);ne&&ne===e.contentHash?.value&&a(G,"contentHash",15)}};if(r?.element&&r?.element instanceof Element){let T=r?.element?.querySelectorAll("*");I(T)}}if(!t.length)return{element:null};t.sort((f,I)=>I.score-f.score);let c=t[0].score,p=t.filter(f=>f.score===c);if(p.length>1){let f=[{path:e.xPath,label:"xPath"},{path:e.cfXPath,label:"cfXPath"},{path:e.fXPath,label:"fXPath"}];for(let I of f)if(I.path){let T=this.getElementFromXPath(I.path);if(T){let B=p.find(z=>z.el===T);if(B)return{element:B.el,matchedBy:`${B.by}+position`,score:B.score,scoreBreakdown:B.scoreBreakdown}}}}let g=t[0];return{element:g.el,matchedBy:g.by,score:g.score,scoreBreakdown:g.scoreBreakdown}}catch(t){return this.loggingService.catch("Error in DomService resolveAnchorRecord: ",t),{element:null}}}subscribeToDomEvents(){try{this.docService?.getDocumentPaths$().pipe(de(e=>{e?(this.onWindowResize(),this.onWindowScroll(),this.onPointerDown(),this.onWindowClick(),this.onWindowKeyupBackspace(),this.onWindowKeyupDelete(),this.onWindowKeyupEsc(),this.onWindowPopState(),this.onWindowKeydownShift(),this.onWindowKeyupShift(),this.addPointerMoveListener(),this.addPointerUpListener(),this.addSelectionChangeListener(),this.onDocumentFocus()):(this.unsubscribeFromWindowResize(),this.unsubscribeFromWindowScroll(),this.unsubscribeFromPointerDown(),this.unsubscribeFromWindowClick(),this.unsubscribeFromWindowKeyupBackspace(),this.unsubscribeFromWindowKeyupDelete(),this.unsubscribeFromWindowKeyupEsc(),this.unsubscribeFromWindowPopState(),this.unsubscribeFromWindowKeydownShift(),this.unsubscribeFromWindowKeyupShift(),this.unsubscribeFromPointerMoveListener(),this.unsubscribeFromPointerUpListener(),this.unsubscribeFromSelectionChangeListener(),this.unsubscribeFromDocumentFocus(),this.unsetMutationObserver())})).subscribe(),this.onDocumentClick()}catch(e){this.loggingService.catch("Error in DomService subscribeToDomEvents: ",e)}}setScrollableElementsIds(e){try{e&&e.length&&this.scrollableElementsIds$.next(Array.from(new Set(e)))}catch(t){this.loggingService.catch("Error in DomService setScrollableElementsIds: ",t)}}getScrollableElementsIds$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getScrollableElementsIds$","color: green;"),this.scrollableElementsIds$.asObservable()}removeScrollableElementsIds(){this.scrollableElementsIds$.next([])}setMutationObserver(e){try{this.mutationObserver||(this.loggingService.log("%c[WB] Calling DomService FUNCTION: setMutationObserver","color: green;"),this.loggingService.log("%c[WB] setMutationObserver from: "+e,"color: green;"),this.mutationObserver=new MutationObserver(t=>{try{if(t?.find(a=>a?.attributeName===U.VELT_IGNORE_CHANGE_DETECTION))return;let r=t.filter(a=>a.type==="childList").filter(a=>{let s=a.target;return a.removedNodes.forEach(c=>{let p=c;if(typeof p.getAttribute=="function"){let g=p.getAttribute(U.ATTRIBUTES.VELT_ELEMENT_CACHE_ID);if(g!==null&&g!==""){let f=this.xpathCacheId.get(g);f!==void 0&&(this.xpathCacheId.delete(g),this.xpathCache.delete(f))}}}),Ki(s)?!1:!!(this.filterSnippylyNodes(a.addedNodes).length||this.filterSnippylyNodes(a.removedNodes).length)});this.childListMutation$.next(r),r.push(...t.filter(a=>a.type==="attributes").filter(a=>!Ki(a.target)).filter(a=>this.filterSnippylyNodes([a.target]).length).filter(a=>{if(a){let s=a.target;return s?.classList?.contains("snippyly-sidebar-panel")?!1:s?!s.getAttribute(U.VELT_IGNORE_CHANGE_DETECTION):!0}return!0})),r=r.filter(a=>{let s=!0;return Object.keys(U.INGNORE_MUTATION_OBSERVER_CHANGE_TAGS).forEach(c=>{a.target?.closest(c)&&(s=!1)}),s}),r=r.filter(a=>a.target&&Pi(a.target)),r.length&&this.mutation$.next(r)}catch(r){this.loggingService.catch("Error in DomService change detection: ",r)}}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0}))}catch(t){this.loggingService.catch("Error in DomService change detection: ",t)}}unsetMutationObserver(){try{this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}catch(e){this.loggingService.catch("Error in DomService unsetMutationObserver: ",e)}}detectNetworkStatusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: detectNetworkStatusChange","color: green;");try{Uo(vi(window,"offline").pipe(de(()=>!1)),vi(window,"online").pipe(de(()=>!0)),new $t(e=>{e.next(navigator.onLine),e.complete()})).subscribe(e=>{this.networkStatus$.next(e)})}catch(e){this.loggingService.catch("Error in DomService detectNetworkStatusChange: ",e)}}onWindowResize(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowResize","color: green;");try{this.unsubscribeFromWindowResize(),this.unlistenWindowResize=this.renderer.listen("window","resize",e=>{this.windowResize$.next(e);let t=this.calculateScreenSize();this.deviceInfo$.next(new Yn),this.currentScreenSize$.next(t)})}catch(e){this.loggingService.catch("Error in DomService onWindowResize: ",e)}}unsubscribeFromWindowResize(){try{this.unlistenWindowResize&&typeof this.unlistenWindowResize=="function"&&(this.unlistenWindowResize(),this.unlistenWindowResize=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowResize: ",e)}}onWindowScroll(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowScroll","color: green;");try{this.unsubscribeFromWindowScroll(),this.unlistenWindowScroll=this.renderer.listen("window","scroll",e=>{this.windowScroll$.next(e);let t=this.calculateScreenSize();this.currentScreenSize$.next(t)})}catch(e){this.loggingService.catch("Error in DomService onWindowScroll: ",e)}}unsubscribeFromWindowScroll(){try{this.unlistenWindowScroll&&typeof this.unlistenWindowScroll=="function"&&(this.unlistenWindowScroll(),this.unlistenWindowScroll=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowScroll: ",e)}}onPointerDown(){this.loggingService.log("%c[WB] Calling FUNCTION: onPointerDown","color: green;");try{this.unsubscribeFromPointerDown(),this.unlistenPointerDown=this.renderer.listen("window","pointerdown",e=>{this.mousedown=!0,this.windowMouseDown$.next(e),this.setPointerPosition(e)})}catch(e){this.loggingService.catch("Error in DomService onPointerDown: ",e)}}unsubscribeFromPointerDown(){try{this.unlistenPointerDown&&typeof this.unlistenPointerDown=="function"&&(this.unlistenPointerDown(),this.unlistenPointerDown=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerDown: ",e)}}onWindowClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupBackspace","color: green;");try{this.unsubscribeFromWindowClick(),this.unlistenWindowClick=this.renderer.listen("window","click",e=>{this.windowClick$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowClick: ",e)}}unsubscribeFromWindowClick(){try{this.unlistenWindowClick&&typeof this.unlistenWindowClick=="function"&&(this.unlistenWindowClick(),this.unlistenWindowClick=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowClick: ",e)}}onWindowKeyupBackspace(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupBackspace","color: green;");try{this.unsubscribeFromWindowKeyupBackspace(),this.unlistenWindowKeyupBackspace=this.renderer.listen("window","keyup.backspace",e=>{this.isVideoEditorHandlingDelete||this.windowKeyupBackspace$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupBackspace: ",e)}}unsubscribeFromWindowKeyupBackspace(){try{this.unlistenWindowKeyupBackspace&&typeof this.unlistenWindowKeyupBackspace=="function"&&(this.unlistenWindowKeyupBackspace(),this.unlistenWindowKeyupBackspace=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupBackspace: ",e)}}onWindowKeyupDelete(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupDelete","color: green;");try{this.unsubscribeFromWindowKeyupDelete(),this.unlistenWindowKeyupDelete=this.renderer.listen("window","keyup.delete",e=>{this.isVideoEditorHandlingDelete||this.windowKeyupDelete$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupDelete: ",e)}}unsubscribeFromWindowKeyupDelete(){try{this.unlistenWindowKeyupDelete&&typeof this.unlistenWindowKeyupDelete=="function"&&(this.unlistenWindowKeyupDelete(),this.unlistenWindowKeyupDelete=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupDelete: ",e)}}onWindowKeyupEsc(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupEsc","color: green;");try{this.unsubscribeFromWindowKeyupEsc(),this.unlistenWindowKeyupEsc=this.renderer.listen("window","keyup.esc",e=>{this.windowKeyupEsc$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupEsc: ",e)}}unsubscribeFromWindowKeyupEsc(){try{this.unlistenWindowKeyupEsc&&typeof this.unlistenWindowKeyupEsc=="function"&&(this.unlistenWindowKeyupEsc(),this.unlistenWindowKeyupEsc=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupEsc: ",e)}}onWindowPopState(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowPopState","color: green;");try{this.unsubscribeFromWindowPopState(),this.unlistenWindowPopState=this.renderer.listen("window","popstate",e=>{this.windowPopState$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowPopState: ",e)}}unsubscribeFromWindowPopState(){try{this.unlistenWindowPopState&&typeof this.unlistenWindowPopState=="function"&&(this.unlistenWindowPopState(),this.unlistenWindowPopState=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowPopState: ",e)}}onDocumentClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onDocumentClick","color: green;");try{this.unsubscribeFromDocumentClick(),this.documentClickListener=e=>{e?.target?.tagName?.toLowerCase()!==U.TAGS.SUPERFLOW_TOOLBAR&&(this.documentClick$.next(e),this.documentClickSubject$.next(e))},document.addEventListener("click",this.documentClickListener,!0)}catch(e){this.loggingService.catch("Error in DomService onDocumentClick: ",e)}}unsubscribeFromDocumentClick(){try{this.documentClickListener&&typeof this.documentClickListener=="function"&&(document.removeEventListener("click",this.documentClickListener,!0),this.documentClickListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromDocumentClick: ",e)}}onDocumentFocus(){this.loggingService.log("%c[WB] Calling FUNCTION: onDocumentFocus","color: green;");try{this.unsubscribeFromDocumentFocus(),this.documentFocusListener=e=>{this.documentFocus$.next(e)},document.addEventListener("focus",this.documentFocusListener,!0)}catch(e){this.loggingService.catch("Error in DomService onDocumentFocus: ",e)}}unsubscribeFromDocumentFocus(){try{this.documentFocusListener&&typeof this.documentFocusListener=="function"&&(document.removeEventListener("focus",this.documentFocusListener,!0),this.documentFocusListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromDocumentFocus: ",e)}}onWindowKeydownShift(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeydownShift","color: green;");try{this.unsubscribeFromWindowKeydownShift(),this.unlistenWindowKeydownShift=this.renderer.listen("window","keydown.shift",e=>{this.windowKeydownShift$.next(e),this.windowKeyupShift$.next(null)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeydownShift: ",e)}}unsubscribeFromWindowKeydownShift(){try{this.unlistenWindowKeydownShift&&typeof this.unlistenWindowKeydownShift=="function"&&(this.unlistenWindowKeydownShift(),this.unlistenWindowKeydownShift=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeydownShift: ",e)}}onWindowKeyupShift(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupShift","color: green;");try{this.unsubscribeFromWindowKeyupShift(),this.unlistenWindowKeyupShift=this.renderer.listen("window","keyup.shift",e=>{this.windowKeyupShift$.next(e),this.windowKeydownShift$.next(null)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupShift: ",e)}}unsubscribeFromWindowKeyupShift(){try{this.unlistenWindowKeyupShift&&typeof this.unlistenWindowKeyupShift=="function"&&(this.unlistenWindowKeyupShift(),this.unlistenWindowKeyupShift=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupShift: ",e)}}onWindowKeydown$(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeydown$","color: green;");try{return vi(window,"keydown")}catch(e){return this.loggingService.catch("Error in DomService onWindowKeydown$: ",e),jl}}addPointerMoveListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerMoveListener","color: green;");try{this.unsubscribeFromPointerMoveListener(),this.unlistenPointerMoveListener=this.renderer.listen("document","pointermove",e=>{this.windowPointerMove$.next(e),this.mouseMoveEvent=e})}catch(e){this.loggingService.catch("Error in DomService addPointerMoveListener: ",e)}}unsubscribeFromPointerMoveListener(){try{this.unlistenPointerMoveListener&&typeof this.unlistenPointerMoveListener=="function"&&(this.unlistenPointerMoveListener(),this.unlistenPointerMoveListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerMoveListener: ",e)}}addPointerUpListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerUpListener","color: green;");try{this.unsubscribeFromPointerUpListener(),this.unlistenPointerUpListener=this.renderer.listen("document","pointerup",e=>{this.windowPointerUp$.next(e)})}catch(e){this.loggingService.catch("Error in DomService addPointerUpListener: ",e)}}unsubscribeFromPointerUpListener(){try{this.unlistenPointerUpListener&&typeof this.unlistenPointerUpListener=="function"&&(this.unlistenPointerUpListener(),this.unlistenPointerUpListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerUpListener: ",e)}}addSelectionChangeListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerUpListener","color: green;");try{this.unsubscribeFromSelectionChangeListener(),this.unlistenSelectionChangeListener=this.renderer.listen("document","selectionchange",e=>{this.documentSelectionChange$.next(e)})}catch(e){this.loggingService.catch("Error in DomService addPointerUpListener: ",e)}}unsubscribeFromSelectionChangeListener(){try{this.unlistenSelectionChangeListener&&typeof this.unlistenSelectionChangeListener=="function"&&(this.unlistenSelectionChangeListener(),this.unlistenSelectionChangeListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromSelectionChangeListener: ",e)}}updateCurrentMousePosition(e){try{if(this.currentMousePosition.pageX=e.pageX,this.currentMousePosition.pageY=e.pageY,this.currentMousePosition.clientX=e.clientX,this.currentMousePosition.clientY=e.clientY,e.target){let t=this.getXPath(e.target),r=e.target;if(t?.includes("name()='svg'")){let f=this.getXPath(t);f&&(r=f.iterateNext()||e.target)}let a=r.getBoundingClientRect(),s=e.clientX-a.x,c=e.clientY-a.y,p=s*100/(a.width||1),g=c*100/(a.height||1);this.currentMousePosition.element={xpath:t,topPercentage:g,leftPercentage:p}}else this.currentMousePosition.element=null;this.currentMousePosition$.next(this.currentMousePosition)}catch(t){this.loggingService.catch("Error in DomService updateCurrentMousePosition: ",t)}}getTargetElementForCursorPosition(e,t=!0,r=!1,a=!0,s,c=!0,p){try{let g=e,f=g?.touches?.length?g.touches[0]?.clientX:g?.clientX,I=g?.touches?.length?g.touches[0]?.clientY:g?.clientY;p&&(f=p.clientX,I=p.clientY);let T=this.getBackgroundElement(f,I,t,r);if(T&&s&&typeof s=="function"&&(T=s(T)),T){let B=this.getXPath(T),z=this.getXPath(T,!0),G=T.getBoundingClientRect(),J=f-G.x,ne=I-G.y,ve=J*100/(G.width||1),ye=ne*100/(G.height||1),Ne={xpath:B,fXpath:z,leftPercentage:ve,topPercentage:ye};if(a){let Ve=this.getXPath(T,!0,!0);Ne.cfXpath=Ve}if(c){let Ve=this.generateAnchorRecord(T);Ve&&(Ne.anchor=Ve)}return Ne}else return null}catch(g){return this.loggingService.catch("Error in DomService getTargetElementForCommentPinAnnotation: ",g),null}}getBackgroundElement(e,t,r=!0,a=!1){try{let s=document.elementsFromPoint(e,t),c=[];s.forEach(g=>{Ki(g)?c=[]:Pi(g)&&c.push(g)}),a&&(c=c.filter(g=>this.isElementVisibleOnScreen(g)));let p=0;return r||c?.forEach((g,f)=>{g.tagName.toLowerCase()==="svg"&&(p=f)}),c[p]}catch(s){return this.loggingService.catch("Error in DomService getBackgroundElement: ",s),null}}getBackgroundVeltElement(e,t){try{let r=document.elementsFromPoint(e,t),a=[];return r.forEach(s=>{Ki(s)&&Pi(s)&&a.push(s)}),a[0]}catch(r){return this.loggingService.catch("Error in DomService getBackgroundSnippylyElement: ",r),null}}setPointerPosition(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPointerPosition","color: green;");try{this.previousMousePosition.pageX=e.pageX,this.previousMousePosition.pageY=e.pageY,this.currentMousePosition.pageX=e.pageX,this.currentMousePosition.pageY=e.pageY}catch(t){this.loggingService.catch("Error in DomService setPointerPosition: ",t)}}getCurrentWindowSize$(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentWindowSize","color: green;"),this.currentScreenSize$.asObservable()}getCurrentMousePosition$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentMousePosition","color: green;"),this.currentMousePosition$.asObservable()}getCurrentWindowSizeValue(){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentWindowSizeValue","color: green;"),this.currentScreenSize$.value}getTopLeftPosition(){this.loggingService.log("%c[WB] Calling FUNCTION: getTopLeftPosition","color: green;");try{let e=document?.body?.getBoundingClientRect()||document?.documentElement?.getBoundingClientRect(),t=this.currentMousePosition?.pageX||e.x+200,r=Math.min(t,e.width/2),a=Math.abs(e.y),s=e.y-20;return a>50&&(s=Math.abs(e.y)+180),this.loggingService.log(e),this.loggingService.log(r),this.loggingService.log(s),{topPositionX:r,topPositionY:s}}catch(e){return this.loggingService.catch("Error in DomService getTopLeftPosition: ",e),{topPositionX:0,topPositionY:0}}}toggleSelection(){this.enableRectSelectionSubject$.next(!this.enableRectSelectionSubject$.value)}enableSelection(){this.enableRectSelectionSubject$.next(!0)}disableSelection(){this.enableRectSelectionSubject$.next(!1)}setPinHighlighterClass(e){this.pinHighlighterClass$.next(e)}setTextHighlighterClass(e){this.textHighlighterClass$.next(e)}getTextHighlighterClass(){return this.textHighlighterClass$.asObservable()}enableCommentPinHighlighter(){this.commentPinHighlighter$.next(!0)}disableCommentPinHighlighter(){this.commentPinHighlighter$.next(!1)}getCommentPinHighlighter$(){return this.commentPinHighlighter$.asObservable()}getCommentPinHighlighter(){return this.commentPinHighlighter$?.value}highlightElement(e,t,r){if(e){if(!r&&this.getCommentPinHighlighter()&&(this.pinHighlighterClass$.value?this.addClassToElement(e,this.pinHighlighterClass$.value):this.addClassToElement(e,U.SNIPPYLY_HIGHLIGHT)),t&&!e.hasAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)){let a=e.style.getPropertyValue("cursor"),s=e.style.getPropertyPriority("cursor"),c=a?{defaultCursorValue:a,defaultCursorPriority:s}:"";e.setAttribute(U.ATTRIBUTES.DEFAULT_CURSOR,c?JSON.stringify(c):""),e.style.setProperty("cursor",t,"important")}e.setAttribute(U.SNIPPYLY_HIGHLIGHT,"true"),e.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true")}}removeHighlightFromElement(e){if(e&&(this.pinHighlighterClass$.value&&this.removeClassFromElement(e,this.pinHighlighterClass$.value),this.removeClassFromElement(e,U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.VELT_IGNORE_CHANGE_DETECTION),e.hasAttribute(U.ATTRIBUTES.DEFAULT_CURSOR))){try{if(e.style.removeProperty("cursor"),e.getAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)){let t=JSON.parse(e.getAttribute(U.ATTRIBUTES.DEFAULT_CURSOR));e.style.setProperty("cursor",t.defaultCursorValue,t.defaultCursorPriority)}}catch{}e.removeAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)}}highlightUserElement(e,t,r,a=!1){try{e&&(this.addClassToElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT),a&&this.addClassToElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT_DEFAULT),e.setAttribute(U.SNIPPYLY_HIGHLIGHT,"true"),e.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true"),t&&!e.style.getPropertyValue(U.VELT_SELECTION_COLOR)&&e.style.setProperty(U.VELT_SELECTION_COLOR,t),r&&e.setAttribute(U.SNIPPYLY_HIGHLIGHT_USER_NAME,r))}catch(s){this.loggingService.catch("Error in DomService highlightUserElement: ",s)}}removeHighlightUserFromElement(e){try{e&&(this.removeClassFromElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT),this.removeClassFromElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT_DEFAULT),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.VELT_IGNORE_CHANGE_DETECTION),e.removeAttribute(U.VELT_SELECTION_COLOR),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT_USER_NAME),e.style.removeProperty(U.VELT_SELECTION_COLOR))}catch(t){this.loggingService.catch("Error in DomService removeHighlightUserFromElement: ",t)}}previewHighlightElement(e){e&&e.setAttribute(U.SNIPPYLY_HIGHLIGHT_PREVIEW,"true")}removePreviewHighlightFromElement(e){e&&e.removeAttribute(U.SNIPPYLY_HIGHLIGHT_PREVIEW)}getXPath(e,t=!1,r=!1,a){try{let s=this.calculateXPath(e,t,r,a);if(s&&typeof s=="string"&&s.includes("/svg")){let c=s.split("/"),p=!1;c.forEach((g,f)=>{g.includes("svg")&&(p=!0),p&&(c[f]="svg:"+g)}),s=c.join("/")}return s}catch(s){this.loggingService.catch("Error in DomService getXPath:",s)}}namespaceResolver(e){return e==="svg"?"http://www.w3.org/2000/svg":null}calculateXPath(e,t,r,a){try{if(e){if(typeof e=="string")return document.evaluate(e,a||document,this.namespaceResolver,XPathResult.ANY_TYPE,null);if(!e||e.nodeType!=1)return"";if(e.id&&document.querySelectorAll(`[id='${e.id}']`)?.length===1&&!t)return"//*[@id='"+e.id+"']";if(r&&e.className&&e.className.split){let c=e.className?.split(" ")?.filter(p=>!p?.includes("snippyly")&&!p?.includes("velt")&&!["show-pin-cursor"].includes(p))[0];if(c){let p=this.calculateXPath(e.parentNode,t,r,a)+"/"+e.tagName.toLowerCase(),g=Array.from(e.parentNode?.children||[]).filter(f=>f.nodeType===1&&f.tagName===e.tagName?f.className?.split(" ")?.filter(T=>T?.includes("snippyly")||T?.includes("velt")||["show-pin-cursor"].includes(T))[0]===c:!1);if(g.length>1){let f=g.indexOf(e)+1;p+=`[contains(concat(' ', normalize-space(@class), ' '), ' ${c} ')][${f}]`}else p+=`[contains(concat(' ', normalize-space(@class), ' '), ' ${c} ')]`;return p}}let s=[].filter.call(e.parentNode?.children?e.parentNode?.children:[],function(c){return c.tagName==e.tagName});return this.calculateXPath(e.parentNode,t,r)+"/"+e.tagName.toLowerCase()+(s.length>1?"["+([].indexOf.call(s,e)+1)+"]":"")}}catch(s){this.loggingService.catch("Error in DomService calculateXPath:",s)}}getElementFromXPath(e,t=document){try{if(this.xpathCache.has(e)){let a=this.xpathCache.get(e);if(a!==void 0&&document.contains(a))return a;this.xpathCache.delete(e)}let r=this.getXPath(e,!1,!1,t);if(r){let a=r?.iterateNext();if(a!==null&&typeof a.setAttribute=="function"){let s=vt();a.setAttribute(U.ATTRIBUTES.VELT_ELEMENT_CACHE_ID,s),this.xpathCacheId.set(s,e)}return this.xpathCache.set(e,a),a}return null}catch(r){return this.loggingService.catch("Error in DomService getElementFromXPath:",r),null}}getElementFromTargetElement(e){try{let t=null;if(e?.anchor){let r=this.resolveAnchorRecord(e.anchor);r?.element&&(t=r.element)}else e?.xpath?t=this.getElementFromXPath(e.xpath):e?.cfXpath?t=this.getElementFromXPath(e.cfXpath):e?.fXpath&&(t=this.getElementFromXPath(e.fXpath));return t}catch(t){return this.loggingService.catch("Error in DomService getElementFromTargetElement:",t),null}}getElementFromTargetTextRange(e){try{let t=null;if(e?.commonAncestorContainerAnchor){let r=this.resolveAnchorRecord(e.commonAncestorContainerAnchor);r?.element&&(t=r.element)}else e?.commonAncestorContainer&&(t=this.getElementFromXPath(e.commonAncestorContainer));return t}catch(t){return this.loggingService.catch("Error in DomService getElementFromTargetTextRange:",t),null}}calculateScreenSize(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowResize","color: green;");try{let e=[document?.body?.clientHeight||0,document?.documentElement?.clientHeight||0,window?.innerHeight||0],t=[document?.body?.clientWidth||0,document?.documentElement?.clientWidth||0,window?.innerWidth||0];this.calculatePageScrollHeight(),this.loggingService.log(this.pageScrollHeight),this.loggingService.log(this.nodeMap),this.highestNode=this.nodeMap[this.pageScrollHeight];let r=new GI;return r.screenWidth=Math.max(...t),r.screenHeight=Math.max(...e),r.screenScrollHeight=this.pageScrollHeight,r}catch(e){return this.loggingService.catch("Error in DomService calculateScreenSize:",e),new GI}}calculatePageScrollHeight(){this.loggingService.log("%c[WB] Calling FUNCTION: calculatePageScrollHeight","color: green;");try{this.pageScrollHeight=0,this.findLongestNode(document?.documentElement?.childNodes)}catch(e){this.loggingService.catch("Error in DomService calculatePageScrollHeight: ",e)}}removeSnippylyContent(e){this.loggingService.log("%c[WB] Calling FUNCTION: removeSnippylyContent","color: green;");try{let r=new DOMParser().parseFromString(e,"text/html");r.querySelectorAll("[data-snippyly-cache-id]").forEach(I=>{I.removeAttribute("data-snippyly-cache-id")}),r.querySelectorAll("[data-velt-cache-id]").forEach(I=>{I.removeAttribute("data-velt-cache-id")}),r.querySelectorAll(".comment-text-highlight").forEach(I=>{I?.parentNode?.insertBefore(document.createTextNode(I?.textContent),I),I.remove()});let p=document.createNodeIterator(r,NodeFilter.SHOW_COMMENT),g;for(;g=p.nextNode();)g?.remove();return this.mergeAdjacentTextNodes(r.body),this.sanitizeHtml(r.body.innerHTML)}catch(t){return this.loggingService.catch("Error in DomService removeSnippylyContent: ",t),e}}mergeAdjacentTextNodes(e){try{let t=e.firstChild;for(;t;){if(t.nodeType===Node.TEXT_NODE){let r=t.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE;)t.textContent+=r.textContent,r.remove(),r=t.nextSibling}t=t.nextSibling}}catch(t){this.loggingService.catch("Error in DomService mergeAdjacentTextNodes: ",t)}}findLongestNode(e){try{for(let t=e.length-1;t>=0;t--){if(e[t]?.scrollHeight&&e[t]?.clientHeight){let r=Math.max(e[t]?.scrollHeight,e[t]?.clientHeight);this.pageScrollHeight=Math.max(r,this.pageScrollHeight),this.nodeMap[r]=e[t]}e[t]?.childNodes?.length&&this.findLongestNode(e[t]?.childNodes)}}catch(t){this.loggingService.catch("Error in DomService findLongestNode: ",t)}}resetSelectedAnnotationsMap(e=!0,t){try{let r=Array.from(document.querySelectorAll(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`)),a=this.getDraftCommentAnnotationDialogs()||[];r.push(...a),r=Array.from(new Set(r));let s=r.map(f=>f.classList.contains("velt-annotation-draft-checked")?(f.classList.remove("velt-annotation-draft-checked"),null):(this.removeClassFromElement(f,"velt-comment-dialog-shake"),setTimeout(()=>{this.addClassToElement(f,"velt-comment-dialog-shake"),f.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_EDIT_COMMENT)||f.classList.contains("velt-annotation-draft-checked")||this.addClassToElement(f,"velt-annotation-draft-checked")},100),f.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_DRAFT))).filter(f=>f),c=Object.keys(this.getRecordingInProgress()||{});s=[...s,...c];let p=this.selectedAnnotationsMap$.value;if(e&&this.selectedAnnotationsMap$.value&&Object.keys(this.selectedAnnotationsMap$.value).length){let f=[];Object.keys(p).forEach(I=>{if(p[I]?.type==="tag"){let T=p[I];T?.to?.length||s.includes(I)||f.push(T)}else p[I]?.comments?.length||s.includes(I)||f.push(p[I])}),this.deleteAnnotations$.next(f),this.deleteAnnotations$.next([])}let g={};Object.keys(p).forEach(f=>{if(s.includes(f)&&(g[f]=p[f]),t)switch(t){case"comment":["comment","videoPin"].includes(p[f]?.type)||(g[f]=p[f]);break;default:p[f]?.type!==t&&(g[f]=p[f]);break}}),Object.keys(g).forEach(f=>{let I=g[f]?.multiThreadAnnotationId;I&&!g[I]&&(g[I]={annotationId:I,type:"multiThread"})}),JSON.stringify(this.selectedAnnotationsMap$.value)!==JSON.stringify(g)&&this.selectedAnnotationsMap$.next(g),this.setDialogOpenedInSidebar(!1)}catch(r){this.loggingService.catch("Error in DomService resetSelectedAnnotationsMap: ",r)}}setRecordingInProgress(e,t){try{if(t)this.recordingInProgress$.next(D(E({},this.recordingInProgress$.value),{[e]:t}));else{let r=this.recordingInProgress$.value;delete r[e],this.recordingInProgress$.next(r)}}catch(r){this.loggingService.catch("Error in DomService setRecordingInProgress: ",r)}}resetRecordingInProgress(){try{this.recordingInProgress$.next({})}catch(e){this.loggingService.catch("Error in DomService resetRecordingInProgress: ",e)}}getRecordingInProgress(){try{return this.recordingInProgress$.value}catch(e){return this.loggingService.catch("Error in DomService getRecordingInProgress: ",e),{}}}getDraftCommentAnnotationDialogs(){try{let e=[];return Array.from(document.querySelectorAll(`${U.TAGS.SNIPPYLY_COMMENT_DIALOG}`)).forEach(r=>{if(r?.shadowRoot){let a=r.shadowRoot.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);a&&e.push(a)}else{let a=r.querySelector(`${U.TAGS.VELT_SHADOW_DOM_INTERNAL}`);if(a?.shadowRoot){let s=a.shadowRoot?.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);s&&e.push(s)}else{let s=r.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);s&&e.push(s)}}}),e}catch(e){return this.loggingService.catch("Error in DomService getDraftCommentAnnotationDialogs: ",e),[]}}getSelectedAnnotationsMap(e){try{let t=this.selectedAnnotationsMap$.value;if(e){let r={};return Object.keys(t).forEach(a=>{switch(e){case"comment":["comment","videoPin"].includes(t[a].type)&&(r[a]=t[a]);break;default:t[a].type===e&&(r[a]=t[a]);break}}),r}else return t}catch(t){return this.loggingService.catch("Error in DomService getSelectedAnnotationsMap: ",t),{}}}getSelectedAnnotationsMap$(e){return this.selectedAnnotationsMap$.asObservable().pipe(de(t=>{if(e){let r={};return Object.keys(t).forEach(a=>{t[a].type===e&&(r[a]=t[a])}),r}else return t}))}getSelectedComments$(){return this.selectedAnnotationsMap$.asObservable().pipe(de(e=>Object.values(e)))}getSelectedAnnotationsLocationMap(){try{return this.selectedAnnotationsLocationMap$.value}catch(e){return this.loggingService.catch("Error in DomService getSelectedAnnotationsLocationMap: ",e),{}}}getSelectedAnnotationsLocationMap$(){return this.selectedAnnotationsLocationMap$.asObservable()}toggleAnnotationSelection(e,t,r,a=!1,s){try{r==="sidebarShowReplies"?this.setDialogOpenedInSidebar(!0):this.setDialogOpenedInSidebar(!1);let c=JSON.parse(JSON.stringify(this.selectedAnnotationsMap$.value||{})),p=JSON.parse(JSON.stringify(this.selectedAnnotationsLocationMap$.value||{}));c[e.annotationId]&&!a?delete c[e.annotationId]:((!this.windowKeydownShift$.value||a)&&(c={}),c[e.annotationId]=e,p[e.annotationId]=t,s=e?.multiThreadAnnotationId||s,s&&(c[s]={annotationId:s,type:"multiThread"},p[s]=t)),this.selectedAnnotationsMap$.next(c),Object.keys(p).forEach(g=>{c[g]||delete p[g]}),this.selectedAnnotationsLocationMap$.next(p)}catch(c){this.loggingService.catch("Error in DomService toggleAnnotationSelection: ",c)}}setSelectedAnnotationLocation(e,t){try{let r=JSON.parse(JSON.stringify(this.getSelectedAnnotationsLocationMap()||{}));r?.[e]!==t&&(r[e]=t,this.selectedAnnotationsLocationMap$.next(r))}catch(r){this.loggingService.catch("Error in DomService setSelectedAnnotationLocation: ",r)}}updateSelectedAnnotationInMap(e){try{let t=this.selectedAnnotationsMap$.value;e.forEach(r=>{t[r.annotationId]&&(t[r.annotationId]=r)}),this.selectedAnnotationsMap$.next(t)}catch(t){this.loggingService.catch("Error in DomService updateSelectedAnnotationInMap: ",t)}}getDeleteCommmentAnnotations$(){try{return this.deleteAnnotations$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getDeleteCommmentAnnotations$: ",e),le([])}}getHighestNode(){return this.loggingService.log("%c[WB] Calling FUNCTION: getHighestNode","color: green;"),this.highestNode}onWindowMouseDown$(){return this.windowMouseDown$.asObservable()}onWindowPointerMove$(){return this.windowPointerMove$.asObservable()}onWindowPointerMove(){return this.windowPointerMove$.value}onWindowPointerUp$(){return this.windowPointerUp$.asObservable()}onSelectionChange$(){return this.documentSelectionChange$.asObservable()}onWindowClick$(){return this.windowClick$.asObservable()}onWindowScroll$(){return this.windowScroll$.asObservable()}onWindowResize$(){return this.windowResize$.asObservable()}onWindowKeyupBackspace$(){return this.windowKeyupBackspace$.asObservable()}onWindowKeyupDelete$(){return this.windowKeyupDelete$.asObservable()}onWindowKeyupEsc$(){return this.windowKeyupEsc$.asObservable()}onWindowPopState$(){return this.windowPopState$.asObservable()}onDocumentClick$(){return this.documentClick$.asObservable()}getLastDocumentClick(){return this.documentClick$.value}onDocumentClickSubject$(){return this.documentClickSubject$.asObservable()}onDocumentFocus$(){return this.documentFocus$.asObservable()}onDomChange$(e){try{return this.mutationObserver||this.setMutationObserver(e),this.mutation$.asObservable()}catch(t){return this.loggingService.catch("Error in DomService onDomChange$: ",t),le([])}}getChildListMutation$(){return this.childListMutation$.asObservable()}onNetworkStatusChange$(){return this.networkStatus$.asObservable()}getNetworkStatus(){return this.networkStatus$.value}getElementOffset(e,t){try{let r={offsetTop:0,offsetLeft:0},a=e;if(a===t){let s=window.getComputedStyle(e);s.position==="static"&&s.transformStyle!="preserve-3d"&&s.transform=="none"&&(r.offsetLeft=e?.offsetLeft||0,r.offsetTop=e?.offsetTop||0)}if(a!==t)if(e?.closest("svg"))for(;a&&a!==t;){let c=window.getComputedStyle(a);if(a.tagName.toLowerCase()==="svg"||a instanceof SVGElement){let p=a.parentElement;if(p){let g=p.getBoundingClientRect(),f=a.getBoundingClientRect();r.offsetLeft+=f.left-g.left,r.offsetTop+=f.top-g.top}}else c.position==="static"?c.transformStyle!="preserve-3d"&&c.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0):(r.offsetLeft+=a.offsetLeft,r.offsetTop+=a.offsetTop);if(a=a.parentElement,e instanceof SVGElement&&a===t){let p=window.getComputedStyle(a);p.position==="static"&&p.transformStyle!="preserve-3d"&&p.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0)}}else{let c=window.getComputedStyle(a);c.position==="static"?c.transformStyle!="preserve-3d"&&c.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0):(r.offsetLeft+=a.offsetLeft,r.offsetTop+=a.offsetTop)}return r}catch(r){return this.loggingService.catch("Error in DomService getElementOffset: ",r),{offsetTop:0,offsetLeft:0}}}isElementVisible(e){try{if(typeof e?.getBoundingClientRect=="function"){let{width:t,height:r,top:a,bottom:s}=e?.getBoundingClientRect();return t>0||r>0||a<window.innerHeight&&s>0}else return!1}catch(t){return this.loggingService.catch("Error in DomService isElementVisible: ",t),!1}}isElementVisibleOnScreen(e){try{if(e){if(!(e instanceof Element))return!1;let t=e,r=window.getComputedStyle(t);return!(r.display==="none"||r.visibility==="hidden"||parseFloat(r.opacity)===0)}return!1}catch(t){return this.loggingService.catch("Error in DomService isElementVisibleOnScreen: ",t),!1}}getClickAndDragPointsObservable(){return new $t(e=>{let t=vi(document,"mousedown").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),r=vi(document,"mousemove").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),a=vi(document,"mouseup").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),c=t.pipe(he(p=>r.pipe(Oi(),de(([g,f])=>({startPoint:p,prevPoint:g,curPoint:f})),yo(a)))).subscribe(e);return()=>c.unsubscribe()})}drawRectangle(e,t){let r=document.querySelector(".rectangle");r||(r=document.createElement("div"),this.addClassToElement(r,"rectangle"),r.setAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED,"true"),r.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true"),document.body.appendChild(r));let a=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y),c=Math.min(e.x,t.x),p=Math.min(e.y,t.y);return r.style.width=`${a}px`,r.style.height=`${s}px`,r.style.left=`${c}px`,r.style.top=`${p}px`,r.style.position="absolute",r.style.border="2px dashed #f00",r.style.pointerEvents="none",r.style.zIndex="2147483577",r}getRange(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: getRange","color: green;"),window.getSelection()?.toString()){let e=window.getSelection();if(e?.rangeCount)return e.getRangeAt(0)}return null}catch(e){return this.loggingService.catch("Error in DomService getRange: ",e),null}}clearTextSelection(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearTextSelection","color: green;"),window.getSelection&&(window.getSelection()?.empty?window.getSelection()?.empty():window.getSelection()?.removeAllRanges&&window.getSelection()?.removeAllRanges())}catch(e){this.loggingService.catch("Error in DomService clearTextSelection: ",e)}}getTargetTextRangeFromSelectionRange(e){try{let t={},r=e.commonAncestorContainer;r?.nodeType===Node.TEXT_NODE&&(r=r.parentElement);let a=document.body;if(r){let c=this.getTextXPath(r);this.isXpathWithId(c)&&(a=r)}let s=this.getAdditionalLocationContainer(r);if(s&&(a=s),t.commonAncestorContainer=this.getTextXPath(a),t.commonAncestorContainer){let c=this.getElementFromXPath(t.commonAncestorContainer);if(c){t.commonAncestorContainerFXpath=this.getXPath(c,!0),t.commonAncestorContainerCFXpath=this.getXPath(c,!0,!0);let p=this.generateAnchorRecord(c);p&&(t.commonAncestorContainerAnchor=p)}}return t.text=e.toString(),t.occurrence=df(a,0,e.startContainer,e.startOffset,e.toString())+1,t}catch(t){this.loggingService.catch("Error in DomService getTargetTextRangeFromSelectionRange: ",t);return}}getTextXPath(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: getTextXPath","color: green;"),e.nodeType===Node.TEXT_NODE){let t=1,r=e.previousSibling;for(;r;)r.nodeType===Node.TEXT_NODE&&t++,r=r.previousSibling;return this.getXPath(e.parentElement)}else return this.getXPath(e)}catch(t){this.loggingService.catch("Error in DomService getTextXPath: ",t);return}}getHostElement(e){try{if(U.NON_NESTABLE_ELEMENTS[e?.tagName?.toLowerCase()]){let r=e?.closest("picture");return r?r?.parentElement:e.parentElement}let t=e.closest("svg");return t?t?.parentElement:e}catch(t){return this.loggingService.catch("Error in DomService getHostElement: ",t),e}}isElementInsideAdditionalLocationContainer(e){try{return!!e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`)}catch(t){return this.loggingService.catch("Error in DomService isElementInsideAdditionalLocationContainer: ",t),!1}}getAdditionalLocationContainer(e){try{return e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`)||null}catch(t){return this.loggingService.catch("Error in DomService getAdditionalLocationContainer: ",t),null}}isXpathWithId(e){try{return typeof e=="string"?!!e?.includes("[@id="):!1}catch(t){return this.loggingService.catch("Error in DomService isXpathWithId: ",t),!1}}getListedElements({elementIds:e,elementClassNames:t,elementQuerySelectors:r}){try{let a=[];if(e?.length)for(let s=0;s<e.length;s++){let c=document.getElementById(e[s]);c&&a.push(c)}if(t?.length)for(let s=0;s<t.length;s++){let c=document.getElementsByClassName(t[s]);for(let p=0;p<c.length;p++){let g=c[p];g&&g instanceof HTMLElement&&a.push(g)}}if(r?.length)for(let s=0;s<r.length;s++){let c=document.querySelectorAll(r[s]);for(let p=0;p<c.length;p++){let g=c[p];g&&g instanceof HTMLElement&&a.push(g)}}return a}catch(a){return this.loggingService.catch("Error in DomService getListedElements: ",a),[]}}isElementInsideListedElementIds(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.getElementById(t[r]);if(a&&a.contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementIds: ",r),!1}}isElementInsideListedElementClassNames(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.getElementsByClassName(t[r]);for(let s=0;s<a.length;s++)if(a[s].contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementClassNames: ",r),!1}}isElementInsideListedElementQuerySelectors(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.querySelectorAll(t[r]);for(let s=0;s<a.length;s++)if(a[s].contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementQuerySelectors: ",r),!1}}addClassToElement(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: addClassToElement","color: green;"),e&&(e.classList?.contains(t)||e.classList?.add(t))}catch(r){this.loggingService.catch("Error in DomService addClassToElement: ",r)}}removeClassFromElement(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeClassFromElement","color: green;"),e&&e.classList?.contains(t)&&e.classList?.remove(t)}catch(r){this.loggingService.catch("Error in DomService removeClassFromElement: ",r)}}isElementInsideParentWithAttribute(e,t,r){try{let a=e;for(;a&&a!==document.body;){if(a?.getAttribute&&a?.getAttribute(t)===r)return!0;a=a.parentElement}return!1}catch(a){return this.loggingService.catch("Error in DomService isElementInsideParentWithAttribute: ",a),!1}}setVideoEditorHandlingDelete(e){try{this.isVideoEditorHandlingDelete=e}catch(t){this.loggingService.catch("Error in DomService setVideoEditorHandlingDelete: ",t)}}isVideoEditorHandlingDeleteKey(){try{return this.isVideoEditorHandlingDelete}catch(e){return this.loggingService.catch("Error in DomService isVideoEditorHandlingDeleteKey: ",e),!1}}setCustomCss(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCustomCss","color: green;"),this.customCss$.next(e)}catch(t){this.loggingService.catch("Error in DomService setCustomCss: ",t)}}getCustomCss$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getCustomCss$","color: green;"),this.customCss$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getCustomCss$: ",e),le(null)}}injectCustomCss(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: injectCustomCss","color: green;");let t=this.customCss$.value;if(t){let r=e?.shadowRoot?.querySelector(`[${U.VELT_CUSTOM_CSS}]`);if(r&&r.remove(),t?.type==="link"){let a=document.createElement("link");a.href=t?.value,a.rel="stylesheet",a.setAttribute(U.VELT_CUSTOM_CSS,"true"),e?.shadowRoot?.appendChild(a)}else{let a=document.createElement("style");a.innerHTML=this.sanitizeHtml(t?.value),a.setAttribute(U.VELT_CUSTOM_CSS,"true"),e?.shadowRoot?.appendChild(a)}}}catch(t){this.loggingService.catch("Error in DomService injectCustomCss: ",t)}}trimCommentHtml(e){try{let t=document.createElement("div");t.innerHTML=e,this.removeEmptyElements(t);let r=t.innerHTML;return r=r.replace(o.MULTIPLE_NBSP_REGEX," ").replace(o.TRIM_NBSP_REGEX,"").trim(),r}catch(t){return this.loggingService.catch("Error in DomService trimCommentHtml: ",t),e}}removeEmptyElements(e){try{let a=function(s){return r.test(s.innerHTML)};var t=a;let r=/^\s*(<br\s*\/?>)?\s*$/;for(;e.firstChild&&a(e.firstChild);)e.removeChild(e.firstChild);for(;e.lastChild&&a(e.lastChild);)e.removeChild(e.lastChild)}catch(r){this.loggingService.catch("Error in DomService removeEmptyElements: ",r)}}normalizeWhitespace(e){try{e.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE?t.nodeValue=t.nodeValue?.replace(/\s+/g," ").trim()??"":t.nodeType===Node.ELEMENT_NODE&&this.normalizeWhitespace(t)})}catch(t){this.loggingService.catch("Error in DomService normalizeWhitespace: ",t)}}sanitizeHtml(e){try{return this.loggingService.log("%c[WB] Calling FUNCTION: sanitizeHtml","color: green;"),t2.sanitize(e,Npe)}catch(t){return this.loggingService.catch("Error in DomService sanitizeHtml: ",t),""}}sanitizeSvg(e){try{return t2.sanitize(e,Npe)}catch(t){return this.loggingService.catch("Error in DomService sanitizeSvg: ",t),e}}setDeviceInfo(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDeviceInfo","color: green;");let e=new Yn;this.deviceInfo$.next(e)}catch(e){this.loggingService.catch("Error in DomService setDeviceInfo: ",e)}}getDeviceInfo$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getDeviceInfo$","color: green;"),this.deviceInfo$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getDeviceInfo$: ",e),le(new Yn)}}getTabId(){try{let e=sessionStorage.getItem(U.SESSION_STORAGE.VELT_TAB_ID);!e&&this.tabId&&(e=this.tabId,sessionStorage.setItem(U.SESSION_STORAGE.VELT_TAB_ID,e)),!this.tabId&&e&&(this.tabId=e);let t=this.getTabIdFromWindowName();return(!e||e!==t)&&(e=vt(),this.tabId=e,sessionStorage.setItem(U.SESSION_STORAGE.VELT_TAB_ID,e),this.setTabIdToWindowName(e)),e}catch(e){return this.loggingService.catch("Error in DomService getTabId: ",e),null}}getTabIdFromWindowName(){try{return window.name}catch(e){return this.loggingService.catch("Error in DomService getTabIdFromWindowName: ",e),null}}setTabIdToWindowName(e){try{window.name=e}catch(t){this.loggingService.catch("Error in DomService setTabIdToWindowName: ",t)}}getDeviceInfo(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getDeviceInfo","color: green;"),this.deviceInfo$.value}catch(e){return this.loggingService.catch("Error in DomService getDeviceInfo: ",e),new Yn}}isMobileDevice(){try{return new Yn().getDeviceType()===mr.MOBILE}catch(e){return this.loggingService.catch("Error in DomService isMobileDevice: ",e),!1}}isTabletDevice(){try{return new Yn().getDeviceType()===mr.TABLET}catch(e){return this.loggingService.catch("Error in DomService isTabletDevice: ",e),!1}}isDesktopDevice(){try{return new Yn().getDeviceType()===mr.DESKTOP}catch(e){return this.loggingService.catch("Error in DomService isDesktopDevice: ",e),!1}}deepCloneElement(e){try{var t=document.createElement(e?.tagName);return Array.from(e.attributes).forEach(r=>{t.setAttribute(r.nodeName,r.nodeValue)}),e.childNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE?t.appendChild(this.deepCloneElement(r)):r.nodeType===Node.TEXT_NODE&&t.appendChild(document.createTextNode(r.nodeValue))}),t}catch(r){return this.loggingService.catch("Error in DomService deepCloneElement: ",r),e}}setRandomNumberToElementRecursive(e){try{if(!e)return;let t=Math.random().toString(36).substring(7);e&&e.setAttribute&&typeof e.setAttribute=="function"&&(e.getAttribute("velt-wireframe-id")||e.setAttribute("velt-wireframe-id",t)),Array.from(e.children).forEach(a=>{this.setRandomNumberToElementRecursive(a)})}catch(t){this.loggingService.catch("Error in DomService setRandomNumberToElementRecursive: ",t)}}setDialogOpenedInSidebar(e){this.dialogOpenedInSidebar$.next(e)}getDialogOpenedInSidebar(){return this.dialogOpenedInSidebar$.asObservable()}removeWireframeSuffixFromTags(e){if(!e)return;Array.from(e.children).forEach(r=>{if(this.removeWireframeSuffixFromTags(r),r.tagName.toLowerCase().endsWith("-wireframe")){let a=r.tagName.toLowerCase().replace("-wireframe",""),s=document.createElement(a);for(Array.from(r.attributes).forEach(c=>{s.setAttribute(c.name,c.value)});r.firstChild;)s.appendChild(r.firstChild);r.parentNode.replaceChild(s,r)}})}isMonitorDevice(){try{return new Yn().getDeviceType()===mr.MONITOR}catch(e){return this.loggingService.catch("Error in DomService isMonitorDevice: ",e),!1}}};o.MULTIPLE_NBSP_REGEX=/(?:&nbsp;\s*){2,}/g,o.TRIM_NBSP_REGEX=/^(?:&nbsp;\s*)+|(?:&nbsp;\s*)+$/g,o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(er),ee(_),ee(Cl))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var je=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.afAuth=e,this.configService=t,this.avatarService=r,this.coreActionsService=a,this.domService=s,this.functions=c,this.analyticsService=p,this.loggingService=g,this.user$=new Ce(null),this.userOptions$=new Ce(null),this.userContacts$=new Ce(null),this.userOrganization$=new Ce(null),this.providedUser=new zo,this.firebaseConfig$=new Ce(null),this.advancedQueries$=new Ce(null),this.planDetails$=new Ce(null),this.signOutPreviousUser$=new Ce(null),this.preSignOutFunctions=new Map,this.autoLoginCalled=!1,this.autoLoginRequired=!0,this.config=null,this.getPlanDetailsCalled=!1,this.forceReLoggedIn=!1,this.lastLoggedInUserData=null,this.sessionReLoginCount=0,this.SESSION_RE_LOGIN_COUNT_LIMIT=10,this.sessionReLoginSubscription=null,this.onRetrySubscription=null,this.TOKEN_EXPIRED_ERROR_COUNT_LIMIT=3,this.tokenExpiredErrorCount=0,this.loggingService.log("%c[WB] Creating CLASS: AuthService","color: blue;");try{this.analyticsService.setAuthService(this),this.configService.getConfig$().subscribe(f=>{this.config=f}),this.forceReLoggedIn=localStorage.getItem(U.LOCAL_STORAGE.VELT_USER_FORCE_RE_LOGGED_IN)==="true",this.sessionReLoginSubscription=ei(this.afAuth).pipe(so(this.afAuth.currentUser),Oi(),he(([f,I])=>this.domService.onNetworkStatusChange$().pipe(Le(T=>T),rt(1),de(()=>({previousUser:f,currentUser:I}))))).subscribe(T=>Q(this,[T],function*({previousUser:f,currentUser:I}){if(!I&&f){let B=f?.stsTokenManager?.expirationTime,z=new Date().getTime(),G=B-z;z>B&&(this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_TOKEN_EXPIRED,{apiKey:this.apiKey,user:this.user$.value,lastLoggedInUserData:this.lastLoggedInUserData,timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.user$.value?.userSnippylyId),this.user$.value&&f?.uid===this.user$.value?.userSnippylyId&&this.lastLoggedInUserData?.user?.userSnippylyId===this.user$.value?.userSnippylyId&&(this.sessionReLoginCount>this.SESSION_RE_LOGIN_COUNT_LIMIT?(this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_RE_LOGIN_COUNT_EXCEEDED,{apiKey:this.apiKey,clientUserId:this.lastLoggedInUserData.user.userId,snippylyUserId:this.lastLoggedInUserData.user.userSnippylyId,timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.user$.value?.userSnippylyId),this.sessionReLoginSubscription?.unsubscribe()):(this.sessionReLoginCount++,this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_RE_LOGIN_TRIGGERED,{apiKey:this.apiKey,clientUserId:this.lastLoggedInUserData.user.userId,snippylyUserId:this.lastLoggedInUserData.user.userSnippylyId,user:this.getUserWithoutContacts(this.lastLoggedInUserData.user),timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.lastLoggedInUserData.user.userSnippylyId),this.lastLoggedInUserData.user=yield this.updateUserWithColorAndTextColor(this.lastLoggedInUserData.user),this.initializeClient(this.lastLoggedInUserData.user,this.lastLoggedInUserData.userOptions,this.lastLoggedInUserData.initializeClientToken,this.lastLoggedInUserData.autoLogin,"internal-sessionReLogin"))))}}),f=>{this.loggingService.catch("Error in AuthService sessionReLoginSubscription: ",f)}),this.getUser$().pipe(Ct(Xt)).subscribe(f=>{let I=Dr(f);this.coreActionsService.triggerAction(mt.USER_UPDATE,I),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:mt.USER_UPDATE,payload:{user:I}})})}catch(f){this.loggingService.catch("Error in AuthService constructor: ",f)}}setApiKey(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: setApiKey","color: green;",e);try{if(this.apiKey){this.loggingService.log("API key is already set");return}this.apiKey=e,this.configService.setApiKey(this.apiKey),t||(t=new t9),this.configService.initConfig(t),t.debugMode?sessionStorage.setItem("debugMode","true"):sessionStorage.removeItem("debugMode"),this.autoLoginCalled||ei(this.afAuth).pipe(rt(1)).subscribe(r=>Q(this,null,function*(){if(this.autoLoginCalled=!0,r){let a=yield ed(r,!0).catch(s=>null);if(a){let{user:s}=a?.claims;this.autoLoginRequired&&(s=yield this.updateUserWithColorAndTextColor(s),this.initializeClient(s,this.userOptions$?.value?D(E({},this.userOptions$?.value),{replaceContacts:!1,replaceGroupContacts:!1,replacePrivateContacts:!1}):{},new Date().getTime(),!0,"internal-autoLogin"))}}}))}catch(r){this.loggingService.catch("Error in setApiKey: ",r)}}setUsersService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUsersService","color: green;"),this.usersService=e}catch(t){this.loggingService.catch("Error in setUsersService: ",t)}}setUserPermissionService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserPermissionService","color: green;"),this.userPermissionService=e}catch(t){this.loggingService.catch("Error in setUserPermissionService: ",t)}}setDocService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocService","color: green;"),this.docService=e}catch(t){this.loggingService.catch("Error in setDocService: ",t)}}setContactService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setContactService","color: green;"),this.contactService=e}catch(t){this.loggingService.catch("Error in setContactService: ",t)}}setIamService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setIamService","color: green;"),this.iamService=e}catch(t){this.loggingService.catch("Error in setIamService: ",t)}}setAreaService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaService","color: green;"),this.areaService=e}catch(t){this.loggingService.catch("Error in setAreaService: ",t)}}setCommentService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentService","color: green;"),this.commentService=e}catch(t){this.loggingService.catch("Error in setCommentService: ",t)}}setReactionService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setReactionService","color: green;"),this.reactionService=e}catch(t){this.loggingService.catch("Error in setReactionService: ",t)}}setRecorderAnnotationService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRecorderAnnotationService","color: green;"),this.recorderAnnotationService=e}catch(t){this.loggingService.catch("Error in setRecorderAnnotationService: ",t)}}setViewsService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setViewsService","color: green;"),this.viewsService=e}catch(t){this.loggingService.catch("Error in setViewsService: ",t)}}setCommonDbService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommonDbService","color: green;"),this.commonDbService=e}catch(t){this.loggingService.catch("Error in setCommonDbService: ",t)}}validateOrganizationId(e){if(this.isVersionGreaterThanOrEqualTo4()&&!e?.organizationId)if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_FAILED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,message:"Organization Id is not set",forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)},!0,e.userSnippylyId),this.configService.getSF())this.loggingService.catch("OrganizationId is not set in Identify method",void 0,void 0,!0);else throw new Error("OrganizationId is not set in Identify method")}setVeltAuthProvider(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setVeltAuthProvider","color: green;");try{this.onRetrySubscription?.unsubscribe();let t=null;if(!e.user)return null;e.generateToken&&typeof e.generateToken=="function"&&(t=yield e.generateToken());let r=yield vz(()=>window.Velt.identify(e.user,E(E({},e.options||{}),t&&{authToken:t}),{fromProvider:!0}).catch(a=>(e.onError&&typeof e.onError=="function"&&e.onError(a),Promise.reject(a))),e.retryConfig||{retryCount:0,retryDelay:0});return r&&e.generateToken&&typeof e.generateToken=="function"&&(this.onRetrySubscription=this.coreActionsService.onAction(mt.ERROR).pipe(Le(a=>a.code==="token_expired"),rt(10)).subscribe(a=>Q(this,null,function*(){if(a.code==="token_expired"){let s=this.docService?.getDocumentIds()?.map(T=>({id:T.clientDocumentId}))??[],c=this.docService?.getOptionsFromDocumentPaths()??void 0,p=[],g=this.docService?.getLocation();g&&p.push(g.location);let f=this.docService?.getLocations();f&&Object.values(f).forEach(T=>{p.push(T.location)}),(yield vz(()=>Q(this,null,function*(){try{let T=yield e.generateToken?.();return T?window.Velt.identify(e.user,E(E({},e.options||{}),T&&{authToken:T}),{fromProvider:!0}):!0}catch{return!1}}),e.retryConfig||{retryCount:0,retryDelay:0}))&&(yield this.docService?.setDocuments({documents:s,options:c,source:"internal"}),yield this.docService?.setLocations({locations:p,source:"internal",options:{appendLocation:!g}}))}}))),r}catch(t){return this.loggingService.catch("Error in setVeltAuthProvider: ",t),null}})}setUserToStorage(e){return Q(this,null,function*(){try{if(e){let t=yield wl(e,e?.userId??"");localStorage.setItem(U.LOCAL_STORAGE.VELT_IDENTIFY_USER,t)}}catch(t){this.loggingService.catch("Error in setUserToStorage: ",t)}})}getUserFromStorage(e){return Q(this,null,function*(){try{let t=localStorage.getItem(U.LOCAL_STORAGE.VELT_IDENTIFY_USER);return t?yield X0(t,e?.userId??""):null}catch(t){return this.loggingService.catch("Error in getUserFromStorage: ",t),null}})}updateUserWithColorAndTextColor(e){return Q(this,null,function*(){try{let t=JSON.parse(JSON.stringify(e??{})),r=yield this.getUserFromStorage(t);return!r||Object.keys(r).length===0?(delete t?.color,delete t?.textColor,t):(r?.color&&(t.color=r?.color),r?.textColor&&(t.textColor=r?.textColor),t)}catch(t){return this.loggingService.catch("Error in updateUserWithColorAndTextColor: ",t),e}})}updateUserIfRequired(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserIfRequired","color: green;");try{let t=yield this.getUserFromStorage(e),r={};if(e.color&&e.color!==t?.color&&(r.color=e.color),e.textColor&&e.textColor!==t?.textColor&&(r.textColor=e.textColor),Object.keys(r).length>0&&e.clientOrganizationId){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));hd({data:{type:"addUserInfoToOrganization",metadata:{organizationId:e.clientOrganizationId},user:D(E({},r),{userId:e.userId})},getSdkProxy:a,userId:e?.userId??""})}}catch(t){this.loggingService.catch("Error in updateUserIfRequired: ",t)}})}initializeClient(e,t,r,a,s){return Q(this,null,function*(){try{if(this.autoLoginRequired=!1,this.userOptions$.next(t),this.initializeClientToken)this.pendingUserLogin=e,this.pendingUserLoginSource=s;else{e.userSnippylyId=eC(this.configService.getApiKey(),e.userId),this.pendingUserLogin=void 0,this.pendingUserLoginSource=void 0,this.initializeClientToken=r;let c=yield ei(this.afAuth).pipe(rt(1)).toPromise().catch(g=>null),p=!0;if(this.providedUser=JSON.parse(JSON.stringify(e)),c){let g=yield ed(c,!0).catch(T=>null);if(!g)return;let{user:f,firebaseConfig:I}=g.claims;if(c?.uid!==e?.userSnippylyId||e?.groupId!==f?.groupId||e?.organizationId!==f?.organizationId||t?.forceReset||!a&&e?.organizationId&&!this.forceReLoggedIn||this.forceReLoginRequiredForAdvancedQueries(e)||this.forceReLoginRequiredForRegion(e,I)||this.forceReLoginRequiredForCommentViews(e))localStorage.setItem(U.LOCAL_STORAGE.VELT_USER_FORCE_RE_LOGGED_IN,"true"),localStorage.setItem(U.LOCAL_STORAGE.VELT_COMMENT_VIEWS_MIGRATED,"true"),this.forceReLoggedIn=!0,yield this.signOutUser("internal");else{this.loggingService.log("%c[WB] Calling FUNCTION: reinitializeCurrentUser","color: green;"),this.loggingService.log("Keeping user");let T=yield ed(c,!0).catch(J=>null);if(!T)return;let{firebaseConfig:B,user:z,advancedQueries:G}=T.claims;yield this.updateUserIfRequired(e),this.validateOrganizationId(e),this.setFirebaseConfig(B),this.setAdvancedQueries(G),z&&(this.providedUser.isAdmin=!!z.isAdmin),this.initializeSignedInUser(c,a,e),p=!1,this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:"auto",forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s})}}if(p){this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_TRIGGERED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s},!0,e.userSnippylyId,e.userId);let g=Qi(this.functions,Ji({url:wn.cloudFunction.validateClient,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),f=_a(),I=(yield g({apiKey:this.apiKey,user:e,version:f,authToken:t?.authToken}))?.data;if(I.error){if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_FAILED,D(E({apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,message:I.error,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)},I),{source:s}),!0,e.userSnippylyId,e.userId),I.error&&typeof I.error=="string")if(I.error?.toLowerCase()?.includes("token expired"))if(this.tokenExpiredErrorCount++,this.tokenExpiredErrorCount<=this.TOKEN_EXPIRED_ERROR_COUNT_LIMIT){let T={code:"token_expired",message:"Token expired",error:I?.error,source:I?.source};this.coreActionsService.triggerAction(mt.ERROR,T)}else{let T={code:"too_many_retries",message:"Token expired. Too many retries.",error:I?.error,source:I?.source};this.coreActionsService.triggerAction(mt.ERROR,T),this.analyticsService.trackEvent(Y.Events.Core.SDK_JWT_EXPIRED_RETRY_EXCEEDED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,source:s},!0,e.userSnippylyId,e.userId)}else{let T=I;this.coreActionsService.triggerAction(mt.ERROR,T)}throw I}else this.tokenExpiredErrorCount=0;if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s},!0,e.userSnippylyId,e.userId),this.validateOrganizationId(e),I.firebaseConfig){this.setFirebaseConfig(I.firebaseConfig),yield this.signInWithCustomToken(e,I.token),this.loggingService.log("new signed in user",this.afAuth.currentUser);let T=yield ed(this.afAuth.currentUser,!0).catch(G=>null);if(!T)return;let{user:B,advancedQueries:z}=T.claims;this.setAdvancedQueries(z),this.providedUser.isAdmin=!!B?.isAdmin,this.initializeSignedInUser(this.afAuth.currentUser,a,e)}}this.initializeClientToken=0,this.lastLoggedInUserData={user:e,userOptions:t,initializeClientToken:r,autoLogin:a},this.checkForPendingLogin()}return e}catch(c){return this.initializeClientToken=0,this.checkForPendingLogin(),this.loggingService.catch("Error in initializeClient: ",c),t?.throwError?Promise.reject(c):Promise.resolve(null)}})}isVersionGreaterThanOrEqualTo4(){try{let e=_a();return(e?parseInt(e.split(".")?.[0]||"0"):0)>=4}catch(e){return this.loggingService.catch("Error in isVersionGreaterThanOrEqualTo4: ",e),!1}}isVersion4Point5(){try{let e=_a();if(e){let t=e.split("."),r=parseInt(t[0]||"0"),a=parseInt(t[1]||"0"),s=parseInt(t[2]||"0");if(r>=4&&a>=5)return r===4&&a===5&&s===0?!e.toLowerCase().includes("beta"):!0}return!1}catch(e){return this.loggingService.catch("Error in isVersion4Point5: ",e),!1}}forceReLoginRequiredForAdvancedQueries(e){try{let t=this.isVersionGreaterThanOrEqualTo4(),r=!1;try{let a=localStorage.getItem(U.LOCAL_STORAGE.VELT_ADVANCED_QUERIES);a&&(r=JSON.parse(a)?.advancedQueriesEnabled)}catch(a){this.loggingService.catch("Error in forceReLoginRequiredForAdvancedQueries: ",a)}return!!(t&&e.organizationId&&!r)}catch(t){return this.loggingService.catch("Error in forceReLoginRequiredForAdvancedQueries: ",t),!1}}forceReLoginRequiredForCommentViews(e){try{let t=this.isVersion4Point5(),r=!1;try{let a=localStorage.getItem(U.LOCAL_STORAGE.VELT_COMMENT_VIEWS_MIGRATED);a&&(r=JSON.parse(a))}catch(a){this.loggingService.catch("Error in forceReLoginRequiredForCommentViews: ",a)}return!!(t&&e.organizationId&&!r)}catch(t){return this.loggingService.catch("Error in forceReLoginRequiredForCommentViews: ",t),!1}}forceReLoginRequiredForRegion(e,t){try{return!!(this.isVersionGreaterThanOrEqualTo4()&&e.organizationId&&!t?.region)}catch(r){return this.loggingService.catch("Error in forceReLoginRequiredForRegion: ",r),!1}}checkForPendingLogin(){this.pendingUserLogin&&this.initializeClient(this.pendingUserLogin,this.userOptions$?.value||{},new Date().getTime(),void 0,this.pendingUserLoginSource)}setFirebaseConfig(e){this.loggingService.log("%c[WB] Calling FUNCTION: setFirebaseConfig","color: green;");try{this.firebaseConfig$.value||this.firebaseConfig$.next({firebaseOptions:E(E({},wn.firebaseConfig),e)})}catch(t){this.loggingService.catch("Error in setFirebaseConfig: ",t)}}getFirebaseConfig$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirebaseConfig","color: green;"),this.firebaseConfig$.asObservable()}getFirebaseConfig(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirebaseConfig","color: green;"),this.firebaseConfig$.value}setAdvancedQueries(e){this.loggingService.log("%c[WB] Calling FUNCTION: setAdvancedQueries","color: green;");try{e&&typeof e=="object"&&localStorage.setItem(U.LOCAL_STORAGE.VELT_ADVANCED_QUERIES,JSON.stringify(e)),this.advancedQueries$.next(e)}catch(t){this.loggingService.catch("Error in setAdvancedQueries: ",t)}}getAdvancedQueries$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAdvancedQueries$","color: green;"),this.advancedQueries$.asObservable()}getAdvancedQueries(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAdvancedQueries","color: green;"),this.advancedQueries$.value}getAdvancedQueriesEnabled$(){return mn([this.configService.getConfig$(),this.getAdvancedQueries$()]).pipe(de(()=>this.getAdvancedQueriesEnabled()),Un(()=>le(!1)))}getAdvancedQueriesEnabled(){try{return!this.configService.getConfig()?.advancedQueriesDisabled&&!!this.getAdvancedQueries()?.advancedQueriesEnabled}catch(e){return this.loggingService.catch("Error in getAdvancedQueriesEnabled: ",e),!1}}signOutPreviousUser(){return this.signOutPreviousUser$.asObservable()}getUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.afAuth?.currentUser?this.user$.value:null}getUser$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUser$","color: green;"),ei(this.afAuth).pipe(he(e=>e?this.user$.asObservable():le(null)),Ct(Xt))}getAuthUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAuthUser","color: green;"),this.afAuth?.currentUser}getUserOptions(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOptions","color: green;"),this.userOptions$.value}getUserOptions$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOptions$","color: green;"),this.userOptions$.asObservable()}updateUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateUser","color: green;");try{let t=this.user$.value;if(e.userId&&e.userId!==t?.userId||e?.groupId&&e?.groupId!==t?.groupId||e?.organizationId&&e?.organizationId!==t?.organizationId)this.providedUser=e,this.initializeClient(e,this.userOptions$?.value||{},new Date().getTime(),void 0,"internal-updateUser");else if(this.providedUser=E(E({},this.providedUser),e),t){let r=E(E({},t),e);this.updateUserInternally(r)}}catch(t){this.loggingService.catch("Error in updateUser: ",t)}}signInWithCustomToken(e,t,r="manual"){this.loggingService.log("%c[WB] Calling FUNCTION: signInWithCustomToken","color: green;");try{return Sie(this.afAuth,t).then(a=>(this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:r,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)}),a)).catch(a=>(this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_FAILED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:r,forceReset:this.userOptions$.value?.forceReset,message:a.message,user:this.getUserWithoutContacts(e)}),a))}catch(a){return this.loggingService.catch("Error in signInWithCustomToken: ",a),Promise.reject(a)}}resetServicesCache(){this.loggingService.log("%c[WB] Calling FUNCTION: resetServicesCache in AuthService","color: green;");try{this.commonDbService?.unsubscribeFromObservables(),this.docService?.clearCacheOnUserCascade(),this.contactService?.clearCache(),this.iamService?.clearCache(),this.areaService?.clearCache(),this.commentService?.clearCache(),this.reactionService?.clearCache(),this.recorderAnnotationService?.clearCache(),this.viewsService?.clearCache()}catch(e){this.loggingService.catch("Error in resetServicesCache: ",e)}}initializeSignedInUser(e,t,r){this.loggingService.log("%c[WB] Calling FUNCTION: initializeSignedInUser","color: green;");try{let a=new zo;a.userSnippylyId=e.uid,a.type="signedIn",r&&(a=E(E({},a),r)),this.setUserToStorage(a),this.mergeUserWithProvidedUserData(a,t)}catch(a){this.loggingService.catch("Error in initializeSignedInUser: ",a)}}mergeUserWithProvidedUserData(e,t){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: mergeUserWithProvidedUserData","color: green;");try{e.userId=this.providedUser?.userId||e.userId;let r=null;if(this.usersService?.externalUserDataProviderAvailable()){let a=vt(),s=Rl.IDENTIFY;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:Hr.MERGE_USER_WITH_PROVIDED_USER_DATA,moduleName:s,source:"internal",payload:{userIds:[e.userId],organizationId:this.providedUser?.organizationId||e.organizationId}});let c=yield this.usersService.resolveUsers({userIds:[e.userId],organizationId:this.providedUser?.organizationId||e.organizationId,skipUserCheck:!0,uniqueId:a,moduleName:s});c&&c[e.userId]&&(r=JSON.parse(JSON.stringify(c[e.userId]||{}))),e=E(E({},e),r||{})}e.name=r?r?.name:this.providedUser?.name||e.name,e.clientUserName=r?r?.clientUserName:this.providedUser?.clientUserName||e.clientUserName,e.photoUrl=r?r?.photoUrl:this.providedUser?.photoUrl||e.photoUrl,e?.photoUrl===void 0&&(e.photoUrl=null),e.email=r?r?.email:this.providedUser?.email||e.email,e.color=r?.color||this.providedUser?.color||this.getUserAvatarColor(e.userId),e.textColor=r?.textColor||this.providedUser?.textColor||this.getUserTextColor(e.userId),e.initial=r?.initial||this.providedUser?.initial||e.initial||e.name?.charAt(0).toUpperCase()||e.email?.charAt(0).toUpperCase(),e.contacts=this.providedUser?.contacts||e.contacts,e.plan=this.providedUser?.plan||e.plan,e.groupId=this.providedUser?.groupId||e.groupId,e.clientGroupId=this.providedUser?.clientGroupId||e.clientGroupId,e.clientOrganizationId=this.providedUser?.clientOrganizationId||e.clientOrganizationId,e.organizationId=this.providedUser?.organizationId||e.organizationId,e.isAdmin=this.providedUser?.isAdmin,e.isReadOnly=this.providedUser?.isReadOnly,e.isAnonymous=this.providedUser?.isAnonymous,e.isGuest=this.providedUser?.isGuest,this.updateUserInternally(e)}catch(r){this.loggingService.catch("Error in mergeUserWithProvidedUserData: ",r)}})}updateUserInternally(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserInternally","color: green;");try{let t=Object.assign({},e);delete t.contacts,this.analyticsService.identifyUser(e.userSnippylyId,t,{forceReset:this.userOptions$.value?.forceReset}),this.getPlanDetailsCalled||this.getPlanDetailsFromDb();try{if(this.userPermissionService?.isPermissionProviderAvailable()&&e.clientOrganizationId){let r=[{userId:e.userId,resource:{id:e.clientOrganizationId,type:Fo.ORGANIZATION,source:Gi.IDENTIFY,organizationId:e.clientOrganizationId}}],a=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.IDENTIFY,uniqueId:a,timestamp:new Date().getTime(),source:"internal",payload:{requests:r}}),yield this.userPermissionService?.onResourceAccessRequired({requests:r,uniqueId:a,userId:e.userId,methodName:Gi.IDENTIFY,fromCache:!1})}}catch(r){this.loggingService.catch("Error in updateUserInternally: ",r)}this.afAuth.currentUser&&(this.user$.next(e),this.updateUserToFirebase(e))}catch(t){this.loggingService.catch("Error in updateUserInternally: ",t)}})}updateUserToFirebase(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserToFirebase","color: green;");try{let t=JSON.parse(JSON.stringify(e)),r=D(E({},t),{lastUpdated:new Date})}catch(t){this.loggingService.catch("Error in updateUserToFirebase: ",t)}}getPlanDetailsFromDb(){return Q(this,null,function*(){try{this.getPlanDetailsCalled=!0;let t=yield Qi(this.functions,Ji({url:wn.cloudFunction.getPlanDetails,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3})({apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType()});return t?.data?.isPlanExpired&&(this.analyticsService.trackEvent(Y.Events.Core.SDK_PLAN_EXPIRED),this.configService.getSF()||console.warn("Velt SDK plan has expired.")),this.planDetails$.next(t?.data||{planInfo:null,isPlanExpired:!1}),t}catch(e){return this.loggingService.catch("Error in getPlanDetailsFromDb: ",e),this.planDetails$.next({planInfo:null,isPlanExpired:!1}),Promise.resolve(null)}})}isPlanExpired$(){return this.planDetails$.pipe(Le(e=>!!e),de(e=>!!e?.isPlanExpired))}isPlanExpired(){return this.planDetails$.getValue()?.isPlanExpired}addPreSignOutFuction(e,t){try{this.preSignOutFunctions.set(e,t)}catch(r){this.loggingService.catch("Error in addPreSignOutFuction: ",r)}}setUserOrganization(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserOrganization","color: green;");let t=JSON.parse(JSON.stringify(this.userOrganization$.value||{}));this.getUser()?.organizationId===e?.organizationId?(t.metadata=e,this.userOrganization$.next(t)):this.userOrganization$.next(null)}catch(t){this.loggingService.catch("Error in setUserOrganization: ",t)}}setOrganizationUserGroups(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserOrganizationGroups","color: green;");let t=JSON.parse(JSON.stringify(this.userOrganization$.value||{}));this.getUser()?.organizationId===t?.metadata?.organizationId&&(t.groups=e,this.userOrganization$.next(t))}catch(t){this.loggingService.catch("Error in setUserOrganizationGroups: ",t)}}getUserOrganization$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOrganization$","color: green;"),this.getUser$().pipe(he(e=>e?this.userOrganization$.asObservable().pipe(de(t=>t?.metadata?.organizationId===e.organizationId?t:null)):le(null)))}signOutUser(e="internal"){return Q(this,null,function*(){try{e==="external"&&this.onRetrySubscription?.unsubscribe(),this.userPermissionService?.revokeAccessOnUserLogout(),yield this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_SIGN_OUT,{apiKey:this.apiKey,clientUserId:this.user$?.value?.userId,snippylyUserId:this.user$?.value?.userSnippylyId,message:e==="external"?"User Sign out":"System Sign out",user:this.user$?.value?this.getUserWithoutContacts(this.user$?.value):null,forceReset:this.userOptions$.value?.forceReset,source:e});let t=yield ei(this.afAuth).pipe(rt(1)).toPromise().catch(r=>null);if(t){this.resetServicesCache(),this.user$.next(null);for(let[r,a]of this.preSignOutFunctions)try{yield a(t)}catch(s){this.loggingService.catch(`Error in signOutUser ${r} function: `,s)}return this.user$.next(null),yield pm(1e3),bie(this.afAuth).catch(r=>{this.loggingService.catch("Error in signOutUser:",r)})}else return Promise.resolve()}catch(t){this.loggingService.catch("Error in signOutUser: ",t)}})}isFeatureAllowed(e){return ro(this.config,this.user$.value,e)}getUserWithoutContacts(e){try{if(e){let t=JSON.parse(JSON.stringify(e));return delete t.contacts,t}else return null}catch(t){return this.loggingService.catch("Error in getUserWithoutContacts: ",t),null}}getUserForClient(e){try{return Dr(e)}catch(t){return this.loggingService.catch("Error in getUserForClient: ",t),null}}getUserAvatarColor(e){try{return e?this.avatarService.generateUserColor(Nn(e)):"#625DF5"}catch{return"#625DF5"}}getUserTextColor(e){try{return"#FFFFFF"}catch{return"#FFFFFF"}}setOptionalPropertiesToUsers(e){try{e.forEach(t=>{try{t?.color||(t.color=this.getUserAvatarColor(t?.userId)),t?.textColor||(t.textColor=this.getUserTextColor(t?.userId)),!t?.initial&&(t?.name||t?.email)&&(t.initial=t.name?.charAt(0).toUpperCase()||t.email?.charAt(0).toUpperCase())}catch{}})}catch{}}};o.\u0275fac=function(t){return new(t||o)(ee(Ri),ee(Ft),ee(ym),ee(ni),ee(Be),ee(Do),ee(Qe),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Sm=class{constructor({apiKey:o,documentId:n,organizationId:e,folderId:t,veltFolderId:r,clientDocumentId:a,clientOrganizationId:s}){this.paths={},this.apiKey=o,this.documentId=n,this.organizationId=e,this.folderId=t,this.veltFolderId=r,this.clientDocumentId=a,this.clientOrganizationId=s,a&&(this.documentId=Tr(a)),s&&(this.organizationId=os(s)),t&&(this.folderId=t,this.veltFolderId=Ai(t)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let o=`${this.apiKey}`;this.organizationId&&(o=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`),this.documentId&&(this.paths.docs=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.folder=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}/`,this.paths.presence=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_PRESENCE}/`,this.paths.cursor=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CURSOR}/`,this.paths.comment=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/`,this.paths.multiThread=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,this.paths.tag=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_TAG}/`,this.paths.area=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AREA}/`,this.paths.arrow=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_ARROW}/`,this.paths.selection=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_SELECTION}/`,this.paths.audioHuddle=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,this.paths.huddle=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_HUDDLE}/`,this.paths.recorder=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/`,this.paths.flock=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,this.paths.syncVideoPlayer=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,this.paths.liveState=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,this.paths.liveStateSingleEditorMode=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,this.paths.reaction=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_REACTION}/`,this.paths.crdt=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CRDT}/`,this.paths.views=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_VIEWS}/`,this.paths.notifications=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,this.paths.metadata=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_METADATA}/`,this.paths.users=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.documentIam=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.userConfig=`${o}/${U.FIREBASE_PARTIAL_PATH_USERS}`),this.paths.customerMetadata=`${o}/${U.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,this.paths.groupContacts=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GROUPS}/`,this.paths.globalContacts=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GLOBAL}/`,this.paths.logins=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_LOGINS}/`,this.paths.userFeedback=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,this.paths.userReportBugs=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_BUGS}/`,this.paths.userContactUs=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,this.organizationId&&(this.paths.organizationMetadata=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,this.paths.organizationIam=`${o}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.organizationGroups=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,this.paths.organizationNotifications=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,this.documentId&&(this.paths.organizationNotificationsWithDocumentId=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/`,this.paths.heartbeatByDocument=`${o}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${this.documentId}/`),this.paths.organizationNotificationsLastNotificationTimestamp=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.organizationNotificationsUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.heartbeat=`${o}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),this.paths.workspaceIam=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_IAM}/`}}catch{}}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("User config path is not available.")}get workspaceIam(){return this.paths.workspaceIam?this.paths.workspaceIam:this.throwError("Workspace IAM path is not available.")}get docs(){return this.paths.docs?this.paths.docs:this.throwError("Docs path is not available.")}get presence(){return this.paths.presence?this.paths.presence:this.throwError("Presence path is not available.")}get cursor(){return this.paths.cursor?this.paths.cursor:this.throwError("Cursor path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get arrow(){return this.paths.arrow?this.paths.arrow:this.throwError("Arrow path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get tag(){return this.paths.tag?this.paths.tag:this.throwError("Tag path is not available.")}get selection(){return this.paths.selection?this.paths.selection:this.throwError("Selection path is not available.")}get audioHuddle(){return this.paths.audioHuddle?this.paths.audioHuddle:this.throwError("Audio huddle path is not available.")}get huddle(){return this.paths.huddle?this.paths.huddle:this.throwError("Huddle path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get flock(){return this.paths.flock?this.paths.flock:this.throwError("Flock path is not available.")}get syncVideoPlayer(){return this.paths.syncVideoPlayer?this.paths.syncVideoPlayer:this.throwError("Sync video player path is not available.")}get liveState(){return this.paths.liveState?this.paths.liveState:this.throwError("Live state path is not available.")}get liveStateSingleEditorMode(){return this.paths.liveStateSingleEditorMode?this.paths.liveStateSingleEditorMode:this.throwError("Live state single editor mode path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}get views(){return this.paths.views?this.paths.views:this.throwError("Views path is not available.")}get notifications(){return this.paths.notifications?this.paths.notifications:this.throwError("Notifications path is not available.")}get metadata(){return this.paths.metadata?this.paths.metadata:this.throwError("Metadata path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get documentIam(){return this.paths.documentIam?this.paths.documentIam:this.throwError("Document IAM path is not available.")}get organizationMetadata(){return this.paths.organizationMetadata?this.paths.organizationMetadata:this.throwError("Organization metadata path is not available.")}get organizationIam(){return this.paths.organizationIam?this.paths.organizationIam:this.throwError("Organization IAM path is not available.")}get customerMetadata(){return this.paths.customerMetadata?this.paths.customerMetadata:this.throwError("Customer metadata path is not available.")}get groupContacts(){return this.paths.groupContacts?this.paths.groupContacts:this.throwError("Group contacts path is not available.")}get globalContacts(){return this.paths.globalContacts?this.paths.globalContacts:this.throwError("Global contacts path is not available.")}get logins(){return this.paths.logins?this.paths.logins:this.throwError("Logins path is not available.")}get userFeedback(){return this.paths.userFeedback?this.paths.userFeedback:this.throwError("User feedback path is not available.")}get userReportBugs(){return this.paths.userReportBugs?this.paths.userReportBugs:this.throwError("User report bugs path is not available.")}get userContactUs(){return this.paths.userContactUs?this.paths.userContactUs:this.throwError("User contact us path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("Organization groups path is not available.")}get heartbeat(){return this.paths.heartbeat?this.paths.heartbeat:this.throwError("Heartbeat path is not available.")}get heartbeatByDocument(){return this.paths.heartbeatByDocument?this.paths.heartbeatByDocument:this.throwError("Heartbeat by document path is not available.")}get organizationNotifications(){return this.paths.organizationNotifications?this.paths.organizationNotifications:this.throwError("Organization notifications path is not available.")}get organizationNotificationsWithDocumentId(){return this.paths.organizationNotificationsWithDocumentId?this.paths.organizationNotificationsWithDocumentId:this.throwError("Organization notifications with document id path is not available.")}get organizationNotificationsUsers(){return this.paths.organizationNotificationsUsers?this.paths.organizationNotificationsUsers:this.throwError("Organization notifications users path is not available.")}get organizationNotificationsLastNotificationTimestamp(){return this.paths.organizationNotificationsLastNotificationTimestamp?this.paths.organizationNotificationsLastNotificationTimestamp:this.throwError("Organization notifications last notification timestamp path is not available.")}throwError(o){throw{type:"DocumentPaths",message:o,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var _9=class{constructor({apiKey:o,documentId:n,organizationId:e,clientDocumentId:t,clientOrganizationId:r,folderId:a,veltFolderId:s}){this.paths={},this.apiKey=o,this.documentId=n,this.organizationId=e,this.veltFolderId=s,t&&(this.documentId=Tr(t)),r&&(this.organizationId=os(r)),a&&(this.folderId=a,this.veltFolderId=Ai(a)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let o=`apiKey/${this.apiKey}`;this.organizationId&&(o=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`,this.paths.organization=o,this.paths.folder=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}`,this.paths.organizationUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,this.paths.users=`${o}/${U.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,this.paths.notificationDocs=`${o}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,this.paths.notificationUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.paths.organizationGroups=`${o}/${U.FIREBASE_PARTIAL_PATH_GROUPS}`,this.paths.lastNotificationTimestamp=`${o}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}`,this.paths.userConfig=`${o}/${U.FIREBASE_PARTIAL_PATH_USERS}`,this.paths.permissionsUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_PERMISSIONS_USERS}`),this.veltFolderId&&(this.paths.folderUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}/${this.veltFolderId}/${U.FIREBASE_PARTIAL_PATH_FOLDER_USERS}`),this.documentId&&(this.paths.document=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}`,this.paths.comment=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}`,this.paths.location=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LOCATION}`,this.paths.multiThread=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,this.paths.area=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AREA}`,this.paths.recorder=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`,this.paths.reaction=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_REACTION}`,this.paths.crdt=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CRDT}`,this.paths.notificationViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,this.paths.documentViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,this.paths.locationViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,this.paths.documentUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,this.paths.docNotification=`${this.paths.notificationDocs}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOC_NOTIFICATION}`)}}catch{}}get permissionsUsers(){return this.paths.permissionsUsers?this.paths.permissionsUsers:this.throwError("PermissionsUsers path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("UserConfig path is not available.")}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get lastNotificationTimestamp(){return this.paths.lastNotificationTimestamp?this.paths.lastNotificationTimestamp:this.throwError("LastNotificationTimestamp path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("organizationGroups path is not available.")}get docNotification(){return this.paths.docNotification?this.paths.docNotification:this.throwError("DocNotification path is not available.")}get organization(){return this.paths.organization?this.paths.organization:this.throwError("Organization path is not available.")}get document(){return this.paths.document?this.paths.document:this.throwError("Document path is not available.")}get location(){return this.paths.location?this.paths.location:this.throwError("Location path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get documentViews(){return this.paths.documentViews?this.paths.documentViews:this.throwError("DocumentViews path is not available.")}get locationViews(){return this.paths.locationViews?this.paths.locationViews:this.throwError("LocationViews path is not available.")}get notificationViews(){return this.paths.notificationViews?this.paths.notificationViews:this.throwError("NotificationViews path is not available.")}get documentUsers(){return this.paths.documentUsers?this.paths.documentUsers:this.throwError("DocumentUsers path is not available.")}get folderUsers(){return this.paths.folderUsers?this.paths.folderUsers:this.throwError("FolderUsers path is not available.")}get organizationUsers(){return this.paths.organizationUsers?this.paths.organizationUsers:this.throwError("OrganizationUsers path is not available.")}get notificationDocs(){return this.paths.notificationDocs?this.paths.notificationDocs:this.throwError("NotificationDocs path is not available.")}get notificationUsers(){return this.paths.notificationUsers?this.paths.notificationUsers:this.throwError("NotificationUsers path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}throwError(o){throw{type:"DocumentPaths",message:o,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var y9=class{};var In=(()=>{let o=class o{constructor(e,t){this.authService=e,this.loggingService=t,this.db$=new Ce(null);try{this.authService.getFirebaseConfig$().subscribe(r=>{r&&this.db$.next(wM(void 0,r.firebaseOptions.databaseURL))},r=>{this.loggingService.catch("Error in DatabaseService constructor: ",r)})}catch(r){this.loggingService.catch("Error in DatabaseService constructor:",r)}}getDb(){return this.db$.asObservable()}getDbValue(){return this.db$.getValue()}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var nl=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.commentAnnotationDataProvider$=new Ce(null),this.commentAnnotationById$=new Ce({}),this.fieldsToRemove=[],this.getCommentAnnotationById=a=>{try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.value?.[a]:void 0}catch(s){this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationById:",s);return}};try{this.loggingService.log("CommentAnnotationsResolverService initialized"),this.commentAnnotationDataProvider$.subscribe(a=>{a&&(a.config?.resolveTimeout&&(this.resolveTimeout=a.config.resolveTimeout),a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig),a.config?.getRetryConfig&&(this.retryGetConfig=a.config.getRetryConfig),a.config?.fieldsToRemove&&(this.fieldsToRemove=a.config.fieldsToRemove))})}catch(a){this.loggingService.catch("Error in CommentAnnotationsResolverService constructor:",a)}}getProvider(){try{let e=this.commentAnnotationDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService getProvider:",e);return}}ngOnDestroy(){try{this.commentAnnotationById$.next({})}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService ngOnDestroy:",e)}}resolveCommentAnnotations(a){return Q(this,arguments,function*({request:e,uniqueId:t,moduleName:r}){try{if(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: resolveCommentAnnotations","color: green;"),!this.commentAnnotationDataProviderAvailable())return{};let s,c=!1,p=!1,g=()=>{s&&(clearTimeout(s),s=void 0,p=!0)};return new Promise((f,I)=>{s=setTimeout(()=>{if(!p){c=!0,g();let ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:new Error("Comment annotation resolution timeout"),request:e}}),I(new Error("Comment annotation resolution timeout"))}},this.commentAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let T=this.getProvider();if(!T)return g(),f({});let B={},z=[...new Set(e.commentAnnotationIds||[])],G=D(E({},e),{commentAnnotationIds:z});Q(this,null,function*(){try{if(z.length>0||e.documentIds?.length||e.folderId){let ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{request:G}});let ve=ud(()=>T?.get(G)||Promise.resolve(void 0),"getCommentAnnotations",this.retryGetConfig).then(ye=>c?{}:(g(),ye&&ye.statusCode!==200?(this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),this.loggingService.catch(ye?.message??"Error in CommentAnnotationsResolverService resolveCommentAnnotations:"),{}):ye?.data)).catch(ye=>{throw g(),ye});try{B=(yield ve)||{},this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_GET,{sourceMethod:"resolveCommentAnnotations",source:"sdk",commentAnnotationIds:z});let ye={};Object.entries(B).forEach(([Ne,Ve])=>{let Ie=this.commentAnnotationById$.value?.[Ne];Ie?Ie&&JSON.stringify(Ie)!==JSON.stringify(Ve)&&(ye[Ne]=Ve):ye[Ne]=Ve}),Object.keys(ye).length>0&&this.commentAnnotationById$.next(E(E({},this.commentAnnotationById$.getValue()),ye)),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),f(ye)}catch(ye){let Ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:Ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ye,request:G}}),c||I(ye),f(B)}}else g(),f({})}catch(ne){g();let ve=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ve,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ne,request:G}}),I(ne)}})})}catch(s){this.loggingService.catch("Error in CommentAnnotationsResolverService resolveCommentAnnotations:",s);let c=t||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:s,request:e}}),{}}})}saveCommentAnnotation(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: saveCommentAnnotation","color: green;");let r=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{request:e}});let s=JSON.parse(JSON.stringify(this.commentAnnotationById$.getValue()));this.commentAnnotationById$._value=E(E({},s),e.commentAnnotation);let c=yield ud(()=>r?.save({commentAnnotation:e.commentAnnotation,event:e.eventType,commentId:e.commentId,metadata:Object.values(e.commentAnnotation??{})?.[0]?.metadata})||Promise.resolve(void 0),"saveCommentAnnotation",this.retrySaveConfig);return c&&c.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.commentAnnotationById$._value=s),this.loggingService.catch(c?.message??"Error in CommentAnnotationsResolverService saveCommentAnnotation:"),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:c,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_SAVE,{sourceMethod:"saveCommentAnnotation",source:"sdk",commentAnnotationIds:Object.keys(e.commentAnnotation),eventType:e.eventType,commentId:e.commentId}),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in CommentAnnotationsResolverService saveCommentAnnotation:",r);let a=t||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:r,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteCommentAnnotation(e,t,r){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: deleteCommentAnnotation","color: green;");let a=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation delete data provider not available");let s=r||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{commentAnnotationId:e.toString(),metadata:t}});let c=this.commentAnnotationById$.getValue(),p=E({},c);delete p?.[e],this.commentAnnotationById$._value=p;let g=yield ud(()=>a?.delete({commentAnnotationId:e.toString(),metadata:t,event:va.COMMENT_ANNOTATION_DELETE})||Promise.resolve(void 0),"deleteCommentAnnotation",this.retryDeleteConfig);return g&&g.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.commentAnnotationById$._value=c),this.loggingService.catch(g?.message??"Error in CommentAnnotationsResolverService deleteCommentAnnotation:"),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:g,commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_DELETE,{sourceMethod:"deleteCommentAnnotation",source:"sdk",commentAnnotationId:e.toString()}),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(a){this.loggingService.warn("Error in CommentAnnotationsResolverService deleteCommentAnnotation:",a);let s=r||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:a,commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getCommentAnnotationsById$(){try{return this.commentAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: getCommentAnnotationsById$","color: green;"),this.commentAnnotationById$.asObservable()):le(void 0)}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationsById$:",e),le(void 0)}}getAnnotationById(e){try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.getValue()?.[e]:void 0}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService getAnnotationById:",t);return}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService getFieldsToRemove:",e),this.fieldsToRemove}}setCommentAnnotationDataProvider(e){try{if(e){this.loggingService.log("Setting comment annotation data provider");let r=["get","save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.comment is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.commentAnnotationDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService setCommentAnnotationDataProvider:",t)}}commentAnnotationDataProviderAvailable(){try{return!!this.commentAnnotationDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService commentAnnotationDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var bm=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.reactionAnnotationDataProvider$=new Ce(null),this.reactionAnnotationById$=new Ce({}),this.getReactionAnnotationById=a=>{try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.value?.[a]:void 0}catch(s){this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationById:",s);return}};try{this.loggingService.log("ReactionAnnotationsResolverService initialized"),this.reactionAnnotationDataProvider$.subscribe(a=>{a&&(a.config?.resolveTimeout&&(this.resolveTimeout=a.config.resolveTimeout),a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig),a.config?.getRetryConfig&&(this.retryGetConfig=a.config.getRetryConfig))})}catch(a){this.loggingService.catch("Error in ReactionAnnotationsResolverService constructor:",a)}}getProvider(){try{let e=this.reactionAnnotationDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService getProvider:",e);return}}ngOnDestroy(){try{this.reactionAnnotationById$.next({})}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService ngOnDestroy:",e)}}resolveReactionAnnotations(a){return Q(this,arguments,function*({request:e,uniqueId:t,moduleName:r}){try{if(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: resolveReactionAnnotations","color: green;"),!this.reactionAnnotationDataProviderAvailable())return{};let s,c=!1,p=!1,g=()=>{s&&(clearTimeout(s),s=void 0,p=!0)};return new Promise((f,I)=>{s=setTimeout(()=>{if(!p){c=!0,g();let ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:new Error("Reaction annotation resolution timeout"),request:e}}),I(new Error("Reaction annotation resolution timeout"))}},this.reactionAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let T=this.getProvider();if(!T)return g(),f({});let B={},z=[...new Set(e.reactionAnnotationIds||[])],G=D(E({},e),{reactionAnnotationIds:z});Q(this,null,function*(){try{if(z.length>0||e.documentIds?.length||e.folderId){let ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{request:G}});let ve=ud(()=>T?.get(G)||Promise.resolve(void 0),"getReactionAnnotations",this.retryGetConfig).then(ye=>c?{}:(g(),ye&&ye.statusCode!==200?(this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),this.loggingService.catch(ye?.message??"Error in ReactionAnnotationsResolverService resolveReactionAnnotations:"),{}):ye?.data)).catch(ye=>{throw g(),ye});try{B=(yield ve)||{},this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_GET,{sourceMethod:"resolveReactionAnnotations",source:"sdk",reactionAnnotationIds:z});let ye={};Object.entries(B).forEach(([Ne,Ve])=>{let Ie=this.reactionAnnotationById$.value?.[Ne];Ie?Ie&&JSON.stringify(Ie)!==JSON.stringify(Ve)&&(ye[Ne]=Ve):ye[Ne]=Ve}),Object.keys(ye).length>0&&this.reactionAnnotationById$.next(E(E({},this.reactionAnnotationById$.getValue()),ye)),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),f(ye)}catch(ye){let Ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:Ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ye,request:G}}),c||I(ye),f(B)}}else g(),f({})}catch(ne){g();let ve=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ve,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ne,request:G}}),I(ne)}})})}catch(s){this.loggingService.catch("Error in ReactionAnnotationsResolverService resolveReactionAnnotations:",s);let c=t||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:s,request:e}}),{}}})}saveReactionAnnotation(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: saveReactionAnnotation","color: green;");let r=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{request:e}});let s=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue()));this.reactionAnnotationById$._value=E(E({},s),e);let c={reactionAnnotation:e,event:va.REACTION_ADD,metadata:Object.values(e??{})?.[0]?.metadata},p=yield ud(()=>r?.save(c)||Promise.resolve(void 0),"saveReactionAnnotation",this.retrySaveConfig);return p&&p.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.reactionAnnotationById$._value=s),this.loggingService.catch(p?.message??"Error in ReactionAnnotationsResolverService saveReactionAnnotation:"),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:p,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_SAVE,{sourceMethod:"saveReactionAnnotation",source:"sdk",reactionAnnotationIds:Object.keys(e),eventType:c.event}),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in ReactionAnnotationsResolverService saveReactionAnnotation:",r);let a=t||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:r,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteReactionAnnotation(e,t,r){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: deleteReactionAnnotation","color: green;");let a=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation delete data provider not available");let s=r||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{reactionAnnotationId:e.toString(),metadata:t}});let c=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue())),p=E({},c);delete p?.[e],this.reactionAnnotationById$._value=p;let g=yield ud(()=>a?.delete({reactionAnnotationId:e.toString(),metadata:t,event:va.REACTION_DELETE})||Promise.resolve(void 0),"deleteReactionAnnotation",this.retryDeleteConfig);return g&&g.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.reactionAnnotationById$._value=c),this.loggingService.catch(g?.message??"Error in ReactionAnnotationsResolverService deleteReactionAnnotation:"),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:g,reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_DELETE,{sourceMethod:"deleteReactionAnnotation",source:"sdk",reactionAnnotationId:e.toString()}),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(a){this.loggingService.warn("Error in ReactionAnnotationsResolverService deleteReactionAnnotation:",a);let s=r||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:a,reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getReactionAnnotationsById$(){try{return this.reactionAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: getReactionAnnotationsById$","color: green;"),this.reactionAnnotationById$.asObservable()):le(void 0)}catch(e){return this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationsById$:",e),le(void 0)}}getAnnotationById(e){try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.getValue()?.[e]:void 0}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService getAnnotationById:",t);return}}setReactionAnnotationDataProvider(e){try{if(e){this.loggingService.log("Setting reaction annotation data provider");let r=["get","save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.reaction is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.reactionAnnotationDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService setReactionAnnotationDataProvider:",t)}}reactionAnnotationDataProviderAvailable(){try{return!!this.reactionAnnotationDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in ReactionAnnotationsResolverService reactionAnnotationDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ot=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I){this.analyticsService=e,this.authService=t,this.databaseService=r,this.domService=a,this.configService=s,this.loggingService=c,this.commentResolverService=p,this.reactionResolverService=g,this.coreActionsService=f,this.functions=I,this.documentPaths$=new Ce(null),this.docContext$=new Ce(null),this.documentIds$=new Ce([]),this.organizationConfig$=new Ce(null),this.firestorePaths$=new Ce(null),this.location$=new Ce(null),this.excludedLocationIds$=new Ce([]),this.organizationMetadata$=new Ce(null),this.documentMetadata$=new Ce(null),this.locationMetadata$=new Ce(null),this.customerMetadata$=new Ce(null),this.currentDocumentId=null,this.isCustomDocId=!1,this.locations$=new Ce({}),this.preDocumentIdChangeFunctions=new Map,this.draftDocuments=[],this.clientDocumentMetadataMap={},this.uiState=new Ce({}),this.lastSetDocumentIdExecutionTime=0,this.lastSetDocumentIdCallTime=0,this.setDocumentIdSubject=new Xe,this.DEBOUNCE_TIME=5e3,this.MAX_QUEUE_SIZE=100,this.queueSize=0,this.isDocumentIdInDebounceQueue=!1,this.currentValidationToken=null,this.draftLocationMap={locations:[],options:void 0};try{this.loggingService.log("%c[WB] Creating CLASS: DocService","color: blue;"),this.domService.setDocService(this),this.authService.setDocService(this),this.setDocumentIdSubject.pipe(Bi(this.DEBOUNCE_TIME)).subscribe({next:T=>Q(this,null,function*(){try{yield this.setDocumentIdImpl(T.documentId,T.clientOrganizationId,T.options),this.lastSetDocumentIdExecutionTime=Date.now(),this.isDocumentIdInDebounceQueue=!1,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"})),this.draftLocationMap={locations:[],options:void 0}}finally{this.queueSize--}}),error:T=>{this.loggingService.catch("Error in setDocumentId subscription:",T),this.queueSize--}}),this.databaseService.getDb().pipe(Le(T=>!!T),rt(1)).subscribe(T=>{T&&(this.db=T)}),this.configService.getApiKey$().subscribe(T=>{if(this.apiKey=T,this.apiKey){if(!this.isCustomDocId){let B=Hk(window.location.href);this.currentUrl=B}this.analyticsService.updateDefaultProperties({apiKey:T})}}),this.authService.getUser$().subscribe(T=>Q(this,null,function*(){if(T&&(this.analyticsService.updateDefaultProperties({organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId}),this.draftDocuments?.length?(yield this.setDocuments({documents:this.draftDocuments,options:this.draftOptions??void 0,source:"internal"}),this.draftDocuments=[],this.draftOptions=void 0,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"}).then(()=>this.draftLocationMap={locations:[],options:void 0}))):this.documentPaths$?.value&&T?.organizationId&&this.documentPaths$.value?.organizationId!==T?.organizationId&&(yield this.setDocuments({documents:this.documentIds$.value.length?this.documentIds$.value.map(B=>({id:B.clientDocumentId})):[{id:this.documentPaths$.value?.clientDocumentId}],options:void 0,source:"internal"})),setTimeout(()=>{this.documentPaths$.value||this.loggingService.catch("Error in DocService constructor:","Please set document id to continue.")},1e4),T?.organizationId&&T?.clientOrganizationId)){let B={organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId};this.getOrganizationConfig()||this.organizationConfig$.next({organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId}),yield this.updateOrganizationMetadata(B)}})),this.documentPaths$.subscribe(T=>{let B={documentId:T?.documentId,clientDocumentId:T?.clientDocumentId,folderId:T?.folderId,allDocuments:T?.allDocuments,veltFolderId:T?.veltFolderId};T?.organizationId&&(B.organizationId=T.organizationId,B.clientOrganizationId=T.clientOrganizationId),this.analyticsService.updateDefaultProperties(B),this.domService.resetSelectedAnnotationsMap()}),this.location$.subscribe(T=>{this.analyticsService.updateDefaultProperties({clientLocation:T?.location,locationId:T?.locationId})}),this.organizationMetadata$.subscribe(T=>{this.authService.setUserOrganization(T?.[this.documentPaths$.value?.organizationId])}),this.documentPaths$.pipe(Le(T=>!!T),rt(1)).subscribe(()=>{try{this.subscribeToCustomerMetadata()}catch(T){this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",T)}},T=>{this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",T)}),this.loggingService.log("%c[WB] Creating CLASS: DocService 2","color: blue;"),this.onWindowPopstate(),this.onWindowClick()}catch(T){this.loggingService.catch("Error in DocService constructor:",T)}}getOptionsFromDocumentPaths(){try{return this.documentPaths$.value?{folderId:this.documentPaths$.value?.folderId,allDocuments:this.documentPaths$.value?.allDocuments,locationId:this.documentPaths$.value?.locationId,organizationId:this.documentPaths$.value?.clientOrganizationId}:null}catch(e){return this.loggingService.catch("Error in getOptionsFromDocumentPaths:",e),null}}clearCacheOnUserCascade(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCacheOnUserCascade in DocService","color: green;");try{this.organizationConfig$.next(null),this.organizationMetadata$.next(null),this.customerMetadata$.next(null),this.customerMetadataSubscription?.unsubscribe(),this.documentPaths$.value&&(this.draftOptions=this.getOptionsFromDocumentPaths(),this.draftLocationMap={locations:[this.location$.value?.location??null,...Object.values(this.locations$.value||{}).map(e=>e.location)].filter(e=>e!==null),options:{rootLocationId:this.location$.value?.location?.id}},this.currentDocumentId=null,this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.unsetDocuments({source:"internal"})}catch(e){this.loggingService.catch("Error in DocService clearCacheOnUserCascade: ",e)}}setCommonDbService(e){try{this.commonDbService=e}catch(t){this.loggingService.catch("Error in setCommonDbService:",t)}}setUserPermissionService(e){try{this.userPermissionService=e}catch(t){this.loggingService.catch("Error in setUserPermissionService:",t)}}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in setCommentService:",t)}}onWindowPopstate(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowPopstate","color: green;");try{this.domService.onWindowPopState$().subscribe(()=>{this.loggingService.log("location",location.href);let e=Hk(location.href);this.currentUrl!==e&&(this.currentUrl=e,!this.isCustomDocId&&this.apiKey&&this.loggingService.log("current url in doc service",this.currentUrl))},e=>{this.loggingService.catch("Error in DocService onWindowPopstate subscription: ",e)})}catch(e){this.loggingService.catch("Error in onWindowPopstate: ",e)}}onWindowClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowClick","color: green;");try{this.domService.onWindowClick$().subscribe(()=>{let e=Hk(location.href);this.currentUrl!==e&&(this.currentUrl=e,this.isCustomDocId||this.loggingService.log("current url in doc service",this.currentUrl))},e=>{this.loggingService.catch("Error in DocService onWindowClick subscription: ",e)})}catch(e){this.loggingService.catch("Error in onWindowClick: ",e)}}setDocument(s){return Q(this,arguments,function*({documentId:e,documentMetadata:t,options:r,source:a="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocument","color: green;"),a==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:e,documentMetadata:t,methodName:"setDocument",source:a}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENTS,source:a,payload:{documentId:e,documentMetadata:t,options:r}}),yield this.setDocumentsImpl({documents:[{id:e,metadata:t}],options:E({organizationId:t?.organizationId},r??{}),source:a})}catch(c){this.loggingService.catch("Error in DocService setDocument:",c)}})}shouldSetDocumentsAgain(e,t={}){try{this.loggingService.log("%c[WB] Calling FUNCTION: shouldSetDocumentsAgain","color: green;");let r=this.documentPaths$.value?.clientDocumentId,a=t?.rootDocumentId??e[0]?.id,s=this.documentIds$.value.map(g=>g.clientDocumentId),c=lz(this.getOptionsFromDocumentPaths()??{})??{};return!e.every(g=>s.includes(g.id))||!hi(c,t)||r!==a}catch(r){return this.loggingService.catch("Error in DocService shouldSetDocumentsAgain:",r),!0}}getDocumentIdsFromDocuments({documents:e,setClientDocumentMetadataMap:t=!1}){try{let r=[];return e.forEach(a=>{let s=a.id,c=`${Nn(s)}`;t&&a?.metadata&&typeof a.metadata=="object"&&(this.clientDocumentMetadataMap[s]=a.metadata),r.push({documentId:c,clientDocumentId:s})}),r}catch(r){return this.loggingService.catch("Error in DocService getDocumentIdsFromDocuments:",r),[]}}setDocuments(s){return Q(this,arguments,function*({documents:e,options:t,source:r="internal",skipPermissionValidation:a=!1}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocuments","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{documents:e,options:t,methodName:"setDocuments",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENTS,source:r,payload:{documents:e,options:t}}),yield this.setDocumentsImpl({documents:e,options:t??{},source:r,skipPermissionValidation:a})}catch(c){this.loggingService.catch("Error in DocService setDocuments:",c)}})}setRootDocument(r){return Q(this,arguments,function*({document:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootDocument","color: green;"),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_ROOT_DOCUMENT_TRIGGERED,methodName:Fa.SET_ROOT_DOCUMENT,source:t,payload:{document:e}});let a=this.getOptionsFromDocumentPaths()??{},s=this.documentIds$.value.map(c=>c.clientDocumentId);if(!s.includes(e.id)){let c=[...s.map(g=>({id:g})),{id:e.id}],p=this.getDocumentIdsFromDocuments({documents:c,setClientDocumentMetadataMap:!0});this.documentIds$.next(p)}yield this.setDocumentIdImpl(e.id,this.documentPaths$.value?.clientOrganizationId,a)}catch(a){this.loggingService.catch("Error in DocService setRootDocument:",a)}})}setDocContext(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocContext","color: green;");let t=JSON.parse(JSON.stringify(e??null));this.docContext$.next(t)}catch(t){this.loggingService.catch("Error in setDocContext: ",t)}}getDocContext(){return this.docContext$.getValue()}getDocContext$(){return this.docContext$.asObservable().pipe(Ct(Xt))}getProcessedDocContext(){return vce(this.getDocContext())}filterRelevantDocuments(a){return Q(this,arguments,function*({options:e,documentIds:t,skipPermissionValidation:r=!1}){try{let s=this.authService.getUser();return!s||!this.commonDbService?.shouldUseFirestore()||(t=yield this.fetchDocumentsFromFolder(e,t,s),yield this.handlePermissionProvider(e,t,s),t=yield this.filterDocumentsByPermissions(e,t,s,r),t=t.slice(0,50)),t}catch(s){return this.loggingService.catch("Error in DocService filterRelevantDocuments:",s),t}})}fetchDocumentsFromFolder(e,t,r){return Q(this,null,function*(){if(!e?.folderId||!e?.allDocuments)return t;try{let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));(yield hd({methodName:"getDocuments",data:{type:"getDocuments",metadata:{organizationId:e?.organizationId??r?.clientOrganizationId,folderId:e?.folderId}},getSdkProxy:a,userId:r?.userId??""}))?.data?.forEach(c=>{t.find(p=>p.clientDocumentId===c.id)||t.push({documentId:Tr(c.id),clientDocumentId:c.id})})}catch(a){this.loggingService.warn("Error in DocService fetchDocumentsFromFolder:",a)}return t})}buildPermissionRequests(e,t,r){try{let a=[];return e.organizationId&&e.organizationId!==r.clientOrganizationId&&a.push({userId:r.userId,resource:{id:e.organizationId,type:Fo.ORGANIZATION,source:Gi.SET_DOCUMENTS,organizationId:e.organizationId,context:e?.context}}),e.folderId&&a.push({userId:r.userId,resource:{id:e.folderId,type:Fo.FOLDER,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:e?.context}}),t&&t.forEach(s=>{a.push({userId:r.userId,resource:{id:s.clientDocumentId,type:Fo.DOCUMENT,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:e?.context}})}),e?.context&&this.userPermissionService?.getIsContextEnabled()&&Cce({input:e?.context}).forEach(c=>{let p=JSON.stringify(c.access);a.push({userId:r.userId,resource:{id:p,type:Fo.CONTEXT,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:c}})}),a}catch(a){return this.loggingService.catch("Error in buildPermissionRequests:",a),[]}}processAccessibleContexts(e,t){try{if(!e?.success||!e?.data?.length||!this.userPermissionService?.getIsContextEnabled())return;let r=e.data.filter(a=>a.type===Fo.CONTEXT&&a.hasAccess).map(a=>a.resourceId);if(this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContextIds:",JSON.parse(JSON.stringify(r??"nil"))),r?.length){let a=t.filter(c=>r.includes(c.resource.id)).map(c=>c.resource.context).filter(c=>!!c),s=_ce({input:a});this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContext:",JSON.parse(JSON.stringify(s??"nil"))),s?.access&&(this.loggingService.logContext("[CONTEXT] setting accessibleContext in docContext:",JSON.parse(JSON.stringify(s??"nil"))),this.setDocContext(s))}}catch(r){this.loggingService.catch("Error in processAccessibleContexts:",r)}}handlePermissionProvider(e,t,r){return Q(this,null,function*(){if(this.userPermissionService?.isPermissionProviderAvailable())try{this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with options:",JSON.parse(JSON.stringify(e??"nil")),"documentIds:",JSON.parse(JSON.stringify(t??"nil")),"user:",JSON.parse(JSON.stringify(r??"nil")));let a=this.buildPermissionRequests(e,t,r),s=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.SET_DOCUMENTS,uniqueId:s,timestamp:new Date().getTime(),source:"internal",payload:{requests:a}});let c=yield this.userPermissionService?.onResourceAccessRequired({requests:a,uniqueId:s,methodName:Gi.SET_DOCUMENTS,fromCache:!1});this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with res:",JSON.parse(JSON.stringify(c??"nil")),"requests:",JSON.parse(JSON.stringify(a??"nil"))),this.processAccessibleContexts(c,a)}catch(a){this.loggingService.catch("Error in handlePermissionProvider:",a)}})}filterDocumentsByPermissions(e,t,r,a=!1){return Q(this,null,function*(){if(a)return t;this.loggingService.logContext("[CONTEXT] filterDocumentsByPermissions called with options:",JSON.parse(JSON.stringify(e??"nil")),"documentIds:",JSON.parse(JSON.stringify(t??"nil")),"user:",JSON.parse(JSON.stringify(r??"nil")));let s=this.currentValidationToken,c=[...t];return s&&this.validatePermissionsInBackground(e,t,r,s),c})}validatePermissionsInBackground(e,t,r,a){let s=e?.organizationId??r?.clientOrganizationId;this.userPermissionService?.getUserPermissions({organizationId:s,documentIds:t.map(c=>c.clientDocumentId),folderIds:e?.folderId?[e?.folderId]:[]}).then(c=>{if(this.currentValidationToken===a&&c){this.userPermissionService?.setCurrentUserPermissions(c);let p=[];Object.entries(c?.[r.userId]?.documents??{}).forEach(([g,f])=>{f?.errorCode===Lo.PERMISSION_DENIED&&p.push(g)}),s&&c?.[r.userId]?.organization?.[s]?.errorCode===Lo.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to organization: ${s}`,void 0,void 0,!0),e?.folderId&&c?.[r.userId]?.folders?.[e?.folderId]?.errorCode===Lo.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to folder: ${e?.folderId}`,void 0,void 0,!0),p.length>0&&(this.loggingService.catch(`User does not have access to documents: ${p.join(", ")}`,void 0,void 0,!0),this.handleDeniedDocumentAccess(p,r,a))}}).catch(c=>{this.loggingService.catch("Error in background permission validation:",c)})}handleDeniedDocumentAccess(e,t,r){try{if(this.currentValidationToken!==r)return;let a=this.documentPaths$.value;this.coreActionsService.triggerAction(mt.ERROR,{event:Y.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"Access denied to document after optimistic load",documentIds:e,userId:t.userId,timestamp:new Date().getTime()});let s=this.documentIds$.value||[],c=s.filter(p=>!e.includes(p.clientDocumentId));c.length!==s.length&&(c.length>0?this.setDocuments({documents:c.map(p=>({id:p.clientDocumentId})),options:{organizationId:a?.clientOrganizationId},source:"internal",skipPermissionValidation:!0}):(this.loggingService.catch("Error in DocService handleDeniedDocumentAccess: Documents provided are all denied"),this.coreActionsService.triggerAction(mt.ERROR,{event:Y.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"All documents provided are denied",documentIds:e,userId:t.userId,timestamp:new Date().getTime()}),this.unsetDocuments({source:"internal"})))}catch(a){this.loggingService.catch("Error in handleDeniedDocumentAccess:",a)}}addUserInfoToOrganization(r){return Q(this,arguments,function*({organizationId:e,user:t}){try{let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));yield hd({data:{type:"addUserInfoToOrganization",metadata:{organizationId:e},user:t},getSdkProxy:a,userId:t?.userId??""})}catch(a){this.loggingService.warn("Error in DocService addUserInfoToOrganization:",a)}})}setDocumentsImpl(s){return Q(this,arguments,function*({documents:e,options:t,source:r,skipPermissionValidation:a=!1}){try{this.loggingService.logContext("[CONTEXT] setDocumentsImpl called with documents:",JSON.parse(JSON.stringify(e??"nil")),"options:",JSON.parse(JSON.stringify(t??"nil")));let c=t?.organizationId??this.documentPaths$.value?.clientOrganizationId;if(!this.shouldSetDocumentsAgain(e,lz(D(E({},t),{organizationId:c})))){r==="external"&&this.loggingService.catch("setDocuments called with previous request");return}let p=vt();this.currentValidationToken=p;let g=this.getDocumentIdsFromDocuments({documents:e,setClientDocumentMetadataMap:!0});if(g?.length===0){this.loggingService.warn("Minimum one document must be set in setDocuments");return}let f=this.authService.getUser();if(!f){this.draftDocuments=e,this.draftOptions=t;return}this.documentPaths$.value?.organizationId&&t?.organizationId&&this.documentPaths$.value?.organizationId!==t?.organizationId?this.authService.resetServicesCache():this.unsetDocuments({source:"internal",unsetDocumentPaths:!1});let I=t?.organizationId??f?.clientOrganizationId;if(I&&this.addUserInfoToOrganization({organizationId:I,user:f}),g=yield this.filterRelevantDocuments({options:t,documentIds:g,skipPermissionValidation:a}),this.documentIds$.next(g),g?.length){let T=g[0]?.clientDocumentId;t?.rootDocumentId&&g.find(B=>B.clientDocumentId===t?.rootDocumentId)&&(T=t?.rootDocumentId),yield this.debounceSetDocuments({documentId:T,clientOrganizationId:t?.organizationId,options:t})}return}catch(c){this.loggingService.catch("Error in DocService setDocumentsImpl:",c)}})}setDocumentId(a){return Q(this,arguments,function*({documentId:e,clientOrganizationId:t,source:r="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentId","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:e,clientOrganizationId:t,methodName:"setDocumentId",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENT_ID,source:r,payload:{documentId:e,clientOrganizationId:t}}),yield this.setDocumentsImpl({documents:[{id:e}],options:{organizationId:t},source:r})}catch(s){this.loggingService.catch("Error in setDocumentId:",s);return}})}debounceSetDocuments(a){return Q(this,arguments,function*({documentId:e,clientOrganizationId:t,options:r}){try{this.loggingService.log("%c[WB] Calling FUNCTION: debounceSetDocuments","color: green;");let s=Date.now(),c=s-this.lastSetDocumentIdCallTime,p=s-this.lastSetDocumentIdExecutionTime;if(this.lastSetDocumentIdCallTime=s,this.queueSize>=this.MAX_QUEUE_SIZE){this.loggingService.warn("SetDocumentId queue size exceeded limit");return}if(!this.documentPaths$.value&&!this.isDocumentIdInDebounceQueue||c>this.DEBOUNCE_TIME&&p>this.DEBOUNCE_TIME){yield this.setDocumentIdImpl(e,t,r),this.lastSetDocumentIdExecutionTime=s;return}this.documentPaths$.next(null),this.isDocumentIdInDebounceQueue=!0,this.draftLocationMap={locations:[],options:void 0},this.queueSize++,this.setDocumentIdSubject.next({documentId:e,clientOrganizationId:t,options:r??void 0});return}catch(s){this.loggingService.catch("Error in debounceSetDocuments:",s)}})}setDocumentIdImpl(e,t,r){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentIdImpl","color: green;");try{let a=this.authService.getUser();if(!a)return;this.currentDocumentId&&this.documentPaths$.value&&(yield this.callPreDocumentIdChangeFunctions(this.documentPaths$.value));let s=this.currentDocumentId;if(this.apiKey){let c=`${Nn(e)}`,p=r?.folderId,g=r?.folderId?Ai(r?.folderId):void 0,f=r?.locationId,I=r?.allDocuments,T=a?.organizationId?t?Tt(t):a?.organizationId:void 0,B=vt(),z=MC.SET_DOCUMENTS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:B,methodName:No.INIT_DOCUMENTS,moduleName:z,source:"internal",payload:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""}});let G=vt(),J=HI.SET_DOCUMENTS;if(this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,moduleName:J,methodName:Ho.INIT_DOCUMENTS,source:"internal",payload:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""}}),yield Promise.allSettled([this.commentResolverService.resolveCommentAnnotations({request:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""},uniqueId:B,moduleName:z}),this.reactionResolverService.resolveReactionAnnotations({request:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""},uniqueId:G,moduleName:J})]),this.currentDocumentId!==c||this.documentPaths$.value?.organizationId!==T){this.loggingService.log("setting new docid"),this.currentDocumentId=c;let ne=new o9,ve=new y9;ne.clientDocumentId=e,ve.clientDocumentId=e,ne.folderId=p,ve.folderId=p,ne.locationId=f,ve.locationId=f,ne.allDocuments=I,ve.allDocuments=I,ne.veltFolderId=g,ve.veltFolderId=g,ne.documentId=c,ve.documentId=c,T&&(ne.organizationId=T,ne.clientOrganizationId=t??a?.clientOrganizationId,ve.organizationId=T,ve.clientOrganizationId=t??a?.clientOrganizationId);let ye=`${this.apiKey}`,Ne=`apiKey/${this.apiKey}`;T&&(ye=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${ne.organizationId}`,Ne=`${Ne}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${ne.organizationId}`),ve.organization=`apiKey/${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}`,ve.document=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}`,ne.presence=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_PRESENCE}/`,ne.cursor=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CURSOR}/`,ne.comment=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/`,ve.comment=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_COMMENT}`,ne.multiThread=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,ve.multiThread=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,ne.tag=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_TAG}/`,ne.area=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AREA}/`,ve.area=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AREA}`,ne.arrow=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_ARROW}/`,ne.selection=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_SELECTION}/`,ne.audioHuddle=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,ne.huddle=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_HUDDLE}/`,ne.recorder=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/`,ve.recorder=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`,ne.flock=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,ne.syncVideoPlayer=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,ne.liveState=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,ne.liveStateSingleEditorMode=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,ne.reaction=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_REACTION}/`,ve.reaction=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_REACTION}`,ne.crdt=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CRDT}/`,ve.crdt=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CRDT}`,ne.customerMetadata=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,ne.views=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_VIEWS}/`,ve.notificationViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,ve.documentViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,ve.locationViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,ne.notifications=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,ne.metadata=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_METADATA}/`,ne.users=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,ne.documentIam=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.workspaceIam=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.groupContacts=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GROUPS}/`,ne.globalContacts=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GLOBAL}/`,ne.logins=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_LOGINS}/`,ne.userFeedback=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,ne.userReportBugs=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_BUGS}/`,ne.userContactUs=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,T&&(ne.organizationMetadata=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,ne.organizationIam=`${ye}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.organizationGroups=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,ne.organizationNotifications=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,c&&(ne.organizationNotificationsWithDocumentId=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/`,ne.heartbeatByDocument=`${ye}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${c}/`),ne.organizationNotificationsLastNotificationTimestamp=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,ne.organizationNotificationsUsers=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,ne.heartbeat=`${ye}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),ve.organizationUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,ve.users=`${Ne}/${U.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,ve.documentUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,ve.notificationDocs=`${Ne}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,ve.notificationUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.documentPaths$.next(ne),this.firestorePaths$.next(ve),ne?.clientOrganizationId&&ne?.organizationId&&!(ne?.clientOrganizationId===this.getOrganizationConfig()?.clientOrganizationId&&ne?.organizationId===this.getOrganizationConfig()?.organizationId)&&this.organizationConfig$.next({organizationId:ne?.organizationId,clientOrganizationId:ne?.clientOrganizationId}),Promise.allSettled([this.updateFolderMetadata(),this.updateDocumentMetadata(),this.fetchLocationMetadata(),this.updateOrganizationMetadata()]),s&&this.location$.value&&this.removeLocation({}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.SET_DOCUMENTS_SUCCESS,payload:{documentId:c,clientDocumentId:e}}),this.analyticsService.trackEvent(Y.Events.Doc.SET_DOCUMENTS_SUCCESS,{documentId:c,clientDocumentId:e},!0,this.getUserIdForAnalytics())}}else this.loggingService.catch("Error in setDocumentIdImpl: API key is not provided.")}catch(a){this.loggingService.catch("Error in setDocumentIdImpl: ",a)}})}unsetDocumentId({source:e,unsetDocumentPaths:t}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentId","color: green;");try{e==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocumentId",source:e}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,methodName:Fa.UNSET_DOCUMENT_ID,source:e}),this.unsetDocumentImpl({source:e,unsetDocumentPaths:t})}catch(r){this.loggingService.catch("Error in unsetDocumentId: ",r)}}unsetDocumentImpl({source:e,unsetDocumentPaths:t}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentImpl","color: green;");try{this.currentDocumentId&&this.documentPaths$.value&&this.callPreDocumentIdChangeFunctions(this.documentPaths$.value),this.userPermissionService?.revokeAccessOnDocumentUnset(),t&&(this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.currentDocumentId=null,this.location$.next(null),this.excludedLocationIds$.next([]),this.documentMetadata$.next(null),this.locationMetadata$.next(null),this.locations$.next({}),this.documentIds$.next([]),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_SUCCESS,source:e}),this.analyticsService.trackEvent(Y.Events.Doc.UNSET_DOCUMENTS_SUCCESS,{documentId:this.currentDocumentId,documentMetadata:this.documentMetadata$.value?.[this.currentDocumentId??""],message:e==="external"?"User unset document id":"System unset document id",source:e},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in unsetDocumentImpl: ",r)}}unsetDocuments({source:e,unsetDocumentPaths:t=!0}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocuments","color: green;");try{e==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocuments",source:e}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,source:e,methodName:Fa.UNSET_DOCUMENTS}),this.unsetDocumentImpl({source:e,unsetDocumentPaths:t})}catch(r){this.loggingService.catch("Error in unsetDocuments: ",r)}}addPreDocumentIdChangeFunction(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: addPreDocumentIdChangeFunction","color: green;"),this.preDocumentIdChangeFunctions.set(e,t)}catch(r){this.loggingService.catch("Error in addPreDocumentIdChangeFunction: ",r)}}callPreDocumentIdChangeFunctions(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: callPreDocumentIdChangeFunctions","color: green;");for(let[t,r]of this.preDocumentIdChangeFunctions)try{yield r(e)}catch(a){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",a)}}catch(t){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",t)}})}fetchOrganizationMetadata(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: fetchOrganizationMetadata","color: green;");try{if(!e&&this.getOrganizationConfig()&&(e=this.getOrganizationConfig()),this.db&&e?.organizationId){let t=e?.organizationId;yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{apiKey:this.apiKey??"",organizationId:t,field:"metadata"}}).then(r=>{r&&!r?.errorCode&&this.organizationMetadata$.next(D(E({},this.organizationMetadata$.value),{[t]:r}))}).catch(r=>{this.loggingService.catch("Error in fetchOrganizationMetadata: ",r)})}}catch(t){this.loggingService.catch("Error in fetchOrganizationMetadata: ",t)}})}fetchDocumentMetadata(e){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value,r=this.documentMetadata$.value;if(e=e.filter(a=>!r?.[a.documentId]),e?.some(a=>!a?.documentId||!a?.clientDocumentId)||!t)return;if(this.commonDbService?.shouldUseFirestore()){let a=t?.folderId,s=[],c={organizationId:t?.clientOrganizationId,folderId:a},p=[],g=20;for(let I=0;I<e.length;I+=g)p.push(e.slice(I,I+g));p.forEach(I=>{let T=JSON.parse(JSON.stringify(c));T.documentIds=I.map(B=>B.clientDocumentId),s.push(this.fetchDocuments(T))});let f={};s.length>0&&(yield Promise.all(s).then(I=>{I?.forEach(T=>{T?.forEach(B=>{B?.metadata?.documentId&&(f[B.metadata.documentId]=B.metadata)})}),this.setAllDocumentMetadata(E(E({},this.documentMetadata$.value),f))}).catch(I=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",I)}))}else r?.[t?.documentId??e?.[0]?.documentId]||this.commonDbService?.queryData({feature:"allDocuments",properties:{apiKey:this.apiKey??"",organizationId:t?.organizationId,documentId:t?.documentId??e?.[0]?.documentId,skipObjectValues:!0}}).then(a=>{a?.documentId&&this.setDocumentMetadata(a.documentId,a)}).catch(a=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",a)})}}catch(t){this.loggingService.catch("Error in fetchDocumentMetadata: ",t)}})}fetchLocationMetadata(){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value,t=this.documentIds$.value,r=e?.folderId,a=e?.allDocuments,s=[],c={organizationId:e?.clientOrganizationId,folderId:r,allDocuments:a},p=[],g=20;for(let I=0;I<t.length;I+=g)p.push(t.slice(I,I+g));p.forEach(I=>{let T=JSON.parse(JSON.stringify(c));T.documentIds=I.map(B=>B.clientDocumentId),s.push(this.fetchLocations(T))});let f=this.locationMetadata$.value??{};s.length>0&&Promise.all(s).then(I=>{I?.forEach(T=>{T?.forEach(B=>{B?.metadata?.documentId&&(f[B.metadata.documentId]=D(E({},f?.[B.metadata.documentId]??{}),{[B.location.id]:B}))})}),Object.keys(f||{}).length>0&&this.locationMetadata$.next(f)}).catch(I=>{this.loggingService.catch("Error in fetchLocationMetadata: ",I)})}}catch(e){this.loggingService.catch("Error in fetchLocationMetadata: ",e)}})}getLocationMetadatas(){return this.locationMetadata$.value}subscribeToCustomerMetadata(){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeToCustomerMetadata","color: green;");try{if(this.customerMetadataSubscription)return;this.db&&this.authService.getUser()&&this.documentPaths$.value&&(this.customerMetadataSubscription=this.commonDbService?.dbListener({feature:"customerMetadata",properties:{skipFirestore:!0}}).pipe(Un(t=>le(null))).subscribe(t=>{this.customerMetadata$.next(t?.data)}))}catch(e){this.loggingService.catch("Error in subscribeToCustomerMetadata: ",e)}}getDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentId","color: green;"),this.documentPaths$.value?.documentId}getClientDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getClientDocumentId","color: green;"),this.documentPaths$.value?.clientDocumentId}getDocumentIds$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds$","color: green;"),this.documentIds$.asObservable().pipe(de(e=>e?.slice()))}getDocumentIds(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds","color: green;"),this.documentIds$.value?.slice()}getLocationMetadata$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocationMetadata$","color: green;"),this.locationMetadata$.asObservable().pipe()}getDocumentPaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths$","color: green;"),this.documentPaths$.asObservable()}getFirestorePaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths$","color: green;"),this.firestorePaths$.asObservable()}getDocumentPaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.documentPaths$.value}generateDocumentId(e){try{return`${Nn(e)}`}catch(t){return this.loggingService.catch("Error in generateDocumentId: ",t),""}}generateOrganizationId(e){try{return`${Tt(e)}`}catch(t){return this.loggingService.catch("Error in generateOrganizationId: ",t),""}}getFirestorePaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths","color: green;"),this.firestorePaths$.value}setLocation(r){return Q(this,arguments,function*({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[e],options:void 0,methodName:"setLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,source:t,methodName:Fa.SET_LOCATION,payload:{locations:[e],options:void 0}}),this.setLocationsImpl({locations:[e]})}catch(a){this.loggingService.catch("Error in setLocation: ",a)}})}setLocations(a){return Q(this,arguments,function*({locations:e,options:t,source:r="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocations","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:e,options:t,methodName:"setLocations",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:Fa.SET_LOCATIONS,source:r,payload:{locations:e,options:t}}),this.setLocationsImpl({locations:e,options:t})}catch(s){this.loggingService.catch("Error in setLocations: ",s)}})}getValidLocations(e){try{let t=[];return e&&Array.isArray(e)&&e.forEach(r=>{if(r&&typeof r=="object"){let a=!0;r?.version&&(!r?.version?.id||!r?.version?.name)&&(this.loggingService.catch(`Error in setting location for locationId: ${r?.id}, If you're setting version then add id and name fields to version object.`),a=!1),a&&t.push(r)}}),t}catch(t){this.loggingService.catch("Error in getValidLocations: ",t)}return e}setRootLocation(r){return Q(this,arguments,function*({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_ROOT_LOCATION_TRIGGERED,{payload:{location:e,methodName:"setRootLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_ROOT_LOCATION_TRIGGERED,methodName:Fa.SET_ROOT_LOCATION,source:t,payload:{location:e}});let a=Object.values(this.locations$.value).map(s=>s.location).filter(s=>String(s.id)!==String(e.id));this.setLocationsImpl({locations:[e,...a],options:{rootLocationId:e.id}})}catch(a){this.loggingService.catch("Error in DocService setRootLocation:",a)}})}setLocationsImpl({locations:e,options:t}){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setLocationsImpl","color: green;"),e.length===0)return;if(!this.authService.getUser()){!t?.appendLocation&&e.length>0&&(this.draftLocationMap.options=D(E(E({},this.draftLocationMap.options??{}),t??{}),{rootLocationId:e[0].id})),this.draftLocationMap.locations=[...this.draftLocationMap.locations,...e],this.draftLocationMap.options=E(E({},this.draftLocationMap.options),t);return}let a=this.getValidLocations(e),s=[],c=[];this.location$.value?.location.id&&c.push(this.location$.value?.location.id),c=[...c,...Object.values(this.locations$.value).map(f=>f.location.id)].filter(f=>f!==void 0);let p;if(t?.rootLocationId&&t?.rootLocationId!==this.location$.value?.location.id&&(p=a.find(f=>f.id===t?.rootLocationId),!p)){this.loggingService.catch(`Error in setting locations, rootLocationId: ${t?.rootLocationId} not found in locations.`);return}if(t?.appendLocation){if(p){let f=or(p),I=Nn(JSON.stringify(f));f.id&&s.push({locationId:I,location:f}),this.location$.next({locationId:I,location:f})}}else{p||(p=a[0]);let f=or(p),I=Nn(JSON.stringify(f));f.id&&s.push({locationId:I,location:f}),this.location$.next({locationId:I,location:f})}let g=[];return a.slice(t?.appendLocation?0:1).forEach(f=>{if(f.id!==this.location$.value?.location.id){let I=E({},f),T=this.locations$.value;f?.id&&Object.keys(T).forEach(J=>{let ne=T[J];ne.location?.id===f.id&&(I=E(E({},ne.location),f),delete T?.[J])});let B=this.genarateLocationId(I),z={locationId:B,location:I};I.id&&s.push({locationId:B,location:I}),g.push(z);let G=D(E({},T),{[B]:z});this.locations$.next(G)}}),this.updateDocumentLocationMetadata(s),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.SET_LOCATIONS_SUCCESS,methodName:Fa.SET_LOCATIONS,payload:{locations:a,options:t}}),this.analyticsService.trackEvent(Y.Events.Doc.SET_LOCATIONS_SUCCESS,{locations:a,options:t},!0,this.getUserIdForAnalytics()),g}catch(r){this.loggingService.catch("Error in setLocationImpl: ",r);return}}addLocation({location:e,source:t="internal"}){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[e],options:{appendLocation:!0},methodName:"addLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:Fa.ADD_LOCATION,source:t,payload:{locations:[e],options:{appendLocation:!0}}}),this.setLocationsImpl({locations:[e],options:{appendLocation:!0}})}catch(r){this.loggingService.catch("Error in DocService addLocation:",r);return}}removeLocation({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:[e],methodName:"removeLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,source:t,methodName:Fa.REMOVE_LOCATION,payload:{locations:[e]}}),e&&this.removeLocationsImpl([e],t)}catch(r){this.loggingService.catch("Error in removeLocation: ",r)}}removeLocations({locations:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:e,methodName:"removeLocations",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,methodName:Fa.REMOVE_LOCATIONS,source:t,payload:{locations:e}}),this.removeLocationsImpl(e,t)}catch(r){this.loggingService.catch("Error in removeLocations: ",r)}}removeLocationsImpl(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:e},methodName:"removeLocations",message:"System removed locations",source:t},!0,this.getUserIdForAnalytics()),e?e.forEach(r=>{let a=this.genarateLocationId(r);this.getLocation()?.locationId===a&&(this.location$.next(null),t!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(s=>s.id!==r.id))),this.removeCustomLocation(r)}):(this.location$.next(null),this.locations$.next({}),t!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.analyticsService.trackEvent(Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locations:e},source:t},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in removeLocation: ",r)}}unsetLocationIds(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsetLocationIds","color: green;"),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.UNSET_LOCATIONS_TRIGGERED,methodName:Fa.UNSET_LOCATION_IDS,source:t,payload:{locationIds:e}}),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_LOCATIONS_TRIGGERED,{payload:{locationIds:e},methodName:"unsetLocationIds",message:"System unset location ids",source:t},!0,this.getUserIdForAnalytics()),e?.length?e.forEach(r=>{this.getLocation()?.location.id===r&&(this.location$.next(null),t!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(a=>a.id!==r))),this.removeCustomLocationId(r)}):(this.location$.next(null),this.locations$.next({}),t!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,methodName:Fa.REMOVE_LOCATIONS_SUCCESS,source:t,payload:{locationIds:e}}),this.analyticsService.trackEvent(Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locationIds:e},source:t},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in unsetLocationIds: ",r)}}getLocation$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.asObservable()}getLocation(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.value?JSON.parse(JSON.stringify(this.location$.value)):null}excludeLocationIds(e){try{this.excludedLocationIds$.next([...e])}catch(t){this.loggingService.catch("Error in excludeLocationIds: ",t)}}getExcludedLocationIds$(){try{return this.excludedLocationIds$.asObservable()}catch(e){return this.loggingService.catch("Error in getExcludedLocationIds$: ",e),le([])}}updateOrganizationMetadata(e){return Q(this,null,function*(){try{!e&&this.getOrganizationConfig()&&(e=this.getOrganizationConfig());let t=e?.organizationId,r=this.documentPaths$.value;if(this.db&&t&&r?.documentId){if(this.organizationMetadata$.value?.[t])return;let s=new h9;s.apiKey=this.configService?.getApiKey()??"",s.organizationId=t,s.clientOrganizationId=e?.clientOrganizationId,this.userPermissionService?.hasEditAccess({organizationId:t})&&(yield this.commonDbService?.updateData({feature:"organizationMetadata",data:JSON.parse(JSON.stringify(s)),properties:{organizationId:t,documentId:r?.documentId??""}})),yield this.fetchOrganizationMetadata(e)}}catch(t){this.loggingService.catch("Error in updateOrganizationMetadata: ",t)}})}updateFolderMetadata(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateFolderMetadata","color: green;"),this.db&&this.authService.getUser()&&this.documentPaths$.value?.folderId){let e=this.documentPaths$.value;if(!e?.veltFolderId||!e?.organizationId)return;if(!(yield this.commonDbService?.getData({feature:"folderMetadata",properties:{organizationId:e?.organizationId??"",folderId:e?.veltFolderId??""}}))?.metadata){let r={folderId:this.documentPaths$.value?.folderId,clientOrganizationId:e?.clientOrganizationId,parentFolderId:"root"};if(this.userPermissionService?.hasEditAccess({folderId:this.documentPaths$.value?.veltFolderId??""})){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));yield hd({methodName:"createFolder",data:{type:"createFolder",metadata:r},getSdkProxy:a,userId:this.authService.getUser()?.userId??""})}}}}catch(e){this.loggingService.catch("Error in updateFolderMetadata: ",e)}})}updateDocumentMetadata(){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value;if(e){let t=this.getDocumentIds();t.find(a=>a.documentId===e.documentId)||t.push({documentId:e.documentId??"",clientDocumentId:e.clientDocumentId??""});let r=t.map(a=>Q(this,null,function*(){let s=new i9;this.clientDocumentMetadataMap?.[a.clientDocumentId]&&(s=E(E({},this.clientDocumentMetadataMap[a.clientDocumentId]),s)),s.apiKey=this.configService?.getApiKey()??"",s.documentId=a.documentId,s.clientDocumentId=a.clientDocumentId,s.organizationId=e.organizationId,s.clientOrganizationId=e.clientOrganizationId,s.pageInfo=Ni();let c=e?.folderId,p=e?.veltFolderId;s?.pageInfo?.deviceInfo&&delete s?.pageInfo?.deviceInfo;let g=!0,f=this.documentMetadata$.value?.[a.documentId];if(c&&p){let I=this.getDocumentMetadata(a?.documentId??"")??(yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:a?.documentId??"",organizationId:e?.organizationId??"",field:"metadata"}}));I?.clientDocumentId&&!I?.errorCode?I?.folderId&&(I?.folderId!==c||I?.veltFolderId!==p)?(this.loggingService.catch(`Folder id mismatch for document ${a?.clientDocumentId??""}`),g=!1):I?.folderId===c?(c&&(s.folderId=c),p&&(s.veltFolderId=p)):(this.loggingService.catch(`Document ${a?.clientDocumentId??""} is not in the folder ${c??""}`),g=!1):(c&&(s.folderId=c),p&&(s.veltFolderId=p))}if(f){let I={};Object.entries(s).forEach(([T,B])=>{I[T]=B}),hi(I,f)&&(g=!1)}g&&this.userPermissionService?.hasEditAccess({documentId:a?.documentId??"",folderId:e?.allDocuments&&e?.veltFolderId?e?.veltFolderId:void 0})&&(yield this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(s)),properties:{organizationId:e?.organizationId??"",documentId:a?.documentId??""}}))}));yield Promise.allSettled(r),yield this.fetchDocumentMetadata(t)}}}catch(e){this.loggingService.catch("Error in updateDocumentMetadata: ",e)}})}updateDocumentLocationMetadata(e){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value;if(t){let r=this.getDocumentIds();r.find(a=>a.documentId===t.documentId)||r.push({documentId:t.documentId??"",clientDocumentId:t.clientDocumentId??""});for(let a of r){let s=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:a?.documentId??"",organizationId:t?.organizationId??"",field:"metadata"}});s?.errorCode&&(s={});let c=[];for(let p of e){let g=new l9;g.locationId=p?.locationId,g.veltLocationId=oz(p?.location?.id??""),g.location=p?.location,g.pageInfo=Ni(),g?.pageInfo?.deviceInfo&&delete g?.pageInfo?.deviceInfo;let f=D(E({},s),{[U.FIREBASE_PARTIAL_PATH_LOCATIONS]:D(E({},s[U.FIREBASE_PARTIAL_PATH_LOCATIONS]??{}),{[p?.locationId]:g})});this.commonDbService?.shouldUseFirestore()||c.push(this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(f)),properties:{documentId:a?.documentId??"",organizationId:t?.organizationId??""}}));let I=this.locationMetadata$.value;if(I||(I={}),p?.location?.id){let T=I?.[a.documentId],B=T?.[p?.location?.id??""];I&&(T||(I[a.documentId]={}),B||(I[a.documentId][p?.location?.id??""]={}),I[a.documentId][p?.location?.id??""]=D(E({},B),{location:p?.location})),Object.keys(I||{}).length>0&&this.locationMetadata$.next(I)}}yield Promise.allSettled(c)}}}}catch(t){this.loggingService.catch("Error in updateDocumentLocationMetadata: ",t)}})}genarateLocationId(e){try{return e&&typeof e=="object"?Nn(JSON.stringify(or(e))):0}catch(t){return this.loggingService.catch("Error in genarateLocationId: ",t),0}}removeCustomLocation(e,t="internal"){try{let r=this.genarateLocationId(e),a=this.locations$.value;a[r]&&(delete a[r],this.locations$.next(E({},a)),t!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(s=>s.id!==e.id)))}catch(r){this.loggingService.catch("Error in DocService removeLocation:",r)}}removeCustomLocationId(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomLocationId","color: green;");let r=this.locations$.value;Object.entries(r).forEach(([a,s])=>{s.location.id===e&&(delete r[a],this.locations$.next(E({},r)),t!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(c=>c.id!==e)))})}catch(r){this.loggingService.catch("Error in DocService removeCustomLocationId:",r)}}getLocationByClientLocationId(e){try{let t=this.getLocation()?.location;if(t?.id===e)return t;{let r=this.getLocations();Object.keys(r).forEach(a=>{let s=r[a];s.location?.id===e&&(t=s.location)})}return t}catch(t){this.loggingService.catch("Error in DocService getLocationByClientLocationId:",t);return}}removeLocationIfNotInDom(){try{let e=this.locations$.value,t=document.querySelectorAll(`[${U.ATTRIBUTES.VELT_LOCATION}]`),r=[];t.forEach(a=>{let s=a.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(s){let c=JSON.parse(s),p=this.genarateLocationId(c);r.push(p)}}),Object.keys(e).forEach(a=>{let s=e[a];r.includes(s.locationId)||delete e[a]}),this.locations$.next(E({},e))}catch(e){this.loggingService.catch("Error in DocService removeLocationIfNotInDom:",e)}}getLocations$(){try{return this.locations$.asObservable()}catch(e){return this.loggingService.catch("Error in DocService getLocations$:",e),le({})}}getLocations(){try{return this.locations$.value}catch(e){return this.loggingService.catch("Error in DocService getLocations:",e),{}}}getLocationFromElement(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: getLocationFromElement","color: green;");let t=null;if(e?.getAttribute(U.ATTRIBUTES.VELT_LOCATION)?t=e:t=e.closest(`[${U.ATTRIBUTES.VELT_LOCATION}]`),t){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(r){let a=JSON.parse(r);return{locationId:this.genarateLocationId(a),location:a}}}return null}catch(t){return this.loggingService.catch("Error in DocService getLocationFromElement:",t),null}}getElementMapWithLocation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getElementMapWithLocation","color: green;");let e={};return document.querySelectorAll(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`).forEach(r=>{if(r.getAttribute(U.ATTRIBUTES.VELT_LOCATION)){let a=this.getLocationFromElement(r);a?.locationId&&(e[a.locationId]={element:r,location:a})}else if(r.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID)){let a=r.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID);if(a){let s=this.getLocationByClientLocationId(a);s?.locationId&&(e[s.locationId]={element:r,location:s});let c={id:a},p=this.genarateLocationId(c);e[a]={element:r,location:{locationId:p,location:c}}}}}),e}catch(e){return this.loggingService.catch("Error in DocService getElementMapWithLocation:",e),{}}}getAdditionLocationFromElement(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: getAdditionLocationFromElement","color: green;");let t;if(t=e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`),t){if(t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION)){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(r)return JSON.parse(r)}else if(t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID)){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID);if(r)return{id:r}}}return null}catch(t){return this.loggingService.catch("Error in DocService getAdditionLocationFromElement:",t),null}}getAdditionalDocumentIdFromElement(e){try{return e?.closest(`[${U.ATTRIBUTES.VELT_DOCUMENT_ID}]`)?.getAttribute(U.ATTRIBUTES.VELT_DOCUMENT_ID)||null}catch(t){return this.loggingService.catch("Error in DocService getAdditionalDocumentIdFromElement:",t),null}}getDocumentMetadata(e){try{return e?this.documentMetadata$.value?.[e]||null:this.documentMetadata$.value?.[this.documentPaths$.value?.documentId??""]||null}catch(t){return this.loggingService.catch("Error in DocService getDocumentMetadata:",t),null}}getAllDocumentMetadata$(e){return this.getAllDocumentMetadataMap$().pipe(de(t=>t?.[e??this.documentPaths$.value?.documentId??""]||null),Ct(Xt))}getAllDocumentMetadata(){try{return Object.values(this.documentMetadata$.value||{})}catch(e){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",e),[]}}getAllDocumentMetadataMap$(){return this.documentMetadata$.asObservable().pipe(de(e=>e||{}),Ct(Xt))}getAllDocumentMetadataMap(){try{return this.documentMetadata$.value||{}}catch(e){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",e),{}}}getDocumentMetadataOfAvailableDocuments(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentMetadataOfAvailableDocuments","color: green;");let e=this.documentMetadata$.value||{},t={},r=this.documentPaths$.value?.veltFolderId,a=this.documentPaths$.value?.allDocuments;if(r&&a)Object.values(e).forEach(s=>{s?.documentId&&s?.veltFolderId===r&&(t[s.documentId]=s)});else{let s=this.documentIds$.value;if(s?.length)s.forEach(c=>{let p=e?.[c.documentId];p&&(t[c.documentId]=p)});else if(this.documentPaths$.value?.documentId){let c=e?.[this.documentPaths$.value?.documentId];c&&(t[this.documentPaths$.value?.documentId]=c)}}return Object.values(t)}catch(e){return this.loggingService.catch("Error in DocService getDocumentMetadataOfAvailableDocuments:",e),[]}}getDocumentMetadata$(e){return this.documentMetadata$.asObservable().pipe(de(t=>t?.[e??this.documentPaths$.value?.documentId??""]||null),Ct(Xt))}setDocumentMetadata(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentMetadata","color: green;");let r=JSON.parse(JSON.stringify(this.documentMetadata$.value??{}));r[e]=t,this.documentMetadata$.next(r)}catch(r){this.loggingService.catch("Error in DocService setDocumentMetadata:",r)}}setAllDocumentMetadata(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAllDocumentMetadata","color: green;"),this.documentMetadata$.next(e)}catch(t){this.loggingService.catch("Error in DocService setAllDocumentMetadata:",t)}}getOrganizationMetadata(e){return this.organizationMetadata$.value?.[e]||null}getOrganizationMetadata$(e){return this.organizationMetadata$.asObservable().pipe(de(t=>t?.[e]||null))}getOrganizationMetadataMap$(){return this.organizationMetadata$.asObservable().pipe(de(e=>e||{}),Ct(Xt))}getCustomerMetadata(){return this.customerMetadata$.value}getCustomerMetadata$(){return this.customerMetadata$.asObservable()}getOrganizationConfig$(){return this.organizationConfig$.asObservable().pipe(Ct(Xt))}getOrganizationConfig(){return this.organizationConfig$.value}getMetadataFromType(e,t){try{switch(e){case"area":return;case"comment":return t?.multiThreadAnnotationId?this.commentService?.getMultiThreadAnnotationById(t.multiThreadAnnotationId)?.metadata:void 0;case"reaction":case"recorder":return t?.commentAnnotationId?this.commentService?.getAnnotationById(t.commentAnnotationId)?.metadata:void 0;default:return}}catch(r){this.loggingService.catch("Error in DocService getMetadataFromType:",r);return}}getDefaultMetadata({clientDocumentId:e,documentId:t}){try{let r=this.documentPaths$.value;if(!r)return;let a=e||r.clientDocumentId,s=t||r.documentId,c=this.getDocumentMetadata(s);if(!c)return;let p=c?.folderId,g=c?.veltFolderId;return E(E({apiKey:this.configService.getApiKey()??void 0,clientDocumentId:a,clientOrganizationId:r.clientOrganizationId,documentId:s,organizationId:r.organizationId},p?{folderId:p}:{}),g?{veltFolderId:g}:{})}catch(r){this.loggingService.catch("Error in DocService getDefaultMetadata:",r);return}}getBaseMetadata(e,t){try{let r,a;t?.element?r=this.getAdditionalDocumentIdFromElement(t.element)||void 0:t?.clientDocumentId&&(r=t.clientDocumentId),r&&(a=this.generateDocumentId(r));let s=this.getMetadataFromType(e,t),c=this.getDefaultMetadata({clientDocumentId:r,documentId:a});return s||c||{}}catch(r){return this.loggingService.catch("Error in DocService getBaseMetadata:",r),{}}}getServerId({documentId:e,organizationId:t}){try{return e&&(e=this.generateDocumentId(e)),t&&(t=this.generateOrganizationId(t)),{documentId:e,organizationId:t}}catch(r){return this.loggingService.catch("Error in DocService getServerId:",r),null}}fetchDocuments(e){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 r=[];if(!e?.organizationId)return this.loggingService.catch("Error in fetchDocuments: organizationId is required"),[];if(e?.folderId){let s=Ai(e?.folderId);r.push(lt("metadata.veltFolderId","==",s))}return e?.documentIds?.length&&!e?.allDocuments&&r.push(lt("metadata.documentId","in",e?.documentIds?.map(s=>this.generateDocumentId(s)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allDocuments",properties:{firestoreQuery:r,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(e?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(t){return this.loggingService.catch("Error in DocService fetchDocuments:",t),[]}})}fetchLocations(e){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 r=[];if(!e?.organizationId)return this.commonDbService?.shouldUseFirestore()&&this.loggingService.catch("Error in fetchLocations: organizationId is required"),[];if(e?.folderId){let s=Ai(e?.folderId);r.push(lt("metadata.veltFolderId","==",s))}return e?.documentIds?.length&&!e?.allDocuments&&r.push(lt("metadata.documentId","in",e?.documentIds?.map(s=>this.generateDocumentId(s)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allLocations",properties:{firestoreQuery:r,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(e?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(t){return this.loggingService.catch("Error in DocService fetchLocations:",t),[]}})}updateDocuments(e){return Q(this,null,function*(){try{if(typeof e=="object"&&(e=JSON.parse(JSON.stringify(e??{}))),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let{organizationId:r,documents:a,folderId:s}=e;if(!r&&(r=this.documentPaths$.value?.clientOrganizationId,!r))return this.loggingService.catch("Error in updateDocuments: organizationId is required"),[];let c=os(r);if(!a||a.length===0)return this.loggingService.catch("Error in updateDocuments: documents is required"),[];let p=[],g=this.documentMetadata$.value??{};for(let f of a)if(f?.documentId){f.organizationId=c,f.clientOrganizationId=r,f.clientDocumentId=f.documentId;let I=Tr(f.documentId);f.documentId=I,f.apiKey=this.configService.getApiKey()??void 0,(s||this.documentPaths$.value?.folderId)&&(f.folderId=s||this.documentPaths$.value?.folderId,f.veltFolderId=Ai(s||this.documentPaths$.value?.folderId||""));let T=()=>{if(s&&this.documentPaths$.value?.folderId&&s!==this.documentPaths$.value?.folderId)return;let z=g?.[I];z?g[I]=E(E({},z),f):g[I]=f},B=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:I,organizationId:c,field:"metadata"}});if(B?.errorCode&&(B={}),B&&B.apiKey&&B.folderId&&s&&B.folderId!=f.folderId){this.loggingService.catch(`Error in updateDocuments: document ${f.clientDocumentId} already exists with different folderId: ${B.folderId}`);continue}if(B&&B.apiKey&&!B.folderId&&f.folderId){this.loggingService.catch(`Error in updateDocuments: document ${f.clientDocumentId} already exists, move this document to folder with REST API`);continue}T(),f&&this.commonDbService&&this.userPermissionService?.hasEditAccess({documentId:f?.documentId??""})&&p.push(this.commonDbService.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(f)),properties:{organizationId:c,documentId:I}}))}yield Promise.all(p),this.setAllDocumentMetadata(g)}catch(t){return this.loggingService.catch("Error in DocService updateDocuments:",t),[]}})}updateLocations(e){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{organizationId:r,locations:a,documentIds:s}=e;if((!s||s.length===0)&&(s=this.documentIds$.value.map(f=>f.clientDocumentId)??[],s.length===0))return this.loggingService.catch("Error in updateLocations: documentId is required"),[];if(!r&&(r=this.documentPaths$.value?.clientOrganizationId,!r))return this.loggingService.catch("Error in updateLocations: organizationId is required"),[];if(!a||a.length===0)return this.loggingService.catch("Error in updateLocations: locations is required"),[];let c=s.map(f=>Tr(f)),p=[],g=this.locationMetadata$.value;g||(g={}),c.forEach(f=>{a.forEach(I=>{let T=this.location$.value;if(I?.id===T?.location?.id&&this.location$.next({locationId:T?.locationId,location:I}),I?.id){delete I?.metadata;let B=oz(I.id),z=g?.[f],G=z?.[I.id];g&&(z||(g[f]={}),G||(g[f][I.id]={}),g[f][I.id]=D(E({},G),{location:I})),I&&this.commonDbService&&p.push(this.commonDbService.updateData({feature:"locationMetadata",data:JSON.parse(JSON.stringify({location:I})),properties:{organizationId:os(r),documentId:f,id:B}}))}})}),yield Promise.all(p),Object.keys(g||{}).length>0&&this.locationMetadata$.next(g)}catch(t){return this.loggingService.catch("Error in DocService updateLocations:",t),[]}})}fetchFolders(e){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 r=[];if(!e?.organizationId)return this.loggingService.catch("Error in fetchFolders: organizationId is required"),{data:[],parentFolders:[]};let a=[],s=this.generateOrganizationId(e?.organizationId);if(e?.folderId){let c=Ai(e?.folderId);r=yield this.commonDbService?.getData({feature:"folder",properties:{folderId:c,apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}}),r&&(r=[r]),a=yield this.commonDbService?.queryData({feature:"allFolders",properties:{firestoreQuery:[lt("metadata.veltParentFolderId","==",c)],folderId:c,apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}})}else r=yield this.commonDbService?.queryData({feature:"allFolders",properties:{apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}});return{data:r,parentFolders:a}}catch(t){return this.loggingService.catch("Error in DocService getFoldersRequest:",t),{data:[],parentFolders:[]}}})}getDocumentIam$(){return this.authService.getUser$().pipe(he(e=>e?this.documentPaths$.pipe(he(t=>t?.documentIam?this.commonDbService?.dbListener({feature:"documentIam",properties:{documentId:t.documentId,organizationId:t.organizationId,isCollection:!1}}).pipe(de(r=>r?.data?.docIamConfig??r?.data),Ct((r,a)=>JSON.stringify(r??{})===JSON.stringify(a??{}))):le(null))):le(null)))}getDocumentAccessType(e){try{return e&&e.features&&e.features.all?e.features.all.restricted?Di.RESTRICTED:Di.PUBLIC:e&&e.documentAccessType?e.documentAccessType:Di.PUBLIC}catch(t){return this.loggingService.catch("Error in DocService getDocumentAccessType:",t),Di.PUBLIC}}changeDocumentAccessType(e){return Q(this,null,function*(){try{let t=this.documentPaths$.value;if(t){let r=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",field:"docIamConfig"}});if(r?.errorCode)return;switch(delete r.documentAccessType,r.features||(r.features={}),r.features.all||(r.features.all={}),e){case Di.PUBLIC:r.features.all.restricted=!1;break;case Di.RESTRICTED:r.features.all.restricted=!0,r.features.all.guestMode=!1;break;default:break}this.commonDbService?.updateData({feature:"documentAccessType",data:JSON.parse(JSON.stringify(r)),properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??""}})}}catch(t){this.loggingService.catch("Error in DocService changeDocumentAccessType:",t)}})}getUserIdForAnalytics(){try{return this.authService?.getAuthUser()?.uid||""}catch(e){return this.loggingService.catch("Error in DocService getUserIdForAnalytics:",e),""}}setUIState(e){try{this.uiState.next(E(E({},this.uiState.value),e))}catch(t){this.loggingService.catch("Error in DocService setUIState:",t)}}getUIState$(){return this.uiState.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(In),ee(Be),ee(Ft),ee(_),ee(nl),ee(bm),ee(ni),ee(Do))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ln=(()=>{let o=class o{constructor(e,t,r,a,s){this.analyticsService=e,this.authService=t,this.coreActionsService=r,this.docService=a,this.loggingService=s,this.resolveOrganizationUsers=new Ce(!0),this.resolveFolderUsers=new Ce(!0),this.resolveDocumentUsers=new Ce(!0),this.unresolvedUsers=new Ce([]),this.resolveTimeout=60*1e3,this.resolveAttempts=new Map,this.subscriptions=new Dn,this.userDataProvider$=new Ce(null),this.userById$=new Ce({}),this.userByIdCalled$=new Ce({}),this.pendingResolutions=new Set,this.getUserById=c=>{try{return this.userById$.value?.[c]}catch(p){this.loggingService.catch("Error in UsersService getUserById:",p);return}};try{this.analyticsService.setUserService(this),this.authService.setUsersService(this),this.docService.getDocumentPaths$().pipe(Le(c=>!!c),he(()=>this.getUnresolvedUsers$().pipe(Le(c=>c.length>0),Bi(300),rt(20),he(c=>{let p=this.docService.getOrganizationConfig()?.organizationId;return this.commonDbService?this.commonDbService?.dbListener({feature:"allOrganizationUsers",properties:{organizationId:p,isCollection:!0,useQuery:!0,firestoreQuery:[li(lt("user.userId","in",c.slice(0,20)))]}}).pipe(de(g=>g?.data),Qt(g=>{if(g&&typeof g=="object"){delete g.undefined,delete g.null;let f=Object.values(g??{});this.setUserByIds(f.map(T=>T.user));let I=c.filter(T=>!f.some(B=>B.user.userId===T));I.length!==c.length&&this.setUnresolvedUsers(I)}})):le([])})))).subscribe()}catch(c){this.loggingService.catch("Error in UsersService constructor:",c)}}setCommonDbService(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCommonDbService","color: green;"),this.commonDbService=e}catch(t){this.loggingService.catch("Error in UsersService setCommonDbService:",t)}}setContactService(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setContactService","color: green;"),this.contactService=e}catch(t){this.loggingService.catch("Error in UsersService setContactService:",t)}}ngOnDestroy(){try{this.subscriptions.unsubscribe(),this.pendingResolutions.clear(),this.resolveAttempts.clear()}catch(e){this.loggingService.catch("Error in UsersService ngOnDestroy:",e)}}isResolverForFeatureDisabled(e){let t=this.userDataProvider$.getValue();try{switch(e){case"allOrganizationUsers":return t?!this.resolveOrganizationUsers.value:!0;case"allFolderUsers":return t?!this.resolveFolderUsers.value:!0;case"allDocumentUsers":return t?!this.resolveDocumentUsers.value:!0;default:return!1}}catch(r){return this.loggingService.catch("Error in UsersService isResolverForFeatureDisabled:",r),!1}}resolveUsers(g){return Q(this,arguments,function*({userIds:e,forceResolve:t,feature:r,organizationId:a,skipUserCheck:s=!1,uniqueId:c,moduleName:p}){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: resolveUsers","color: green;");let f=!1;if(r&&(f=this.isResolverForFeatureDisabled(r)),f)return{};{let I={},T=[],B={};if(e?.forEach(z=>{let G=this.getUserById(z);G?I[z]=G:this.userByIdCalled$.getValue()[z]?t&&T.push(z):(T.push(z),this.userByIdCalled$.next(D(E({},this.userByIdCalled$.getValue()),{[z]:!0})))}),T.length>0){let z=c||vt();this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:z,moduleName:p,methodName:Hr.RESOLVE_USERS,source:"internal",payload:{userIds:T,organizationId:a,feature:r,forceResolve:t,skipUserCheck:s,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}});let G={};try{let J,ne=new Promise((ve,ye)=>{J=setTimeout(()=>{ye(new Error("User resolution timeout"))},this.userDataProvider$.getValue()?.config?.resolveTimeout||this.userDataProvider$.getValue()?.resolveTimeout||this.resolveTimeout)});G=yield Promise.race([this.getUsersFromDB({userIds:T,organizationId:a,skipUserCheck:s}).finally(()=>{clearTimeout(J)}),ne]),this.analyticsService.trackEvent(Y.Events.Resolver.USER_RESOLVER_GET,{sourceMethod:"resolveUsers",source:"sdk",userIds:T}),this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:z,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{result:G,userIds:T,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}catch(J){this.loggingService.catch("Error in UsersService resolveUsers getUsers:",J,{userIds:T}),this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:z,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{error:J,userIds:T,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}finally{T?.forEach(J=>{if(!G[J]){let ne=new Set([...this.getUnresolvedUsers(),J]);this.unresolvedUsers.next(Array.from(ne)),G[J]={userId:J,name:`User ${J}`}}})}Object.entries(G).forEach(([J,ne])=>{ne&&(I[J]=G?.[J],B[J]=G?.[J])})}return Object.keys(B).length>0&&(this.authService.setOptionalPropertiesToUsers(Object.values(B)),this.userById$.next(E(E({},this.userById$.getValue()),B))),I}}catch(f){this.loggingService.catch("Error in UsersService resolveUsers:",f);let I=c||vt();return this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:I,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{error:f,userIds:e,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}}),{}}})}getUnresolvedUsers$(){return this.unresolvedUsers.asObservable()}getUnresolvedUsers(){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUnresolvedUsers","color: green;");try{return JSON.parse(JSON.stringify(this.unresolvedUsers.getValue()))}catch(e){return this.loggingService.catch("Error in UsersService getUnresolvedUsers:",e),[]}}setUnresolvedUsers(e){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUnresolvedUsers","color: green;");try{if(Array.isArray(e)){let t=JSON.parse(JSON.stringify(e));this.unresolvedUsers.next(t)}}catch(t){this.loggingService.catch("Error in UsersService setUnresolvedUsers:",t)}}getUsersFromDB(a){return Q(this,arguments,function*({userIds:e,organizationId:t,skipUserCheck:r=!1}){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUsersFromDB","color: green;");try{let s=this.userDataProvider$.getValue();if(s)return s.get(e);if(t||(t=this.docService.getOrganizationConfig()?.organizationId),!t)return{};let c=(yield this.getUsersFromDBWithBatching({userIds:e,organizationId:t,skipUserCheck:r}))??[];this.contactService?.setResolvedUsers(c.flat());let p={};return c.forEach(g=>{g.forEach(f=>{f?.user?.userId&&(p[f.user.userId]=f.user)})}),p}catch(s){return this.loggingService.catch("Error in UsersService getUsersFromDB:",s),{}}})}getUsersFromDBWithBatching(a){return Q(this,arguments,function*({userIds:e,organizationId:t,skipUserCheck:r=!1}){try{if(!e?.length)return[];let s=[];for(let g=0;g<e.length;g+=30)s.push(e.slice(g,g+30));let c=s.map((g,f)=>Q(this,null,function*(){try{return(yield this.commonDbService?.queryData({feature:"allOrganizationUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[lt("user.userId","in",g)],skipUserCheck:r}}))||[]}catch(I){return this.loggingService.catch(`Error in batch ${f+1}:`,I),[]}}));return yield Promise.all(c)}catch(s){return this.loggingService.catch("Error in getUsersFromDBWithBatching:",s),[]}})}getTemporaryUsersFromDBWithBatching(a){return Q(this,arguments,function*({userIds:e,organizationId:t,resourceIds:r}){try{if(!e?.length||!r?.length)return[];let s=[];for(let z=0;z<e.length;z+=30)s.push(e.slice(z,z+30));let c=[];for(let z=0;z<r.length;z+=30)c.push(r.slice(z,z+30));let p=[],g=0,f=(z,G)=>Q(this,null,function*(){try{return((yield this.commonDbService?.queryData({feature:"allPermissionsUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[li(lt("userId","in",z),lt("veltResourceId","in",G))]}}))??[])||[]}catch(J){return this.loggingService.catch(`Error in batch ${g+1}:`,J),[]}});for(let z of s)for(let G of c)p.push(f(z,G)),g++;return(yield Promise.all(p)).flat().filter((z,G,J)=>G===J.findIndex(ne=>ne.userId===z.userId&&ne.resourceId===z.resourceId))}catch(s){return this.loggingService.catch("Error in getTemporaryUsersFromDBWithBatching:",s),[]}})}getResolveOrganizationUsers$(){return this.resolveOrganizationUsers.asObservable()}getResolveFolderUsers$(){return this.resolveFolderUsers.asObservable()}getResolveDocumentUsers$(){return this.resolveDocumentUsers.asObservable()}getUserById$(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUserById$","color: green;"),this.userById$.asObservable().pipe(Ct(Xt))}catch(e){return this.loggingService.catch("Error in UsersService getUserById$:",e),le({})}}setUserByIds(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserByIds","color: green;");let t=JSON.parse(JSON.stringify(this.userById$.getValue()??{}));e.forEach(r=>{t[r.userId]=E(E({},t?.[r.userId]??{}),r)}),this.userById$.next(t)}catch(t){this.loggingService.catch("Error in UsersService setUserByIds:",t)}}setUserDataProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserDataProvider","color: green;"),this.userDataProvider$.next(e),e.config?.resolveUsersConfig?.organization===!1?this.resolveOrganizationUsers.next(!1):this.resolveOrganizationUsers.next(!0),e.config?.resolveUsersConfig?.folder===!1?this.resolveFolderUsers.next(!1):this.resolveFolderUsers.next(!0),e.config?.resolveUsersConfig?.document===!1?this.resolveDocumentUsers.next(!1):this.resolveDocumentUsers.next(!0)}catch(t){this.loggingService.catch("Error in UsersService setUserDataProvider:",t)}}externalUserDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: externalUserDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()&&!!this.userDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersService externalUserDataProviderAvailable:",e),!1}}userDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: userDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()}catch(e){return this.loggingService.catch("Error in UsersService userDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(ni),ee(ot),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Fpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromAreaAnnotations(e){try{this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: getUserIdsToResolveFromAreaAnnotations","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in AreaUtilsService getUserIdsToResolveFromAreaAnnotations:",t),[]}}mergeAreaWithUser(e){try{if(this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: mergeAreaWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in AreaUtilsService mergeAreaWithUser:",t),e}}formatAreaData(e){try{return this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: formatAreaData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in AreaUtilsService formatAreaData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Lpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromArrowAnnotations(e){try{this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: getUserIdsToResolveFromArrowAnnotations","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ArrowUtilsService getUserIdsToResolveFromArrowAnnotations:",t),[]}}mergeArrowWithUser(e){try{if(this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: mergeArrowWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in ArrowUtilsService mergeArrowWithUser:",t),e}}formatArrowData(e){try{return this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: formatArrowData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in ArrowUtilsService formatArrowData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var iu=class{static getFirestoreProdDbName(o,n){return n?.databaseURL?.includes("snippyly-plugin.firebaseio.com")||n?.databaseURL?.includes("snippyly-plugin-staging.firebaseio.com")?"sfdb":n?.storeDbId??(this.isTestingDb(n?.databaseURL??"")?"sdktest":`apikey${o.toLowerCase()}`)}static isTestingDb(o){try{return o.includes("-test")}catch(n){return nt.error("Error in isTestingDb:",n),!1}}};var ou=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.attachmentDataProvider$=new Ce(null);try{this.loggingService.log("AttachmentResolverService initialized"),this.attachmentDataProvider$.subscribe(a=>{a&&(a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig))})}catch(a){this.loggingService.catch("Error in AttachmentResolverService constructor:",a)}}getProvider(){try{let e=this.attachmentDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in AttachmentResolverService getProvider:",e);return}}saveAttachment(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: saveAttachment","color: green;");let r=this.getProvider();if(!this.attachmentDataProviderAvailable())throw new Error("Attachment save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{request:e}});let s=yield ud(()=>r?.save({attachment:e.attachment,event:e.eventType,metadata:e.attachment.metadata})||Promise.resolve(void 0),"saveAttachment",this.retrySaveConfig);if(s?.statusCode!==200){this.loggingService.catch(s?.message??"Error in AttachmentResolverService saveAttachment:"),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{error:s,request:e}});return}return this.analyticsService.trackEvent(Y.Events.Resolver.ATTACHMENT_RESOLVER_SAVE,{sourceMethod:"saveAttachment",source:"sdk",attachmentId:e.attachment.attachmentId,eventType:e.eventType}),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{result:s,request:e}}),s}catch(r){this.loggingService.warn("Error in AttachmentResolverService saveAttachment:",r);let a=t||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{error:r,request:e}});return}})}deleteAttachment(a,s){return Q(this,arguments,function*({attachmentId:e,metadata:t},r){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: deleteAttachment","color: green;");let c=this.getProvider();if(!this.attachmentDataProviderAvailable())throw new Error("Attachment delete data provider not available");let p=r||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:e,metadata:t}});let g=yield ud(()=>c?.delete({attachmentId:e,metadata:t,event:va.ATTACHMENT_DELETE})||Promise.resolve(void 0),"deleteAttachment",this.retryDeleteConfig);return g?.statusCode!==200?(this.loggingService.catch(g?.message??"Error in AttachmentResolverService deleteAttachment:"),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{error:g,attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.ATTACHMENT_RESOLVER_DELETE,{sourceMethod:"deleteAttachment",source:"sdk",attachmentId:e}),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(c){this.loggingService.warn("Error in AttachmentResolverService deleteAttachment:",c);let p=r||vt();return this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{error:c,attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}setAttachmentDataProvider(e){try{if(e){this.loggingService.log("Setting attachment data provider");let r=["save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.attachment is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.attachmentDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in AttachmentResolverService setAttachmentDataProvider:",t)}}attachmentDataProviderAvailable(){try{return!!this.attachmentDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in AttachmentResolverService attachmentDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ru=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.loggingService=e,this.usersService=t,this.authService=r,this.functions=a,this.configService=s,this.commentAnnotationsResolverService=c,this.attachmentResolverService=p,this.coreActionsService=g,this.notificationActionTypeMap={[Wt.NEWLY_ADDED]:va.COMMENT_ANNOTATION_ADD,[Wt.ADDED]:va.COMMENT_ADD,[Wt.UPDATED]:va.COMMENT_UPDATE,[Wt.DELETED]:va.COMMENT_DELETE}}setNotificationService(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setNotificationService","color: green;"),this.notificationService=e}catch(t){this.loggingService.catch("Error in CommentUtilsService setNotificationService: ",t)}}setUserPermissionService(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setUserPermissionService","color: green;"),this.userPermissionService=e}catch(t){this.loggingService.catch("Error in CommentUtilsService setUserPermissionService: ",t)}}getUserIdsToResolveFromComments(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: getUserIdsToResolveFromComments","color: green;");let t=new Set;for(let r of e){if(r?.from?.userId&&t.add(r?.from?.userId),r?.comments)for(let a of r?.comments){if(a?.from?.userId&&t.add(a?.from?.userId),a?.to)for(let s of a?.to)s?.userId&&t.add(s?.userId);if(a?.taggedUserContacts)for(let s of a?.taggedUserContacts)s?.userId&&t.add(s?.userId)}if(r?.assignedTo?.userId&&t.add(r?.assignedTo?.userId),r?.subscribedUsers)for(let a of Object.values(r?.subscribedUsers))a.user.userId&&t.add(a.user.userId);if(r?.unsubscribedUsers)for(let a of Object.values(r?.unsubscribedUsers))a.user.userId&&t.add(a.user.userId)}return Array.from(t)}catch(t){return this.loggingService.catch("Error in CommentUtilsService getUserIdsToResolveFromComments:",t),[]}}mergeCommentWithUser(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeCommentWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.comments)for(let t of e?.comments){if(t?.from?.userId){let a=this.usersService.getUserById(t?.from?.userId);a&&(t.from=a)}t?.to&&(t.to=t?.to?.map(a=>{if(a?.userId){let s=this.usersService.getUserById(a?.userId);if(s)return E(E({},a),s)}return a})),t?.taggedUserContacts&&(t.taggedUserContacts=t?.taggedUserContacts?.map(a=>{if(a?.contact){let s=this.usersService.getUserById(a?.contact?.userId);s&&(a.contact=s,(s?.name||s?.email)&&(a.text=`@${s?.name||s?.email}`))}return a})),(t?.taggedUserContacts?.filter((a,s,c)=>c.findIndex(p=>p.text===a.text)===s)||[]).forEach(a=>{if(a?.text){let s=new RegExp(pd(`{{${a.userId}}}`),"g");t.commentText?.includes(`@User ${a.userId}`)&&(s=new RegExp(pd(`@User ${a.userId}`),"g")),t.commentText=t.commentText?.replaceAll(s,a.text),t.commentHtml=t.commentHtml?.replaceAll(s,a.text)}})}if(e?.assignedTo?.userId){let t=this.usersService.getUserById(e?.assignedTo?.userId);t&&(e.assignedTo=t)}if(e?.subscribedUsers)for(let t of Object.values(e?.subscribedUsers)){let r=this.usersService.getUserById(t.user.userId);r&&e?.subscribedUsers?.id?.user&&(e.subscribedUsers.id.user=r)}if(e?.unsubscribedUsers)for(let t of Object.values(e?.unsubscribedUsers)){let r=this.usersService.getUserById(t.user.userId);r&&e?.unsubscribedUsers?.id?.user&&(e.unsubscribedUsers.id.user=r)}return e}catch(t){return this.loggingService.catch("Error in CommentUtilsService mergeCommentWithUser:",t),e}}formatCommentData(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentData","color: green;"),e?.comments?.forEach(t=>{t?.commentText&&t?.commentText?.length>0&&(t.isCommentTextAvailable=!0)}),e?.viewedBy&&delete e.viewedBy,e?.unread!==void 0&&delete e.unread,e?.comments&&e.comments.forEach(t=>{t?.reactionAnnotations&&delete t.reactionAnnotations}),this.usersService.userDataProviderAvailable()){if(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.assignedTo?.userId&&(e.assignedTo={userId:e.assignedTo.userId}),e?.subscribedUsers)for(let t of Object.keys(e?.subscribedUsers))e.subscribedUsers[t].user={userId:e?.subscribedUsers[t].user.userId};if(e?.unsubscribedUsers)for(let t of Object.keys(e?.unsubscribedUsers))e.unsubscribedUsers[t].user={userId:e?.unsubscribedUsers[t].user.userId}}return e?.comments&&(e.comments=e?.comments?.map(t=>this.formatCommentThreadData(t))),e}catch(t){return this.loggingService.catch("Error in CommentUtilsService formatCommentData:",t),e}}mergeStrippedDataWithCommentAnnotations(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeStrippedDataWithCommentAnnotations","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return e;let t=this.commentAnnotationsResolverService.getAnnotationById(e?.annotationId),r=this.attachmentResolverService.attachmentDataProviderAvailable(),a=this.commentAnnotationsResolverService.getFieldsToRemove();return t&&(e?.comments?.forEach(s=>{let c=t?.comments?.[s?.commentId];if(c){s.commentHtml=c?.commentHtml,s.commentText=c?.commentText;let p=c?.attachments;r&&p&&s.attachments?.forEach(g=>{let f=g?.attachmentId;p?.[f]&&(g.name=p?.[f]?.name,g.url=p?.[f]?.url)})}}),t?.targetTextRange?.text&&e?.targetTextRange&&(e.targetTextRange.text=t?.targetTextRange?.text),a?.length>0&&a.forEach(s=>{t?.[s]&&(e[s]=t[s])})),e}catch(t){return this.loggingService.catch("Error in CommentUtilsService mergeStrippedDataWithCommentAnnotations:",t),e}}mergeLocationWithCommentAnnotations(e,t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeLocationWithCommentAnnotations","color: green;");let r=e?.location?.id,a=e?.metadata?.documentId;if(!r||!a)return e;let s=t?.[a]?.[r];return s&&(e.location=s?.location),e}catch(r){return this.loggingService.catch("Error in CommentUtilsService mergeLocationWithCommentAnnotations:",r),e}}isCommentsDataChanged(e,t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: isCommentsDataChanged","color: green;");let r=this.commentAnnotationsResolverService.getCommentAnnotationById(t);return r?!hi(e,r):!0}catch(r){return this.loggingService.catch("Error in CommentUtilsService isCommentsDataChanged:",r),!0}}stripCommentsFromAnnotationData({comment:e}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentsFromAnnotationData","color: green;");let t=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable();if(!t)return e;let r=this.attachmentResolverService.attachmentDataProviderAvailable(),a=new _d;if(Object.assign(a,e),a.isCommentResolverUsed=t,r){let s=a.attachments?.map(c=>(c.isAttachmentResolverUsed=!0,delete c?.name,delete c?.url,c));a.attachments=s}return delete a?.commentHtml,delete a?.commentText,a}catch(t){return this.loggingService.catch("Error in CommentUtilsService stripCommentsFromAnnotationData:",t),e}}stripCommentAnnotationData({data:e,actionType:t,commentId:r}){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentAnnotationData","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return{originalData:e,strippedData:null};let a=this.attachmentResolverService.attachmentDataProviderAvailable(),s=this.commentAnnotationsResolverService.getFieldsToRemove(),c;t&&(c=this.notificationActionTypeMap?.[t]);let p={},g=null,f=!1;if(e&&e.annotationId){let T=e.annotationId;p[T]=E(E(E(E({annotationId:T,metadata:oC(e.metadata??{}),comments:{}},e?.from&&{from:e?.from}),e?.assignedTo&&{assignedTo:e?.assignedTo}),e?.resolvedByUserId&&{resolvedByUserId:e?.resolvedByUserId}),e?.targetTextRange?.text&&{targetTextRange:{text:e?.targetTextRange?.text}}),delete e?.targetTextRange?.text,s?.length>0&&s.forEach(z=>{e?.[z]&&(p[T][z]=e[z],delete e[z])}),e.comments?.forEach(z=>{if(z.commentId){let G;a&&(G={},z.attachments?.forEach(J=>{G[J.attachmentId]={attachmentId:J.attachmentId,name:J.name,url:J.url}})),p[T].comments[z.commentId]=E(E(E(E(E(E({commentId:z.commentId},z?.commentHtml&&{commentHtml:z?.commentHtml}),z?.commentText&&{commentText:z?.commentText}),G&&{attachments:G}),z?.from&&{from:z?.from}),z?.to&&{to:z?.to}),z?.taggedUserContacts&&{taggedUserContacts:z?.taggedUserContacts})}}),f=this.isCommentsDataChanged(p[T],T);let B=new Zo;Object.assign(B,e),B.comments=e.comments?.map(z=>this.stripCommentsFromAnnotationData({comment:z}))||[],g=B}let I=g?.comments?.find(T=>T.commentId===r);return I?.isDraft&&(c=g?.comments?.length&&g?.comments?.length>0?va.COMMENT_ADD:va.COMMENT_ANNOTATION_ADD),{strippedData:f&&(t||I?.isDraft)?p:null,originalData:g,eventType:c}}catch(a){return this.loggingService.catch("Error in CommentAnnotationsResolverService stripCommentAnnotationData:",a),{strippedData:null,originalData:null}}}formatCommentThreadData(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentThreadData","color: green;"),this.usersService.userDataProviderAvailable()){e?.from?.userId&&(e.from={userId:e.from.userId}),e?.to&&(e.to=e?.to?.map(r=>r?.userId?{userId:r.userId}:r)),e?.taggedUserContacts&&(e.taggedUserContacts=e?.taggedUserContacts?.map(r=>r?.contact?.userId?D(E({},r),{contact:{userId:r.contact.userId}}):r));let t=e?.taggedUserContacts?.filter((r,a,s)=>s.findIndex(c=>c.text===r.text)===a)||[];t.forEach(r=>{if(r?.text&&r?.contact?.userId){let a=new RegExp(pd(r.text),"g");e.commentText=e.commentText?.replaceAll(a,s=>`{{${r.userId}}}`),e.commentHtml=e.commentHtml?.replaceAll(a,s=>`{{${r.userId}}}`)}}),t.forEach(r=>{r?.text&&r?.contact?.userId&&(r.text="")})}return e}catch(t){return this.loggingService.catch("Error in CommentUtilsService formatCommentThreadData:",t),e}}getDeniedForYouUsers(t){return Q(this,arguments,function*({extraData:e}){try{let r=Object.values(e?.annotationData?.subscribedUsers||{}).map(s=>s.user.userId)??[],a=[];if(this.userPermissionService?.isPermissionProviderAvailable()&&r.length){let s=e?.metadata?.clientDocumentId,c=[];r.forEach(f=>{if(c.push({userId:f,resource:{id:s,type:Fo.DOCUMENT,source:Gi.SET_NOTIFICATIONS,organizationId:e?.metadata?.clientOrganizationId??""}}),e?.annotationData?.context?.access&&this.userPermissionService?.getIsContextEnabled()){let I=JSON.stringify(e?.annotationData?.context?.access);c.push({userId:f,resource:{id:I,type:Fo.CONTEXT,source:Gi.SET_NOTIFICATIONS,organizationId:e?.metadata?.clientOrganizationId??"",context:{access:e?.annotationData?.context?.access}}})}});let p=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.SET_NOTIFICATIONS,uniqueId:p,timestamp:new Date().getTime(),source:"internal",payload:{requests:c}});let g=yield this.userPermissionService?.onResourceAccessRequired({requests:c,uniqueId:p,methodName:Gi.SET_NOTIFICATIONS});g?.success&&g?.data?.length&&g.data.forEach(f=>{f.hasAccess||a.push(f.userId)})}return a}catch(r){return this.loggingService.catch("Error in CommentUtilsService getDeniedForYouUsers:",r),[]}})}handleCommentEncryption(c){return Q(this,arguments,function*({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: handleCommentEncryption","color: green;");let p=Bk(this.authService.getFirebaseConfig()?.firebaseOptions),g=Qi(this.functions,Ji({url:wn.cloudFunction?.[p]?.setEncryptedData,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3});if(r){r=this.notificationService?.processNotificationData(r),r.annotationData=e;let z=r?.targetAnnotationData?.commentId;if(z){let G=e?.comments?.find(J=>J?.commentId===z);G&&(r.targetAnnotationData=G)}try{let G=this.stripCommentAnnotationData({data:r.annotationData,actionType:r?.actionType??Wt.NEWLY_ADDED});G?.originalData&&(r.annotationData=this.formatCommentData(G.originalData)),r?.targetAnnotationData&&(r.targetAnnotationData=this.formatCommentThreadData(this.stripCommentsFromAnnotationData({comment:r.targetAnnotationData})))}catch(G){this.loggingService.warn("Error in CommentUtilsService handleCommentEncryption:",G)}}let f=iu.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),I=yield this.getDeniedForYouUsers({extraData:r}),T={path:t??"",data:e??{},dbId:f??"",notificationData:r||void 0,notificationURL:wn.firebaseNotificationsDatabaseURL,feature:"comment",eventType:a??"PATCH",sdkVersion:_a(),deniedForYouUsers:I,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),isCommentResolverUsed:this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),metadata:s},B=yield wl(T,this.authService.getUser()?.userId??"");yield g({veltData:B})}catch(p){this.loggingService.catch("Error in CommentUtilsService handleCommentEncryption:",p)}})}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln),ee(je),ee(Do),ee(Ft),ee(nl),ee(ou),ee(ni))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Bpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromUserIamData(e){try{this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: getUserIdsToResolveFromUserIamData","color: green;");let t=new Set;if(e?.length)for(let r of e)r?.user?.userId&&t.add(r?.user?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ContactUtilsService getUserIdsToResolveFromUserIamData: ",t),[]}}mergeUserIamWithUser(e){try{if(this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: mergeUserIamWithUser","color: green;"),e?.user?.userId){let t=this.usersService.getUserById(e?.user?.userId);if(t){let r=t;e?.user&&typeof e.user=="object"&&(r=E(E({},r),e.user)),e=D(E({},e),{user:r})}}return e}catch(t){return this.loggingService.catch("Error in ContactUtilsService mergeUserIamWithUser: ",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Vpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromCursorUsers(e){try{this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: getUserIdsToResolveFromCursorUsers","color: green;");let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in CursorUtilsService getUserIdsToResolveFromCursorUsers:",t),[]}}mergeCursorUserWithUser(e){try{if(this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: mergeCursorUserWithUser","color: green;"),this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in CursorUtilsService mergeCursorUserWithUser:",t),e}}formatCursorUserData(e){try{if(this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: formatCursorUserData","color: green;"),this.usersService.userDataProviderAvailable()){let t=["userId","comment","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","targetElement","position","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in CursorUtilsService formatCursorUserData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var I9=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromHuddleAttendees(e){try{this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: getUserIdsToResolveFromHuddleAttendees","color: green;");let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in HuddleUtilsService getUserIdsToResolveFromHuddleAttendees:",t),[]}}mergeHuddleAttendeeWithUser(e){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: mergeHuddleAttendeeWithUser","color: green;"),e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService mergeHuddleAttendeeWithUser:",t),e}}formatHuddleAttendeeData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","userSnippylyId","state","timestamp","initialHuddleMode","streamMetadata","initialHuddleType","huddleOnCursorMode"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService formatHuddleAttendeeData:",t),e}}getUserIdsToResolveFromHuddleMessages(e){try{this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: getUserIdsToResolveFromHuddleMessages","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in HuddleUtilsService getUserIdsToResolveFromHuddleMessages:",t),[]}}mergeHuddleMessageWithUser(e){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: mergeHuddleMessageWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService mergeHuddleMessageWithUser:",t),e}}resolveUsersFromHuddleMessages(e){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: resolveUsersFromHuddleMessages","color: green;"),this.usersService.userDataProviderAvailable()){let t=this.getUserIdsToResolveFromHuddleMessages(e),r=vt(),a=Rl.GET_HUDDLE_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:Hr.RESOLVE_USERS_FROM_HUDDLE_MESSAGES,moduleName:a,source:"internal",payload:{userIds:t}});let s=yield this.usersService.resolveUsers({userIds:t,uniqueId:r,moduleName:a});for(let c of e)c?.from?.userId&&s[c.from.userId]&&(c.from=s[c.from.userId])}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService resolveUsersFromHuddleMessages:",t),e}})}formatHuddleMessageData(e){try{return this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: formatHuddleMessageData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService formatHuddleMessageData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var E9=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromLiveStateCustom(e){try{let t=new Set;return e?.updatedBy&&t.add(e?.updatedBy?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustom:",t),[]}}mergeLiveStateCustomWithUser(e){try{if(e?.updatedBy?.userId){let t=this.usersService.getUserById(e?.updatedBy?.userId);t&&(e.updatedBy=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateCustomWithUser:",t),e}}formatLiveStateCustomData(e){try{return this.usersService.userDataProviderAvailable()&&e?.updatedBy&&(e.updatedBy={userId:e.updatedBy.userId}),e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateCustomData:",t),e}}getUserIdsToResolveFromLiveStateCustoms(e){try{let t=new Set;for(let r of e)r?.updatedBy?.userId&&t.add(r?.updatedBy?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustoms:",t),[]}}getUserIdsToResolveFromLiveStates(e){try{let t=new Set;return e?.default?.singleEditorMode?.editor?.userId&&t.add(e?.default?.singleEditorMode?.editor?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStates:",t),[]}}getUserIdsToResolveFromLiveStateSingleEditorMode(e){try{let t=new Set;return e?.editor?.userId&&t.add(e?.editor?.userId),e?.requestEditorAccess?.user?.userId&&t.add(e?.requestEditorAccess?.user?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateSingleEditorMode:",t),[]}}mergeLiveStateWithUser(e){try{if(e?.default?.singleEditorMode?.editor?.userId){let t=this.usersService.getUserById(e?.default?.singleEditorMode?.editor?.userId);t&&(e.default.singleEditorMode.editor=t)}if(e?.default?.singleEditorMode?.requestEditorAccess?.user?.userId){let t=this.usersService.getUserById(e?.default?.singleEditorMode?.requestEditorAccess?.user?.userId);t&&(e.default.singleEditorMode.requestEditorAccess.user=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateWithUser:",t),e}}mergeSingleEditorLiveStateDataWithUser(e){try{if(e?.editor?.userId){let t=this.usersService.getUserById(e?.editor?.userId);t&&(e.editor=t)}if(e?.requestEditorAccess?.user?.userId){let t=this.usersService.getUserById(e?.requestEditorAccess?.user?.userId);t&&(e.requestEditorAccess.user=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeSingleEditorLiveStateDataWithUser:",t),e}}resolveAndMergeSingleEditorLiveStateDataWithUser(e){return Q(this,null,function*(){try{let t=this.getUserIdsToResolveFromLiveStates({default:{singleEditorMode:e}});if(t.length){let r=vt(),a=Rl.GET_SINGLE_EDITOR_USERS;return this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:Hr.RESOLVE_AND_MERGE_SINGLE_EDITOR_LIVE_STATE_DATA_WITH_USER,moduleName:a,source:"internal",payload:{userIds:t}}),yield this.usersService.resolveUsers({userIds:t,uniqueId:r,moduleName:a}),this.mergeSingleEditorLiveStateDataWithUser(e)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService resolveAndMergeSingleEditorLiveStateDataWithUser:",t),e}})}formatLiveStateSingleEditorModeData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.editor?.userId&&(e.editor={userId:e.editor.userId}),e?.requestEditorAccess?.user?.userId&&(e.requestEditorAccess.user={userId:e.requestEditorAccess.user.userId})),e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateSingleEditorModeData:",t),e}}mergeLiveStateCustomsWithUsers(e){try{for(let t of e)if(t?.updatedBy?.userId){let r=this.usersService.getUserById(t?.updatedBy?.userId);r&&(t.updatedBy=r)}return e}catch(t){return this.loggingService.catch("Error in mergeLiveStateCustomsWithUsers:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var $pe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromMultiThreads(e){try{let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService getUserIdsToResolveFromMultiThreads:",t),[]}}mergeMultiThreadWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService mergeMultiThreadWithUser:",t),e}}formatMultiThreadData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.commentAnnotationsMap&&(e.commentAnnotationsMap=null)),e}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService formatMultiThreadData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var VC=(()=>{let o=class o{constructor(e,t,r){this.authService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromRecorders(e){try{let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId),r?.transcription?.from?.userId&&t.add(r?.transcription?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in RecorderUtilsService getUserIdsToResolveFromRecorders:",t),[]}}mergeRecorderWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.transcription?.from?.userId){let t=this.usersService.getUserById(e?.transcription?.from?.userId);t&&(e.transcription.from=t)}return e}catch(t){return this.loggingService.catch("Error in RecorderUtilsService mergeRecorderWithUser:",t),e}}formatRecorderData(e,t){try{return e.transcription=e?.transcription?D(E({},e.transcription),{lastUpdated:t}):void 0,this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.transcription?.from?.userId&&(e.transcription.from={userId:e.transcription.from.userId})),e}catch(r){return this.loggingService.catch("Error in RecorderUtilsService formatRecorderData:",r),e}}formatRecorderDataForWhisperTranscription(e){try{return this.usersService.userDataProviderAvailable()&&e?.fromUser?.userId&&(e.fromUser={userId:e.fromUser?.userId}),e}catch(t){return this.loggingService.catch("Error in RecorderUtilsService formatRecorderDataForWhisperTranscription:",t),e}}encryptRecorderAnnotation(e){return Q(this,null,function*(){try{return yield wl(e,this.authService.getUser()?.userId??"")}catch(t){this.loggingService.catch("Error in RecorderUtilsService encryptRecorderAnnotation:",t);return}})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var x9=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.commentUtilsService=e,this.recorderUtilsService=t,this.loggingService=r,this.usersService=a,this.authService=s,this.commentAnnotationsResolverService=c}getUserIdsToResolveFromNotifications(e){try{let t=new Set;for(let r of e){let{notification:a}=r;switch(a?.actionUser?.userId&&t.add(a?.actionUser?.userId),a?.displayHeadlineMessageTemplateData?.actionUser?.userId&&t.add(a?.displayHeadlineMessageTemplateData?.actionUser?.userId),a?.displayHeadlineMessageTemplateData?.recipientUser?.userId&&t.add(a?.displayHeadlineMessageTemplateData?.recipientUser?.userId),a?.notificationSource){case"comment":if(a?.notificationSourceData){let s=this.commentUtilsService.getUserIdsToResolveFromComments([a?.notificationSourceData]);for(let c of s)t.add(c)}break}}return Array.from(t)}catch(t){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",t),[]}}mergeStrippedDataWithNotification(e){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeStrippedDataWithNotification","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return e;let t=this.commentAnnotationsResolverService.getAnnotationById(e?.notification?.targetAnnotationId),r=e?.raw?.targetAnnotationData?.commentId,a=t?.comments?.[r]?.commentText,s=t?.comments?.[r]?.commentHtml;return a&&s&&e?.raw?.notificationSource==="comment"&&(e.notification.displayBodyMessageTemplate=a,e.raw.targetAnnotationData.commentText=a,e.raw.targetAnnotationData.commentHtml=s),e}catch(t){return this.loggingService.catch("Error in NotificationUtilsService mergeStrippedDataWithNotification:",t),e}}mergeLocationWithNotification(e,t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeLocationWithNotification","color: green;");let r=e?.notification?.notificationSourceData?.location?.id,a=e?.notification?.notificationSourceData?.metadata?.documentId;if(!r||!a)return e;let s=t?.[a]?.[r];return s&&(e.notification.notificationSourceData.location=s?.location,e?.raw?.annotationData?.location&&(e.raw.annotationData.location=s?.location)),e}catch(r){return this.loggingService.catch("Error in NotificationUtilsService mergeLocationWithNotification:",r),e}}mergeNotificationWithUser(e){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeNotificationWithUser","color: green;");let{notification:t}=e;if(t?.actionUser?.userId){let r=this.usersService.getUserById(t?.actionUser?.userId);r&&(t.actionUser=r)}if(t?.displayHeadlineMessageTemplateData?.actionUser?.userId){let r=this.usersService.getUserById(t?.displayHeadlineMessageTemplateData?.actionUser?.userId);r&&(t.displayHeadlineMessageTemplateData.actionUser=r)}if(t?.displayHeadlineMessageTemplateData?.recipientUser?.userId){let r=this.usersService.getUserById(t?.displayHeadlineMessageTemplateData?.recipientUser?.userId);r&&(t.displayHeadlineMessageTemplateData.recipientUser=r)}switch(t?.notificationSource){case"comment":t?.notificationSourceData&&this.commentUtilsService.mergeCommentWithUser(t?.notificationSourceData);break}return e}catch(t){return this.loggingService.catch("Error in NotificationUtilsService mergeNotificationWithUser:",t),e}}formatNotification(e,t){try{switch(typeof e=="object"&&(e=JSON.parse(JSON.stringify(e))),this.usersService.userDataProviderAvailable()&&e?.actionUser&&(e.actionUser={userId:e.actionUser.userId}),e.notificationSource){case"comment":this.commentUtilsService.formatCommentData(e.annotationData),this.commentUtilsService.formatCommentThreadData(e.targetAnnotationData);break;case"recorder":this.recorderUtilsService.formatRecorderData(e.annotationData,t);break}return e}catch(r){return this.loggingService.catch("Error in NotificationUtilsService formatNotification: ",r),e}}getTargetAnnotationIdsFromNotifications(e){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getTargetAnnotationIdsFromNotifications","color: green;");let t=[];return Object.values(e).forEach(r=>{r?.notification?.targetAnnotationId&&r?.raw?.notificationSource==="comment"&&t.push(r.notification.targetAnnotationId)}),t}catch(t){return this.loggingService.catch("Error in NotificationUtilsService getTargetAnnotationIdsFromNotifications:",t),[]}}handleNotificationEncryption(t){return Q(this,arguments,function*({data:e}){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: handleNotificationEncryption","color: green;");let r="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??"");return yield wl(e,r)}catch(r){return this.loggingService.catch("Error in NotificationUtilsService handleNotificationEncryption:",r),e}})}};o.\u0275fac=function(t){return new(t||o)(ee(ru),ee(VC),ee(_),ee(Ln),ee(je),ee(nl))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var zpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromPresenceUsers(e){try{let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in PresenceUtilsService getUserIdsToResolveFromPresenceUsers:",t),[]}}mergePresenceUserWithUser(e){try{if(this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService mergePresenceUserWithUser:",t),e}}formatPresenceUserData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService formatPresenceUserData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Gpe=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.loggingService=e,this.usersService=t,this.authService=r,this.functions=a,this.configService=s,this.reactionAnnotationsResolverService=c}getUserIdsToResolveFromReactions(e){try{let t=new Set;for(let r of e)if(r?.from?.userId&&t.add(r?.from?.userId),r?.reactions?.length)for(let a of r?.reactions)a?.from?.userId&&t.add(a?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",t),[]}}handleReactionEncryption(a){return Q(this,arguments,function*({data:e,firestorePath:t,eventType:r}){try{let s=Bk(this.authService.getFirebaseConfig()?.firebaseOptions),c=Qi(this.functions,Ji({url:wn.cloudFunction?.[s]?.setEncryptedData,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),p=iu.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),g=this.authService.getUser()?.userId??"",f={path:t??"",data:e??{},dbId:p??"",feature:"reaction",eventType:r??"PATCH",sdkVersion:_a()},I=yield wl(f,g);yield c({veltData:I})}catch(s){this.loggingService.catch("Error in handleReactionEncryption:",s)}})}mergeReactionWithUser(e){try{if(this.usersService.userDataProviderAvailable()){if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.reactions?.length){for(let t of e?.reactions)if(t?.from?.userId){let r=this.usersService.getUserById(t?.from?.userId);r&&(t.from=r)}}}return e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService mergeReactionWithUser:",t),e}}formatReactionData(e){try{return this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e.reactions=e?.reactions?.map(t=>(this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t)),e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService formatReactionData:",t),e}}isReactionDataChanged(e,t){try{this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: isReactionDataChanged","color: green;");let r=this.reactionAnnotationsResolverService.getReactionAnnotationById(t);return r?!hi(e,r):!0}catch(r){return this.loggingService.catch("Error in ReactionUtilsService isReactionDataChanged:",r),!0}}stripReactionAnnotationData(e){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: stripReactionAnnotationData","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return{originalData:e,strippedData:null};let t={};if(e&&e.annotationId){let r=e.annotationId;if(t[r]=E({annotationId:r,metadata:oC(e.metadata??{}),icon:e.icon},e?.from&&{from:e?.from}),!this.isReactionDataChanged(t[r],r))return{strippedData:null,originalData:e};delete e?.icon,e.isReactionResolverUsed=!0}return{strippedData:t,originalData:e}}catch(t){return this.loggingService.catch("Error in ReactionUtilsService stripReactionAnnotationData:",t),{strippedData:null,originalData:null}}}mergeStrippedDataWithReactionAnnotations(e){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: mergeStrippedDataWithReactionAnnotations","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return e;let t=this.reactionAnnotationsResolverService.getReactionAnnotationById(e?.annotationId);return t&&t.icon&&(e.icon=t.icon),e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService mergeStrippedDataWithReactionAnnotations:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln),ee(je),ee(Do),ee(Ft),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromSelections(e){try{let t=new Set;for(let r of e)r?.user?.userId&&t.add(r.user.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in SelectionUtilsService getUserIdsToResolveFromSelections:",t),[]}}mergeSelectionWithUser(e){try{if(e?.user?.userId){let t=this.usersService.getUserById(e?.user?.userId);t&&(e.user=t)}return e}catch(t){return this.loggingService.catch("Error in SelectionUtilsService mergeSelectionWithUser:",t),e}}formatSelectionData(e){try{return this.usersService.userDataProviderAvailable()&&e?.user?.userId&&(e.user={userId:e.user.userId}),e}catch(t){return this.loggingService.catch("Error in SelectionUtilsService formatSelectionData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var qpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromTags(e){try{let t=new Set;for(let r of e)if(r?.from?.userId&&t.add(r.from.userId),r?.to?.length)for(let a of r.to)a?.userId&&t.add(a.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in TagUtilsService getUserIdsToResolveFromTags:",t),[]}}mergeTagWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e?.to?.length&&(e.to=e.to.map(t=>{if(t?.userId){let r=this.usersService.getUserById(t?.userId);r&&(t=r)}return t})),e}catch(t){return this.loggingService.catch("Error in TagUtilsService mergeTagWithUser:",t),e}}formatTagData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.to?.length&&(e.to=e.to.map(t=>(t?.userId&&(t={userId:t.userId}),t)))),e}catch(t){return this.loggingService.catch("Error in TagUtilsService formatTagData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Im=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye,Ne,Ve){this.areaUtilsService=e,this.arrowUtilsService=t,this.commentUtilsService=r,this.contactUtilsService=a,this.coreActionsService=s,this.cursorUtilsService=c,this.huddleUtilsService=p,this.liveStateUtilsService=g,this.loggingService=f,this.multiThreadUtilsService=I,this.notificationUtilsService=T,this.presenceUtilsService=B,this.reactionUtilsService=z,this.recorderUtilsService=G,this.selectionUtilsService=J,this.tagUtilsService=ne,this.usersService=ve,this.docService=ye,this.commentAnnotationsResolverService=Ne,this.reactionAnnotationsResolverService=Ve}getErrorForGetRequests({feature:e,error:t}){try{switch(e){case"organizationMetadata":case"documentMetadata":case"folderMetadata":return(t?.message??"")?.includes("Missing or insufficient permissions.")?{errorCode:"PERMISSION_DENIED"}:null;default:return null}}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService getErrorForGetRequests:",r),null}}getFirestorePath({feature:e,properties:t,documentPaths:r,apiKey:a}){try{if(!a)return;let{documentId:s,organizationId:c,folderId:p}=t;c||(c=r?.organizationId);let g=new _9({apiKey:a,documentId:s?`${s}`:"",organizationId:c?`${c}`:"",veltFolderId:p?`${p}`:void 0});switch(e){case"userConfig":return t?.userId&&t?.documentId&&g?.userConfig?`${g?.userConfig}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${t?.documentId}`:void 0;case"allPermissionsUsers":return g?.permissionsUsers?`${g?.permissionsUsers}`:void 0;case"comment":return t?.documentId&&t?.id&&g?.comment?`${g?.comment}/${t?.id}`:void 0;case"allComments":return t?.documentId&&g?.comment?`${g?.comment}`:void 0;case"multiThread":return t?.documentId&&t?.id&&g?.multiThread?`${g?.multiThread}/${t?.id}`:void 0;case"allMultiThreads":return t?.documentId&&g?.multiThread?`${g?.multiThread}`:void 0;case"crdt":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}`:void 0;case"allLastNotificationTimestamp":return g?.lastNotificationTimestamp?`${g?.lastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return t?.id&&g?.lastNotificationTimestamp?`${g?.lastNotificationTimestamp}/${t?.id}`:void 0;case"area":return t?.documentId&&t?.id&&g?.area?`${g?.area}/${t?.id}`:void 0;case"allAreas":return t?.documentId&&g?.area?`${g?.area}`:void 0;case"allDocuments":return g?.document?`${g?.document}`:void 0;case"allLocations":return g?.location?`${g?.location}`:void 0;case"allFolders":return g?.folder?`${g?.folder}`:void 0;case"folder":return g?.folder&&t.folderId?`${g?.folder}/${t.folderId}`:void 0;case"documentUserAccess":return t?.documentId&&t?.id&&g?.documentUsers?`${g?.documentUsers}/${t?.id}`:void 0;case"reaction":return t?.documentId&&t?.id&&g?.reaction?`${g?.reaction}/${t?.id}`:void 0;case"allReactions":return t?.documentId&&g?.reaction?`${g?.reaction}`:void 0;case"recorder":return t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}/${t?.id}`:void 0;case"allRecorders":return t?.documentId&&g?.recorder?`${g?.recorder}`:void 0;case"recorderTrackEvent":return t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}/${t?.id}/trackRecorderEvent`:void 0;case"documentAccessType":return t?.documentId&&g?.document?`${g?.document}/${t?.documentId}`:void 0;case"organizationMetadata":return g?.organization?`${g?.organization}`:void 0;case"documentIam":case"documentMetadata":return t?.documentId&&g?.document?`${g?.document}/${t?.documentId}`:void 0;case"folderMetadata":return t?.folderId&&g?.folder?`${g?.folder}/${t?.folderId}`:void 0;case"locationMetadata":return t?.documentId&&g?.location&&t?.id?`${g?.location}/${t?.id}`:void 0;case"documentUser":return t?.documentId&&t?.id&&g?.documentUsers?`${g?.documentUsers}/${t?.id}`:void 0;case"allDocumentUsers":return g?.users?`${g?.users}`:void 0;case"allFolderUsers":return g?.users?`${g?.users}`:void 0;case"allOrganizationGroups":return g?.organizationGroups?`${g?.organizationGroups}`:void 0;case"allOrganizationUsers":return g?.users?`${g?.users}`:void 0;case"notificationViewsTimestamp":return t?.documentId&&t?.id&&g?.notificationViews?`${g?.notificationViews}/${t?.id}`:void 0;case"allDocumentViews":return t?.documentId&&g?.documentViews?`${g?.documentViews}`:void 0;case"documentViews":case"documentMetadataViews":case"documentDayViews":case"documentUsersViews":return t?.documentId&&t?.id&&g?.documentViews?`${g?.documentViews}/${t?.id}`:void 0;case"locationDayViews":case"locationUsersViews":case"locationViews":case"locationMetadataViews":case"location":return t?.documentId&&t?.id&&g?.locationViews?`${g?.locationViews}/${t?.id}`:void 0;case"allLocationViews":return t?.documentId&&g?.locationViews?`${g?.locationViews}`:void 0;case"allDocNotifications":return t?.documentId&&g?.docNotification?`${g?.docNotification}`:void 0;case"docNotificationViews":case"docNotification":return t?.documentId&&t?.id&&g?.docNotification?`${g?.docNotification}/${t?.id}`:void 0;case"userNotificationViews":case"userNotification":return t?.userId&&t?.id&&g?.notificationUsers?`${g?.notificationUsers}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}/${t?.id}`:void 0;case"allUserNotifications":return t?.userId&&g?.notificationUsers?`${g?.notificationUsers}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}`:void 0;default:throw new Error(`Unknown feature: ${e}`)}}catch(s){this.loggingService.catch("Error in CommonDbUtilsService getFirestorePath:",s);return}}getFirestoreCollectionGroupPath(e){try{switch(e){case"allComments":return U.FIREBASE_PARTIAL_PATH_COMMENT;case"allDocuments":return U.FIREBASE_PARTIAL_PATH_DOCS;case"allLocations":return U.FIREBASE_PARTIAL_PATH_LOCATION;case"allMultiThreads":return U.FIREBASE_PARTIAL_PATH_MULTI_THREAD;case"allAreas":return U.FIREBASE_PARTIAL_PATH_AREA;case"allReactions":return U.FIREBASE_PARTIAL_PATH_REACTION;case"allRecorders":return U.FIREBASE_PARTIAL_PATH_RECORDER;case"allDocumentViews":return U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS;case"allLocationViews":return U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS;case"allDocumentUsers":return U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS;case"allFolderUsers":return U.FIREBASE_PARTIAL_PATH_FOLDER_USERS;default:throw new Error(`Unknown feature: ${e}`)}}catch(t){this.loggingService.catch("Error in CommonDbUtilsService getFirestoreCollectionGroupPath:",t);return}}getDocumentPath({feature:e,properties:t,defaultDocumentPaths:r,apiKey:a,useFirestore:s}){try{if(!a)return;let{documentId:c,organizationId:p}=t;p||(p=r?.organizationId);let g=new Sm({apiKey:a,documentId:c?`${c}`:"",organizationId:p?`${p}`:""});switch(e){case"userConfig":return t?.userId&&t?.documentId&&g?.userConfig?`${g?.userConfig}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${t?.documentId}`:void 0;case"allComments":return!s&&t?.documentId&&g?.comment?`${g?.comment}`:void 0;case"allGlobalContacts":return t?.documentId&&g?.globalContacts?`${g?.globalContacts}`:void 0;case"globalContacts":return t?.documentId&&t?.userId&&g?.globalContacts?`${g?.globalContacts}${t?.userId}`:void 0;case"groupContacts":return t?.documentId&&t?.groupId&&g?.groupContacts?`${g?.groupContacts}${t?.groupId}`:void 0;case"groupContactsUser":return t?.documentId&&t?.groupId&&t?.userId&&g?.groupContacts?`${g?.groupContacts}${t?.groupId}/${t?.userId}`:void 0;case"allLoginContacts":return t?.documentId&&t?.userId&&g?.logins?`${g?.logins}${t?.userId}/contacts`:void 0;case"allLogins":return t?.documentId&&g?.logins?`${g?.logins}`:void 0;case"logins":return t?.documentId&&t?.userId&&g?.logins?`${g?.logins}${t?.userId}`:void 0;case"customerMetadata":return g?.customerMetadata?`${g?.customerMetadata}`:void 0;case"allArrows":return t?.documentId&&g?.arrow?`${g?.arrow}`:void 0;case"arrow":return t?.documentId&&g?.arrow&&t.id?`${g?.arrow}${t.id}`:void 0;case"allCursors":return t?.documentId&&g?.cursor?`${g?.cursor}`:void 0;case"cursor":return t?.documentId&&g?.cursor&&t.id?`${g?.cursor}${t.id}`:void 0;case"flockUser":return t?.documentId&&g?.flock&&t.id?`${g?.flock}users/${t.id}`:void 0;case"flockSession":return t?.documentId&&g?.flock&&t.id?`${g?.flock}sessions/${t.id}`:void 0;case"allHuddleAttendees":return t?.documentId&&g?.huddle?`${g?.huddle}attendees`:void 0;case"huddleAttendee":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}attendees/${t.id}`:void 0;case"huddleAttendeeState":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}attendees/${t.id}/state`:void 0;case"allHuddleInvitees":return t?.documentId&&g?.huddle?`${g?.huddle}invitees`:void 0;case"huddleConnection":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}connections/${t.id}`:void 0;case"huddleIceCandidate":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}iceCandidates/${t.id}`:void 0;case"allHuddleIceCandidates":return t?.documentId&&g?.huddle?`${g?.huddle}iceCandidates`:void 0;case"allHuddleMessages":return t?.documentId&&g?.huddle?`${g?.huddle}messages`:void 0;case"huddleMessage":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}messages/${t.id}`:void 0;case"allLiveStates":return t?.documentId&&g?.liveState?`${g?.liveState}`:void 0;case"allLiveStateCustoms":return t?.documentId&&g?.liveState?`${g?.liveState}custom`:void 0;case"liveStateCustom":return t?.documentId&&g?.liveState&&t?.id?`${g?.liveState}custom/${t.id}`:void 0;case"liveStateSingleEditorMode":return t?.documentId&&g?.liveStateSingleEditorMode?`${g?.liveStateSingleEditorMode}`:void 0;case"liveStateAutoSyncState":return t?.documentId&&g?.liveState?`${g?.liveState}default/autoSyncState`:void 0;case"liveStateAutoSyncStateCurrent":return t?.documentId&&g?.liveState?`${g?.liveState}default/autoSyncState/current`:void 0;case"liveStateAutoSyncStateHistoryId":return t?.documentId&&g?.liveState&&t?.id?`${g?.liveState}default/autoSyncState/history/${t.id}`:void 0;case"presence":return t?.documentId&&g?.presence&&t?.userId?`${g?.presence}${t?.userId}`:void 0;case"allPresence":return t?.documentId&&g?.presence?`${g?.presence}`:void 0;case"workspaceIam":return g?.workspaceIam?`${g?.workspaceIam}`:void 0;case"selection":return t?.documentId&&g?.selection&&t?.userId?`${g?.selection}${t?.userId}`:void 0;case"allSelections":return t?.documentId&&g?.selection?`${g?.selection}`:void 0;case"syncVideoPlayer":return t?.documentId&&g?.syncVideoPlayer?`${g?.syncVideoPlayer}`:void 0;case"allTags":return t?.documentId&&g?.tag?`${g?.tag}`:void 0;case"tag":return t?.documentId&&g?.tag&&t?.id?`${g?.tag}${t?.id}`:void 0;case"userContactUs":return t?.documentId&&g?.userContactUs?`${g?.userContactUs}`:void 0;case"userFeedback":return t?.documentId&&g?.userFeedback?`${g?.userFeedback}`:void 0;case"userReportBug":return t?.documentId&&g?.userReportBugs?`${g?.userReportBugs}`:void 0;case"comment":return!s&&t?.documentId&&t?.id&&g?.comment?`${g?.comment}${t?.id}`:void 0;case"allMultiThreads":return!s&&t?.documentId&&g?.multiThread?`${g?.multiThread}`:void 0;case"crdt":return!s&&t?.documentId&&g?.crdt?`${g?.crdt}`:void 0;case"crdtData":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/data`:void 0;case"crdtSyncState":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/state`:void 0;case"crdtSyncPresence":return t?.documentId&&t.userId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/presence/${t.userId}`:void 0;case"allCrdtSyncPresence":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/presence`:void 0;case"crdtPresence":return t?.documentId&&t.userId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/presence/${t.userId}`:void 0;case"allCrdtPresence":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/presence`:void 0;case"crdtVersion":return t?.documentId&&g?.crdt&&t?.id&&t?.versionId?`${g?.crdt}/${t?.id}/versions/${t?.versionId}`:void 0;case"crdtVersions":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/versions`:void 0;case"multiThread":return!s&&t?.documentId&&t?.id&&g?.multiThread?`${g?.multiThread}${t?.id}`:void 0;case"allLastNotificationTimestamp":return!s&&g?.organizationNotificationsLastNotificationTimestamp?`${g?.organizationNotificationsLastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return!s&&t?.id&&g?.organizationNotificationsLastNotificationTimestamp?`${g?.organizationNotificationsLastNotificationTimestamp}${t?.id}`:void 0;case"documentIam":return!s&&t?.documentId&&g?.documentIam?`${g?.documentIam}`:void 0;case"allDocuments":return!s&&g?.docs&&t?.documentId?`${g?.docs}/${t?.documentId}/${U.FIREBASE_PARTIAL_PATH_METADATA}`:void 0;case"allAreas":return!s&&t?.documentId&&g?.area?`${g?.area}`:void 0;case"area":return!s&&t?.id&&g?.area?`${g?.area}${t?.id}`:void 0;case"folder":return!s&&t?.folderId&&g?.folder?`${g?.folder}${t?.folderId}`:void 0;case"documentUserAccess":return!s&&t?.id&&g?.documentIam?`${g?.documentIam}users/${t?.id}`:void 0;case"documentUser":return!s&&t?.documentId&&t?.id&&g?.documentIam?`${g?.documentIam}users/${t?.id}`:void 0;case"allDocumentUsers":return!s&&t?.documentId&&g?.documentIam?`${g?.documentIam}users/`:void 0;case"allOrganizationGroups":return!s&&g?.organizationGroups?`${g?.organizationGroups}`:void 0;case"allOrganizationUsers":return!s&&g?.organizationIam?`${g?.organizationIam}users/`:void 0;case"reaction":return!s&&t?.id&&g?.reaction?`${g?.reaction}${t?.id}`:void 0;case"allReactions":return!s&&t?.documentId&&g?.reaction?`${g?.reaction}`:void 0;case"recorder":return!s&&t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}${t?.id}`:void 0;case"allRecorders":return!s&&t?.documentId&&g?.recorder?`${g?.recorder}`:void 0;case"organizationMetadata":return!s&&g?.organizationMetadata?`${g?.organizationMetadata}`:void 0;case"heartbeat":return t?.id&&g?.heartbeat?`${g?.heartbeat}${t?.id}`:void 0;case"allHeartbeats":return g?.heartbeat?`${g?.heartbeat}`:void 0;case"heartbeatByDocument":return t?.id&&g?.heartbeatByDocument?`${g?.heartbeatByDocument}${t?.id}`:void 0;case"allHeartbeatsByDocument":return g?.heartbeatByDocument?`${g?.heartbeatByDocument}`:void 0;case"documentAccessType":return!s&&g?.documentIam?`${g?.documentIam}`:void 0;case"documentMetadata":return!s&&t?.documentId&&g?.metadata?`${g?.metadata}`:void 0;case"allDocumentViews":return!s&&t?.documentId&&g?.views?`${g?.views}documentViews/`:void 0;case"documentViews":return!s&&t?.documentId&&t?.id&&g?.views?`${g?.views}documentViews/${t?.id}`:void 0;case"allLocationViews":return!s&&t?.documentId&&g?.views?`${g?.views}locationViews/`:void 0;case"notificationViewsTimestamp":return!s&&t?.id&&t?.user&&g?.views?`${g?.views}notification/${t?.id}/views/${t?.user}`:void 0;case"documentUsersViews":return!s&&t?.id&&t?.user&&t?.date&&g?.views?`${g?.views}documentViews/${t?.id}/users/${t?.user}/${t?.date}`:void 0;case"documentMetadataViews":return!s&&t?.id&&g?.views?`${g?.views}documentViews/${t?.id}/metadata`:void 0;case"documentDayViews":return!s&&t?.id&&t?.date&&t?.user&&g?.views?`${g?.views}documentViews/${t?.id}/day/${t?.date}/${t?.user}`:void 0;case"locationViews":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}/location`:void 0;case"location":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}`:void 0;case"locationUsersViews":return!s&&t?.id&&t?.user&&t?.date&&g?.views?`${g?.views}locationViews/${t?.id}/users/${t?.user}/${t?.date}`:void 0;case"locationMetadataViews":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}/metadata`:void 0;case"locationDayViews":return!s&&t?.id&&t?.date&&t?.user&&g?.views?`${g?.views}locationViews/${t?.id}/day/${t?.date}/${t?.user}`:void 0;case"docNotificationViews":case"docNotification":return t?.documentId&&t?.id&&g?.organizationNotificationsWithDocumentId?`${g?.organizationNotificationsWithDocumentId}${t?.id}`:void 0;case"allDocNotifications":return t?.documentId&&g?.organizationNotificationsWithDocumentId?`${g?.organizationNotificationsWithDocumentId}`:void 0;case"allUserNotifications":return t?.userId&&g?.organizationNotificationsUsers?`${g?.organizationNotificationsUsers}${t?.userId}`:void 0;case"userNotificationViews":case"userNotification":return t?.userId&&t?.id&&g?.organizationNotificationsUsers?`${g?.organizationNotificationsUsers}${t?.userId}/${t?.id}`:void 0;case"locationMetadata":return;case"allLocations":return;case"folderMetadata":return;case"allPermissionsUsers":return;default:throw new Error(`Unknown feature: ${e}`)}}catch(c){this.loggingService.catch("Error in CommonDbUtilsService getDocumentPath:",c);return}}resolveAnnotations(r){return Q(this,arguments,function*({data:e,feature:t}){try{if(e&&e?.length>0)switch(t){case"allComments":{if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let a=vt(),s=MC.GET_COMMENT_ANNOTATIONS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:s,source:"internal",payload:{commentAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:a,moduleName:s})}break}case"allReactions":{if(this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()){let a=vt(),s=HI.GET_REACTION_ANNOTATIONS;this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:s,source:"internal",payload:{reactionAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.reactionAnnotationsResolverService.resolveReactionAnnotations({request:{reactionAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:a,moduleName:s})}break}default:break}}catch(a){this.loggingService.catch(`Error in CommonDbUtilsService resolveAnnotations: ${t}`,a)}})}formatResponse(c){return Q(this,arguments,function*({feature:e,data:t,shouldAwait:r=!1,forceResolve:a=!1,shouldCommentAnnotationsResolverAwait:s=!1}){try{if(this.usersService.userDataProviderAvailable()){let p=[];switch(e){case"allAreas":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.areaUtilsService.getUserIdsToResolveFromAreaAnnotations(Object.values(t)));break}case"allArrows":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.arrowUtilsService.getUserIdsToResolveFromArrowAnnotations(Object.values(t)));break}case"allCursors":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.cursorUtilsService.getUserIdsToResolveFromCursorUsers(Object.values(t)));break}case"allComments":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.commentUtilsService.getUserIdsToResolveFromComments(Object.values(t)));break}case"allDocumentUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allFolderUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allOrganizationUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allMultiThreads":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.multiThreadUtilsService.getUserIdsToResolveFromMultiThreads(Object.values(t)));break}case"allDocNotifications":{t&&typeof t=="object"&&(p=this.notificationUtilsService.getUserIdsToResolveFromNotifications(Array.isArray(t)?t:Object.values(t)));break}case"allUserNotifications":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.notificationUtilsService.getUserIdsToResolveFromNotifications(Object.values(t)));break}case"allPresence":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.presenceUtilsService.getUserIdsToResolveFromPresenceUsers(Object.values(t)));break}case"allRecorders":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.recorderUtilsService.getUserIdsToResolveFromRecorders(Object.values(t)));break}case"allReactions":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.reactionUtilsService.getUserIdsToResolveFromReactions(Object.values(t)));break}case"allTags":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.tagUtilsService.getUserIdsToResolveFromTags(Object.values(t)));break}case"allHuddleAttendees":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.huddleUtilsService.getUserIdsToResolveFromHuddleAttendees(Object.values(t)));break}case"liveStateCustom":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustom(t));break}case"allLiveStateCustoms":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustoms(Object.values(t)));break}case"allLiveStates":{t&&typeof t=="object"&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStates(t));break}case"liveStateSingleEditorMode":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateSingleEditorMode(t));break}case"allSelections":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.selectionUtilsService.getUserIdsToResolveFromSelections(Object.values(t)));break}default:p=[]}if(p?.length){let g=vt(),f=Rl.GET_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Hr.FORMAT_RESPONSE,source:"internal",moduleName:f,payload:{userIds:p,feature:e,forceResolve:a}}),r?yield this.usersService.resolveUsers({userIds:p,forceResolve:a,feature:e,uniqueId:g,moduleName:f}):this.usersService.resolveUsers({userIds:p,forceResolve:a,feature:e,uniqueId:g,moduleName:f})}}if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let p=[];switch(e){case"allDocNotifications":{if(t&&typeof t=="object"){let g=this.notificationUtilsService.getTargetAnnotationIdsFromNotifications(t);p=[...p,...g],p=p.filter(f=>!this.commentAnnotationsResolverService.getCommentAnnotationById(f))}break}case"allUserNotifications":{if(t&&typeof t=="object"&&!Array.isArray(t)){let g=this.notificationUtilsService.getTargetAnnotationIdsFromNotifications(t);p=[...p,...g],p=p.filter(f=>!this.commentAnnotationsResolverService.getCommentAnnotationById(f))}break}default:p=[]}if(p?.length){let g=vt(),f=MC.GET_NOTIFICATIONS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:No.FORMAT_RESPONSE,moduleName:f,source:"internal",payload:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??"",shouldCommentAnnotationsResolverAwait:s}}),s?yield this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:g,moduleName:f}):this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:g,moduleName:f})}}return t}catch(p){return this.loggingService.catch("Error in CommonDbUtilsService formatResponse:",p),t}})}mergeCommentAnnotationsWithData({data:e,feature:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeCommentAnnotationsWithData","color: green;"),this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())switch(t){case"allComments":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.commentUtilsService.mergeStrippedDataWithCommentAnnotations(s),r),{}):e;case"allDocNotifications":case"allUserNotifications":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.notificationUtilsService.mergeStrippedDataWithNotification(s),r),{}):e;default:return e}return e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeCommentAnnotationsWithData:",r),e}}mergeReactionAnnotationsWithData({data:e,feature:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeReactionAnnotationsWithData","color: green;"),this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())switch(t){case"allReactions":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.reactionUtilsService.mergeStrippedDataWithReactionAnnotations(s),r),{}):e;default:return e}return e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeReactionAnnotationsWithData:",r),e}}mergeLocationMetadataWithData({data:e,feature:t,locationMetadata:r}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeLocationMetadataWithData","color: green;"),r&&typeof r=="object"&&!Array.isArray(r))switch(t){case"allComments":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((a,[s,c])=>(a[s]=this.commentUtilsService.mergeLocationWithCommentAnnotations(c,r),a),{}):e;case"allDocNotifications":case"allUserNotifications":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((a,[s,c])=>(a[s]=this.notificationUtilsService.mergeLocationWithNotification(c,r),a),{}):e;default:return e}return e}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService mergeLocationMetadataWithData:",a),e}}mergeUsersWithData({feature:e,data:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeUsersWithData","color: green;"),this.usersService.userDataProviderAvailable())switch(e){case"allAreas":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.areaUtilsService.mergeAreaWithUser(s),r),{}):t;case"allArrows":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.arrowUtilsService.mergeArrowWithUser(s),r),{}):t;case"allCursors":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.cursorUtilsService.mergeCursorUserWithUser(s),r),{}):t;case"allComments":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.commentUtilsService.mergeCommentWithUser(s),r),{}):t;case"allDocumentUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allFolderUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allOrganizationUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allMultiThreads":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.multiThreadUtilsService.mergeMultiThreadWithUser(s),r),{}):t;case"allDocNotifications":return t&&typeof t=="object"?t?.map(r=>this.notificationUtilsService.mergeNotificationWithUser(r)):t;case"allUserNotifications":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.notificationUtilsService.mergeNotificationWithUser(s),r),{}):t;case"allPresence":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.presenceUtilsService.mergePresenceUserWithUser(s),r),{}):t;case"allRecorders":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.recorderUtilsService.mergeRecorderWithUser(s),r),{}):t;case"allReactions":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.reactionUtilsService.mergeReactionWithUser(s),r),{}):t;case"allTags":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.tagUtilsService.mergeTagWithUser(s),r),{}):t;case"allHuddleAttendees":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.huddleUtilsService.mergeHuddleAttendeeWithUser(s),r),{}):t;case"liveStateCustom":return t&&typeof t=="object"&&!Array.isArray(t)?this.liveStateUtilsService.mergeLiveStateCustomWithUser(t):t;case"allLiveStateCustoms":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.liveStateUtilsService.mergeLiveStateCustomWithUser(s),r),{}):t;case"allLiveStates":return t&&typeof t=="object"?this.liveStateUtilsService.mergeLiveStateWithUser(t):t;case"liveStateSingleEditorMode":return t&&typeof t=="object"&&!Array.isArray(t)?this.liveStateUtilsService.mergeSingleEditorLiveStateDataWithUser(t):t;case"allSelections":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.selectionUtilsService.mergeSelectionWithUser(s),r),{}):t;default:return t}return t}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeUsersWithData:",r),t}}mergeCommentAnnotationsWithData$({data:e,feature:t}){try{return this.commentAnnotationsResolverService.getCommentAnnotationsById$().pipe(de(()=>{let r=this.mergeCommentAnnotationsWithData({data:e?.data??{},feature:t}),a=this.mergeUsersWithData({feature:t,data:r??{}});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch("Error in mergeCommentAnnotationsWithData:",r),le(e)}}mergeReactionAnnotationsWithData$({data:e,feature:t}){try{return this.reactionAnnotationsResolverService.getReactionAnnotationsById$().pipe(de(()=>{let r=this.mergeReactionAnnotationsWithData({data:e?.data??{},feature:t}),a=this.mergeUsersWithData({feature:t,data:r??{}});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch("Error in mergeReactionAnnotationsWithData:",r),le(e)}}mergeUsersWithData$({feature:e,data:t}){try{return this.usersService.getUserById$().pipe(de(()=>{let r=this.mergeUsersWithData({feature:e,data:t?.data??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch(`Error in mergeUsersWithData for ${e}:`,r),le(t)}}mergeLocationMetadataWithData$({data:e,feature:t}){try{return this.docService.getLocationMetadata$().pipe(de(r=>{let a=this.mergeLocationMetadataWithData({data:e?.data??{},feature:t,locationMetadata:r});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch(`Error in mergeLocationMetadataWithData for ${t}:`,r),le(e)}}handleDataStripping({feature:e,data:t,actionType:r,commentId:a}){try{switch(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: handleDataStripping","color: green;"),e){case"comment":return this.commentUtilsService.stripCommentAnnotationData({data:t,actionType:r,commentId:a});case"reaction":return this.reactionUtilsService.stripReactionAnnotationData(t);default:return{originalData:t,strippedData:null}}}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService handleDataStripping:",s),{originalData:t,strippedData:null}}}formatData({feature:e,data:t,properties:r,offset:a,isRealtimeDb:s}){try{this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: formatData","color: green;"),typeof t=="object"&&(t=JSON.parse(JSON.stringify(t)));let c=new Date().getTime()+a;switch(e){case"documentAccessType":return delete t?.users,{docIamConfig:t};case"organizationMetadata":case"documentMetadata":return s?t:{metadata:t};case"documentCommentMetadata":return t;case"cursor":return this.cursorUtilsService.formatCursorUserData(t);case"comment":return this.commentUtilsService.formatCommentData(t);case"area":return this.areaUtilsService.formatAreaData(t);case"arrow":return this.arrowUtilsService.formatArrowData(t);case"liveStateCustom":return this.liveStateUtilsService.formatLiveStateCustomData(t);case"liveStateSingleEditorMode":return this.liveStateUtilsService.formatLiveStateSingleEditorModeData(t);case"multiThread":return this.multiThreadUtilsService.formatMultiThreadData(t);case"reaction":return this.reactionUtilsService.formatReactionData(t);case"recorder":return this.recorderUtilsService.formatRecorderData(t,c);case"notificationViewsTimestamp":return{views:{[r.user??""]:t}};case"documentUsersViews":return s?t:{users:{[r.user??""]:{[r.date??""]:t}}};case"documentDayViews":return s?t:{day:{[r.date??""]:{[r.user??""]:t}}};case"documentMetadataViews":return s?t:{metadata:t};case"huddleMessage":return this.huddleUtilsService.formatHuddleMessageData(t);case"locationMetadataViews":return s?t:{metadata:t};case"locationUsersViews":return s?t:{users:{[r.user??""]:{[r.date??""]:t}}};case"locationDayViews":return s?t:{day:{[r.date??""]:{[r.user??""]:t}}};case"locationViews":return s?t:{location:t};case"docNotificationViews":return s?t:{views:t.views};case"userNotificationViews":return s?t:{views:t.views};case"presence":return this.presenceUtilsService.formatPresenceUserData(t);case"selection":return this.selectionUtilsService.formatSelectionData(t);case"tag":return this.tagUtilsService.formatTagData(t);default:return t}}catch(c){return this.loggingService.catch("Error in CommonDbUtilsService formatData:",c),t}}modifyAndSetData(s){return Q(this,arguments,function*({feature:e,data:t,subscriber:r,operation:a=null}){try{let c=yield this.modifyData({feature:e,data:t});r.next({data:c,operation:a})}catch(c){this.loggingService.catch("Error in CommonDbUtilsService modifyAndSetData:",c)}})}isDataAlreadyProcessedInLocalCache({feature:e,change:t,cache:r}){try{if(e==="allReactions"||e==="allComments"){if(t.type==="removed")return!Object.keys(r??{}).includes(t.doc.id);if(r?.[t.doc.id]){let a=t.doc.data(),s=r?.[t.doc.id];return a?.lastUpdated===s?.lastUpdated}}return!1}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService isDataAlreadyProcessedInLocalCache:",a),!1}}modifyData(r){return Q(this,arguments,function*({feature:e,data:t}){try{return yield this.formatResponse({feature:e,data:t})}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService modifyData:",a),t}})}addMetadata(e,t){try{return e&&typeof e=="object"&&!Array.isArray(e)?D(E({},e),{metadata:e?.metadata??{documentId:t?.documentId,organizationId:t?.organizationId,apiKey:t?.apiKey}}):e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService addMetadata:",r),e}}setDataInLocal(p){return Q(this,arguments,function*({feature:e,data:t,observablesCache:r,eventType:a,id:s,operation:c=null}){try{let f={comment:"allComments",reaction:"allReactions"}[e];if(!f)return null;let I=t?.metadata?.documentId,T=t?.metadata?.veltFolderId;return Object.keys(r).filter(B=>B.includes(f)&&(!I||B.includes(I)||T&&B.includes(T))).forEach(B=>{let z=r[B]?.subject?.getValue()??{};a==="DELETE"?s&&z?.data?.[s]&&(delete z?.data?.[s],r[B]?.subject&&r[B].subject.next({data:z?.data,operation:c})):r[B]?.subject?.next({data:D(E({},z?.data),{[t?.annotationId]:t}),operation:c})}),null}catch(g){return this.loggingService.catch("Error in CommonDbUtilsService setDataInLocal:",g),null}})}handleCommentEncryption(c){return Q(this,arguments,function*({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s}){try{return yield this.commentUtilsService.handleCommentEncryption({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s})}catch(p){return this.loggingService.catch("Error in CommonDbUtilsService handleCommentEncryption:",p),e}})}handleReactionEncryption(a){return Q(this,arguments,function*({data:e,firestorePath:t,eventType:r}){try{return yield this.reactionUtilsService.handleReactionEncryption({data:e,firestorePath:t,eventType:r})}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService handleReactionEncryption:",s),e}})}rtdbDefaultTransactionCallback(e,t){try{let r=E({},e||{});return Object.entries(t).forEach(([a,s])=>{s==null?delete r[a]:r[a]=s}),r}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService rtdbDefaultTransactionCallback:",r),e}}};o.\u0275fac=function(t){return new(t||o)(ee(Fpe),ee(Lpe),ee(ru),ee(Bpe),ee(ni),ee(Vpe),ee(I9),ee(E9),ee(_),ee($pe),ee(x9),ee(zpe),ee(Gpe),ee(VC),ee(Wpe),ee(qpe),ee(Ln),ee(ot),ee(nl),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ype=(()=>{let o=class o{constructor(e,t,r){this.configService=e,this.authService=t,this.loggingService=r,this.firestore$=new Ce(null);try{mn([this.authService.getFirebaseConfig$(),this.configService.getApiKey$()]).pipe(Le(([a,s])=>!!a&&!!s),rt(1)).subscribe(([a,s])=>{a&&s&&a?.firebaseOptions?.storeDbId&&this.firestore$.next(KR(iu.getFirestoreProdDbName(s,a.firebaseOptions)))},a=>{})}catch{}}getFirestore(){return this.firestore$.asObservable()}getFirestoreValue(){return this.firestore$.value}generateFirestoreDocumentId(){try{let e=this.getFirestoreValue()||KR("DocumentIdDb");if(e){let t=jI(e,"generateDocumentId");return AC(t).id}return}catch(e){this.loggingService.catch("Error in FirestoreService generateFirestoreDocumentId: ",e);return}}};o.\u0275fac=function(t){return new(t||o)(ee(Ft),ee(je),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var un=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T){this.authService=e,this.commonDbUtilsService=t,this.coreActionsService=r,this.loggingService=a,this.firestoreService=s,this.databaseService=c,this.configService=p,this.docService=g,this.usersService=f,this.commentAnnotationsResolverService=I,this.reactionAnnotationsResolverService=T,this.offset=0,this.db=null,this.firestore=null,this.subscriptions=[],this.offsetListener=null,this.observablesCache={},this.firestoreSubscriptions={},this.rtdbSubscriptions={},this.loggingService.log("%c[WB] Creating CLASS: CommonDbService","color: blue;"),this.docService.setCommonDbService(this),this.authService.setCommonDbService(this),this.usersService.setCommonDbService(this),this.subscriptions.push(this.databaseService.getDb().subscribe(B=>{if(B){this.db=B;let z=Ti(B,".info/serverTimeOffset");this.offsetListener=Mg(z,G=>{let J=G.val();this.offset=J})}})),this.subscriptions.push(this.firestoreService.getFirestore().subscribe(B=>{B&&(this.firestore=B)}))}unsubscribeFromObservables(){try{Object.values(this.firestoreSubscriptions??{}).forEach(e=>{e?.unsubscribe()}),Object.values(this.rtdbSubscriptions??{}).forEach(e=>{e?.unsubscribe()}),Object.entries(this.observablesCache??{}).forEach(([e,t])=>{t?.subject?.complete(),t?.subject?.unsubscribe()}),this.observablesCache={},this.firestoreSubscriptions={},this.rtdbSubscriptions={}}catch(e){this.loggingService.catch("Error in unsubscribeFromObservables:",e)}}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.offsetListener&&this.offsetListener(),this.unsubscribeFromObservables()}setupOnDisconnect(e,t){return Q(this,null,function*(){try{if(this.db){let r=Ti(this.db,e);return Es(r).update(t)}return Promise.resolve()}catch(r){return this.loggingService.catch("Error in setupOnDisconnect:",r),Promise.resolve()}})}getOffset(){return this.offset}getServerTimestamp(){return new Date().getTime()+this.getOffset()}subscribeToServices(e){mn([this.databaseService.getDb(),this.firestoreService.getFirestore()]).pipe(Le(([t,r])=>!!t),rt(1),Qt(([t,r])=>{e({db:t,firestore:r})})).subscribe({error:t=>{this.loggingService.catch("Error in CommonDbService subscription: ",t)}})}performDatabaseOperation(e,t,r,a,s,c){return Q(this,null,function*(){try{if(!t){this.loggingService.warn(`%c[WB] No properties found for ${e}`,"color: red;");return}return this.subscribeToServices(f=>Q(this,[f],function*({db:p,firestore:g}){let I;t?.skipFirestore||(I=this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()}));let T=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey(),useFirestore:this.shouldUseFirestore()});if(!p){this.loggingService.warn(`%c[WB] No database or firestore found for ${e}`,"color: red;");return}try{let B,z;try{T&&(B=Ti(p,`${T}`))}catch{this.loggingService.catch("Error in dbRef")}try{I?.includes("/organizations")&&g&&I&&(z=AC(g,`${I}`))}catch{this.loggingService.catch("Error in docRef")}if(!this.authService.getUser())return;yield r({dbRef:B,firestoreRef:z,data:a,firestorePath:I}),c&&c({firestoreAvailable:!!g})}catch(B){this.loggingService.catch(`Error in ${e} operation: `,B),s&&s(B)}}))}catch(p){this.loggingService.catch("Error in performDatabaseOperation:",p)}})}setData(p){return Q(this,arguments,function*({feature:e,data:t,properties:r,callback:a,errorCallback:s,extraData:c}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: setData for ${e}`,"color: green;"),this.shouldUseFirestore()&&t?.metadata&&!t?.metadata?.apiKey?void 0:(this.commonDbUtilsService.setDataInLocal({feature:e,data:t,observablesCache:this.observablesCache,operation:null}),this.performDatabaseOperation(e,r,g=>Q(this,null,function*(){if(g.dbRef){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset(),isRealtimeDb:!0});r?.rtdbTransaction?yield Yh(g.dbRef,()=>JSON.parse(JSON.stringify(f))):yield S0(g.dbRef,JSON.parse(JSON.stringify(f)))}try{if(g.firestoreRef&&g.data&&!r?.skipFirestore){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset()});typeof f=="object"&&(f=JSON.parse(JSON.stringify(f)));let{strippedData:I,originalData:T,eventType:B}=this.commonDbUtilsService.handleDataStripping({feature:e,data:f,actionType:c?.actionType,commentId:c?.targetAnnotationData?.commentId??r?.targetCommentId});if(e==="comment"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:No.SET_DATA,source:"internal",payload:{strippedData:I,originalData:T,eventType:B,commentId:c?.targetAnnotationData?.commentId}}),I&&(z=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:I,eventType:B,commentId:c?.targetAnnotationData?.commentId},G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:T,firestorePath:g.firestorePath??"",extraData:c,metadata:r?.metadata}))}else if(e==="reaction"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:Ho.SET_DATA,source:"internal",payload:{strippedData:I,originalData:T}}),I&&(z=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(I,G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:T,firestorePath:g.firestorePath??""}))}else e==="recorder"?this.firestore&&(yield vpe(this.firestore,z=>Q(this,null,function*(){z.set(g.firestoreRef,f)}))):yield GW(g.firestoreRef,f)}}catch(f){this.authService.getUser()&&this.loggingService.catch(`Error in setData for ${e}`,f)}}),t,s,a))}catch(g){this.loggingService.catch(`Error in setData for ${e}`,g)}})}updateData(p){return Q(this,arguments,function*({feature:e,data:t,properties:r,callback:a,errorCallback:s,extraData:c}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: updateData for ${e}`,"color: green;"),this.shouldUseFirestore()&&t?.metadata&&!t?.metadata?.apiKey?void 0:(this.commonDbUtilsService.setDataInLocal({feature:e,data:t,observablesCache:this.observablesCache,operation:null}),this.performDatabaseOperation(e,r,g=>Q(this,null,function*(){if(g.dbRef&&!r?.skipRtdb){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset(),isRealtimeDb:!0});r?.rtdbTransaction?yield Yh(g.dbRef,I=>{let T;return r?.rtdbTransactionCallback?T=r.rtdbTransactionCallback(I,f):T=this.commonDbUtilsService.rtdbDefaultTransactionCallback(I,f),JSON.parse(JSON.stringify(T))}):yield RM(g.dbRef,JSON.parse(JSON.stringify(f)))}try{if(g.firestoreRef&&g.data&&!r?.skipFirestore){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset()});typeof f=="object"&&(f=JSON.parse(JSON.stringify(f)));let{strippedData:I,originalData:T,eventType:B}=this.commonDbUtilsService.handleDataStripping({feature:e,data:f,actionType:c?.actionType,commentId:c?.targetAnnotationData?.commentId});if(e==="comment"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:No.UPDATE_DATA,source:"internal",payload:{strippedData:I,originalData:T,eventType:B,commentId:c?.targetAnnotationData?.commentId}}),I&&(z=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:I,eventType:B,commentId:c?.targetAnnotationData?.commentId},G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:T,firestorePath:g.firestorePath??"",extraData:c,metadata:r?.metadata}))}else if(e==="reaction"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:Ho.UPDATE_DATA,source:"internal",payload:{strippedData:I,originalData:T}}),I&&(z=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(I,G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:T,firestorePath:g.firestorePath??""}))}else yield GW(g.firestoreRef,f,{merge:!0})}}catch(f){this.authService.getUser()&&this.loggingService.catch(`Error in updateDoc for ${e}`,f)}}),t,s,a))}catch(g){this.loggingService.catch(`Error in updateData for ${e}`,g)}})}deleteData(s){return Q(this,arguments,function*({feature:e,properties:t,callback:r,errorCallback:a}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: deleteData for ${e}`,"color: green;"),this.commonDbUtilsService.setDataInLocal({feature:e,observablesCache:this.observablesCache,eventType:"DELETE",id:t?.id,operation:{type:"removed",ids:[t?.id]}}),this.performDatabaseOperation(e,t,c=>Q(this,null,function*(){c.dbRef&&(yield kM(c.dbRef));try{if(c.firestoreRef&&!t?.skipFirestore)if(e==="comment"){let p=null,g=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:No.DELETE_DATA,source:"internal",payload:{commentAnnotationId:t?.id??"",metadata:t?.metadata}}),p=yield this.commentAnnotationsResolverService.deleteCommentAnnotation(t?.id??"",t?.metadata,g),(p?.isSuccess||p===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({firestorePath:c.firestorePath??"",eventType:"DELETE",metadata:t?.metadata}))}else if(e==="reaction"){let p=null,g=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Ho.DELETE_DATA,source:"internal",payload:{reactionAnnotationId:t?.id??"",metadata:t?.metadata}}),p=yield this.reactionAnnotationsResolverService.deleteReactionAnnotation(t?.id??"",t?.metadata,g),(p?.isSuccess||p===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({firestorePath:c.firestorePath??"",eventType:"DELETE"}))}else yield ppe(c.firestoreRef)}catch(p){this.authService.getUser()&&this.loggingService.catch(`Error in deleteData for ${e}`,p)}}),void 0,a,r)}catch(c){this.loggingService.catch(`Error in deleteData for ${e}`,c)}})}shouldUseFirestore(){try{return this.authService.getAdvancedQueriesEnabled()}catch(e){return this.loggingService.catch("Error in shouldUseFirestore:",e),!1}}generateDocumentId(){try{let e=this.firestoreService.generateFirestoreDocumentId();return e||(e=vt()),e||"noDocumentId"}catch(e){return this.loggingService.catch("Error in generateFirestoreDocumentId:",e),vt()||"noDocumentId"}}queryData(r){return Q(this,arguments,function*({feature:e,properties:t}){try{let a=this.shouldUseFirestore();return!e||!t?(this.loggingService.warn("[WB] Missing required parameters in queryData"),[]):a?yield this.handleFirestoreQuery(e,t):yield this.handleRtdbQuery(e,t)}catch(a){return this.loggingService.catch(`Error in queryData for ${e}`,a),[]}})}handleFirestoreQuery(e,t){return Q(this,null,function*(){try{if(!this.firestore)return this.loggingService.warn("[WB] Firestore not initialized"),[];let r=t?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(e):this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!r)return this.loggingService.warn(`[WB] No firestore path found for ${e}`),[];try{let a=jI(this.firestore,r);t?.useCollectionGroup&&(a=$W(this.firestore,r));let s=t?.firestoreQuery??[],c=zW(a,...s);if(!this.authService.getUser()&&!t?.skipUserCheck)return[];if(t?.getCount)try{let p=yield upe(c).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${e}`,g),null));return p?p.data().count:0}catch(p){return this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${e}`,p),0}else try{let p=yield fpe(c).catch(f=>(this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${e}`,f),null));if(!p)return[];let g=p.docs.map(f=>f.data());try{return yield this.commonDbUtilsService.modifyData({feature:e,data:g})}catch(f){return this.loggingService.catch(`Error in modifyData for ${e}`,f),g}}catch(p){return this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${e}`,p),[]}}catch(a){return this.loggingService.catch(`Error in Firestore query for ${e}:`,a),[]}}catch(r){return this.loggingService.catch(`Error in Firestore query for ${e}:`,r),[]}})}handleRtdbQuery(e,t){return Q(this,null,function*(){if(!this.db)return this.loggingService.warn("[WB] Realtime Database not initialized"),[];let r=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!r)return this.loggingService.warn(`[WB] No database path found for ${e}`),[];try{let a=Ti(this.db,r),s=t?.rtdbQuery??[],c=f$(a,...s);if(!this.authService.getUser()&&!t?.skipUserCheck)return[];let p=yield u$(c).catch(f=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${e}`,f),null));if(!p)return[];let g=p.val();return g?t?.skipObjectValues?g:Object.values(g??{}):[]}catch(a){return this.loggingService.catch(`Error in RTDB query for ${e}:`,a),[]}})}getData(r){return Q(this,arguments,function*({feature:e,properties:t}){try{let a=this.shouldUseFirestore();if(t?.skipFirestore&&(a=!1),!e||!t)return this.loggingService.warn("[WB] Missing required parameters in getData"),{};if(a&&this.firestore){let s=this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!s)return this.loggingService.warn(`[WB] No firestore path found for ${e}`),{};try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getData]",void 0,void 0,!0),{};let c=yield hpe(AC(this.firestore,s)).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in getDoc for ${e}`,g),this.commonDbUtilsService.getErrorForGetRequests({feature:e,error:g})));if(c){if(c?.errorCode)return c}else return this.loggingService.warn(`[WB] No document found at ${s}`),{};let p=c.data();return t?.field?p?.[t.field]??{}:p??{}}catch(c){return this.loggingService.catch(`Error fetching Firestore data for ${e}:`,c),{}}}if(this.db){let s=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!s)return this.loggingService.warn(`[WB] No database path found for ${e}`),{};try{if(!this.authService.getUser())return{};let c=yield u$(Ti(this.db,s)).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${e}`,g),this.commonDbUtilsService.getErrorForGetRequests({feature:e,error:g})));if(c){if(c?.errorCode)return c}else return this.loggingService.warn(`[WB] No data found at ${s}`),{};let p=c.val();return t?.field?p?.[t.field]??{}:p??{}}catch(c){return this.loggingService.catch(`Error fetching RTDB data for ${e}:`,c),{}}}return this.loggingService.warn("[WB] No database connection available"),{}}catch(a){return this.loggingService.catch("Unexpected error in getData:",a),{}}})}dbListener({feature:e,properties:t}){let r=this.shouldUseFirestore();t?.skipFirestore&&(r=!1);let a=`${e}-${JSON.stringify(t)}`;return mn([this.databaseService.getDb(),this.firestoreService.getFirestore(),this.authService.getUser$().pipe(Le(s=>!!s))]).pipe(Le(([s,c])=>s?r&&!c?(this.loggingService.warn(`[WB] Firestore requested but not available for ${e}`),!1):!0:(this.loggingService.warn(`[WB] No database found for ${e}`),!1)),he(([s,c])=>{try{if(r&&c){if(!!!this.observablesCache[a]){this.observablesCache[a]={subject:new Ce({}),count:0};let f=this.handleFirestoreListener(e,t,c).subscribe(I=>{this.observablesCache[a]?.subject?.next(I)},I=>this.observablesCache[a]?.subject?.error(I));this.firestoreSubscriptions[a]=f}return new $t(g=>{let f=this.observablesCache[a]?.subject?.subscribe(I=>g.next(I),I=>g.error(I),()=>g.complete());return this.observablesCache[a].count+=1,()=>{f?.unsubscribe(),this.observablesCache[a]&&(this.observablesCache[a].count-=1,this.observablesCache[a].count<=0&&(this.firestoreSubscriptions[a]?.unsubscribe(),delete this.firestoreSubscriptions[a],this.observablesCache[a]?.subject?.complete(),delete this.observablesCache[a]))}})}else if(s){if(!!!this.observablesCache[a]){this.observablesCache[a]={subject:new Ce({}),count:0};let f=this.handleRealtimeDbListener(e,t,s).subscribe(I=>{this.observablesCache[a]?.subject?.next(I)},I=>this.observablesCache[a]?.subject?.error(I));this.rtdbSubscriptions[a]=f}return new $t(g=>{let f=this.observablesCache[a]?.subject?.subscribe(I=>g.next(I),I=>g.error(I),()=>g.complete());return this.observablesCache[a].count+=1,()=>{f?.unsubscribe(),this.observablesCache[a]&&(this.observablesCache[a].count-=1,this.observablesCache[a].count<=0&&(this.rtdbSubscriptions[a]?.unsubscribe(),delete this.rtdbSubscriptions?.[a],this.observablesCache[a]?.subject?.complete(),delete this.observablesCache?.[a]))}})}return le({})}catch(p){return this.loggingService.catch(`Error setting up listener for ${e}:`,p),le({})}}),Yu(()=>{this.loggingService.log(`[WB] Cleaning up listener for ${e} and key ${a}`)}))}handleFirestoreListener(e,t,r){let a=t?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(e):this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()}),s=`${e}-${JSON.stringify(t)}`;return a?new $t(c=>{let p=t.isCollection?this.setupCollectionListener(r,a,e,c,t):this.setupDocumentListener(r,a,e,c,t);return()=>{c.complete(),c.unsubscribe(),p(),this.observablesCache[s]?.subject?.complete(),this.observablesCache[s]?.subject?.unsubscribe(),delete this.observablesCache[s]}}).pipe(he(c=>this.commonDbUtilsService.mergeUsersWithData$({feature:e,data:c})),he(c=>["allComments","allUserNotifications"].includes(e)?this.commonDbUtilsService.mergeCommentAnnotationsWithData$({data:c,feature:e}):le(c)),he(c=>["allReactions"].includes(e)?this.commonDbUtilsService.mergeReactionAnnotationsWithData$({data:c,feature:e}):le(c)),Ct(Xt)):(this.loggingService.warn(`[WB] No firestore path found for ${e} and key ${s}`),le({}))}setupCollectionListener(e,t,r,a,s){let c=`${r}-${JSON.stringify(s)}`,p=jI(e,t);if(s?.useCollectionGroup&&(p=$W(e,t)),s?.useQuery&&s?.firestoreQuery){let I=s?.firestoreQuery??[];p=zW(p,...I)}let g=!0,f=[];return r==="allComments"&&this.loggingService.logContext("[CONTEXT] setupCollectionListener called with path:",t,"feature:",r,"properties:",JSON.stringify(s??"nil")),HW(p,I=>{try{let T=JSON.parse(JSON.stringify(this.observablesCache[c]?.subject?.getValue()?.data??{})),B=null,z=!1;I?.docChanges()?.length?I.docChanges().forEach(G=>{["allComments","allReactions"].includes(r)&&!g&&G.type!=="removed"&&f.push(G.doc.id),this.commonDbUtilsService.isDataAlreadyProcessedInLocalCache({feature:r,change:G,cache:this.observablesCache[c]?.subject?.getValue()?.data??{}})||(z=!0,Object.assign(T,this.handleCollectionChange(G,T)),G.type==="removed"&&(B||(B={type:G.type,ids:[]}),B.ids.push(G.doc.id)))}):z=!0,z&&(["allComments","allReactions"].includes(r)&&f?.length&&(this.commonDbUtilsService.resolveAnnotations({data:f,feature:r}),f=[]),this.commonDbUtilsService.modifyAndSetData({feature:r,data:T,subscriber:a,operation:B})),g=!1}catch(T){this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${r}:`,T),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(s??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(T,r,a)}},I=>{this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${r}:`,I),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(s??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(I,r,a)})}handleCollectionChange(e,t){switch(e.type){case"added":case"modified":t[e.doc.id]=e.doc.data();break;case"removed":delete t?.[e.doc.id];break}return t}setupDocumentListener(e,t,r,a,s){let c=AC(e,t);return HW(c,p=>{try{let g=p.data()||{};s?.field&&(g=g?.[s?.field]??{}),this.commonDbUtilsService.modifyAndSetData({feature:r,data:g,subscriber:a,operation:null})}catch(g){this.handleListenerError(g,r,a)}},p=>this.handleListenerError(p,r,a))}handleListenerError(e,t,r){this.loggingService.catch(`Firestore listener error for ${t}:`,e)}handleRealtimeDbListener(e,t,r){let a=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!a)return this.loggingService.warn(`[WB] No database path found for ${e}`),le({});let s=Ti(r,a);if(t?.useQuery&&t?.rtdbQuery){let c=t?.rtdbQuery??[];s=f$(s,...c)}return this.objectValFromChildEvents(s,e).pipe(Un(c=>(this.loggingService.catch(`RTDB listener error for ${e}:`,c),le({}))),de(c=>(c===null&&(c={}),c&&typeof c=="object"?Object.entries(c??{}).reduce((g,[f,I])=>(g[f]=this.commonDbUtilsService.addMetadata(I,t),g),{}):this.commonDbUtilsService.addMetadata(c,t))),he(c=>this.commonDbUtilsService.modifyData({feature:e,data:c})),he(c=>this.usersService.getUserById$().pipe(de(()=>({data:this.commonDbUtilsService.mergeUsersWithData({feature:e,data:c}),operation:null})))))}objectValFromChildEvents(e,t){return new $t(r=>{let a={},s=!1,c=null,p=G=>{try{this.loggingService.catch(`Realtime DB listener error for ${t}:`,G),r.error(G)}catch{}},g=G=>{try{if(!hi(G,c)){let J=JSON.parse(JSON.stringify(G));c=J,r.next(J)}}catch{}},f=G=>{try{G.key&&(a[G.key]=G.val(),s&&g(E({},a)))}catch{}},I=G=>{try{G.key&&(a[G.key]=G.val(),s&&g(E({},a)))}catch{}},T=G=>{try{G.key&&(delete a[G.key],s&&g(E({},a)))}catch{}},B=G=>{try{if(!s){let J=a&&typeof a=="object"?JSON.parse(JSON.stringify(a)):{};c=J,r.next(J),s=!0}}catch{}};Dre(e,f,p),wre(e,I,p),Ore(e,T,p);let z=Mg(e,B,p,{onlyOnce:!0});return()=>{try{z&&typeof z=="function"&&z(),MM(e,"child_added",f),MM(e,"child_changed",I),MM(e,"child_removed",T)}catch{}}})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Im),ee(ni),ee(_),ee(Ype),ee(In),ee(Ft),ee(ot),ee(Ln),ee(nl),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Si=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f){this.analyticsService=e,this.authService=t,this.configService=r,this.coreActionsService=a,this.databaseService=s,this.docService=c,this.loggingService=p,this.commonDbService=g,this.usersService=f,this.db=Is(),this.internalUserContacts$=new Ce([]),this.userGlobalContact$=new Ce(!1),this.userGroupContact$=new Ce(null),this.users$=new Ce([]),this.userPersonalContacts=[],this.userGroupContacts=[],this.userGlobalContacts=[],this.users=[],this.documentPaths=null,this.userAccessFields$=new Ce({}),this.userOrganizationContacts$=new Ce([]),this.userFolderContacts$=new Ce([]),this.userDocumentContacts$=new Ce([]),this.userOrganizationGroups$=new Ce([]),this.onContactSelectedSubject$=new Xe,this.documentAccessType=null,this.atHereEnabled$=new Ce(!1),this.atHereLabel$=new Ce("here"),this.atHereDescription$=new Ce(null),this.contactListScopeForOrganizationUsers$=new Ce([Yi.ALL]),this.customUserContacts$=new Ce(null),this.customUserContactsConfig$=new Ce({merge:!1}),this.currentOrganizationUserIAM$=new Ce(null),this.userContacts$=new Ce([]),this.userSnippylyIdContacts$=new Ce(null),this.usersByOrganizationId$=new Ce({}),this.temporaryUserIds$=new Ce([]),this.usersByOrganizationIdAndDocumentId$=new Ce({}),this.usersByOrganizationIdAndFolderId$=new Ce({}),this.userById$=new Ce({}),this.searchUsersSubject$=new Xe,this.searchUsersDebounceTime=300,this.pendingSearchPromises=new Map,this.authService.setContactService(this),this.usersService.setContactService(this),this.authService.getUser$().pipe(he(I=>this.docService.getDocumentPaths$().pipe(Qt(T=>{this.documentPaths=T}),de(()=>I)))).subscribe(I=>Q(this,null,function*(){if(this.user=I,I&&this.documentPaths)if(!I?.organizationId)this.getLoggedInUsers$().subscribe(),this.getUserContactsFromDb$(),yield this.migrateLoggedInUserFromEmailToUserIdPath(I),this.setLoggedInUser(I),yield this.moveGlobalContactUserFromEmailToUserIdPath(I),this.updateUserInGlobalContactsIfAvailable(I),I?.groupId&&(yield this.migrateGroupContactsFromEmailToUserIdPath(I?.groupId)),this.checkToSetLoggedInUserInGroupContacts();else{let T=this.userPermissionService?.getCurrentUserPermissions(),B=this.documentPaths.folderId,z=!0;B&&T?.[I?.userId]?.folders?.[B]?.errorCode===Lo.PERMISSION_DENIED&&(z=!1),this.getOrganizationContactsFromDb$(),z&&this.getFolderContactsFromDb$(),this.getDocumentContactsFromDb$(),this.getOrganizationGroupsFromDb$(),this.getTemporaryUsers()}else this.getUserContactSubscription?.unsubscribe(),this.getUserContactSubscription=void 0,this.getLoggedInUsersSubscription?.unsubscribe(),this.getLoggedInUsersSubscription=void 0,this.getOrganizationContactsSubscription?.unsubscribe(),this.getOrganizationContactsSubscription=void 0,this.getFolderContactsSubscription?.unsubscribe(),this.getFolderContactsSubscription=void 0,this.getDocumentContactsSubscription?.unsubscribe(),this.getDocumentContactsSubscription=void 0,this.getOrganizationGroupsSubscription?.unsubscribe(),this.getOrganizationGroupsSubscription=void 0}),I=>{this.loggingService.catch("Error in ContactService constructor getUser$: ",I)}),this.databaseService.getDb().pipe(Le(I=>!!I),rt(1)).subscribe(I=>{I&&(this.db=I)},I=>{this.loggingService.catch("Error in ContactService constructor getDb: ",I)}),this.getOrganizationGroups$().subscribe(I=>{this.authService.setOrganizationUserGroups(I)}),mn([this.getInternalUserContacts$(),this.getCustomUserContacts$(),this.getCustomUserContactsConfig$()]).subscribe(([I,T,B])=>{T?B?.merge?this.userContacts$.next([...I||[],...T||[]]):this.userContacts$.next(T||[]):this.userContacts$.next(I||[])}),this.getUserContacts$().subscribe(I=>{try{I?.forEach(T=>{let B=T?.userSnippylyId||eC(this.configService.getApiKey(),T.userId);B&&this.userSnippylyIdContacts$.next(D(E({},this.userSnippylyIdContacts$.value),{[B]:T}))})}catch{}})}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in ContactService setCommentService: ",t)}}setUserPermissionService(e){try{this.userPermissionService=e}catch(t){this.loggingService.catch("Error in ContactService setUserPermissionService: ",t)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ContactService","color: green;");try{this.documentPaths=null,this.usersByOrganizationId$.next({}),this.temporaryUserIds$.next([]),this.usersByOrganizationIdAndFolderId$.next({}),this.usersByOrganizationIdAndDocumentId$.next({}),this.userById$.next({}),this.userOrganizationContacts$.next([]),this.userFolderContacts$.next([]),this.userDocumentContacts$.next([]),this.userOrganizationGroups$.next([]),this.userContacts$.next([]),this.userSnippylyIdContacts$.next(null),this.userGlobalContact$.next(!1),this.userGroupContact$.next(null),this.users$.next([]),this.userPersonalContacts=[],this.userGroupContacts=[],this.userGlobalContacts=[],this.users=[],this.currentOrganizationUserIAM$.next(null)}catch(e){this.loggingService.catch("Error in ContactService clearCache: ",e)}}setDocumentAccessType(e){try{this.documentAccessType=e}catch(t){this.loggingService.catch("Error in ContactService setDocumentAccessType: ",t)}}checkIfUserGlobalContact(e){return Q(this,null,function*(){try{if(e?.userId&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0}});if(Object.keys(t??{}).length>0)return!0}if(e?.email&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0)return!0}return!1}catch(t){return this.loggingService.catch("Error in ContactService isUserGlobalContact: ",t),!1}})}setLoggedInUser(e){try{e?.userId&&this.documentPaths?.logins&&(this.commonDbService.updateData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(D(E({},e),{contacts:void 0})))}),this.setLoggedInUserPrivateContacts(e,e?.contacts))}catch(t){this.loggingService.catch("Error in ContactService setLoggedInUser: ",t)}}migrateLoggedInUserFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(e?.email&&this.documentPaths?.logins){let t=yield this.commonDbService?.getData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0){let r=t;if(r){if(r?.contacts){let a={};Object.keys(r?.contacts??{})?.forEach(s=>{let c=r.contacts[s];if(c?.userId){let p=Tt(c?.userId);a[p]=c}}),r.contacts=a}yield this.commonDbService.updateData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}),yield this.commonDbService.deleteData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}})}}}}catch(t){this.loggingService.catch("Error in ContactService migrateLoggedInUserFromEmailToUserIdPath: ",t)}})}addGlobalContact(e){try{e?.userId&&this.documentPaths?.globalContacts&&this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(e))})}catch(t){this.loggingService.catch("Error in ContactService addGlobalContact: ",t)}}getUserAccessFields(){return JSON.parse(JSON.stringify(this.userAccessFields$.value))}getUserAccessFieldsByUserId(e){return this.getUserAccessFields()?.[e]}setUserAccessFields(e){try{let t=this.getUserAccessFields();e.forEach(a=>{t[a.user.userId]=a.accessFields||[]});let r=this.authService.getUser()?.userId;if(r&&t?.[r]?.length){let a=this.userPermissionService?.getCurrentUserPermissions();a&&(a[r]||(a[r]={}),a[r].context={accessFields:t[r]},this.userPermissionService?.setCurrentUserPermissions(a))}this.userAccessFields$.next(JSON.parse(JSON.stringify(t)))}catch(t){this.loggingService.catch("Error in ContactService setUserAccessFields: ",t)}}updateUserInGlobalContactsIfAvailable(e){return Q(this,null,function*(){try{if(e?.userId&&this.documentPaths?.globalContacts&&(yield this.checkIfUserGlobalContact(e))){let r=new zo;r.userId=e?.userId,r.userSnippylyId=e?.userSnippylyId,r.email=e?.email,r.name=e?.name,r.photoUrl=e?.photoUrl,this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))})}}catch(t){this.loggingService.catch("Error in ContactService updateUserInGlobalContactsIfAvailable: ",t)}})}moveGlobalContactUserFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(e?.email&&e?.userId&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0){let r=t;r&&(yield this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}),yield this.commonDbService.deleteData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}}))}}}catch(t){this.loggingService.catch("Error in ContactService removeUserFromGlobalContactsByEmail: ",t)}})}setLoggedInUserPrivateContacts(e,t){try{if(e?.userId&&this.documentPaths?.logins){let r,a=t?.filter(c=>c?.visibility!=="group"),s=!1;this.authService.getUserOptions()&&(s=!!this.authService.getUserOptions()?.replaceContacts||!!this.authService.getUserOptions()?.replacePrivateContacts),a?.length?(r={},a?.forEach(c=>{if(c?.userId){let p=Tt(c?.userId);r[p]=c}}),s?this.commonDbService.setData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}):this.commonDbService.updateData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))})):s&&this.commonDbService.deleteData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0}})}}catch(r){this.loggingService.catch("Error in ContactService setLoggedInUserPrivateContacts: ",r)}}migrateGroupContactsFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(this.documentPaths?.groupContacts&&e){let t=yield this.commonDbService?.getData({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,skipFirestore:!0}});t&&Object.keys(t??{}).forEach(r=>Q(this,null,function*(){let a=t[r];a?.email&&a?.userId&&Tt(a?.email)===r&&(yield this.commonDbService.deleteData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:r,skipFirestore:!0}}),yield this.commonDbService.updateData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(a))}))}))}}catch(t){this.loggingService.catch("Error in ContactService migrateGroupContacts: ",t)}})}checkToSetLoggedInUserInGroupContacts(){return Q(this,null,function*(){try{this.user?.groupId&&this.user?.userId&&((yield this.checkIfUserGlobalContact(this.user))||this.docService.getDocumentIam$().pipe(rt(1)).subscribe(t=>Q(this,null,function*(){if(this.user?.groupId&&this.user?.userId){let r=!1,a=this.docService.getDocumentAccessType(t);if(!a||a===Di.PUBLIC)r=!0;else if(a===Di.RESTRICTED){let s=Tt(this.user?.userId);if(t?.users?.[s]&&(r=!0),this.user?.email){let c=Tt(this.user?.email);t?.users?.[c]&&(r=!0)}}if(r){let s=new Pp;s.email=this.user.email,s.visibility="group",s.name=this.user.name,s.photoUrl=this.user.photoUrl,s.userId=this.user.userId,(this.authService.getUserOptions()?.replaceContacts||this.authService.getUserOptions()?.replaceGroupContacts)&&(yield this.removeGroupContacts(this.user?.groupId)),this.setLoggedInUserGroupContacts(this.user?.groupId,[s]),this.user?.contacts&&this.user?.groupId&&this.setLoggedInUserGroupContacts(this.user?.groupId,this.user?.contacts)}}})))}catch(e){this.loggingService.catch("Error in ContactService checkToSetLoggedInUserInGroupContacts: ",e)}})}setLoggedInUserGroupContacts(e,t){try{let r=t?.filter(a=>a?.visibility==="group");r?.length&&r.forEach(a=>Q(this,null,function*(){if(a?.userId&&e&&this.documentPaths?.groupContacts){if(this.configService?.getSF()&&(yield this.checkIfUserGlobalContact(a)))return;yield this.commonDbService.updateData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(a))}),a?.email&&(yield this.commonDbService.deleteData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.email),skipFirestore:!0}}))}}))}catch(r){this.loggingService.catch("Error in ContactService setLoggedInUserGroupContacts: ",r)}}removeGroupContacts(e){return Q(this,null,function*(){try{if(this.documentPaths?.groupContacts&&e)return this.commonDbService.deleteData({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in ContactService removeGroupContacts: ",t)}})}mergeUserContacts(){try{let e=[];this.userPersonalContacts&&e.push(...this.userPersonalContacts),this.userGroupContacts&&e.push(...this.userGroupContacts),this.userGlobalContacts&&e.push(...this.userGlobalContacts);let t={};e.forEach(r=>{r?.userId?(!r?.email||!t[r.email])&&(t[r.userId]=r):r?.email&&(!r?.userId||!t[r.userId])&&(t[r.email]=r)}),e=Object.values(t??{}),this.internalUserContacts$.next(e)}catch(e){this.loggingService.catch("Error in ContactService mergeUserContacts: ",e)}}getInternalUserContacts(){return this.internalUserContacts$.value}getInternalUserContacts$(){return this.internalUserContacts$.asObservable()}getUserContacts$(e){try{let{organizationId:t,documentId:r,veltFolderId:a}=e||{};return t&&r?mn([this.usersByOrganizationId$,this.usersByOrganizationIdAndFolderId$,this.usersByOrganizationIdAndDocumentId$,this.userById$,this.customUserContacts$,this.customUserContactsConfig$,this.getContactListScopeForOrganizationUsers$(),this.temporaryUserIds$]).pipe(de(([s,c,p,g,f,I,T,B])=>{let z={},G=!1;I&&!I?.merge&&(G=!0);let J=Ve=>T.some(Ie=>Ve.includes(Ie)),ne=J([Yi.ALL,Yi.ORGANIZATION])?Object.keys(s?.[t]||{}):[],ve=a?J([Yi.ALL,Yi.FOLDER])?Object.keys(c?.[t]?.[a]||{}):[]:[],ye=J([Yi.ALL,Yi.DOCUMENT])?Object.keys(p?.[t]?.[r]||{}):[];if([...ne,...ve||[],...ye,...B].forEach(Ve=>{let Ie=g?.[Ve];Ie&&(z[Ve]=Ie)}),f){let{merge:Ve,options:Ie}=I||{},{organizationId:be,documentId:Ae,folderId:_e}=Ie||{},fe=_e?Ai(_e):void 0;(!be||be===t)&&(!Ae||Ae===r)&&(!fe||fe===a)&&(Ve||(z={}),f.forEach(Oe=>{Oe?.userId&&(z[Oe.userId]=Oe)}))}return Object.values(z??{})})):this.userContacts$.asObservable().pipe(de(s=>s))}catch(t){return this.loggingService.catch("Error in ContactService getUserContacts$ metadata: ",t),le([])}}getUserContactsBySnippylyId$(){return this.userSnippylyIdContacts$.asObservable()}getUserBySnippylyId(e){return this.userSnippylyIdContacts$.value?.[e]}getAtHereLabel(){return this.atHereLabel$.asObservable()}getAtHereDescription(){return this.atHereDescription$.asObservable()}getUserContactsFromDb$(){this.getUserContactSubscription||(this.getUserContactSubscription=this.authService.getUser$().pipe(Le(e=>!!e),he(e=>this.docService.getDocumentPaths$().pipe(Le(t=>!!t),Qt(t=>{this.documentPaths=t}),de(()=>e))),he(e=>{if(this.userGroupContacts=[],this.userPersonalContacts=[],!e)return le();if(!this.documentPaths)return le();let t=[];return t.push(this.commonDbService.dbListener({feature:"allGlobalContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(r=>r?.data),Qt(r=>{r?(this.userGlobalContacts=Object.values(r??{}),this.userGlobalContacts?.find(a=>a.userId===this.user?.userId)?this.userGlobalContact$.next(!0):this.userGlobalContact$.next(!1)):(this.userGlobalContacts=[],this.userGlobalContact$.next(!1))}))),t.push(this.commonDbService.dbListener({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0,groupId:e?.groupId}}).pipe(de(r=>r?.data),Qt(r=>{r?(this.userGroupContacts=Object.values(r??{}),this.userGroupContacts?.find(a=>a?.userId===this.user?.userId)?this.userGroupContact$.next(!0):this.userGroupContact$.next(!1)):(this.userGroupContacts=[],this.userGroupContact$.next(!1))}))),t.push(this.commonDbService.dbListener({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0,userId:Tt(e?.userId)}}).pipe(de(r=>r?.data),Qt(r=>{r?this.userPersonalContacts=Object.values(r??{}):this.userPersonalContacts=[]}))),Uo(...t).pipe(yo(this.authService.getUser$().pipe(Le(r=>!r))))})).subscribe(()=>{this.mergeUserContacts()},e=>{this.loggingService.catch("Error in ContactService getUserContacts$ subscription: ",e)}))}addUserContact(e){try{this.user?.organizationId||this.user?.groupId&&(e.visibility="group",this.setLoggedInUserGroupContacts(this.user?.groupId,[e]))}catch(t){this.loggingService.catch("Error in ContactService addUserContact: ",t)}}isUserGlobalContact$(){return this.userGlobalContact$.asObservable().pipe(Ct(Xt))}isUserGlobalContact(){return this.userGlobalContact$.value}isUserGroupContact$(){return this.userGroupContact$.asObservable()}isUserGroupContact(){return this.userGroupContact$.value}getLoggedInUsers$(){return this.getLoggedInUsersSubscription||(this.getLoggedInUsersSubscription=this.authService.getUser$().pipe(he(e=>e?this.documentPaths?e?.userId&&this.documentPaths?.logins?this.commonDbService.dbListener({feature:"allLogins",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(t=>t?.data),Qt(t=>{t?this.users=Object.values(t??{}):this.users=[]})):(this.users=[],le()):le():le())).subscribe(()=>{this.users$.next(this.users)},e=>{this.loggingService.catch("Error in ContactService getLoggedInUsers$ subscription: ",e)})),this.users$.asObservable()}getUsersMap$(){return this.authService.getUser$().pipe(he(e=>e?.organizationId?this.userById$.pipe(de(t=>{let r={};return Object.values(t||{}).forEach(a=>{a?.userSnippylyId&&(r[a?.userSnippylyId]=a)}),r})):this.users$.pipe(de(t=>{let r={};return t.forEach(a=>{r[a.userSnippylyId]=a}),r}))))}getUserByEmail$(e){return this.users$.pipe(de(t=>t.find(r=>r.email===e)))}getUserByEmail(e){return this.users?.find(t=>t.email===e)}getContactByEmail(e){return this.getInternalUserContacts().find(t=>t.email===e)}getUserByUserId$(e){return this.users$.pipe(de(t=>t.find(r=>r.userId===e)))}getUserGroupContacts(){return this.userGroupContacts}getTemporaryUsers(){try{let e=this.authService.getUser();this.docService.getOrganizationConfig$().pipe(Le(t=>!!t),de(t=>t?.organizationId)).subscribe(t=>Q(this,null,function*(){if(t&&e){let r=((yield this.commonDbService?.queryData({feature:"allPermissionsUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[lt("expiresAt",">",new Date().getTime())]}}))??[]).filter(a=>a?.userId!==e?.userId);if(r?.length){let a=r.map(g=>g?.userId),s=vt(),c=Rl.GET_TEMPORARY_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:s,moduleName:c,methodName:Hr.GET_TEMPORARY_USERS,source:"internal",payload:{userIds:a}});let p=yield this.usersService.resolveUsers({userIds:a,uniqueId:s,moduleName:c});if(p){let g={};Object.entries(p).forEach(([I,T])=>{g[I]=T}),this.userById$.next(E(E({},this.userById$.value),g));let f=new Set([...this.temporaryUserIds$.value,...Object.keys(g)]);this.temporaryUserIds$.next(Array.from(f))}}}}))}catch(e){this.loggingService.catch("Error in ContactService getTemporaryUsers: ",e)}}searchUsers(e){return Q(this,null,function*(){try{if(!e||typeof e!="string"||!e.trim())return[];let t=e.trim();return this.searchUsersDebounced$||(this.searchUsersDebounced$=this.searchUsersSubject$.pipe(Bi(this.searchUsersDebounceTime),Ct(),he(r=>no(this.performSearch(r)).pipe(de(a=>({searchText:r,results:a})),Un(a=>(this.loggingService.catch("Error in ContactService performSearch: ",a),le({searchText:r,results:[]})))))),this.searchUsersDebounced$.subscribe({next:({searchText:r,results:a})=>{Array.from(this.pendingSearchPromises.keys()).forEach(p=>{if(p!==r){let g=this.pendingSearchPromises.get(p);g&&(g.forEach(({resolve:f})=>f([])),this.pendingSearchPromises.delete(p))}});let c=this.pendingSearchPromises.get(r);c&&(c.forEach(({resolve:p})=>p(a)),this.pendingSearchPromises.delete(r))},error:r=>{this.pendingSearchPromises.forEach(a=>{a.forEach(({reject:s})=>s(r))}),this.pendingSearchPromises.clear()}})),new Promise((r,a)=>{this.pendingSearchPromises.has(t)||this.pendingSearchPromises.set(t,[]),this.pendingSearchPromises.get(t).push({resolve:r,reject:a}),this.searchUsersSubject$.next(t)})}catch(t){return this.loggingService.catch("Error in ContactService searchUsers: ",t),[]}})}performSearch(e){return Q(this,null,function*(){try{let t=this.docService.getOrganizationConfig()?.organizationId;if(!t)return[];let r=this.documentPaths?.veltFolderId,a=this.docService.getDocumentIds().map(J=>J?.documentId),s=e.toLowerCase().trim(),c=s+"\uF8FF",p=[],g=a?.filter(J=>!!J)||[],f=g.length>0,I=!!r;if(f){let J=[];for(let ve=0;ve<g.length;ve+=20)J.push(g.slice(ve,ve+20));J.forEach(ve=>{let ye=[lt("documentIds","array-contains-any",ve),lt("viewerDocumentIds","array-contains-any",ve)],Ne=[lt("organizationIds","array-contains-any",[t]),lt("viewerOrganizationIds","array-contains-any",[t]),...ye];I&&Ne.push(lt("folderIds","array-contains-any",[r]),lt("viewerFolderIds","array-contains-any",[r])),p.push(this.commonDbService.queryData({feature:"allDocumentUsers",properties:{organizationId:t,isCollection:!0,useCollectionGroup:!1,useQuery:!0,firestoreQuery:[li(Df(...Ne),lt("user.name_lowercase",">=",s),lt("user.name_lowercase","<",c)),_m(10)]}}).catch(()=>[])),p.push(this.commonDbService.queryData({feature:"allDocumentUsers",properties:{organizationId:t,isCollection:!0,useCollectionGroup:!1,useQuery:!0,firestoreQuery:[li(Df(...Ne),lt("user.email_lowercase",">=",s),lt("user.email_lowercase","<",c)),_m(10)]}}).catch(()=>[]))})}let T=yield Promise.all(p),B=[];T.forEach(J=>{J&&Array.isArray(J)?J.forEach(ne=>{ne&&ne.user&&ne.user.userId&&B.push(ne)}):J&&typeof J=="object"&&Object.values(J).forEach(ve=>{ve&&ve.user&&ve.user.userId&&B.push(ve)})});let z=new Map;B.forEach(J=>{let ne=J.user?.userId;ne&&!z.has(ne)&&z.set(ne,J)});let G=Array.from(z.values());return this.setResolvedUsers(G,!0),G}catch(t){return this.loggingService.catch("Error in ContactService performSearch: ",t),[]}})}setResolvedUsers(e,t=!1){try{if(e?.length){let r=[],a=[],s=[],c=this.docService.getOrganizationConfig()?.organizationId,p=this.documentPaths?.veltFolderId,g=this.docService.getDocumentIds().map(T=>T?.documentId);e.forEach(T=>{this.userById$.value[T?.user?.userId]||(c&&T?.organizationIds?.includes(c)&&!r.find(B=>B?.user?.userId===T?.user?.userId)&&r.push(T),p&&T?.folderIds?.includes(p)&&!a.find(B=>B?.user?.userId===T?.user?.userId)&&a.push(T),g?.some(B=>T?.documentIds?.includes(B))&&!s.find(B=>B?.user?.userId===T?.user?.userId)&&s.push(T))}),r?.length&&this.setUserOrganizationContacts(r,c,t),a?.length&&this.setUserFolderContacts(a,t),s?.length&&this.setUserDocumentContacts(s,t);let I=[...r,...a,...s].filter((T,B,z)=>B===z.findIndex(G=>G.user.userId===T.user.userId));I?.length&&(this.setUserAccessFields(I),this.mergeOrganizationAndDocumentContacts())}}catch(r){this.loggingService.catch("Error in ContactService setResolvedUsers: ",r)}}getOrganizationContactsFromDb$(){try{this.getOrganizationContactsSubscription||(this.getOrganizationContactsSubscription=this.authService.getUser$().pipe(he(e=>e?.organizationId?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>this.usersService.getResolveOrganizationUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>{let r=this.docService.getOrganizationConfig()?.organizationId;return this.setUserOrganizationContacts([],r),t?r?this.commonDbService.dbListener({feature:"allOrganizationUsers",properties:{organizationId:r,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("organizationIds","array-contains-any",[r]),lt("viewerOrganizationIds","array-contains-any",[r]))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]}}).pipe(de(a=>a?.data),he(a=>this.commentService?.getPaginatedContactList()&&!Object.values(a??{}).find(s=>s?.user?.userId===this.authService.getUser()?.userId)?no(this.commonDbService.queryData({feature:"allOrganizationUsers",properties:{organizationId:r,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("organizationIds","array-contains-any",[r]),lt("viewerOrganizationIds","array-contains-any",[r])),lt("user.userId","==",this.authService.getUser()?.userId))]}})).pipe(de(s=>{if(s&&s.length>0){let c=s[0],p=c?.user?.userId||c?.id;if(p&&a){let g=Tt(p);return D(E({},a),{[g]:c})}}return a})):le(a)),de(a=>{if(a){typeof a=="object"&&(a?.undefined&&delete a.undefined,a?.null&&delete a.null);let s=Object.values(a??{});this.setUserAccessFields(s),this.setUserOrganizationContacts(s,r)}else this.setUserOrganizationContacts([],r)})):le():le()}),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserOrganizationContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getOrganizationContactsFromDb$ subscription: ",e)}))}catch{}}getFolderContactsFromDb$(){try{this.getFolderContactsSubscription||(this.getFolderContactsSubscription=this.authService.getUser$().pipe(he(e=>e?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>this.usersService.getResolveFolderUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>{let r=this.docService.getOrganizationConfig()?.organizationId;if(this.setUserFolderContacts([]),!t)return le();if(!this.commonDbService.shouldUseFirestore())return le();if(!this.documentPaths?.veltFolderId)return le();let a=le([]);return a=this.commonDbService.dbListener({feature:"allFolderUsers",properties:{organizationId:r,folderId:this.documentPaths?.veltFolderId,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("folderIds","array-contains-any",[this.documentPaths?.veltFolderId]),lt("viewerFolderIds","array-contains-any",[this.documentPaths?.veltFolderId]))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]}}).pipe(de(s=>s?.data)),a.pipe(de(s=>{if(s){typeof s=="object"&&(s?.undefined&&delete s.undefined,s?.null&&delete s.null);let c=Object.values(s??{});this.setUserAccessFields(c),this.setUserFolderContacts(c)}else this.setUserFolderContacts([])}))}),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserFolderContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getFolderContactsFromDb$ subscription: ",e)}))}catch{}}getDocumentContactsFromDb$(){try{this.getDocumentContactsSubscription||(this.getDocumentContactsSubscription=this.authService.getUser$().pipe(he(e=>e?le(e).pipe(he(t=>this.docService.getDocumentPaths$().pipe(Le(r=>!!r),Qt(r=>{this.documentPaths=r}),de(()=>t))),he(t=>this.usersService.getResolveDocumentUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>(this.setUserDocumentContacts([]),t?this.documentPaths?this.docService.getDocumentIds$().pipe(he(r=>{let a=r?.length>0?r.map(g=>g.documentId):[this.documentPaths?.documentId??""];if(a.some(g=>!g)||!this.documentPaths)return le();let s=le([]),c={isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(c.documentId=a?.length?a[0]:void 0,c.organizationId=this.documentPaths?.organizationId);let p=[];for(let g=0;g<a.length;g+=U.LISTENER_BATCH_SIZE)p.push(a.slice(g,g+U.LISTENER_BATCH_SIZE));return s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allDocumentUsers",properties:D(E({},c),{firestoreQuery:[li(Df(lt("documentIds","array-contains-any",g),lt("viewerDocumentIds","array-contains-any",g))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]})}).pipe(Or()))).pipe(de(g=>na(g)?.data)),s.pipe(de(g=>{if(g){typeof g=="object"&&(g?.undefined&&delete g.undefined,g?.null&&delete g.null);let f=Object.values(g??{});this.setUserAccessFields(f),this.setUserDocumentContacts(f)}else this.setUserDocumentContacts([])}))})):le():le())),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserDocumentContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getDocumentContactsFromDb$ subscription: ",e)}))}catch{}}setUserOrganizationContacts(e,t,r=!0){try{let a=e.find(c=>c.user.userId===this.user?.userId);a&&this.currentOrganizationUserIAM$.next(a);let s=e.map(c=>c.user)?.filter(c=>!this.userOrganizationContacts$.value.find(p=>p.userId===c.userId));if(this.userOrganizationContacts$.next([...this.userOrganizationContacts$.value,...s]),r&&this.usersService.setUserByIds(s),t){let c={};c[t]={};let p={};e.forEach(f=>{c[t][f.user.userId]=f,p[f.user.userId]=f.user}),this.userById$.next(E(E({},this.userById$.value),p));let g=this.usersByOrganizationId$.value?.[t];g&&(c[t]=E(E({},g),c[t])),this.usersByOrganizationId$.next(D(E({},this.usersByOrganizationId$.value),{[t]:c[t]}))}else this.usersByOrganizationId$.next({})}catch(a){this.loggingService.catch("Error in ContactService setUserOrganizationContacts: ",a)}}getUserOrganizationContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION])?this.userOrganizationContacts$.asObservable():le([])))}getUserOrganizationContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION])?this.userOrganizationContacts$.value:[]}setUserFolderContacts(e,t=!0){try{let r=e?.map(p=>p?.user)?.filter(p=>!this.userFolderContacts$.value.find(g=>g.userId===p.userId));this.userFolderContacts$.next([...this.userFolderContacts$.value,...r]),t&&this.usersService.setUserByIds(r);let a=this.usersByOrganizationIdAndFolderId$.value||{},s=E({},a),c={};e?.forEach(p=>{let{organizationId:g}=p?.metadata||{};g&&(s[g]||(s[g]={}),p.folderIds?.forEach(f=>{s[g][f]||(s[g][f]={}),s[g][f]=D(E({},s[g][f]),{[p.user.userId]:p}),c[p.user.userId]=p.user}))}),this.userById$.next(E(E({},this.userById$.value),c)),this.usersByOrganizationIdAndFolderId$.next(s)}catch(r){this.loggingService.catch("Error in ContactService updateUserFolderContacts: ",r)}}getUserFolderContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.FOLDER])?this.userFolderContacts$.asObservable():le([])))}getUserFolderContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.FOLDER])?this.userFolderContacts$.value:[]}setUserDocumentContacts(e,t=!0){try{let r=e?.map(p=>p?.user)?.filter(p=>!this.userDocumentContacts$.value.find(g=>g.userId===p.userId));this.userDocumentContacts$.next([...this.userDocumentContacts$.value,...r]),t&&this.usersService.setUserByIds(r);let a=this.usersByOrganizationIdAndDocumentId$.value||{},s=E({},a),c={};e?.forEach(p=>{let{organizationId:g}=p?.metadata||{};g&&(s[g]||(s[g]={}),p.documentIds?.forEach(f=>{s[g][f]||(s[g][f]={}),s[g][f]=D(E({},s[g][f]),{[p.user.userId]:p}),c[p.user.userId]=p.user}))}),this.userById$.next(E(E({},this.userById$.value),c)),this.usersByOrganizationIdAndDocumentId$.next(s)}catch(r){this.loggingService.catch("Error in ContactService updateUserDocumentContacts: ",r)}}getUserDocumentContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.userDocumentContacts$.asObservable():le([])))}getUserDocumentContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.userDocumentContacts$.value:[]}getCurrentOrganizationUserIAM$(){return this.currentOrganizationUserIAM$.asObservable()}getCurrentOrganizationUserIAM(){return this.currentOrganizationUserIAM$.value}mergeOrganizationAndDocumentContacts(){try{this.mergeContactsDebounceTimer&&clearTimeout(this.mergeContactsDebounceTimer),this.mergeContactsDebounceTimer=setTimeout(()=>{this.executeMergeContacts()},200)}catch(e){this.loggingService.catch("Error in ContactService mergeOrganizationAndDocumentContacts: ",e)}}executeMergeContacts(){try{let e=this.getContactListScopeForOrganizationUsers(),t=[];e.includes(Yi.ALL)?t=[...this.getUserOrganizationContacts(),...this.getUserFolderContacts(),...this.getUserDocumentContacts()]:e.includes(Yi.ORGANIZATION)?t=[...this.getUserOrganizationContacts()]:e.includes(Yi.FOLDER)?t=[...this.getUserFolderContacts()]:e.includes(Yi.DOCUMENT)&&(t=[...this.getUserDocumentContacts()]);let r=[...new Map(t.filter(a=>a?.userId).map(a=>[a.userId,a])).values()];this.internalUserContacts$.next(r)}catch(e){this.loggingService.catch("Error in ContactService mergeOrganizationAndDocumentContacts: ",e)}}getOrganizationGroupsFromDb$(){try{this.getOrganizationGroupsSubscription||(this.getOrganizationGroupsSubscription=this.authService.getUser$().pipe(he(e=>e?.organizationId?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>{if(this.setUserOrganizationGroups([]),!t)return le();let r=this.docService.getOrganizationConfig()?.organizationId;return r?this.commonDbService.dbListener({feature:"allOrganizationGroups",properties:{organizationId:r,isCollection:!0}}).pipe(de(a=>a?.data),de(a=>{a?(typeof a=="object"&&(a?.undefined&&delete a.undefined,a?.null&&delete a.null),this.setUserOrganizationGroups(Object.values(a??{}))):this.setUserOrganizationGroups([])})):le()})):(this.setUserOrganizationGroups([]),le()))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ContactService getOrganizationGroupsFromDb$ subscription: ",e)}))}catch{}}setUserOrganizationGroups(e){try{this.userOrganizationGroups$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setUserOrganizationGroups: ",t)}}onContactSelected(e){try{if(e?.userId){let t=!!this.getUserDocumentContacts().find(a=>a.userId===e.userId),r=!!this.getUserOrganizationContacts().find(a=>a.userId===e.userId);switch(this.documentAccessType){case Di.RESTRICTED:if(!t){let a={contact:e,isOrganizationContact:r,isDocumentContact:t,documentAccessType:this.documentAccessType};this.onContactSelectedSubject$.next(a)}break}}else{let t={contact:e,isOrganizationContact:!1,isDocumentContact:!1,documentAccessType:this.documentAccessType};this.onContactSelectedSubject$.next(t)}}catch(t){this.loggingService.catch("Error in ContactService onContactSelected: ",t)}}onContactSelected$(){return this.onContactSelectedSubject$.asObservable()}getOrganizationGroups$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION_USER_GROUP])?this.userOrganizationGroups$.asObservable():le([])))}enableAtHere(){try{if(this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereEnabled:!0}}),this.atHereEnabled$.value===!0)return;this.atHereEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ContactService enableAtHere: ",e)}}setAtHereLabel(e){try{this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereLabel:e}}),e&&this.atHereLabel$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setAtHereLabel: ",t)}}setAtHereDescription(e){try{this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereDescription:e}}),e&&this.atHereDescription$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setAtHereDescription: ",t)}}disableAtHere(){try{if(this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereEnabled:!1}}),this.atHereEnabled$.value===!1)return;this.atHereEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in ContactService disableAtHere: ",e)}}getAtHereEnabled$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.atHereEnabled$.asObservable():le(!1)))}getAtHereEnabled(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.atHereEnabled$.value:!1}updateContactListScopeForOrganizationUsers(e){try{this.contactListScopeForOrganizationUsers$.next(e)}catch(t){this.loggingService.catch("Error in ContactService updateContactListScopeForOrganizationUsers: ",t)}}getContactListScopeForOrganizationUsers$(){return this.contactListScopeForOrganizationUsers$.asObservable()}getContactListScopeForOrganizationUsers(){return this.contactListScopeForOrganizationUsers$.value}checkContactListScopeForOrganizationUsers(e){return this.getContactListScopeForOrganizationUsers().some(t=>e.includes(t))}updateContactList(e,t){return Q(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{contactsCount:e?.length,config:t}),this.usersService.setUserByIds(e),this.customUserContacts$.next(e),this.customUserContactsConfig$.next(t)}catch(r){this.loggingService.catch("Error in CommentService updateContactList: ",r)}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:r}=this.docService.getServerId(e?.options);e.options=D(E({},e?.options),{documentId:t,organizationId:r})}return this}catch(t){return this.loggingService.catch("Error in ContactService convert: ",t),this}}getContactList$(){try{return this.authService.getUser$().pipe(he(e=>e?mn([this.userOrganizationContacts$.asObservable(),this.userFolderContacts$.asObservable(),this.userDocumentContacts$.asObservable(),this.userOrganizationGroups$.asObservable(),this.customUserContacts$.asObservable()]).pipe(de(([t,r,a,s,c])=>{let p={};p.organizationUsers=t?.map(f=>this.convertToClientUser(f)),p.folderUsers=r?.map(f=>this.convertToClientUser(f)),p.documentUsers=a?.map(f=>this.convertToClientUser(f)),p.updatedContactList=c?.map(f=>this.convertToClientUser(f));let g=[];return s?.forEach(f=>{let I=this.convertToClientUserGroup(f,p.organizationUsers||[]);I&&g.push(I)}),p.userGroups=g,p}),Ct(Xt)):le(null)),Un(e=>(this.loggingService.catch("Error in ContactService getContactList$: ",e),le(null))))}catch(e){return this.loggingService.catch("Error in ContactService getContactList$: ",e),le(null)}}convertToClientUserGroup(e,t){try{let r={groupId:e?.metadata?.clientGroupId,groupName:e?.metadata?.groupName,users:[]},a={};return t?.forEach(s=>{if(s?.userId){let c=Tt(s.userId);a[c]=s}}),Object.keys(e?.users??{}).forEach(s=>{a[s]&&r.users?.push(a[s])}),r}catch(r){return this.loggingService.catch("Error in ContactService convertToClientUserGroup: ",r),null}}convertToClientUser(e){try{return e&&(e=JSON.parse(JSON.stringify(e)),e?.clientGroupId&&(e.groupId=e.clientGroupId,delete e.clientGroupId),e?.clientOrganizationId&&(e.organizationId=e.clientOrganizationId,delete e.clientOrganizationId),e?.userSnippylyId&&delete e.userSnippylyId),e}catch(t){return this.loggingService.catch("Error in ContactService convertToClientUser: ",t),e}}getCustomUserContacts(){return this.customUserContacts$.value}getCustomUserContacts$(){return this.customUserContacts$.asObservable()}getCustomUserContactsConfig(){return this.customUserContactsConfig$.value}getCustomUserContactsConfig$(){return this.customUserContactsConfig$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(Ft),ee(ni),ee(In),ee(ot),ee(_),ee(un),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Kpe=i=>{try{let o={USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_ATTR:["onerror","onload","onclick","onmouseover","onmouseout","onmouseenter","onmouseleave","onmousemove","onmousedown","onmouseup","onwheel","onscroll","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","onsubmit","on*"],FORBID_TAGS:["script","style","iframe","object","embed","form"]};return t2.sanitize(i,o)}catch(o){return nt.catch("Error in File utils sanitizeSvg: ",o),""}},Zpe=i=>{try{return i.name.split(".").slice(0,-1).join(".")}catch(o){nt.catch("Error in File utils getFileName: ",o);return}},rq=i=>{try{return/(?:\.([^.]+))?$/.exec(i?.name)[1]}catch(o){nt.catch("Error in File utils getFileExtension: ",o);return}},Xpe=(i,o)=>{try{let n=i.slice(0,-1,i.type);return new File([n],o+"."+rq(i),{type:i.type})}catch(n){nt.catch("Error in File utils updateFile: ",n);return}},Qpe=i=>new Promise((o,n)=>{let e=new FileReader;e.readAsDataURL(i),e.onload=()=>{o(e.result)},e.onerror=t=>{n(t)}}),aq={mp4:"video/mp4",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",webm:"video/webm",mkv:"video/x-matroska",m4v:"video/x-m4v",m4a:"audio/x-m4a",aac:"audio/aac","3gp":"video/3gpp","3g2":"video/3gpp2",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",odt:"application/vnd.oasis.opendocument.text",ods:"application/vnd.oasis.opendocument.spreadsheet",zip:"application/zip",rar:"application/x-rar-compressed",txt:"text/plain",rtf:"application/rtf",html:"text/html",htm:"text/html",csv:"text/csv",ics:"text/calendar",vcf:"text/x-vcard",js:"application/javascript",css:"text/css",json:"application/json",xml:"application/xml",swf:"application/x-shockwave-flash"};var au=(()=>{let o=class o{constructor(e,t,r,a,s){this.authService=e,this.configService=t,this.coreActionsService=r,this.loggingService=a,this.attachmentResolverService=s,this.storage=Nb();try{this.configService.getApiKey$().subscribe(c=>{this.apiKey=c}),this.authService.getFirebaseConfig$().subscribe(c=>{c&&c.firebaseOptions?.storageBucket&&(this.storage=Nb(void 0,c?.firebaseOptions?.storageBucket))},c=>{this.loggingService.catch("Error in StorageService constructor: ",c)})}catch(c){this.loggingService.catch("Error in StorageService constructor:",c)}}createAttachment({path:e,file:t}){try{let r=new PC;r.name=t.name;let a=Xpe(t,`${r.attachmentId}_${Zpe(t)}`),s=`${this.apiKey}/${e}/${a?.name}`;return r.bucketPath=s,r.size=t.size,r.type=rq(t),r?.type&&(r.mimeType=aq[r?.type]),r}catch(r){return this.loggingService.catch("Error in StorageService createAttachment: ",r),null}}sanitizeSvgFile(e){return Q(this,null,function*(){if(e.type===aq.svg)try{let t=yield e.text(),r=Kpe(t);return new File([r],e.name,{type:e.type})}catch(t){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",t),e}return e})}uploadAttachmentToStorage(s){return Q(this,arguments,function*({attachment:e,file:t,resolve:r,reject:a}){try{let c=Fb(this.storage,e.bucketPath),p=$$(c,t,{cacheControl:"public,max-age=3600"});p.on("state_changed",g=>{let f=g.bytesTransferred/g.totalBytes*100},g=>{a(g)},()=>{j$(p.snapshot.ref).then(g=>{e.url=g,r(e)})})}catch(c){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",c),a(c)}})}uploadToResolver(c){return Q(this,arguments,function*({file:e,attachment:t,metadata:r,resolve:a,reject:s}){try{r.attachmentId=t.attachmentId;let p={attachmentId:t.attachmentId,name:t.name,file:e,metadata:r,mimeType:t.mimeType},g=vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Nl.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:p,eventType:va.ATTACHMENT_ADD}});let f=yield this.attachmentResolverService.saveAttachment({attachment:p,eventType:va.ATTACHMENT_ADD},g);f&&f.data?.url?(t.url=f.data?.url,a(t)):s(new Error("Failed to upload attachment to resolver"))}catch(p){this.loggingService.catch("Error in StorageService uploadToResolver: ",p),s(p)}})}uploadFile({path:e,file:t,useAttachmentResolver:r,metadata:a}){return new Promise((s,c)=>Q(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let p=yield this.sanitizeSvgFile(t),g=this.createAttachment({path:e,file:p});if(!g)throw new Error("Attachment not created");r?this.uploadToResolver({file:p,attachment:g,metadata:a,resolve:s,reject:c}):this.uploadAttachmentToStorage({attachment:g,file:p,resolve:s,reject:c})}catch(p){this.loggingService.catch("Error in StorageService uploadFile:",p),c(p)}}))}uploadChunk(e,t,r){return new Promise((a,s)=>{try{if(this.apiKey){let c=`${this.apiKey}/${e}/${t.name}`,p=Fb(this.storage,c),g=$$(p,t,{cacheControl:"public,max-age=3600"});g.on("state_changed",f=>{let I=f.bytesTransferred/f.totalBytes*100},f=>{s(f)},()=>{j$(g.snapshot.ref).then(f=>{a(f)}).catch(f=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${r}:`,f),s(f)})})}else{let c=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",c),s(c)}}catch(c){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${r}: `,c),s(c)}})}downloadAttachment(e){try{if(e.url){let t=new XMLHttpRequest;t.responseType="blob",t.onload=()=>{let r=t.response,a=document.createElement("a"),s=window.URL.createObjectURL(r);a.setAttribute("type","hidden"),a.setAttribute(U.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),a.classList.add("snippyly-overlay-panel"),a.href=s,e?.name&&(a.download=e?.name),document.body.appendChild(a);let c=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(c),window.URL.revokeObjectURL(s),a.remove()},t.onerror=()=>{window.open(e.url,"_blank")},t.open("GET",e.url),t.send()}}catch(t){this.loggingService.catch("Error in StorageService downloadAttachment: ",t)}}deleteAttachment({attachment:e,metadata:t,useAttachmentResolver:r}){return new Promise((a,s)=>{if(r){let c=vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:e.attachmentId,metadata:t}}),this.attachmentResolverService.deleteAttachment({attachmentId:e.attachmentId,metadata:t},c).then(()=>{a(null)}).catch(p=>{s(p)})}else{let c=Fb(this.storage,e.bucketPath);U$(c).then(()=>{a(null)}).catch(p=>{a(null)})}})}deleteFileFromPath(e){return new Promise((t,r)=>{let a=Fb(this.storage,e);U$(a).then(()=>{t(null)}).catch(s=>{r(s)})})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Ft),ee(ni),ee(_),ee(ou))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var En=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.analyticsService=e,this.authService=t,this.contactService=r,this.databaseService=a,this.docService=s,this.configService=c,this.loggingService=p,this.commonDbService=g,this.documentIAM$=new Ce(null),this.workspaceIAM$=new Ce(null),this.roles$=new Ce([]),this.getDocumentIamSubscription=null,this.getOrganizationIamSubscription=null,this.getWorkspaceIamSubscription=null;try{this.authService.setIamService(this),this.databaseService.getDb().pipe(Le(f=>!!f),rt(1)).subscribe(f=>{f&&(this.getUser(),this.getDocumentPaths())},f=>{this.loggingService.catch("Error in CommentService getDb subscription: ",f)}),this.getRole$().pipe(rt(1)).subscribe(f=>{this.authService?.getUser()&&!f&&this.analyticsService.trackEvent(Y.Events.Iam.USER_ACCESS_DENIED)}),this.documentIAM$.subscribe(f=>{f?.accessType&&this.contactService.setDocumentAccessType(f.accessType)})}catch(f){this.loggingService.catch("Error in IamService constructor: ",f)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in IamService","color: green;");try{this.documentIAM$.next(null),this.workspaceIAM$.next(null),this.roles$.next([]),this.documentPaths=null}catch(e){this.loggingService.catch("Error in IamService clearCache: ",e)}}getUser(){try{this.authService.getUser$().pipe(Le(e=>!!e)).subscribe(e=>{this.user=e,this.user?this.getDocumentIam():(this.getDocumentIamSubscription?.unsubscribe(),this.getOrganizationIamSubscription?.unsubscribe(),this.getWorkspaceIamSubscription?.unsubscribe())},e=>{this.loggingService.catch("Error in IamService getUser$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getUser: ",e)}}getDocumentPaths(){try{this.docService.getDocumentPaths$().pipe(Le(e=>!!e)).subscribe(e=>{this.documentPaths=e,this.getDocumentIam(),this.getWorkspaceIam()},e=>{this.loggingService.catch("Error in IamService getDocumentPaths$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getDocumentPaths: ",e)}}getDocumentIam(){try{this.getDocumentIamSubscription&&(this.getDocumentIamSubscription.unsubscribe(),this.getDocumentIamSubscription=null),this.user?this.getDocumentIamSubscription=this.docService.getDocumentIam$().subscribe(e=>{let t=e||new n9;this.documentIAM$.next(t)},e=>{this.loggingService.catch("Error in IamService getDocumentIam$ subscription: ",e)}):this.documentIAM$.next(null)}catch(e){this.loggingService.catch("Error in IamService getDocumentIam: ",e)}}getWorkspaceIam(){try{this.getWorkspaceIamSubscription||(this.getWorkspaceIamSubscription=this.commonDbService.dbListener({feature:"workspaceIam",properties:{skipFirestore:!0}}).pipe(Un(e=>le(null))).subscribe(e=>{this.workspaceIAM$.next(e?.data),this.roles$.next(e?.data?.roles||[])}))}catch(e){this.loggingService.catch("Error in IamService getWorkspaceIam: ",e)}}isUserAllowed$(){return this.getRole$().pipe(de(e=>!!e),Ct())}getDocumentIAM$(){return this.documentIAM$.asObservable()}getRoles$(){return this.roles$.asObservable().pipe(de(e=>e?.length?e:U.WorkspaceRoles))}getFeaturesAccessLevel$(){return this.documentIAM$.asObservable().pipe(de(e=>e?.features),he(e=>this.getRole$().pipe(de(t=>(t===go.ADMIN&&(e=e&&JSON.parse(JSON.stringify(e||{})),e?.all?.disabled&&(e.all.disabled=!1)),e)))))}hasRole(e){try{return e===this.getRole()}catch(t){return this.loggingService.catch("Error in IamService hasRole: ",t),!1}}hasRoleAny(e=[]){try{return e?.includes(this.getRole()||"")}catch(t){return this.loggingService.catch("Error in IamService hasRoleAny: ",t),!1}}hasRole$(e){try{return this.authService.getUser$().pipe(he(()=>this.documentIAM$.pipe(Le(t=>!!t),he(()=>this.workspaceIAM$.pipe(de(()=>e===this.getRole()))))))}catch(t){return this.loggingService.catch("Error in IamService hasRole$: ",t),le(!1)}}getRole$(){try{return this.authService.getUser$().pipe(he(()=>this.configService.getSF$()),he(()=>this.configService.getSF()?this.contactService.isUserGlobalContact$():le(null)),he(()=>this.configService.getSF()?this.documentIAM$.pipe(Le(e=>!!e),Ct(Xt)):le(null)),he(()=>this.workspaceIAM$.pipe(Ct(Xt))),de(()=>this.getRole()))}catch(e){return this.loggingService.catch("Error in IamService getRole$: ",e),le(null)}}getRole(){try{let e=this.configService.getSF();if(e&&this.contactService.isUserGlobalContact())return go.ADMIN;if(!e)return this.user?.isAdmin?go.ADMIN:go.COMMENTER;let t=null,r;if(this.user)switch((this.documentIAM$.value?this.documentIAM$.value?.features?.all?.restricted:!1)?Di.RESTRICTED:this.documentIAM$.value?this.documentIAM$.value?.documentAccessType||Di.PUBLIC:null){case Di.PUBLIC:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||go.COMMENTER;break;case Di.RESTRICTED:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||null;break;default:break}return t}catch(e){this.loggingService.catch("Error in IamService getRole: ",e)}return null}isUserAdmin$(){return this.getRole$().pipe(de(e=>e===go.ADMIN),Ct())}isUserAdmin(){try{return this.getRole()===go.ADMIN}catch(e){return this.loggingService.catch("Error in IamService isUserAdmin: ",e),!1}}getUserFromDocumentIAM(e,t){try{if(e||t){let r;return e&&(r=this.documentIAM$.value?.users?.[Tt(e)]),!r&&t&&(r=this.documentIAM$.value?.users?.[Tt(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromDocumentIAM: ",r)}}getUserFromWorkspaceIAM(e,t){try{if(e||t){let r;return e&&(r=this.workspaceIAM$.value?.users?.[Tt(e)]),!r&&t&&(r=this.workspaceIAM$.value?.users?.[Tt(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromWorkspaceIAM: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(Si),ee(In),ee(ot),ee(Ft),ee(_),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ss=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I){this.authService=e,this.docService=t,this.loggingService=r,this.commonDbService=a,this.usersService=s,this.commentUtilsService=c,this.coreActionsService=p,this.functions=g,this.configService=f,this.contactService=I,this.currentUserPermissions$=new Ce(null),this.permissionsCache$=new Ce(null),this.permissionProvider$=new Ce(null);try{this.docService.setUserPermissionService(this),this.authService.setUserPermissionService(this),this.commentUtilsService.setUserPermissionService(this),this.contactService.setUserPermissionService(this)}catch(T){this.loggingService.catch("Error in UserPermissionService constructor:",T)}}hasUserContextAccess({userId:e,accessFields:t}){try{if(!this.getIsContextEnabled()||t.includes(U.DEFAULT_VELT_CONTEXT))return!0;let r=this.contactService.getUserAccessFieldsByUserId(e);return r?t.every(a=>r.includes(a)):!0}catch(r){return this.loggingService.catch("Error in UserPermissionService hasUserContextAccess:",r),!1}}organizationDetails(e){return Q(this,null,function*(){try{let t=yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{organizationId:e}});return t&&t?.errorCode?{errorCode:Lo.PERMISSION_DENIED,error:!0}:t&&!t?.metadata?{errorCode:Lo.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(t){return this.loggingService.catch("Error in UserPermissionService organizationDetails:",t),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}documentDetails(r){return Q(this,arguments,function*({documentId:e,organizationId:t}){try{let a=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:e,organizationId:t}});if(a&&a?.errorCode)return{errorCode:Lo.PERMISSION_DENIED,error:!0};if(a&&!a?.metadata)return{errorCode:Lo.DOES_NOT_EXIST,error:!0};let s=this.docService.getDocumentMetadata(e)??{};return this.docService.setDocumentMetadata(e,E(E({},s),a?.metadata??{})),{error:!1}}catch(a){return this.loggingService.catch("Error in UserPermissionService documentDetails:",a),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}folderDetails(r){return Q(this,arguments,function*({folderId:e,organizationId:t}){try{let a=yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:e,organizationId:t}});return a&&a?.errorCode?{errorCode:Lo.PERMISSION_DENIED,error:!0}:a&&!a?.metadata?{errorCode:Lo.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(a){return this.loggingService.catch("Error in UserPermissionService folderDetails:",a),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}getUserPermissions(e){return Q(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getUserPermissions]",void 0,void 0,!0),{};let t=this.extractResourceIds(e);if(!t.clientOrganizationId||!t.organizationId)return this.loggingService.catch("Client organization id or organization id not set during getUserPermissions",void 0,void 0,!0),{};let r=yield this.validateResources(t),[a,s]=yield this.fetchUserPermissionsFromDB(t),c=this.buildPermissionsResponse(t,r,a,s);return!e&&Object.keys(c).length>0&&this.setCurrentUserPermissions(c),c}catch(t){return this.loggingService.catch("Error in UserPermissionService getUserPermissions:",t),{}}})}extractResourceIds(e){let t=this.docService.getDocumentPaths(),r=this.docService.getDocumentIds();return{folderIds:e?.folderIds?.length?e.folderIds:t?.folderId?[t.folderId]:[],documentIds:e?.documentIds?.length?e.documentIds:r.map(a=>a.clientDocumentId),clientOrganizationId:e?.organizationId??t?.clientOrganizationId,organizationId:e?.organizationId??t?.clientOrganizationId?os(e?.organizationId??t?.clientOrganizationId??""):void 0}}validateResources(e){return Q(this,null,function*(){let{folderIds:t,documentIds:r,organizationId:a,clientOrganizationId:s}=e,c=[],p=[];a&&(c.push(this.organizationDetails(a)),p.push({id:s??"",type:"organization"})),t.forEach(f=>{c.push(this.folderDetails({folderId:Ai(f),organizationId:a??""})),p.push({id:f,type:"folder"})}),r.forEach(f=>{c.push(this.documentDetails({documentId:Tr(f),organizationId:a??""})),p.push({id:f,type:"document"})});let g=yield Promise.allSettled(c);return this.processValidationResults(g,p)})}processValidationResults(e,t){let r=[],a=[],s,c=e.map((p,g)=>({result:p,metadata:t[g]})).filter(({result:p})=>p.status==="rejected"||p.status==="fulfilled"&&p.value.error);for(let{result:p,metadata:g}of c){let f=p.status==="fulfilled"?p.value.errorCode??Lo.SOMETHING_WENT_WRONG:Lo.SOMETHING_WENT_WRONG,I={id:g.id,errorCode:f};switch(g.type){case"organization":if(s=I,f===Lo.DOES_NOT_EXIST)throw new Error(`Organization with id '${g.id}' does not exist`);break;case"folder":r.push(I);break;case"document":a.push(I);break}}return{failedFolderIds:r,failedDocumentIds:a,failedOrganizationId:s}}fetchUserPermissionsFromDB(e){return Q(this,null,function*(){let{folderIds:t,documentIds:r,organizationId:a}=e,s=[this.authService.getUser()?.userId??""],c=[...t.map(f=>Ai(f)),...r.map(f=>Tr(f)),a??""],[p,g]=yield Promise.allSettled([this.usersService.getUsersFromDBWithBatching({userIds:s,organizationId:a}),this.usersService.getTemporaryUsersFromDBWithBatching({userIds:s,organizationId:a,resourceIds:c})]);return[p.status==="fulfilled"?p.value:[],g.status==="fulfilled"?g.value:[]]})}buildPermissionsResponse(e,t,r,a){let{folderIds:s,documentIds:c,clientOrganizationId:p,organizationId:g}=e,{failedFolderIds:f,failedDocumentIds:I,failedOrganizationId:T}=t,B={};return this.processRegularUserPermissions(B,r,s,c,p??"",g??"",f,I,T),this.processTemporaryUserPermissions(B,a),this.processContextPermissions(B),B}processContextPermissions(e){try{let t=this.authService.getUser()?.userId;if(t){let r=this.contactService.getUserAccessFieldsByUserId(t);r?.length&&(e[t]||(e[t]={}),e[t].context={accessFields:r})}}catch(t){this.loggingService.catch("Error in UserPermissionService processContextPermissions:",t);return}}processRegularUserPermissions(e,t,r,a,s,c,p,g,f){for(let I of t)for(let T of I)T?.user?.userId&&(e[T.user.userId]=D(E({},r.length&&{folders:this.buildFolderPermissions(r,T,p)}),{documents:this.buildDocumentPermissions(a,T,g),organization:{[s]:this.buildOrganizationPermission(c,T,f)}}))}getErrorMessage(e,t){try{switch(this.loggingService.log(`Error in UserPermissionService getErrorMessage: ${e} ${t}`),e){case Lo.DOES_NOT_EXIST:return`${t} does not exist`;case Lo.PERMISSION_DENIED:return`User does not have access to ${t}`;case Lo.SOMETHING_WENT_WRONG:return"Something went wrong";default:return"Something went wrong"}}catch(r){return this.loggingService.catch("Error in UserPermissionService getErrorMessage:",r),"Something went wrong"}}buildFolderPermissions(e,t,r){return e.reduce((a,s)=>{let c=r.find(p=>p.id===s);return c?a[s]={error:this.getErrorMessage(c.errorCode,"folder"),errorCode:c.errorCode}:a[s]={accessRole:t.viewerFolderIds?.includes(Ai(s))?tl.VIEWER:tl.EDITOR},a},{})}buildDocumentPermissions(e,t,r){return e.reduce((a,s)=>{let c=r.find(p=>p.id===s);return c?a[s]={error:this.getErrorMessage(c.errorCode,"document"),errorCode:c.errorCode}:a[s]={accessRole:t.viewerDocumentIds?.includes(Tr(s))?tl.VIEWER:tl.EDITOR},a},{})}buildOrganizationPermission(e,t,r){return r?{error:this.getErrorMessage(r.errorCode,"organization"),errorCode:r.errorCode}:{accessRole:t.viewerOrganizationIds?.includes(e)?tl.VIEWER:tl.EDITOR}}processTemporaryUserPermissions(e,t){for(let r of t)if(r?.userId)switch(this.ensureUserPermissionStructure(e,r.userId),r.type){case"folder":this.addTemporaryFolderPermission(e,r);break;case"document":this.addTemporaryDocumentPermission(e,r);break;case"organization":this.addTemporaryOrganizationPermission(e,r);break}}ensureUserPermissionStructure(e,t){e[t]||(e[t]={})}addTemporaryFolderPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].folders||(e[r].folders={}),e[r].folders[a]||(e[r].folders[a]={accessRole:s??tl.EDITOR,expiresAt:c})}addTemporaryDocumentPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].documents||(e[r].documents={}),e[r].documents[a]={accessRole:s??tl.EDITOR,expiresAt:c}}addTemporaryOrganizationPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].organization||(e[r].organization={}),e[r].organization[a]={accessRole:s??tl.EDITOR,expiresAt:c}}hasEditAccess({organizationId:e,folderId:t,documentId:r}){try{let a=!0,s=this.getCurrentUserPermissionsWithServerIds(),c=this.authService.getUser()?.userId??"";return s&&(e&&typeof e=="string"&&s?.[c]?.organization?.[e]&&(s?.[c]?.organization?.[e]?.accessRole===tl.VIEWER||s?.[c]?.organization?.[e]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1),t&&typeof t=="string"&&s?.[c]?.folders?.[t]&&(s?.[c]?.folders?.[t]?.accessRole===tl.VIEWER||s?.[c]?.folders?.[t]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1),r&&typeof r=="string"&&s?.[c]?.documents?.[r]&&(s?.[c]?.documents?.[r]?.accessRole===tl.VIEWER||s?.[c]?.documents?.[r]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1)),a}catch{return!0}}getCurrentUserPermissions$(){return this.currentUserPermissions$.asObservable().pipe(Ct(Xt))}getCurrentUserPermissions(){return this.currentUserPermissions$.value}refactorPermissionsWithServerIds(e){try{let t=JSON.parse(JSON.stringify(e??{})),r=this.authService.getUser()?.userId??"";if(t?.[r]){let a=this.docService.getDocumentPaths()?.clientOrganizationId??"";if(t?.[r]?.organization?.[a]){let s=os(a);t[r].organization&&(t[r].organization[s]=t[r].organization[a],delete t[r].organization[a])}t?.[r]?.folders&&(t[r].folders=Object.fromEntries(Object.entries(t?.[r]?.folders??{}).map(([s,c])=>[Ai(s),c]))),t?.[r]?.documents&&(t[r].documents=Object.fromEntries(Object.entries(t?.[r]?.documents??{}).map(([s,c])=>[Tr(s),c])))}return t}catch(t){return this.loggingService.catch("Error in UsersPermissionService refactorPermissionsWithServerIds:",t),e}}getCurrentUserPermissionsWithServerIds$(){return this.currentUserPermissions$.asObservable().pipe(de(e=>this.refactorPermissionsWithServerIds(e)),Ct(Xt))}getCurrentUserPermissionsWithServerIds(){return this.refactorPermissionsWithServerIds(this.currentUserPermissions$.value)}setCurrentUserPermissions(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCurrentUserPermissions","color: green;");let t=null;e&&(t=JSON.parse(JSON.stringify(e))),this.currentUserPermissions$.next(t)}catch(t){this.loggingService.catch("Error in UsersPermissionService setCurrentUserPermissions:",t)}}getIsContextEnabled(){return this.loggingService.log("%c[WB] Calling FUNCTION: getIsContextEnabled","color: green;"),this.permissionProvider$.value?.isContextEnabled??!1}setPermissionProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setPermissionProvider","color: green;"),this.permissionProvider$.next(e)}catch(t){this.loggingService.catch("Error in UsersPermissionService setPermissionProvider:",t)}}get isRevokeAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.DOCUMENT_UNSET)??!1}get isRevokeAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.USER_LOGOUT)??!1}get isRevokeOrganizationAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.USER_LOGOUT&&e.revokeOrganizationAccess)??!1}get isRevokeOrganizationAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.DOCUMENT_UNSET&&e.revokeOrganizationAccess)??!1}getPermissionProviderRetryConfig(){return this.permissionProvider$.value?.retryConfig??{retryCount:0,retryDelay:0}}revokeAccessOnUserLogout(){return Q(this,null,function*(){let e=vt();try{if(this.isRevokeAccessOnUserLogoutEnabled){let t=[],r=this.authService.getUser()?.userId??"";if((this.getPermissionsCache()??[]).forEach(s=>{s.userId===r&&s.hasAccess&&(s.type===Fo.ORGANIZATION?this.isRevokeOrganizationAccessOnUserLogoutEnabled&&t.push(D(E({},s),{hasAccess:!1})):t.push(D(E({},s),{hasAccess:!1})))}),t.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:t}}),this.setPermissionsCache([]),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:t}});let s=yield this.revokeAccess({requests:t,userId:this.authService.getUser()?.userId??""});s.success?this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:s,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:s,success:!1,statusCode:500}}})}}}catch(t){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{error:t}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnUserLogout:",t)}})}revokeAccessOnDocumentUnset(){return Q(this,null,function*(){let e=vt();try{if(this.isRevokeAccessOnDocumentUnsetEnabled){let t=[],r=this.docService.getDocumentIds(),a=this.docService.getOrganizationConfig()?.clientOrganizationId??"",s=this.docService.getDocumentPaths()?.folderId??"",c=this.authService.getUser()?.userId??"",p=this.getPermissionsCache()??[];if(r.forEach(g=>{p.find(f=>f.resourceId===g.clientDocumentId&&f.type===Fo.DOCUMENT&&f.organizationId===a&&f.userId===c)&&(t.push({userId:c,resourceId:g.clientDocumentId,organizationId:a,type:Fo.DOCUMENT,hasAccess:!1}),p=p.filter(f=>!(f.resourceId===g.clientDocumentId&&f.type===Fo.DOCUMENT&&f.organizationId===a&&f.userId===c)))}),s&&p.find(g=>g.resourceId===s&&g.type===Fo.FOLDER&&g.organizationId===a&&g.userId===c)&&(t.push({userId:c,resourceId:s,organizationId:a,type:Fo.FOLDER,hasAccess:!1}),p=p.filter(g=>!(g.resourceId===s&&g.type===Fo.FOLDER&&g.organizationId===a&&g.userId===c))),a&&this.isRevokeOrganizationAccessOnDocumentUnsetEnabled&&p.find(g=>g.resourceId===a&&g.type===Fo.ORGANIZATION&&g.organizationId===a&&g.userId===c)&&(t.push({userId:c,resourceId:a,organizationId:a,type:Fo.ORGANIZATION,hasAccess:!1}),p=p.filter(g=>!(g.resourceId===a&&g.type===Fo.ORGANIZATION&&g.organizationId===a&&g.userId===c))),this.setPermissionsCache(p),t.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:t}}),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:t}});let g=yield this.revokeAccess({requests:t,userId:c});g.success?this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:g,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:g,success:!1,statusCode:500}}})}}}catch(t){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:t}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnDocumentUnset:",t)}})}getAccess(r){return Q(this,arguments,function*({requests:e,userId:t}){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield hd({methodName:"getAccess",data:{type:"getAccess",data:e,metadata:{retryConfig:this.getPermissionProviderRetryConfig()}},getSdkProxy:a,userId:t})})}revokeAccess(r){return Q(this,arguments,function*({requests:e,userId:t}){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield hd({methodName:"revokeAccess",data:{type:"revokeAccess",data:e,metadata:{retryConfig:this.getPermissionProviderRetryConfig()}},getSdkProxy:a,userId:t})})}onResourceAccessRequired(c){return Q(this,arguments,function*({requests:e,uniqueId:t,methodName:r,userId:a,fromCache:s=!0}){try{if(!e?.length)return;let p=[],g=this.getPermissionsCache()??[];if(!this.forceRefreshPermissions()&&s&&(e.forEach(f=>{let I=g?.find(T=>T.resourceId===f.resource.id&&T.type===f.resource.type&&T.userId===f.userId&&T.organizationId===f.resource.organizationId);I&&p.push(I)}),p.length>0&&(e=e.filter(f=>!p.find(I=>I.resourceId===f.resource.id&&I.type===f.resource.type&&I.userId===f.userId&&I.organizationId===f.resource.organizationId)))),e.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:t,methodName:r,source:"internal",payload:{requests:e,fromCache:s}});let f=yield this.getAccess({requests:e,userId:this.authService.getUser()?.userId??a??""});return this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_RESULT,timestamp:new Date().getTime(),uniqueId:t,methodName:r,source:"internal",payload:{result:f}}),f?.success&&f?.data?.length&&(this.setPermissionsCache([...g,...f.data]),f.data=[...p,...f.data]),f}else if(p.length>0)return this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_RESULT_FROM_CACHE,timestamp:new Date().getTime(),methodName:r,source:"internal",uniqueId:t,payload:{results:p}}),{data:p,success:!0,statusCode:200};return}catch(p){this.loggingService.catch("Error in UsersPermissionService onResourceAccessRequired:",p),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_ERROR,timestamp:new Date().getTime(),methodName:r,source:"internal",uniqueId:t,payload:{error:p,requests:e,fromCache:s}});return}})}getPermissionsCache(){return this.forceRefreshPermissions()?[]:this.permissionsCache$.getValue()}forceRefreshPermissions(){return this.getPermissionProvider()?.forceRefresh??!1}setPermissionsCache(e){try{let t=new Map;e.forEach(a=>{let s=`${a.userId}_${a.resourceId}_${a.organizationId}_${a.type}`;t.set(s,a)});let r=JSON.parse(JSON.stringify(Array.from(t.values())));this.permissionsCache$.next(r)}catch(t){this.loggingService.catch("Error in UsersPermissionService setPermissionsCache:",t)}}isPermissionProviderAvailable(){try{return!!this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService isPermissionProviderAvailable:",e),!1}}getPermissionProvider(){try{return this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService getPermissionProvider:",e),null}}getPermissionProvider$(){return this.permissionProvider$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(ot),ee(_),ee(un),ee(Ln),ee(ru),ee(ni),ee(Do),ee(Ft),ee(Si))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var hn=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye){this.afAuth=e,this.analyticsService=t,this.authService=r,this.configService=a,this.commonDbService=s,this.commonDbUtilsService=c,this.commentUtilsService=p,this.commentAnnotationsResolverService=g,this.databaseService=f,this.docService=I,this.domService=T,this.iamService=B,this.loggingService=z,this.notificationUtilsService=G,this.usersService=J,this.functions=ne,this.userPermissionService=ve,this.coreActionsService=ye,this.db=Is(),this.notificationsDb=Is(void 0,wn.firebaseNotificationsDatabaseURL),this.documentPaths=null,this.notifications$=new Ce([]),this.rawNotificationsByIdMap$=new Ce(new Map),this.processedNotifications$=new Ce([]),this.userNotificationsFromServer$=new Ce(null),this.readNotificationsOnForYouTab$=new Ce(!1),this.currentDocumentOnly$=new Ce(!1),this.notificationViews$=new Ce({}),this.notificationsByIdMap$=new Ce(new Map),this.historyPanelVisible$=new Ce(!1),this.notificationsForYou$=new Ce(null),this.notificationsByDocumentIdMap$=new Ce(null),this.notificationsByDocumentIdSubscription={},this.allowedDocumentMetadataMap$=new Ce(null),this.maxNotificationDays$=new Ce(15),this.tabConfig$=new Ce({people:{enable:!1}}),this.settingsConfig$=new Ce(null),this.muteAllNotifications$=new Ce(!1),this.enableSettings$=new Ce(!1),this.selfNotifications$=new Ce(!1),this.settingsInitialConfig$=new Ce([{name:"Inbox",id:"inbox",default:"ALL",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]},{name:"Email",id:"email",default:"MINE",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]}]),this.notificationsPanelVisible$=new Ce(!1);try{this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(Le(Ne=>!!Ne),rt(1)).subscribe(Ne=>{Ne&&(this.db=Ne,this.getDocumentIds(),this.subscribeGetNotificationsForYou())},Ne=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",Ne)}),this.authService.getUser$().subscribe(Ne=>{Ne?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(Ve=>{this.notificationsByDocumentIdSubscription[Ve]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),this.docService.getLocationMetadata$().subscribe(Ne=>{if(Ne){let Ve=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(Ne||{}).forEach(Ie=>{let be=Ve?.[Ie]?.notifications;be?.length&&be.forEach(Ae=>{this.notificationUtilsService.mergeLocationWithNotification({notification:Ae},Ne)?.notification})}),this.notificationsByDocumentIdMap$.next(Ve)}})}catch(Ne){this.loggingService.catch("Error in NotificationService constructor: ",Ne)}}setDBConfigDataToInitialConfig(e){try{let t=JSON.parse(JSON.stringify(this.settingsConfig$.getValue()??{}));Object.entries(e||{}).forEach(([r,a])=>{t[r]=a}),this.settingsConfig$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService setDBConfigDataToInitialConfig: ",t)}}getInitialConfigFromDB(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: getInitialConfigFromDB","color: green;");let t=Tt(this.authService.getUser()?.userId??""),r=yield this.commonDbService.getData({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?.documentId,userId:t}});if(r?.notificationsConfig)this.setDBConfigDataToInitialConfig(r?.notificationsConfig);else{this.setSettingsInitialConfig(this.settingsInitialConfig$.getValue());let a={};this.settingsInitialConfig$.getValue().forEach(c=>{if(c.enable){let p=c?.values?.find(g=>g.id===c.default);a[c.id]=p||c?.values?.[0]||{id:"NONE",name:"None"}}});let s={};Object.keys(a).forEach(c=>{s[c]=a[c].id}),yield this.updateSettingsConfigToDb(s)}}catch(t){this.loggingService.catch("Error in NotificationService getInitialConfigFromDB: ",t)}})}subscribeToUserSettings(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: subscribeToUserSettings","color: green;"),this.userSettingsSubscription&&this.userSettingsSubscription.unsubscribe();let e=Tt(this.authService.getUser()?.userId??"");this.userSettingsSubscription=this.enableSettings$.pipe(Le(t=>t===!0),he(()=>this.docService.getDocumentPaths$().pipe(Le(t=>!!t),he(t=>no(this.getInitialConfigFromDB(t)).pipe(he(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:t?.documentId,userId:e}}).pipe(de(r=>{r?.data?.notificationsConfig&&!hi(r?.data?.notificationsConfig??{},this.settingsConfig$.getValue()??{})&&this.setDBConfigDataToInitialConfig(r?.data?.notificationsConfig)})))))))).subscribe()}catch(e){this.loggingService.catch("Error in NotificationService subscribeToUserSettings: ",e)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: resetCacheData","color: green;"),this.setUserNotificationsFromServer(null),this.notificationsByDocumentIdMap$.next(null),this.notificationsForYou$.next(null),this.settingsConfig$.next(null)}catch(e){this.loggingService.catch("Error in NotificationService resetCacheData: ",e)}}subscribeGetNotificationsForYou(){try{this.notificationForYouSubscription&&this.notificationForYouSubscription.unsubscribe(),this.notificationForYouSubscription=this.getNotificationsForYou().subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getNotificationsForYou subscription: ",e)})}catch(e){this.loggingService.catch("Error in NotificationService subscriveGetNotificationsForYou: ",e)}}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in NotificationService setCommentService: ",t)}}getDocumentIds(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe(),this.documentIdsSubscription=this.selfNotifications$.pipe(he(()=>this.getCurrentDocumentOnly$().pipe(he(e=>e?this.docService.getDocumentPaths$().pipe(de(t=>{})):le(void 0)))),Qt(()=>{this.notificationsByDocumentIdMap$.next(null)}),he(()=>this.getDocumentIdsByLastNotificationTimestamp().pipe(Oi(),de(([e,t])=>{let r=e?.map(g=>g.documentId),a=t?.map(g=>g.documentId),s=r?.filter(g=>!a?.includes(g)),c=a?.map(g=>({documentId:g,timestamp:t?.find(f=>f.documentId===g)?.timestamp})).filter(g=>!r?.includes(g.documentId)),p=a?.map(g=>{let f=t?.find(I=>I.documentId===g)?.timestamp;return{documentId:g,timestamp:f}}).filter(g=>{let f=e?.find(I=>I.documentId===g.documentId)?.timestamp;return f&&g.timestamp&&f!==g.timestamp});c?.length&&this.fetchNotificationsForDocumentIds(c),p?.length&&this.fetchNotificationsForDocumentIds(p,1),s?.forEach(g=>{this.removeNotificationsForDocumentId(g)}),t&&!t?.length&&!this.notificationsByDocumentIdMap$.getValue()&&this.notificationsByDocumentIdMap$.next(null)})))).subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",e)})}catch(e){this.loggingService.catch("Error in NotificationService getDocumentIds: ",e)}}getDocumentIdsByLastNotificationTimestamp(e=15){try{return this.authService.getUser$().pipe(he(t=>this.docService.getOrganizationConfig$().pipe(de(r=>{let a=null,s=this.configService.getApiKey(),c=r?.organizationId||t?.organizationId;return s&&c&&(a=new Sm({apiKey:s,organizationId:c})),{user:t,documentPaths:a}}))),he(t=>{let{user:r,documentPaths:a}=t;if(this.getCurrentDocumentOnly()&&!this.docService?.getDocumentPaths()?.documentId)return le(null);if(r&&a?.organizationNotificationsLastNotificationTimestamp){let s=new Date,c=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;s.setDate(s.getDate()-c);let p=s.getTime(),g=[li(lt("timestamp",">=",p),...this.getCurrentDocumentOnly()&&this.docService.getDocumentPaths()?.documentId?[lt("metadata.documentId","==",this.docService.getDocumentPaths()?.documentId)]:[])];return this.getCurrentDocumentOnly()||(g.push(eo("timestamp","desc")),g.push(_m(e))),this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:a?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:g}}).pipe(de(f=>f?.data),de(f=>{let I=[];return Object.keys(f||{}).forEach(T=>{let B=this.commonDbService.shouldUseFirestore()?f[T]?.timestamp??0:f[T],z=this.commonDbService.shouldUseFirestore()?f[T]?.deletedNotification??!1:!1;if(z&&z.id&&z?.timestamp===B){let G=z.id,J=f[T]?.metadata?.documentId,ne=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),ve=ne?.[J]??{documentMetadata:null,notifications:[]},ye=ve.notifications??[],Ne=ye?.findIndex(Ve=>Ve.id===G);Ne!==-1&&(ye.splice(Ne,1),this.notificationsByDocumentIdMap$.next(D(E({},ne),{[J]:D(E({},ve),{notifications:ye})})))}I.push({documentId:T,timestamp:B})}),I}),Un(f=>(this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",f),le([]))))}return le(null)}))}catch(t){return this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",t),le([])}}fetchNotificationsForDocumentIds(e,t=15){return Q(this,null,function*(){try{if(e?.length){let r=Qi(this.functions,Ji({url:wn.cloudFunction.getNotificationsForDocuments,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a=this.docService.getOrganizationConfig()?.organizationId??"";if(!a)return[];let s=this.getStartAtTimestamp(),c={};if(e.forEach(ye=>{if(ye?.documentId){let Ne=this.getAllowedDocumentMetadataByDocumentId(ye.documentId);Ne&&(c[ye.documentId]=Ne)}}),this.userPermissionService?.isPermissionProviderAvailable())try{let ye=[];if(e.forEach(Ae=>{this.docService.getDocumentMetadata(Ae.documentId)||ye.push(Ae.documentId)}),ye.length){let Ae=this.authService.getUser(),_e=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let fe=yield hd({methodName:"getDocumentMetadataFromIds",data:{type:"getDocumentMetadataFromIds",metadata:{organizationId:Ae?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:ye},getSdkProxy:_e,userId:Ae?.userId??""});if(fe?.data?.length){let Oe={};fe.data.forEach(Fe=>{Fe?.documentId&&(Oe[Fe.documentId]=Fe)}),this.docService.setAllDocumentMetadata(E(E({},this.docService.getAllDocumentMetadataMap()),Oe))}}catch(fe){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",fe)}}let Ne=[],Ve=[];e.forEach(Ae=>{let _e=this.docService.getDocumentMetadata(Ae.documentId);_e?.clientDocumentId?Ne.push({userId:this.authService.getUser()?.userId??"",resource:{id:_e.clientDocumentId,type:Fo.DOCUMENT,source:Gi.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""}}):Ve.push(Ae.documentId)}),Ve.length&&(e=e.filter(Ae=>!Ve.includes(Ae.documentId)));let Ie=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:Ie,methodName:Gi.GET_NOTIFICATIONS,source:"internal",payload:{requests:Ne}});let be=yield this.userPermissionService?.onResourceAccessRequired({requests:Ne,uniqueId:Ie,methodName:Gi.GET_NOTIFICATIONS});be?.success&&be?.data?.length?be.data.forEach(Ae=>{!Ae.hasAccess&&Ae.resourceId&&(e=e.filter(_e=>_e.documentId!==Tr(Ae.resourceId)))}):e=[]}catch(ye){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",ye),e=[]}if(!e.length)return[];let p=this.userPermissionService?.getPermissionsCache()?.filter(ye=>ye.type===Fo.CONTEXT),g={organizationId:a,documentIds:e.filter(ye=>!!ye.documentId&&!!ye.timestamp).map(ye=>({documentId:ye.documentId,timestamp:ye.timestamp??0})),timestamp:s,limitToLast:t,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:p,retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},f=yield this.notificationUtilsService.handleNotificationEncryption({data:g}),I=yield r({veltData:f}),T=I?.data?.data?.veltData||{},B=I?.data?.data?.veltAdditionalData||{},z="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),G=yield X0(T,z),{userNotifications:J=[],userNotificationIdsInDocNotifications:ne=[],permissionResults:ve=[]}=yield X0(B,z);if(this.userPermissionService?.getIsContextEnabled()){let ye=[...this.userPermissionService?.getPermissionsCache()??[],...ve??[]];this.userPermissionService?.setPermissionsCache(ye)}if(G&&typeof G=="object"){let ye=this.usersService.userDataProviderAvailable(),Ne=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),Ve=[],Ie=[];Object.keys(G).forEach((be,Ae)=>{let _e=G[be].documentMetadata;if(_e){let Oe=this.allowedDocumentMetadataMap$.value||{};(!Oe?.[be]||!hi(Oe?.[be],_e))&&this.allowedDocumentMetadataMap$.next(D(E({},Oe),{[be]:_e}))}let fe=G[be].notifications||[];fe.forEach(Oe=>{ne.includes(Oe.notificationId)&&!J.find(Fe=>Fe.notificationId===Oe.notificationId)&&J.push(JSON.parse(JSON.stringify(Oe))),Oe.notification=this.getClientNotificationObject(Oe)}),this.setNotificationForDocumentIdInCache(be,_e,fe),ye&&(Ve.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:fe,shouldAwait:!0,forceResolve:!0})),Ve.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:J,shouldAwait:!0,forceResolve:!0}))),Ne&&(Ie.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:fe,shouldCommentAnnotationsResolverAwait:!0})),Ie.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:J,shouldCommentAnnotationsResolverAwait:!0})))}),this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...J]),ye&&Promise.all(Ve).then(()=>{Object.keys(G).forEach(be=>{let Ae=G?.[be]?.documentMetadata||{},_e=this.commonDbUtilsService.mergeUsersWithData({feature:"allDocNotifications",data:G?.[be]?.notifications||[]});_e.forEach(fe=>{fe.notification=this.getClientNotificationObject(fe)}),this.setNotificationForDocumentIdInCache(be,Ae,_e)})}),Ne&&Promise.all(Ie).then(()=>{Object.keys(G).forEach(be=>{let Ae=G?.[be]?.documentMetadata||{},_e=G?.[be]?.notifications?.reduce((fe,Oe)=>(fe[Oe.notificationId]=Oe,fe),{});_e=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allDocNotifications",data:_e}),_e=Object.values(_e??{}),_e.forEach(fe=>{fe.notification=this.getClientNotificationObject(fe)}),this.setNotificationForDocumentIdInCache(be,Ae,_e)})})}}}catch(r){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",r),[]}})}getUserNotificationsFromServer$(){return this.userNotificationsFromServer$.asObservable()}setUserNotificationsFromServer(e){try{let t=JSON.parse(JSON.stringify(e));t=t?.filter((r,a,s)=>a===s.findIndex(c=>c.notificationId===r.notificationId)),this.userNotificationsFromServer$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService setUserNotificationsFromServer: ",t)}}getUserNotificationsFromServer(){return this.userNotificationsFromServer$.getValue()}setNotificationForDocumentIdInCache(e,t,r,a){try{let s=this.docService.getOrganizationConfig()?.organizationId??"",c=this.docService.getOrganizationMetadata(s);t||(t=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),c||(c=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(s)||{})));let p=this.notificationsByDocumentIdMap$.getValue(),g=p?.[e]?.notifications||[],f=this.docService.getLocationMetadatas(),I=r?.map(z=>{let G=z?.notification;return G?(G.metadata&&(G.metadata.documentName=t?.documentName||G.metadata.documentName,G.metadata.organizationMetadata=c||G.metadata.organizationMetadata,G.metadata.documentMetadata=t||G.metadata.documentMetadata),f&&(G=this.notificationUtilsService.mergeLocationWithNotification({notification:G},f)?.notification),G):null})?.filter(z=>!!z)||[],T=new Map(g.map(z=>[z.id,z]));I.forEach(z=>{T.set(z.id,z)});let B=Array.from(T.values()).sort((z,G)=>(G.timestamp||0)-(z.timestamp||0));this.notificationsByDocumentIdMap$.next(D(E({},p),{[e]:{notifications:B,documentMetadata:t}}))}catch(s){this.loggingService.catch("Error in NotificationService setNotificationForDocumentIdInCache: ",s)}}removeNotificationsForDocumentId(e){try{this.notificationsByDocumentIdSubscription[e]&&this.notificationsByDocumentIdSubscription[e].unsubscribe();let t=this.notificationsByDocumentIdMap$.getValue();delete t?.[e],this.notificationsByDocumentIdMap$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService removeNotificationsForDocumentId: ",t)}}getStartAtTimestamp(){try{let e=new Date,t=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;return e.setDate(e.getDate()-t),e.getTime()}catch(e){return this.loggingService.catch("Error in NotificationService getStartAtTimestamp: ",e),0}}getNotificationsForYou(){try{return this.getUserNotificationsFromServer$().pipe(he(e=>le(e).pipe(Le(t=>!!t),de(t=>{let r=this.usersService.userDataProviderAvailable(),a=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable();if(r||a){let c=t?.reduce((p,g)=>(p[g.notificationId]=g,p),{});r&&(c=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:c||[]})),a&&(c=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:c||[]})),t=Object.values(c??{})}return t.forEach(c=>{c.notification=this.getClientNotificationObject(c)}),t.sort((c,p)=>p.timestamp-c.timestamp),t.map(c=>c.notification).filter(c=>!!c)}),he(t=>{let r={data:t?.reduce((a,s)=>(a[s.id]={notification:s},a),{}),operation:null};return this.commonDbUtilsService.mergeLocationMetadataWithData$({data:r,feature:"allUserNotifications"}).pipe(de(a=>Object.values(a?.data||{}).map(s=>s?.notification)))}))),he(e=>{let t=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(t).pipe(de(()=>e))}),he(e=>this.allowedDocumentMetadataMap$.pipe(de(()=>e))),de(e=>(e?.length&&(e=e.map(t=>{if(t?.metadata){let r=this.docService.getOrganizationConfig()?.organizationId??"",a=this.getAllowedDocumentMetadataByDocumentId(t.metadata.documentId),s=this.docService.getOrganizationMetadata(r);a||(a=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),s||(s=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(r)||{}))),t.metadata.documentName=a?.documentName||t.metadata.documentName,t.metadata.organizationMetadata=s||t.metadata.organizationMetadata,t.metadata.documentMetadata=a||t.metadata.documentMetadata}return t})),e===null?this.notificationsForYou$.next(null):e?.length?this.notificationsForYou$.next(JSON.parse(JSON.stringify(e))):this.notificationsForYou$.next([]),le(e))))}catch(e){return this.loggingService.catch("Error in NotificationService getNotificationsForYou: ",e),le({})}}subscribeNotificationsData(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let r,a;try{if(e&&(a=Nn(e)),t&&typeof t=="object"){let s=or(t);r=Nn(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return ei(this.afAuth).pipe(Le(s=>!!s),he(s=>this.isFeatureAllowed({firebaseUser:s})),he(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(de(c=>(s.featureAllowed=c,s))):le(s)),he(s=>!s.featureAllowed||s?.user?.organizationId?(this.notifications$.next([]),this.rawNotificationsByIdMap$.next(new Map),this.processedNotifications$.next([]),this.notificationsByIdMap$.next(new Map),this.notificationViews$.next({}),this.setNotificationsByIdMap(),le([])):le(s).pipe(he(c=>this.docService.getDocumentPaths$().pipe(de(p=>(this.documentPaths=p,c.documentPaths=p,c)))),he(c=>this.getDataFromDocumentId(a)))))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),he(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),he(t=>ro(t.config,t.user,Re.NOTIFICATION)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),he(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.views){let r=`${this.configService.getApiKey()}`;this.documentPaths?.organizationId&&(r+=`/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let a=Ti(this.db,`${e?r+"/"+U.FIREBASE_PARTIAL_PATH_DOCS+"/"+e+"/"+U.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return PM(a).pipe(Un(s=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",s),le(null))),de(s=>{let c=[],p=new Map;s?.raw&&(Object.keys(s?.raw||{}).forEach(f=>{let I=s?.raw[f];I?.id&&c.push(I)}),c.forEach(f=>{f.id&&p.set(f.id,f)})),this.notifications$.next(c),this.rawNotificationsByIdMap$.next(p);let g=[];s?.processed&&Object.keys(s?.processed||{}).forEach(f=>{let I=s?.processed[f];I?.id&&g.push(I)}),this.processedNotifications$.next(g),this.setNotificationsByIdMap()}))}else return le(null)}))}setNotificationsByIdMap(){try{let e=this.authService.getUser();if(e){let t=this.notificationViews$.getValue(),r;e?.email&&(r=Tt(e?.email));let a;e?.userId&&(a=Tt(e?.userId));let s=new Map;this.processedNotifications$.getValue().forEach(p=>{if(p.id&&p?.displayHeadlineMessageTemplate){let g=!1;(r&&p.notifyUsers?.[r]||a&&p.notifyUsers?.[a])&&(g=!0);let f={id:p.id,notificationSource:p.notificationSource,actionType:p.actionType,actionUser:p.actionUser,timestamp:p.timestamp,targetAnnotationId:p.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(p),displayBodyMessage:this.getNotificationBodyMessage(p),forYou:g,notificationSourceData:p.notificationSourceData},I=this.getRawNotificationById(f.id);if(I?.metadata&&(f.metadata={apiKey:I.metadata.apiKey,organizationId:I.metadata.organizationId,clientOrganizationId:I.metadata.clientOrganizationId,documentId:I.metadata.documentId,clientDocumentId:I.metadata.clientDocumentId,location:I?.location,locationId:I?.locationId}),f?.notificationSource==="comment"&&f?.targetAnnotationId){let T=this.commentService?.getAnnotationById(f.targetAnnotationId);T||I?.annotationData&&(T=I.annotationData),T&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(T))}s.set(p.id,f)}}),s.forEach((p,g)=>{p.isUnread=p?.actionUser?.userSnippylyId!==e?.userSnippylyId&&!t?.notification?.[g]?.views?.[e?.userSnippylyId],s.set(g,p)}),this.notificationsByIdMap$.next(s)}}catch(e){this.loggingService.catch("Error in NotificationService setNotificationsByIdMap: ",e)}}getClientNotificationObject({processed:e,raw:t,metadata:r,views:a,notification:s}){try{let c=this.authService.getUser(),p=s||e;if(p.id&&p?.displayHeadlineMessageTemplate&&c){let g=null;c?.email&&(g=Tt(c?.email));let f=null;c?.userId&&(f=Tt(c?.userId));let I=!1,T=!0;(g&&p.notifyUsers?.[g]||f&&p.notifyUsersByUserId?.[f])&&(I=!0),f&&a?.[f]&&(T=!1);let B={id:p.id};if(s?B=D(E(E({},B),s),{displayHeadlineMessage:this.getNotificationHeadlineMessage(s),displayBodyMessage:this.getNotificationBodyMessage(s),forYou:I,isUnread:T}):B={id:e.id,notificationSource:e.notificationSource,actionType:e.actionType,actionUser:e.actionUser,timestamp:e.timestamp,targetAnnotationId:e.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(e),displayBodyMessage:this.getNotificationBodyMessage(e),forYou:I,isUnread:T,metadata:r},B?.notificationSource==="comment"&&B?.targetAnnotationId){let z=this.commentService?.getAnnotationById(B.targetAnnotationId);z||s?.notificationSourceData&&(z=s?.notificationSourceData),z||t?.annotationData&&(z=t.annotationData),z&&(B.notificationSourceData=this.commentService?.getCommentAnnotationForClient(z))}return t?.targetAnnotationData?.isCommentResolverUsed&&(B.isCommentResolverUsed=t?.targetAnnotationData?.isCommentResolverUsed),B}return}catch(c){this.loggingService.catch("Error in NotificationService getClientNotificationObject: ",c);return}}getNotificationsForYou$(){return this.notificationsForYou$.asObservable()}getNotificationsByDocumentId$(){return this.notificationsByDocumentIdMap$.asObservable().pipe(de(e=>e?Object.keys(e??{}).map(t=>{let r=e[t].notifications||[],a=r.filter(c=>c.isUnread).length,s=r.length>0&&r[0]?.timestamp||0;return{documentId:t,notifications:e[t]?.notifications,unreadNotificationsCount:a,latestNotificationTimestamp:s,documentMetadata:e[t]?.documentMetadata}}).filter(t=>t.notifications?.length>0).sort((t,r)=>r.latestNotificationTimestamp-t.latestNotificationTimestamp):null))}getAllNotifications$(){return this.getNotificationsByDocumentId$().pipe(de(e=>{let t=null;return e?(t=[],e.forEach(r=>{r.notifications.forEach(a=>{t?.push(a)})}),t?.sort((r,a)=>a.timestamp-r.timestamp)):null}))}processNotificationData(e){try{let t=e?.annotationData?.metadata,r=this.docService.getOrganizationConfig()?.organizationId;e.metadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(t?.documentId)||{})),e.metadata||(e.metadata={},this.loggingService.catch("Warning in NotificationService updateNotificationDatabase: ","Document metadata not found")),delete e.metadata.locations,e.metadata.documentMetadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(t?.documentId)||{})),e?.metadata?.documentMetadata?.clientDocumentId&&e?.metadata?.documentMetadata?.documentId&&(e.metadata.documentMetadata.documentId=e?.metadata?.documentMetadata?.clientDocumentId),delete e.metadata.documentMetadata.locations,e.metadata.organizationMetadata=JSON.parse(JSON.stringify(r?this.docService.getOrganizationMetadata(r)||{}:{})),e?.metadata?.organizationMetadata?.clientOrganizationId&&e?.metadata?.organizationMetadata?.organizationId&&(e.metadata.organizationMetadata.organizationId=e?.metadata?.organizationMetadata?.clientOrganizationId);let a=this.configService.getApiKey();e.metadata.apiKey=a,e.platform=this.configService.getSF()?"sf":"sdk",e.actionUser=this.authService.getUser();let s=t?.documentId?new Sm({apiKey:a,documentId:t.documentId,organizationId:t?.organizationId}):this.docService.getDocumentPaths();e?.actionUser?.organizationId&&(e.metadata.organizationId=s?.organizationId||e.actionUser.organizationId,e.metadata.clientOrganizationId=s?.clientOrganizationId||e.actionUser.clientOrganizationId);let c=this.docService.getLocation();c&&(e.location=c?.location,e.locationId=c?.locationId),this.loggingService.log(`[NOTIFICATION] ${e?.notificationSource} ${e?.actionType}`,e);let p=this.commonDbService.getServerTimestamp(),g=this.notificationUtilsService.formatNotification(e,p);return JSON.parse(JSON.stringify(g))}catch(t){return this.loggingService.catch("Error in NotificationService processNotificationData: ",t),null}}updateNotificationDatabase(e){try{let t=Ti(this.notificationsDb),r=this.processNotificationData(e);SM(t,JSON.parse(JSON.stringify(r)))}catch(t){this.loggingService.catch("Error in NotificationService updateNotificationDatabase: ",t)}}getRawNotifications$(){return this.notifications$.asObservable()}getProcessedNotifications$(){return this.processedNotifications$.asObservable()}getNotifications$(e){return this.authService.getUser$().pipe(he(t=>t?t.organizationId?this.getAllNotifications$().pipe(he(r=>this.notificationsForYou$.pipe(de(a=>{if(r||a){let s=new Map;return(!e?.type||["all","documents"].includes(e.type))&&(r||[]).forEach(c=>{c.id&&s.set(c.id,c)}),(!e?.type||["all","forYou"].includes(e.type))&&(a||[]).forEach(c=>{c.id&&!s.has(c.id)&&s.set(c.id,c)}),Array.from(s.values()).sort((c,p)=>(p.timestamp||0)-(c.timestamp||0))}else return null})))):this.notificationsByIdMap$.asObservable().pipe(de(r=>Array.from(r.values())),de(r=>r.sort((a,s)=>s.timestamp-a.timestamp)),Ku()):le(null)),Ct(Xt))}getRawNotificationById(e){try{return this.rawNotificationsByIdMap$.getValue()?.get(e)}catch(t){this.loggingService.catch("Error in NotificationService getRawNotificationById: ",t);return}}setNotificationViews(e){try{this.notificationViews$.next(e),this.setNotificationsByIdMap()}catch(t){this.loggingService.catch("Error in NotificationService setNotificationViews: ",t)}}getNotificationHeadlineMessage(e){try{let t=this.authService.getUser();if(e?.displayHeadlineMessageTemplate&&e?.displayHeadlineMessageTemplateData){let r=e.displayHeadlineMessageTemplate,a=e.displayHeadlineMessageTemplateData,s=/\{(\w+)\}/g,c=r.replace(s,(p,g)=>(g==="actionUser"||g==="recipientUser")&&a[g]?t?.email&&a[g].email===t?.email||t?.userId&&a[g]?.userId===t?.userId?"You":a[g].name||a[g].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':a[g]?a[g]:p);return this.domService.sanitizeHtml(c)}return this.domService.sanitizeHtml(e.displayHeadlineMessageTemplate||"")}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationHeadlineMessage: ",t),""}}getNotificationBodyMessage(e){try{if(e?.displayBodyMessageTemplate&&e?.displayBodyMessageTemplateData){let t=e?.displayBodyMessageTemplate;return e?.displayBodyMessageTemplateData&&e?.displayBodyMessageTemplateData?.users?.forEach(r=>{if(r?.userId){let a=this.usersService.getUserById(r?.userId);t=t?.replaceAll(`{{${r.userId}}}`,a?.name||a?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>'),t=t?.replaceAll(`@User ${r.userId}`,a?.name||a?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>')}}),this.domService.sanitizeHtml(t)}return this.domService.sanitizeHtml(e.displayBodyMessage||"")}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationBodyMessage: ",t),""}}setHistoryPanelVisibility(e,t=!1,r=!1){try{e?document.querySelector(U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(e):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(e),e?this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}toggleHistoryPanelVisibility(e=!1,t=!1){try{this.historyPanelVisible$.value?this.historyPanelVisible$.next(!this.historyPanelVisible$.value):document.querySelector(U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(e){return Q(this,null,function*(){try{let t=JSON.parse(JSON.stringify(this.getUserNotificationsFromServer()??[]));if(e?.length){for(let c=0;c<e.length;c+=50){let g=e.slice(c,c+50).filter(T=>T?.id),f=g.map(T=>this.setNotificationAsRead({notification:T,userNotifications:JSON.parse(JSON.stringify(t))})),I=yield Promise.all(f);g.forEach((T,B)=>{let z=I[B];if(!z.some(J=>J.notificationId===T.id))t=t.filter(J=>J.notificationId!==T.id);else{let J=t.find(ve=>ve.notificationId===T.id),ne=z.find(ve=>ve.notificationId===T.id);J&&ne?.views&&(J.views=ne.views)}})}let a=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));e.forEach(c=>{let p=c.metadata?.documentId;if(p&&a?.[p]){let g=a?.[p]?.notifications||[],f=g.find(I=>I.id===c.id);f&&(f.isUnread=!1),a[p].notifications=g}}),this.notificationsByDocumentIdMap$.next(a),!hi(t,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(t)}}catch(t){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",t)}})}setAllNotificationsAsRead(e){return Q(this,null,function*(){try{if(e?.tabId==="for-you"){let t=this.notificationsForYou$.value||[];this.setNotificationsAsRead(t)}else this.getNotifications$().pipe(rt(1)).subscribe(t=>{t&&this.setNotificationsAsRead(t)})}catch(t){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",t)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(de(e=>e?.filter(r=>r?.isUnread)?.length??null),he(e=>this.getNotifications$().pipe(de(t=>{let r=t?.filter(a=>a?.isUnread)?.length??null;return{forYou:e,all:r}}))))}catch(e){return this.loggingService.catch("Error in NotificationService getUnreadNotificationsCount$: ",e),le({forYou:null,all:null})}}setNotificationAsRead(r){return Q(this,arguments,function*({notification:e,userNotifications:t}){try{let a=this.authService.getUser();if(a&&e?.id){let s=Tt(a?.userId),{metadata:c}=e;if(c){let{apiKey:p,organizationId:g,documentId:f}=c;if(p&&g&&f&&s){let I=yield this.commonDbService.getData({feature:"docNotification",properties:{id:e.id,organizationId:g,documentId:f,apiKey:p}});I?.notificationId&&(I?.views?.[s]||(I.views||(I.views={}),I.views[s]={timestamp:Date.now()},this.commonDbService.updateData({feature:"docNotificationViews",properties:{id:e.id,organizationId:g,documentId:f,apiKey:p},data:I})));let T=yield this.commonDbService.getData({feature:"userNotification",properties:{id:e.id,userId:s,documentId:f,organizationId:g}});if(T?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:e.id,userId:s,documentId:f,organizationId:g}}),t=t.filter(B=>B.notificationId!==e.id);else if(!T?.views?.[s]){T.views||(T.views={}),T.views[s]={timestamp:Date.now()};let B=t.find(z=>z.notificationId===e.id);B&&(B.views=T.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:e.id,userId:s,documentId:f,organizationId:g},data:T})}}}}}return t}catch(a){return this.loggingService.catch("Error in NotificationService setNotificationAsRead: ",a),t}})}setMaxDays(e){try{e>0?this.maxNotificationDays$.next(e):this.maxNotificationDays$.next(15)}catch(t){this.loggingService.catch("Error in NotificationService setMaxDays: ",t)}}setTabConfig(e){try{e&&this.tabConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setTabConfig: ",t)}}getTabConfig$(){return this.tabConfig$.asObservable()}getTabConfig(){return this.tabConfig$.value}enableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!0)}disableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!1)}getReadNotificationsOnForYouTab$(){return this.readNotificationsOnForYouTab$.asObservable()}getReadNotificationsOnForYouTab(){return this.readNotificationsOnForYouTab$.value}enableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!0)return;this.currentDocumentOnly$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableCurrentDocumentOnly: ",e)}}disableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!1)return;this.currentDocumentOnly$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableCurrentDocumentOnly: ",e)}}getCurrentDocumentOnly$(){return this.currentDocumentOnly$.asObservable()}getCurrentDocumentOnly(){return this.currentDocumentOnly$.value}markNotificationAsReadById(e){return Q(this,null,function*(){try{this.getNotifications$().pipe(rt(1)).subscribe(t=>{if(t){let r=t.filter(a=>a.id===e);this.setNotificationsAsRead(r)}})}catch(t){this.loggingService.catch("Error in NotificationService markNotificationAsReadById: ",t)}})}getAllowedDocumentMetadataByDocumentId(e){try{return this.allowedDocumentMetadataMap$.value?.[e]||null}catch(t){return this.loggingService.catch("Error in NotificationService getAllowedDocumentMetadataByDocumentId: ",t),null}}setSettingsConfig(e){try{this.enableSettings$.value&&this.settingsConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsConfig: ",t)}}setSettingsConfigWithDB(e){try{this.enableSettings$.value&&(this.settingsConfig$.next(e),this.updateSettingsConfigToDb())}catch(t){this.loggingService.catch("Error in NotificationService setSettingsConfigWithDB: ",t)}}getSettingsConfig$(){return this.settingsConfig$.asObservable()}getSettingsConfig(){return this.settingsConfig$.value}setMuteAllNotifications(){try{this.muteAllNotifications$.value!==!0&&this.muteAllNotifications$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService setSettingsMuteAll: ",e)}}getMuteAllNotifications$(){return this.muteAllNotifications$.asObservable()}getMuteAllNotifications(){return this.muteAllNotifications$.value}enableSettings(){try{this.enableSettings$.value!==!0&&this.enableSettings$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableSettings: ",e)}}enableSelfNotifications(){try{this.selfNotifications$.value!==!0&&this.selfNotifications$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableSelfNotifications: ",e)}}disableSelfNotifications(){try{this.selfNotifications$.value!==!1&&this.selfNotifications$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableSelfNotifications: ",e)}}disableSettings(){try{this.enableSettings$.value!==!1&&this.enableSettings$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableSettings: ",e)}}getEnableSettings$(){return this.enableSettings$.asObservable()}getEnableSettings(){return this.enableSettings$.value}setSettingsInitialConfig(e){try{let t=!1;if(e.forEach(r=>{["email","inbox"].includes(r.id)&&(t=!r.values?.every(a=>["ALL","NONE","MINE"].includes(a.id)))}),t){this.loggingService.catch("Invalid config values for email or inbox, It should have only ALL, NONE, MINE values");return}this.settingsInitialConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsInitialConfig: ",t)}}getSettingsInitialConfig$(){return this.settingsInitialConfig$.asObservable()}getSettingsInitialConfig(){return this.settingsInitialConfig$.value}updateSettingsConfigToDb(e){return Q(this,null,function*(){try{let t=Tt(this.authService.getUser()?.userId??""),r=this.docService.getDocumentPaths(),a={apiKey:this.configService.getApiKey(),organizationId:r?.organizationId,documentId:r?.documentId,clientOrganizationId:r?.clientOrganizationId,clientDocumentId:r?.clientDocumentId,userId:t,clientUserId:this.authService.getUser()?.userId};t&&r?.documentId&&this.getEnableSettings()&&this.enableSettings$.value&&(yield this.commonDbService.updateData({feature:"userConfig",properties:{documentId:r.documentId,userId:t},data:{id:r.documentId,notificationsConfig:e||this.settingsConfig$.getValue(),metadata:a}}))}catch(t){this.loggingService.catch("Error in NotificationService updateSettingsConfigToDb: ",t)}})}openNotificationsPanel(){try{this.notificationsPanelVisible$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService openNotificationsPanel: ",e)}}closeNotificationsPanel(){try{this.notificationsPanelVisible$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService closeNotificationsPanel: ",e)}}getNotificationsPanelVisible$(){return this.notificationsPanelVisible$.asObservable()}getNotificationsPanelVisible(){return this.notificationsPanelVisible$.value}};o.\u0275fac=function(t){return new(t||o)(ee(Ri),ee(Qe),ee(je),ee(Ft),ee(un),ee(Im),ee(ru),ee(nl),ee(In),ee(ot),ee(Be),ee(En),ee(_),ee(x9),ee(Ln),ee(Do),ee(ss),ee(ni))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wo=(()=>{let o=class o{constructor(e){this.loggingService=e,this._customStatusMap=new Ce(U.CommentAnnotationStatusMap),this._customPriorityMap=new Ce(U.CommentAnnotationPriorityMap),this._customCategoryMap=new Ce(U.CommentCategoryMap);try{let t=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP);t&&this._customPriorityMap.next(JSON.parse(t));let r=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP);r&&this._customStatusMap.next(JSON.parse(r));let a=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_CATEGORY_MAP);a&&this._customCategoryMap.next(JSON.parse(a))}catch(t){this.loggingService.catch("Error in CustomFilterService constructor: ",t)}}setCustomStatusFilters(e){try{if(e.length<2){this._customStatusMap.next(U.CommentAnnotationStatusMap),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP,JSON.stringify(U.CommentAnnotationStatusMap)),this.loggingService.catch("Custom status filters must have at least 2 filters");return}let t={};e.forEach(r=>{t[r.id]=r,r.type||(r.type="ongoing")}),this._customStatusMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomStatusFilters: ",t)}}setCustomPriorityFilters(e){try{if(e.length<2){this._customPriorityMap.next(U.CommentAnnotationPriorityMap),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP,JSON.stringify(U.CommentAnnotationPriorityMap)),this.loggingService.catch("Custom priority filters must have at least 2 filters");return}let t={};e.forEach(r=>{t[r.id]=r}),this._customPriorityMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomPriorityFilters: ",t)}}setCustomCategories(e){try{let t={};e.forEach(r=>{t[r.id]=r}),this._customCategoryMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_CATEGORY_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomCategories: ",t)}}get customStatusMap$(){return this._customStatusMap.asObservable()}get customPriorityMap$(){return this._customPriorityMap.asObservable()}get customCategoryMap$(){return this._customCategoryMap.asObservable()}get defaultStatus(){try{let t=Object.entries(this._customStatusMap.value).find(([r,a])=>a.type==="default");if(t)return t[1]}catch(e){this.loggingService.catch("Error in CustomFilterService defaultStatus: ",e)}return U.CommentAnnotationStatusMap.OPEN}get resolvedStatus(){try{let t=Object.entries(this._customStatusMap.value).find(([r,a])=>a.type==="terminal");if(t)return t[1]}catch(e){this.loggingService.catch("Error in CustomFilterService resolvedStatus: ",e)}return U.CommentAnnotationStatusMap.OPEN}get ongoingStatuses(){try{let t=Object.entries(this._customStatusMap.value).filter(([r,a])=>a.type==="ongoing");if(t)return t.map(r=>r[1])}catch(e){this.loggingService.catch("Error in CustomFilterService ongoingStatuses: ",e)}return[U.CommentAnnotationStatusMap.IN_PROGRESS]}convertLegacyAnnotationStatus(e){try{if(typeof e.status=="string"||e.status===void 0){let t=Object.entries(this._customStatusMap.value),r=t.find(([a,s])=>s.type==="default");switch(e.status){case"open":r&&(e.status=r[1]);break;case"inProgress":let a=t.find(([c,p])=>p.type==="ongoing");a&&(e.status=a[1]);break;case"resolved":let s=t.find(([c,p])=>p.type==="terminal");s&&(e.status=s[1]);break;default:r&&(e.status=r[1]);break}}return e}catch(t){return this.loggingService.catch("Error in CustomFilterService convertLegacyAnnotation: ",t),e}}convertLegacyPriority(e){try{typeof e.priority=="string"&&(e.priority=U.CommentAnnotationPriorityMap[e.priority])}catch(t){this.loggingService.catch("Error in CustomFilterService convertLegacyPriority: ",t)}return e}convertLegacyCategory(e){try{if(e.commentCategories===void 0||e.commentCategories===null||!Array.isArray(e.commentCategories)||e.commentCategories.length===0)return e;typeof e.commentCategories[0]=="string"&&(e.commentCategories=e.commentCategories.map(t=>U.CommentCategoryMap[t]))}catch(t){this.loggingService.catch("Error in CustomFilterService convertLegacyCategory: ",t)}return e}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Sd=(()=>{let o=class o{constructor(e,t,r){this.domService=e,this.loggingService=t,this.sanitizer=r,this.emojis={};try{this.loggingService.log("%c[WB] Creating CLASS: EmojiService","color: blue;"),Object.keys(o.Icons).forEach(a=>{let s=o.Icons[a];this.emojis[a]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeSvg(s))}),Object.keys(o.GIF_PATHS).forEach(a=>{let s=`<img src="${o.GIF_PATHS[a]}" alt="${a}" />`;this.emojis[a]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(s))})}catch(a){this.loggingService.catch("Error in EmojiService constructor: ",a)}}getEmoji(e){try{return this.emojis[e]}catch{return""}}getEmojiFromIconUrl(e){try{return this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(`<img src="${e}" alt="emoji" />`))}catch{return""}}getEmojiFromIconEmoji(e,t){try{let r=`<span class="velt-emoji-icon velt-emoji-icon--emoji">${e}</span>`;return t&&(r=`<span class="velt-emoji-icon velt-emoji-icon--emoji" emoji-id=${t}>${e}</span>`),this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(r))}catch{return""}}setEmojiList(e){try{this.emojis={},Object.keys(e).forEach(t=>{let r=e[t];if(r.svg)this.emojis[t]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeSvg(r.svg));else if(r.url){let a=`<img src="${r.url}" alt="${t}" />`;this.emojis[t]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(a))}else r.emoji&&(this.emojis[t]=this.getEmojiFromIconEmoji(this.domService.sanitizeHtml(r.emoji)))})}catch(t){this.loggingService.catch("Error in EmojiService setEmojiList: ",t)}}};o.Icons={RAISED_HANDS:`<svg width="58" height="57" viewBox="0 0 58 57" fill="none" xmlns="http://www.w3.org/2000/svg">
207
+ `+Da),wd&&f9([Oe,Fe,ao],dl=>{Da=XI(Da,dl," ")}),ye&&Au?ye.createHTML(Da):Da},o.setConfig=function(){let cn=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Gf(cn),jf=!0},o.clearConfig=function(){Tc=null,jf=!1},o.isValidAttribute=function(cn,Ue,Mt){Tc||Gf({});let Jt=fr(cn),Co=fr(Ue);return Wf(Jt,Co,Mt)},o.addHook=function(cn,Ue){typeof Ue=="function"&&ZI(fe[cn],Ue)},o.removeHook=function(cn,Ue){if(Ue!==void 0){let Mt=KNe(fe[cn],Ue);return Mt===-1?void 0:ZNe(fe[cn],Mt,1)[0]}return Epe(fe[cn])},o.removeHooks=function(cn){fe[cn]=[]},o.removeAllHooks=function(){fe=Ape()},o}var t2=Rpe();var Npe={ADD_TAGS:["velt-skeleton-loader"],ADD_ATTR:["border-radius","target"]},Be=(()=>{let o=class o{constructor(e,t,r,a){this.analyticsService=e,this.rendererFactory2=t,this.loggingService=r,this.sanitizer=a,this.isVideoEditorHandlingDelete=!1,this.pageScrollHeight=0,this.enableRectSelectionSubject$=new Ce(!1),this.enableRectSelection$=this.enableRectSelectionSubject$.asObservable(),this.scrollableElementsIds$=new Ce([]),this.mousedown=!1,this.windowMouseDown$=new Xe,this.windowPointerMove$=new Ce(null),this.windowPointerUp$=new Ce(null),this.documentSelectionChange$=new Ce(null),this.windowClick$=new Ce(null),this.windowScroll$=new Ce(null),this.windowResize$=new Ce(null),this.windowKeyupBackspace$=new Ce(null),this.windowKeyupDelete$=new Ce(null),this.windowKeyupEsc$=new Ce(null),this.windowPopState$=new Ce(null),this.documentClick$=new Ce(null),this.documentClickSubject$=new Xe,this.documentFocus$=new Ce(null),this.windowKeydownShift$=new Ce(null),this.windowKeyupShift$=new Ce(null),this.mutation$=new Ce(null),this.childListMutation$=new Ce(null),this.networkStatus$=new Ce(!1),this.xpathCache=new Map,this.xpathCacheId=new Map,this.selectedAnnotationsMap$=new Ce({}),this.selectedAnnotationsLocationMap$=new Ce({}),this.recordingInProgress$=new Ce({}),this.deleteAnnotations$=new Ce([]),this.pinHighlighterClass$=new Ce(null),this.dialogOpenedInSidebar$=new Ce(!1),this.textHighlighterClass$=new Ce(null),this.commentPinHighlighter$=new Ce(!1),this.deviceInfo$=new Ce(new Yn),this.customCss$=new Ce(null),this.mutationObserver=null,this.previousMousePosition={pageX:0,pageY:0,clientX:0,clientY:0},this.currentMousePosition={pageX:0,pageY:0,clientX:0,clientY:0,element:{xpath:"",topPercentage:0,leftPercentage:0}},this.nodeMap={},this.unlistenElementScroll={},this.tabId=null,this.dynamicIdPatterns=[/^yui_[a-z0-9_]+$/i],this.excludeClassList=["show-pin-cursor"],this.filterSnippylyNodes=s=>{try{let c=[];return s.forEach(p=>{if(!Ki(p))if(p instanceof HTMLElement){if(p.className.includes("cdk-overlay-container")||p.className.includes("cdk-overlay-connected-position-bounding-box"))return;if(p.className.includes("cdk-overlay")){let g=!1;p.childNodes.forEach(f=>{Ki(f)&&(g=!0)}),g||c.push(p)}else c.push(p)}else c.push(p)}),c}catch(c){return this.loggingService.catch("Error in DomService filterSnippylyNodes: ",c),[]}},this.loggingService.log("%c[WB] Creating CLASS: DomService","color: blue;");try{this.analyticsService.setDomService(this),this.renderer=this.rendererFactory2.createRenderer(null,null);let s=this.calculateScreenSize();this.currentScreenSize$=new Ce(s),this.currentMousePosition$=new Ce(this.currentMousePosition),this.detectNetworkStatusChange(),this.getScrollableElementsIds$().pipe(Oi(),Qt(([c,p])=>{try{let g=p.filter(I=>!c.includes(I)),f=c.filter(I=>!p.includes(I));f.length&&f.map(T=>document.getElementById(T)).filter(T=>T).forEach(T=>{this.unlistenElementScroll&&this.unlistenElementScroll[T.id]&&this.unlistenElementScroll[T.id]()}),g.length&&g.map(T=>document.getElementById(T)).filter(T=>T).forEach(T=>{this.unlistenElementScroll[T.id]=this.renderer.listen(T,"scroll",B=>{let z=this.calculateScreenSize();this.currentScreenSize$.next(z)})})}catch(g){this.loggingService.catch("Error in DomService getScrollableElementsIds subscription: ",g)}})).subscribe(()=>{},c=>{this.loggingService.catch("Error in DomService getScrollableElementsIds subscription: ",c)}),this.getSelectedAnnotationsMap$().subscribe(c=>{Object.keys(c||{})?.length?oce("snippylyUserScalableNo","viewport","width=device-width, user-scalable=no"):rce("snippylyUserScalableNo")},c=>{this.loggingService.catch("Error in DomService getSelectedAnnotationsMap$ subscription: ",c)})}catch(s){this.loggingService.catch("Error in DomService constructor: ",s)}}setDocService(e){try{this.docService=e,this.subscribeToDomEvents()}catch(t){this.loggingService.catch("Error in DomService setDocService: ",t)}}setDynamicIdPatterns(e){try{let t=e.map(r=>typeof r=="string"?new RegExp(r):r).filter(Boolean);t.length&&(this.dynamicIdPatterns=t)}catch(t){this.loggingService.catch("Error in DomService setDynamicIdPatterns: ",t)}}isLikelyDynamicId(e){try{return e?this.dynamicIdPatterns.some(t=>t.test(e)):!1}catch{return!1}}getStableAttributes(e){try{let t={};if(!e.getAttributeNames)return t;let r=new Set(["id","class","style"]);return e.getAttributeNames().forEach(s=>{if(r.has(s)||s.includes("snippyly")||s.includes("velt"))return;let c=e.getAttribute(s);c&&c.length<=256&&(t[s]=c)}),t}catch{return{}}}buildStableElementSelector(e,t){try{if(Object.keys(t).length===0)return;let a=[e.tagName?.toLowerCase()],s=["data-","aria-","role","name","title","type"];return Object.keys(t).sort((p,g)=>{let f=s.findIndex(T=>p.startsWith(T)),I=s.findIndex(T=>g.startsWith(T));return(f===-1?99:f)-(I===-1?99:I)}).slice(0,4).forEach(p=>{let g=CSS.escape(t[p]);a.push(`[${p}="${g}"]`)}),a.join("")}catch{return}}getVisibleText(e,t=400){try{let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a="",s,c=0;for(;(s=r.nextNode())&&a.length<t;){let p=(s.textContent||"").replace(/\s+/g," ").trim();if(p&&(a+=(a?" ":"")+p),c++,c>100)break}return a.slice(0,t)}catch{return""}}hashText(e){try{return Wle(e)}catch{return}}generateRobustXPath(e,t){try{let r=t?.maxDepth||10,a=t?.useAbsolutePath||!1,s=[],c=e,p=0;for(;c&&c!==document.documentElement&&p<r;){let T=this.buildRobustXPathSegment(c);if(T&&(s.unshift(T),this.isStrongAnchorSegment(T)))break;c=c.parentElement,p++}if(s.length===0)return;let f=(a?"/":"//")+s.join("/");return s.some(T=>T.includes("[@")||T.includes("[contains(@class"))?f:void 0}catch{return}}buildRobustXPathSegment(e){try{let t=e.tagName.toLowerCase(),r=e.id;if(r&&!this.isLikelyDynamicId(r)&&document.querySelectorAll(`[id="${CSS.escape(r)}"]`).length===1)return`*[@id=${this.escapeXPathValue(r)}]`;let a=["data-region","data-instanceid","data-action","data-key","data-block","data-activityid"];for(let T of a){let B=e.getAttribute(T);if(B)return`${t}[@${T}=${this.escapeXPathValue(B)}]`}let s=Array.from(e.attributes).filter(T=>T.name.startsWith("data-")&&!T.name.includes("snippyly")&&!T.name.includes("velt")&&T.value.length<100).sort((T,B)=>T.value.length-B.value.length);if(s.length>0){let T=s[0];return`${t}[@${T.name}=${this.escapeXPathValue(T.value)}]`}let c=e.getAttribute("role");if(c)return`${t}[@role=${this.escapeXPathValue(c)}]`;let p=e.getAttribute("aria-label");if(p&&p.length<50)return`${t}[@aria-label=${this.escapeXPathValue(p)}]`;let g=e.getAttribute("name");if(g)return`${t}[@name=${this.escapeXPathValue(g)}]`;let f=e.getAttribute("type");if(f)return`${t}[@type=${this.escapeXPathValue(f)}]`;let I=Array.from(e.classList||[]).filter(T=>T.length>0&&T.length<40&&!T.includes("yui")&&!T.includes("velt")&&!T.includes("snippyly")&&!this.excludeClassList.includes(T)).slice(0,2);if(I.length>0){let T=I.map(B=>`contains(@class, ${this.escapeXPathValue(B)})`).join(" and ");return`${t}[${T}]`}if(e.parentElement){let T=Array.from(e.parentElement.children).filter(B=>B.tagName===e.tagName);if(T.length>1){let B=T.indexOf(e)+1;return`${t}[${B}]`}}return t}catch{return}}isStrongAnchorSegment(e){try{return!!(e.includes("[@id=")||["main","navigation","banner","contentinfo","complementary","search"].some(a=>e.includes(`[@role='${a}']`))||["data-region","data-instanceid","data-activityid"].some(a=>e.includes(`[@${a}=`)))}catch{return!1}}escapeXPathValue(e,t=!0){try{return e.includes("'")?e.includes('"')?`concat(${e.split("'").map(s=>`'${s}'`).join(`,"'",`)})`:t?`"${e}"`:e:t?`'${e}'`:e}catch{try{return`concat(${e.split("'").map(c=>`'${c}'`).join(`,"'",`)})`}catch{return t?`'${e}'`:e}}}getElementFromRobustXPath(e){try{return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch{return null}}getAllElementsFromRobustXPath(e){try{let t=document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),r=[];for(let a=0;a<t.snapshotLength;a++){let s=t.snapshotItem(a);s instanceof Element&&r.push(s)}return r}catch{return[]}}generateAnchorRecord(e,t){try{let r=this.generateAnchorRecordForElement(e,t),a=null;if(e.parentElement&&e.parentElement instanceof HTMLElement&&Pi(e.parentElement)&&e.parentElement!==document.body&&(a=e.parentElement),r&&a){let s=this.generateAnchorRecordForElement(a,t);s&&(r.parent=s)}return r}catch(r){return this.loggingService.catch("Error in DomService generateAnchorRecord: ",r),null}}generateAnchorRecordForElement(e,t){try{if(!e)return null;let r=e,a=r.tagName?.toUpperCase();if(!a)return null;let s=r.id&&!this.isLikelyDynamicId(r.id)?r.id:void 0,c=this.getStableAttributes(r),p=this.buildStableElementSelector(r,c),g=this.getVisibleText(r),f=this.hashText(g||""),I=this.generateRobustXPath(r),T=this.getXPath(r),B=this.getXPath(r,!0),z=this.getXPath(r,!0,!0);return{version:"1.0",id:s,tagName:a,elementSelector:p,robustXPath:I||void 0,xPath:T||void 0,fXPath:B||void 0,cfXPath:z||void 0,contentHash:f?{value:f,algorithm:"md5",source:"textContent"}:void 0,createdAt:Date.now()}}catch(r){return this.loggingService.catch("Error in DomService generateAnchorRecordForElement: ",r),null}}resolveAnchorRecord(e){try{let t=[],r=null,a=(f,I,T=0)=>{let B=[],z=T;if(B.push({method:I,score:T}),e.tagName&&f.tagName?.toUpperCase()===e.tagName&&(z+=10,B.push({method:"tagName-match",score:10})),e.contentHash?.value){let G=this.getVisibleText(f);this.hashText(G)===e.contentHash.value&&(z+=30,B.push({method:"contentHash-match",score:30}))}t.push({el:f,score:z,by:I,scoreBreakdown:B})};if(e.id){let f=document.querySelectorAll(`#${CSS.escape(e.id)}`);if(f.length===1)return{element:f[0],matchedBy:"id",score:90};f.length>1&&f.forEach(I=>a(I,"id-duplicate",70))}if(e.elementSelector){let f=document.querySelectorAll(e.elementSelector);if(f.length===1)return{element:f[0],matchedBy:"element-selector",score:80};f.forEach(I=>a(I,"element-selector-duplicate",60))}e.robustXPath&&this.getAllElementsFromRobustXPath(e.robustXPath).slice(0,20).forEach(B=>a(B,"robustXPath",50)),e?.parent&&(r=this.resolveAnchorRecord(e.parent),r.element&&r.element.querySelectorAll(e.tagName?.toLowerCase()||"*").forEach(I=>a(I,"parent+tag",40)));let s=(f,I,T)=>{if(!f)return;let B=this.getElementFromXPath(f);B&&a(B,I||"xpath",T||30)};if(s(e.xPath,"xPath",30),s(e.cfXPath,"cfXPath",30),s(e.fXPath,"fXPath",30),e.contentHash?.value&&t.length===0){let I=T=>{let B=0;for(let z=0;z<T.length&&B<400;z++){let G=T[z];if(B++,!this.isElementVisible(G))continue;let J=this.getVisibleText(G),ne=this.hashText(J);ne&&ne===e.contentHash?.value&&a(G,"contentHash",15)}};if(r?.element&&r?.element instanceof Element){let T=r?.element?.querySelectorAll("*");I(T)}}if(!t.length)return{element:null};t.sort((f,I)=>I.score-f.score);let c=t[0].score,p=t.filter(f=>f.score===c);if(p.length>1){let f=[{path:e.xPath,label:"xPath"},{path:e.cfXPath,label:"cfXPath"},{path:e.fXPath,label:"fXPath"}];for(let I of f)if(I.path){let T=this.getElementFromXPath(I.path);if(T){let B=p.find(z=>z.el===T);if(B)return{element:B.el,matchedBy:`${B.by}+position`,score:B.score,scoreBreakdown:B.scoreBreakdown}}}}let g=t[0];return{element:g.el,matchedBy:g.by,score:g.score,scoreBreakdown:g.scoreBreakdown}}catch(t){return this.loggingService.catch("Error in DomService resolveAnchorRecord: ",t),{element:null}}}subscribeToDomEvents(){try{this.docService?.getDocumentPaths$().pipe(de(e=>{e?(this.onWindowResize(),this.onWindowScroll(),this.onPointerDown(),this.onWindowClick(),this.onWindowKeyupBackspace(),this.onWindowKeyupDelete(),this.onWindowKeyupEsc(),this.onWindowPopState(),this.onWindowKeydownShift(),this.onWindowKeyupShift(),this.addPointerMoveListener(),this.addPointerUpListener(),this.addSelectionChangeListener(),this.onDocumentFocus()):(this.unsubscribeFromWindowResize(),this.unsubscribeFromWindowScroll(),this.unsubscribeFromPointerDown(),this.unsubscribeFromWindowClick(),this.unsubscribeFromWindowKeyupBackspace(),this.unsubscribeFromWindowKeyupDelete(),this.unsubscribeFromWindowKeyupEsc(),this.unsubscribeFromWindowPopState(),this.unsubscribeFromWindowKeydownShift(),this.unsubscribeFromWindowKeyupShift(),this.unsubscribeFromPointerMoveListener(),this.unsubscribeFromPointerUpListener(),this.unsubscribeFromSelectionChangeListener(),this.unsubscribeFromDocumentFocus(),this.unsetMutationObserver())})).subscribe(),this.onDocumentClick()}catch(e){this.loggingService.catch("Error in DomService subscribeToDomEvents: ",e)}}setScrollableElementsIds(e){try{e&&e.length&&this.scrollableElementsIds$.next(Array.from(new Set(e)))}catch(t){this.loggingService.catch("Error in DomService setScrollableElementsIds: ",t)}}getScrollableElementsIds$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getScrollableElementsIds$","color: green;"),this.scrollableElementsIds$.asObservable()}removeScrollableElementsIds(){this.scrollableElementsIds$.next([])}setMutationObserver(e){try{this.mutationObserver||(this.loggingService.log("%c[WB] Calling DomService FUNCTION: setMutationObserver","color: green;"),this.loggingService.log("%c[WB] setMutationObserver from: "+e,"color: green;"),this.mutationObserver=new MutationObserver(t=>{try{if(t?.find(a=>a?.attributeName===U.VELT_IGNORE_CHANGE_DETECTION))return;let r=t.filter(a=>a.type==="childList").filter(a=>{let s=a.target;return a.removedNodes.forEach(c=>{let p=c;if(typeof p.getAttribute=="function"){let g=p.getAttribute(U.ATTRIBUTES.VELT_ELEMENT_CACHE_ID);if(g!==null&&g!==""){let f=this.xpathCacheId.get(g);f!==void 0&&(this.xpathCacheId.delete(g),this.xpathCache.delete(f))}}}),Ki(s)?!1:!!(this.filterSnippylyNodes(a.addedNodes).length||this.filterSnippylyNodes(a.removedNodes).length)});this.childListMutation$.next(r),r.push(...t.filter(a=>a.type==="attributes").filter(a=>!Ki(a.target)).filter(a=>this.filterSnippylyNodes([a.target]).length).filter(a=>{if(a){let s=a.target;return s?.classList?.contains("snippyly-sidebar-panel")?!1:s?!s.getAttribute(U.VELT_IGNORE_CHANGE_DETECTION):!0}return!0})),r=r.filter(a=>{let s=!0;return Object.keys(U.INGNORE_MUTATION_OBSERVER_CHANGE_TAGS).forEach(c=>{a.target?.closest(c)&&(s=!1)}),s}),r=r.filter(a=>a.target&&Pi(a.target)),r.length&&this.mutation$.next(r)}catch(r){this.loggingService.catch("Error in DomService change detection: ",r)}}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0}))}catch(t){this.loggingService.catch("Error in DomService change detection: ",t)}}unsetMutationObserver(){try{this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}catch(e){this.loggingService.catch("Error in DomService unsetMutationObserver: ",e)}}detectNetworkStatusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: detectNetworkStatusChange","color: green;");try{Uo(vi(window,"offline").pipe(de(()=>!1)),vi(window,"online").pipe(de(()=>!0)),new $t(e=>{e.next(navigator.onLine),e.complete()})).subscribe(e=>{this.networkStatus$.next(e)})}catch(e){this.loggingService.catch("Error in DomService detectNetworkStatusChange: ",e)}}onWindowResize(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowResize","color: green;");try{this.unsubscribeFromWindowResize(),this.unlistenWindowResize=this.renderer.listen("window","resize",e=>{this.windowResize$.next(e);let t=this.calculateScreenSize();this.deviceInfo$.next(new Yn),this.currentScreenSize$.next(t)})}catch(e){this.loggingService.catch("Error in DomService onWindowResize: ",e)}}unsubscribeFromWindowResize(){try{this.unlistenWindowResize&&typeof this.unlistenWindowResize=="function"&&(this.unlistenWindowResize(),this.unlistenWindowResize=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowResize: ",e)}}onWindowScroll(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowScroll","color: green;");try{this.unsubscribeFromWindowScroll(),this.unlistenWindowScroll=this.renderer.listen("window","scroll",e=>{this.windowScroll$.next(e);let t=this.calculateScreenSize();this.currentScreenSize$.next(t)})}catch(e){this.loggingService.catch("Error in DomService onWindowScroll: ",e)}}unsubscribeFromWindowScroll(){try{this.unlistenWindowScroll&&typeof this.unlistenWindowScroll=="function"&&(this.unlistenWindowScroll(),this.unlistenWindowScroll=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowScroll: ",e)}}onPointerDown(){this.loggingService.log("%c[WB] Calling FUNCTION: onPointerDown","color: green;");try{this.unsubscribeFromPointerDown(),this.unlistenPointerDown=this.renderer.listen("window","pointerdown",e=>{this.mousedown=!0,this.windowMouseDown$.next(e),this.setPointerPosition(e)})}catch(e){this.loggingService.catch("Error in DomService onPointerDown: ",e)}}unsubscribeFromPointerDown(){try{this.unlistenPointerDown&&typeof this.unlistenPointerDown=="function"&&(this.unlistenPointerDown(),this.unlistenPointerDown=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerDown: ",e)}}onWindowClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupBackspace","color: green;");try{this.unsubscribeFromWindowClick(),this.unlistenWindowClick=this.renderer.listen("window","click",e=>{this.windowClick$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowClick: ",e)}}unsubscribeFromWindowClick(){try{this.unlistenWindowClick&&typeof this.unlistenWindowClick=="function"&&(this.unlistenWindowClick(),this.unlistenWindowClick=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowClick: ",e)}}onWindowKeyupBackspace(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupBackspace","color: green;");try{this.unsubscribeFromWindowKeyupBackspace(),this.unlistenWindowKeyupBackspace=this.renderer.listen("window","keyup.backspace",e=>{this.isVideoEditorHandlingDelete||this.windowKeyupBackspace$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupBackspace: ",e)}}unsubscribeFromWindowKeyupBackspace(){try{this.unlistenWindowKeyupBackspace&&typeof this.unlistenWindowKeyupBackspace=="function"&&(this.unlistenWindowKeyupBackspace(),this.unlistenWindowKeyupBackspace=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupBackspace: ",e)}}onWindowKeyupDelete(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupDelete","color: green;");try{this.unsubscribeFromWindowKeyupDelete(),this.unlistenWindowKeyupDelete=this.renderer.listen("window","keyup.delete",e=>{this.isVideoEditorHandlingDelete||this.windowKeyupDelete$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupDelete: ",e)}}unsubscribeFromWindowKeyupDelete(){try{this.unlistenWindowKeyupDelete&&typeof this.unlistenWindowKeyupDelete=="function"&&(this.unlistenWindowKeyupDelete(),this.unlistenWindowKeyupDelete=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupDelete: ",e)}}onWindowKeyupEsc(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupEsc","color: green;");try{this.unsubscribeFromWindowKeyupEsc(),this.unlistenWindowKeyupEsc=this.renderer.listen("window","keyup.esc",e=>{this.windowKeyupEsc$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupEsc: ",e)}}unsubscribeFromWindowKeyupEsc(){try{this.unlistenWindowKeyupEsc&&typeof this.unlistenWindowKeyupEsc=="function"&&(this.unlistenWindowKeyupEsc(),this.unlistenWindowKeyupEsc=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupEsc: ",e)}}onWindowPopState(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowPopState","color: green;");try{this.unsubscribeFromWindowPopState(),this.unlistenWindowPopState=this.renderer.listen("window","popstate",e=>{this.windowPopState$.next(e)})}catch(e){this.loggingService.catch("Error in DomService onWindowPopState: ",e)}}unsubscribeFromWindowPopState(){try{this.unlistenWindowPopState&&typeof this.unlistenWindowPopState=="function"&&(this.unlistenWindowPopState(),this.unlistenWindowPopState=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowPopState: ",e)}}onDocumentClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onDocumentClick","color: green;");try{this.unsubscribeFromDocumentClick(),this.documentClickListener=e=>{e?.target?.tagName?.toLowerCase()!==U.TAGS.SUPERFLOW_TOOLBAR&&(this.documentClick$.next(e),this.documentClickSubject$.next(e))},document.addEventListener("click",this.documentClickListener,!0)}catch(e){this.loggingService.catch("Error in DomService onDocumentClick: ",e)}}unsubscribeFromDocumentClick(){try{this.documentClickListener&&typeof this.documentClickListener=="function"&&(document.removeEventListener("click",this.documentClickListener,!0),this.documentClickListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromDocumentClick: ",e)}}onDocumentFocus(){this.loggingService.log("%c[WB] Calling FUNCTION: onDocumentFocus","color: green;");try{this.unsubscribeFromDocumentFocus(),this.documentFocusListener=e=>{this.documentFocus$.next(e)},document.addEventListener("focus",this.documentFocusListener,!0)}catch(e){this.loggingService.catch("Error in DomService onDocumentFocus: ",e)}}unsubscribeFromDocumentFocus(){try{this.documentFocusListener&&typeof this.documentFocusListener=="function"&&(document.removeEventListener("focus",this.documentFocusListener,!0),this.documentFocusListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromDocumentFocus: ",e)}}onWindowKeydownShift(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeydownShift","color: green;");try{this.unsubscribeFromWindowKeydownShift(),this.unlistenWindowKeydownShift=this.renderer.listen("window","keydown.shift",e=>{this.windowKeydownShift$.next(e),this.windowKeyupShift$.next(null)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeydownShift: ",e)}}unsubscribeFromWindowKeydownShift(){try{this.unlistenWindowKeydownShift&&typeof this.unlistenWindowKeydownShift=="function"&&(this.unlistenWindowKeydownShift(),this.unlistenWindowKeydownShift=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeydownShift: ",e)}}onWindowKeyupShift(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeyupShift","color: green;");try{this.unsubscribeFromWindowKeyupShift(),this.unlistenWindowKeyupShift=this.renderer.listen("window","keyup.shift",e=>{this.windowKeyupShift$.next(e),this.windowKeydownShift$.next(null)})}catch(e){this.loggingService.catch("Error in DomService onWindowKeyupShift: ",e)}}unsubscribeFromWindowKeyupShift(){try{this.unlistenWindowKeyupShift&&typeof this.unlistenWindowKeyupShift=="function"&&(this.unlistenWindowKeyupShift(),this.unlistenWindowKeyupShift=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromWindowKeyupShift: ",e)}}onWindowKeydown$(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowKeydown$","color: green;");try{return vi(window,"keydown")}catch(e){return this.loggingService.catch("Error in DomService onWindowKeydown$: ",e),jl}}addPointerMoveListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerMoveListener","color: green;");try{this.unsubscribeFromPointerMoveListener(),this.unlistenPointerMoveListener=this.renderer.listen("document","pointermove",e=>{this.windowPointerMove$.next(e),this.mouseMoveEvent=e})}catch(e){this.loggingService.catch("Error in DomService addPointerMoveListener: ",e)}}unsubscribeFromPointerMoveListener(){try{this.unlistenPointerMoveListener&&typeof this.unlistenPointerMoveListener=="function"&&(this.unlistenPointerMoveListener(),this.unlistenPointerMoveListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerMoveListener: ",e)}}addPointerUpListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerUpListener","color: green;");try{this.unsubscribeFromPointerUpListener(),this.unlistenPointerUpListener=this.renderer.listen("document","pointerup",e=>{this.windowPointerUp$.next(e)})}catch(e){this.loggingService.catch("Error in DomService addPointerUpListener: ",e)}}unsubscribeFromPointerUpListener(){try{this.unlistenPointerUpListener&&typeof this.unlistenPointerUpListener=="function"&&(this.unlistenPointerUpListener(),this.unlistenPointerUpListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromPointerUpListener: ",e)}}addSelectionChangeListener(){this.loggingService.log("%c[WB] Calling FUNCTION: addPointerUpListener","color: green;");try{this.unsubscribeFromSelectionChangeListener(),this.unlistenSelectionChangeListener=this.renderer.listen("document","selectionchange",e=>{this.documentSelectionChange$.next(e)})}catch(e){this.loggingService.catch("Error in DomService addPointerUpListener: ",e)}}unsubscribeFromSelectionChangeListener(){try{this.unlistenSelectionChangeListener&&typeof this.unlistenSelectionChangeListener=="function"&&(this.unlistenSelectionChangeListener(),this.unlistenSelectionChangeListener=null)}catch(e){this.loggingService.catch("Error in DomService unsubscribeFromSelectionChangeListener: ",e)}}updateCurrentMousePosition(e){try{if(this.currentMousePosition.pageX=e.pageX,this.currentMousePosition.pageY=e.pageY,this.currentMousePosition.clientX=e.clientX,this.currentMousePosition.clientY=e.clientY,e.target){let t=this.getXPath(e.target),r=e.target;if(t?.includes("name()='svg'")){let f=this.getXPath(t);f&&(r=f.iterateNext()||e.target)}let a=r.getBoundingClientRect(),s=e.clientX-a.x,c=e.clientY-a.y,p=s*100/(a.width||1),g=c*100/(a.height||1);this.currentMousePosition.element={xpath:t,topPercentage:g,leftPercentage:p}}else this.currentMousePosition.element=null;this.currentMousePosition$.next(this.currentMousePosition)}catch(t){this.loggingService.catch("Error in DomService updateCurrentMousePosition: ",t)}}getTargetElementForCursorPosition(e,t=!0,r=!1,a=!0,s,c=!0,p){try{let g=e,f=g?.touches?.length?g.touches[0]?.clientX:g?.clientX,I=g?.touches?.length?g.touches[0]?.clientY:g?.clientY;p&&(f=p.clientX,I=p.clientY);let T=this.getBackgroundElement(f,I,t,r);if(T&&s&&typeof s=="function"&&(T=s(T)),T){let B=this.getXPath(T),z=this.getXPath(T,!0),G=T.getBoundingClientRect(),J=f-G.x,ne=I-G.y,ve=J*100/(G.width||1),ye=ne*100/(G.height||1),Ne={xpath:B,fXpath:z,leftPercentage:ve,topPercentage:ye};if(a){let Ve=this.getXPath(T,!0,!0);Ne.cfXpath=Ve}if(c){let Ve=this.generateAnchorRecord(T);Ve&&(Ne.anchor=Ve)}return Ne}else return null}catch(g){return this.loggingService.catch("Error in DomService getTargetElementForCommentPinAnnotation: ",g),null}}getBackgroundElement(e,t,r=!0,a=!1){try{let s=document.elementsFromPoint(e,t),c=[];s.forEach(g=>{Ki(g)?c=[]:Pi(g)&&c.push(g)}),a&&(c=c.filter(g=>this.isElementVisibleOnScreen(g)));let p=0;return r||c?.forEach((g,f)=>{g.tagName.toLowerCase()==="svg"&&(p=f)}),c[p]}catch(s){return this.loggingService.catch("Error in DomService getBackgroundElement: ",s),null}}getBackgroundVeltElement(e,t){try{let r=document.elementsFromPoint(e,t),a=[];return r.forEach(s=>{Ki(s)&&Pi(s)&&a.push(s)}),a[0]}catch(r){return this.loggingService.catch("Error in DomService getBackgroundSnippylyElement: ",r),null}}setPointerPosition(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPointerPosition","color: green;");try{this.previousMousePosition.pageX=e.pageX,this.previousMousePosition.pageY=e.pageY,this.currentMousePosition.pageX=e.pageX,this.currentMousePosition.pageY=e.pageY}catch(t){this.loggingService.catch("Error in DomService setPointerPosition: ",t)}}getCurrentWindowSize$(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentWindowSize","color: green;"),this.currentScreenSize$.asObservable()}getCurrentMousePosition$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentMousePosition","color: green;"),this.currentMousePosition$.asObservable()}getCurrentWindowSizeValue(){return this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentWindowSizeValue","color: green;"),this.currentScreenSize$.value}getTopLeftPosition(){this.loggingService.log("%c[WB] Calling FUNCTION: getTopLeftPosition","color: green;");try{let e=document?.body?.getBoundingClientRect()||document?.documentElement?.getBoundingClientRect(),t=this.currentMousePosition?.pageX||e.x+200,r=Math.min(t,e.width/2),a=Math.abs(e.y),s=e.y-20;return a>50&&(s=Math.abs(e.y)+180),this.loggingService.log(e),this.loggingService.log(r),this.loggingService.log(s),{topPositionX:r,topPositionY:s}}catch(e){return this.loggingService.catch("Error in DomService getTopLeftPosition: ",e),{topPositionX:0,topPositionY:0}}}toggleSelection(){this.enableRectSelectionSubject$.next(!this.enableRectSelectionSubject$.value)}enableSelection(){this.enableRectSelectionSubject$.next(!0)}disableSelection(){this.enableRectSelectionSubject$.next(!1)}setPinHighlighterClass(e){this.pinHighlighterClass$.next(e)}setTextHighlighterClass(e){this.textHighlighterClass$.next(e)}getTextHighlighterClass(){return this.textHighlighterClass$.asObservable()}enableCommentPinHighlighter(){this.commentPinHighlighter$.next(!0)}disableCommentPinHighlighter(){this.commentPinHighlighter$.next(!1)}getCommentPinHighlighter$(){return this.commentPinHighlighter$.asObservable()}getCommentPinHighlighter(){return this.commentPinHighlighter$?.value}highlightElement(e,t,r){if(e){if(!r&&this.getCommentPinHighlighter()&&(this.pinHighlighterClass$.value?this.addClassToElement(e,this.pinHighlighterClass$.value):this.addClassToElement(e,U.SNIPPYLY_HIGHLIGHT)),t&&!e.hasAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)){let a=e.style.getPropertyValue("cursor"),s=e.style.getPropertyPriority("cursor"),c=a?{defaultCursorValue:a,defaultCursorPriority:s}:"";e.setAttribute(U.ATTRIBUTES.DEFAULT_CURSOR,c?JSON.stringify(c):""),e.style.setProperty("cursor",t,"important")}e.setAttribute(U.SNIPPYLY_HIGHLIGHT,"true"),e.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true")}}removeHighlightFromElement(e){if(e&&(this.pinHighlighterClass$.value&&this.removeClassFromElement(e,this.pinHighlighterClass$.value),this.removeClassFromElement(e,U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.VELT_IGNORE_CHANGE_DETECTION),e.hasAttribute(U.ATTRIBUTES.DEFAULT_CURSOR))){try{if(e.style.removeProperty("cursor"),e.getAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)){let t=JSON.parse(e.getAttribute(U.ATTRIBUTES.DEFAULT_CURSOR));e.style.setProperty("cursor",t.defaultCursorValue,t.defaultCursorPriority)}}catch{}e.removeAttribute(U.ATTRIBUTES.DEFAULT_CURSOR)}}highlightUserElement(e,t,r,a=!1){try{e&&(this.addClassToElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT),a&&this.addClassToElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT_DEFAULT),e.setAttribute(U.SNIPPYLY_HIGHLIGHT,"true"),e.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true"),t&&!e.style.getPropertyValue(U.VELT_SELECTION_COLOR)&&e.style.setProperty(U.VELT_SELECTION_COLOR,t),r&&e.setAttribute(U.SNIPPYLY_HIGHLIGHT_USER_NAME,r))}catch(s){this.loggingService.catch("Error in DomService highlightUserElement: ",s)}}removeHighlightUserFromElement(e){try{e&&(this.removeClassFromElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT),this.removeClassFromElement(e,U.VELT_LIVE_SELECTION_ON_ELEMENT_DEFAULT),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT),e.removeAttribute(U.VELT_IGNORE_CHANGE_DETECTION),e.removeAttribute(U.VELT_SELECTION_COLOR),e.removeAttribute(U.SNIPPYLY_HIGHLIGHT_USER_NAME),e.style.removeProperty(U.VELT_SELECTION_COLOR))}catch(t){this.loggingService.catch("Error in DomService removeHighlightUserFromElement: ",t)}}previewHighlightElement(e){e&&e.setAttribute(U.SNIPPYLY_HIGHLIGHT_PREVIEW,"true")}removePreviewHighlightFromElement(e){e&&e.removeAttribute(U.SNIPPYLY_HIGHLIGHT_PREVIEW)}getXPath(e,t=!1,r=!1,a){try{let s=this.calculateXPath(e,t,r,a);if(s&&typeof s=="string"&&s.includes("/svg")){let c=s.split("/"),p=!1;c.forEach((g,f)=>{g.includes("svg")&&(p=!0),p&&(c[f]="svg:"+g)}),s=c.join("/")}return s}catch(s){this.loggingService.catch("Error in DomService getXPath:",s)}}namespaceResolver(e){return e==="svg"?"http://www.w3.org/2000/svg":null}calculateXPath(e,t,r,a){try{if(e){if(typeof e=="string")return document.evaluate(e,a||document,this.namespaceResolver,XPathResult.ANY_TYPE,null);if(!e||e.nodeType!=1)return"";if(e.id&&document.querySelectorAll(`[id='${e.id}']`)?.length===1&&!t)return"//*[@id='"+e.id+"']";if(r&&e.className&&e.className.split){let c=e.className?.split(" ")?.filter(p=>!p?.includes("snippyly")&&!p?.includes("velt")&&!["show-pin-cursor"].includes(p))[0];if(c){let p=this.calculateXPath(e.parentNode,t,r,a)+"/"+e.tagName.toLowerCase(),g=Array.from(e.parentNode?.children||[]).filter(f=>f.nodeType===1&&f.tagName===e.tagName?f.className?.split(" ")?.filter(T=>T?.includes("snippyly")||T?.includes("velt")||["show-pin-cursor"].includes(T))[0]===c:!1);if(g.length>1){let f=g.indexOf(e)+1;p+=`[contains(concat(' ', normalize-space(@class), ' '), ' ${c} ')][${f}]`}else p+=`[contains(concat(' ', normalize-space(@class), ' '), ' ${c} ')]`;return p}}let s=[].filter.call(e.parentNode?.children?e.parentNode?.children:[],function(c){return c.tagName==e.tagName});return this.calculateXPath(e.parentNode,t,r)+"/"+e.tagName.toLowerCase()+(s.length>1?"["+([].indexOf.call(s,e)+1)+"]":"")}}catch(s){this.loggingService.catch("Error in DomService calculateXPath:",s)}}getElementFromXPath(e,t=document){try{if(this.xpathCache.has(e)){let a=this.xpathCache.get(e);if(a!==void 0&&document.contains(a))return a;this.xpathCache.delete(e)}let r=this.getXPath(e,!1,!1,t);if(r){let a=r?.iterateNext();if(a!==null&&typeof a.setAttribute=="function"){let s=vt();a.setAttribute(U.ATTRIBUTES.VELT_ELEMENT_CACHE_ID,s),this.xpathCacheId.set(s,e)}return this.xpathCache.set(e,a),a}return null}catch(r){return this.loggingService.catch("Error in DomService getElementFromXPath:",r),null}}getElementFromTargetElement(e){try{let t=null;if(e?.anchor){let r=this.resolveAnchorRecord(e.anchor);r?.element&&(t=r.element)}else e?.xpath?t=this.getElementFromXPath(e.xpath):e?.cfXpath?t=this.getElementFromXPath(e.cfXpath):e?.fXpath&&(t=this.getElementFromXPath(e.fXpath));return t}catch(t){return this.loggingService.catch("Error in DomService getElementFromTargetElement:",t),null}}getElementFromTargetTextRange(e){try{let t=null;if(e?.commonAncestorContainerAnchor){let r=this.resolveAnchorRecord(e.commonAncestorContainerAnchor);r?.element&&(t=r.element)}else e?.commonAncestorContainer&&(t=this.getElementFromXPath(e.commonAncestorContainer));return t}catch(t){return this.loggingService.catch("Error in DomService getElementFromTargetTextRange:",t),null}}calculateScreenSize(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowResize","color: green;");try{let e=[document?.body?.clientHeight||0,document?.documentElement?.clientHeight||0,window?.innerHeight||0],t=[document?.body?.clientWidth||0,document?.documentElement?.clientWidth||0,window?.innerWidth||0];this.calculatePageScrollHeight(),this.loggingService.log(this.pageScrollHeight),this.loggingService.log(this.nodeMap),this.highestNode=this.nodeMap[this.pageScrollHeight];let r=new GI;return r.screenWidth=Math.max(...t),r.screenHeight=Math.max(...e),r.screenScrollHeight=this.pageScrollHeight,r}catch(e){return this.loggingService.catch("Error in DomService calculateScreenSize:",e),new GI}}calculatePageScrollHeight(){this.loggingService.log("%c[WB] Calling FUNCTION: calculatePageScrollHeight","color: green;");try{this.pageScrollHeight=0,this.findLongestNode(document?.documentElement?.childNodes)}catch(e){this.loggingService.catch("Error in DomService calculatePageScrollHeight: ",e)}}removeSnippylyContent(e){this.loggingService.log("%c[WB] Calling FUNCTION: removeSnippylyContent","color: green;");try{let r=new DOMParser().parseFromString(e,"text/html");r.querySelectorAll("[data-snippyly-cache-id]").forEach(I=>{I.removeAttribute("data-snippyly-cache-id")}),r.querySelectorAll("[data-velt-cache-id]").forEach(I=>{I.removeAttribute("data-velt-cache-id")}),r.querySelectorAll(".comment-text-highlight").forEach(I=>{I?.parentNode?.insertBefore(document.createTextNode(I?.textContent),I),I.remove()});let p=document.createNodeIterator(r,NodeFilter.SHOW_COMMENT),g;for(;g=p.nextNode();)g?.remove();return this.mergeAdjacentTextNodes(r.body),this.sanitizeHtml(r.body.innerHTML)}catch(t){return this.loggingService.catch("Error in DomService removeSnippylyContent: ",t),e}}mergeAdjacentTextNodes(e){try{let t=e.firstChild;for(;t;){if(t.nodeType===Node.TEXT_NODE){let r=t.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE;)t.textContent+=r.textContent,r.remove(),r=t.nextSibling}t=t.nextSibling}}catch(t){this.loggingService.catch("Error in DomService mergeAdjacentTextNodes: ",t)}}findLongestNode(e){try{for(let t=e.length-1;t>=0;t--){if(e[t]?.scrollHeight&&e[t]?.clientHeight){let r=Math.max(e[t]?.scrollHeight,e[t]?.clientHeight);this.pageScrollHeight=Math.max(r,this.pageScrollHeight),this.nodeMap[r]=e[t]}e[t]?.childNodes?.length&&this.findLongestNode(e[t]?.childNodes)}}catch(t){this.loggingService.catch("Error in DomService findLongestNode: ",t)}}resetSelectedAnnotationsMap(e=!0,t){try{let r=Array.from(document.querySelectorAll(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`)),a=this.getDraftCommentAnnotationDialogs()||[];r.push(...a),r=Array.from(new Set(r));let s=r.map(f=>f.classList.contains("velt-annotation-draft-checked")?(f.classList.remove("velt-annotation-draft-checked"),null):(this.removeClassFromElement(f,"velt-comment-dialog-shake"),setTimeout(()=>{this.addClassToElement(f,"velt-comment-dialog-shake"),f.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_EDIT_COMMENT)||f.classList.contains("velt-annotation-draft-checked")||this.addClassToElement(f,"velt-annotation-draft-checked")},100),f.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_DRAFT))).filter(f=>f),c=Object.keys(this.getRecordingInProgress()||{});s=[...s,...c];let p=this.selectedAnnotationsMap$.value;if(e&&this.selectedAnnotationsMap$.value&&Object.keys(this.selectedAnnotationsMap$.value).length){let f=[];Object.keys(p).forEach(I=>{if(p[I]?.type==="tag"){let T=p[I];T?.to?.length||s.includes(I)||f.push(T)}else p[I]?.comments?.length||s.includes(I)||f.push(p[I])}),this.deleteAnnotations$.next(f),this.deleteAnnotations$.next([])}let g={};Object.keys(p).forEach(f=>{if(s.includes(f)&&(g[f]=p[f]),t)switch(t){case"comment":["comment","videoPin"].includes(p[f]?.type)||(g[f]=p[f]);break;default:p[f]?.type!==t&&(g[f]=p[f]);break}}),Object.keys(g).forEach(f=>{let I=g[f]?.multiThreadAnnotationId;I&&!g[I]&&(g[I]={annotationId:I,type:"multiThread"})}),JSON.stringify(this.selectedAnnotationsMap$.value)!==JSON.stringify(g)&&this.selectedAnnotationsMap$.next(g),this.setDialogOpenedInSidebar(!1)}catch(r){this.loggingService.catch("Error in DomService resetSelectedAnnotationsMap: ",r)}}setRecordingInProgress(e,t){try{if(t)this.recordingInProgress$.next(D(E({},this.recordingInProgress$.value),{[e]:t}));else{let r=this.recordingInProgress$.value;delete r[e],this.recordingInProgress$.next(r)}}catch(r){this.loggingService.catch("Error in DomService setRecordingInProgress: ",r)}}resetRecordingInProgress(){try{this.recordingInProgress$.next({})}catch(e){this.loggingService.catch("Error in DomService resetRecordingInProgress: ",e)}}getRecordingInProgress(){try{return this.recordingInProgress$.value}catch(e){return this.loggingService.catch("Error in DomService getRecordingInProgress: ",e),{}}}getDraftCommentAnnotationDialogs(){try{let e=[];return Array.from(document.querySelectorAll(`${U.TAGS.SNIPPYLY_COMMENT_DIALOG}`)).forEach(r=>{if(r?.shadowRoot){let a=r.shadowRoot.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);a&&e.push(a)}else{let a=r.querySelector(`${U.TAGS.VELT_SHADOW_DOM_INTERNAL}`);if(a?.shadowRoot){let s=a.shadowRoot?.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);s&&e.push(s)}else{let s=r.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);s&&e.push(s)}}}),e}catch(e){return this.loggingService.catch("Error in DomService getDraftCommentAnnotationDialogs: ",e),[]}}getSelectedAnnotationsMap(e){try{let t=this.selectedAnnotationsMap$.value;if(e){let r={};return Object.keys(t).forEach(a=>{switch(e){case"comment":["comment","videoPin"].includes(t[a].type)&&(r[a]=t[a]);break;default:t[a].type===e&&(r[a]=t[a]);break}}),r}else return t}catch(t){return this.loggingService.catch("Error in DomService getSelectedAnnotationsMap: ",t),{}}}getSelectedAnnotationsMap$(e){return this.selectedAnnotationsMap$.asObservable().pipe(de(t=>{if(e){let r={};return Object.keys(t).forEach(a=>{t[a].type===e&&(r[a]=t[a])}),r}else return t}))}getSelectedComments$(){return this.selectedAnnotationsMap$.asObservable().pipe(de(e=>Object.values(e)))}getSelectedAnnotationsLocationMap(){try{return this.selectedAnnotationsLocationMap$.value}catch(e){return this.loggingService.catch("Error in DomService getSelectedAnnotationsLocationMap: ",e),{}}}getSelectedAnnotationsLocationMap$(){return this.selectedAnnotationsLocationMap$.asObservable()}toggleAnnotationSelection(e,t,r,a=!1,s){try{r==="sidebarShowReplies"?this.setDialogOpenedInSidebar(!0):this.setDialogOpenedInSidebar(!1);let c=JSON.parse(JSON.stringify(this.selectedAnnotationsMap$.value||{})),p=JSON.parse(JSON.stringify(this.selectedAnnotationsLocationMap$.value||{}));c[e.annotationId]&&!a?delete c[e.annotationId]:((!this.windowKeydownShift$.value||a)&&(c={}),c[e.annotationId]=e,p[e.annotationId]=t,s=e?.multiThreadAnnotationId||s,s&&(c[s]={annotationId:s,type:"multiThread"},p[s]=t)),this.selectedAnnotationsMap$.next(c),Object.keys(p).forEach(g=>{c[g]||delete p[g]}),this.selectedAnnotationsLocationMap$.next(p)}catch(c){this.loggingService.catch("Error in DomService toggleAnnotationSelection: ",c)}}setSelectedAnnotationLocation(e,t){try{let r=JSON.parse(JSON.stringify(this.getSelectedAnnotationsLocationMap()||{}));r?.[e]!==t&&(r[e]=t,this.selectedAnnotationsLocationMap$.next(r))}catch(r){this.loggingService.catch("Error in DomService setSelectedAnnotationLocation: ",r)}}updateSelectedAnnotationInMap(e){try{let t=this.selectedAnnotationsMap$.value;e.forEach(r=>{t[r.annotationId]&&(t[r.annotationId]=r)}),this.selectedAnnotationsMap$.next(t)}catch(t){this.loggingService.catch("Error in DomService updateSelectedAnnotationInMap: ",t)}}getDeleteCommmentAnnotations$(){try{return this.deleteAnnotations$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getDeleteCommmentAnnotations$: ",e),le([])}}getHighestNode(){return this.loggingService.log("%c[WB] Calling FUNCTION: getHighestNode","color: green;"),this.highestNode}onWindowMouseDown$(){return this.windowMouseDown$.asObservable()}onWindowPointerMove$(){return this.windowPointerMove$.asObservable()}onWindowPointerMove(){return this.windowPointerMove$.value}onWindowPointerUp$(){return this.windowPointerUp$.asObservable()}onSelectionChange$(){return this.documentSelectionChange$.asObservable()}onWindowClick$(){return this.windowClick$.asObservable()}onWindowScroll$(){return this.windowScroll$.asObservable()}onWindowResize$(){return this.windowResize$.asObservable()}onWindowKeyupBackspace$(){return this.windowKeyupBackspace$.asObservable()}onWindowKeyupDelete$(){return this.windowKeyupDelete$.asObservable()}onWindowKeyupEsc$(){return this.windowKeyupEsc$.asObservable()}onWindowPopState$(){return this.windowPopState$.asObservable()}onDocumentClick$(){return this.documentClick$.asObservable()}getLastDocumentClick(){return this.documentClick$.value}onDocumentClickSubject$(){return this.documentClickSubject$.asObservable()}onDocumentFocus$(){return this.documentFocus$.asObservable()}onDomChange$(e){try{return this.mutationObserver||this.setMutationObserver(e),this.mutation$.asObservable()}catch(t){return this.loggingService.catch("Error in DomService onDomChange$: ",t),le([])}}getChildListMutation$(){return this.childListMutation$.asObservable()}onNetworkStatusChange$(){return this.networkStatus$.asObservable()}getNetworkStatus(){return this.networkStatus$.value}getElementOffset(e,t){try{let r={offsetTop:0,offsetLeft:0},a=e;if(a===t){let s=window.getComputedStyle(e);s.position==="static"&&s.transformStyle!="preserve-3d"&&s.transform=="none"&&(r.offsetLeft=e?.offsetLeft||0,r.offsetTop=e?.offsetTop||0)}if(a!==t)if(e?.closest("svg"))for(;a&&a!==t;){let c=window.getComputedStyle(a);if(a.tagName.toLowerCase()==="svg"||a instanceof SVGElement){let p=a.parentElement;if(p){let g=p.getBoundingClientRect(),f=a.getBoundingClientRect();r.offsetLeft+=f.left-g.left,r.offsetTop+=f.top-g.top}}else c.position==="static"?c.transformStyle!="preserve-3d"&&c.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0):(r.offsetLeft+=a.offsetLeft,r.offsetTop+=a.offsetTop);if(a=a.parentElement,e instanceof SVGElement&&a===t){let p=window.getComputedStyle(a);p.position==="static"&&p.transformStyle!="preserve-3d"&&p.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0)}}else{let c=window.getComputedStyle(a);c.position==="static"?c.transformStyle!="preserve-3d"&&c.transform=="none"&&(r.offsetLeft+=a?.offsetLeft||0,r.offsetTop+=a?.offsetTop||0):(r.offsetLeft+=a.offsetLeft,r.offsetTop+=a.offsetTop)}return r}catch(r){return this.loggingService.catch("Error in DomService getElementOffset: ",r),{offsetTop:0,offsetLeft:0}}}isElementVisible(e){try{if(typeof e?.getBoundingClientRect=="function"){let{width:t,height:r,top:a,bottom:s}=e?.getBoundingClientRect();return t>0||r>0||a<window.innerHeight&&s>0}else return!1}catch(t){return this.loggingService.catch("Error in DomService isElementVisible: ",t),!1}}isElementVisibleOnScreen(e){try{if(e){if(!(e instanceof Element))return!1;let t=e,r=window.getComputedStyle(t);return!(r.display==="none"||r.visibility==="hidden"||parseFloat(r.opacity)===0)}return!1}catch(t){return this.loggingService.catch("Error in DomService isElementVisibleOnScreen: ",t),!1}}getClickAndDragPointsObservable(){return new $t(e=>{let t=vi(document,"mousedown").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),r=vi(document,"mousemove").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),a=vi(document,"mouseup").pipe(de(p=>({type:p.type,x:p.clientX+window.scrollX,y:p.clientY+window.scrollY,event:p}))),c=t.pipe(he(p=>r.pipe(Oi(),de(([g,f])=>({startPoint:p,prevPoint:g,curPoint:f})),yo(a)))).subscribe(e);return()=>c.unsubscribe()})}drawRectangle(e,t){let r=document.querySelector(".rectangle");r||(r=document.createElement("div"),this.addClassToElement(r,"rectangle"),r.setAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED,"true"),r.setAttribute(U.VELT_IGNORE_CHANGE_DETECTION,"true"),document.body.appendChild(r));let a=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y),c=Math.min(e.x,t.x),p=Math.min(e.y,t.y);return r.style.width=`${a}px`,r.style.height=`${s}px`,r.style.left=`${c}px`,r.style.top=`${p}px`,r.style.position="absolute",r.style.border="2px dashed #f00",r.style.pointerEvents="none",r.style.zIndex="2147483577",r}getRange(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: getRange","color: green;"),window.getSelection()?.toString()){let e=window.getSelection();if(e?.rangeCount)return e.getRangeAt(0)}return null}catch(e){return this.loggingService.catch("Error in DomService getRange: ",e),null}}clearTextSelection(){try{this.loggingService.log("%c[WB] Calling FUNCTION: clearTextSelection","color: green;"),window.getSelection&&(window.getSelection()?.empty?window.getSelection()?.empty():window.getSelection()?.removeAllRanges&&window.getSelection()?.removeAllRanges())}catch(e){this.loggingService.catch("Error in DomService clearTextSelection: ",e)}}getTargetTextRangeFromSelectionRange(e){try{let t={},r=e.commonAncestorContainer;r?.nodeType===Node.TEXT_NODE&&(r=r.parentElement);let a=document.body;if(r){let c=this.getTextXPath(r);this.isXpathWithId(c)&&(a=r)}let s=this.getAdditionalLocationContainer(r);if(s&&(a=s),t.commonAncestorContainer=this.getTextXPath(a),t.commonAncestorContainer){let c=this.getElementFromXPath(t.commonAncestorContainer);if(c){t.commonAncestorContainerFXpath=this.getXPath(c,!0),t.commonAncestorContainerCFXpath=this.getXPath(c,!0,!0);let p=this.generateAnchorRecord(c);p&&(t.commonAncestorContainerAnchor=p)}}return t.text=e.toString(),t.occurrence=df(a,0,e.startContainer,e.startOffset,e.toString())+1,t}catch(t){this.loggingService.catch("Error in DomService getTargetTextRangeFromSelectionRange: ",t);return}}getTextXPath(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: getTextXPath","color: green;"),e.nodeType===Node.TEXT_NODE){let t=1,r=e.previousSibling;for(;r;)r.nodeType===Node.TEXT_NODE&&t++,r=r.previousSibling;return this.getXPath(e.parentElement)}else return this.getXPath(e)}catch(t){this.loggingService.catch("Error in DomService getTextXPath: ",t);return}}getHostElement(e){try{if(U.NON_NESTABLE_ELEMENTS[e?.tagName?.toLowerCase()]){let r=e?.closest("picture");return r?r?.parentElement:e.parentElement}let t=e.closest("svg");return t?t?.parentElement:e}catch(t){return this.loggingService.catch("Error in DomService getHostElement: ",t),e}}isElementInsideAdditionalLocationContainer(e){try{return!!e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`)}catch(t){return this.loggingService.catch("Error in DomService isElementInsideAdditionalLocationContainer: ",t),!1}}getAdditionalLocationContainer(e){try{return e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`)||null}catch(t){return this.loggingService.catch("Error in DomService getAdditionalLocationContainer: ",t),null}}isXpathWithId(e){try{return typeof e=="string"?!!e?.includes("[@id="):!1}catch(t){return this.loggingService.catch("Error in DomService isXpathWithId: ",t),!1}}getListedElements({elementIds:e,elementClassNames:t,elementQuerySelectors:r}){try{let a=[];if(e?.length)for(let s=0;s<e.length;s++){let c=document.getElementById(e[s]);c&&a.push(c)}if(t?.length)for(let s=0;s<t.length;s++){let c=document.getElementsByClassName(t[s]);for(let p=0;p<c.length;p++){let g=c[p];g&&g instanceof HTMLElement&&a.push(g)}}if(r?.length)for(let s=0;s<r.length;s++){let c=document.querySelectorAll(r[s]);for(let p=0;p<c.length;p++){let g=c[p];g&&g instanceof HTMLElement&&a.push(g)}}return a}catch(a){return this.loggingService.catch("Error in DomService getListedElements: ",a),[]}}isElementInsideListedElementIds(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.getElementById(t[r]);if(a&&a.contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementIds: ",r),!1}}isElementInsideListedElementClassNames(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.getElementsByClassName(t[r]);for(let s=0;s<a.length;s++)if(a[s].contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementClassNames: ",r),!1}}isElementInsideListedElementQuerySelectors(e,t){try{if(t?.length){for(let r=0;r<t.length;r++){let a=document.querySelectorAll(t[r]);for(let s=0;s<a.length;s++)if(a[s].contains(e))return!0}return!1}return!0}catch(r){return this.loggingService.catch("Error in DomService isElementInsideListedElementQuerySelectors: ",r),!1}}addClassToElement(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: addClassToElement","color: green;"),e&&(e.classList?.contains(t)||e.classList?.add(t))}catch(r){this.loggingService.catch("Error in DomService addClassToElement: ",r)}}removeClassFromElement(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeClassFromElement","color: green;"),e&&e.classList?.contains(t)&&e.classList?.remove(t)}catch(r){this.loggingService.catch("Error in DomService removeClassFromElement: ",r)}}isElementInsideParentWithAttribute(e,t,r){try{let a=e;for(;a&&a!==document.body;){if(a?.getAttribute&&a?.getAttribute(t)===r)return!0;a=a.parentElement}return!1}catch(a){return this.loggingService.catch("Error in DomService isElementInsideParentWithAttribute: ",a),!1}}setVideoEditorHandlingDelete(e){try{this.isVideoEditorHandlingDelete=e}catch(t){this.loggingService.catch("Error in DomService setVideoEditorHandlingDelete: ",t)}}isVideoEditorHandlingDeleteKey(){try{return this.isVideoEditorHandlingDelete}catch(e){return this.loggingService.catch("Error in DomService isVideoEditorHandlingDeleteKey: ",e),!1}}setCustomCss(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCustomCss","color: green;"),this.customCss$.next(e)}catch(t){this.loggingService.catch("Error in DomService setCustomCss: ",t)}}getCustomCss$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getCustomCss$","color: green;"),this.customCss$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getCustomCss$: ",e),le(null)}}injectCustomCss(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: injectCustomCss","color: green;");let t=this.customCss$.value;if(t){let r=e?.shadowRoot?.querySelector(`[${U.VELT_CUSTOM_CSS}]`);if(r&&r.remove(),t?.type==="link"){let a=document.createElement("link");a.href=t?.value,a.rel="stylesheet",a.setAttribute(U.VELT_CUSTOM_CSS,"true"),e?.shadowRoot?.appendChild(a)}else{let a=document.createElement("style");a.innerHTML=this.sanitizeHtml(t?.value),a.setAttribute(U.VELT_CUSTOM_CSS,"true"),e?.shadowRoot?.appendChild(a)}}}catch(t){this.loggingService.catch("Error in DomService injectCustomCss: ",t)}}trimCommentHtml(e){try{let t=document.createElement("div");t.innerHTML=e,this.removeEmptyElements(t);let r=t.innerHTML;return r=r.replace(o.MULTIPLE_NBSP_REGEX," ").replace(o.TRIM_NBSP_REGEX,"").trim(),r}catch(t){return this.loggingService.catch("Error in DomService trimCommentHtml: ",t),e}}removeEmptyElements(e){try{let a=function(s){return r.test(s.innerHTML)};var t=a;let r=/^\s*(<br\s*\/?>)?\s*$/;for(;e.firstChild&&a(e.firstChild);)e.removeChild(e.firstChild);for(;e.lastChild&&a(e.lastChild);)e.removeChild(e.lastChild)}catch(r){this.loggingService.catch("Error in DomService removeEmptyElements: ",r)}}normalizeWhitespace(e){try{e.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE?t.nodeValue=t.nodeValue?.replace(/\s+/g," ").trim()??"":t.nodeType===Node.ELEMENT_NODE&&this.normalizeWhitespace(t)})}catch(t){this.loggingService.catch("Error in DomService normalizeWhitespace: ",t)}}sanitizeHtml(e){try{return this.loggingService.log("%c[WB] Calling FUNCTION: sanitizeHtml","color: green;"),t2.sanitize(e,Npe)}catch(t){return this.loggingService.catch("Error in DomService sanitizeHtml: ",t),""}}sanitizeSvg(e){try{return t2.sanitize(e,Npe)}catch(t){return this.loggingService.catch("Error in DomService sanitizeSvg: ",t),e}}setDeviceInfo(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDeviceInfo","color: green;");let e=new Yn;this.deviceInfo$.next(e)}catch(e){this.loggingService.catch("Error in DomService setDeviceInfo: ",e)}}getDeviceInfo$(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getDeviceInfo$","color: green;"),this.deviceInfo$.asObservable()}catch(e){return this.loggingService.catch("Error in DomService getDeviceInfo$: ",e),le(new Yn)}}getTabId(){try{let e=sessionStorage.getItem(U.SESSION_STORAGE.VELT_TAB_ID);!e&&this.tabId&&(e=this.tabId,sessionStorage.setItem(U.SESSION_STORAGE.VELT_TAB_ID,e)),!this.tabId&&e&&(this.tabId=e);let t=this.getTabIdFromWindowName();return(!e||e!==t)&&(e=vt(),this.tabId=e,sessionStorage.setItem(U.SESSION_STORAGE.VELT_TAB_ID,e),this.setTabIdToWindowName(e)),e}catch(e){return this.loggingService.catch("Error in DomService getTabId: ",e),null}}getTabIdFromWindowName(){try{return window.name}catch(e){return this.loggingService.catch("Error in DomService getTabIdFromWindowName: ",e),null}}setTabIdToWindowName(e){try{window.name=e}catch(t){this.loggingService.catch("Error in DomService setTabIdToWindowName: ",t)}}getDeviceInfo(){try{return this.loggingService.log("%c[WB] Calling FUNCTION: getDeviceInfo","color: green;"),this.deviceInfo$.value}catch(e){return this.loggingService.catch("Error in DomService getDeviceInfo: ",e),new Yn}}isMobileDevice(){try{return new Yn().getDeviceType()===mr.MOBILE}catch(e){return this.loggingService.catch("Error in DomService isMobileDevice: ",e),!1}}isTabletDevice(){try{return new Yn().getDeviceType()===mr.TABLET}catch(e){return this.loggingService.catch("Error in DomService isTabletDevice: ",e),!1}}isDesktopDevice(){try{return new Yn().getDeviceType()===mr.DESKTOP}catch(e){return this.loggingService.catch("Error in DomService isDesktopDevice: ",e),!1}}deepCloneElement(e){try{var t=document.createElement(e?.tagName);return Array.from(e.attributes).forEach(r=>{t.setAttribute(r.nodeName,r.nodeValue)}),e.childNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE?t.appendChild(this.deepCloneElement(r)):r.nodeType===Node.TEXT_NODE&&t.appendChild(document.createTextNode(r.nodeValue))}),t}catch(r){return this.loggingService.catch("Error in DomService deepCloneElement: ",r),e}}setRandomNumberToElementRecursive(e){try{if(!e)return;let t=Math.random().toString(36).substring(7);e&&e.setAttribute&&typeof e.setAttribute=="function"&&(e.getAttribute("velt-wireframe-id")||e.setAttribute("velt-wireframe-id",t)),Array.from(e.children).forEach(a=>{this.setRandomNumberToElementRecursive(a)})}catch(t){this.loggingService.catch("Error in DomService setRandomNumberToElementRecursive: ",t)}}setDialogOpenedInSidebar(e){this.dialogOpenedInSidebar$.next(e)}getDialogOpenedInSidebar(){return this.dialogOpenedInSidebar$.asObservable()}removeWireframeSuffixFromTags(e){if(!e)return;Array.from(e.children).forEach(r=>{if(this.removeWireframeSuffixFromTags(r),r.tagName.toLowerCase().endsWith("-wireframe")){let a=r.tagName.toLowerCase().replace("-wireframe",""),s=document.createElement(a);for(Array.from(r.attributes).forEach(c=>{s.setAttribute(c.name,c.value)});r.firstChild;)s.appendChild(r.firstChild);r.parentNode.replaceChild(s,r)}})}isMonitorDevice(){try{return new Yn().getDeviceType()===mr.MONITOR}catch(e){return this.loggingService.catch("Error in DomService isMonitorDevice: ",e),!1}}};o.MULTIPLE_NBSP_REGEX=/(?:&nbsp;\s*){2,}/g,o.TRIM_NBSP_REGEX=/^(?:&nbsp;\s*)+|(?:&nbsp;\s*)+$/g,o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(er),ee(_),ee(Cl))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var je=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.afAuth=e,this.configService=t,this.avatarService=r,this.coreActionsService=a,this.domService=s,this.functions=c,this.analyticsService=p,this.loggingService=g,this.user$=new Ce(null),this.userOptions$=new Ce(null),this.userContacts$=new Ce(null),this.userOrganization$=new Ce(null),this.providedUser=new zo,this.firebaseConfig$=new Ce(null),this.advancedQueries$=new Ce(null),this.planDetails$=new Ce(null),this.signOutPreviousUser$=new Ce(null),this.preSignOutFunctions=new Map,this.autoLoginCalled=!1,this.autoLoginRequired=!0,this.config=null,this.getPlanDetailsCalled=!1,this.forceReLoggedIn=!1,this.lastLoggedInUserData=null,this.sessionReLoginCount=0,this.SESSION_RE_LOGIN_COUNT_LIMIT=10,this.sessionReLoginSubscription=null,this.onRetrySubscription=null,this.TOKEN_EXPIRED_ERROR_COUNT_LIMIT=3,this.tokenExpiredErrorCount=0,this.loggingService.log("%c[WB] Creating CLASS: AuthService","color: blue;");try{this.analyticsService.setAuthService(this),this.configService.getConfig$().subscribe(f=>{this.config=f}),this.forceReLoggedIn=localStorage.getItem(U.LOCAL_STORAGE.VELT_USER_FORCE_RE_LOGGED_IN)==="true",this.sessionReLoginSubscription=ei(this.afAuth).pipe(so(this.afAuth.currentUser),Oi(),he(([f,I])=>this.domService.onNetworkStatusChange$().pipe(Le(T=>T),rt(1),de(()=>({previousUser:f,currentUser:I}))))).subscribe(T=>Q(this,[T],function*({previousUser:f,currentUser:I}){if(!I&&f){let B=f?.stsTokenManager?.expirationTime,z=new Date().getTime(),G=B-z;z>B&&(this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_TOKEN_EXPIRED,{apiKey:this.apiKey,user:this.user$.value,lastLoggedInUserData:this.lastLoggedInUserData,timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.user$.value?.userSnippylyId),this.user$.value&&f?.uid===this.user$.value?.userSnippylyId&&this.lastLoggedInUserData?.user?.userSnippylyId===this.user$.value?.userSnippylyId&&(this.sessionReLoginCount>this.SESSION_RE_LOGIN_COUNT_LIMIT?(this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_RE_LOGIN_COUNT_EXCEEDED,{apiKey:this.apiKey,clientUserId:this.lastLoggedInUserData.user.userId,snippylyUserId:this.lastLoggedInUserData.user.userSnippylyId,timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.user$.value?.userSnippylyId),this.sessionReLoginSubscription?.unsubscribe()):(this.sessionReLoginCount++,this.analyticsService.trackEvent(Y.Events.Core.SDK_SESSION_RE_LOGIN_TRIGGERED,{apiKey:this.apiKey,clientUserId:this.lastLoggedInUserData.user.userId,snippylyUserId:this.lastLoggedInUserData.user.userSnippylyId,user:this.getUserWithoutContacts(this.lastLoggedInUserData.user),timeLeft:G,forceReset:this.userOptions$.value?.forceReset,sessionReLoginCount:this.sessionReLoginCount},!0,this.lastLoggedInUserData.user.userSnippylyId),this.lastLoggedInUserData.user=yield this.updateUserWithColorAndTextColor(this.lastLoggedInUserData.user),this.initializeClient(this.lastLoggedInUserData.user,this.lastLoggedInUserData.userOptions,this.lastLoggedInUserData.initializeClientToken,this.lastLoggedInUserData.autoLogin,"internal-sessionReLogin"))))}}),f=>{this.loggingService.catch("Error in AuthService sessionReLoginSubscription: ",f)}),this.getUser$().pipe(Ct(Xt)).subscribe(f=>{let I=Dr(f);this.coreActionsService.triggerAction(mt.USER_UPDATE,I),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:mt.USER_UPDATE,payload:{user:I}})})}catch(f){this.loggingService.catch("Error in AuthService constructor: ",f)}}setApiKey(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: setApiKey","color: green;",e);try{if(this.apiKey){this.loggingService.log("API key is already set");return}this.apiKey=e,this.configService.setApiKey(this.apiKey),t||(t=new t9),this.configService.initConfig(t),t.debugMode?sessionStorage.setItem("debugMode","true"):sessionStorage.removeItem("debugMode"),this.autoLoginCalled||ei(this.afAuth).pipe(rt(1)).subscribe(r=>Q(this,null,function*(){if(this.autoLoginCalled=!0,r){let a=yield ed(r,!0).catch(s=>null);if(a){let{user:s}=a?.claims;this.autoLoginRequired&&(s=yield this.updateUserWithColorAndTextColor(s),this.initializeClient(s,this.userOptions$?.value?D(E({},this.userOptions$?.value),{replaceContacts:!1,replaceGroupContacts:!1,replacePrivateContacts:!1}):{},new Date().getTime(),!0,"internal-autoLogin"))}}}))}catch(r){this.loggingService.catch("Error in setApiKey: ",r)}}setUsersService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUsersService","color: green;"),this.usersService=e}catch(t){this.loggingService.catch("Error in setUsersService: ",t)}}setUserPermissionService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserPermissionService","color: green;"),this.userPermissionService=e}catch(t){this.loggingService.catch("Error in setUserPermissionService: ",t)}}setDocService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocService","color: green;"),this.docService=e}catch(t){this.loggingService.catch("Error in setDocService: ",t)}}setContactService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setContactService","color: green;"),this.contactService=e}catch(t){this.loggingService.catch("Error in setContactService: ",t)}}setIamService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setIamService","color: green;"),this.iamService=e}catch(t){this.loggingService.catch("Error in setIamService: ",t)}}setAreaService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaService","color: green;"),this.areaService=e}catch(t){this.loggingService.catch("Error in setAreaService: ",t)}}setCommentService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentService","color: green;"),this.commentService=e}catch(t){this.loggingService.catch("Error in setCommentService: ",t)}}setReactionService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setReactionService","color: green;"),this.reactionService=e}catch(t){this.loggingService.catch("Error in setReactionService: ",t)}}setRecorderAnnotationService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRecorderAnnotationService","color: green;"),this.recorderAnnotationService=e}catch(t){this.loggingService.catch("Error in setRecorderAnnotationService: ",t)}}setViewsService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setViewsService","color: green;"),this.viewsService=e}catch(t){this.loggingService.catch("Error in setViewsService: ",t)}}setCommonDbService(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommonDbService","color: green;"),this.commonDbService=e}catch(t){this.loggingService.catch("Error in setCommonDbService: ",t)}}validateOrganizationId(e){if(this.isVersionGreaterThanOrEqualTo4()&&!e?.organizationId)if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_FAILED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,message:"Organization Id is not set",forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)},!0,e.userSnippylyId),this.configService.getSF())this.loggingService.catch("OrganizationId is not set in Identify method",void 0,void 0,!0);else throw new Error("OrganizationId is not set in Identify method")}setVeltAuthProvider(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setVeltAuthProvider","color: green;");try{this.onRetrySubscription?.unsubscribe();let t=null;if(!e.user)return null;e.generateToken&&typeof e.generateToken=="function"&&(t=yield e.generateToken());let r=yield vz(()=>window.Velt.identify(e.user,E(E({},e.options||{}),t&&{authToken:t}),{fromProvider:!0}).catch(a=>(e.onError&&typeof e.onError=="function"&&e.onError(a),Promise.reject(a))),e.retryConfig||{retryCount:0,retryDelay:0});return r&&e.generateToken&&typeof e.generateToken=="function"&&(this.onRetrySubscription=this.coreActionsService.onAction(mt.ERROR).pipe(Le(a=>a.code==="token_expired"),rt(10)).subscribe(a=>Q(this,null,function*(){if(a.code==="token_expired"){let s=this.docService?.getDocumentIds()?.map(T=>({id:T.clientDocumentId}))??[],c=this.docService?.getOptionsFromDocumentPaths()??void 0,p=[],g=this.docService?.getLocation();g&&p.push(g.location);let f=this.docService?.getLocations();f&&Object.values(f).forEach(T=>{p.push(T.location)}),(yield vz(()=>Q(this,null,function*(){try{let T=yield e.generateToken?.();return T?window.Velt.identify(e.user,E(E({},e.options||{}),T&&{authToken:T}),{fromProvider:!0}):!0}catch{return!1}}),e.retryConfig||{retryCount:0,retryDelay:0}))&&(yield this.docService?.setDocuments({documents:s,options:c,source:"internal"}),yield this.docService?.setLocations({locations:p,source:"internal",options:{appendLocation:!g}}))}}))),r}catch(t){return this.loggingService.catch("Error in setVeltAuthProvider: ",t),null}})}setUserToStorage(e){return Q(this,null,function*(){try{if(e){let t=yield wl(e,e?.userId??"");localStorage.setItem(U.LOCAL_STORAGE.VELT_IDENTIFY_USER,t)}}catch(t){this.loggingService.catch("Error in setUserToStorage: ",t)}})}getUserFromStorage(e){return Q(this,null,function*(){try{let t=localStorage.getItem(U.LOCAL_STORAGE.VELT_IDENTIFY_USER);return t?yield X0(t,e?.userId??""):null}catch(t){return this.loggingService.catch("Error in getUserFromStorage: ",t),null}})}updateUserWithColorAndTextColor(e){return Q(this,null,function*(){try{let t=JSON.parse(JSON.stringify(e??{})),r=yield this.getUserFromStorage(t);return!r||Object.keys(r).length===0?(delete t?.color,delete t?.textColor,t):(r?.color&&(t.color=r?.color),r?.textColor&&(t.textColor=r?.textColor),t)}catch(t){return this.loggingService.catch("Error in updateUserWithColorAndTextColor: ",t),e}})}updateUserIfRequired(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserIfRequired","color: green;");try{let t=yield this.getUserFromStorage(e),r={};if(e.color&&e.color!==t?.color&&(r.color=e.color),e.textColor&&e.textColor!==t?.textColor&&(r.textColor=e.textColor),Object.keys(r).length>0&&e.clientOrganizationId){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));hd({data:{type:"addUserInfoToOrganization",metadata:{organizationId:e.clientOrganizationId},user:D(E({},r),{userId:e.userId})},getSdkProxy:a,userId:e?.userId??""})}}catch(t){this.loggingService.catch("Error in updateUserIfRequired: ",t)}})}initializeClient(e,t,r,a,s){return Q(this,null,function*(){try{if(this.autoLoginRequired=!1,this.userOptions$.next(t),this.initializeClientToken)this.pendingUserLogin=e,this.pendingUserLoginSource=s;else{e.userSnippylyId=eC(this.configService.getApiKey(),e.userId),this.pendingUserLogin=void 0,this.pendingUserLoginSource=void 0,this.initializeClientToken=r;let c=yield ei(this.afAuth).pipe(rt(1)).toPromise().catch(g=>null),p=!0;if(this.providedUser=JSON.parse(JSON.stringify(e)),c){let g=yield ed(c,!0).catch(T=>null);if(!g)return;let{user:f,firebaseConfig:I}=g.claims;if(c?.uid!==e?.userSnippylyId||e?.groupId!==f?.groupId||e?.organizationId!==f?.organizationId||t?.forceReset||!a&&e?.organizationId&&!this.forceReLoggedIn||this.forceReLoginRequiredForAdvancedQueries(e)||this.forceReLoginRequiredForRegion(e,I)||this.forceReLoginRequiredForCommentViews(e))localStorage.setItem(U.LOCAL_STORAGE.VELT_USER_FORCE_RE_LOGGED_IN,"true"),localStorage.setItem(U.LOCAL_STORAGE.VELT_COMMENT_VIEWS_MIGRATED,"true"),this.forceReLoggedIn=!0,yield this.signOutUser("internal");else{this.loggingService.log("%c[WB] Calling FUNCTION: reinitializeCurrentUser","color: green;"),this.loggingService.log("Keeping user");let T=yield ed(c,!0).catch(J=>null);if(!T)return;let{firebaseConfig:B,user:z,advancedQueries:G}=T.claims;yield this.updateUserIfRequired(e),this.validateOrganizationId(e),this.setFirebaseConfig(B),this.setAdvancedQueries(G),z&&(this.providedUser.isAdmin=!!z.isAdmin),this.initializeSignedInUser(c,a,e),p=!1,this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:"auto",forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s})}}if(p){this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_TRIGGERED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s},!0,e.userSnippylyId,e.userId);let g=Qi(this.functions,Ji({url:wn.cloudFunction.validateClient,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),f=_a(),I=(yield g({apiKey:this.apiKey,user:e,version:f,authToken:t?.authToken}))?.data;if(I.error){if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_FAILED,D(E({apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,message:I.error,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)},I),{source:s}),!0,e.userSnippylyId,e.userId),I.error&&typeof I.error=="string")if(I.error?.toLowerCase()?.includes("token expired"))if(this.tokenExpiredErrorCount++,this.tokenExpiredErrorCount<=this.TOKEN_EXPIRED_ERROR_COUNT_LIMIT){let T={code:"token_expired",message:"Token expired",error:I?.error,source:I?.source};this.coreActionsService.triggerAction(mt.ERROR,T)}else{let T={code:"too_many_retries",message:"Token expired. Too many retries.",error:I?.error,source:I?.source};this.coreActionsService.triggerAction(mt.ERROR,T),this.analyticsService.trackEvent(Y.Events.Core.SDK_JWT_EXPIRED_RETRY_EXCEEDED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,source:s},!0,e.userSnippylyId,e.userId)}else{let T=I;this.coreActionsService.triggerAction(mt.ERROR,T)}throw I}else this.tokenExpiredErrorCount=0;if(this.analyticsService.trackEvent(Y.Events.Core.SDK_VALIDATE_CLIENT_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e),source:s},!0,e.userSnippylyId,e.userId),this.validateOrganizationId(e),I.firebaseConfig){this.setFirebaseConfig(I.firebaseConfig),yield this.signInWithCustomToken(e,I.token),this.loggingService.log("new signed in user",this.afAuth.currentUser);let T=yield ed(this.afAuth.currentUser,!0).catch(G=>null);if(!T)return;let{user:B,advancedQueries:z}=T.claims;this.setAdvancedQueries(z),this.providedUser.isAdmin=!!B?.isAdmin,this.initializeSignedInUser(this.afAuth.currentUser,a,e)}}this.initializeClientToken=0,this.lastLoggedInUserData={user:e,userOptions:t,initializeClientToken:r,autoLogin:a},this.checkForPendingLogin()}return e}catch(c){return this.initializeClientToken=0,this.checkForPendingLogin(),this.loggingService.catch("Error in initializeClient: ",c),t?.throwError?Promise.reject(c):Promise.resolve(null)}})}isVersionGreaterThanOrEqualTo4(){try{let e=_a();return(e?parseInt(e.split(".")?.[0]||"0"):0)>=4}catch(e){return this.loggingService.catch("Error in isVersionGreaterThanOrEqualTo4: ",e),!1}}isVersion4Point5(){try{let e=_a();if(e){let t=e.split("."),r=parseInt(t[0]||"0"),a=parseInt(t[1]||"0"),s=parseInt(t[2]||"0");if(r>=4&&a>=5)return r===4&&a===5&&s===0?!e.toLowerCase().includes("beta"):!0}return!1}catch(e){return this.loggingService.catch("Error in isVersion4Point5: ",e),!1}}forceReLoginRequiredForAdvancedQueries(e){try{let t=this.isVersionGreaterThanOrEqualTo4(),r=!1;try{let a=localStorage.getItem(U.LOCAL_STORAGE.VELT_ADVANCED_QUERIES);a&&(r=JSON.parse(a)?.advancedQueriesEnabled)}catch(a){this.loggingService.catch("Error in forceReLoginRequiredForAdvancedQueries: ",a)}return!!(t&&e.organizationId&&!r)}catch(t){return this.loggingService.catch("Error in forceReLoginRequiredForAdvancedQueries: ",t),!1}}forceReLoginRequiredForCommentViews(e){try{let t=this.isVersion4Point5(),r=!1;try{let a=localStorage.getItem(U.LOCAL_STORAGE.VELT_COMMENT_VIEWS_MIGRATED);a&&(r=JSON.parse(a))}catch(a){this.loggingService.catch("Error in forceReLoginRequiredForCommentViews: ",a)}return!!(t&&e.organizationId&&!r)}catch(t){return this.loggingService.catch("Error in forceReLoginRequiredForCommentViews: ",t),!1}}forceReLoginRequiredForRegion(e,t){try{return!!(this.isVersionGreaterThanOrEqualTo4()&&e.organizationId&&!t?.region)}catch(r){return this.loggingService.catch("Error in forceReLoginRequiredForRegion: ",r),!1}}checkForPendingLogin(){this.pendingUserLogin&&this.initializeClient(this.pendingUserLogin,this.userOptions$?.value||{},new Date().getTime(),void 0,this.pendingUserLoginSource)}setFirebaseConfig(e){this.loggingService.log("%c[WB] Calling FUNCTION: setFirebaseConfig","color: green;");try{this.firebaseConfig$.value||this.firebaseConfig$.next({firebaseOptions:E(E({},wn.firebaseConfig),e)})}catch(t){this.loggingService.catch("Error in setFirebaseConfig: ",t)}}getFirebaseConfig$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirebaseConfig","color: green;"),this.firebaseConfig$.asObservable()}getFirebaseConfig(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirebaseConfig","color: green;"),this.firebaseConfig$.value}setAdvancedQueries(e){this.loggingService.log("%c[WB] Calling FUNCTION: setAdvancedQueries","color: green;");try{e&&typeof e=="object"&&localStorage.setItem(U.LOCAL_STORAGE.VELT_ADVANCED_QUERIES,JSON.stringify(e)),this.advancedQueries$.next(e)}catch(t){this.loggingService.catch("Error in setAdvancedQueries: ",t)}}getAdvancedQueries$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAdvancedQueries$","color: green;"),this.advancedQueries$.asObservable()}getAdvancedQueries(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAdvancedQueries","color: green;"),this.advancedQueries$.value}getAdvancedQueriesEnabled$(){return mn([this.configService.getConfig$(),this.getAdvancedQueries$()]).pipe(de(()=>this.getAdvancedQueriesEnabled()),Un(()=>le(!1)))}getAdvancedQueriesEnabled(){try{return!this.configService.getConfig()?.advancedQueriesDisabled&&!!this.getAdvancedQueries()?.advancedQueriesEnabled}catch(e){return this.loggingService.catch("Error in getAdvancedQueriesEnabled: ",e),!1}}signOutPreviousUser(){return this.signOutPreviousUser$.asObservable()}getUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.afAuth?.currentUser?this.user$.value:null}getUser$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUser$","color: green;"),ei(this.afAuth).pipe(he(e=>e?this.user$.asObservable():le(null)),Ct(Xt))}getAuthUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAuthUser","color: green;"),this.afAuth?.currentUser}getUserOptions(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOptions","color: green;"),this.userOptions$.value}getUserOptions$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOptions$","color: green;"),this.userOptions$.asObservable()}updateUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateUser","color: green;");try{let t=this.user$.value;if(e.userId&&e.userId!==t?.userId||e?.groupId&&e?.groupId!==t?.groupId||e?.organizationId&&e?.organizationId!==t?.organizationId)this.providedUser=e,this.initializeClient(e,this.userOptions$?.value||{},new Date().getTime(),void 0,"internal-updateUser");else if(this.providedUser=E(E({},this.providedUser),e),t){let r=E(E({},t),e);this.updateUserInternally(r)}}catch(t){this.loggingService.catch("Error in updateUser: ",t)}}signInWithCustomToken(e,t,r="manual"){this.loggingService.log("%c[WB] Calling FUNCTION: signInWithCustomToken","color: green;");try{return Sie(this.afAuth,t).then(a=>(this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_SUCCESS,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:r,forceReset:this.userOptions$.value?.forceReset,user:this.getUserWithoutContacts(e)}),a)).catch(a=>(this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_AUTH_FAILED,{apiKey:this.apiKey,clientUserId:e.userId,snippylyUserId:e.userSnippylyId,authType:r,forceReset:this.userOptions$.value?.forceReset,message:a.message,user:this.getUserWithoutContacts(e)}),a))}catch(a){return this.loggingService.catch("Error in signInWithCustomToken: ",a),Promise.reject(a)}}resetServicesCache(){this.loggingService.log("%c[WB] Calling FUNCTION: resetServicesCache in AuthService","color: green;");try{this.commonDbService?.unsubscribeFromObservables(),this.docService?.clearCacheOnUserCascade(),this.contactService?.clearCache(),this.iamService?.clearCache(),this.areaService?.clearCache(),this.commentService?.clearCache(),this.reactionService?.clearCache(),this.recorderAnnotationService?.clearCache(),this.viewsService?.clearCache()}catch(e){this.loggingService.catch("Error in resetServicesCache: ",e)}}initializeSignedInUser(e,t,r){this.loggingService.log("%c[WB] Calling FUNCTION: initializeSignedInUser","color: green;");try{let a=new zo;a.userSnippylyId=e.uid,a.type="signedIn",r&&(a=E(E({},a),r)),this.setUserToStorage(a),this.mergeUserWithProvidedUserData(a,t)}catch(a){this.loggingService.catch("Error in initializeSignedInUser: ",a)}}mergeUserWithProvidedUserData(e,t){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: mergeUserWithProvidedUserData","color: green;");try{e.userId=this.providedUser?.userId||e.userId;let r=null;if(this.usersService?.externalUserDataProviderAvailable()){let a=vt(),s=Rl.IDENTIFY;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:Hr.MERGE_USER_WITH_PROVIDED_USER_DATA,moduleName:s,source:"internal",payload:{userIds:[e.userId],organizationId:this.providedUser?.organizationId||e.organizationId}});let c=yield this.usersService.resolveUsers({userIds:[e.userId],organizationId:this.providedUser?.organizationId||e.organizationId,skipUserCheck:!0,uniqueId:a,moduleName:s});c&&c[e.userId]&&(r=JSON.parse(JSON.stringify(c[e.userId]||{}))),e=E(E({},e),r||{})}e.name=r?r?.name:this.providedUser?.name||e.name,e.clientUserName=r?r?.clientUserName:this.providedUser?.clientUserName||e.clientUserName,e.photoUrl=r?r?.photoUrl:this.providedUser?.photoUrl||e.photoUrl,e?.photoUrl===void 0&&(e.photoUrl=null),e.email=r?r?.email:this.providedUser?.email||e.email,e.color=r?.color||this.providedUser?.color||this.getUserAvatarColor(e.userId),e.textColor=r?.textColor||this.providedUser?.textColor||this.getUserTextColor(e.userId),e.initial=r?.initial||this.providedUser?.initial||e.initial||e.name?.charAt(0).toUpperCase()||e.email?.charAt(0).toUpperCase(),e.contacts=this.providedUser?.contacts||e.contacts,e.plan=this.providedUser?.plan||e.plan,e.groupId=this.providedUser?.groupId||e.groupId,e.clientGroupId=this.providedUser?.clientGroupId||e.clientGroupId,e.clientOrganizationId=this.providedUser?.clientOrganizationId||e.clientOrganizationId,e.organizationId=this.providedUser?.organizationId||e.organizationId,e.isAdmin=this.providedUser?.isAdmin,e.isReadOnly=this.providedUser?.isReadOnly,e.isAnonymous=this.providedUser?.isAnonymous,e.isGuest=this.providedUser?.isGuest,this.updateUserInternally(e)}catch(r){this.loggingService.catch("Error in mergeUserWithProvidedUserData: ",r)}})}updateUserInternally(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserInternally","color: green;");try{let t=Object.assign({},e);delete t.contacts,this.analyticsService.identifyUser(e.userSnippylyId,t,{forceReset:this.userOptions$.value?.forceReset}),this.getPlanDetailsCalled||this.getPlanDetailsFromDb();try{if(this.userPermissionService?.isPermissionProviderAvailable()&&e.clientOrganizationId){let r=[{userId:e.userId,resource:{id:e.clientOrganizationId,type:Fo.ORGANIZATION,source:Gi.IDENTIFY,organizationId:e.clientOrganizationId}}],a=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.IDENTIFY,uniqueId:a,timestamp:new Date().getTime(),source:"internal",payload:{requests:r}}),yield this.userPermissionService?.onResourceAccessRequired({requests:r,uniqueId:a,userId:e.userId,methodName:Gi.IDENTIFY,fromCache:!1})}}catch(r){this.loggingService.catch("Error in updateUserInternally: ",r)}this.afAuth.currentUser&&(this.user$.next(e),this.updateUserToFirebase(e))}catch(t){this.loggingService.catch("Error in updateUserInternally: ",t)}})}updateUserToFirebase(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserToFirebase","color: green;");try{let t=JSON.parse(JSON.stringify(e)),r=D(E({},t),{lastUpdated:new Date})}catch(t){this.loggingService.catch("Error in updateUserToFirebase: ",t)}}getPlanDetailsFromDb(){return Q(this,null,function*(){try{this.getPlanDetailsCalled=!0;let t=yield Qi(this.functions,Ji({url:wn.cloudFunction.getPlanDetails,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3})({apiKey:this.configService.getApiKey(),sdkVersion:_a(),sdkType:this.configService.getSdkType()});return t?.data?.isPlanExpired&&(this.analyticsService.trackEvent(Y.Events.Core.SDK_PLAN_EXPIRED),this.configService.getSF()||console.warn("Velt SDK plan has expired.")),this.planDetails$.next(t?.data||{planInfo:null,isPlanExpired:!1}),t}catch(e){return this.loggingService.catch("Error in getPlanDetailsFromDb: ",e),this.planDetails$.next({planInfo:null,isPlanExpired:!1}),Promise.resolve(null)}})}isPlanExpired$(){return this.planDetails$.pipe(Le(e=>!!e),de(e=>!!e?.isPlanExpired))}isPlanExpired(){return this.planDetails$.getValue()?.isPlanExpired}addPreSignOutFuction(e,t){try{this.preSignOutFunctions.set(e,t)}catch(r){this.loggingService.catch("Error in addPreSignOutFuction: ",r)}}setUserOrganization(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserOrganization","color: green;");let t=JSON.parse(JSON.stringify(this.userOrganization$.value||{}));this.getUser()?.organizationId===e?.organizationId?(t.metadata=e,this.userOrganization$.next(t)):this.userOrganization$.next(null)}catch(t){this.loggingService.catch("Error in setUserOrganization: ",t)}}setOrganizationUserGroups(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setUserOrganizationGroups","color: green;");let t=JSON.parse(JSON.stringify(this.userOrganization$.value||{}));this.getUser()?.organizationId===t?.metadata?.organizationId&&(t.groups=e,this.userOrganization$.next(t))}catch(t){this.loggingService.catch("Error in setUserOrganizationGroups: ",t)}}getUserOrganization$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getUserOrganization$","color: green;"),this.getUser$().pipe(he(e=>e?this.userOrganization$.asObservable().pipe(de(t=>t?.metadata?.organizationId===e.organizationId?t:null)):le(null)))}signOutUser(e="internal"){return Q(this,null,function*(){try{e==="external"&&this.onRetrySubscription?.unsubscribe(),this.userPermissionService?.revokeAccessOnUserLogout(),yield this.analyticsService.trackEvent(Y.Events.Core.SDK_USER_SIGN_OUT,{apiKey:this.apiKey,clientUserId:this.user$?.value?.userId,snippylyUserId:this.user$?.value?.userSnippylyId,message:e==="external"?"User Sign out":"System Sign out",user:this.user$?.value?this.getUserWithoutContacts(this.user$?.value):null,forceReset:this.userOptions$.value?.forceReset,source:e});let t=yield ei(this.afAuth).pipe(rt(1)).toPromise().catch(r=>null);if(t){this.resetServicesCache(),this.user$.next(null);for(let[r,a]of this.preSignOutFunctions)try{yield a(t)}catch(s){this.loggingService.catch(`Error in signOutUser ${r} function: `,s)}return this.user$.next(null),yield pm(1e3),bie(this.afAuth).catch(r=>{this.loggingService.catch("Error in signOutUser:",r)})}else return Promise.resolve()}catch(t){this.loggingService.catch("Error in signOutUser: ",t)}})}isFeatureAllowed(e){return ro(this.config,this.user$.value,e)}getUserWithoutContacts(e){try{if(e){let t=JSON.parse(JSON.stringify(e));return delete t.contacts,t}else return null}catch(t){return this.loggingService.catch("Error in getUserWithoutContacts: ",t),null}}getUserForClient(e){try{return Dr(e)}catch(t){return this.loggingService.catch("Error in getUserForClient: ",t),null}}getUserAvatarColor(e){try{return e?this.avatarService.generateUserColor(Nn(e)):"#625DF5"}catch{return"#625DF5"}}getUserTextColor(e){try{return"#FFFFFF"}catch{return"#FFFFFF"}}setOptionalPropertiesToUsers(e){try{e.forEach(t=>{try{t?.color||(t.color=this.getUserAvatarColor(t?.userId)),t?.textColor||(t.textColor=this.getUserTextColor(t?.userId)),!t?.initial&&(t?.name||t?.email)&&(t.initial=t.name?.charAt(0).toUpperCase()||t.email?.charAt(0).toUpperCase())}catch{}})}catch{}}};o.\u0275fac=function(t){return new(t||o)(ee(Ri),ee(Ft),ee(ym),ee(ni),ee(Be),ee(Do),ee(Qe),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Sm=class{constructor({apiKey:o,documentId:n,organizationId:e,folderId:t,veltFolderId:r,clientDocumentId:a,clientOrganizationId:s}){this.paths={},this.apiKey=o,this.documentId=n,this.organizationId=e,this.folderId=t,this.veltFolderId=r,this.clientDocumentId=a,this.clientOrganizationId=s,a&&(this.documentId=Tr(a)),s&&(this.organizationId=os(s)),t&&(this.folderId=t,this.veltFolderId=Ai(t)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let o=`${this.apiKey}`;this.organizationId&&(o=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`),this.documentId&&(this.paths.docs=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.folder=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}/`,this.paths.presence=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_PRESENCE}/`,this.paths.cursor=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CURSOR}/`,this.paths.comment=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/`,this.paths.multiThread=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,this.paths.tag=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_TAG}/`,this.paths.area=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AREA}/`,this.paths.arrow=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_ARROW}/`,this.paths.selection=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_SELECTION}/`,this.paths.audioHuddle=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,this.paths.huddle=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_HUDDLE}/`,this.paths.recorder=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/`,this.paths.flock=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,this.paths.syncVideoPlayer=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,this.paths.liveState=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,this.paths.liveStateSingleEditorMode=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,this.paths.reaction=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_REACTION}/`,this.paths.crdt=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CRDT}/`,this.paths.views=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_VIEWS}/`,this.paths.notifications=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,this.paths.metadata=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_METADATA}/`,this.paths.users=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.documentIam=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.userConfig=`${o}/${U.FIREBASE_PARTIAL_PATH_USERS}`),this.paths.customerMetadata=`${o}/${U.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,this.paths.groupContacts=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GROUPS}/`,this.paths.globalContacts=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GLOBAL}/`,this.paths.logins=`${o}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_LOGINS}/`,this.paths.userFeedback=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,this.paths.userReportBugs=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_BUGS}/`,this.paths.userContactUs=`${o}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,this.organizationId&&(this.paths.organizationMetadata=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,this.paths.organizationIam=`${o}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.organizationGroups=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,this.paths.organizationNotifications=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,this.documentId&&(this.paths.organizationNotificationsWithDocumentId=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/`,this.paths.heartbeatByDocument=`${o}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${this.documentId}/`),this.paths.organizationNotificationsLastNotificationTimestamp=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.organizationNotificationsUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.heartbeat=`${o}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),this.paths.workspaceIam=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_IAM}/`}}catch{}}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("User config path is not available.")}get workspaceIam(){return this.paths.workspaceIam?this.paths.workspaceIam:this.throwError("Workspace IAM path is not available.")}get docs(){return this.paths.docs?this.paths.docs:this.throwError("Docs path is not available.")}get presence(){return this.paths.presence?this.paths.presence:this.throwError("Presence path is not available.")}get cursor(){return this.paths.cursor?this.paths.cursor:this.throwError("Cursor path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get arrow(){return this.paths.arrow?this.paths.arrow:this.throwError("Arrow path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get tag(){return this.paths.tag?this.paths.tag:this.throwError("Tag path is not available.")}get selection(){return this.paths.selection?this.paths.selection:this.throwError("Selection path is not available.")}get audioHuddle(){return this.paths.audioHuddle?this.paths.audioHuddle:this.throwError("Audio huddle path is not available.")}get huddle(){return this.paths.huddle?this.paths.huddle:this.throwError("Huddle path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get flock(){return this.paths.flock?this.paths.flock:this.throwError("Flock path is not available.")}get syncVideoPlayer(){return this.paths.syncVideoPlayer?this.paths.syncVideoPlayer:this.throwError("Sync video player path is not available.")}get liveState(){return this.paths.liveState?this.paths.liveState:this.throwError("Live state path is not available.")}get liveStateSingleEditorMode(){return this.paths.liveStateSingleEditorMode?this.paths.liveStateSingleEditorMode:this.throwError("Live state single editor mode path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}get views(){return this.paths.views?this.paths.views:this.throwError("Views path is not available.")}get notifications(){return this.paths.notifications?this.paths.notifications:this.throwError("Notifications path is not available.")}get metadata(){return this.paths.metadata?this.paths.metadata:this.throwError("Metadata path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get documentIam(){return this.paths.documentIam?this.paths.documentIam:this.throwError("Document IAM path is not available.")}get organizationMetadata(){return this.paths.organizationMetadata?this.paths.organizationMetadata:this.throwError("Organization metadata path is not available.")}get organizationIam(){return this.paths.organizationIam?this.paths.organizationIam:this.throwError("Organization IAM path is not available.")}get customerMetadata(){return this.paths.customerMetadata?this.paths.customerMetadata:this.throwError("Customer metadata path is not available.")}get groupContacts(){return this.paths.groupContacts?this.paths.groupContacts:this.throwError("Group contacts path is not available.")}get globalContacts(){return this.paths.globalContacts?this.paths.globalContacts:this.throwError("Global contacts path is not available.")}get logins(){return this.paths.logins?this.paths.logins:this.throwError("Logins path is not available.")}get userFeedback(){return this.paths.userFeedback?this.paths.userFeedback:this.throwError("User feedback path is not available.")}get userReportBugs(){return this.paths.userReportBugs?this.paths.userReportBugs:this.throwError("User report bugs path is not available.")}get userContactUs(){return this.paths.userContactUs?this.paths.userContactUs:this.throwError("User contact us path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("Organization groups path is not available.")}get heartbeat(){return this.paths.heartbeat?this.paths.heartbeat:this.throwError("Heartbeat path is not available.")}get heartbeatByDocument(){return this.paths.heartbeatByDocument?this.paths.heartbeatByDocument:this.throwError("Heartbeat by document path is not available.")}get organizationNotifications(){return this.paths.organizationNotifications?this.paths.organizationNotifications:this.throwError("Organization notifications path is not available.")}get organizationNotificationsWithDocumentId(){return this.paths.organizationNotificationsWithDocumentId?this.paths.organizationNotificationsWithDocumentId:this.throwError("Organization notifications with document id path is not available.")}get organizationNotificationsUsers(){return this.paths.organizationNotificationsUsers?this.paths.organizationNotificationsUsers:this.throwError("Organization notifications users path is not available.")}get organizationNotificationsLastNotificationTimestamp(){return this.paths.organizationNotificationsLastNotificationTimestamp?this.paths.organizationNotificationsLastNotificationTimestamp:this.throwError("Organization notifications last notification timestamp path is not available.")}throwError(o){throw{type:"DocumentPaths",message:o,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var _9=class{constructor({apiKey:o,documentId:n,organizationId:e,clientDocumentId:t,clientOrganizationId:r,folderId:a,veltFolderId:s}){this.paths={},this.apiKey=o,this.documentId=n,this.organizationId=e,this.veltFolderId=s,t&&(this.documentId=Tr(t)),r&&(this.organizationId=os(r)),a&&(this.folderId=a,this.veltFolderId=Ai(a)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let o=`apiKey/${this.apiKey}`;this.organizationId&&(o=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`,this.paths.organization=o,this.paths.folder=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}`,this.paths.organizationUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,this.paths.users=`${o}/${U.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,this.paths.notificationDocs=`${o}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,this.paths.notificationUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.paths.organizationGroups=`${o}/${U.FIREBASE_PARTIAL_PATH_GROUPS}`,this.paths.lastNotificationTimestamp=`${o}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}`,this.paths.userConfig=`${o}/${U.FIREBASE_PARTIAL_PATH_USERS}`,this.paths.permissionsUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_PERMISSIONS_USERS}`),this.veltFolderId&&(this.paths.folderUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_FOLDERS}/${this.veltFolderId}/${U.FIREBASE_PARTIAL_PATH_FOLDER_USERS}`),this.documentId&&(this.paths.document=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}`,this.paths.comment=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_COMMENT}`,this.paths.location=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LOCATION}`,this.paths.multiThread=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,this.paths.area=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_AREA}`,this.paths.recorder=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`,this.paths.reaction=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_REACTION}`,this.paths.crdt=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_CRDT}`,this.paths.notificationViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,this.paths.documentViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,this.paths.locationViews=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,this.paths.documentUsers=`${o}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,this.paths.docNotification=`${this.paths.notificationDocs}/${this.documentId}/${U.FIREBASE_PARTIAL_PATH_DOC_NOTIFICATION}`)}}catch{}}get permissionsUsers(){return this.paths.permissionsUsers?this.paths.permissionsUsers:this.throwError("PermissionsUsers path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("UserConfig path is not available.")}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get lastNotificationTimestamp(){return this.paths.lastNotificationTimestamp?this.paths.lastNotificationTimestamp:this.throwError("LastNotificationTimestamp path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("organizationGroups path is not available.")}get docNotification(){return this.paths.docNotification?this.paths.docNotification:this.throwError("DocNotification path is not available.")}get organization(){return this.paths.organization?this.paths.organization:this.throwError("Organization path is not available.")}get document(){return this.paths.document?this.paths.document:this.throwError("Document path is not available.")}get location(){return this.paths.location?this.paths.location:this.throwError("Location path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get documentViews(){return this.paths.documentViews?this.paths.documentViews:this.throwError("DocumentViews path is not available.")}get locationViews(){return this.paths.locationViews?this.paths.locationViews:this.throwError("LocationViews path is not available.")}get notificationViews(){return this.paths.notificationViews?this.paths.notificationViews:this.throwError("NotificationViews path is not available.")}get documentUsers(){return this.paths.documentUsers?this.paths.documentUsers:this.throwError("DocumentUsers path is not available.")}get folderUsers(){return this.paths.folderUsers?this.paths.folderUsers:this.throwError("FolderUsers path is not available.")}get organizationUsers(){return this.paths.organizationUsers?this.paths.organizationUsers:this.throwError("OrganizationUsers path is not available.")}get notificationDocs(){return this.paths.notificationDocs?this.paths.notificationDocs:this.throwError("NotificationDocs path is not available.")}get notificationUsers(){return this.paths.notificationUsers?this.paths.notificationUsers:this.throwError("NotificationUsers path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}throwError(o){throw{type:"DocumentPaths",message:o,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var y9=class{};var In=(()=>{let o=class o{constructor(e,t){this.authService=e,this.loggingService=t,this.db$=new Ce(null);try{this.authService.getFirebaseConfig$().subscribe(r=>{r&&this.db$.next(wM(void 0,r.firebaseOptions.databaseURL))},r=>{this.loggingService.catch("Error in DatabaseService constructor: ",r)})}catch(r){this.loggingService.catch("Error in DatabaseService constructor:",r)}}getDb(){return this.db$.asObservable()}getDbValue(){return this.db$.getValue()}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var nl=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.commentAnnotationDataProvider$=new Ce(null),this.commentAnnotationById$=new Ce({}),this.fieldsToRemove=[],this.getCommentAnnotationById=a=>{try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.value?.[a]:void 0}catch(s){this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationById:",s);return}};try{this.loggingService.log("CommentAnnotationsResolverService initialized"),this.commentAnnotationDataProvider$.subscribe(a=>{a&&(a.config?.resolveTimeout&&(this.resolveTimeout=a.config.resolveTimeout),a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig),a.config?.getRetryConfig&&(this.retryGetConfig=a.config.getRetryConfig),a.config?.fieldsToRemove&&(this.fieldsToRemove=a.config.fieldsToRemove))})}catch(a){this.loggingService.catch("Error in CommentAnnotationsResolverService constructor:",a)}}getProvider(){try{let e=this.commentAnnotationDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService getProvider:",e);return}}ngOnDestroy(){try{this.commentAnnotationById$.next({})}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService ngOnDestroy:",e)}}resolveCommentAnnotations(a){return Q(this,arguments,function*({request:e,uniqueId:t,moduleName:r}){try{if(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: resolveCommentAnnotations","color: green;"),!this.commentAnnotationDataProviderAvailable())return{};let s,c=!1,p=!1,g=()=>{s&&(clearTimeout(s),s=void 0,p=!0)};return new Promise((f,I)=>{s=setTimeout(()=>{if(!p){c=!0,g();let ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:new Error("Comment annotation resolution timeout"),request:e}}),I(new Error("Comment annotation resolution timeout"))}},this.commentAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let T=this.getProvider();if(!T)return g(),f({});let B={},z=[...new Set(e.commentAnnotationIds||[])],G=D(E({},e),{commentAnnotationIds:z});Q(this,null,function*(){try{if(z.length>0||e.documentIds?.length||e.folderId){let ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{request:G}});let ve=ud(()=>T?.get(G)||Promise.resolve(void 0),"getCommentAnnotations",this.retryGetConfig).then(ye=>c?{}:(g(),ye&&ye.statusCode!==200?(this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),this.loggingService.catch(ye?.message??"Error in CommentAnnotationsResolverService resolveCommentAnnotations:"),{}):ye?.data)).catch(ye=>{throw g(),ye});try{B=(yield ve)||{},this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_GET,{sourceMethod:"resolveCommentAnnotations",source:"sdk",commentAnnotationIds:z});let ye={};Object.entries(B).forEach(([Ne,Ve])=>{let Ie=this.commentAnnotationById$.value?.[Ne];Ie?Ie&&JSON.stringify(Ie)!==JSON.stringify(Ve)&&(ye[Ne]=Ve):ye[Ne]=Ve}),Object.keys(ye).length>0&&this.commentAnnotationById$.next(E(E({},this.commentAnnotationById$.getValue()),ye)),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),f(ye)}catch(ye){let Ne=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:Ne,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ye,request:G}}),c||I(ye),f(B)}}else g(),f({})}catch(ne){g();let ve=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ve,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ne,request:G}}),I(ne)}})})}catch(s){this.loggingService.catch("Error in CommentAnnotationsResolverService resolveCommentAnnotations:",s);let c=t||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:s,request:e}}),{}}})}saveCommentAnnotation(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: saveCommentAnnotation","color: green;");let r=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{request:e}});let s=JSON.parse(JSON.stringify(this.commentAnnotationById$.getValue()));this.commentAnnotationById$._value=E(E({},s),e.commentAnnotation);let c=yield ud(()=>r?.save({commentAnnotation:e.commentAnnotation,event:e.eventType,commentId:e.commentId,metadata:Object.values(e.commentAnnotation??{})?.[0]?.metadata})||Promise.resolve(void 0),"saveCommentAnnotation",this.retrySaveConfig);return c&&c.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.commentAnnotationById$._value=s),this.loggingService.catch(c?.message??"Error in CommentAnnotationsResolverService saveCommentAnnotation:"),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:c,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_SAVE,{sourceMethod:"saveCommentAnnotation",source:"sdk",commentAnnotationIds:Object.keys(e.commentAnnotation),eventType:e.eventType,commentId:e.commentId}),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in CommentAnnotationsResolverService saveCommentAnnotation:",r);let a=t||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:No.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:r,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteCommentAnnotation(e,t,r){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: deleteCommentAnnotation","color: green;");let a=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation delete data provider not available");let s=r||vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{commentAnnotationId:e.toString(),metadata:t}});let c=this.commentAnnotationById$.getValue(),p=E({},c);delete p?.[e],this.commentAnnotationById$._value=p;let g=yield ud(()=>a?.delete({commentAnnotationId:e.toString(),metadata:t,event:va.COMMENT_ANNOTATION_DELETE})||Promise.resolve(void 0),"deleteCommentAnnotation",this.retryDeleteConfig);return g&&g.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.commentAnnotationById$._value=c),this.loggingService.catch(g?.message??"Error in CommentAnnotationsResolverService deleteCommentAnnotation:"),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:g,commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.COMMENT_RESOLVER_DELETE,{sourceMethod:"deleteCommentAnnotation",source:"sdk",commentAnnotationId:e.toString()}),this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(a){this.loggingService.warn("Error in CommentAnnotationsResolverService deleteCommentAnnotation:",a);let s=r||vt();return this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:No.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:a,commentAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getCommentAnnotationsById$(){try{return this.commentAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: getCommentAnnotationsById$","color: green;"),this.commentAnnotationById$.asObservable()):le(void 0)}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationsById$:",e),le(void 0)}}getAnnotationById(e){try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.getValue()?.[e]:void 0}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService getAnnotationById:",t);return}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService getFieldsToRemove:",e),this.fieldsToRemove}}setCommentAnnotationDataProvider(e){try{if(e){this.loggingService.log("Setting comment annotation data provider");let r=["get","save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.comment is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.commentAnnotationDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService setCommentAnnotationDataProvider:",t)}}commentAnnotationDataProviderAvailable(){try{return!!this.commentAnnotationDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in CommentAnnotationsResolverService commentAnnotationDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var bm=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.reactionAnnotationDataProvider$=new Ce(null),this.reactionAnnotationById$=new Ce({}),this.getReactionAnnotationById=a=>{try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.value?.[a]:void 0}catch(s){this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationById:",s);return}};try{this.loggingService.log("ReactionAnnotationsResolverService initialized"),this.reactionAnnotationDataProvider$.subscribe(a=>{a&&(a.config?.resolveTimeout&&(this.resolveTimeout=a.config.resolveTimeout),a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig),a.config?.getRetryConfig&&(this.retryGetConfig=a.config.getRetryConfig))})}catch(a){this.loggingService.catch("Error in ReactionAnnotationsResolverService constructor:",a)}}getProvider(){try{let e=this.reactionAnnotationDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService getProvider:",e);return}}ngOnDestroy(){try{this.reactionAnnotationById$.next({})}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService ngOnDestroy:",e)}}resolveReactionAnnotations(a){return Q(this,arguments,function*({request:e,uniqueId:t,moduleName:r}){try{if(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: resolveReactionAnnotations","color: green;"),!this.reactionAnnotationDataProviderAvailable())return{};let s,c=!1,p=!1,g=()=>{s&&(clearTimeout(s),s=void 0,p=!0)};return new Promise((f,I)=>{s=setTimeout(()=>{if(!p){c=!0,g();let ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:new Error("Reaction annotation resolution timeout"),request:e}}),I(new Error("Reaction annotation resolution timeout"))}},this.reactionAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let T=this.getProvider();if(!T)return g(),f({});let B={},z=[...new Set(e.reactionAnnotationIds||[])],G=D(E({},e),{reactionAnnotationIds:z});Q(this,null,function*(){try{if(z.length>0||e.documentIds?.length||e.folderId){let ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{request:G}});let ve=ud(()=>T?.get(G)||Promise.resolve(void 0),"getReactionAnnotations",this.retryGetConfig).then(ye=>c?{}:(g(),ye&&ye.statusCode!==200?(this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),this.loggingService.catch(ye?.message??"Error in ReactionAnnotationsResolverService resolveReactionAnnotations:"),{}):ye?.data)).catch(ye=>{throw g(),ye});try{B=(yield ve)||{},this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_GET,{sourceMethod:"resolveReactionAnnotations",source:"sdk",reactionAnnotationIds:z});let ye={};Object.entries(B).forEach(([Ne,Ve])=>{let Ie=this.reactionAnnotationById$.value?.[Ne];Ie?Ie&&JSON.stringify(Ie)!==JSON.stringify(Ve)&&(ye[Ne]=Ve):ye[Ne]=Ve}),Object.keys(ye).length>0&&this.reactionAnnotationById$.next(E(E({},this.reactionAnnotationById$.getValue()),ye)),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{result:ye,request:G}}),f(ye)}catch(ye){let Ne=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:Ne,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ye,request:G}}),c||I(ye),f(B)}}else g(),f({})}catch(ne){g();let ve=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:ve,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:ne,request:G}}),I(ne)}})})}catch(s){this.loggingService.catch("Error in ReactionAnnotationsResolverService resolveReactionAnnotations:",s);let c=t||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:r,source:"internal",payload:{error:s,request:e}}),{}}})}saveReactionAnnotation(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: saveReactionAnnotation","color: green;");let r=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{request:e}});let s=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue()));this.reactionAnnotationById$._value=E(E({},s),e);let c={reactionAnnotation:e,event:va.REACTION_ADD,metadata:Object.values(e??{})?.[0]?.metadata},p=yield ud(()=>r?.save(c)||Promise.resolve(void 0),"saveReactionAnnotation",this.retrySaveConfig);return p&&p.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.reactionAnnotationById$._value=s),this.loggingService.catch(p?.message??"Error in ReactionAnnotationsResolverService saveReactionAnnotation:"),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:p,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_SAVE,{sourceMethod:"saveReactionAnnotation",source:"sdk",reactionAnnotationIds:Object.keys(e),eventType:c.event}),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in ReactionAnnotationsResolverService saveReactionAnnotation:",r);let a=t||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:r,request:e}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteReactionAnnotation(e,t,r){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: deleteReactionAnnotation","color: green;");let a=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation delete data provider not available");let s=r||vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{reactionAnnotationId:e.toString(),metadata:t}});let c=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue())),p=E({},c);delete p?.[e],this.reactionAnnotationById$._value=p;let g=yield ud(()=>a?.delete({reactionAnnotationId:e.toString(),metadata:t,event:va.REACTION_DELETE})||Promise.resolve(void 0),"deleteReactionAnnotation",this.retryDeleteConfig);return g&&g.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.reactionAnnotationById$._value=c),this.loggingService.catch(g?.message??"Error in ReactionAnnotationsResolverService deleteReactionAnnotation:"),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:g,reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.REACTION_RESOLVER_DELETE,{sourceMethod:"deleteReactionAnnotation",source:"sdk",reactionAnnotationId:e.toString()}),this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(a){this.loggingService.warn("Error in ReactionAnnotationsResolverService deleteReactionAnnotation:",a);let s=r||vt();return this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:Ho.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:a,reactionAnnotationId:e.toString(),metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getReactionAnnotationsById$(){try{return this.reactionAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: getReactionAnnotationsById$","color: green;"),this.reactionAnnotationById$.asObservable()):le(void 0)}catch(e){return this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationsById$:",e),le(void 0)}}getAnnotationById(e){try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.getValue()?.[e]:void 0}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService getAnnotationById:",t);return}}setReactionAnnotationDataProvider(e){try{if(e){this.loggingService.log("Setting reaction annotation data provider");let r=["get","save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.reaction is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.reactionAnnotationDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService setReactionAnnotationDataProvider:",t)}}reactionAnnotationDataProviderAvailable(){try{return!!this.reactionAnnotationDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in ReactionAnnotationsResolverService reactionAnnotationDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ot=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I){this.analyticsService=e,this.authService=t,this.databaseService=r,this.domService=a,this.configService=s,this.loggingService=c,this.commentResolverService=p,this.reactionResolverService=g,this.coreActionsService=f,this.functions=I,this.documentPaths$=new Ce(null),this.docContext$=new Ce(null),this.documentIds$=new Ce([]),this.organizationConfig$=new Ce(null),this.firestorePaths$=new Ce(null),this.location$=new Ce(null),this.excludedLocationIds$=new Ce([]),this.organizationMetadata$=new Ce(null),this.documentMetadata$=new Ce(null),this.locationMetadata$=new Ce(null),this.customerMetadata$=new Ce(null),this.currentDocumentId=null,this.isCustomDocId=!1,this.locations$=new Ce({}),this.preDocumentIdChangeFunctions=new Map,this.draftDocuments=[],this.clientDocumentMetadataMap={},this.uiState=new Ce({}),this.lastSetDocumentIdExecutionTime=0,this.lastSetDocumentIdCallTime=0,this.setDocumentIdSubject=new Xe,this.DEBOUNCE_TIME=5e3,this.MAX_QUEUE_SIZE=100,this.queueSize=0,this.isDocumentIdInDebounceQueue=!1,this.currentValidationToken=null,this.draftLocationMap={locations:[],options:void 0};try{this.loggingService.log("%c[WB] Creating CLASS: DocService","color: blue;"),this.domService.setDocService(this),this.authService.setDocService(this),this.setDocumentIdSubject.pipe(Bi(this.DEBOUNCE_TIME)).subscribe({next:T=>Q(this,null,function*(){try{yield this.setDocumentIdImpl(T.documentId,T.clientOrganizationId,T.options),this.lastSetDocumentIdExecutionTime=Date.now(),this.isDocumentIdInDebounceQueue=!1,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"})),this.draftLocationMap={locations:[],options:void 0}}finally{this.queueSize--}}),error:T=>{this.loggingService.catch("Error in setDocumentId subscription:",T),this.queueSize--}}),this.databaseService.getDb().pipe(Le(T=>!!T),rt(1)).subscribe(T=>{T&&(this.db=T)}),this.configService.getApiKey$().subscribe(T=>{if(this.apiKey=T,this.apiKey){if(!this.isCustomDocId){let B=Hk(window.location.href);this.currentUrl=B}this.analyticsService.updateDefaultProperties({apiKey:T})}}),this.authService.getUser$().subscribe(T=>Q(this,null,function*(){if(T&&(this.analyticsService.updateDefaultProperties({organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId}),this.draftDocuments?.length?(yield this.setDocuments({documents:this.draftDocuments,options:this.draftOptions??void 0,source:"internal"}),this.draftDocuments=[],this.draftOptions=void 0,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"}).then(()=>this.draftLocationMap={locations:[],options:void 0}))):this.documentPaths$?.value&&T?.organizationId&&this.documentPaths$.value?.organizationId!==T?.organizationId&&(yield this.setDocuments({documents:this.documentIds$.value.length?this.documentIds$.value.map(B=>({id:B.clientDocumentId})):[{id:this.documentPaths$.value?.clientDocumentId}],options:void 0,source:"internal"})),setTimeout(()=>{this.documentPaths$.value||this.loggingService.catch("Error in DocService constructor:","Please set document id to continue.")},1e4),T?.organizationId&&T?.clientOrganizationId)){let B={organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId};this.getOrganizationConfig()||this.organizationConfig$.next({organizationId:T?.organizationId,clientOrganizationId:T?.clientOrganizationId}),yield this.updateOrganizationMetadata(B)}})),this.documentPaths$.subscribe(T=>{let B={documentId:T?.documentId,clientDocumentId:T?.clientDocumentId,folderId:T?.folderId,allDocuments:T?.allDocuments,veltFolderId:T?.veltFolderId};T?.organizationId&&(B.organizationId=T.organizationId,B.clientOrganizationId=T.clientOrganizationId),this.analyticsService.updateDefaultProperties(B),this.domService.resetSelectedAnnotationsMap()}),this.location$.subscribe(T=>{this.analyticsService.updateDefaultProperties({clientLocation:T?.location,locationId:T?.locationId})}),this.organizationMetadata$.subscribe(T=>{this.authService.setUserOrganization(T?.[this.documentPaths$.value?.organizationId])}),this.documentPaths$.pipe(Le(T=>!!T),rt(1)).subscribe(()=>{try{this.subscribeToCustomerMetadata()}catch(T){this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",T)}},T=>{this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",T)}),this.loggingService.log("%c[WB] Creating CLASS: DocService 2","color: blue;"),this.onWindowPopstate(),this.onWindowClick()}catch(T){this.loggingService.catch("Error in DocService constructor:",T)}}getOptionsFromDocumentPaths(){try{return this.documentPaths$.value?{folderId:this.documentPaths$.value?.folderId,allDocuments:this.documentPaths$.value?.allDocuments,locationId:this.documentPaths$.value?.locationId,organizationId:this.documentPaths$.value?.clientOrganizationId}:null}catch(e){return this.loggingService.catch("Error in getOptionsFromDocumentPaths:",e),null}}clearCacheOnUserCascade(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCacheOnUserCascade in DocService","color: green;");try{this.organizationConfig$.next(null),this.organizationMetadata$.next(null),this.customerMetadata$.next(null),this.customerMetadataSubscription?.unsubscribe(),this.documentPaths$.value&&(this.draftOptions=this.getOptionsFromDocumentPaths(),this.draftLocationMap={locations:[this.location$.value?.location??null,...Object.values(this.locations$.value||{}).map(e=>e.location)].filter(e=>e!==null),options:{rootLocationId:this.location$.value?.location?.id}},this.currentDocumentId=null,this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.unsetDocuments({source:"internal"})}catch(e){this.loggingService.catch("Error in DocService clearCacheOnUserCascade: ",e)}}setCommonDbService(e){try{this.commonDbService=e}catch(t){this.loggingService.catch("Error in setCommonDbService:",t)}}setUserPermissionService(e){try{this.userPermissionService=e}catch(t){this.loggingService.catch("Error in setUserPermissionService:",t)}}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in setCommentService:",t)}}onWindowPopstate(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowPopstate","color: green;");try{this.domService.onWindowPopState$().subscribe(()=>{this.loggingService.log("location",location.href);let e=Hk(location.href);this.currentUrl!==e&&(this.currentUrl=e,!this.isCustomDocId&&this.apiKey&&this.loggingService.log("current url in doc service",this.currentUrl))},e=>{this.loggingService.catch("Error in DocService onWindowPopstate subscription: ",e)})}catch(e){this.loggingService.catch("Error in onWindowPopstate: ",e)}}onWindowClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowClick","color: green;");try{this.domService.onWindowClick$().subscribe(()=>{let e=Hk(location.href);this.currentUrl!==e&&(this.currentUrl=e,this.isCustomDocId||this.loggingService.log("current url in doc service",this.currentUrl))},e=>{this.loggingService.catch("Error in DocService onWindowClick subscription: ",e)})}catch(e){this.loggingService.catch("Error in onWindowClick: ",e)}}setDocument(s){return Q(this,arguments,function*({documentId:e,documentMetadata:t,options:r,source:a="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocument","color: green;"),a==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:e,documentMetadata:t,methodName:"setDocument",source:a}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENTS,source:a,payload:{documentId:e,documentMetadata:t,options:r}}),yield this.setDocumentsImpl({documents:[{id:e,metadata:t}],options:E({organizationId:t?.organizationId},r??{}),source:a})}catch(c){this.loggingService.catch("Error in DocService setDocument:",c)}})}shouldSetDocumentsAgain(e,t={}){try{this.loggingService.log("%c[WB] Calling FUNCTION: shouldSetDocumentsAgain","color: green;");let r=this.documentPaths$.value?.clientDocumentId,a=t?.rootDocumentId??e[0]?.id,s=this.documentIds$.value.map(g=>g.clientDocumentId),c=lz(this.getOptionsFromDocumentPaths()??{})??{};return!e.every(g=>s.includes(g.id))||!hi(c,t)||r!==a}catch(r){return this.loggingService.catch("Error in DocService shouldSetDocumentsAgain:",r),!0}}getDocumentIdsFromDocuments({documents:e,setClientDocumentMetadataMap:t=!1}){try{let r=[];return e.forEach(a=>{let s=a.id,c=`${Nn(s)}`;t&&a?.metadata&&typeof a.metadata=="object"&&(this.clientDocumentMetadataMap[s]=a.metadata),r.push({documentId:c,clientDocumentId:s})}),r}catch(r){return this.loggingService.catch("Error in DocService getDocumentIdsFromDocuments:",r),[]}}setDocuments(s){return Q(this,arguments,function*({documents:e,options:t,source:r="internal",skipPermissionValidation:a=!1}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocuments","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{documents:e,options:t,methodName:"setDocuments",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENTS,source:r,payload:{documents:e,options:t}}),yield this.setDocumentsImpl({documents:e,options:t??{},source:r,skipPermissionValidation:a})}catch(c){this.loggingService.catch("Error in DocService setDocuments:",c)}})}setRootDocument(r){return Q(this,arguments,function*({document:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootDocument","color: green;"),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_ROOT_DOCUMENT_TRIGGERED,methodName:Fa.SET_ROOT_DOCUMENT,source:t,payload:{document:e}});let a=this.getOptionsFromDocumentPaths()??{},s=this.documentIds$.value.map(c=>c.clientDocumentId);if(!s.includes(e.id)){let c=[...s.map(g=>({id:g})),{id:e.id}],p=this.getDocumentIdsFromDocuments({documents:c,setClientDocumentMetadataMap:!0});this.documentIds$.next(p)}yield this.setDocumentIdImpl(e.id,this.documentPaths$.value?.clientOrganizationId,a)}catch(a){this.loggingService.catch("Error in DocService setRootDocument:",a)}})}setDocContext(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocContext","color: green;");let t=JSON.parse(JSON.stringify(e??null));this.docContext$.next(t)}catch(t){this.loggingService.catch("Error in setDocContext: ",t)}}getDocContext(){return this.docContext$.getValue()}getDocContext$(){return this.docContext$.asObservable().pipe(Ct(Xt))}getProcessedDocContext(){return vce(this.getDocContext())}filterRelevantDocuments(a){return Q(this,arguments,function*({options:e,documentIds:t,skipPermissionValidation:r=!1}){try{let s=this.authService.getUser();return!s||!this.commonDbService?.shouldUseFirestore()||(t=yield this.fetchDocumentsFromFolder(e,t,s),yield this.handlePermissionProvider(e,t,s),t=yield this.filterDocumentsByPermissions(e,t,s,r),t=t.slice(0,50)),t}catch(s){return this.loggingService.catch("Error in DocService filterRelevantDocuments:",s),t}})}fetchDocumentsFromFolder(e,t,r){return Q(this,null,function*(){if(!e?.folderId||!e?.allDocuments)return t;try{let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));(yield hd({methodName:"getDocuments",data:{type:"getDocuments",metadata:{organizationId:e?.organizationId??r?.clientOrganizationId,folderId:e?.folderId}},getSdkProxy:a,userId:r?.userId??""}))?.data?.forEach(c=>{t.find(p=>p.clientDocumentId===c.id)||t.push({documentId:Tr(c.id),clientDocumentId:c.id})})}catch(a){this.loggingService.warn("Error in DocService fetchDocumentsFromFolder:",a)}return t})}buildPermissionRequests(e,t,r){try{let a=[];return e.organizationId&&e.organizationId!==r.clientOrganizationId&&a.push({userId:r.userId,resource:{id:e.organizationId,type:Fo.ORGANIZATION,source:Gi.SET_DOCUMENTS,organizationId:e.organizationId,context:e?.context}}),e.folderId&&a.push({userId:r.userId,resource:{id:e.folderId,type:Fo.FOLDER,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:e?.context}}),t&&t.forEach(s=>{a.push({userId:r.userId,resource:{id:s.clientDocumentId,type:Fo.DOCUMENT,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:e?.context}})}),e?.context&&this.userPermissionService?.getIsContextEnabled()&&Cce({input:e?.context}).forEach(c=>{let p=JSON.stringify(c.access);a.push({userId:r.userId,resource:{id:p,type:Fo.CONTEXT,source:Gi.SET_DOCUMENTS,organizationId:e?.organizationId??r?.clientOrganizationId??"",context:c}})}),a}catch(a){return this.loggingService.catch("Error in buildPermissionRequests:",a),[]}}processAccessibleContexts(e,t){try{if(!e?.success||!e?.data?.length||!this.userPermissionService?.getIsContextEnabled())return;let r=e.data.filter(a=>a.type===Fo.CONTEXT&&a.hasAccess).map(a=>a.resourceId);if(this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContextIds:",JSON.parse(JSON.stringify(r??"nil"))),r?.length){let a=t.filter(c=>r.includes(c.resource.id)).map(c=>c.resource.context).filter(c=>!!c),s=_ce({input:a});this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContext:",JSON.parse(JSON.stringify(s??"nil"))),s?.access&&(this.loggingService.logContext("[CONTEXT] setting accessibleContext in docContext:",JSON.parse(JSON.stringify(s??"nil"))),this.setDocContext(s))}}catch(r){this.loggingService.catch("Error in processAccessibleContexts:",r)}}handlePermissionProvider(e,t,r){return Q(this,null,function*(){if(this.userPermissionService?.isPermissionProviderAvailable())try{this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with options:",JSON.parse(JSON.stringify(e??"nil")),"documentIds:",JSON.parse(JSON.stringify(t??"nil")),"user:",JSON.parse(JSON.stringify(r??"nil")));let a=this.buildPermissionRequests(e,t,r),s=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.SET_DOCUMENTS,uniqueId:s,timestamp:new Date().getTime(),source:"internal",payload:{requests:a}});let c=yield this.userPermissionService?.onResourceAccessRequired({requests:a,uniqueId:s,methodName:Gi.SET_DOCUMENTS,fromCache:!1});this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with res:",JSON.parse(JSON.stringify(c??"nil")),"requests:",JSON.parse(JSON.stringify(a??"nil"))),this.processAccessibleContexts(c,a)}catch(a){this.loggingService.catch("Error in handlePermissionProvider:",a)}})}filterDocumentsByPermissions(e,t,r,a=!1){return Q(this,null,function*(){if(a)return t;this.loggingService.logContext("[CONTEXT] filterDocumentsByPermissions called with options:",JSON.parse(JSON.stringify(e??"nil")),"documentIds:",JSON.parse(JSON.stringify(t??"nil")),"user:",JSON.parse(JSON.stringify(r??"nil")));let s=this.currentValidationToken,c=[...t];return s&&this.validatePermissionsInBackground(e,t,r,s),c})}validatePermissionsInBackground(e,t,r,a){let s=e?.organizationId??r?.clientOrganizationId;this.userPermissionService?.getUserPermissions({organizationId:s,documentIds:t.map(c=>c.clientDocumentId),folderIds:e?.folderId?[e?.folderId]:[]}).then(c=>{if(this.currentValidationToken===a&&c){this.userPermissionService?.setCurrentUserPermissions(c);let p=[];Object.entries(c?.[r.userId]?.documents??{}).forEach(([g,f])=>{f?.errorCode===Lo.PERMISSION_DENIED&&p.push(g)}),s&&c?.[r.userId]?.organization?.[s]?.errorCode===Lo.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to organization: ${s}`,void 0,void 0,!0),e?.folderId&&c?.[r.userId]?.folders?.[e?.folderId]?.errorCode===Lo.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to folder: ${e?.folderId}`,void 0,void 0,!0),p.length>0&&(this.loggingService.catch(`User does not have access to documents: ${p.join(", ")}`,void 0,void 0,!0),this.handleDeniedDocumentAccess(p,r,a))}}).catch(c=>{this.loggingService.catch("Error in background permission validation:",c)})}handleDeniedDocumentAccess(e,t,r){try{if(this.currentValidationToken!==r)return;let a=this.documentPaths$.value;this.coreActionsService.triggerAction(mt.ERROR,{event:Y.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"Access denied to document after optimistic load",documentIds:e,userId:t.userId,timestamp:new Date().getTime()});let s=this.documentIds$.value||[],c=s.filter(p=>!e.includes(p.clientDocumentId));c.length!==s.length&&(c.length>0?this.setDocuments({documents:c.map(p=>({id:p.clientDocumentId})),options:{organizationId:a?.clientOrganizationId},source:"internal",skipPermissionValidation:!0}):(this.loggingService.catch("Error in DocService handleDeniedDocumentAccess: Documents provided are all denied"),this.coreActionsService.triggerAction(mt.ERROR,{event:Y.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"All documents provided are denied",documentIds:e,userId:t.userId,timestamp:new Date().getTime()}),this.unsetDocuments({source:"internal"})))}catch(a){this.loggingService.catch("Error in handleDeniedDocumentAccess:",a)}}addUserInfoToOrganization(r){return Q(this,arguments,function*({organizationId:e,user:t}){try{let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));yield hd({data:{type:"addUserInfoToOrganization",metadata:{organizationId:e},user:t},getSdkProxy:a,userId:t?.userId??""})}catch(a){this.loggingService.warn("Error in DocService addUserInfoToOrganization:",a)}})}setDocumentsImpl(s){return Q(this,arguments,function*({documents:e,options:t,source:r,skipPermissionValidation:a=!1}){try{this.loggingService.logContext("[CONTEXT] setDocumentsImpl called with documents:",JSON.parse(JSON.stringify(e??"nil")),"options:",JSON.parse(JSON.stringify(t??"nil")));let c=t?.organizationId??this.documentPaths$.value?.clientOrganizationId;if(!this.shouldSetDocumentsAgain(e,lz(D(E({},t),{organizationId:c})))){r==="external"&&this.loggingService.catch("setDocuments called with previous request");return}let p=vt();this.currentValidationToken=p;let g=this.getDocumentIdsFromDocuments({documents:e,setClientDocumentMetadataMap:!0});if(g?.length===0){this.loggingService.warn("Minimum one document must be set in setDocuments");return}let f=this.authService.getUser();if(!f){this.draftDocuments=e,this.draftOptions=t;return}this.documentPaths$.value?.organizationId&&t?.organizationId&&this.documentPaths$.value?.organizationId!==t?.organizationId?this.authService.resetServicesCache():this.unsetDocuments({source:"internal",unsetDocumentPaths:!1});let I=t?.organizationId??f?.clientOrganizationId;if(I&&this.addUserInfoToOrganization({organizationId:I,user:f}),g=yield this.filterRelevantDocuments({options:t,documentIds:g,skipPermissionValidation:a}),this.documentIds$.next(g),g?.length){let T=g[0]?.clientDocumentId;t?.rootDocumentId&&g.find(B=>B.clientDocumentId===t?.rootDocumentId)&&(T=t?.rootDocumentId),yield this.debounceSetDocuments({documentId:T,clientOrganizationId:t?.organizationId,options:t})}return}catch(c){this.loggingService.catch("Error in DocService setDocumentsImpl:",c)}})}setDocumentId(a){return Q(this,arguments,function*({documentId:e,clientOrganizationId:t,source:r="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentId","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:e,clientOrganizationId:t,methodName:"setDocumentId",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:Fa.SET_DOCUMENT_ID,source:r,payload:{documentId:e,clientOrganizationId:t}}),yield this.setDocumentsImpl({documents:[{id:e}],options:{organizationId:t},source:r})}catch(s){this.loggingService.catch("Error in setDocumentId:",s);return}})}debounceSetDocuments(a){return Q(this,arguments,function*({documentId:e,clientOrganizationId:t,options:r}){try{this.loggingService.log("%c[WB] Calling FUNCTION: debounceSetDocuments","color: green;");let s=Date.now(),c=s-this.lastSetDocumentIdCallTime,p=s-this.lastSetDocumentIdExecutionTime;if(this.lastSetDocumentIdCallTime=s,this.queueSize>=this.MAX_QUEUE_SIZE){this.loggingService.warn("SetDocumentId queue size exceeded limit");return}if(!this.documentPaths$.value&&!this.isDocumentIdInDebounceQueue||c>this.DEBOUNCE_TIME&&p>this.DEBOUNCE_TIME){yield this.setDocumentIdImpl(e,t,r),this.lastSetDocumentIdExecutionTime=s;return}this.documentPaths$.next(null),this.isDocumentIdInDebounceQueue=!0,this.draftLocationMap={locations:[],options:void 0},this.queueSize++,this.setDocumentIdSubject.next({documentId:e,clientOrganizationId:t,options:r??void 0});return}catch(s){this.loggingService.catch("Error in debounceSetDocuments:",s)}})}setDocumentIdImpl(e,t,r){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentIdImpl","color: green;");try{let a=this.authService.getUser();if(!a)return;this.currentDocumentId&&this.documentPaths$.value&&(yield this.callPreDocumentIdChangeFunctions(this.documentPaths$.value));let s=this.currentDocumentId;if(this.apiKey){let c=`${Nn(e)}`,p=r?.folderId,g=r?.folderId?Ai(r?.folderId):void 0,f=r?.locationId,I=r?.allDocuments,T=a?.organizationId?t?Tt(t):a?.organizationId:void 0,B=vt(),z=MC.SET_DOCUMENTS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:B,methodName:No.INIT_DOCUMENTS,moduleName:z,source:"internal",payload:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""}});let G=vt(),J=HI.SET_DOCUMENTS;if(this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,moduleName:J,methodName:Ho.INIT_DOCUMENTS,source:"internal",payload:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""}}),yield Promise.allSettled([this.commentResolverService.resolveCommentAnnotations({request:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""},uniqueId:B,moduleName:z}),this.reactionResolverService.resolveReactionAnnotations({request:{documentIds:this.documentIds$.value.map(ne=>ne.clientDocumentId),organizationId:t??a?.clientOrganizationId??""},uniqueId:G,moduleName:J})]),this.currentDocumentId!==c||this.documentPaths$.value?.organizationId!==T){this.loggingService.log("setting new docid"),this.currentDocumentId=c;let ne=new o9,ve=new y9;ne.clientDocumentId=e,ve.clientDocumentId=e,ne.folderId=p,ve.folderId=p,ne.locationId=f,ve.locationId=f,ne.allDocuments=I,ve.allDocuments=I,ne.veltFolderId=g,ve.veltFolderId=g,ne.documentId=c,ve.documentId=c,T&&(ne.organizationId=T,ne.clientOrganizationId=t??a?.clientOrganizationId,ve.organizationId=T,ve.clientOrganizationId=t??a?.clientOrganizationId);let ye=`${this.apiKey}`,Ne=`apiKey/${this.apiKey}`;T&&(ye=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${ne.organizationId}`,Ne=`${Ne}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${ne.organizationId}`),ve.organization=`apiKey/${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}`,ve.document=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}`,ne.presence=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_PRESENCE}/`,ne.cursor=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CURSOR}/`,ne.comment=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_COMMENT}/`,ve.comment=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_COMMENT}`,ne.multiThread=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,ve.multiThread=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,ne.tag=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_TAG}/`,ne.area=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AREA}/`,ve.area=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AREA}`,ne.arrow=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_ARROW}/`,ne.selection=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_SELECTION}/`,ne.audioHuddle=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,ne.huddle=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_HUDDLE}/`,ne.recorder=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_RECORDER}/`,ve.recorder=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_RECORDER}`,ne.flock=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,ne.syncVideoPlayer=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,ne.liveState=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,ne.liveStateSingleEditorMode=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,ne.reaction=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_REACTION}/`,ve.reaction=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_REACTION}`,ne.crdt=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CRDT}/`,ve.crdt=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_CRDT}`,ne.customerMetadata=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,ne.views=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_VIEWS}/`,ve.notificationViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,ve.documentViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,ve.locationViews=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,ne.notifications=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,ne.metadata=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_METADATA}/`,ne.users=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,ne.documentIam=`${ye}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.workspaceIam=`${this.apiKey}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.groupContacts=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GROUPS}/`,ne.globalContacts=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_GLOBAL}/`,ne.logins=`${ye}/${U.FIREBASE_PARTIAL_PATH_CONTACTS}/${U.FIREBASE_PARTIAL_PATH_LOGINS}/`,ne.userFeedback=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,ne.userReportBugs=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_BUGS}/`,ne.userContactUs=`${ye}/${U.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${U.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,T&&(ne.organizationMetadata=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,ne.organizationIam=`${ye}/${U.FIREBASE_PARTIAL_PATH_IAM}/`,ne.organizationGroups=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,ne.organizationNotifications=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,c&&(ne.organizationNotificationsWithDocumentId=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/`,ne.heartbeatByDocument=`${ye}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${c}/`),ne.organizationNotificationsLastNotificationTimestamp=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${U.FIREBASE_PARTIAL_PATH_DOCS}/`,ne.organizationNotificationsUsers=`${ye}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${U.FIREBASE_PARTIAL_PATH_USERS}/`,ne.heartbeat=`${ye}/${U.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),ve.organizationUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,ve.users=`${Ne}/${U.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,ve.documentUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_DOCS}/${c}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,ve.notificationDocs=`${Ne}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,ve.notificationUsers=`${Ne}/${U.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.documentPaths$.next(ne),this.firestorePaths$.next(ve),ne?.clientOrganizationId&&ne?.organizationId&&!(ne?.clientOrganizationId===this.getOrganizationConfig()?.clientOrganizationId&&ne?.organizationId===this.getOrganizationConfig()?.organizationId)&&this.organizationConfig$.next({organizationId:ne?.organizationId,clientOrganizationId:ne?.clientOrganizationId}),Promise.allSettled([this.updateFolderMetadata(),this.updateDocumentMetadata(),this.fetchLocationMetadata(),this.updateOrganizationMetadata()]),s&&this.location$.value&&this.removeLocation({}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.SET_DOCUMENTS_SUCCESS,payload:{documentId:c,clientDocumentId:e}}),this.analyticsService.trackEvent(Y.Events.Doc.SET_DOCUMENTS_SUCCESS,{documentId:c,clientDocumentId:e},!0,this.getUserIdForAnalytics())}}else this.loggingService.catch("Error in setDocumentIdImpl: API key is not provided.")}catch(a){this.loggingService.catch("Error in setDocumentIdImpl: ",a)}})}unsetDocumentId({source:e,unsetDocumentPaths:t}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentId","color: green;");try{e==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocumentId",source:e}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,methodName:Fa.UNSET_DOCUMENT_ID,source:e}),this.unsetDocumentImpl({source:e,unsetDocumentPaths:t})}catch(r){this.loggingService.catch("Error in unsetDocumentId: ",r)}}unsetDocumentImpl({source:e,unsetDocumentPaths:t}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentImpl","color: green;");try{this.currentDocumentId&&this.documentPaths$.value&&this.callPreDocumentIdChangeFunctions(this.documentPaths$.value),this.userPermissionService?.revokeAccessOnDocumentUnset(),t&&(this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.currentDocumentId=null,this.location$.next(null),this.excludedLocationIds$.next([]),this.documentMetadata$.next(null),this.locationMetadata$.next(null),this.locations$.next({}),this.documentIds$.next([]),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_SUCCESS,source:e}),this.analyticsService.trackEvent(Y.Events.Doc.UNSET_DOCUMENTS_SUCCESS,{documentId:this.currentDocumentId,documentMetadata:this.documentMetadata$.value?.[this.currentDocumentId??""],message:e==="external"?"User unset document id":"System unset document id",source:e},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in unsetDocumentImpl: ",r)}}unsetDocuments({source:e,unsetDocumentPaths:t=!0}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocuments","color: green;");try{e==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocuments",source:e}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,source:e,methodName:Fa.UNSET_DOCUMENTS}),this.unsetDocumentImpl({source:e,unsetDocumentPaths:t})}catch(r){this.loggingService.catch("Error in unsetDocuments: ",r)}}addPreDocumentIdChangeFunction(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: addPreDocumentIdChangeFunction","color: green;"),this.preDocumentIdChangeFunctions.set(e,t)}catch(r){this.loggingService.catch("Error in addPreDocumentIdChangeFunction: ",r)}}callPreDocumentIdChangeFunctions(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: callPreDocumentIdChangeFunctions","color: green;");for(let[t,r]of this.preDocumentIdChangeFunctions)try{yield r(e)}catch(a){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",a)}}catch(t){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",t)}})}fetchOrganizationMetadata(e){return Q(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: fetchOrganizationMetadata","color: green;");try{if(!e&&this.getOrganizationConfig()&&(e=this.getOrganizationConfig()),this.db&&e?.organizationId){let t=e?.organizationId;yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{apiKey:this.apiKey??"",organizationId:t,field:"metadata"}}).then(r=>{r&&!r?.errorCode&&this.organizationMetadata$.next(D(E({},this.organizationMetadata$.value),{[t]:r}))}).catch(r=>{this.loggingService.catch("Error in fetchOrganizationMetadata: ",r)})}}catch(t){this.loggingService.catch("Error in fetchOrganizationMetadata: ",t)}})}fetchDocumentMetadata(e){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value,r=this.documentMetadata$.value;if(e=e.filter(a=>!r?.[a.documentId]),e?.some(a=>!a?.documentId||!a?.clientDocumentId)||!t)return;if(this.commonDbService?.shouldUseFirestore()){let a=t?.folderId,s=[],c={organizationId:t?.clientOrganizationId,folderId:a},p=[],g=20;for(let I=0;I<e.length;I+=g)p.push(e.slice(I,I+g));p.forEach(I=>{let T=JSON.parse(JSON.stringify(c));T.documentIds=I.map(B=>B.clientDocumentId),s.push(this.fetchDocuments(T))});let f={};s.length>0&&(yield Promise.all(s).then(I=>{I?.forEach(T=>{T?.forEach(B=>{B?.metadata?.documentId&&(f[B.metadata.documentId]=B.metadata)})}),this.setAllDocumentMetadata(E(E({},this.documentMetadata$.value),f))}).catch(I=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",I)}))}else r?.[t?.documentId??e?.[0]?.documentId]||this.commonDbService?.queryData({feature:"allDocuments",properties:{apiKey:this.apiKey??"",organizationId:t?.organizationId,documentId:t?.documentId??e?.[0]?.documentId,skipObjectValues:!0}}).then(a=>{a?.documentId&&this.setDocumentMetadata(a.documentId,a)}).catch(a=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",a)})}}catch(t){this.loggingService.catch("Error in fetchDocumentMetadata: ",t)}})}fetchLocationMetadata(){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value,t=this.documentIds$.value,r=e?.folderId,a=e?.allDocuments,s=[],c={organizationId:e?.clientOrganizationId,folderId:r,allDocuments:a},p=[],g=20;for(let I=0;I<t.length;I+=g)p.push(t.slice(I,I+g));p.forEach(I=>{let T=JSON.parse(JSON.stringify(c));T.documentIds=I.map(B=>B.clientDocumentId),s.push(this.fetchLocations(T))});let f=this.locationMetadata$.value??{};s.length>0&&Promise.all(s).then(I=>{I?.forEach(T=>{T?.forEach(B=>{B?.metadata?.documentId&&(f[B.metadata.documentId]=D(E({},f?.[B.metadata.documentId]??{}),{[B.location.id]:B}))})}),Object.keys(f||{}).length>0&&this.locationMetadata$.next(f)}).catch(I=>{this.loggingService.catch("Error in fetchLocationMetadata: ",I)})}}catch(e){this.loggingService.catch("Error in fetchLocationMetadata: ",e)}})}getLocationMetadatas(){return this.locationMetadata$.value}subscribeToCustomerMetadata(){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeToCustomerMetadata","color: green;");try{if(this.customerMetadataSubscription)return;this.db&&this.authService.getUser()&&this.documentPaths$.value&&(this.customerMetadataSubscription=this.commonDbService?.dbListener({feature:"customerMetadata",properties:{skipFirestore:!0}}).pipe(Un(t=>le(null))).subscribe(t=>{this.customerMetadata$.next(t?.data)}))}catch(e){this.loggingService.catch("Error in subscribeToCustomerMetadata: ",e)}}getDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentId","color: green;"),this.documentPaths$.value?.documentId}getClientDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getClientDocumentId","color: green;"),this.documentPaths$.value?.clientDocumentId}getDocumentIds$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds$","color: green;"),this.documentIds$.asObservable().pipe(de(e=>e?.slice()))}getDocumentIds(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds","color: green;"),this.documentIds$.value?.slice()}getLocationMetadata$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocationMetadata$","color: green;"),this.locationMetadata$.asObservable().pipe()}getDocumentPaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths$","color: green;"),this.documentPaths$.asObservable()}getFirestorePaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths$","color: green;"),this.firestorePaths$.asObservable()}getDocumentPaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.documentPaths$.value}generateDocumentId(e){try{return`${Nn(e)}`}catch(t){return this.loggingService.catch("Error in generateDocumentId: ",t),""}}generateOrganizationId(e){try{return`${Tt(e)}`}catch(t){return this.loggingService.catch("Error in generateOrganizationId: ",t),""}}getFirestorePaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths","color: green;"),this.firestorePaths$.value}setLocation(r){return Q(this,arguments,function*({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[e],options:void 0,methodName:"setLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,source:t,methodName:Fa.SET_LOCATION,payload:{locations:[e],options:void 0}}),this.setLocationsImpl({locations:[e]})}catch(a){this.loggingService.catch("Error in setLocation: ",a)}})}setLocations(a){return Q(this,arguments,function*({locations:e,options:t,source:r="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocations","color: green;"),r==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:e,options:t,methodName:"setLocations",source:r}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:Fa.SET_LOCATIONS,source:r,payload:{locations:e,options:t}}),this.setLocationsImpl({locations:e,options:t})}catch(s){this.loggingService.catch("Error in setLocations: ",s)}})}getValidLocations(e){try{let t=[];return e&&Array.isArray(e)&&e.forEach(r=>{if(r&&typeof r=="object"){let a=!0;r?.version&&(!r?.version?.id||!r?.version?.name)&&(this.loggingService.catch(`Error in setting location for locationId: ${r?.id}, If you're setting version then add id and name fields to version object.`),a=!1),a&&t.push(r)}}),t}catch(t){this.loggingService.catch("Error in getValidLocations: ",t)}return e}setRootLocation(r){return Q(this,arguments,function*({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_ROOT_LOCATION_TRIGGERED,{payload:{location:e,methodName:"setRootLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_ROOT_LOCATION_TRIGGERED,methodName:Fa.SET_ROOT_LOCATION,source:t,payload:{location:e}});let a=Object.values(this.locations$.value).map(s=>s.location).filter(s=>String(s.id)!==String(e.id));this.setLocationsImpl({locations:[e,...a],options:{rootLocationId:e.id}})}catch(a){this.loggingService.catch("Error in DocService setRootLocation:",a)}})}setLocationsImpl({locations:e,options:t}){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setLocationsImpl","color: green;"),e.length===0)return;if(!this.authService.getUser()){!t?.appendLocation&&e.length>0&&(this.draftLocationMap.options=D(E(E({},this.draftLocationMap.options??{}),t??{}),{rootLocationId:e[0].id})),this.draftLocationMap.locations=[...this.draftLocationMap.locations,...e],this.draftLocationMap.options=E(E({},this.draftLocationMap.options),t);return}let a=this.getValidLocations(e),s=[],c=[];this.location$.value?.location.id&&c.push(this.location$.value?.location.id),c=[...c,...Object.values(this.locations$.value).map(f=>f.location.id)].filter(f=>f!==void 0);let p;if(t?.rootLocationId&&t?.rootLocationId!==this.location$.value?.location.id&&(p=a.find(f=>f.id===t?.rootLocationId),!p)){this.loggingService.catch(`Error in setting locations, rootLocationId: ${t?.rootLocationId} not found in locations.`);return}if(t?.appendLocation){if(p){let f=or(p),I=Nn(JSON.stringify(f));f.id&&s.push({locationId:I,location:f}),this.location$.next({locationId:I,location:f})}}else{p||(p=a[0]);let f=or(p),I=Nn(JSON.stringify(f));f.id&&s.push({locationId:I,location:f}),this.location$.next({locationId:I,location:f})}let g=[];return a.slice(t?.appendLocation?0:1).forEach(f=>{if(f.id!==this.location$.value?.location.id){let I=E({},f),T=this.locations$.value;f?.id&&Object.keys(T).forEach(J=>{let ne=T[J];ne.location?.id===f.id&&(I=E(E({},ne.location),f),delete T?.[J])});let B=this.genarateLocationId(I),z={locationId:B,location:I};I.id&&s.push({locationId:B,location:I}),g.push(z);let G=D(E({},T),{[B]:z});this.locations$.next(G)}}),this.updateDocumentLocationMetadata(s),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.SET_LOCATIONS_SUCCESS,methodName:Fa.SET_LOCATIONS,payload:{locations:a,options:t}}),this.analyticsService.trackEvent(Y.Events.Doc.SET_LOCATIONS_SUCCESS,{locations:a,options:t},!0,this.getUserIdForAnalytics()),g}catch(r){this.loggingService.catch("Error in setLocationImpl: ",r);return}}addLocation({location:e,source:t="internal"}){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[e],options:{appendLocation:!0},methodName:"addLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:Fa.ADD_LOCATION,source:t,payload:{locations:[e],options:{appendLocation:!0}}}),this.setLocationsImpl({locations:[e],options:{appendLocation:!0}})}catch(r){this.loggingService.catch("Error in DocService addLocation:",r);return}}removeLocation({location:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocation","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:[e],methodName:"removeLocation",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,source:t,methodName:Fa.REMOVE_LOCATION,payload:{locations:[e]}}),e&&this.removeLocationsImpl([e],t)}catch(r){this.loggingService.catch("Error in removeLocation: ",r)}}removeLocations({locations:e,source:t="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:e,methodName:"removeLocations",source:t}}),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,methodName:Fa.REMOVE_LOCATIONS,source:t,payload:{locations:e}}),this.removeLocationsImpl(e,t)}catch(r){this.loggingService.catch("Error in removeLocations: ",r)}}removeLocationsImpl(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:e},methodName:"removeLocations",message:"System removed locations",source:t},!0,this.getUserIdForAnalytics()),e?e.forEach(r=>{let a=this.genarateLocationId(r);this.getLocation()?.locationId===a&&(this.location$.next(null),t!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(s=>s.id!==r.id))),this.removeCustomLocation(r)}):(this.location$.next(null),this.locations$.next({}),t!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.analyticsService.trackEvent(Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locations:e},source:t},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in removeLocation: ",r)}}unsetLocationIds(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsetLocationIds","color: green;"),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Core.UNSET_LOCATIONS_TRIGGERED,methodName:Fa.UNSET_LOCATION_IDS,source:t,payload:{locationIds:e}}),t==="internal"&&this.analyticsService.trackEvent(Y.Events.Core.UNSET_LOCATIONS_TRIGGERED,{payload:{locationIds:e},methodName:"unsetLocationIds",message:"System unset location ids",source:t},!0,this.getUserIdForAnalytics()),e?.length?e.forEach(r=>{this.getLocation()?.location.id===r&&(this.location$.next(null),t!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(a=>a.id!==r))),this.removeCustomLocationId(r)}):(this.location$.next(null),this.locations$.next({}),t!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.coreActionsService.triggerAction(mt.INIT_UPDATE,{event:Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,methodName:Fa.REMOVE_LOCATIONS_SUCCESS,source:t,payload:{locationIds:e}}),this.analyticsService.trackEvent(Y.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locationIds:e},source:t},!0,this.getUserIdForAnalytics())}catch(r){this.loggingService.catch("Error in unsetLocationIds: ",r)}}getLocation$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.asObservable()}getLocation(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.value?JSON.parse(JSON.stringify(this.location$.value)):null}excludeLocationIds(e){try{this.excludedLocationIds$.next([...e])}catch(t){this.loggingService.catch("Error in excludeLocationIds: ",t)}}getExcludedLocationIds$(){try{return this.excludedLocationIds$.asObservable()}catch(e){return this.loggingService.catch("Error in getExcludedLocationIds$: ",e),le([])}}updateOrganizationMetadata(e){return Q(this,null,function*(){try{!e&&this.getOrganizationConfig()&&(e=this.getOrganizationConfig());let t=e?.organizationId,r=this.documentPaths$.value;if(this.db&&t&&r?.documentId){if(this.organizationMetadata$.value?.[t])return;let s=new h9;s.apiKey=this.configService?.getApiKey()??"",s.organizationId=t,s.clientOrganizationId=e?.clientOrganizationId,this.userPermissionService?.hasEditAccess({organizationId:t})&&(yield this.commonDbService?.updateData({feature:"organizationMetadata",data:JSON.parse(JSON.stringify(s)),properties:{organizationId:t,documentId:r?.documentId??""}})),yield this.fetchOrganizationMetadata(e)}}catch(t){this.loggingService.catch("Error in updateOrganizationMetadata: ",t)}})}updateFolderMetadata(){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateFolderMetadata","color: green;"),this.db&&this.authService.getUser()&&this.documentPaths$.value?.folderId){let e=this.documentPaths$.value;if(!e?.veltFolderId||!e?.organizationId)return;if(!(yield this.commonDbService?.getData({feature:"folderMetadata",properties:{organizationId:e?.organizationId??"",folderId:e?.veltFolderId??""}}))?.metadata){let r={folderId:this.documentPaths$.value?.folderId,clientOrganizationId:e?.clientOrganizationId,parentFolderId:"root"};if(this.userPermissionService?.hasEditAccess({folderId:this.documentPaths$.value?.veltFolderId??""})){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));yield hd({methodName:"createFolder",data:{type:"createFolder",metadata:r},getSdkProxy:a,userId:this.authService.getUser()?.userId??""})}}}}catch(e){this.loggingService.catch("Error in updateFolderMetadata: ",e)}})}updateDocumentMetadata(){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value;if(e){let t=this.getDocumentIds();t.find(a=>a.documentId===e.documentId)||t.push({documentId:e.documentId??"",clientDocumentId:e.clientDocumentId??""});let r=t.map(a=>Q(this,null,function*(){let s=new i9;this.clientDocumentMetadataMap?.[a.clientDocumentId]&&(s=E(E({},this.clientDocumentMetadataMap[a.clientDocumentId]),s)),s.apiKey=this.configService?.getApiKey()??"",s.documentId=a.documentId,s.clientDocumentId=a.clientDocumentId,s.organizationId=e.organizationId,s.clientOrganizationId=e.clientOrganizationId,s.pageInfo=Ni();let c=e?.folderId,p=e?.veltFolderId;s?.pageInfo?.deviceInfo&&delete s?.pageInfo?.deviceInfo;let g=!0,f=this.documentMetadata$.value?.[a.documentId];if(c&&p){let I=this.getDocumentMetadata(a?.documentId??"")??(yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:a?.documentId??"",organizationId:e?.organizationId??"",field:"metadata"}}));I?.clientDocumentId&&!I?.errorCode?I?.folderId&&(I?.folderId!==c||I?.veltFolderId!==p)?(this.loggingService.catch(`Folder id mismatch for document ${a?.clientDocumentId??""}`),g=!1):I?.folderId===c?(c&&(s.folderId=c),p&&(s.veltFolderId=p)):(this.loggingService.catch(`Document ${a?.clientDocumentId??""} is not in the folder ${c??""}`),g=!1):(c&&(s.folderId=c),p&&(s.veltFolderId=p))}if(f){let I={};Object.entries(s).forEach(([T,B])=>{I[T]=B}),hi(I,f)&&(g=!1)}g&&this.userPermissionService?.hasEditAccess({documentId:a?.documentId??"",folderId:e?.allDocuments&&e?.veltFolderId?e?.veltFolderId:void 0})&&(yield this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(s)),properties:{organizationId:e?.organizationId??"",documentId:a?.documentId??""}}))}));yield Promise.allSettled(r),yield this.fetchDocumentMetadata(t)}}}catch(e){this.loggingService.catch("Error in updateDocumentMetadata: ",e)}})}updateDocumentLocationMetadata(e){return Q(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value;if(t){let r=this.getDocumentIds();r.find(a=>a.documentId===t.documentId)||r.push({documentId:t.documentId??"",clientDocumentId:t.clientDocumentId??""});for(let a of r){let s=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:a?.documentId??"",organizationId:t?.organizationId??"",field:"metadata"}});s?.errorCode&&(s={});let c=[];for(let p of e){let g=new l9;g.locationId=p?.locationId,g.veltLocationId=oz(p?.location?.id??""),g.location=p?.location,g.pageInfo=Ni(),g?.pageInfo?.deviceInfo&&delete g?.pageInfo?.deviceInfo;let f=D(E({},s),{[U.FIREBASE_PARTIAL_PATH_LOCATIONS]:D(E({},s[U.FIREBASE_PARTIAL_PATH_LOCATIONS]??{}),{[p?.locationId]:g})});this.commonDbService?.shouldUseFirestore()||c.push(this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(f)),properties:{documentId:a?.documentId??"",organizationId:t?.organizationId??""}}));let I=this.locationMetadata$.value;if(I||(I={}),p?.location?.id){let T=I?.[a.documentId],B=T?.[p?.location?.id??""];I&&(T||(I[a.documentId]={}),B||(I[a.documentId][p?.location?.id??""]={}),I[a.documentId][p?.location?.id??""]=D(E({},B),{location:p?.location})),Object.keys(I||{}).length>0&&this.locationMetadata$.next(I)}}yield Promise.allSettled(c)}}}}catch(t){this.loggingService.catch("Error in updateDocumentLocationMetadata: ",t)}})}genarateLocationId(e){try{return e&&typeof e=="object"?Nn(JSON.stringify(or(e))):0}catch(t){return this.loggingService.catch("Error in genarateLocationId: ",t),0}}removeCustomLocation(e,t="internal"){try{let r=this.genarateLocationId(e),a=this.locations$.value;a[r]&&(delete a[r],this.locations$.next(E({},a)),t!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(s=>s.id!==e.id)))}catch(r){this.loggingService.catch("Error in DocService removeLocation:",r)}}removeCustomLocationId(e,t="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomLocationId","color: green;");let r=this.locations$.value;Object.entries(r).forEach(([a,s])=>{s.location.id===e&&(delete r[a],this.locations$.next(E({},r)),t!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(c=>c.id!==e)))})}catch(r){this.loggingService.catch("Error in DocService removeCustomLocationId:",r)}}getLocationByClientLocationId(e){try{let t=this.getLocation()?.location;if(t?.id===e)return t;{let r=this.getLocations();Object.keys(r).forEach(a=>{let s=r[a];s.location?.id===e&&(t=s.location)})}return t}catch(t){this.loggingService.catch("Error in DocService getLocationByClientLocationId:",t);return}}removeLocationIfNotInDom(){try{let e=this.locations$.value,t=document.querySelectorAll(`[${U.ATTRIBUTES.VELT_LOCATION}]`),r=[];t.forEach(a=>{let s=a.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(s){let c=JSON.parse(s),p=this.genarateLocationId(c);r.push(p)}}),Object.keys(e).forEach(a=>{let s=e[a];r.includes(s.locationId)||delete e[a]}),this.locations$.next(E({},e))}catch(e){this.loggingService.catch("Error in DocService removeLocationIfNotInDom:",e)}}getLocations$(){try{return this.locations$.asObservable()}catch(e){return this.loggingService.catch("Error in DocService getLocations$:",e),le({})}}getLocations(){try{return this.locations$.value}catch(e){return this.loggingService.catch("Error in DocService getLocations:",e),{}}}getLocationFromElement(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: getLocationFromElement","color: green;");let t=null;if(e?.getAttribute(U.ATTRIBUTES.VELT_LOCATION)?t=e:t=e.closest(`[${U.ATTRIBUTES.VELT_LOCATION}]`),t){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(r){let a=JSON.parse(r);return{locationId:this.genarateLocationId(a),location:a}}}return null}catch(t){return this.loggingService.catch("Error in DocService getLocationFromElement:",t),null}}getElementMapWithLocation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getElementMapWithLocation","color: green;");let e={};return document.querySelectorAll(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`).forEach(r=>{if(r.getAttribute(U.ATTRIBUTES.VELT_LOCATION)){let a=this.getLocationFromElement(r);a?.locationId&&(e[a.locationId]={element:r,location:a})}else if(r.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID)){let a=r.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID);if(a){let s=this.getLocationByClientLocationId(a);s?.locationId&&(e[s.locationId]={element:r,location:s});let c={id:a},p=this.genarateLocationId(c);e[a]={element:r,location:{locationId:p,location:c}}}}}),e}catch(e){return this.loggingService.catch("Error in DocService getElementMapWithLocation:",e),{}}}getAdditionLocationFromElement(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: getAdditionLocationFromElement","color: green;");let t;if(t=e?.closest(`[${U.ATTRIBUTES.VELT_LOCATION}], [${U.ATTRIBUTES.VELT_LOCATION_ID}]`),t){if(t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION)){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION);if(r)return JSON.parse(r)}else if(t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID)){let r=t?.getAttribute(U.ATTRIBUTES.VELT_LOCATION_ID);if(r)return{id:r}}}return null}catch(t){return this.loggingService.catch("Error in DocService getAdditionLocationFromElement:",t),null}}getAdditionalDocumentIdFromElement(e){try{return e?.closest(`[${U.ATTRIBUTES.VELT_DOCUMENT_ID}]`)?.getAttribute(U.ATTRIBUTES.VELT_DOCUMENT_ID)||null}catch(t){return this.loggingService.catch("Error in DocService getAdditionalDocumentIdFromElement:",t),null}}getDocumentMetadata(e){try{return e?this.documentMetadata$.value?.[e]||null:this.documentMetadata$.value?.[this.documentPaths$.value?.documentId??""]||null}catch(t){return this.loggingService.catch("Error in DocService getDocumentMetadata:",t),null}}getAllDocumentMetadata$(e){return this.getAllDocumentMetadataMap$().pipe(de(t=>t?.[e??this.documentPaths$.value?.documentId??""]||null),Ct(Xt))}getAllDocumentMetadata(){try{return Object.values(this.documentMetadata$.value||{})}catch(e){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",e),[]}}getAllDocumentMetadataMap$(){return this.documentMetadata$.asObservable().pipe(de(e=>e||{}),Ct(Xt))}getAllDocumentMetadataMap(){try{return this.documentMetadata$.value||{}}catch(e){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",e),{}}}getDocumentMetadataOfAvailableDocuments(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentMetadataOfAvailableDocuments","color: green;");let e=this.documentMetadata$.value||{},t={},r=this.documentPaths$.value?.veltFolderId,a=this.documentPaths$.value?.allDocuments;if(r&&a)Object.values(e).forEach(s=>{s?.documentId&&s?.veltFolderId===r&&(t[s.documentId]=s)});else{let s=this.documentIds$.value;if(s?.length)s.forEach(c=>{let p=e?.[c.documentId];p&&(t[c.documentId]=p)});else if(this.documentPaths$.value?.documentId){let c=e?.[this.documentPaths$.value?.documentId];c&&(t[this.documentPaths$.value?.documentId]=c)}}return Object.values(t)}catch(e){return this.loggingService.catch("Error in DocService getDocumentMetadataOfAvailableDocuments:",e),[]}}getDocumentMetadata$(e){return this.documentMetadata$.asObservable().pipe(de(t=>t?.[e??this.documentPaths$.value?.documentId??""]||null),Ct(Xt))}setDocumentMetadata(e,t){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentMetadata","color: green;");let r=JSON.parse(JSON.stringify(this.documentMetadata$.value??{}));r[e]=t,this.documentMetadata$.next(r)}catch(r){this.loggingService.catch("Error in DocService setDocumentMetadata:",r)}}setAllDocumentMetadata(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAllDocumentMetadata","color: green;"),this.documentMetadata$.next(e)}catch(t){this.loggingService.catch("Error in DocService setAllDocumentMetadata:",t)}}getOrganizationMetadata(e){return this.organizationMetadata$.value?.[e]||null}getOrganizationMetadata$(e){return this.organizationMetadata$.asObservable().pipe(de(t=>t?.[e]||null))}getOrganizationMetadataMap$(){return this.organizationMetadata$.asObservable().pipe(de(e=>e||{}),Ct(Xt))}getCustomerMetadata(){return this.customerMetadata$.value}getCustomerMetadata$(){return this.customerMetadata$.asObservable()}getOrganizationConfig$(){return this.organizationConfig$.asObservable().pipe(Ct(Xt))}getOrganizationConfig(){return this.organizationConfig$.value}getMetadataFromType(e,t){try{switch(e){case"area":return;case"comment":return t?.multiThreadAnnotationId?this.commentService?.getMultiThreadAnnotationById(t.multiThreadAnnotationId)?.metadata:void 0;case"reaction":case"recorder":return t?.commentAnnotationId?this.commentService?.getAnnotationById(t.commentAnnotationId)?.metadata:void 0;default:return}}catch(r){this.loggingService.catch("Error in DocService getMetadataFromType:",r);return}}getDefaultMetadata({clientDocumentId:e,documentId:t}){try{let r=this.documentPaths$.value;if(!r)return;let a=e||r.clientDocumentId,s=t||r.documentId,c=this.getDocumentMetadata(s);if(!c)return;let p=c?.folderId,g=c?.veltFolderId;return E(E({apiKey:this.configService.getApiKey()??void 0,clientDocumentId:a,clientOrganizationId:r.clientOrganizationId,documentId:s,organizationId:r.organizationId},p?{folderId:p}:{}),g?{veltFolderId:g}:{})}catch(r){this.loggingService.catch("Error in DocService getDefaultMetadata:",r);return}}getBaseMetadata(e,t){try{let r,a;t?.element?r=this.getAdditionalDocumentIdFromElement(t.element)||void 0:t?.clientDocumentId&&(r=t.clientDocumentId),r&&(a=this.generateDocumentId(r));let s=this.getMetadataFromType(e,t),c=this.getDefaultMetadata({clientDocumentId:r,documentId:a});return s||c||{}}catch(r){return this.loggingService.catch("Error in DocService getBaseMetadata:",r),{}}}getServerId({documentId:e,organizationId:t}){try{return e&&(e=this.generateDocumentId(e)),t&&(t=this.generateOrganizationId(t)),{documentId:e,organizationId:t}}catch(r){return this.loggingService.catch("Error in DocService getServerId:",r),null}}fetchDocuments(e){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 r=[];if(!e?.organizationId)return this.loggingService.catch("Error in fetchDocuments: organizationId is required"),[];if(e?.folderId){let s=Ai(e?.folderId);r.push(lt("metadata.veltFolderId","==",s))}return e?.documentIds?.length&&!e?.allDocuments&&r.push(lt("metadata.documentId","in",e?.documentIds?.map(s=>this.generateDocumentId(s)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allDocuments",properties:{firestoreQuery:r,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(e?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(t){return this.loggingService.catch("Error in DocService fetchDocuments:",t),[]}})}fetchLocations(e){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 r=[];if(!e?.organizationId)return this.commonDbService?.shouldUseFirestore()&&this.loggingService.catch("Error in fetchLocations: organizationId is required"),[];if(e?.folderId){let s=Ai(e?.folderId);r.push(lt("metadata.veltFolderId","==",s))}return e?.documentIds?.length&&!e?.allDocuments&&r.push(lt("metadata.documentId","in",e?.documentIds?.map(s=>this.generateDocumentId(s)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allLocations",properties:{firestoreQuery:r,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(e?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(t){return this.loggingService.catch("Error in DocService fetchLocations:",t),[]}})}updateDocuments(e){return Q(this,null,function*(){try{if(typeof e=="object"&&(e=JSON.parse(JSON.stringify(e??{}))),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let{organizationId:r,documents:a,folderId:s}=e;if(!r&&(r=this.documentPaths$.value?.clientOrganizationId,!r))return this.loggingService.catch("Error in updateDocuments: organizationId is required"),[];let c=os(r);if(!a||a.length===0)return this.loggingService.catch("Error in updateDocuments: documents is required"),[];let p=[],g=this.documentMetadata$.value??{};for(let f of a)if(f?.documentId){f.organizationId=c,f.clientOrganizationId=r,f.clientDocumentId=f.documentId;let I=Tr(f.documentId);f.documentId=I,f.apiKey=this.configService.getApiKey()??void 0,(s||this.documentPaths$.value?.folderId)&&(f.folderId=s||this.documentPaths$.value?.folderId,f.veltFolderId=Ai(s||this.documentPaths$.value?.folderId||""));let T=()=>{if(s&&this.documentPaths$.value?.folderId&&s!==this.documentPaths$.value?.folderId)return;let z=g?.[I];z?g[I]=E(E({},z),f):g[I]=f},B=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:I,organizationId:c,field:"metadata"}});if(B?.errorCode&&(B={}),B&&B.apiKey&&B.folderId&&s&&B.folderId!=f.folderId){this.loggingService.catch(`Error in updateDocuments: document ${f.clientDocumentId} already exists with different folderId: ${B.folderId}`);continue}if(B&&B.apiKey&&!B.folderId&&f.folderId){this.loggingService.catch(`Error in updateDocuments: document ${f.clientDocumentId} already exists, move this document to folder with REST API`);continue}T(),f&&this.commonDbService&&this.userPermissionService?.hasEditAccess({documentId:f?.documentId??""})&&p.push(this.commonDbService.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(f)),properties:{organizationId:c,documentId:I}}))}yield Promise.all(p),this.setAllDocumentMetadata(g)}catch(t){return this.loggingService.catch("Error in DocService updateDocuments:",t),[]}})}updateLocations(e){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{organizationId:r,locations:a,documentIds:s}=e;if((!s||s.length===0)&&(s=this.documentIds$.value.map(f=>f.clientDocumentId)??[],s.length===0))return this.loggingService.catch("Error in updateLocations: documentId is required"),[];if(!r&&(r=this.documentPaths$.value?.clientOrganizationId,!r))return this.loggingService.catch("Error in updateLocations: organizationId is required"),[];if(!a||a.length===0)return this.loggingService.catch("Error in updateLocations: locations is required"),[];let c=s.map(f=>Tr(f)),p=[],g=this.locationMetadata$.value;g||(g={}),c.forEach(f=>{a.forEach(I=>{let T=this.location$.value;if(I?.id===T?.location?.id&&this.location$.next({locationId:T?.locationId,location:I}),I?.id){delete I?.metadata;let B=oz(I.id),z=g?.[f],G=z?.[I.id];g&&(z||(g[f]={}),G||(g[f][I.id]={}),g[f][I.id]=D(E({},G),{location:I})),I&&this.commonDbService&&p.push(this.commonDbService.updateData({feature:"locationMetadata",data:JSON.parse(JSON.stringify({location:I})),properties:{organizationId:os(r),documentId:f,id:B}}))}})}),yield Promise.all(p),Object.keys(g||{}).length>0&&this.locationMetadata$.next(g)}catch(t){return this.loggingService.catch("Error in DocService updateLocations:",t),[]}})}fetchFolders(e){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 r=[];if(!e?.organizationId)return this.loggingService.catch("Error in fetchFolders: organizationId is required"),{data:[],parentFolders:[]};let a=[],s=this.generateOrganizationId(e?.organizationId);if(e?.folderId){let c=Ai(e?.folderId);r=yield this.commonDbService?.getData({feature:"folder",properties:{folderId:c,apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}}),r&&(r=[r]),a=yield this.commonDbService?.queryData({feature:"allFolders",properties:{firestoreQuery:[lt("metadata.veltParentFolderId","==",c)],folderId:c,apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}})}else r=yield this.commonDbService?.queryData({feature:"allFolders",properties:{apiKey:this.apiKey??"",organizationId:s,documentId:this.documentPaths$.value?.documentId}});return{data:r,parentFolders:a}}catch(t){return this.loggingService.catch("Error in DocService getFoldersRequest:",t),{data:[],parentFolders:[]}}})}getDocumentIam$(){return this.authService.getUser$().pipe(he(e=>e?this.documentPaths$.pipe(he(t=>t?.documentIam?this.commonDbService?.dbListener({feature:"documentIam",properties:{documentId:t.documentId,organizationId:t.organizationId,isCollection:!1}}).pipe(de(r=>r?.data?.docIamConfig??r?.data),Ct((r,a)=>JSON.stringify(r??{})===JSON.stringify(a??{}))):le(null))):le(null)))}getDocumentAccessType(e){try{return e&&e.features&&e.features.all?e.features.all.restricted?Di.RESTRICTED:Di.PUBLIC:e&&e.documentAccessType?e.documentAccessType:Di.PUBLIC}catch(t){return this.loggingService.catch("Error in DocService getDocumentAccessType:",t),Di.PUBLIC}}changeDocumentAccessType(e){return Q(this,null,function*(){try{let t=this.documentPaths$.value;if(t){let r=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??"",field:"docIamConfig"}});if(r?.errorCode)return;switch(delete r.documentAccessType,r.features||(r.features={}),r.features.all||(r.features.all={}),e){case Di.PUBLIC:r.features.all.restricted=!1;break;case Di.RESTRICTED:r.features.all.restricted=!0,r.features.all.guestMode=!1;break;default:break}this.commonDbService?.updateData({feature:"documentAccessType",data:JSON.parse(JSON.stringify(r)),properties:{documentId:t?.documentId??"",organizationId:t?.organizationId??""}})}}catch(t){this.loggingService.catch("Error in DocService changeDocumentAccessType:",t)}})}getUserIdForAnalytics(){try{return this.authService?.getAuthUser()?.uid||""}catch(e){return this.loggingService.catch("Error in DocService getUserIdForAnalytics:",e),""}}setUIState(e){try{this.uiState.next(E(E({},this.uiState.value),e))}catch(t){this.loggingService.catch("Error in DocService setUIState:",t)}}getUIState$(){return this.uiState.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(In),ee(Be),ee(Ft),ee(_),ee(nl),ee(bm),ee(ni),ee(Do))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ln=(()=>{let o=class o{constructor(e,t,r,a,s){this.analyticsService=e,this.authService=t,this.coreActionsService=r,this.docService=a,this.loggingService=s,this.resolveOrganizationUsers=new Ce(!0),this.resolveFolderUsers=new Ce(!0),this.resolveDocumentUsers=new Ce(!0),this.unresolvedUsers=new Ce([]),this.resolveTimeout=60*1e3,this.resolveAttempts=new Map,this.subscriptions=new Dn,this.userDataProvider$=new Ce(null),this.userById$=new Ce({}),this.userByIdCalled$=new Ce({}),this.pendingResolutions=new Set,this.getUserById=c=>{try{return this.userById$.value?.[c]}catch(p){this.loggingService.catch("Error in UsersService getUserById:",p);return}};try{this.analyticsService.setUserService(this),this.authService.setUsersService(this),this.docService.getDocumentPaths$().pipe(Le(c=>!!c),he(()=>this.getUnresolvedUsers$().pipe(Le(c=>c.length>0),Bi(300),rt(20),he(c=>{let p=this.docService.getOrganizationConfig()?.organizationId;return this.commonDbService?this.commonDbService?.dbListener({feature:"allOrganizationUsers",properties:{organizationId:p,isCollection:!0,useQuery:!0,firestoreQuery:[li(lt("user.userId","in",c.slice(0,20)))]}}).pipe(de(g=>g?.data),Qt(g=>{if(g&&typeof g=="object"){delete g.undefined,delete g.null;let f=Object.values(g??{});this.setUserByIds(f.map(T=>T.user));let I=c.filter(T=>!f.some(B=>B.user.userId===T));I.length!==c.length&&this.setUnresolvedUsers(I)}})):le([])})))).subscribe()}catch(c){this.loggingService.catch("Error in UsersService constructor:",c)}}setCommonDbService(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCommonDbService","color: green;"),this.commonDbService=e}catch(t){this.loggingService.catch("Error in UsersService setCommonDbService:",t)}}setContactService(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setContactService","color: green;"),this.contactService=e}catch(t){this.loggingService.catch("Error in UsersService setContactService:",t)}}ngOnDestroy(){try{this.subscriptions.unsubscribe(),this.pendingResolutions.clear(),this.resolveAttempts.clear()}catch(e){this.loggingService.catch("Error in UsersService ngOnDestroy:",e)}}isResolverForFeatureDisabled(e){let t=this.userDataProvider$.getValue();try{switch(e){case"allOrganizationUsers":return t?!this.resolveOrganizationUsers.value:!0;case"allFolderUsers":return t?!this.resolveFolderUsers.value:!0;case"allDocumentUsers":return t?!this.resolveDocumentUsers.value:!0;default:return!1}}catch(r){return this.loggingService.catch("Error in UsersService isResolverForFeatureDisabled:",r),!1}}resolveUsers(g){return Q(this,arguments,function*({userIds:e,forceResolve:t,feature:r,organizationId:a,skipUserCheck:s=!1,uniqueId:c,moduleName:p}){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: resolveUsers","color: green;");let f=!1;if(r&&(f=this.isResolverForFeatureDisabled(r)),f)return{};{let I={},T=[],B={};if(e?.forEach(z=>{let G=this.getUserById(z);G?I[z]=G:this.userByIdCalled$.getValue()[z]?t&&T.push(z):(T.push(z),this.userByIdCalled$.next(D(E({},this.userByIdCalled$.getValue()),{[z]:!0})))}),T.length>0){let z=c||vt();this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:z,moduleName:p,methodName:Hr.RESOLVE_USERS,source:"internal",payload:{userIds:T,organizationId:a,feature:r,forceResolve:t,skipUserCheck:s,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}});let G={};try{let J,ne=new Promise((ve,ye)=>{J=setTimeout(()=>{ye(new Error("User resolution timeout"))},this.userDataProvider$.getValue()?.config?.resolveTimeout||this.userDataProvider$.getValue()?.resolveTimeout||this.resolveTimeout)});G=yield Promise.race([this.getUsersFromDB({userIds:T,organizationId:a,skipUserCheck:s}).finally(()=>{clearTimeout(J)}),ne]),this.analyticsService.trackEvent(Y.Events.Resolver.USER_RESOLVER_GET,{sourceMethod:"resolveUsers",source:"sdk",userIds:T}),this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:z,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{result:G,userIds:T,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}catch(J){this.loggingService.catch("Error in UsersService resolveUsers getUsers:",J,{userIds:T}),this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:z,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{error:J,userIds:T,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}finally{T?.forEach(J=>{if(!G[J]){let ne=new Set([...this.getUnresolvedUsers(),J]);this.unresolvedUsers.next(Array.from(ne)),G[J]={userId:J,name:`User ${J}`}}})}Object.entries(G).forEach(([J,ne])=>{ne&&(I[J]=G?.[J],B[J]=G?.[J])})}return Object.keys(B).length>0&&(this.authService.setOptionalPropertiesToUsers(Object.values(B)),this.userById$.next(E(E({},this.userById$.getValue()),B))),I}}catch(f){this.loggingService.catch("Error in UsersService resolveUsers:",f);let I=c||vt();return this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:I,methodName:Hr.RESOLVE_USERS,moduleName:p,source:"internal",payload:{error:f,userIds:e,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}}),{}}})}getUnresolvedUsers$(){return this.unresolvedUsers.asObservable()}getUnresolvedUsers(){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUnresolvedUsers","color: green;");try{return JSON.parse(JSON.stringify(this.unresolvedUsers.getValue()))}catch(e){return this.loggingService.catch("Error in UsersService getUnresolvedUsers:",e),[]}}setUnresolvedUsers(e){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUnresolvedUsers","color: green;");try{if(Array.isArray(e)){let t=JSON.parse(JSON.stringify(e));this.unresolvedUsers.next(t)}}catch(t){this.loggingService.catch("Error in UsersService setUnresolvedUsers:",t)}}getUsersFromDB(a){return Q(this,arguments,function*({userIds:e,organizationId:t,skipUserCheck:r=!1}){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUsersFromDB","color: green;");try{let s=this.userDataProvider$.getValue();if(s)return s.get(e);if(t||(t=this.docService.getOrganizationConfig()?.organizationId),!t)return{};let c=(yield this.getUsersFromDBWithBatching({userIds:e,organizationId:t,skipUserCheck:r}))??[];this.contactService?.setResolvedUsers(c.flat());let p={};return c.forEach(g=>{g.forEach(f=>{f?.user?.userId&&(p[f.user.userId]=f.user)})}),p}catch(s){return this.loggingService.catch("Error in UsersService getUsersFromDB:",s),{}}})}getUsersFromDBWithBatching(a){return Q(this,arguments,function*({userIds:e,organizationId:t,skipUserCheck:r=!1}){try{if(!e?.length)return[];let s=[];for(let g=0;g<e.length;g+=30)s.push(e.slice(g,g+30));let c=s.map((g,f)=>Q(this,null,function*(){try{return(yield this.commonDbService?.queryData({feature:"allOrganizationUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[lt("user.userId","in",g)],skipUserCheck:r}}))||[]}catch(I){return this.loggingService.catch(`Error in batch ${f+1}:`,I),[]}}));return yield Promise.all(c)}catch(s){return this.loggingService.catch("Error in getUsersFromDBWithBatching:",s),[]}})}getTemporaryUsersFromDBWithBatching(a){return Q(this,arguments,function*({userIds:e,organizationId:t,resourceIds:r}){try{if(!e?.length||!r?.length)return[];let s=[];for(let z=0;z<e.length;z+=30)s.push(e.slice(z,z+30));let c=[];for(let z=0;z<r.length;z+=30)c.push(r.slice(z,z+30));let p=[],g=0,f=(z,G)=>Q(this,null,function*(){try{return((yield this.commonDbService?.queryData({feature:"allPermissionsUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[li(lt("userId","in",z),lt("veltResourceId","in",G))]}}))??[])||[]}catch(J){return this.loggingService.catch(`Error in batch ${g+1}:`,J),[]}});for(let z of s)for(let G of c)p.push(f(z,G)),g++;return(yield Promise.all(p)).flat().filter((z,G,J)=>G===J.findIndex(ne=>ne.userId===z.userId&&ne.resourceId===z.resourceId))}catch(s){return this.loggingService.catch("Error in getTemporaryUsersFromDBWithBatching:",s),[]}})}getResolveOrganizationUsers$(){return this.resolveOrganizationUsers.asObservable()}getResolveFolderUsers$(){return this.resolveFolderUsers.asObservable()}getResolveDocumentUsers$(){return this.resolveDocumentUsers.asObservable()}getUserById$(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUserById$","color: green;"),this.userById$.asObservable().pipe(Ct(Xt))}catch(e){return this.loggingService.catch("Error in UsersService getUserById$:",e),le({})}}setUserByIds(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserByIds","color: green;");let t=JSON.parse(JSON.stringify(this.userById$.getValue()??{}));e.forEach(r=>{t[r.userId]=E(E({},t?.[r.userId]??{}),r)}),this.userById$.next(t)}catch(t){this.loggingService.catch("Error in UsersService setUserByIds:",t)}}setUserDataProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserDataProvider","color: green;"),this.userDataProvider$.next(e),e.config?.resolveUsersConfig?.organization===!1?this.resolveOrganizationUsers.next(!1):this.resolveOrganizationUsers.next(!0),e.config?.resolveUsersConfig?.folder===!1?this.resolveFolderUsers.next(!1):this.resolveFolderUsers.next(!0),e.config?.resolveUsersConfig?.document===!1?this.resolveDocumentUsers.next(!1):this.resolveDocumentUsers.next(!0)}catch(t){this.loggingService.catch("Error in UsersService setUserDataProvider:",t)}}externalUserDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: externalUserDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()&&!!this.userDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersService externalUserDataProviderAvailable:",e),!1}}userDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: userDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()}catch(e){return this.loggingService.catch("Error in UsersService userDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(ni),ee(ot),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Fpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromAreaAnnotations(e){try{this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: getUserIdsToResolveFromAreaAnnotations","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in AreaUtilsService getUserIdsToResolveFromAreaAnnotations:",t),[]}}mergeAreaWithUser(e){try{if(this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: mergeAreaWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in AreaUtilsService mergeAreaWithUser:",t),e}}formatAreaData(e){try{return this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: formatAreaData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in AreaUtilsService formatAreaData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Lpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromArrowAnnotations(e){try{this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: getUserIdsToResolveFromArrowAnnotations","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ArrowUtilsService getUserIdsToResolveFromArrowAnnotations:",t),[]}}mergeArrowWithUser(e){try{if(this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: mergeArrowWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in ArrowUtilsService mergeArrowWithUser:",t),e}}formatArrowData(e){try{return this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: formatArrowData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in ArrowUtilsService formatArrowData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var iu=class{static getFirestoreProdDbName(o,n){return n?.databaseURL?.includes("snippyly-plugin.firebaseio.com")||n?.databaseURL?.includes("snippyly-plugin-staging.firebaseio.com")?"sfdb":n?.storeDbId??(this.isTestingDb(n?.databaseURL??"")?"sdktest":`apikey${o.toLowerCase()}`)}static isTestingDb(o){try{return o.includes("-test")}catch(n){return nt.error("Error in isTestingDb:",n),!1}}};var ou=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.analyticsService=r,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.attachmentDataProvider$=new Ce(null);try{this.loggingService.log("AttachmentResolverService initialized"),this.attachmentDataProvider$.subscribe(a=>{a&&(a.config?.saveRetryConfig&&(this.retrySaveConfig=a.config.saveRetryConfig),a.config?.deleteRetryConfig&&(this.retryDeleteConfig=a.config.deleteRetryConfig))})}catch(a){this.loggingService.catch("Error in AttachmentResolverService constructor:",a)}}getProvider(){try{let e=this.attachmentDataProvider$.getValue();return e||void 0}catch(e){this.loggingService.catch("Error in AttachmentResolverService getProvider:",e);return}}saveAttachment(e,t){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: saveAttachment","color: green;");let r=this.getProvider();if(!this.attachmentDataProviderAvailable())throw new Error("Attachment save data provider not available");let a=t||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{request:e}});let s=yield ud(()=>r?.save({attachment:e.attachment,event:e.eventType,metadata:e.attachment.metadata})||Promise.resolve(void 0),"saveAttachment",this.retrySaveConfig);if(s?.statusCode!==200){this.loggingService.catch(s?.message??"Error in AttachmentResolverService saveAttachment:"),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{error:s,request:e}});return}return this.analyticsService.trackEvent(Y.Events.Resolver.ATTACHMENT_RESOLVER_SAVE,{sourceMethod:"saveAttachment",source:"sdk",attachmentId:e.attachment.attachmentId,eventType:e.eventType}),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{result:s,request:e}}),s}catch(r){this.loggingService.warn("Error in AttachmentResolverService saveAttachment:",r);let a=t||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:a,methodName:Nl.SAVE_ATTACHMENT,source:"internal",payload:{error:r,request:e}});return}})}deleteAttachment(a,s){return Q(this,arguments,function*({attachmentId:e,metadata:t},r){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: deleteAttachment","color: green;");let c=this.getProvider();if(!this.attachmentDataProviderAvailable())throw new Error("Attachment delete data provider not available");let p=r||vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:e,metadata:t}});let g=yield ud(()=>c?.delete({attachmentId:e,metadata:t,event:va.ATTACHMENT_DELETE})||Promise.resolve(void 0),"deleteAttachment",this.retryDeleteConfig);return g?.statusCode!==200?(this.loggingService.catch(g?.message??"Error in AttachmentResolverService deleteAttachment:"),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{error:g,attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(Y.Events.Resolver.ATTACHMENT_RESOLVER_DELETE,{sourceMethod:"deleteAttachment",source:"sdk",attachmentId:e}),this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(c){this.loggingService.warn("Error in AttachmentResolverService deleteAttachment:",c);let p=r||vt();return this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:p,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{error:c,attachmentId:e,metadata:t}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}setAttachmentDataProvider(e){try{if(e){this.loggingService.log("Setting attachment data provider");let r=["save","delete"].filter(a=>!(a in e)||typeof e[a]!="function");if(r.length>0){let a=`DataProviders.attachment is invalid. The following methods are missing or are not functions: ${r.join(", ")}.`;this.loggingService.catch(a);return}else this.attachmentDataProvider$.next(e)}}catch(t){this.loggingService.catch("Error in AttachmentResolverService setAttachmentDataProvider:",t)}}attachmentDataProviderAvailable(){try{return!!this.attachmentDataProvider$.getValue()}catch(e){return this.loggingService.catch("Error in AttachmentResolverService attachmentDataProviderAvailable:",e),!1}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Qe))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ru=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.loggingService=e,this.usersService=t,this.authService=r,this.functions=a,this.configService=s,this.commentAnnotationsResolverService=c,this.attachmentResolverService=p,this.coreActionsService=g,this.notificationActionTypeMap={[Wt.NEWLY_ADDED]:va.COMMENT_ANNOTATION_ADD,[Wt.ADDED]:va.COMMENT_ADD,[Wt.UPDATED]:va.COMMENT_UPDATE,[Wt.DELETED]:va.COMMENT_DELETE}}setNotificationService(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setNotificationService","color: green;"),this.notificationService=e}catch(t){this.loggingService.catch("Error in CommentUtilsService setNotificationService: ",t)}}setUserPermissionService(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setUserPermissionService","color: green;"),this.userPermissionService=e}catch(t){this.loggingService.catch("Error in CommentUtilsService setUserPermissionService: ",t)}}getUserIdsToResolveFromComments(e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: getUserIdsToResolveFromComments","color: green;");let t=new Set;for(let r of e){if(r?.from?.userId&&t.add(r?.from?.userId),r?.comments)for(let a of r?.comments){if(a?.from?.userId&&t.add(a?.from?.userId),a?.to)for(let s of a?.to)s?.userId&&t.add(s?.userId);if(a?.taggedUserContacts)for(let s of a?.taggedUserContacts)s?.userId&&t.add(s?.userId)}if(r?.assignedTo?.userId&&t.add(r?.assignedTo?.userId),r?.subscribedUsers)for(let a of Object.values(r?.subscribedUsers))a.user.userId&&t.add(a.user.userId);if(r?.unsubscribedUsers)for(let a of Object.values(r?.unsubscribedUsers))a.user.userId&&t.add(a.user.userId)}return Array.from(t)}catch(t){return this.loggingService.catch("Error in CommentUtilsService getUserIdsToResolveFromComments:",t),[]}}mergeCommentWithUser(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeCommentWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.comments)for(let t of e?.comments){if(t?.from?.userId){let a=this.usersService.getUserById(t?.from?.userId);a&&(t.from=a)}t?.to&&(t.to=t?.to?.map(a=>{if(a?.userId){let s=this.usersService.getUserById(a?.userId);if(s)return E(E({},a),s)}return a})),t?.taggedUserContacts&&(t.taggedUserContacts=t?.taggedUserContacts?.map(a=>{if(a?.contact){let s=this.usersService.getUserById(a?.contact?.userId);s&&(a.contact=s,(s?.name||s?.email)&&(a.text=`@${s?.name||s?.email}`))}return a})),(t?.taggedUserContacts?.filter((a,s,c)=>c.findIndex(p=>p.text===a.text)===s)||[]).forEach(a=>{if(a?.text){let s=new RegExp(pd(`{{${a.userId}}}`),"g");t.commentText?.includes(`@User ${a.userId}`)&&(s=new RegExp(pd(`@User ${a.userId}`),"g")),t.commentText=t.commentText?.replaceAll(s,a.text),t.commentHtml=t.commentHtml?.replaceAll(s,a.text)}})}if(e?.assignedTo?.userId){let t=this.usersService.getUserById(e?.assignedTo?.userId);t&&(e.assignedTo=t)}if(e?.subscribedUsers)for(let t of Object.values(e?.subscribedUsers)){let r=this.usersService.getUserById(t.user.userId);r&&e?.subscribedUsers?.id?.user&&(e.subscribedUsers.id.user=r)}if(e?.unsubscribedUsers)for(let t of Object.values(e?.unsubscribedUsers)){let r=this.usersService.getUserById(t.user.userId);r&&e?.unsubscribedUsers?.id?.user&&(e.unsubscribedUsers.id.user=r)}return e}catch(t){return this.loggingService.catch("Error in CommentUtilsService mergeCommentWithUser:",t),e}}formatCommentData(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentData","color: green;"),e?.comments?.forEach(t=>{t?.commentText&&t?.commentText?.length>0&&(t.isCommentTextAvailable=!0)}),e?.viewedBy&&delete e.viewedBy,e?.unread!==void 0&&delete e.unread,e?.comments&&e.comments.forEach(t=>{t?.reactionAnnotations&&delete t.reactionAnnotations}),this.usersService.userDataProviderAvailable()){if(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.assignedTo?.userId&&(e.assignedTo={userId:e.assignedTo.userId}),e?.subscribedUsers)for(let t of Object.keys(e?.subscribedUsers))e.subscribedUsers[t].user={userId:e?.subscribedUsers[t].user.userId};if(e?.unsubscribedUsers)for(let t of Object.keys(e?.unsubscribedUsers))e.unsubscribedUsers[t].user={userId:e?.unsubscribedUsers[t].user.userId}}return e?.comments&&(e.comments=e?.comments?.map(t=>this.formatCommentThreadData(t))),e}catch(t){return this.loggingService.catch("Error in CommentUtilsService formatCommentData:",t),e}}mergeStrippedDataWithCommentAnnotations(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeStrippedDataWithCommentAnnotations","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return e;let t=this.commentAnnotationsResolverService.getAnnotationById(e?.annotationId),r=this.attachmentResolverService.attachmentDataProviderAvailable(),a=this.commentAnnotationsResolverService.getFieldsToRemove();return t&&(e?.comments?.forEach(s=>{let c=t?.comments?.[s?.commentId];if(c){s.commentHtml=c?.commentHtml,s.commentText=c?.commentText;let p=c?.attachments;r&&p&&s.attachments?.forEach(g=>{let f=g?.attachmentId;p?.[f]&&(g.name=p?.[f]?.name,g.url=p?.[f]?.url)})}}),t?.targetTextRange?.text&&e?.targetTextRange&&(e.targetTextRange.text=t?.targetTextRange?.text),a?.length>0&&a.forEach(s=>{t?.[s]&&(e[s]=t[s])})),e}catch(t){return this.loggingService.catch("Error in CommentUtilsService mergeStrippedDataWithCommentAnnotations:",t),e}}mergeLocationWithCommentAnnotations(e,t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeLocationWithCommentAnnotations","color: green;");let r=e?.location?.id,a=e?.metadata?.documentId;if(!r||!a)return e;let s=t?.[a]?.[r];return s&&(e.location=s?.location),e}catch(r){return this.loggingService.catch("Error in CommentUtilsService mergeLocationWithCommentAnnotations:",r),e}}isCommentsDataChanged(e,t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: isCommentsDataChanged","color: green;");let r=this.commentAnnotationsResolverService.getCommentAnnotationById(t);return r?!hi(e,r):!0}catch(r){return this.loggingService.catch("Error in CommentUtilsService isCommentsDataChanged:",r),!0}}stripCommentsFromAnnotationData({comment:e}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentsFromAnnotationData","color: green;");let t=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable();if(!t)return e;let r=this.attachmentResolverService.attachmentDataProviderAvailable(),a=new _d;if(Object.assign(a,e),a.isCommentResolverUsed=t,r){let s=a.attachments?.map(c=>(c.isAttachmentResolverUsed=!0,delete c?.name,delete c?.url,c));a.attachments=s}return delete a?.commentHtml,delete a?.commentText,a}catch(t){return this.loggingService.catch("Error in CommentUtilsService stripCommentsFromAnnotationData:",t),e}}stripCommentAnnotationData({data:e,actionType:t,commentId:r}){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentAnnotationData","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return{originalData:e,strippedData:null};let a=this.attachmentResolverService.attachmentDataProviderAvailable(),s=this.commentAnnotationsResolverService.getFieldsToRemove(),c;t&&(c=this.notificationActionTypeMap?.[t]);let p={},g=null,f=!1;if(e&&e.annotationId){let T=e.annotationId;p[T]=E(E(E(E({annotationId:T,metadata:oC(e.metadata??{}),comments:{}},e?.from&&{from:e?.from}),e?.assignedTo&&{assignedTo:e?.assignedTo}),e?.resolvedByUserId&&{resolvedByUserId:e?.resolvedByUserId}),e?.targetTextRange?.text&&{targetTextRange:{text:e?.targetTextRange?.text}}),delete e?.targetTextRange?.text,s?.length>0&&s.forEach(z=>{e?.[z]&&(p[T][z]=e[z],delete e[z])}),e.comments?.forEach(z=>{if(z.commentId){let G;a&&(G={},z.attachments?.forEach(J=>{G[J.attachmentId]={attachmentId:J.attachmentId,name:J.name,url:J.url}})),p[T].comments[z.commentId]=E(E(E(E(E(E({commentId:z.commentId},z?.commentHtml&&{commentHtml:z?.commentHtml}),z?.commentText&&{commentText:z?.commentText}),G&&{attachments:G}),z?.from&&{from:z?.from}),z?.to&&{to:z?.to}),z?.taggedUserContacts&&{taggedUserContacts:z?.taggedUserContacts})}}),f=this.isCommentsDataChanged(p[T],T);let B=new Zo;Object.assign(B,e),B.comments=e.comments?.map(z=>this.stripCommentsFromAnnotationData({comment:z}))||[],g=B}let I=g?.comments?.find(T=>T.commentId===r);return I?.isDraft&&(c=g?.comments?.length&&g?.comments?.length>0?va.COMMENT_ADD:va.COMMENT_ANNOTATION_ADD),{strippedData:f&&(t||I?.isDraft)?p:null,originalData:g,eventType:c}}catch(a){return this.loggingService.catch("Error in CommentAnnotationsResolverService stripCommentAnnotationData:",a),{strippedData:null,originalData:null}}}formatCommentThreadData(e){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentThreadData","color: green;"),this.usersService.userDataProviderAvailable()){e?.from?.userId&&(e.from={userId:e.from.userId}),e?.to&&(e.to=e?.to?.map(r=>r?.userId?{userId:r.userId}:r)),e?.taggedUserContacts&&(e.taggedUserContacts=e?.taggedUserContacts?.map(r=>r?.contact?.userId?D(E({},r),{contact:{userId:r.contact.userId}}):r));let t=e?.taggedUserContacts?.filter((r,a,s)=>s.findIndex(c=>c.text===r.text)===a)||[];t.forEach(r=>{if(r?.text&&r?.contact?.userId){let a=new RegExp(pd(r.text),"g");e.commentText=e.commentText?.replaceAll(a,s=>`{{${r.userId}}}`),e.commentHtml=e.commentHtml?.replaceAll(a,s=>`{{${r.userId}}}`)}}),t.forEach(r=>{r?.text&&r?.contact?.userId&&(r.text="")})}return e}catch(t){return this.loggingService.catch("Error in CommentUtilsService formatCommentThreadData:",t),e}}getDeniedForYouUsers(t){return Q(this,arguments,function*({extraData:e}){try{let r=Object.values(e?.annotationData?.subscribedUsers||{}).map(s=>s.user.userId)??[],a=[];if(this.userPermissionService?.isPermissionProviderAvailable()&&r.length){let s=e?.metadata?.clientDocumentId,c=[];r.forEach(f=>{if(c.push({userId:f,resource:{id:s,type:Fo.DOCUMENT,source:Gi.SET_NOTIFICATIONS,organizationId:e?.metadata?.clientOrganizationId??""}}),e?.annotationData?.context?.access&&this.userPermissionService?.getIsContextEnabled()){let I=JSON.stringify(e?.annotationData?.context?.access);c.push({userId:f,resource:{id:I,type:Fo.CONTEXT,source:Gi.SET_NOTIFICATIONS,organizationId:e?.metadata?.clientOrganizationId??"",context:{access:e?.annotationData?.context?.access}}})}});let p=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:Gi.SET_NOTIFICATIONS,uniqueId:p,timestamp:new Date().getTime(),source:"internal",payload:{requests:c}});let g=yield this.userPermissionService?.onResourceAccessRequired({requests:c,uniqueId:p,methodName:Gi.SET_NOTIFICATIONS});g?.success&&g?.data?.length&&g.data.forEach(f=>{f.hasAccess||a.push(f.userId)})}return a}catch(r){return this.loggingService.catch("Error in CommentUtilsService getDeniedForYouUsers:",r),[]}})}handleCommentEncryption(c){return Q(this,arguments,function*({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: handleCommentEncryption","color: green;");let p=Bk(this.authService.getFirebaseConfig()?.firebaseOptions),g=Qi(this.functions,Ji({url:wn.cloudFunction?.[p]?.setEncryptedData,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3});if(r){r=this.notificationService?.processNotificationData(r),r.annotationData=e;let z=r?.targetAnnotationData?.commentId;if(z){let G=e?.comments?.find(J=>J?.commentId===z);G&&(r.targetAnnotationData=G)}try{let G=this.stripCommentAnnotationData({data:r.annotationData,actionType:r?.actionType??Wt.NEWLY_ADDED});G?.originalData&&(r.annotationData=this.formatCommentData(G.originalData)),r?.targetAnnotationData&&(r.targetAnnotationData=this.formatCommentThreadData(this.stripCommentsFromAnnotationData({comment:r.targetAnnotationData})))}catch(G){this.loggingService.warn("Error in CommentUtilsService handleCommentEncryption:",G)}}let f=iu.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),I=yield this.getDeniedForYouUsers({extraData:r}),T={path:t??"",data:e??{},dbId:f??"",notificationData:r||void 0,notificationURL:wn.firebaseNotificationsDatabaseURL,feature:"comment",eventType:a??"PATCH",sdkVersion:_a(),deniedForYouUsers:I,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),isCommentResolverUsed:this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),metadata:s},B=yield wl(T,this.authService.getUser()?.userId??"");yield g({veltData:B})}catch(p){this.loggingService.catch("Error in CommentUtilsService handleCommentEncryption:",p)}})}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln),ee(je),ee(Do),ee(Ft),ee(nl),ee(ou),ee(ni))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Bpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromUserIamData(e){try{this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: getUserIdsToResolveFromUserIamData","color: green;");let t=new Set;if(e?.length)for(let r of e)r?.user?.userId&&t.add(r?.user?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ContactUtilsService getUserIdsToResolveFromUserIamData: ",t),[]}}mergeUserIamWithUser(e){try{if(this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: mergeUserIamWithUser","color: green;"),e?.user?.userId){let t=this.usersService.getUserById(e?.user?.userId);if(t){let r=t;e?.user&&typeof e.user=="object"&&(r=E(E({},r),e.user)),e=D(E({},e),{user:r})}}return e}catch(t){return this.loggingService.catch("Error in ContactUtilsService mergeUserIamWithUser: ",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Vpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromCursorUsers(e){try{this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: getUserIdsToResolveFromCursorUsers","color: green;");let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in CursorUtilsService getUserIdsToResolveFromCursorUsers:",t),[]}}mergeCursorUserWithUser(e){try{if(this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: mergeCursorUserWithUser","color: green;"),this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in CursorUtilsService mergeCursorUserWithUser:",t),e}}formatCursorUserData(e){try{if(this.loggingService.log("%c[WB] Calling CursorUtilsService FUNCTION: formatCursorUserData","color: green;"),this.usersService.userDataProviderAvailable()){let t=["userId","comment","positionX","positionY","screenWidth","screenHeight","screenScrollHeight","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","targetElement","position","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in CursorUtilsService formatCursorUserData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var I9=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromHuddleAttendees(e){try{this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: getUserIdsToResolveFromHuddleAttendees","color: green;");let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in HuddleUtilsService getUserIdsToResolveFromHuddleAttendees:",t),[]}}mergeHuddleAttendeeWithUser(e){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: mergeHuddleAttendeeWithUser","color: green;"),e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService mergeHuddleAttendeeWithUser:",t),e}}formatHuddleAttendeeData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","userSnippylyId","state","timestamp","initialHuddleMode","streamMetadata","initialHuddleType","huddleOnCursorMode"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService formatHuddleAttendeeData:",t),e}}getUserIdsToResolveFromHuddleMessages(e){try{this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: getUserIdsToResolveFromHuddleMessages","color: green;");let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in HuddleUtilsService getUserIdsToResolveFromHuddleMessages:",t),[]}}mergeHuddleMessageWithUser(e){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: mergeHuddleMessageWithUser","color: green;"),e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService mergeHuddleMessageWithUser:",t),e}}resolveUsersFromHuddleMessages(e){return Q(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: resolveUsersFromHuddleMessages","color: green;"),this.usersService.userDataProviderAvailable()){let t=this.getUserIdsToResolveFromHuddleMessages(e),r=vt(),a=Rl.GET_HUDDLE_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:Hr.RESOLVE_USERS_FROM_HUDDLE_MESSAGES,moduleName:a,source:"internal",payload:{userIds:t}});let s=yield this.usersService.resolveUsers({userIds:t,uniqueId:r,moduleName:a});for(let c of e)c?.from?.userId&&s[c.from.userId]&&(c.from=s[c.from.userId])}return e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService resolveUsersFromHuddleMessages:",t),e}})}formatHuddleMessageData(e){try{return this.loggingService.log("%c[WB] Calling HuddleUtilsService FUNCTION: formatHuddleMessageData","color: green;"),this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e}catch(t){return this.loggingService.catch("Error in HuddleUtilsService formatHuddleMessageData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var E9=(()=>{let o=class o{constructor(e,t,r){this.coreActionsService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromLiveStateCustom(e){try{let t=new Set;return e?.updatedBy&&t.add(e?.updatedBy?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustom:",t),[]}}mergeLiveStateCustomWithUser(e){try{if(e?.updatedBy?.userId){let t=this.usersService.getUserById(e?.updatedBy?.userId);t&&(e.updatedBy=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateCustomWithUser:",t),e}}formatLiveStateCustomData(e){try{return this.usersService.userDataProviderAvailable()&&e?.updatedBy&&(e.updatedBy={userId:e.updatedBy.userId}),e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateCustomData:",t),e}}getUserIdsToResolveFromLiveStateCustoms(e){try{let t=new Set;for(let r of e)r?.updatedBy?.userId&&t.add(r?.updatedBy?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustoms:",t),[]}}getUserIdsToResolveFromLiveStates(e){try{let t=new Set;return e?.default?.singleEditorMode?.editor?.userId&&t.add(e?.default?.singleEditorMode?.editor?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStates:",t),[]}}getUserIdsToResolveFromLiveStateSingleEditorMode(e){try{let t=new Set;return e?.editor?.userId&&t.add(e?.editor?.userId),e?.requestEditorAccess?.user?.userId&&t.add(e?.requestEditorAccess?.user?.userId),Array.from(t)}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateSingleEditorMode:",t),[]}}mergeLiveStateWithUser(e){try{if(e?.default?.singleEditorMode?.editor?.userId){let t=this.usersService.getUserById(e?.default?.singleEditorMode?.editor?.userId);t&&(e.default.singleEditorMode.editor=t)}if(e?.default?.singleEditorMode?.requestEditorAccess?.user?.userId){let t=this.usersService.getUserById(e?.default?.singleEditorMode?.requestEditorAccess?.user?.userId);t&&(e.default.singleEditorMode.requestEditorAccess.user=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateWithUser:",t),e}}mergeSingleEditorLiveStateDataWithUser(e){try{if(e?.editor?.userId){let t=this.usersService.getUserById(e?.editor?.userId);t&&(e.editor=t)}if(e?.requestEditorAccess?.user?.userId){let t=this.usersService.getUserById(e?.requestEditorAccess?.user?.userId);t&&(e.requestEditorAccess.user=t)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService mergeSingleEditorLiveStateDataWithUser:",t),e}}resolveAndMergeSingleEditorLiveStateDataWithUser(e){return Q(this,null,function*(){try{let t=this.getUserIdsToResolveFromLiveStates({default:{singleEditorMode:e}});if(t.length){let r=vt(),a=Rl.GET_SINGLE_EDITOR_USERS;return this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:Hr.RESOLVE_AND_MERGE_SINGLE_EDITOR_LIVE_STATE_DATA_WITH_USER,moduleName:a,source:"internal",payload:{userIds:t}}),yield this.usersService.resolveUsers({userIds:t,uniqueId:r,moduleName:a}),this.mergeSingleEditorLiveStateDataWithUser(e)}return e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService resolveAndMergeSingleEditorLiveStateDataWithUser:",t),e}})}formatLiveStateSingleEditorModeData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.editor?.userId&&(e.editor={userId:e.editor.userId}),e?.requestEditorAccess?.user?.userId&&(e.requestEditorAccess.user={userId:e.requestEditorAccess.user.userId})),e}catch(t){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateSingleEditorModeData:",t),e}}mergeLiveStateCustomsWithUsers(e){try{for(let t of e)if(t?.updatedBy?.userId){let r=this.usersService.getUserById(t?.updatedBy?.userId);r&&(t.updatedBy=r)}return e}catch(t){return this.loggingService.catch("Error in mergeLiveStateCustomsWithUsers:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(ni),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var $pe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromMultiThreads(e){try{let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService getUserIdsToResolveFromMultiThreads:",t),[]}}mergeMultiThreadWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService mergeMultiThreadWithUser:",t),e}}formatMultiThreadData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.commentAnnotationsMap&&(e.commentAnnotationsMap=null)),e}catch(t){return this.loggingService.catch("Error in MultiThreadUtilsService formatMultiThreadData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var VC=(()=>{let o=class o{constructor(e,t,r){this.authService=e,this.loggingService=t,this.usersService=r}getUserIdsToResolveFromRecorders(e){try{let t=new Set;for(let r of e)r?.from?.userId&&t.add(r?.from?.userId),r?.transcription?.from?.userId&&t.add(r?.transcription?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in RecorderUtilsService getUserIdsToResolveFromRecorders:",t),[]}}mergeRecorderWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.transcription?.from?.userId){let t=this.usersService.getUserById(e?.transcription?.from?.userId);t&&(e.transcription.from=t)}return e}catch(t){return this.loggingService.catch("Error in RecorderUtilsService mergeRecorderWithUser:",t),e}}formatRecorderData(e,t){try{return e.transcription=e?.transcription?D(E({},e.transcription),{lastUpdated:t}):void 0,this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.transcription?.from?.userId&&(e.transcription.from={userId:e.transcription.from.userId})),e}catch(r){return this.loggingService.catch("Error in RecorderUtilsService formatRecorderData:",r),e}}formatRecorderDataForWhisperTranscription(e){try{return this.usersService.userDataProviderAvailable()&&e?.fromUser?.userId&&(e.fromUser={userId:e.fromUser?.userId}),e}catch(t){return this.loggingService.catch("Error in RecorderUtilsService formatRecorderDataForWhisperTranscription:",t),e}}encryptRecorderAnnotation(e){return Q(this,null,function*(){try{return yield wl(e,this.authService.getUser()?.userId??"")}catch(t){this.loggingService.catch("Error in RecorderUtilsService encryptRecorderAnnotation:",t);return}})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var x9=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.commentUtilsService=e,this.recorderUtilsService=t,this.loggingService=r,this.usersService=a,this.authService=s,this.commentAnnotationsResolverService=c}getUserIdsToResolveFromNotifications(e){try{let t=new Set;for(let r of e){let{notification:a}=r;switch(a?.actionUser?.userId&&t.add(a?.actionUser?.userId),a?.displayHeadlineMessageTemplateData?.actionUser?.userId&&t.add(a?.displayHeadlineMessageTemplateData?.actionUser?.userId),a?.displayHeadlineMessageTemplateData?.recipientUser?.userId&&t.add(a?.displayHeadlineMessageTemplateData?.recipientUser?.userId),a?.notificationSource){case"comment":if(a?.notificationSourceData){let s=this.commentUtilsService.getUserIdsToResolveFromComments([a?.notificationSourceData]);for(let c of s)t.add(c)}break}}return Array.from(t)}catch(t){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",t),[]}}mergeStrippedDataWithNotification(e){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeStrippedDataWithNotification","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return e;let t=this.commentAnnotationsResolverService.getAnnotationById(e?.notification?.targetAnnotationId),r=e?.raw?.targetAnnotationData?.commentId,a=t?.comments?.[r]?.commentText,s=t?.comments?.[r]?.commentHtml;return a&&s&&e?.raw?.notificationSource==="comment"&&(e.notification.displayBodyMessageTemplate=a,e.raw.targetAnnotationData.commentText=a,e.raw.targetAnnotationData.commentHtml=s),e}catch(t){return this.loggingService.catch("Error in NotificationUtilsService mergeStrippedDataWithNotification:",t),e}}mergeLocationWithNotification(e,t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeLocationWithNotification","color: green;");let r=e?.notification?.notificationSourceData?.location?.id,a=e?.notification?.notificationSourceData?.metadata?.documentId;if(!r||!a)return e;let s=t?.[a]?.[r];return s&&(e.notification.notificationSourceData.location=s?.location,e?.raw?.annotationData?.location&&(e.raw.annotationData.location=s?.location)),e}catch(r){return this.loggingService.catch("Error in NotificationUtilsService mergeLocationWithNotification:",r),e}}mergeNotificationWithUser(e){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeNotificationWithUser","color: green;");let{notification:t}=e;if(t?.actionUser?.userId){let r=this.usersService.getUserById(t?.actionUser?.userId);r&&(t.actionUser=r)}if(t?.displayHeadlineMessageTemplateData?.actionUser?.userId){let r=this.usersService.getUserById(t?.displayHeadlineMessageTemplateData?.actionUser?.userId);r&&(t.displayHeadlineMessageTemplateData.actionUser=r)}if(t?.displayHeadlineMessageTemplateData?.recipientUser?.userId){let r=this.usersService.getUserById(t?.displayHeadlineMessageTemplateData?.recipientUser?.userId);r&&(t.displayHeadlineMessageTemplateData.recipientUser=r)}switch(t?.notificationSource){case"comment":t?.notificationSourceData&&this.commentUtilsService.mergeCommentWithUser(t?.notificationSourceData);break}return e}catch(t){return this.loggingService.catch("Error in NotificationUtilsService mergeNotificationWithUser:",t),e}}formatNotification(e,t){try{switch(typeof e=="object"&&(e=JSON.parse(JSON.stringify(e))),this.usersService.userDataProviderAvailable()&&e?.actionUser&&(e.actionUser={userId:e.actionUser.userId}),e.notificationSource){case"comment":this.commentUtilsService.formatCommentData(e.annotationData),this.commentUtilsService.formatCommentThreadData(e.targetAnnotationData);break;case"recorder":this.recorderUtilsService.formatRecorderData(e.annotationData,t);break}return e}catch(r){return this.loggingService.catch("Error in NotificationUtilsService formatNotification: ",r),e}}getTargetAnnotationIdsFromNotifications(e){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getTargetAnnotationIdsFromNotifications","color: green;");let t=[];return Object.values(e).forEach(r=>{r?.notification?.targetAnnotationId&&r?.raw?.notificationSource==="comment"&&t.push(r.notification.targetAnnotationId)}),t}catch(t){return this.loggingService.catch("Error in NotificationUtilsService getTargetAnnotationIdsFromNotifications:",t),[]}}handleNotificationEncryption(t){return Q(this,arguments,function*({data:e}){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: handleNotificationEncryption","color: green;");let r="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??"");return yield wl(e,r)}catch(r){return this.loggingService.catch("Error in NotificationUtilsService handleNotificationEncryption:",r),e}})}};o.\u0275fac=function(t){return new(t||o)(ee(ru),ee(VC),ee(_),ee(Ln),ee(je),ee(nl))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var zpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromPresenceUsers(e){try{let t=new Set;for(let r of e)r?.userId&&t.add(r?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in PresenceUtilsService getUserIdsToResolveFromPresenceUsers:",t),[]}}mergePresenceUserWithUser(e){try{if(this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=E(E({},e),t))}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService mergePresenceUserWithUser:",t),e}}formatPresenceUserData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(r=>{t.includes(r)||(e[r]=null)})}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService formatPresenceUserData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Gpe=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.loggingService=e,this.usersService=t,this.authService=r,this.functions=a,this.configService=s,this.reactionAnnotationsResolverService=c}getUserIdsToResolveFromReactions(e){try{let t=new Set;for(let r of e)if(r?.from?.userId&&t.add(r?.from?.userId),r?.reactions?.length)for(let a of r?.reactions)a?.from?.userId&&t.add(a?.from?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",t),[]}}handleReactionEncryption(a){return Q(this,arguments,function*({data:e,firestorePath:t,eventType:r}){try{let s=Bk(this.authService.getFirebaseConfig()?.firebaseOptions),c=Qi(this.functions,Ji({url:wn.cloudFunction?.[s]?.setEncryptedData,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),p=iu.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),g=this.authService.getUser()?.userId??"",f={path:t??"",data:e??{},dbId:p??"",feature:"reaction",eventType:r??"PATCH",sdkVersion:_a()},I=yield wl(f,g);yield c({veltData:I})}catch(s){this.loggingService.catch("Error in handleReactionEncryption:",s)}})}mergeReactionWithUser(e){try{if(this.usersService.userDataProviderAvailable()){if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}if(e?.reactions?.length){for(let t of e?.reactions)if(t?.from?.userId){let r=this.usersService.getUserById(t?.from?.userId);r&&(t.from=r)}}}return e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService mergeReactionWithUser:",t),e}}formatReactionData(e){try{return this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e.reactions=e?.reactions?.map(t=>(this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t)),e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService formatReactionData:",t),e}}isReactionDataChanged(e,t){try{this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: isReactionDataChanged","color: green;");let r=this.reactionAnnotationsResolverService.getReactionAnnotationById(t);return r?!hi(e,r):!0}catch(r){return this.loggingService.catch("Error in ReactionUtilsService isReactionDataChanged:",r),!0}}stripReactionAnnotationData(e){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: stripReactionAnnotationData","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return{originalData:e,strippedData:null};let t={};if(e&&e.annotationId){let r=e.annotationId;if(t[r]=E({annotationId:r,metadata:oC(e.metadata??{}),icon:e.icon},e?.from&&{from:e?.from}),!this.isReactionDataChanged(t[r],r))return{strippedData:null,originalData:e};delete e?.icon,e.isReactionResolverUsed=!0}return{strippedData:t,originalData:e}}catch(t){return this.loggingService.catch("Error in ReactionUtilsService stripReactionAnnotationData:",t),{strippedData:null,originalData:null}}}mergeStrippedDataWithReactionAnnotations(e){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: mergeStrippedDataWithReactionAnnotations","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return e;let t=this.reactionAnnotationsResolverService.getReactionAnnotationById(e?.annotationId);return t&&t.icon&&(e.icon=t.icon),e}catch(t){return this.loggingService.catch("Error in ReactionUtilsService mergeStrippedDataWithReactionAnnotations:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln),ee(je),ee(Do),ee(Ft),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromSelections(e){try{let t=new Set;for(let r of e)r?.user?.userId&&t.add(r.user.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in SelectionUtilsService getUserIdsToResolveFromSelections:",t),[]}}mergeSelectionWithUser(e){try{if(e?.user?.userId){let t=this.usersService.getUserById(e?.user?.userId);t&&(e.user=t)}return e}catch(t){return this.loggingService.catch("Error in SelectionUtilsService mergeSelectionWithUser:",t),e}}formatSelectionData(e){try{return this.usersService.userDataProviderAvailable()&&e?.user?.userId&&(e.user={userId:e.user.userId}),e}catch(t){return this.loggingService.catch("Error in SelectionUtilsService formatSelectionData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var qpe=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromTags(e){try{let t=new Set;for(let r of e)if(r?.from?.userId&&t.add(r.from.userId),r?.to?.length)for(let a of r.to)a?.userId&&t.add(a.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in TagUtilsService getUserIdsToResolveFromTags:",t),[]}}mergeTagWithUser(e){try{if(e?.from?.userId){let t=this.usersService.getUserById(e?.from?.userId);t&&(e.from=t)}return e?.to?.length&&(e.to=e.to.map(t=>{if(t?.userId){let r=this.usersService.getUserById(t?.userId);r&&(t=r)}return t})),e}catch(t){return this.loggingService.catch("Error in TagUtilsService mergeTagWithUser:",t),e}}formatTagData(e){try{return this.usersService.userDataProviderAvailable()&&(e?.from?.userId&&(e.from={userId:e.from.userId}),e?.to?.length&&(e.to=e.to.map(t=>(t?.userId&&(t={userId:t.userId}),t)))),e}catch(t){return this.loggingService.catch("Error in TagUtilsService formatTagData:",t),e}}};o.\u0275fac=function(t){return new(t||o)(ee(_),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Im=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye,Ne,Ve){this.areaUtilsService=e,this.arrowUtilsService=t,this.commentUtilsService=r,this.contactUtilsService=a,this.coreActionsService=s,this.cursorUtilsService=c,this.huddleUtilsService=p,this.liveStateUtilsService=g,this.loggingService=f,this.multiThreadUtilsService=I,this.notificationUtilsService=T,this.presenceUtilsService=B,this.reactionUtilsService=z,this.recorderUtilsService=G,this.selectionUtilsService=J,this.tagUtilsService=ne,this.usersService=ve,this.docService=ye,this.commentAnnotationsResolverService=Ne,this.reactionAnnotationsResolverService=Ve}getErrorForGetRequests({feature:e,error:t}){try{switch(e){case"organizationMetadata":case"documentMetadata":case"folderMetadata":return(t?.message??"")?.includes("Missing or insufficient permissions.")?{errorCode:"PERMISSION_DENIED"}:null;default:return null}}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService getErrorForGetRequests:",r),null}}getFirestorePath({feature:e,properties:t,documentPaths:r,apiKey:a}){try{if(!a)return;let{documentId:s,organizationId:c,folderId:p}=t;c||(c=r?.organizationId);let g=new _9({apiKey:a,documentId:s?`${s}`:"",organizationId:c?`${c}`:"",veltFolderId:p?`${p}`:void 0});switch(e){case"userConfig":return t?.userId&&t?.documentId&&g?.userConfig?`${g?.userConfig}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${t?.documentId}`:void 0;case"allPermissionsUsers":return g?.permissionsUsers?`${g?.permissionsUsers}`:void 0;case"comment":return t?.documentId&&t?.id&&g?.comment?`${g?.comment}/${t?.id}`:void 0;case"allComments":return t?.documentId&&g?.comment?`${g?.comment}`:void 0;case"multiThread":return t?.documentId&&t?.id&&g?.multiThread?`${g?.multiThread}/${t?.id}`:void 0;case"allMultiThreads":return t?.documentId&&g?.multiThread?`${g?.multiThread}`:void 0;case"crdt":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}`:void 0;case"allLastNotificationTimestamp":return g?.lastNotificationTimestamp?`${g?.lastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return t?.id&&g?.lastNotificationTimestamp?`${g?.lastNotificationTimestamp}/${t?.id}`:void 0;case"area":return t?.documentId&&t?.id&&g?.area?`${g?.area}/${t?.id}`:void 0;case"allAreas":return t?.documentId&&g?.area?`${g?.area}`:void 0;case"allDocuments":return g?.document?`${g?.document}`:void 0;case"allLocations":return g?.location?`${g?.location}`:void 0;case"allFolders":return g?.folder?`${g?.folder}`:void 0;case"folder":return g?.folder&&t.folderId?`${g?.folder}/${t.folderId}`:void 0;case"documentUserAccess":return t?.documentId&&t?.id&&g?.documentUsers?`${g?.documentUsers}/${t?.id}`:void 0;case"reaction":return t?.documentId&&t?.id&&g?.reaction?`${g?.reaction}/${t?.id}`:void 0;case"allReactions":return t?.documentId&&g?.reaction?`${g?.reaction}`:void 0;case"recorder":return t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}/${t?.id}`:void 0;case"allRecorders":return t?.documentId&&g?.recorder?`${g?.recorder}`:void 0;case"recorderTrackEvent":return t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}/${t?.id}/trackRecorderEvent`:void 0;case"documentAccessType":return t?.documentId&&g?.document?`${g?.document}/${t?.documentId}`:void 0;case"organizationMetadata":return g?.organization?`${g?.organization}`:void 0;case"documentIam":case"documentMetadata":return t?.documentId&&g?.document?`${g?.document}/${t?.documentId}`:void 0;case"folderMetadata":return t?.folderId&&g?.folder?`${g?.folder}/${t?.folderId}`:void 0;case"locationMetadata":return t?.documentId&&g?.location&&t?.id?`${g?.location}/${t?.id}`:void 0;case"documentUser":return t?.documentId&&t?.id&&g?.documentUsers?`${g?.documentUsers}/${t?.id}`:void 0;case"allDocumentUsers":return g?.users?`${g?.users}`:void 0;case"allFolderUsers":return g?.users?`${g?.users}`:void 0;case"allOrganizationGroups":return g?.organizationGroups?`${g?.organizationGroups}`:void 0;case"allOrganizationUsers":return g?.users?`${g?.users}`:void 0;case"notificationViewsTimestamp":return t?.documentId&&t?.id&&g?.notificationViews?`${g?.notificationViews}/${t?.id}`:void 0;case"allDocumentViews":return t?.documentId&&g?.documentViews?`${g?.documentViews}`:void 0;case"documentViews":case"documentMetadataViews":case"documentDayViews":case"documentUsersViews":return t?.documentId&&t?.id&&g?.documentViews?`${g?.documentViews}/${t?.id}`:void 0;case"locationDayViews":case"locationUsersViews":case"locationViews":case"locationMetadataViews":case"location":return t?.documentId&&t?.id&&g?.locationViews?`${g?.locationViews}/${t?.id}`:void 0;case"allLocationViews":return t?.documentId&&g?.locationViews?`${g?.locationViews}`:void 0;case"allDocNotifications":return t?.documentId&&g?.docNotification?`${g?.docNotification}`:void 0;case"docNotificationViews":case"docNotification":return t?.documentId&&t?.id&&g?.docNotification?`${g?.docNotification}/${t?.id}`:void 0;case"userNotificationViews":case"userNotification":return t?.userId&&t?.id&&g?.notificationUsers?`${g?.notificationUsers}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}/${t?.id}`:void 0;case"allUserNotifications":return t?.userId&&g?.notificationUsers?`${g?.notificationUsers}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}`:void 0;default:throw new Error(`Unknown feature: ${e}`)}}catch(s){this.loggingService.catch("Error in CommonDbUtilsService getFirestorePath:",s);return}}getFirestoreCollectionGroupPath(e){try{switch(e){case"allComments":return U.FIREBASE_PARTIAL_PATH_COMMENT;case"allDocuments":return U.FIREBASE_PARTIAL_PATH_DOCS;case"allLocations":return U.FIREBASE_PARTIAL_PATH_LOCATION;case"allMultiThreads":return U.FIREBASE_PARTIAL_PATH_MULTI_THREAD;case"allAreas":return U.FIREBASE_PARTIAL_PATH_AREA;case"allReactions":return U.FIREBASE_PARTIAL_PATH_REACTION;case"allRecorders":return U.FIREBASE_PARTIAL_PATH_RECORDER;case"allDocumentViews":return U.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS;case"allLocationViews":return U.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS;case"allDocumentUsers":return U.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS;case"allFolderUsers":return U.FIREBASE_PARTIAL_PATH_FOLDER_USERS;default:throw new Error(`Unknown feature: ${e}`)}}catch(t){this.loggingService.catch("Error in CommonDbUtilsService getFirestoreCollectionGroupPath:",t);return}}getDocumentPath({feature:e,properties:t,defaultDocumentPaths:r,apiKey:a,useFirestore:s}){try{if(!a)return;let{documentId:c,organizationId:p}=t;p||(p=r?.organizationId);let g=new Sm({apiKey:a,documentId:c?`${c}`:"",organizationId:p?`${p}`:""});switch(e){case"userConfig":return t?.userId&&t?.documentId&&g?.userConfig?`${g?.userConfig}/${t?.userId}/${U.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${t?.documentId}`:void 0;case"allComments":return!s&&t?.documentId&&g?.comment?`${g?.comment}`:void 0;case"allGlobalContacts":return t?.documentId&&g?.globalContacts?`${g?.globalContacts}`:void 0;case"globalContacts":return t?.documentId&&t?.userId&&g?.globalContacts?`${g?.globalContacts}${t?.userId}`:void 0;case"groupContacts":return t?.documentId&&t?.groupId&&g?.groupContacts?`${g?.groupContacts}${t?.groupId}`:void 0;case"groupContactsUser":return t?.documentId&&t?.groupId&&t?.userId&&g?.groupContacts?`${g?.groupContacts}${t?.groupId}/${t?.userId}`:void 0;case"allLoginContacts":return t?.documentId&&t?.userId&&g?.logins?`${g?.logins}${t?.userId}/contacts`:void 0;case"allLogins":return t?.documentId&&g?.logins?`${g?.logins}`:void 0;case"logins":return t?.documentId&&t?.userId&&g?.logins?`${g?.logins}${t?.userId}`:void 0;case"customerMetadata":return g?.customerMetadata?`${g?.customerMetadata}`:void 0;case"allArrows":return t?.documentId&&g?.arrow?`${g?.arrow}`:void 0;case"arrow":return t?.documentId&&g?.arrow&&t.id?`${g?.arrow}${t.id}`:void 0;case"allCursors":return t?.documentId&&g?.cursor?`${g?.cursor}`:void 0;case"cursor":return t?.documentId&&g?.cursor&&t.id?`${g?.cursor}${t.id}`:void 0;case"flockUser":return t?.documentId&&g?.flock&&t.id?`${g?.flock}users/${t.id}`:void 0;case"flockSession":return t?.documentId&&g?.flock&&t.id?`${g?.flock}sessions/${t.id}`:void 0;case"allHuddleAttendees":return t?.documentId&&g?.huddle?`${g?.huddle}attendees`:void 0;case"huddleAttendee":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}attendees/${t.id}`:void 0;case"huddleAttendeeState":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}attendees/${t.id}/state`:void 0;case"allHuddleInvitees":return t?.documentId&&g?.huddle?`${g?.huddle}invitees`:void 0;case"huddleConnection":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}connections/${t.id}`:void 0;case"huddleIceCandidate":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}iceCandidates/${t.id}`:void 0;case"allHuddleIceCandidates":return t?.documentId&&g?.huddle?`${g?.huddle}iceCandidates`:void 0;case"allHuddleMessages":return t?.documentId&&g?.huddle?`${g?.huddle}messages`:void 0;case"huddleMessage":return t?.documentId&&g?.huddle&&t.id?`${g?.huddle}messages/${t.id}`:void 0;case"allLiveStates":return t?.documentId&&g?.liveState?`${g?.liveState}`:void 0;case"allLiveStateCustoms":return t?.documentId&&g?.liveState?`${g?.liveState}custom`:void 0;case"liveStateCustom":return t?.documentId&&g?.liveState&&t?.id?`${g?.liveState}custom/${t.id}`:void 0;case"liveStateSingleEditorMode":return t?.documentId&&g?.liveStateSingleEditorMode?`${g?.liveStateSingleEditorMode}`:void 0;case"liveStateAutoSyncState":return t?.documentId&&g?.liveState?`${g?.liveState}default/autoSyncState`:void 0;case"liveStateAutoSyncStateCurrent":return t?.documentId&&g?.liveState?`${g?.liveState}default/autoSyncState/current`:void 0;case"liveStateAutoSyncStateHistoryId":return t?.documentId&&g?.liveState&&t?.id?`${g?.liveState}default/autoSyncState/history/${t.id}`:void 0;case"presence":return t?.documentId&&g?.presence&&t?.userId?`${g?.presence}${t?.userId}`:void 0;case"allPresence":return t?.documentId&&g?.presence?`${g?.presence}`:void 0;case"workspaceIam":return g?.workspaceIam?`${g?.workspaceIam}`:void 0;case"selection":return t?.documentId&&g?.selection&&t?.userId?`${g?.selection}${t?.userId}`:void 0;case"allSelections":return t?.documentId&&g?.selection?`${g?.selection}`:void 0;case"syncVideoPlayer":return t?.documentId&&g?.syncVideoPlayer?`${g?.syncVideoPlayer}`:void 0;case"allTags":return t?.documentId&&g?.tag?`${g?.tag}`:void 0;case"tag":return t?.documentId&&g?.tag&&t?.id?`${g?.tag}${t?.id}`:void 0;case"userContactUs":return t?.documentId&&g?.userContactUs?`${g?.userContactUs}`:void 0;case"userFeedback":return t?.documentId&&g?.userFeedback?`${g?.userFeedback}`:void 0;case"userReportBug":return t?.documentId&&g?.userReportBugs?`${g?.userReportBugs}`:void 0;case"comment":return!s&&t?.documentId&&t?.id&&g?.comment?`${g?.comment}${t?.id}`:void 0;case"allMultiThreads":return!s&&t?.documentId&&g?.multiThread?`${g?.multiThread}`:void 0;case"crdt":return!s&&t?.documentId&&g?.crdt?`${g?.crdt}`:void 0;case"crdtData":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/data`:void 0;case"crdtSyncState":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/state`:void 0;case"crdtSyncPresence":return t?.documentId&&t.userId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/presence/${t.userId}`:void 0;case"allCrdtSyncPresence":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/sync/presence`:void 0;case"crdtPresence":return t?.documentId&&t.userId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/presence/${t.userId}`:void 0;case"allCrdtPresence":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/presence`:void 0;case"crdtVersion":return t?.documentId&&g?.crdt&&t?.id&&t?.versionId?`${g?.crdt}/${t?.id}/versions/${t?.versionId}`:void 0;case"crdtVersions":return t?.documentId&&g?.crdt&&t?.id?`${g?.crdt}/${t?.id}/versions`:void 0;case"multiThread":return!s&&t?.documentId&&t?.id&&g?.multiThread?`${g?.multiThread}${t?.id}`:void 0;case"allLastNotificationTimestamp":return!s&&g?.organizationNotificationsLastNotificationTimestamp?`${g?.organizationNotificationsLastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return!s&&t?.id&&g?.organizationNotificationsLastNotificationTimestamp?`${g?.organizationNotificationsLastNotificationTimestamp}${t?.id}`:void 0;case"documentIam":return!s&&t?.documentId&&g?.documentIam?`${g?.documentIam}`:void 0;case"allDocuments":return!s&&g?.docs&&t?.documentId?`${g?.docs}/${t?.documentId}/${U.FIREBASE_PARTIAL_PATH_METADATA}`:void 0;case"allAreas":return!s&&t?.documentId&&g?.area?`${g?.area}`:void 0;case"area":return!s&&t?.id&&g?.area?`${g?.area}${t?.id}`:void 0;case"folder":return!s&&t?.folderId&&g?.folder?`${g?.folder}${t?.folderId}`:void 0;case"documentUserAccess":return!s&&t?.id&&g?.documentIam?`${g?.documentIam}users/${t?.id}`:void 0;case"documentUser":return!s&&t?.documentId&&t?.id&&g?.documentIam?`${g?.documentIam}users/${t?.id}`:void 0;case"allDocumentUsers":return!s&&t?.documentId&&g?.documentIam?`${g?.documentIam}users/`:void 0;case"allOrganizationGroups":return!s&&g?.organizationGroups?`${g?.organizationGroups}`:void 0;case"allOrganizationUsers":return!s&&g?.organizationIam?`${g?.organizationIam}users/`:void 0;case"reaction":return!s&&t?.id&&g?.reaction?`${g?.reaction}${t?.id}`:void 0;case"allReactions":return!s&&t?.documentId&&g?.reaction?`${g?.reaction}`:void 0;case"recorder":return!s&&t?.documentId&&t?.id&&g?.recorder?`${g?.recorder}${t?.id}`:void 0;case"allRecorders":return!s&&t?.documentId&&g?.recorder?`${g?.recorder}`:void 0;case"organizationMetadata":return!s&&g?.organizationMetadata?`${g?.organizationMetadata}`:void 0;case"heartbeat":return t?.id&&g?.heartbeat?`${g?.heartbeat}${t?.id}`:void 0;case"allHeartbeats":return g?.heartbeat?`${g?.heartbeat}`:void 0;case"heartbeatByDocument":return t?.id&&g?.heartbeatByDocument?`${g?.heartbeatByDocument}${t?.id}`:void 0;case"allHeartbeatsByDocument":return g?.heartbeatByDocument?`${g?.heartbeatByDocument}`:void 0;case"documentAccessType":return!s&&g?.documentIam?`${g?.documentIam}`:void 0;case"documentMetadata":return!s&&t?.documentId&&g?.metadata?`${g?.metadata}`:void 0;case"allDocumentViews":return!s&&t?.documentId&&g?.views?`${g?.views}documentViews/`:void 0;case"documentViews":return!s&&t?.documentId&&t?.id&&g?.views?`${g?.views}documentViews/${t?.id}`:void 0;case"allLocationViews":return!s&&t?.documentId&&g?.views?`${g?.views}locationViews/`:void 0;case"notificationViewsTimestamp":return!s&&t?.id&&t?.user&&g?.views?`${g?.views}notification/${t?.id}/views/${t?.user}`:void 0;case"documentUsersViews":return!s&&t?.id&&t?.user&&t?.date&&g?.views?`${g?.views}documentViews/${t?.id}/users/${t?.user}/${t?.date}`:void 0;case"documentMetadataViews":return!s&&t?.id&&g?.views?`${g?.views}documentViews/${t?.id}/metadata`:void 0;case"documentDayViews":return!s&&t?.id&&t?.date&&t?.user&&g?.views?`${g?.views}documentViews/${t?.id}/day/${t?.date}/${t?.user}`:void 0;case"locationViews":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}/location`:void 0;case"location":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}`:void 0;case"locationUsersViews":return!s&&t?.id&&t?.user&&t?.date&&g?.views?`${g?.views}locationViews/${t?.id}/users/${t?.user}/${t?.date}`:void 0;case"locationMetadataViews":return!s&&t?.id&&g?.views?`${g?.views}locationViews/${t?.id}/metadata`:void 0;case"locationDayViews":return!s&&t?.id&&t?.date&&t?.user&&g?.views?`${g?.views}locationViews/${t?.id}/day/${t?.date}/${t?.user}`:void 0;case"docNotificationViews":case"docNotification":return t?.documentId&&t?.id&&g?.organizationNotificationsWithDocumentId?`${g?.organizationNotificationsWithDocumentId}${t?.id}`:void 0;case"allDocNotifications":return t?.documentId&&g?.organizationNotificationsWithDocumentId?`${g?.organizationNotificationsWithDocumentId}`:void 0;case"allUserNotifications":return t?.userId&&g?.organizationNotificationsUsers?`${g?.organizationNotificationsUsers}${t?.userId}`:void 0;case"userNotificationViews":case"userNotification":return t?.userId&&t?.id&&g?.organizationNotificationsUsers?`${g?.organizationNotificationsUsers}${t?.userId}/${t?.id}`:void 0;case"locationMetadata":return;case"allLocations":return;case"folderMetadata":return;case"allPermissionsUsers":return;default:throw new Error(`Unknown feature: ${e}`)}}catch(c){this.loggingService.catch("Error in CommonDbUtilsService getDocumentPath:",c);return}}resolveAnnotations(r){return Q(this,arguments,function*({data:e,feature:t}){try{if(e&&e?.length>0)switch(t){case"allComments":{if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let a=vt(),s=MC.GET_COMMENT_ANNOTATIONS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:No.RESOLVE_COMMENT_ANNOTATIONS,moduleName:s,source:"internal",payload:{commentAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:a,moduleName:s})}break}case"allReactions":{if(this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()){let a=vt(),s=HI.GET_REACTION_ANNOTATIONS;this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:a,methodName:Ho.RESOLVE_REACTION_ANNOTATIONS,moduleName:s,source:"internal",payload:{reactionAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.reactionAnnotationsResolverService.resolveReactionAnnotations({request:{reactionAnnotationIds:e,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:a,moduleName:s})}break}default:break}}catch(a){this.loggingService.catch(`Error in CommonDbUtilsService resolveAnnotations: ${t}`,a)}})}formatResponse(c){return Q(this,arguments,function*({feature:e,data:t,shouldAwait:r=!1,forceResolve:a=!1,shouldCommentAnnotationsResolverAwait:s=!1}){try{if(this.usersService.userDataProviderAvailable()){let p=[];switch(e){case"allAreas":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.areaUtilsService.getUserIdsToResolveFromAreaAnnotations(Object.values(t)));break}case"allArrows":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.arrowUtilsService.getUserIdsToResolveFromArrowAnnotations(Object.values(t)));break}case"allCursors":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.cursorUtilsService.getUserIdsToResolveFromCursorUsers(Object.values(t)));break}case"allComments":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.commentUtilsService.getUserIdsToResolveFromComments(Object.values(t)));break}case"allDocumentUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allFolderUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allOrganizationUsers":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(t)));break}case"allMultiThreads":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.multiThreadUtilsService.getUserIdsToResolveFromMultiThreads(Object.values(t)));break}case"allDocNotifications":{t&&typeof t=="object"&&(p=this.notificationUtilsService.getUserIdsToResolveFromNotifications(Array.isArray(t)?t:Object.values(t)));break}case"allUserNotifications":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.notificationUtilsService.getUserIdsToResolveFromNotifications(Object.values(t)));break}case"allPresence":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.presenceUtilsService.getUserIdsToResolveFromPresenceUsers(Object.values(t)));break}case"allRecorders":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.recorderUtilsService.getUserIdsToResolveFromRecorders(Object.values(t)));break}case"allReactions":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.reactionUtilsService.getUserIdsToResolveFromReactions(Object.values(t)));break}case"allTags":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.tagUtilsService.getUserIdsToResolveFromTags(Object.values(t)));break}case"allHuddleAttendees":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.huddleUtilsService.getUserIdsToResolveFromHuddleAttendees(Object.values(t)));break}case"liveStateCustom":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustom(t));break}case"allLiveStateCustoms":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustoms(Object.values(t)));break}case"allLiveStates":{t&&typeof t=="object"&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStates(t));break}case"liveStateSingleEditorMode":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateSingleEditorMode(t));break}case"allSelections":{t&&typeof t=="object"&&!Array.isArray(t)&&(p=this.selectionUtilsService.getUserIdsToResolveFromSelections(Object.values(t)));break}default:p=[]}if(p?.length){let g=vt(),f=Rl.GET_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Hr.FORMAT_RESPONSE,source:"internal",moduleName:f,payload:{userIds:p,feature:e,forceResolve:a}}),r?yield this.usersService.resolveUsers({userIds:p,forceResolve:a,feature:e,uniqueId:g,moduleName:f}):this.usersService.resolveUsers({userIds:p,forceResolve:a,feature:e,uniqueId:g,moduleName:f})}}if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let p=[];switch(e){case"allDocNotifications":{if(t&&typeof t=="object"){let g=this.notificationUtilsService.getTargetAnnotationIdsFromNotifications(t);p=[...p,...g],p=p.filter(f=>!this.commentAnnotationsResolverService.getCommentAnnotationById(f))}break}case"allUserNotifications":{if(t&&typeof t=="object"&&!Array.isArray(t)){let g=this.notificationUtilsService.getTargetAnnotationIdsFromNotifications(t);p=[...p,...g],p=p.filter(f=>!this.commentAnnotationsResolverService.getCommentAnnotationById(f))}break}default:p=[]}if(p?.length){let g=vt(),f=MC.GET_NOTIFICATIONS;this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:No.FORMAT_RESPONSE,moduleName:f,source:"internal",payload:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??"",shouldCommentAnnotationsResolverAwait:s}}),s?yield this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:g,moduleName:f}):this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:p,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:g,moduleName:f})}}return t}catch(p){return this.loggingService.catch("Error in CommonDbUtilsService formatResponse:",p),t}})}mergeCommentAnnotationsWithData({data:e,feature:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeCommentAnnotationsWithData","color: green;"),this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())switch(t){case"allComments":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.commentUtilsService.mergeStrippedDataWithCommentAnnotations(s),r),{}):e;case"allDocNotifications":case"allUserNotifications":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.notificationUtilsService.mergeStrippedDataWithNotification(s),r),{}):e;default:return e}return e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeCommentAnnotationsWithData:",r),e}}mergeReactionAnnotationsWithData({data:e,feature:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeReactionAnnotationsWithData","color: green;"),this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())switch(t){case"allReactions":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((r,[a,s])=>(r[a]=this.reactionUtilsService.mergeStrippedDataWithReactionAnnotations(s),r),{}):e;default:return e}return e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeReactionAnnotationsWithData:",r),e}}mergeLocationMetadataWithData({data:e,feature:t,locationMetadata:r}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeLocationMetadataWithData","color: green;"),r&&typeof r=="object"&&!Array.isArray(r))switch(t){case"allComments":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((a,[s,c])=>(a[s]=this.commentUtilsService.mergeLocationWithCommentAnnotations(c,r),a),{}):e;case"allDocNotifications":case"allUserNotifications":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((a,[s,c])=>(a[s]=this.notificationUtilsService.mergeLocationWithNotification(c,r),a),{}):e;default:return e}return e}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService mergeLocationMetadataWithData:",a),e}}mergeUsersWithData({feature:e,data:t}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeUsersWithData","color: green;"),this.usersService.userDataProviderAvailable())switch(e){case"allAreas":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.areaUtilsService.mergeAreaWithUser(s),r),{}):t;case"allArrows":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.arrowUtilsService.mergeArrowWithUser(s),r),{}):t;case"allCursors":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.cursorUtilsService.mergeCursorUserWithUser(s),r),{}):t;case"allComments":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.commentUtilsService.mergeCommentWithUser(s),r),{}):t;case"allDocumentUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allFolderUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allOrganizationUsers":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.contactUtilsService.mergeUserIamWithUser(s),r),{}):t;case"allMultiThreads":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.multiThreadUtilsService.mergeMultiThreadWithUser(s),r),{}):t;case"allDocNotifications":return t&&typeof t=="object"?t?.map(r=>this.notificationUtilsService.mergeNotificationWithUser(r)):t;case"allUserNotifications":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.notificationUtilsService.mergeNotificationWithUser(s),r),{}):t;case"allPresence":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.presenceUtilsService.mergePresenceUserWithUser(s),r),{}):t;case"allRecorders":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.recorderUtilsService.mergeRecorderWithUser(s),r),{}):t;case"allReactions":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.reactionUtilsService.mergeReactionWithUser(s),r),{}):t;case"allTags":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.tagUtilsService.mergeTagWithUser(s),r),{}):t;case"allHuddleAttendees":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.huddleUtilsService.mergeHuddleAttendeeWithUser(s),r),{}):t;case"liveStateCustom":return t&&typeof t=="object"&&!Array.isArray(t)?this.liveStateUtilsService.mergeLiveStateCustomWithUser(t):t;case"allLiveStateCustoms":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.liveStateUtilsService.mergeLiveStateCustomWithUser(s),r),{}):t;case"allLiveStates":return t&&typeof t=="object"?this.liveStateUtilsService.mergeLiveStateWithUser(t):t;case"liveStateSingleEditorMode":return t&&typeof t=="object"&&!Array.isArray(t)?this.liveStateUtilsService.mergeSingleEditorLiveStateDataWithUser(t):t;case"allSelections":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[a,s])=>(r[a]=this.selectionUtilsService.mergeSelectionWithUser(s),r),{}):t;default:return t}return t}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeUsersWithData:",r),t}}mergeCommentAnnotationsWithData$({data:e,feature:t}){try{return this.commentAnnotationsResolverService.getCommentAnnotationsById$().pipe(de(()=>{let r=this.mergeCommentAnnotationsWithData({data:e?.data??{},feature:t}),a=this.mergeUsersWithData({feature:t,data:r??{}});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch("Error in mergeCommentAnnotationsWithData:",r),le(e)}}mergeReactionAnnotationsWithData$({data:e,feature:t}){try{return this.reactionAnnotationsResolverService.getReactionAnnotationsById$().pipe(de(()=>{let r=this.mergeReactionAnnotationsWithData({data:e?.data??{},feature:t}),a=this.mergeUsersWithData({feature:t,data:r??{}});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch("Error in mergeReactionAnnotationsWithData:",r),le(e)}}mergeUsersWithData$({feature:e,data:t}){try{return this.usersService.getUserById$().pipe(de(()=>{let r=this.mergeUsersWithData({feature:e,data:t?.data??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch(`Error in mergeUsersWithData for ${e}:`,r),le(t)}}mergeLocationMetadataWithData$({data:e,feature:t}){try{return this.docService.getLocationMetadata$().pipe(de(r=>{let a=this.mergeLocationMetadataWithData({data:e?.data??{},feature:t,locationMetadata:r});return typeof a=="object"?{data:JSON.parse(JSON.stringify(a)),operation:e?.operation??null}:{data:a,operation:e?.operation??null}}),Ct(Xt))}catch(r){return this.loggingService.catch(`Error in mergeLocationMetadataWithData for ${t}:`,r),le(e)}}handleDataStripping({feature:e,data:t,actionType:r,commentId:a}){try{switch(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: handleDataStripping","color: green;"),e){case"comment":return this.commentUtilsService.stripCommentAnnotationData({data:t,actionType:r,commentId:a});case"reaction":return this.reactionUtilsService.stripReactionAnnotationData(t);default:return{originalData:t,strippedData:null}}}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService handleDataStripping:",s),{originalData:t,strippedData:null}}}formatData({feature:e,data:t,properties:r,offset:a,isRealtimeDb:s}){try{this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: formatData","color: green;"),typeof t=="object"&&(t=JSON.parse(JSON.stringify(t)));let c=new Date().getTime()+a;switch(e){case"documentAccessType":return delete t?.users,{docIamConfig:t};case"organizationMetadata":case"documentMetadata":return s?t:{metadata:t};case"documentCommentMetadata":return t;case"cursor":return this.cursorUtilsService.formatCursorUserData(t);case"comment":return this.commentUtilsService.formatCommentData(t);case"area":return this.areaUtilsService.formatAreaData(t);case"arrow":return this.arrowUtilsService.formatArrowData(t);case"liveStateCustom":return this.liveStateUtilsService.formatLiveStateCustomData(t);case"liveStateSingleEditorMode":return this.liveStateUtilsService.formatLiveStateSingleEditorModeData(t);case"multiThread":return this.multiThreadUtilsService.formatMultiThreadData(t);case"reaction":return this.reactionUtilsService.formatReactionData(t);case"recorder":return this.recorderUtilsService.formatRecorderData(t,c);case"notificationViewsTimestamp":return{views:{[r.user??""]:t}};case"documentUsersViews":return s?t:{users:{[r.user??""]:{[r.date??""]:t}}};case"documentDayViews":return s?t:{day:{[r.date??""]:{[r.user??""]:t}}};case"documentMetadataViews":return s?t:{metadata:t};case"huddleMessage":return this.huddleUtilsService.formatHuddleMessageData(t);case"locationMetadataViews":return s?t:{metadata:t};case"locationUsersViews":return s?t:{users:{[r.user??""]:{[r.date??""]:t}}};case"locationDayViews":return s?t:{day:{[r.date??""]:{[r.user??""]:t}}};case"locationViews":return s?t:{location:t};case"docNotificationViews":return s?t:{views:t.views};case"userNotificationViews":return s?t:{views:t.views};case"presence":return this.presenceUtilsService.formatPresenceUserData(t);case"selection":return this.selectionUtilsService.formatSelectionData(t);case"tag":return this.tagUtilsService.formatTagData(t);default:return t}}catch(c){return this.loggingService.catch("Error in CommonDbUtilsService formatData:",c),t}}modifyAndSetData(s){return Q(this,arguments,function*({feature:e,data:t,subscriber:r,operation:a=null}){try{let c=yield this.modifyData({feature:e,data:t});r.next({data:c,operation:a})}catch(c){this.loggingService.catch("Error in CommonDbUtilsService modifyAndSetData:",c)}})}isDataAlreadyProcessedInLocalCache({feature:e,change:t,cache:r}){try{if(e==="allReactions"||e==="allComments"){if(t.type==="removed")return!Object.keys(r??{}).includes(t.doc.id);if(r?.[t.doc.id]){let a=t.doc.data(),s=r?.[t.doc.id];return a?.lastUpdated===s?.lastUpdated}}return!1}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService isDataAlreadyProcessedInLocalCache:",a),!1}}modifyData(r){return Q(this,arguments,function*({feature:e,data:t}){try{return yield this.formatResponse({feature:e,data:t})}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService modifyData:",a),t}})}addMetadata(e,t){try{return e&&typeof e=="object"&&!Array.isArray(e)?D(E({},e),{metadata:e?.metadata??{documentId:t?.documentId,organizationId:t?.organizationId,apiKey:t?.apiKey}}):e}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService addMetadata:",r),e}}setDataInLocal(p){return Q(this,arguments,function*({feature:e,data:t,observablesCache:r,eventType:a,id:s,operation:c=null}){try{let f={comment:"allComments",reaction:"allReactions"}[e];if(!f)return null;let I=t?.metadata?.documentId,T=t?.metadata?.veltFolderId;return Object.keys(r).filter(B=>B.includes(f)&&(!I||B.includes(I)||T&&B.includes(T))).forEach(B=>{let z=r[B]?.subject?.getValue()??{};a==="DELETE"?s&&z?.data?.[s]&&(delete z?.data?.[s],r[B]?.subject&&r[B].subject.next({data:z?.data,operation:c})):r[B]?.subject?.next({data:D(E({},z?.data),{[t?.annotationId]:t}),operation:c})}),null}catch(g){return this.loggingService.catch("Error in CommonDbUtilsService setDataInLocal:",g),null}})}handleCommentEncryption(c){return Q(this,arguments,function*({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s}){try{return yield this.commentUtilsService.handleCommentEncryption({data:e,firestorePath:t,extraData:r,eventType:a,metadata:s})}catch(p){return this.loggingService.catch("Error in CommonDbUtilsService handleCommentEncryption:",p),e}})}handleReactionEncryption(a){return Q(this,arguments,function*({data:e,firestorePath:t,eventType:r}){try{return yield this.reactionUtilsService.handleReactionEncryption({data:e,firestorePath:t,eventType:r})}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService handleReactionEncryption:",s),e}})}rtdbDefaultTransactionCallback(e,t){try{let r=E({},e||{});return Object.entries(t).forEach(([a,s])=>{s==null?delete r[a]:r[a]=s}),r}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService rtdbDefaultTransactionCallback:",r),e}}};o.\u0275fac=function(t){return new(t||o)(ee(Fpe),ee(Lpe),ee(ru),ee(Bpe),ee(ni),ee(Vpe),ee(I9),ee(E9),ee(_),ee($pe),ee(x9),ee(zpe),ee(Gpe),ee(VC),ee(Wpe),ee(qpe),ee(Ln),ee(ot),ee(nl),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Ype=(()=>{let o=class o{constructor(e,t,r){this.configService=e,this.authService=t,this.loggingService=r,this.firestore$=new Ce(null);try{mn([this.authService.getFirebaseConfig$(),this.configService.getApiKey$()]).pipe(Le(([a,s])=>!!a&&!!s),rt(1)).subscribe(([a,s])=>{a&&s&&a?.firebaseOptions?.storeDbId&&this.firestore$.next(KR(iu.getFirestoreProdDbName(s,a.firebaseOptions)))},a=>{})}catch{}}getFirestore(){return this.firestore$.asObservable()}getFirestoreValue(){return this.firestore$.value}generateFirestoreDocumentId(){try{let e=this.getFirestoreValue()||KR("DocumentIdDb");if(e){let t=jI(e,"generateDocumentId");return AC(t).id}return}catch(e){this.loggingService.catch("Error in FirestoreService generateFirestoreDocumentId: ",e);return}}};o.\u0275fac=function(t){return new(t||o)(ee(Ft),ee(je),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var un=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T){this.authService=e,this.commonDbUtilsService=t,this.coreActionsService=r,this.loggingService=a,this.firestoreService=s,this.databaseService=c,this.configService=p,this.docService=g,this.usersService=f,this.commentAnnotationsResolverService=I,this.reactionAnnotationsResolverService=T,this.offset=0,this.db=null,this.firestore=null,this.subscriptions=[],this.offsetListener=null,this.observablesCache={},this.firestoreSubscriptions={},this.rtdbSubscriptions={},this.loggingService.log("%c[WB] Creating CLASS: CommonDbService","color: blue;"),this.docService.setCommonDbService(this),this.authService.setCommonDbService(this),this.usersService.setCommonDbService(this),this.subscriptions.push(this.databaseService.getDb().subscribe(B=>{if(B){this.db=B;let z=Ti(B,".info/serverTimeOffset");this.offsetListener=Mg(z,G=>{let J=G.val();this.offset=J})}})),this.subscriptions.push(this.firestoreService.getFirestore().subscribe(B=>{B&&(this.firestore=B)}))}unsubscribeFromObservables(){try{Object.values(this.firestoreSubscriptions??{}).forEach(e=>{e?.unsubscribe()}),Object.values(this.rtdbSubscriptions??{}).forEach(e=>{e?.unsubscribe()}),Object.entries(this.observablesCache??{}).forEach(([e,t])=>{t?.subject?.complete(),t?.subject?.unsubscribe()}),this.observablesCache={},this.firestoreSubscriptions={},this.rtdbSubscriptions={}}catch(e){this.loggingService.catch("Error in unsubscribeFromObservables:",e)}}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.offsetListener&&this.offsetListener(),this.unsubscribeFromObservables()}setupOnDisconnect(e,t){return Q(this,null,function*(){try{if(this.db){let r=Ti(this.db,e);return Es(r).update(t)}return Promise.resolve()}catch(r){return this.loggingService.catch("Error in setupOnDisconnect:",r),Promise.resolve()}})}getOffset(){return this.offset}getServerTimestamp(){return new Date().getTime()+this.getOffset()}subscribeToServices(e){mn([this.databaseService.getDb(),this.firestoreService.getFirestore()]).pipe(Le(([t,r])=>!!t),rt(1),Qt(([t,r])=>{e({db:t,firestore:r})})).subscribe({error:t=>{this.loggingService.catch("Error in CommonDbService subscription: ",t)}})}performDatabaseOperation(e,t,r,a,s,c){return Q(this,null,function*(){try{if(!t){this.loggingService.warn(`%c[WB] No properties found for ${e}`,"color: red;");return}return this.subscribeToServices(f=>Q(this,[f],function*({db:p,firestore:g}){let I;t?.skipFirestore||(I=this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()}));let T=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey(),useFirestore:this.shouldUseFirestore()});if(!p){this.loggingService.warn(`%c[WB] No database or firestore found for ${e}`,"color: red;");return}try{let B,z;try{T&&(B=Ti(p,`${T}`))}catch{this.loggingService.catch("Error in dbRef")}try{I?.includes("/organizations")&&g&&I&&(z=AC(g,`${I}`))}catch{this.loggingService.catch("Error in docRef")}if(!this.authService.getUser())return;yield r({dbRef:B,firestoreRef:z,data:a,firestorePath:I}),c&&c({firestoreAvailable:!!g})}catch(B){this.loggingService.catch(`Error in ${e} operation: `,B),s&&s(B)}}))}catch(p){this.loggingService.catch("Error in performDatabaseOperation:",p)}})}setData(p){return Q(this,arguments,function*({feature:e,data:t,properties:r,callback:a,errorCallback:s,extraData:c}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: setData for ${e}`,"color: green;"),this.shouldUseFirestore()&&t?.metadata&&!t?.metadata?.apiKey?void 0:(this.commonDbUtilsService.setDataInLocal({feature:e,data:t,observablesCache:this.observablesCache,operation:null}),this.performDatabaseOperation(e,r,g=>Q(this,null,function*(){if(g.dbRef){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset(),isRealtimeDb:!0});r?.rtdbTransaction?yield Yh(g.dbRef,()=>JSON.parse(JSON.stringify(f))):yield S0(g.dbRef,JSON.parse(JSON.stringify(f)))}try{if(g.firestoreRef&&g.data&&!r?.skipFirestore){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset()});typeof f=="object"&&(f=JSON.parse(JSON.stringify(f)));let{strippedData:I,originalData:T,eventType:B}=this.commonDbUtilsService.handleDataStripping({feature:e,data:f,actionType:c?.actionType,commentId:c?.targetAnnotationData?.commentId??r?.targetCommentId});if(e==="comment"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:No.SET_DATA,source:"internal",payload:{strippedData:I,originalData:T,eventType:B,commentId:c?.targetAnnotationData?.commentId}}),I&&(z=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:I,eventType:B,commentId:c?.targetAnnotationData?.commentId},G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:T,firestorePath:g.firestorePath??"",extraData:c,metadata:r?.metadata}))}else if(e==="reaction"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:Ho.SET_DATA,source:"internal",payload:{strippedData:I,originalData:T}}),I&&(z=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(I,G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:T,firestorePath:g.firestorePath??""}))}else e==="recorder"?this.firestore&&(yield vpe(this.firestore,z=>Q(this,null,function*(){z.set(g.firestoreRef,f)}))):yield GW(g.firestoreRef,f)}}catch(f){this.authService.getUser()&&this.loggingService.catch(`Error in setData for ${e}`,f)}}),t,s,a))}catch(g){this.loggingService.catch(`Error in setData for ${e}`,g)}})}updateData(p){return Q(this,arguments,function*({feature:e,data:t,properties:r,callback:a,errorCallback:s,extraData:c}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: updateData for ${e}`,"color: green;"),this.shouldUseFirestore()&&t?.metadata&&!t?.metadata?.apiKey?void 0:(this.commonDbUtilsService.setDataInLocal({feature:e,data:t,observablesCache:this.observablesCache,operation:null}),this.performDatabaseOperation(e,r,g=>Q(this,null,function*(){if(g.dbRef&&!r?.skipRtdb){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset(),isRealtimeDb:!0});r?.rtdbTransaction?yield Yh(g.dbRef,I=>{let T;return r?.rtdbTransactionCallback?T=r.rtdbTransactionCallback(I,f):T=this.commonDbUtilsService.rtdbDefaultTransactionCallback(I,f),JSON.parse(JSON.stringify(T))}):yield RM(g.dbRef,JSON.parse(JSON.stringify(f)))}try{if(g.firestoreRef&&g.data&&!r?.skipFirestore){let f=this.commonDbUtilsService.formatData({feature:e,data:g.data,properties:r,offset:this.getOffset()});typeof f=="object"&&(f=JSON.parse(JSON.stringify(f)));let{strippedData:I,originalData:T,eventType:B}=this.commonDbUtilsService.handleDataStripping({feature:e,data:f,actionType:c?.actionType,commentId:c?.targetAnnotationData?.commentId});if(e==="comment"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:No.UPDATE_DATA,source:"internal",payload:{strippedData:I,originalData:T,eventType:B,commentId:c?.targetAnnotationData?.commentId}}),I&&(z=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:I,eventType:B,commentId:c?.targetAnnotationData?.commentId},G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:T,firestorePath:g.firestorePath??"",extraData:c,metadata:r?.metadata}))}else if(e==="reaction"){let z=null,G=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:G,methodName:Ho.UPDATE_DATA,source:"internal",payload:{strippedData:I,originalData:T}}),I&&(z=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(I,G)),T&&(z?.isSuccess||z===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:T,firestorePath:g.firestorePath??""}))}else yield GW(g.firestoreRef,f,{merge:!0})}}catch(f){this.authService.getUser()&&this.loggingService.catch(`Error in updateDoc for ${e}`,f)}}),t,s,a))}catch(g){this.loggingService.catch(`Error in updateData for ${e}`,g)}})}deleteData(s){return Q(this,arguments,function*({feature:e,properties:t,callback:r,errorCallback:a}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: deleteData for ${e}`,"color: green;"),this.commonDbUtilsService.setDataInLocal({feature:e,observablesCache:this.observablesCache,eventType:"DELETE",id:t?.id,operation:{type:"removed",ids:[t?.id]}}),this.performDatabaseOperation(e,t,c=>Q(this,null,function*(){c.dbRef&&(yield kM(c.dbRef));try{if(c.firestoreRef&&!t?.skipFirestore)if(e==="comment"){let p=null,g=vt();this.coreActionsService.triggerAction(mt.COMMENT_RESOLVER,{event:Y.Events.Resolver.COMMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:No.DELETE_DATA,source:"internal",payload:{commentAnnotationId:t?.id??"",metadata:t?.metadata}}),p=yield this.commentAnnotationsResolverService.deleteCommentAnnotation(t?.id??"",t?.metadata,g),(p?.isSuccess||p===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({firestorePath:c.firestorePath??"",eventType:"DELETE",metadata:t?.metadata}))}else if(e==="reaction"){let p=null,g=vt();this.coreActionsService.triggerAction(mt.REACTION_RESOLVER,{event:Y.Events.Resolver.REACTION_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Ho.DELETE_DATA,source:"internal",payload:{reactionAnnotationId:t?.id??"",metadata:t?.metadata}}),p=yield this.reactionAnnotationsResolverService.deleteReactionAnnotation(t?.id??"",t?.metadata,g),(p?.isSuccess||p===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({firestorePath:c.firestorePath??"",eventType:"DELETE"}))}else yield ppe(c.firestoreRef)}catch(p){this.authService.getUser()&&this.loggingService.catch(`Error in deleteData for ${e}`,p)}}),void 0,a,r)}catch(c){this.loggingService.catch(`Error in deleteData for ${e}`,c)}})}shouldUseFirestore(){try{return this.authService.getAdvancedQueriesEnabled()}catch(e){return this.loggingService.catch("Error in shouldUseFirestore:",e),!1}}generateDocumentId(){try{let e=this.firestoreService.generateFirestoreDocumentId();return e||(e=vt()),e||"noDocumentId"}catch(e){return this.loggingService.catch("Error in generateFirestoreDocumentId:",e),vt()||"noDocumentId"}}queryData(r){return Q(this,arguments,function*({feature:e,properties:t}){try{let a=this.shouldUseFirestore();return!e||!t?(this.loggingService.warn("[WB] Missing required parameters in queryData"),[]):a?yield this.handleFirestoreQuery(e,t):yield this.handleRtdbQuery(e,t)}catch(a){return this.loggingService.catch(`Error in queryData for ${e}`,a),[]}})}handleFirestoreQuery(e,t){return Q(this,null,function*(){try{if(!this.firestore)return this.loggingService.warn("[WB] Firestore not initialized"),[];let r=t?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(e):this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!r)return this.loggingService.warn(`[WB] No firestore path found for ${e}`),[];try{let a=jI(this.firestore,r);t?.useCollectionGroup&&(a=$W(this.firestore,r));let s=t?.firestoreQuery??[],c=zW(a,...s);if(!this.authService.getUser()&&!t?.skipUserCheck)return[];if(t?.getCount)try{let p=yield upe(c).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${e}`,g),null));return p?p.data().count:0}catch(p){return this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${e}`,p),0}else try{let p=yield fpe(c).catch(f=>(this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${e}`,f),null));if(!p)return[];let g=p.docs.map(f=>f.data());try{return yield this.commonDbUtilsService.modifyData({feature:e,data:g})}catch(f){return this.loggingService.catch(`Error in modifyData for ${e}`,f),g}}catch(p){return this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${e}`,p),[]}}catch(a){return this.loggingService.catch(`Error in Firestore query for ${e}:`,a),[]}}catch(r){return this.loggingService.catch(`Error in Firestore query for ${e}:`,r),[]}})}handleRtdbQuery(e,t){return Q(this,null,function*(){if(!this.db)return this.loggingService.warn("[WB] Realtime Database not initialized"),[];let r=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!r)return this.loggingService.warn(`[WB] No database path found for ${e}`),[];try{let a=Ti(this.db,r),s=t?.rtdbQuery??[],c=f$(a,...s);if(!this.authService.getUser()&&!t?.skipUserCheck)return[];let p=yield u$(c).catch(f=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${e}`,f),null));if(!p)return[];let g=p.val();return g?t?.skipObjectValues?g:Object.values(g??{}):[]}catch(a){return this.loggingService.catch(`Error in RTDB query for ${e}:`,a),[]}})}getData(r){return Q(this,arguments,function*({feature:e,properties:t}){try{let a=this.shouldUseFirestore();if(t?.skipFirestore&&(a=!1),!e||!t)return this.loggingService.warn("[WB] Missing required parameters in getData"),{};if(a&&this.firestore){let s=this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!s)return this.loggingService.warn(`[WB] No firestore path found for ${e}`),{};try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getData]",void 0,void 0,!0),{};let c=yield hpe(AC(this.firestore,s)).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in getDoc for ${e}`,g),this.commonDbUtilsService.getErrorForGetRequests({feature:e,error:g})));if(c){if(c?.errorCode)return c}else return this.loggingService.warn(`[WB] No document found at ${s}`),{};let p=c.data();return t?.field?p?.[t.field]??{}:p??{}}catch(c){return this.loggingService.catch(`Error fetching Firestore data for ${e}:`,c),{}}}if(this.db){let s=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!s)return this.loggingService.warn(`[WB] No database path found for ${e}`),{};try{if(!this.authService.getUser())return{};let c=yield u$(Ti(this.db,s)).catch(g=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${e}`,g),this.commonDbUtilsService.getErrorForGetRequests({feature:e,error:g})));if(c){if(c?.errorCode)return c}else return this.loggingService.warn(`[WB] No data found at ${s}`),{};let p=c.val();return t?.field?p?.[t.field]??{}:p??{}}catch(c){return this.loggingService.catch(`Error fetching RTDB data for ${e}:`,c),{}}}return this.loggingService.warn("[WB] No database connection available"),{}}catch(a){return this.loggingService.catch("Unexpected error in getData:",a),{}}})}dbListener({feature:e,properties:t}){let r=this.shouldUseFirestore();t?.skipFirestore&&(r=!1);let a=`${e}-${JSON.stringify(t)}`;return mn([this.databaseService.getDb(),this.firestoreService.getFirestore(),this.authService.getUser$().pipe(Le(s=>!!s))]).pipe(Le(([s,c])=>s?r&&!c?(this.loggingService.warn(`[WB] Firestore requested but not available for ${e}`),!1):!0:(this.loggingService.warn(`[WB] No database found for ${e}`),!1)),he(([s,c])=>{try{if(r&&c){if(!!!this.observablesCache[a]){this.observablesCache[a]={subject:new Ce({}),count:0};let f=this.handleFirestoreListener(e,t,c).subscribe(I=>{this.observablesCache[a]?.subject?.next(I)},I=>this.observablesCache[a]?.subject?.error(I));this.firestoreSubscriptions[a]=f}return new $t(g=>{let f=this.observablesCache[a]?.subject?.subscribe(I=>g.next(I),I=>g.error(I),()=>g.complete());return this.observablesCache[a].count+=1,()=>{f?.unsubscribe(),this.observablesCache[a]&&(this.observablesCache[a].count-=1,this.observablesCache[a].count<=0&&(this.firestoreSubscriptions[a]?.unsubscribe(),delete this.firestoreSubscriptions[a],this.observablesCache[a]?.subject?.complete(),delete this.observablesCache[a]))}})}else if(s){if(!!!this.observablesCache[a]){this.observablesCache[a]={subject:new Ce({}),count:0};let f=this.handleRealtimeDbListener(e,t,s).subscribe(I=>{this.observablesCache[a]?.subject?.next(I)},I=>this.observablesCache[a]?.subject?.error(I));this.rtdbSubscriptions[a]=f}return new $t(g=>{let f=this.observablesCache[a]?.subject?.subscribe(I=>g.next(I),I=>g.error(I),()=>g.complete());return this.observablesCache[a].count+=1,()=>{f?.unsubscribe(),this.observablesCache[a]&&(this.observablesCache[a].count-=1,this.observablesCache[a].count<=0&&(this.rtdbSubscriptions[a]?.unsubscribe(),delete this.rtdbSubscriptions?.[a],this.observablesCache[a]?.subject?.complete(),delete this.observablesCache?.[a]))}})}return le({})}catch(p){return this.loggingService.catch(`Error setting up listener for ${e}:`,p),le({})}}),Yu(()=>{this.loggingService.log(`[WB] Cleaning up listener for ${e} and key ${a}`)}))}handleFirestoreListener(e,t,r){let a=t?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(e):this.commonDbUtilsService.getFirestorePath({feature:e,properties:t,documentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()}),s=`${e}-${JSON.stringify(t)}`;return a?new $t(c=>{let p=t.isCollection?this.setupCollectionListener(r,a,e,c,t):this.setupDocumentListener(r,a,e,c,t);return()=>{c.complete(),c.unsubscribe(),p(),this.observablesCache[s]?.subject?.complete(),this.observablesCache[s]?.subject?.unsubscribe(),delete this.observablesCache[s]}}).pipe(he(c=>this.commonDbUtilsService.mergeUsersWithData$({feature:e,data:c})),he(c=>["allComments","allUserNotifications"].includes(e)?this.commonDbUtilsService.mergeCommentAnnotationsWithData$({data:c,feature:e}):le(c)),he(c=>["allReactions"].includes(e)?this.commonDbUtilsService.mergeReactionAnnotationsWithData$({data:c,feature:e}):le(c)),Ct(Xt)):(this.loggingService.warn(`[WB] No firestore path found for ${e} and key ${s}`),le({}))}setupCollectionListener(e,t,r,a,s){let c=`${r}-${JSON.stringify(s)}`,p=jI(e,t);if(s?.useCollectionGroup&&(p=$W(e,t)),s?.useQuery&&s?.firestoreQuery){let I=s?.firestoreQuery??[];p=zW(p,...I)}let g=!0,f=[];return r==="allComments"&&this.loggingService.logContext("[CONTEXT] setupCollectionListener called with path:",t,"feature:",r,"properties:",JSON.stringify(s??"nil")),HW(p,I=>{try{let T=JSON.parse(JSON.stringify(this.observablesCache[c]?.subject?.getValue()?.data??{})),B=null,z=!1;I?.docChanges()?.length?I.docChanges().forEach(G=>{["allComments","allReactions"].includes(r)&&!g&&G.type!=="removed"&&f.push(G.doc.id),this.commonDbUtilsService.isDataAlreadyProcessedInLocalCache({feature:r,change:G,cache:this.observablesCache[c]?.subject?.getValue()?.data??{}})||(z=!0,Object.assign(T,this.handleCollectionChange(G,T)),G.type==="removed"&&(B||(B={type:G.type,ids:[]}),B.ids.push(G.doc.id)))}):z=!0,z&&(["allComments","allReactions"].includes(r)&&f?.length&&(this.commonDbUtilsService.resolveAnnotations({data:f,feature:r}),f=[]),this.commonDbUtilsService.modifyAndSetData({feature:r,data:T,subscriber:a,operation:B})),g=!1}catch(T){this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${r}:`,T),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(s??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(T,r,a)}},I=>{this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${r}:`,I),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(s??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(I,r,a)})}handleCollectionChange(e,t){switch(e.type){case"added":case"modified":t[e.doc.id]=e.doc.data();break;case"removed":delete t?.[e.doc.id];break}return t}setupDocumentListener(e,t,r,a,s){let c=AC(e,t);return HW(c,p=>{try{let g=p.data()||{};s?.field&&(g=g?.[s?.field]??{}),this.commonDbUtilsService.modifyAndSetData({feature:r,data:g,subscriber:a,operation:null})}catch(g){this.handleListenerError(g,r,a)}},p=>this.handleListenerError(p,r,a))}handleListenerError(e,t,r){this.loggingService.catch(`Firestore listener error for ${t}:`,e)}handleRealtimeDbListener(e,t,r){let a=this.commonDbUtilsService.getDocumentPath({feature:e,properties:t,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:t.apiKey??this.configService.getApiKey()});if(!a)return this.loggingService.warn(`[WB] No database path found for ${e}`),le({});let s=Ti(r,a);if(t?.useQuery&&t?.rtdbQuery){let c=t?.rtdbQuery??[];s=f$(s,...c)}return this.objectValFromChildEvents(s,e).pipe(Un(c=>(this.loggingService.catch(`RTDB listener error for ${e}:`,c),le({}))),de(c=>(c===null&&(c={}),c&&typeof c=="object"?Object.entries(c??{}).reduce((g,[f,I])=>(g[f]=this.commonDbUtilsService.addMetadata(I,t),g),{}):this.commonDbUtilsService.addMetadata(c,t))),he(c=>this.commonDbUtilsService.modifyData({feature:e,data:c})),he(c=>this.usersService.getUserById$().pipe(de(()=>({data:this.commonDbUtilsService.mergeUsersWithData({feature:e,data:c}),operation:null})))))}objectValFromChildEvents(e,t){return new $t(r=>{let a={},s=!1,c=null,p=G=>{try{this.loggingService.catch(`Realtime DB listener error for ${t}:`,G),r.error(G)}catch{}},g=G=>{try{if(!hi(G,c)){let J=JSON.parse(JSON.stringify(G));c=J,r.next(J)}}catch{}},f=G=>{try{G.key&&(a[G.key]=G.val(),s&&g(E({},a)))}catch{}},I=G=>{try{G.key&&(a[G.key]=G.val(),s&&g(E({},a)))}catch{}},T=G=>{try{G.key&&(delete a[G.key],s&&g(E({},a)))}catch{}},B=G=>{try{if(!s){let J=a&&typeof a=="object"?JSON.parse(JSON.stringify(a)):{};c=J,r.next(J),s=!0}}catch{}};Dre(e,f,p),wre(e,I,p),Ore(e,T,p);let z=Mg(e,B,p,{onlyOnce:!0});return()=>{try{z&&typeof z=="function"&&z(),MM(e,"child_added",f),MM(e,"child_changed",I),MM(e,"child_removed",T)}catch{}}})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Im),ee(ni),ee(_),ee(Ype),ee(In),ee(Ft),ee(ot),ee(Ln),ee(nl),ee(bm))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Si=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f){this.analyticsService=e,this.authService=t,this.configService=r,this.coreActionsService=a,this.databaseService=s,this.docService=c,this.loggingService=p,this.commonDbService=g,this.usersService=f,this.db=Is(),this.internalUserContacts$=new Ce([]),this.userGlobalContact$=new Ce(!1),this.userGroupContact$=new Ce(null),this.users$=new Ce([]),this.userPersonalContacts=[],this.userGroupContacts=[],this.userGlobalContacts=[],this.users=[],this.documentPaths=null,this.userAccessFields$=new Ce({}),this.userOrganizationContacts$=new Ce([]),this.userFolderContacts$=new Ce([]),this.userDocumentContacts$=new Ce([]),this.userOrganizationGroups$=new Ce([]),this.onContactSelectedSubject$=new Xe,this.documentAccessType=null,this.atHereEnabled$=new Ce(!1),this.atHereLabel$=new Ce("here"),this.atHereDescription$=new Ce(null),this.contactListScopeForOrganizationUsers$=new Ce([Yi.ALL]),this.customUserContacts$=new Ce(null),this.customUserContactsConfig$=new Ce({merge:!1}),this.currentOrganizationUserIAM$=new Ce(null),this.userContacts$=new Ce([]),this.userSnippylyIdContacts$=new Ce(null),this.usersByOrganizationId$=new Ce({}),this.temporaryUserIds$=new Ce([]),this.usersByOrganizationIdAndDocumentId$=new Ce({}),this.usersByOrganizationIdAndFolderId$=new Ce({}),this.userById$=new Ce({}),this.searchUsersSubject$=new Xe,this.searchUsersDebounceTime=300,this.pendingSearchPromises=new Map,this.authService.setContactService(this),this.usersService.setContactService(this),this.authService.getUser$().pipe(he(I=>this.docService.getDocumentPaths$().pipe(Qt(T=>{this.documentPaths=T}),de(()=>I)))).subscribe(I=>Q(this,null,function*(){if(this.user=I,I&&this.documentPaths)if(!I?.organizationId)this.getLoggedInUsers$().subscribe(),this.getUserContactsFromDb$(),yield this.migrateLoggedInUserFromEmailToUserIdPath(I),this.setLoggedInUser(I),yield this.moveGlobalContactUserFromEmailToUserIdPath(I),this.updateUserInGlobalContactsIfAvailable(I),I?.groupId&&(yield this.migrateGroupContactsFromEmailToUserIdPath(I?.groupId)),this.checkToSetLoggedInUserInGroupContacts();else{let T=this.userPermissionService?.getCurrentUserPermissions(),B=this.documentPaths.folderId,z=!0;B&&T?.[I?.userId]?.folders?.[B]?.errorCode===Lo.PERMISSION_DENIED&&(z=!1),this.getOrganizationContactsFromDb$(),z&&this.getFolderContactsFromDb$(),this.getDocumentContactsFromDb$(),this.getOrganizationGroupsFromDb$(),this.getTemporaryUsers()}else this.getUserContactSubscription?.unsubscribe(),this.getUserContactSubscription=void 0,this.getLoggedInUsersSubscription?.unsubscribe(),this.getLoggedInUsersSubscription=void 0,this.getOrganizationContactsSubscription?.unsubscribe(),this.getOrganizationContactsSubscription=void 0,this.getFolderContactsSubscription?.unsubscribe(),this.getFolderContactsSubscription=void 0,this.getDocumentContactsSubscription?.unsubscribe(),this.getDocumentContactsSubscription=void 0,this.getOrganizationGroupsSubscription?.unsubscribe(),this.getOrganizationGroupsSubscription=void 0}),I=>{this.loggingService.catch("Error in ContactService constructor getUser$: ",I)}),this.databaseService.getDb().pipe(Le(I=>!!I),rt(1)).subscribe(I=>{I&&(this.db=I)},I=>{this.loggingService.catch("Error in ContactService constructor getDb: ",I)}),this.getOrganizationGroups$().subscribe(I=>{this.authService.setOrganizationUserGroups(I)}),mn([this.getInternalUserContacts$(),this.getCustomUserContacts$(),this.getCustomUserContactsConfig$()]).subscribe(([I,T,B])=>{T?B?.merge?this.userContacts$.next([...I||[],...T||[]]):this.userContacts$.next(T||[]):this.userContacts$.next(I||[])}),this.getUserContacts$().subscribe(I=>{try{I?.forEach(T=>{let B=T?.userSnippylyId||eC(this.configService.getApiKey(),T.userId);B&&this.userSnippylyIdContacts$.next(D(E({},this.userSnippylyIdContacts$.value),{[B]:T}))})}catch{}})}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in ContactService setCommentService: ",t)}}setUserPermissionService(e){try{this.userPermissionService=e}catch(t){this.loggingService.catch("Error in ContactService setUserPermissionService: ",t)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ContactService","color: green;");try{this.documentPaths=null,this.usersByOrganizationId$.next({}),this.temporaryUserIds$.next([]),this.usersByOrganizationIdAndFolderId$.next({}),this.usersByOrganizationIdAndDocumentId$.next({}),this.userById$.next({}),this.userOrganizationContacts$.next([]),this.userFolderContacts$.next([]),this.userDocumentContacts$.next([]),this.userOrganizationGroups$.next([]),this.userContacts$.next([]),this.userSnippylyIdContacts$.next(null),this.userGlobalContact$.next(!1),this.userGroupContact$.next(null),this.users$.next([]),this.userPersonalContacts=[],this.userGroupContacts=[],this.userGlobalContacts=[],this.users=[],this.currentOrganizationUserIAM$.next(null)}catch(e){this.loggingService.catch("Error in ContactService clearCache: ",e)}}setDocumentAccessType(e){try{this.documentAccessType=e}catch(t){this.loggingService.catch("Error in ContactService setDocumentAccessType: ",t)}}checkIfUserGlobalContact(e){return Q(this,null,function*(){try{if(e?.userId&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0}});if(Object.keys(t??{}).length>0)return!0}if(e?.email&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0)return!0}return!1}catch(t){return this.loggingService.catch("Error in ContactService isUserGlobalContact: ",t),!1}})}setLoggedInUser(e){try{e?.userId&&this.documentPaths?.logins&&(this.commonDbService.updateData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(D(E({},e),{contacts:void 0})))}),this.setLoggedInUserPrivateContacts(e,e?.contacts))}catch(t){this.loggingService.catch("Error in ContactService setLoggedInUser: ",t)}}migrateLoggedInUserFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(e?.email&&this.documentPaths?.logins){let t=yield this.commonDbService?.getData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0){let r=t;if(r){if(r?.contacts){let a={};Object.keys(r?.contacts??{})?.forEach(s=>{let c=r.contacts[s];if(c?.userId){let p=Tt(c?.userId);a[p]=c}}),r.contacts=a}yield this.commonDbService.updateData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}),yield this.commonDbService.deleteData({feature:"logins",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}})}}}}catch(t){this.loggingService.catch("Error in ContactService migrateLoggedInUserFromEmailToUserIdPath: ",t)}})}addGlobalContact(e){try{e?.userId&&this.documentPaths?.globalContacts&&this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(e))})}catch(t){this.loggingService.catch("Error in ContactService addGlobalContact: ",t)}}getUserAccessFields(){return JSON.parse(JSON.stringify(this.userAccessFields$.value))}getUserAccessFieldsByUserId(e){return this.getUserAccessFields()?.[e]}setUserAccessFields(e){try{let t=this.getUserAccessFields();e.forEach(a=>{t[a.user.userId]=a.accessFields||[]});let r=this.authService.getUser()?.userId;if(r&&t?.[r]?.length){let a=this.userPermissionService?.getCurrentUserPermissions();a&&(a[r]||(a[r]={}),a[r].context={accessFields:t[r]},this.userPermissionService?.setCurrentUserPermissions(a))}this.userAccessFields$.next(JSON.parse(JSON.stringify(t)))}catch(t){this.loggingService.catch("Error in ContactService setUserAccessFields: ",t)}}updateUserInGlobalContactsIfAvailable(e){return Q(this,null,function*(){try{if(e?.userId&&this.documentPaths?.globalContacts&&(yield this.checkIfUserGlobalContact(e))){let r=new zo;r.userId=e?.userId,r.userSnippylyId=e?.userSnippylyId,r.email=e?.email,r.name=e?.name,r.photoUrl=e?.photoUrl,this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))})}}catch(t){this.loggingService.catch("Error in ContactService updateUserInGlobalContactsIfAvailable: ",t)}})}moveGlobalContactUserFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(e?.email&&e?.userId&&this.documentPaths?.globalContacts){let t=yield this.commonDbService?.getData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}});if(Object.keys(t??{}).length>0){let r=t;r&&(yield this.commonDbService.updateData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}),yield this.commonDbService.deleteData({feature:"globalContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.email),skipFirestore:!0}}))}}}catch(t){this.loggingService.catch("Error in ContactService removeUserFromGlobalContactsByEmail: ",t)}})}setLoggedInUserPrivateContacts(e,t){try{if(e?.userId&&this.documentPaths?.logins){let r,a=t?.filter(c=>c?.visibility!=="group"),s=!1;this.authService.getUserOptions()&&(s=!!this.authService.getUserOptions()?.replaceContacts||!!this.authService.getUserOptions()?.replacePrivateContacts),a?.length?(r={},a?.forEach(c=>{if(c?.userId){let p=Tt(c?.userId);r[p]=c}}),s?this.commonDbService.setData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))}):this.commonDbService.updateData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(r))})):s&&this.commonDbService.deleteData({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",userId:Tt(e?.userId),skipFirestore:!0}})}}catch(r){this.loggingService.catch("Error in ContactService setLoggedInUserPrivateContacts: ",r)}}migrateGroupContactsFromEmailToUserIdPath(e){return Q(this,null,function*(){try{if(this.documentPaths?.groupContacts&&e){let t=yield this.commonDbService?.getData({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,skipFirestore:!0}});t&&Object.keys(t??{}).forEach(r=>Q(this,null,function*(){let a=t[r];a?.email&&a?.userId&&Tt(a?.email)===r&&(yield this.commonDbService.deleteData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:r,skipFirestore:!0}}),yield this.commonDbService.updateData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(a))}))}))}}catch(t){this.loggingService.catch("Error in ContactService migrateGroupContacts: ",t)}})}checkToSetLoggedInUserInGroupContacts(){return Q(this,null,function*(){try{this.user?.groupId&&this.user?.userId&&((yield this.checkIfUserGlobalContact(this.user))||this.docService.getDocumentIam$().pipe(rt(1)).subscribe(t=>Q(this,null,function*(){if(this.user?.groupId&&this.user?.userId){let r=!1,a=this.docService.getDocumentAccessType(t);if(!a||a===Di.PUBLIC)r=!0;else if(a===Di.RESTRICTED){let s=Tt(this.user?.userId);if(t?.users?.[s]&&(r=!0),this.user?.email){let c=Tt(this.user?.email);t?.users?.[c]&&(r=!0)}}if(r){let s=new Pp;s.email=this.user.email,s.visibility="group",s.name=this.user.name,s.photoUrl=this.user.photoUrl,s.userId=this.user.userId,(this.authService.getUserOptions()?.replaceContacts||this.authService.getUserOptions()?.replaceGroupContacts)&&(yield this.removeGroupContacts(this.user?.groupId)),this.setLoggedInUserGroupContacts(this.user?.groupId,[s]),this.user?.contacts&&this.user?.groupId&&this.setLoggedInUserGroupContacts(this.user?.groupId,this.user?.contacts)}}})))}catch(e){this.loggingService.catch("Error in ContactService checkToSetLoggedInUserInGroupContacts: ",e)}})}setLoggedInUserGroupContacts(e,t){try{let r=t?.filter(a=>a?.visibility==="group");r?.length&&r.forEach(a=>Q(this,null,function*(){if(a?.userId&&e&&this.documentPaths?.groupContacts){if(this.configService?.getSF()&&(yield this.checkIfUserGlobalContact(a)))return;yield this.commonDbService.updateData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.userId),skipFirestore:!0},data:JSON.parse(JSON.stringify(a))}),a?.email&&(yield this.commonDbService.deleteData({feature:"groupContactsUser",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,userId:Tt(a?.email),skipFirestore:!0}}))}}))}catch(r){this.loggingService.catch("Error in ContactService setLoggedInUserGroupContacts: ",r)}}removeGroupContacts(e){return Q(this,null,function*(){try{if(this.documentPaths?.groupContacts&&e)return this.commonDbService.deleteData({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",groupId:e,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in ContactService removeGroupContacts: ",t)}})}mergeUserContacts(){try{let e=[];this.userPersonalContacts&&e.push(...this.userPersonalContacts),this.userGroupContacts&&e.push(...this.userGroupContacts),this.userGlobalContacts&&e.push(...this.userGlobalContacts);let t={};e.forEach(r=>{r?.userId?(!r?.email||!t[r.email])&&(t[r.userId]=r):r?.email&&(!r?.userId||!t[r.userId])&&(t[r.email]=r)}),e=Object.values(t??{}),this.internalUserContacts$.next(e)}catch(e){this.loggingService.catch("Error in ContactService mergeUserContacts: ",e)}}getInternalUserContacts(){return this.internalUserContacts$.value}getInternalUserContacts$(){return this.internalUserContacts$.asObservable()}getUserContacts$(e){try{let{organizationId:t,documentId:r,veltFolderId:a}=e||{};return t&&r?mn([this.usersByOrganizationId$,this.usersByOrganizationIdAndFolderId$,this.usersByOrganizationIdAndDocumentId$,this.userById$,this.customUserContacts$,this.customUserContactsConfig$,this.getContactListScopeForOrganizationUsers$(),this.temporaryUserIds$]).pipe(de(([s,c,p,g,f,I,T,B])=>{let z={},G=!1;I&&!I?.merge&&(G=!0);let J=Ve=>T.some(Ie=>Ve.includes(Ie)),ne=J([Yi.ALL,Yi.ORGANIZATION])?Object.keys(s?.[t]||{}):[],ve=a?J([Yi.ALL,Yi.FOLDER])?Object.keys(c?.[t]?.[a]||{}):[]:[],ye=J([Yi.ALL,Yi.DOCUMENT])?Object.keys(p?.[t]?.[r]||{}):[];if([...ne,...ve||[],...ye,...B].forEach(Ve=>{let Ie=g?.[Ve];Ie&&(z[Ve]=Ie)}),f){let{merge:Ve,options:Ie}=I||{},{organizationId:be,documentId:Ae,folderId:_e}=Ie||{},fe=_e?Ai(_e):void 0;(!be||be===t)&&(!Ae||Ae===r)&&(!fe||fe===a)&&(Ve||(z={}),f.forEach(Oe=>{Oe?.userId&&(z[Oe.userId]=Oe)}))}return Object.values(z??{})})):this.userContacts$.asObservable().pipe(de(s=>s))}catch(t){return this.loggingService.catch("Error in ContactService getUserContacts$ metadata: ",t),le([])}}getUserContactsBySnippylyId$(){return this.userSnippylyIdContacts$.asObservable()}getUserBySnippylyId(e){return this.userSnippylyIdContacts$.value?.[e]}getAtHereLabel(){return this.atHereLabel$.asObservable()}getAtHereDescription(){return this.atHereDescription$.asObservable()}getUserContactsFromDb$(){this.getUserContactSubscription||(this.getUserContactSubscription=this.authService.getUser$().pipe(Le(e=>!!e),he(e=>this.docService.getDocumentPaths$().pipe(Le(t=>!!t),Qt(t=>{this.documentPaths=t}),de(()=>e))),he(e=>{if(this.userGroupContacts=[],this.userPersonalContacts=[],!e)return le();if(!this.documentPaths)return le();let t=[];return t.push(this.commonDbService.dbListener({feature:"allGlobalContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(r=>r?.data),Qt(r=>{r?(this.userGlobalContacts=Object.values(r??{}),this.userGlobalContacts?.find(a=>a.userId===this.user?.userId)?this.userGlobalContact$.next(!0):this.userGlobalContact$.next(!1)):(this.userGlobalContacts=[],this.userGlobalContact$.next(!1))}))),t.push(this.commonDbService.dbListener({feature:"groupContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0,groupId:e?.groupId}}).pipe(de(r=>r?.data),Qt(r=>{r?(this.userGroupContacts=Object.values(r??{}),this.userGroupContacts?.find(a=>a?.userId===this.user?.userId)?this.userGroupContact$.next(!0):this.userGroupContact$.next(!1)):(this.userGroupContacts=[],this.userGroupContact$.next(!1))}))),t.push(this.commonDbService.dbListener({feature:"allLoginContacts",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0,userId:Tt(e?.userId)}}).pipe(de(r=>r?.data),Qt(r=>{r?this.userPersonalContacts=Object.values(r??{}):this.userPersonalContacts=[]}))),Uo(...t).pipe(yo(this.authService.getUser$().pipe(Le(r=>!r))))})).subscribe(()=>{this.mergeUserContacts()},e=>{this.loggingService.catch("Error in ContactService getUserContacts$ subscription: ",e)}))}addUserContact(e){try{this.user?.organizationId||this.user?.groupId&&(e.visibility="group",this.setLoggedInUserGroupContacts(this.user?.groupId,[e]))}catch(t){this.loggingService.catch("Error in ContactService addUserContact: ",t)}}isUserGlobalContact$(){return this.userGlobalContact$.asObservable().pipe(Ct(Xt))}isUserGlobalContact(){return this.userGlobalContact$.value}isUserGroupContact$(){return this.userGroupContact$.asObservable()}isUserGroupContact(){return this.userGroupContact$.value}getLoggedInUsers$(){return this.getLoggedInUsersSubscription||(this.getLoggedInUsersSubscription=this.authService.getUser$().pipe(he(e=>e?this.documentPaths?e?.userId&&this.documentPaths?.logins?this.commonDbService.dbListener({feature:"allLogins",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(de(t=>t?.data),Qt(t=>{t?this.users=Object.values(t??{}):this.users=[]})):(this.users=[],le()):le():le())).subscribe(()=>{this.users$.next(this.users)},e=>{this.loggingService.catch("Error in ContactService getLoggedInUsers$ subscription: ",e)})),this.users$.asObservable()}getUsersMap$(){return this.authService.getUser$().pipe(he(e=>e?.organizationId?this.userById$.pipe(de(t=>{let r={};return Object.values(t||{}).forEach(a=>{a?.userSnippylyId&&(r[a?.userSnippylyId]=a)}),r})):this.users$.pipe(de(t=>{let r={};return t.forEach(a=>{r[a.userSnippylyId]=a}),r}))))}getUserByEmail$(e){return this.users$.pipe(de(t=>t.find(r=>r.email===e)))}getUserByEmail(e){return this.users?.find(t=>t.email===e)}getContactByEmail(e){return this.getInternalUserContacts().find(t=>t.email===e)}getUserByUserId$(e){return this.users$.pipe(de(t=>t.find(r=>r.userId===e)))}getUserGroupContacts(){return this.userGroupContacts}getTemporaryUsers(){try{let e=this.authService.getUser();this.docService.getOrganizationConfig$().pipe(Le(t=>!!t),de(t=>t?.organizationId)).subscribe(t=>Q(this,null,function*(){if(t&&e){let r=((yield this.commonDbService?.queryData({feature:"allPermissionsUsers",properties:{organizationId:t,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[lt("expiresAt",">",new Date().getTime())]}}))??[]).filter(a=>a?.userId!==e?.userId);if(r?.length){let a=r.map(g=>g?.userId),s=vt(),c=Rl.GET_TEMPORARY_USERS;this.coreActionsService.triggerAction(mt.USER_RESOLVER,{event:Y.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:s,moduleName:c,methodName:Hr.GET_TEMPORARY_USERS,source:"internal",payload:{userIds:a}});let p=yield this.usersService.resolveUsers({userIds:a,uniqueId:s,moduleName:c});if(p){let g={};Object.entries(p).forEach(([I,T])=>{g[I]=T}),this.userById$.next(E(E({},this.userById$.value),g));let f=new Set([...this.temporaryUserIds$.value,...Object.keys(g)]);this.temporaryUserIds$.next(Array.from(f))}}}}))}catch(e){this.loggingService.catch("Error in ContactService getTemporaryUsers: ",e)}}searchUsers(e){return Q(this,null,function*(){try{if(!e||typeof e!="string"||!e.trim())return[];let t=e.trim();return this.searchUsersDebounced$||(this.searchUsersDebounced$=this.searchUsersSubject$.pipe(Bi(this.searchUsersDebounceTime),Ct(),he(r=>no(this.performSearch(r)).pipe(de(a=>({searchText:r,results:a})),Un(a=>(this.loggingService.catch("Error in ContactService performSearch: ",a),le({searchText:r,results:[]})))))),this.searchUsersDebounced$.subscribe({next:({searchText:r,results:a})=>{Array.from(this.pendingSearchPromises.keys()).forEach(p=>{if(p!==r){let g=this.pendingSearchPromises.get(p);g&&(g.forEach(({resolve:f})=>f([])),this.pendingSearchPromises.delete(p))}});let c=this.pendingSearchPromises.get(r);c&&(c.forEach(({resolve:p})=>p(a)),this.pendingSearchPromises.delete(r))},error:r=>{this.pendingSearchPromises.forEach(a=>{a.forEach(({reject:s})=>s(r))}),this.pendingSearchPromises.clear()}})),new Promise((r,a)=>{this.pendingSearchPromises.has(t)||this.pendingSearchPromises.set(t,[]),this.pendingSearchPromises.get(t).push({resolve:r,reject:a}),this.searchUsersSubject$.next(t)})}catch(t){return this.loggingService.catch("Error in ContactService searchUsers: ",t),[]}})}performSearch(e){return Q(this,null,function*(){try{let t=this.docService.getOrganizationConfig()?.organizationId;if(!t)return[];let r=this.documentPaths?.veltFolderId,a=this.docService.getDocumentIds().map(J=>J?.documentId),s=e.toLowerCase().trim(),c=s+"\uF8FF",p=[],g=a?.filter(J=>!!J)||[],f=g.length>0,I=!!r;if(f){let J=[];for(let ve=0;ve<g.length;ve+=20)J.push(g.slice(ve,ve+20));J.forEach(ve=>{let ye=[lt("documentIds","array-contains-any",ve),lt("viewerDocumentIds","array-contains-any",ve)],Ne=[lt("organizationIds","array-contains-any",[t]),lt("viewerOrganizationIds","array-contains-any",[t]),...ye];I&&Ne.push(lt("folderIds","array-contains-any",[r]),lt("viewerFolderIds","array-contains-any",[r])),p.push(this.commonDbService.queryData({feature:"allDocumentUsers",properties:{organizationId:t,isCollection:!0,useCollectionGroup:!1,useQuery:!0,firestoreQuery:[li(Df(...Ne),lt("user.name_lowercase",">=",s),lt("user.name_lowercase","<",c)),_m(10)]}}).catch(()=>[])),p.push(this.commonDbService.queryData({feature:"allDocumentUsers",properties:{organizationId:t,isCollection:!0,useCollectionGroup:!1,useQuery:!0,firestoreQuery:[li(Df(...Ne),lt("user.email_lowercase",">=",s),lt("user.email_lowercase","<",c)),_m(10)]}}).catch(()=>[]))})}let T=yield Promise.all(p),B=[];T.forEach(J=>{J&&Array.isArray(J)?J.forEach(ne=>{ne&&ne.user&&ne.user.userId&&B.push(ne)}):J&&typeof J=="object"&&Object.values(J).forEach(ve=>{ve&&ve.user&&ve.user.userId&&B.push(ve)})});let z=new Map;B.forEach(J=>{let ne=J.user?.userId;ne&&!z.has(ne)&&z.set(ne,J)});let G=Array.from(z.values());return this.setResolvedUsers(G,!0),G}catch(t){return this.loggingService.catch("Error in ContactService performSearch: ",t),[]}})}setResolvedUsers(e,t=!1){try{if(e?.length){let r=[],a=[],s=[],c=this.docService.getOrganizationConfig()?.organizationId,p=this.documentPaths?.veltFolderId,g=this.docService.getDocumentIds().map(T=>T?.documentId);e.forEach(T=>{this.userById$.value[T?.user?.userId]||(c&&T?.organizationIds?.includes(c)&&!r.find(B=>B?.user?.userId===T?.user?.userId)&&r.push(T),p&&T?.folderIds?.includes(p)&&!a.find(B=>B?.user?.userId===T?.user?.userId)&&a.push(T),g?.some(B=>T?.documentIds?.includes(B))&&!s.find(B=>B?.user?.userId===T?.user?.userId)&&s.push(T))}),r?.length&&this.setUserOrganizationContacts(r,c,t),a?.length&&this.setUserFolderContacts(a,t),s?.length&&this.setUserDocumentContacts(s,t);let I=[...r,...a,...s].filter((T,B,z)=>B===z.findIndex(G=>G.user.userId===T.user.userId));I?.length&&(this.setUserAccessFields(I),this.mergeOrganizationAndDocumentContacts())}}catch(r){this.loggingService.catch("Error in ContactService setResolvedUsers: ",r)}}getOrganizationContactsFromDb$(){try{this.getOrganizationContactsSubscription||(this.getOrganizationContactsSubscription=this.authService.getUser$().pipe(he(e=>e?.organizationId?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>this.usersService.getResolveOrganizationUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>{let r=this.docService.getOrganizationConfig()?.organizationId;return this.setUserOrganizationContacts([],r),t?r?this.commonDbService.dbListener({feature:"allOrganizationUsers",properties:{organizationId:r,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("organizationIds","array-contains-any",[r]),lt("viewerOrganizationIds","array-contains-any",[r]))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]}}).pipe(de(a=>a?.data),he(a=>this.commentService?.getPaginatedContactList()&&!Object.values(a??{}).find(s=>s?.user?.userId===this.authService.getUser()?.userId)?no(this.commonDbService.queryData({feature:"allOrganizationUsers",properties:{organizationId:r,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("organizationIds","array-contains-any",[r]),lt("viewerOrganizationIds","array-contains-any",[r])),lt("user.userId","==",this.authService.getUser()?.userId))]}})).pipe(de(s=>{if(s&&s.length>0){let c=s[0],p=c?.user?.userId||c?.id;if(p&&a){let g=Tt(p);return D(E({},a),{[g]:c})}}return a})):le(a)),de(a=>{if(a){typeof a=="object"&&(a?.undefined&&delete a.undefined,a?.null&&delete a.null);let s=Object.values(a??{});this.setUserAccessFields(s),this.setUserOrganizationContacts(s,r)}else this.setUserOrganizationContacts([],r)})):le():le()}),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserOrganizationContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getOrganizationContactsFromDb$ subscription: ",e)}))}catch{}}getFolderContactsFromDb$(){try{this.getFolderContactsSubscription||(this.getFolderContactsSubscription=this.authService.getUser$().pipe(he(e=>e?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>this.usersService.getResolveFolderUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>{let r=this.docService.getOrganizationConfig()?.organizationId;if(this.setUserFolderContacts([]),!t)return le();if(!this.commonDbService.shouldUseFirestore())return le();if(!this.documentPaths?.veltFolderId)return le();let a=le([]);return a=this.commonDbService.dbListener({feature:"allFolderUsers",properties:{organizationId:r,folderId:this.documentPaths?.veltFolderId,isCollection:!0,useQuery:!0,firestoreQuery:[li(Df(lt("folderIds","array-contains-any",[this.documentPaths?.veltFolderId]),lt("viewerFolderIds","array-contains-any",[this.documentPaths?.veltFolderId]))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]}}).pipe(de(s=>s?.data)),a.pipe(de(s=>{if(s){typeof s=="object"&&(s?.undefined&&delete s.undefined,s?.null&&delete s.null);let c=Object.values(s??{});this.setUserAccessFields(c),this.setUserFolderContacts(c)}else this.setUserFolderContacts([])}))}),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserFolderContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getFolderContactsFromDb$ subscription: ",e)}))}catch{}}getDocumentContactsFromDb$(){try{this.getDocumentContactsSubscription||(this.getDocumentContactsSubscription=this.authService.getUser$().pipe(he(e=>e?le(e).pipe(he(t=>this.docService.getDocumentPaths$().pipe(Le(r=>!!r),Qt(r=>{this.documentPaths=r}),de(()=>t))),he(t=>this.usersService.getResolveDocumentUsers$().pipe(Le(r=>r),de(()=>t))),he(t=>(this.setUserDocumentContacts([]),t?this.documentPaths?this.docService.getDocumentIds$().pipe(he(r=>{let a=r?.length>0?r.map(g=>g.documentId):[this.documentPaths?.documentId??""];if(a.some(g=>!g)||!this.documentPaths)return le();let s=le([]),c={isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(c.documentId=a?.length?a[0]:void 0,c.organizationId=this.documentPaths?.organizationId);let p=[];for(let g=0;g<a.length;g+=U.LISTENER_BATCH_SIZE)p.push(a.slice(g,g+U.LISTENER_BATCH_SIZE));return s=mn(p.map(g=>this.commonDbService.dbListener({feature:"allDocumentUsers",properties:D(E({},c),{firestoreQuery:[li(Df(lt("documentIds","array-contains-any",g),lt("viewerDocumentIds","array-contains-any",g))),eo("id"),...this.commentService?.getPaginatedContactList()?[_m(10)]:[]]})}).pipe(Or()))).pipe(de(g=>na(g)?.data)),s.pipe(de(g=>{if(g){typeof g=="object"&&(g?.undefined&&delete g.undefined,g?.null&&delete g.null);let f=Object.values(g??{});this.setUserAccessFields(f),this.setUserDocumentContacts(f)}else this.setUserDocumentContacts([])}))})):le():le())),he(()=>this.getContactListScopeForOrganizationUsers$())):(this.setUserDocumentContacts([]),le()))).subscribe(()=>{this.mergeOrganizationAndDocumentContacts()},e=>{this.loggingService.catch("Error in ContactService getDocumentContactsFromDb$ subscription: ",e)}))}catch{}}setUserOrganizationContacts(e,t,r=!0){try{let a=e.find(c=>c.user.userId===this.user?.userId);a&&this.currentOrganizationUserIAM$.next(a);let s=e.map(c=>c.user)?.filter(c=>!this.userOrganizationContacts$.value.find(p=>p.userId===c.userId));if(this.userOrganizationContacts$.next([...this.userOrganizationContacts$.value,...s]),r&&this.usersService.setUserByIds(s),t){let c={};c[t]={};let p={};e.forEach(f=>{c[t][f.user.userId]=f,p[f.user.userId]=f.user}),this.userById$.next(E(E({},this.userById$.value),p));let g=this.usersByOrganizationId$.value?.[t];g&&(c[t]=E(E({},g),c[t])),this.usersByOrganizationId$.next(D(E({},this.usersByOrganizationId$.value),{[t]:c[t]}))}else this.usersByOrganizationId$.next({})}catch(a){this.loggingService.catch("Error in ContactService setUserOrganizationContacts: ",a)}}getUserOrganizationContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION])?this.userOrganizationContacts$.asObservable():le([])))}getUserOrganizationContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION])?this.userOrganizationContacts$.value:[]}setUserFolderContacts(e,t=!0){try{let r=e?.map(p=>p?.user)?.filter(p=>!this.userFolderContacts$.value.find(g=>g.userId===p.userId));this.userFolderContacts$.next([...this.userFolderContacts$.value,...r]),t&&this.usersService.setUserByIds(r);let a=this.usersByOrganizationIdAndFolderId$.value||{},s=E({},a),c={};e?.forEach(p=>{let{organizationId:g}=p?.metadata||{};g&&(s[g]||(s[g]={}),p.folderIds?.forEach(f=>{s[g][f]||(s[g][f]={}),s[g][f]=D(E({},s[g][f]),{[p.user.userId]:p}),c[p.user.userId]=p.user}))}),this.userById$.next(E(E({},this.userById$.value),c)),this.usersByOrganizationIdAndFolderId$.next(s)}catch(r){this.loggingService.catch("Error in ContactService updateUserFolderContacts: ",r)}}getUserFolderContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.FOLDER])?this.userFolderContacts$.asObservable():le([])))}getUserFolderContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.FOLDER])?this.userFolderContacts$.value:[]}setUserDocumentContacts(e,t=!0){try{let r=e?.map(p=>p?.user)?.filter(p=>!this.userDocumentContacts$.value.find(g=>g.userId===p.userId));this.userDocumentContacts$.next([...this.userDocumentContacts$.value,...r]),t&&this.usersService.setUserByIds(r);let a=this.usersByOrganizationIdAndDocumentId$.value||{},s=E({},a),c={};e?.forEach(p=>{let{organizationId:g}=p?.metadata||{};g&&(s[g]||(s[g]={}),p.documentIds?.forEach(f=>{s[g][f]||(s[g][f]={}),s[g][f]=D(E({},s[g][f]),{[p.user.userId]:p}),c[p.user.userId]=p.user}))}),this.userById$.next(E(E({},this.userById$.value),c)),this.usersByOrganizationIdAndDocumentId$.next(s)}catch(r){this.loggingService.catch("Error in ContactService updateUserDocumentContacts: ",r)}}getUserDocumentContacts$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.userDocumentContacts$.asObservable():le([])))}getUserDocumentContacts(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.userDocumentContacts$.value:[]}getCurrentOrganizationUserIAM$(){return this.currentOrganizationUserIAM$.asObservable()}getCurrentOrganizationUserIAM(){return this.currentOrganizationUserIAM$.value}mergeOrganizationAndDocumentContacts(){try{this.mergeContactsDebounceTimer&&clearTimeout(this.mergeContactsDebounceTimer),this.mergeContactsDebounceTimer=setTimeout(()=>{this.executeMergeContacts()},200)}catch(e){this.loggingService.catch("Error in ContactService mergeOrganizationAndDocumentContacts: ",e)}}executeMergeContacts(){try{let e=this.getContactListScopeForOrganizationUsers(),t=[];e.includes(Yi.ALL)?t=[...this.getUserOrganizationContacts(),...this.getUserFolderContacts(),...this.getUserDocumentContacts()]:e.includes(Yi.ORGANIZATION)?t=[...this.getUserOrganizationContacts()]:e.includes(Yi.FOLDER)?t=[...this.getUserFolderContacts()]:e.includes(Yi.DOCUMENT)&&(t=[...this.getUserDocumentContacts()]);let r=[...new Map(t.filter(a=>a?.userId).map(a=>[a.userId,a])).values()];this.internalUserContacts$.next(r)}catch(e){this.loggingService.catch("Error in ContactService mergeOrganizationAndDocumentContacts: ",e)}}getOrganizationGroupsFromDb$(){try{this.getOrganizationGroupsSubscription||(this.getOrganizationGroupsSubscription=this.authService.getUser$().pipe(he(e=>e?.organizationId?le(e).pipe(he(t=>this.docService.getOrganizationConfig$().pipe(Le(r=>!!r),de(()=>t))),he(t=>{if(this.setUserOrganizationGroups([]),!t)return le();let r=this.docService.getOrganizationConfig()?.organizationId;return r?this.commonDbService.dbListener({feature:"allOrganizationGroups",properties:{organizationId:r,isCollection:!0}}).pipe(de(a=>a?.data),de(a=>{a?(typeof a=="object"&&(a?.undefined&&delete a.undefined,a?.null&&delete a.null),this.setUserOrganizationGroups(Object.values(a??{}))):this.setUserOrganizationGroups([])})):le()})):(this.setUserOrganizationGroups([]),le()))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ContactService getOrganizationGroupsFromDb$ subscription: ",e)}))}catch{}}setUserOrganizationGroups(e){try{this.userOrganizationGroups$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setUserOrganizationGroups: ",t)}}onContactSelected(e){try{if(e?.userId){let t=!!this.getUserDocumentContacts().find(a=>a.userId===e.userId),r=!!this.getUserOrganizationContacts().find(a=>a.userId===e.userId);switch(this.documentAccessType){case Di.RESTRICTED:if(!t){let a={contact:e,isOrganizationContact:r,isDocumentContact:t,documentAccessType:this.documentAccessType};this.onContactSelectedSubject$.next(a)}break}}else{let t={contact:e,isOrganizationContact:!1,isDocumentContact:!1,documentAccessType:this.documentAccessType};this.onContactSelectedSubject$.next(t)}}catch(t){this.loggingService.catch("Error in ContactService onContactSelected: ",t)}}onContactSelected$(){return this.onContactSelectedSubject$.asObservable()}getOrganizationGroups$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.ORGANIZATION_USER_GROUP])?this.userOrganizationGroups$.asObservable():le([])))}enableAtHere(){try{if(this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereEnabled:!0}}),this.atHereEnabled$.value===!0)return;this.atHereEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ContactService enableAtHere: ",e)}}setAtHereLabel(e){try{this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereLabel:e}}),e&&this.atHereLabel$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setAtHereLabel: ",t)}}setAtHereDescription(e){try{this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereDescription:e}}),e&&this.atHereDescription$.next(e)}catch(t){this.loggingService.catch("Error in ContactService setAtHereDescription: ",t)}}disableAtHere(){try{if(this.analyticsService.setFeatureConfig({feature:Re.COMMENT,config:{atHereEnabled:!1}}),this.atHereEnabled$.value===!1)return;this.atHereEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in ContactService disableAtHere: ",e)}}getAtHereEnabled$(){return this.getContactListScopeForOrganizationUsers$().pipe(he(()=>this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.atHereEnabled$.asObservable():le(!1)))}getAtHereEnabled(){return this.checkContactListScopeForOrganizationUsers([Yi.ALL,Yi.DOCUMENT])?this.atHereEnabled$.value:!1}updateContactListScopeForOrganizationUsers(e){try{this.contactListScopeForOrganizationUsers$.next(e)}catch(t){this.loggingService.catch("Error in ContactService updateContactListScopeForOrganizationUsers: ",t)}}getContactListScopeForOrganizationUsers$(){return this.contactListScopeForOrganizationUsers$.asObservable()}getContactListScopeForOrganizationUsers(){return this.contactListScopeForOrganizationUsers$.value}checkContactListScopeForOrganizationUsers(e){return this.getContactListScopeForOrganizationUsers().some(t=>e.includes(t))}updateContactList(e,t){return Q(this,null,function*(){try{this.analyticsService.trackEvent(Y.Events.Contact.UPDATE_CONTACT_LIST_TRIGGERED,{contactsCount:e?.length,config:t}),this.usersService.setUserByIds(e),this.customUserContacts$.next(e),this.customUserContactsConfig$.next(t)}catch(r){this.loggingService.catch("Error in CommentService updateContactList: ",r)}})}convert(e){try{if(e?.options){let{documentId:t,organizationId:r}=this.docService.getServerId(e?.options);e.options=D(E({},e?.options),{documentId:t,organizationId:r})}return this}catch(t){return this.loggingService.catch("Error in ContactService convert: ",t),this}}getContactList$(){try{return this.authService.getUser$().pipe(he(e=>e?mn([this.userOrganizationContacts$.asObservable(),this.userFolderContacts$.asObservable(),this.userDocumentContacts$.asObservable(),this.userOrganizationGroups$.asObservable(),this.customUserContacts$.asObservable()]).pipe(de(([t,r,a,s,c])=>{let p={};p.organizationUsers=t?.map(f=>this.convertToClientUser(f)),p.folderUsers=r?.map(f=>this.convertToClientUser(f)),p.documentUsers=a?.map(f=>this.convertToClientUser(f)),p.updatedContactList=c?.map(f=>this.convertToClientUser(f));let g=[];return s?.forEach(f=>{let I=this.convertToClientUserGroup(f,p.organizationUsers||[]);I&&g.push(I)}),p.userGroups=g,p}),Ct(Xt)):le(null)),Un(e=>(this.loggingService.catch("Error in ContactService getContactList$: ",e),le(null))))}catch(e){return this.loggingService.catch("Error in ContactService getContactList$: ",e),le(null)}}convertToClientUserGroup(e,t){try{let r={groupId:e?.metadata?.clientGroupId,groupName:e?.metadata?.groupName,users:[]},a={};return t?.forEach(s=>{if(s?.userId){let c=Tt(s.userId);a[c]=s}}),Object.keys(e?.users??{}).forEach(s=>{a[s]&&r.users?.push(a[s])}),r}catch(r){return this.loggingService.catch("Error in ContactService convertToClientUserGroup: ",r),null}}convertToClientUser(e){try{return e&&(e=JSON.parse(JSON.stringify(e)),e?.clientGroupId&&(e.groupId=e.clientGroupId,delete e.clientGroupId),e?.clientOrganizationId&&(e.organizationId=e.clientOrganizationId,delete e.clientOrganizationId),e?.userSnippylyId&&delete e.userSnippylyId),e}catch(t){return this.loggingService.catch("Error in ContactService convertToClientUser: ",t),e}}getCustomUserContacts(){return this.customUserContacts$.value}getCustomUserContacts$(){return this.customUserContacts$.asObservable()}getCustomUserContactsConfig(){return this.customUserContactsConfig$.value}getCustomUserContactsConfig$(){return this.customUserContactsConfig$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(Ft),ee(ni),ee(In),ee(ot),ee(_),ee(un),ee(Ln))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Kpe=i=>{try{let o={USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_ATTR:["onerror","onload","onclick","onmouseover","onmouseout","onmouseenter","onmouseleave","onmousemove","onmousedown","onmouseup","onwheel","onscroll","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","onsubmit","on*"],FORBID_TAGS:["script","style","iframe","object","embed","form"]};return t2.sanitize(i,o)}catch(o){return nt.catch("Error in File utils sanitizeSvg: ",o),""}},Zpe=i=>{try{return i.name.split(".").slice(0,-1).join(".")}catch(o){nt.catch("Error in File utils getFileName: ",o);return}},rq=i=>{try{return/(?:\.([^.]+))?$/.exec(i?.name)[1]}catch(o){nt.catch("Error in File utils getFileExtension: ",o);return}},Xpe=(i,o)=>{try{let n=i.slice(0,-1,i.type);return new File([n],o+"."+rq(i),{type:i.type})}catch(n){nt.catch("Error in File utils updateFile: ",n);return}},Qpe=i=>new Promise((o,n)=>{let e=new FileReader;e.readAsDataURL(i),e.onload=()=>{o(e.result)},e.onerror=t=>{n(t)}}),aq={mp4:"video/mp4",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",webm:"video/webm",mkv:"video/x-matroska",m4v:"video/x-m4v",m4a:"audio/x-m4a",aac:"audio/aac","3gp":"video/3gpp","3g2":"video/3gpp2",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",odt:"application/vnd.oasis.opendocument.text",ods:"application/vnd.oasis.opendocument.spreadsheet",zip:"application/zip",rar:"application/x-rar-compressed",txt:"text/plain",rtf:"application/rtf",html:"text/html",htm:"text/html",csv:"text/csv",ics:"text/calendar",vcf:"text/x-vcard",js:"application/javascript",css:"text/css",json:"application/json",xml:"application/xml",swf:"application/x-shockwave-flash"};var au=(()=>{let o=class o{constructor(e,t,r,a,s){this.authService=e,this.configService=t,this.coreActionsService=r,this.loggingService=a,this.attachmentResolverService=s,this.storage=Nb();try{this.configService.getApiKey$().subscribe(c=>{this.apiKey=c}),this.authService.getFirebaseConfig$().subscribe(c=>{c&&c.firebaseOptions?.storageBucket&&(this.storage=Nb(void 0,c?.firebaseOptions?.storageBucket))},c=>{this.loggingService.catch("Error in StorageService constructor: ",c)})}catch(c){this.loggingService.catch("Error in StorageService constructor:",c)}}createAttachment({path:e,file:t}){try{let r=new PC;r.name=t.name;let a=Xpe(t,`${r.attachmentId}_${Zpe(t)}`),s=`${this.apiKey}/${e}/${a?.name}`;return r.bucketPath=s,r.size=t.size,r.type=rq(t),r?.type&&(r.mimeType=aq[r?.type]),r}catch(r){return this.loggingService.catch("Error in StorageService createAttachment: ",r),null}}sanitizeSvgFile(e){return Q(this,null,function*(){if(e.type===aq.svg)try{let t=yield e.text(),r=Kpe(t);return new File([r],e.name,{type:e.type})}catch(t){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",t),e}return e})}uploadAttachmentToStorage(s){return Q(this,arguments,function*({attachment:e,file:t,resolve:r,reject:a}){try{let c=Fb(this.storage,e.bucketPath),p=$$(c,t,{cacheControl:"public,max-age=3600"});p.on("state_changed",g=>{let f=g.bytesTransferred/g.totalBytes*100},g=>{a(g)},()=>{j$(p.snapshot.ref).then(g=>{e.url=g,r(e)})})}catch(c){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",c),a(c)}})}uploadToResolver(c){return Q(this,arguments,function*({file:e,attachment:t,metadata:r,resolve:a,reject:s}){try{r.attachmentId=t.attachmentId;let p={attachmentId:t.attachmentId,name:t.name,file:e,metadata:r,mimeType:t.mimeType},g=vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:Nl.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:p,eventType:va.ATTACHMENT_ADD}});let f=yield this.attachmentResolverService.saveAttachment({attachment:p,eventType:va.ATTACHMENT_ADD},g);f&&f.data?.url?(t.url=f.data?.url,a(t)):s(new Error("Failed to upload attachment to resolver"))}catch(p){this.loggingService.catch("Error in StorageService uploadToResolver: ",p),s(p)}})}uploadFile({path:e,file:t,useAttachmentResolver:r,metadata:a}){return new Promise((s,c)=>Q(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let p=yield this.sanitizeSvgFile(t),g=this.createAttachment({path:e,file:p});if(!g)throw new Error("Attachment not created");r?this.uploadToResolver({file:p,attachment:g,metadata:a,resolve:s,reject:c}):this.uploadAttachmentToStorage({attachment:g,file:p,resolve:s,reject:c})}catch(p){this.loggingService.catch("Error in StorageService uploadFile:",p),c(p)}}))}uploadChunk(e,t,r){return new Promise((a,s)=>{try{if(this.apiKey){let c=`${this.apiKey}/${e}/${t.name}`,p=Fb(this.storage,c),g=$$(p,t,{cacheControl:"public,max-age=3600"});g.on("state_changed",f=>{let I=f.bytesTransferred/f.totalBytes*100},f=>{s(f)},()=>{j$(g.snapshot.ref).then(f=>{a(f)}).catch(f=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${r}:`,f),s(f)})})}else{let c=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",c),s(c)}}catch(c){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${r}: `,c),s(c)}})}downloadAttachment(e){try{if(e.url){let t=new XMLHttpRequest;t.responseType="blob",t.onload=()=>{let r=t.response,a=document.createElement("a"),s=window.URL.createObjectURL(r);a.setAttribute("type","hidden"),a.setAttribute(U.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),a.classList.add("snippyly-overlay-panel"),a.href=s,e?.name&&(a.download=e?.name),document.body.appendChild(a);let c=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(c),window.URL.revokeObjectURL(s),a.remove()},t.onerror=()=>{window.open(e.url,"_blank")},t.open("GET",e.url),t.send()}}catch(t){this.loggingService.catch("Error in StorageService downloadAttachment: ",t)}}deleteAttachment({attachment:e,metadata:t,useAttachmentResolver:r}){return new Promise((a,s)=>{if(r){let c=vt();this.coreActionsService.triggerAction(mt.ATTACHMENT_RESOLVER,{event:Y.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:Nl.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:e.attachmentId,metadata:t}}),this.attachmentResolverService.deleteAttachment({attachmentId:e.attachmentId,metadata:t},c).then(()=>{a(null)}).catch(p=>{s(p)})}else{let c=Fb(this.storage,e.bucketPath);U$(c).then(()=>{a(null)}).catch(p=>{a(null)})}})}deleteFileFromPath(e){return new Promise((t,r)=>{let a=Fb(this.storage,e);U$(a).then(()=>{t(null)}).catch(s=>{r(s)})})}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Ft),ee(ni),ee(_),ee(ou))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var En=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.analyticsService=e,this.authService=t,this.contactService=r,this.databaseService=a,this.docService=s,this.configService=c,this.loggingService=p,this.commonDbService=g,this.documentIAM$=new Ce(null),this.workspaceIAM$=new Ce(null),this.roles$=new Ce([]),this.getDocumentIamSubscription=null,this.getOrganizationIamSubscription=null,this.getWorkspaceIamSubscription=null;try{this.authService.setIamService(this),this.databaseService.getDb().pipe(Le(f=>!!f),rt(1)).subscribe(f=>{f&&(this.getUser(),this.getDocumentPaths())},f=>{this.loggingService.catch("Error in CommentService getDb subscription: ",f)}),this.getRole$().pipe(rt(1)).subscribe(f=>{this.authService?.getUser()&&!f&&this.analyticsService.trackEvent(Y.Events.Iam.USER_ACCESS_DENIED)}),this.documentIAM$.subscribe(f=>{f?.accessType&&this.contactService.setDocumentAccessType(f.accessType)})}catch(f){this.loggingService.catch("Error in IamService constructor: ",f)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in IamService","color: green;");try{this.documentIAM$.next(null),this.workspaceIAM$.next(null),this.roles$.next([]),this.documentPaths=null}catch(e){this.loggingService.catch("Error in IamService clearCache: ",e)}}getUser(){try{this.authService.getUser$().pipe(Le(e=>!!e)).subscribe(e=>{this.user=e,this.user?this.getDocumentIam():(this.getDocumentIamSubscription?.unsubscribe(),this.getOrganizationIamSubscription?.unsubscribe(),this.getWorkspaceIamSubscription?.unsubscribe())},e=>{this.loggingService.catch("Error in IamService getUser$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getUser: ",e)}}getDocumentPaths(){try{this.docService.getDocumentPaths$().pipe(Le(e=>!!e)).subscribe(e=>{this.documentPaths=e,this.getDocumentIam(),this.getWorkspaceIam()},e=>{this.loggingService.catch("Error in IamService getDocumentPaths$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getDocumentPaths: ",e)}}getDocumentIam(){try{this.getDocumentIamSubscription&&(this.getDocumentIamSubscription.unsubscribe(),this.getDocumentIamSubscription=null),this.user?this.getDocumentIamSubscription=this.docService.getDocumentIam$().subscribe(e=>{let t=e||new n9;this.documentIAM$.next(t)},e=>{this.loggingService.catch("Error in IamService getDocumentIam$ subscription: ",e)}):this.documentIAM$.next(null)}catch(e){this.loggingService.catch("Error in IamService getDocumentIam: ",e)}}getWorkspaceIam(){try{this.getWorkspaceIamSubscription||(this.getWorkspaceIamSubscription=this.commonDbService.dbListener({feature:"workspaceIam",properties:{skipFirestore:!0}}).pipe(Un(e=>le(null))).subscribe(e=>{this.workspaceIAM$.next(e?.data),this.roles$.next(e?.data?.roles||[])}))}catch(e){this.loggingService.catch("Error in IamService getWorkspaceIam: ",e)}}isUserAllowed$(){return this.getRole$().pipe(de(e=>!!e),Ct())}getDocumentIAM$(){return this.documentIAM$.asObservable()}getRoles$(){return this.roles$.asObservable().pipe(de(e=>e?.length?e:U.WorkspaceRoles))}getFeaturesAccessLevel$(){return this.documentIAM$.asObservable().pipe(de(e=>e?.features),he(e=>this.getRole$().pipe(de(t=>(t===go.ADMIN&&(e=e&&JSON.parse(JSON.stringify(e||{})),e?.all?.disabled&&(e.all.disabled=!1)),e)))))}hasRole(e){try{return e===this.getRole()}catch(t){return this.loggingService.catch("Error in IamService hasRole: ",t),!1}}hasRoleAny(e=[]){try{return e?.includes(this.getRole()||"")}catch(t){return this.loggingService.catch("Error in IamService hasRoleAny: ",t),!1}}hasRole$(e){try{return this.authService.getUser$().pipe(he(()=>this.documentIAM$.pipe(Le(t=>!!t),he(()=>this.workspaceIAM$.pipe(de(()=>e===this.getRole()))))))}catch(t){return this.loggingService.catch("Error in IamService hasRole$: ",t),le(!1)}}getRole$(){try{return this.authService.getUser$().pipe(he(()=>this.configService.getSF$()),he(()=>this.configService.getSF()?this.contactService.isUserGlobalContact$():le(null)),he(()=>this.configService.getSF()?this.documentIAM$.pipe(Le(e=>!!e),Ct(Xt)):le(null)),he(()=>this.workspaceIAM$.pipe(Ct(Xt))),de(()=>this.getRole()))}catch(e){return this.loggingService.catch("Error in IamService getRole$: ",e),le(null)}}getRole(){try{let e=this.configService.getSF();if(e&&this.contactService.isUserGlobalContact())return go.ADMIN;if(!e)return this.user?.isAdmin?go.ADMIN:go.COMMENTER;let t=null,r;if(this.user)switch((this.documentIAM$.value?this.documentIAM$.value?.features?.all?.restricted:!1)?Di.RESTRICTED:this.documentIAM$.value?this.documentIAM$.value?.documentAccessType||Di.PUBLIC:null){case Di.PUBLIC:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||go.COMMENTER;break;case Di.RESTRICTED:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||null;break;default:break}return t}catch(e){this.loggingService.catch("Error in IamService getRole: ",e)}return null}isUserAdmin$(){return this.getRole$().pipe(de(e=>e===go.ADMIN),Ct())}isUserAdmin(){try{return this.getRole()===go.ADMIN}catch(e){return this.loggingService.catch("Error in IamService isUserAdmin: ",e),!1}}getUserFromDocumentIAM(e,t){try{if(e||t){let r;return e&&(r=this.documentIAM$.value?.users?.[Tt(e)]),!r&&t&&(r=this.documentIAM$.value?.users?.[Tt(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromDocumentIAM: ",r)}}getUserFromWorkspaceIAM(e,t){try{if(e||t){let r;return e&&(r=this.workspaceIAM$.value?.users?.[Tt(e)]),!r&&t&&(r=this.workspaceIAM$.value?.users?.[Tt(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromWorkspaceIAM: ",r)}}};o.\u0275fac=function(t){return new(t||o)(ee(Qe),ee(je),ee(Si),ee(In),ee(ot),ee(Ft),ee(_),ee(un))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ss=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I){this.authService=e,this.docService=t,this.loggingService=r,this.commonDbService=a,this.usersService=s,this.commentUtilsService=c,this.coreActionsService=p,this.functions=g,this.configService=f,this.contactService=I,this.currentUserPermissions$=new Ce(null),this.permissionsCache$=new Ce(null),this.permissionProvider$=new Ce(null);try{this.docService.setUserPermissionService(this),this.authService.setUserPermissionService(this),this.commentUtilsService.setUserPermissionService(this),this.contactService.setUserPermissionService(this)}catch(T){this.loggingService.catch("Error in UserPermissionService constructor:",T)}}hasUserContextAccess({userId:e,accessFields:t}){try{if(!this.getIsContextEnabled()||t.includes(U.DEFAULT_VELT_CONTEXT))return!0;let r=this.contactService.getUserAccessFieldsByUserId(e);return r?t.every(a=>r.includes(a)):!0}catch(r){return this.loggingService.catch("Error in UserPermissionService hasUserContextAccess:",r),!1}}organizationDetails(e){return Q(this,null,function*(){try{let t=yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{organizationId:e}});return t&&t?.errorCode?{errorCode:Lo.PERMISSION_DENIED,error:!0}:t&&!t?.metadata?{errorCode:Lo.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(t){return this.loggingService.catch("Error in UserPermissionService organizationDetails:",t),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}documentDetails(r){return Q(this,arguments,function*({documentId:e,organizationId:t}){try{let a=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:e,organizationId:t}});if(a&&a?.errorCode)return{errorCode:Lo.PERMISSION_DENIED,error:!0};if(a&&!a?.metadata)return{errorCode:Lo.DOES_NOT_EXIST,error:!0};let s=this.docService.getDocumentMetadata(e)??{};return this.docService.setDocumentMetadata(e,E(E({},s),a?.metadata??{})),{error:!1}}catch(a){return this.loggingService.catch("Error in UserPermissionService documentDetails:",a),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}folderDetails(r){return Q(this,arguments,function*({folderId:e,organizationId:t}){try{let a=yield this.commonDbService?.getData({feature:"folderMetadata",properties:{folderId:e,organizationId:t}});return a&&a?.errorCode?{errorCode:Lo.PERMISSION_DENIED,error:!0}:a&&!a?.metadata?{errorCode:Lo.DOES_NOT_EXIST,error:!0}:{error:!1}}catch(a){return this.loggingService.catch("Error in UserPermissionService folderDetails:",a),{errorCode:Lo.SOMETHING_WENT_WRONG,error:!0}}})}getUserPermissions(e){return Q(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getUserPermissions]",void 0,void 0,!0),{};let t=this.extractResourceIds(e);if(!t.clientOrganizationId||!t.organizationId)return this.loggingService.catch("Client organization id or organization id not set during getUserPermissions",void 0,void 0,!0),{};let r=yield this.validateResources(t),[a,s]=yield this.fetchUserPermissionsFromDB(t),c=this.buildPermissionsResponse(t,r,a,s);return!e&&Object.keys(c).length>0&&this.setCurrentUserPermissions(c),c}catch(t){return this.loggingService.catch("Error in UserPermissionService getUserPermissions:",t),{}}})}extractResourceIds(e){let t=this.docService.getDocumentPaths(),r=this.docService.getDocumentIds();return{folderIds:e?.folderIds?.length?e.folderIds:t?.folderId?[t.folderId]:[],documentIds:e?.documentIds?.length?e.documentIds:r.map(a=>a.clientDocumentId),clientOrganizationId:e?.organizationId??t?.clientOrganizationId,organizationId:e?.organizationId??t?.clientOrganizationId?os(e?.organizationId??t?.clientOrganizationId??""):void 0}}validateResources(e){return Q(this,null,function*(){let{folderIds:t,documentIds:r,organizationId:a,clientOrganizationId:s}=e,c=[],p=[];a&&(c.push(this.organizationDetails(a)),p.push({id:s??"",type:"organization"})),t.forEach(f=>{c.push(this.folderDetails({folderId:Ai(f),organizationId:a??""})),p.push({id:f,type:"folder"})}),r.forEach(f=>{c.push(this.documentDetails({documentId:Tr(f),organizationId:a??""})),p.push({id:f,type:"document"})});let g=yield Promise.allSettled(c);return this.processValidationResults(g,p)})}processValidationResults(e,t){let r=[],a=[],s,c=e.map((p,g)=>({result:p,metadata:t[g]})).filter(({result:p})=>p.status==="rejected"||p.status==="fulfilled"&&p.value.error);for(let{result:p,metadata:g}of c){let f=p.status==="fulfilled"?p.value.errorCode??Lo.SOMETHING_WENT_WRONG:Lo.SOMETHING_WENT_WRONG,I={id:g.id,errorCode:f};switch(g.type){case"organization":if(s=I,f===Lo.DOES_NOT_EXIST)throw new Error(`Organization with id '${g.id}' does not exist`);break;case"folder":r.push(I);break;case"document":a.push(I);break}}return{failedFolderIds:r,failedDocumentIds:a,failedOrganizationId:s}}fetchUserPermissionsFromDB(e){return Q(this,null,function*(){let{folderIds:t,documentIds:r,organizationId:a}=e,s=[this.authService.getUser()?.userId??""],c=[...t.map(f=>Ai(f)),...r.map(f=>Tr(f)),a??""],[p,g]=yield Promise.allSettled([this.usersService.getUsersFromDBWithBatching({userIds:s,organizationId:a}),this.usersService.getTemporaryUsersFromDBWithBatching({userIds:s,organizationId:a,resourceIds:c})]);return[p.status==="fulfilled"?p.value:[],g.status==="fulfilled"?g.value:[]]})}buildPermissionsResponse(e,t,r,a){let{folderIds:s,documentIds:c,clientOrganizationId:p,organizationId:g}=e,{failedFolderIds:f,failedDocumentIds:I,failedOrganizationId:T}=t,B={};return this.processRegularUserPermissions(B,r,s,c,p??"",g??"",f,I,T),this.processTemporaryUserPermissions(B,a),this.processContextPermissions(B),B}processContextPermissions(e){try{let t=this.authService.getUser()?.userId;if(t){let r=this.contactService.getUserAccessFieldsByUserId(t);r?.length&&(e[t]||(e[t]={}),e[t].context={accessFields:r})}}catch(t){this.loggingService.catch("Error in UserPermissionService processContextPermissions:",t);return}}processRegularUserPermissions(e,t,r,a,s,c,p,g,f){for(let I of t)for(let T of I)T?.user?.userId&&(e[T.user.userId]=D(E({},r.length&&{folders:this.buildFolderPermissions(r,T,p)}),{documents:this.buildDocumentPermissions(a,T,g),organization:{[s]:this.buildOrganizationPermission(c,T,f)}}))}getErrorMessage(e,t){try{switch(this.loggingService.log(`Error in UserPermissionService getErrorMessage: ${e} ${t}`),e){case Lo.DOES_NOT_EXIST:return`${t} does not exist`;case Lo.PERMISSION_DENIED:return`User does not have access to ${t}`;case Lo.SOMETHING_WENT_WRONG:return"Something went wrong";default:return"Something went wrong"}}catch(r){return this.loggingService.catch("Error in UserPermissionService getErrorMessage:",r),"Something went wrong"}}buildFolderPermissions(e,t,r){return e.reduce((a,s)=>{let c=r.find(p=>p.id===s);return c?a[s]={error:this.getErrorMessage(c.errorCode,"folder"),errorCode:c.errorCode}:a[s]={accessRole:t.viewerFolderIds?.includes(Ai(s))?tl.VIEWER:tl.EDITOR},a},{})}buildDocumentPermissions(e,t,r){return e.reduce((a,s)=>{let c=r.find(p=>p.id===s);return c?a[s]={error:this.getErrorMessage(c.errorCode,"document"),errorCode:c.errorCode}:a[s]={accessRole:t.viewerDocumentIds?.includes(Tr(s))?tl.VIEWER:tl.EDITOR},a},{})}buildOrganizationPermission(e,t,r){return r?{error:this.getErrorMessage(r.errorCode,"organization"),errorCode:r.errorCode}:{accessRole:t.viewerOrganizationIds?.includes(e)?tl.VIEWER:tl.EDITOR}}processTemporaryUserPermissions(e,t){for(let r of t)if(r?.userId)switch(this.ensureUserPermissionStructure(e,r.userId),r.type){case"folder":this.addTemporaryFolderPermission(e,r);break;case"document":this.addTemporaryDocumentPermission(e,r);break;case"organization":this.addTemporaryOrganizationPermission(e,r);break}}ensureUserPermissionStructure(e,t){e[t]||(e[t]={})}addTemporaryFolderPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].folders||(e[r].folders={}),e[r].folders[a]||(e[r].folders[a]={accessRole:s??tl.EDITOR,expiresAt:c})}addTemporaryDocumentPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].documents||(e[r].documents={}),e[r].documents[a]={accessRole:s??tl.EDITOR,expiresAt:c}}addTemporaryOrganizationPermission(e,t){let{userId:r,resourceId:a,role:s,expiresAt:c}=t;e[r].organization||(e[r].organization={}),e[r].organization[a]={accessRole:s??tl.EDITOR,expiresAt:c}}hasEditAccess({organizationId:e,folderId:t,documentId:r}){try{let a=!0,s=this.getCurrentUserPermissionsWithServerIds(),c=this.authService.getUser()?.userId??"";return s&&(e&&typeof e=="string"&&s?.[c]?.organization?.[e]&&(s?.[c]?.organization?.[e]?.accessRole===tl.VIEWER||s?.[c]?.organization?.[e]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1),t&&typeof t=="string"&&s?.[c]?.folders?.[t]&&(s?.[c]?.folders?.[t]?.accessRole===tl.VIEWER||s?.[c]?.folders?.[t]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1),r&&typeof r=="string"&&s?.[c]?.documents?.[r]&&(s?.[c]?.documents?.[r]?.accessRole===tl.VIEWER||s?.[c]?.documents?.[r]?.errorCode===Lo.PERMISSION_DENIED)&&(a=!1)),a}catch{return!0}}getCurrentUserPermissions$(){return this.currentUserPermissions$.asObservable().pipe(Ct(Xt))}getCurrentUserPermissions(){return this.currentUserPermissions$.value}refactorPermissionsWithServerIds(e){try{let t=JSON.parse(JSON.stringify(e??{})),r=this.authService.getUser()?.userId??"";if(t?.[r]){let a=this.docService.getDocumentPaths()?.clientOrganizationId??"";if(t?.[r]?.organization?.[a]){let s=os(a);t[r].organization&&(t[r].organization[s]=t[r].organization[a],delete t[r].organization[a])}t?.[r]?.folders&&(t[r].folders=Object.fromEntries(Object.entries(t?.[r]?.folders??{}).map(([s,c])=>[Ai(s),c]))),t?.[r]?.documents&&(t[r].documents=Object.fromEntries(Object.entries(t?.[r]?.documents??{}).map(([s,c])=>[Tr(s),c])))}return t}catch(t){return this.loggingService.catch("Error in UsersPermissionService refactorPermissionsWithServerIds:",t),e}}getCurrentUserPermissionsWithServerIds$(){return this.currentUserPermissions$.asObservable().pipe(de(e=>this.refactorPermissionsWithServerIds(e)),Ct(Xt))}getCurrentUserPermissionsWithServerIds(){return this.refactorPermissionsWithServerIds(this.currentUserPermissions$.value)}setCurrentUserPermissions(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCurrentUserPermissions","color: green;");let t=null;e&&(t=JSON.parse(JSON.stringify(e))),this.currentUserPermissions$.next(t)}catch(t){this.loggingService.catch("Error in UsersPermissionService setCurrentUserPermissions:",t)}}getIsContextEnabled(){return this.loggingService.log("%c[WB] Calling FUNCTION: getIsContextEnabled","color: green;"),this.permissionProvider$.value?.isContextEnabled??!1}setPermissionProvider(e){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setPermissionProvider","color: green;"),this.permissionProvider$.next(e)}catch(t){this.loggingService.catch("Error in UsersPermissionService setPermissionProvider:",t)}}get isRevokeAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.DOCUMENT_UNSET)??!1}get isRevokeAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.USER_LOGOUT)??!1}get isRevokeOrganizationAccessOnUserLogoutEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.USER_LOGOUT&&e.revokeOrganizationAccess)??!1}get isRevokeOrganizationAccessOnDocumentUnsetEnabled(){return this.permissionProvider$.value?.revokeAccessOn?.some(e=>e.type===RC.DOCUMENT_UNSET&&e.revokeOrganizationAccess)??!1}getPermissionProviderRetryConfig(){return this.permissionProvider$.value?.retryConfig??{retryCount:0,retryDelay:0}}revokeAccessOnUserLogout(){return Q(this,null,function*(){let e=vt();try{if(this.isRevokeAccessOnUserLogoutEnabled){let t=[],r=this.authService.getUser()?.userId??"";if((this.getPermissionsCache()??[]).forEach(s=>{s.userId===r&&s.hasAccess&&(s.type===Fo.ORGANIZATION?this.isRevokeOrganizationAccessOnUserLogoutEnabled&&t.push(D(E({},s),{hasAccess:!1})):t.push(D(E({},s),{hasAccess:!1})))}),t.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:t}}),this.setPermissionsCache([]),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{requests:t}});let s=yield this.revokeAccess({requests:t,userId:this.authService.getUser()?.userId??""});s.success?this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:s,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{result:{data:s,success:!1,statusCode:500}}})}}}catch(t){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_USER_LOGOUT_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_USER_LOGOUT,source:"internal",payload:{error:t}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnUserLogout:",t)}})}revokeAccessOnDocumentUnset(){return Q(this,null,function*(){let e=vt();try{if(this.isRevokeAccessOnDocumentUnsetEnabled){let t=[],r=this.docService.getDocumentIds(),a=this.docService.getOrganizationConfig()?.clientOrganizationId??"",s=this.docService.getDocumentPaths()?.folderId??"",c=this.authService.getUser()?.userId??"",p=this.getPermissionsCache()??[];if(r.forEach(g=>{p.find(f=>f.resourceId===g.clientDocumentId&&f.type===Fo.DOCUMENT&&f.organizationId===a&&f.userId===c)&&(t.push({userId:c,resourceId:g.clientDocumentId,organizationId:a,type:Fo.DOCUMENT,hasAccess:!1}),p=p.filter(f=>!(f.resourceId===g.clientDocumentId&&f.type===Fo.DOCUMENT&&f.organizationId===a&&f.userId===c)))}),s&&p.find(g=>g.resourceId===s&&g.type===Fo.FOLDER&&g.organizationId===a&&g.userId===c)&&(t.push({userId:c,resourceId:s,organizationId:a,type:Fo.FOLDER,hasAccess:!1}),p=p.filter(g=>!(g.resourceId===s&&g.type===Fo.FOLDER&&g.organizationId===a&&g.userId===c))),a&&this.isRevokeOrganizationAccessOnDocumentUnsetEnabled&&p.find(g=>g.resourceId===a&&g.type===Fo.ORGANIZATION&&g.organizationId===a&&g.userId===c)&&(t.push({userId:c,resourceId:a,organizationId:a,type:Fo.ORGANIZATION,hasAccess:!1}),p=p.filter(g=>!(g.resourceId===a&&g.type===Fo.ORGANIZATION&&g.organizationId===a&&g.userId===c))),this.setPermissionsCache(p),t.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_FORMED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:t}}),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_TRIGGERED,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{requests:t}});let g=yield this.revokeAccess({requests:t,userId:c});g.success?this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_RESULT,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:g,success:!0,statusCode:200}}}):this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{result:{data:g,success:!1,statusCode:500}}})}}}catch(t){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR,timestamp:new Date().getTime(),uniqueId:e,methodName:Gi.REVOKE_ACCESS_ON_DOCUMENT_UNSET,source:"internal",payload:{error:t}}),this.loggingService.catch("Error in UsersPermissionService revokeAccessOnDocumentUnset:",t)}})}getAccess(r){return Q(this,arguments,function*({requests:e,userId:t}){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield hd({methodName:"getAccess",data:{type:"getAccess",data:e,metadata:{retryConfig:this.getPermissionProviderRetryConfig()}},getSdkProxy:a,userId:t})})}revokeAccess(r){return Q(this,arguments,function*({requests:e,userId:t}){let a=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield hd({methodName:"revokeAccess",data:{type:"revokeAccess",data:e,metadata:{retryConfig:this.getPermissionProviderRetryConfig()}},getSdkProxy:a,userId:t})})}onResourceAccessRequired(c){return Q(this,arguments,function*({requests:e,uniqueId:t,methodName:r,userId:a,fromCache:s=!0}){try{if(!e?.length)return;let p=[],g=this.getPermissionsCache()??[];if(!this.forceRefreshPermissions()&&s&&(e.forEach(f=>{let I=g?.find(T=>T.resourceId===f.resource.id&&T.type===f.resource.type&&T.userId===f.userId&&T.organizationId===f.resource.organizationId);I&&p.push(I)}),p.length>0&&(e=e.filter(f=>!p.find(I=>I.resourceId===f.resource.id&&I.type===f.resource.type&&I.userId===f.userId&&I.organizationId===f.resource.organizationId)))),e.length>0){this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:t,methodName:r,source:"internal",payload:{requests:e,fromCache:s}});let f=yield this.getAccess({requests:e,userId:this.authService.getUser()?.userId??a??""});return this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_RESULT,timestamp:new Date().getTime(),uniqueId:t,methodName:r,source:"internal",payload:{result:f}}),f?.success&&f?.data?.length&&(this.setPermissionsCache([...g,...f.data]),f.data=[...p,...f.data]),f}else if(p.length>0)return this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_RESULT_FROM_CACHE,timestamp:new Date().getTime(),methodName:r,source:"internal",uniqueId:t,payload:{results:{data:p,success:!0,statusCode:200}}}),{data:p,success:!0,statusCode:200};return}catch(p){this.loggingService.catch("Error in UsersPermissionService onResourceAccessRequired:",p),this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_ERROR,timestamp:new Date().getTime(),methodName:r,source:"internal",uniqueId:t,payload:{error:p,requests:e,fromCache:s}});return}})}getPermissionsCache(){return this.forceRefreshPermissions()?[]:this.permissionsCache$.getValue()}forceRefreshPermissions(){return this.getPermissionProvider()?.forceRefresh??!1}setPermissionsCache(e){try{let t=new Map;e.forEach(a=>{let s=`${a.userId}_${a.resourceId}_${a.organizationId}_${a.type}`;t.set(s,a)});let r=JSON.parse(JSON.stringify(Array.from(t.values())));this.permissionsCache$.next(r)}catch(t){this.loggingService.catch("Error in UsersPermissionService setPermissionsCache:",t)}}isPermissionProviderAvailable(){try{return!!this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService isPermissionProviderAvailable:",e),!1}}getPermissionProvider(){try{return this.permissionProvider$.getValue()}catch(e){return this.loggingService.catch("Error in UsersPermissionService getPermissionProvider:",e),null}}getPermissionProvider$(){return this.permissionProvider$.asObservable()}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(ot),ee(_),ee(un),ee(Ln),ee(ru),ee(ni),ee(Do),ee(Ft),ee(Si))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var hn=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye){this.afAuth=e,this.analyticsService=t,this.authService=r,this.configService=a,this.commonDbService=s,this.commonDbUtilsService=c,this.commentUtilsService=p,this.commentAnnotationsResolverService=g,this.databaseService=f,this.docService=I,this.domService=T,this.iamService=B,this.loggingService=z,this.notificationUtilsService=G,this.usersService=J,this.functions=ne,this.userPermissionService=ve,this.coreActionsService=ye,this.db=Is(),this.notificationsDb=Is(void 0,wn.firebaseNotificationsDatabaseURL),this.documentPaths=null,this.notifications$=new Ce([]),this.rawNotificationsByIdMap$=new Ce(new Map),this.processedNotifications$=new Ce([]),this.userNotificationsFromServer$=new Ce(null),this.readNotificationsOnForYouTab$=new Ce(!1),this.currentDocumentOnly$=new Ce(!1),this.notificationViews$=new Ce({}),this.notificationsByIdMap$=new Ce(new Map),this.historyPanelVisible$=new Ce(!1),this.notificationsForYou$=new Ce(null),this.notificationsByDocumentIdMap$=new Ce(null),this.notificationsByDocumentIdSubscription={},this.allowedDocumentMetadataMap$=new Ce(null),this.maxNotificationDays$=new Ce(15),this.tabConfig$=new Ce({people:{enable:!1}}),this.settingsConfig$=new Ce(null),this.muteAllNotifications$=new Ce(!1),this.enableSettings$=new Ce(!1),this.selfNotifications$=new Ce(!1),this.settingsInitialConfig$=new Ce([{name:"Inbox",id:"inbox",default:"ALL",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]},{name:"Email",id:"email",default:"MINE",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]}]),this.notificationsPanelVisible$=new Ce(!1);try{this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(Le(Ne=>!!Ne),rt(1)).subscribe(Ne=>{Ne&&(this.db=Ne,this.getDocumentIds(),this.subscribeGetNotificationsForYou())},Ne=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",Ne)}),this.authService.getUser$().subscribe(Ne=>{Ne?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(Ve=>{this.notificationsByDocumentIdSubscription[Ve]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),this.docService.getLocationMetadata$().subscribe(Ne=>{if(Ne){let Ve=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(Ne||{}).forEach(Ie=>{let be=Ve?.[Ie]?.notifications;be?.length&&be.forEach(Ae=>{this.notificationUtilsService.mergeLocationWithNotification({notification:Ae},Ne)?.notification})}),this.notificationsByDocumentIdMap$.next(Ve)}})}catch(Ne){this.loggingService.catch("Error in NotificationService constructor: ",Ne)}}setDBConfigDataToInitialConfig(e){try{let t=JSON.parse(JSON.stringify(this.settingsConfig$.getValue()??{}));Object.entries(e||{}).forEach(([r,a])=>{t[r]=a}),this.settingsConfig$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService setDBConfigDataToInitialConfig: ",t)}}getInitialConfigFromDB(e){return Q(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: getInitialConfigFromDB","color: green;");let t=Tt(this.authService.getUser()?.userId??""),r=yield this.commonDbService.getData({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?.documentId,userId:t}});if(r?.notificationsConfig)this.setDBConfigDataToInitialConfig(r?.notificationsConfig);else{this.setSettingsInitialConfig(this.settingsInitialConfig$.getValue());let a={};this.settingsInitialConfig$.getValue().forEach(c=>{if(c.enable){let p=c?.values?.find(g=>g.id===c.default);a[c.id]=p||c?.values?.[0]||{id:"NONE",name:"None"}}});let s={};Object.keys(a).forEach(c=>{s[c]=a[c].id}),yield this.updateSettingsConfigToDb(s)}}catch(t){this.loggingService.catch("Error in NotificationService getInitialConfigFromDB: ",t)}})}subscribeToUserSettings(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: subscribeToUserSettings","color: green;"),this.userSettingsSubscription&&this.userSettingsSubscription.unsubscribe();let e=Tt(this.authService.getUser()?.userId??"");this.userSettingsSubscription=this.enableSettings$.pipe(Le(t=>t===!0),he(()=>this.docService.getDocumentPaths$().pipe(Le(t=>!!t),he(t=>no(this.getInitialConfigFromDB(t)).pipe(he(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:t?.documentId,userId:e}}).pipe(de(r=>{r?.data?.notificationsConfig&&!hi(r?.data?.notificationsConfig??{},this.settingsConfig$.getValue()??{})&&this.setDBConfigDataToInitialConfig(r?.data?.notificationsConfig)})))))))).subscribe()}catch(e){this.loggingService.catch("Error in NotificationService subscribeToUserSettings: ",e)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: resetCacheData","color: green;"),this.setUserNotificationsFromServer(null),this.notificationsByDocumentIdMap$.next(null),this.notificationsForYou$.next(null),this.settingsConfig$.next(null)}catch(e){this.loggingService.catch("Error in NotificationService resetCacheData: ",e)}}subscribeGetNotificationsForYou(){try{this.notificationForYouSubscription&&this.notificationForYouSubscription.unsubscribe(),this.notificationForYouSubscription=this.getNotificationsForYou().subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getNotificationsForYou subscription: ",e)})}catch(e){this.loggingService.catch("Error in NotificationService subscriveGetNotificationsForYou: ",e)}}setCommentService(e){try{this.commentService=e}catch(t){this.loggingService.catch("Error in NotificationService setCommentService: ",t)}}getDocumentIds(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe(),this.documentIdsSubscription=this.selfNotifications$.pipe(he(()=>this.getCurrentDocumentOnly$().pipe(he(e=>e?this.docService.getDocumentPaths$().pipe(de(t=>{})):le(void 0)))),Qt(()=>{this.notificationsByDocumentIdMap$.next(null)}),he(()=>this.getDocumentIdsByLastNotificationTimestamp().pipe(Oi(),de(([e,t])=>{let r=e?.map(g=>g.documentId),a=t?.map(g=>g.documentId),s=r?.filter(g=>!a?.includes(g)),c=a?.map(g=>({documentId:g,timestamp:t?.find(f=>f.documentId===g)?.timestamp})).filter(g=>!r?.includes(g.documentId)),p=a?.map(g=>{let f=t?.find(I=>I.documentId===g)?.timestamp;return{documentId:g,timestamp:f}}).filter(g=>{let f=e?.find(I=>I.documentId===g.documentId)?.timestamp;return f&&g.timestamp&&f!==g.timestamp});c?.length&&this.fetchNotificationsForDocumentIds(c),p?.length&&this.fetchNotificationsForDocumentIds(p,1),s?.forEach(g=>{this.removeNotificationsForDocumentId(g)}),t&&!t?.length&&!this.notificationsByDocumentIdMap$.getValue()&&this.notificationsByDocumentIdMap$.next(null)})))).subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",e)})}catch(e){this.loggingService.catch("Error in NotificationService getDocumentIds: ",e)}}getDocumentIdsByLastNotificationTimestamp(e=15){try{return this.authService.getUser$().pipe(he(t=>this.docService.getOrganizationConfig$().pipe(de(r=>{let a=null,s=this.configService.getApiKey(),c=r?.organizationId||t?.organizationId;return s&&c&&(a=new Sm({apiKey:s,organizationId:c})),{user:t,documentPaths:a}}))),he(t=>{let{user:r,documentPaths:a}=t;if(this.getCurrentDocumentOnly()&&!this.docService?.getDocumentPaths()?.documentId)return le(null);if(r&&a?.organizationNotificationsLastNotificationTimestamp){let s=new Date,c=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;s.setDate(s.getDate()-c);let p=s.getTime(),g=[li(lt("timestamp",">=",p),...this.getCurrentDocumentOnly()&&this.docService.getDocumentPaths()?.documentId?[lt("metadata.documentId","==",this.docService.getDocumentPaths()?.documentId)]:[])];return this.getCurrentDocumentOnly()||(g.push(eo("timestamp","desc")),g.push(_m(e))),this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:a?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:g}}).pipe(de(f=>f?.data),de(f=>{let I=[];return Object.keys(f||{}).forEach(T=>{let B=this.commonDbService.shouldUseFirestore()?f[T]?.timestamp??0:f[T],z=this.commonDbService.shouldUseFirestore()?f[T]?.deletedNotification??!1:!1;if(z&&z.id&&z?.timestamp===B){let G=z.id,J=f[T]?.metadata?.documentId,ne=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),ve=ne?.[J]??{documentMetadata:null,notifications:[]},ye=ve.notifications??[],Ne=ye?.findIndex(Ve=>Ve.id===G);Ne!==-1&&(ye.splice(Ne,1),this.notificationsByDocumentIdMap$.next(D(E({},ne),{[J]:D(E({},ve),{notifications:ye})})))}I.push({documentId:T,timestamp:B})}),I}),Un(f=>(this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",f),le([]))))}return le(null)}))}catch(t){return this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",t),le([])}}fetchNotificationsForDocumentIds(e,t=15){return Q(this,null,function*(){try{if(e?.length){let r=Qi(this.functions,Ji({url:wn.cloudFunction.getNotificationsForDocuments,apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),a=this.docService.getOrganizationConfig()?.organizationId??"";if(!a)return[];let s=this.getStartAtTimestamp(),c={};if(e.forEach(ye=>{if(ye?.documentId){let Ne=this.getAllowedDocumentMetadataByDocumentId(ye.documentId);Ne&&(c[ye.documentId]=Ne)}}),this.userPermissionService?.isPermissionProviderAvailable())try{let ye=[];if(e.forEach(Ae=>{this.docService.getDocumentMetadata(Ae.documentId)||ye.push(Ae.documentId)}),ye.length){let Ae=this.authService.getUser(),_e=Qi(this.functions,Ji({url:wn?.cloudFunction?.sdkProxy,apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let fe=yield hd({methodName:"getDocumentMetadataFromIds",data:{type:"getDocumentMetadataFromIds",metadata:{organizationId:Ae?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:ye},getSdkProxy:_e,userId:Ae?.userId??""});if(fe?.data?.length){let Oe={};fe.data.forEach(Fe=>{Fe?.documentId&&(Oe[Fe.documentId]=Fe)}),this.docService.setAllDocumentMetadata(E(E({},this.docService.getAllDocumentMetadataMap()),Oe))}}catch(fe){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",fe)}}let Ne=[],Ve=[];e.forEach(Ae=>{let _e=this.docService.getDocumentMetadata(Ae.documentId);_e?.clientDocumentId?Ne.push({userId:this.authService.getUser()?.userId??"",resource:{id:_e.clientDocumentId,type:Fo.DOCUMENT,source:Gi.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""}}):Ve.push(Ae.documentId)}),Ve.length&&(e=e.filter(Ae=>!Ve.includes(Ae.documentId)));let Ie=vt();this.coreActionsService.triggerAction(mt.PERMISSION_PROVIDER,{event:Y.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:Ie,methodName:Gi.GET_NOTIFICATIONS,source:"internal",payload:{requests:Ne}});let be=yield this.userPermissionService?.onResourceAccessRequired({requests:Ne,uniqueId:Ie,methodName:Gi.GET_NOTIFICATIONS});be?.success&&be?.data?.length?be.data.forEach(Ae=>{!Ae.hasAccess&&Ae.resourceId&&(e=e.filter(_e=>_e.documentId!==Tr(Ae.resourceId)))}):e=[]}catch(ye){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",ye),e=[]}if(!e.length)return[];let p=this.userPermissionService?.getPermissionsCache()?.filter(ye=>ye.type===Fo.CONTEXT),g={organizationId:a,documentIds:e.filter(ye=>!!ye.documentId&&!!ye.timestamp).map(ye=>({documentId:ye.documentId,timestamp:ye.timestamp??0})),timestamp:s,limitToLast:t,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:p,retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},f=yield this.notificationUtilsService.handleNotificationEncryption({data:g}),I=yield r({veltData:f}),T=I?.data?.data?.veltData||{},B=I?.data?.data?.veltAdditionalData||{},z="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),G=yield X0(T,z),{userNotifications:J=[],userNotificationIdsInDocNotifications:ne=[],permissionResults:ve=[]}=yield X0(B,z);if(this.userPermissionService?.getIsContextEnabled()){let ye=[...this.userPermissionService?.getPermissionsCache()??[],...ve??[]];this.userPermissionService?.setPermissionsCache(ye)}if(G&&typeof G=="object"){let ye=this.usersService.userDataProviderAvailable(),Ne=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),Ve=[],Ie=[];Object.keys(G).forEach((be,Ae)=>{let _e=G[be].documentMetadata;if(_e){let Oe=this.allowedDocumentMetadataMap$.value||{};(!Oe?.[be]||!hi(Oe?.[be],_e))&&this.allowedDocumentMetadataMap$.next(D(E({},Oe),{[be]:_e}))}let fe=G[be].notifications||[];fe.forEach(Oe=>{ne.includes(Oe.notificationId)&&!J.find(Fe=>Fe.notificationId===Oe.notificationId)&&J.push(JSON.parse(JSON.stringify(Oe))),Oe.notification=this.getClientNotificationObject(Oe)}),this.setNotificationForDocumentIdInCache(be,_e,fe),ye&&(Ve.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:fe,shouldAwait:!0,forceResolve:!0})),Ve.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:J,shouldAwait:!0,forceResolve:!0}))),Ne&&(Ie.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:fe,shouldCommentAnnotationsResolverAwait:!0})),Ie.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:J,shouldCommentAnnotationsResolverAwait:!0})))}),this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...J]),ye&&Promise.all(Ve).then(()=>{Object.keys(G).forEach(be=>{let Ae=G?.[be]?.documentMetadata||{},_e=this.commonDbUtilsService.mergeUsersWithData({feature:"allDocNotifications",data:G?.[be]?.notifications||[]});_e.forEach(fe=>{fe.notification=this.getClientNotificationObject(fe)}),this.setNotificationForDocumentIdInCache(be,Ae,_e)})}),Ne&&Promise.all(Ie).then(()=>{Object.keys(G).forEach(be=>{let Ae=G?.[be]?.documentMetadata||{},_e=G?.[be]?.notifications?.reduce((fe,Oe)=>(fe[Oe.notificationId]=Oe,fe),{});_e=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allDocNotifications",data:_e}),_e=Object.values(_e??{}),_e.forEach(fe=>{fe.notification=this.getClientNotificationObject(fe)}),this.setNotificationForDocumentIdInCache(be,Ae,_e)})})}}}catch(r){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",r),[]}})}getUserNotificationsFromServer$(){return this.userNotificationsFromServer$.asObservable()}setUserNotificationsFromServer(e){try{let t=JSON.parse(JSON.stringify(e));t=t?.filter((r,a,s)=>a===s.findIndex(c=>c.notificationId===r.notificationId)),this.userNotificationsFromServer$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService setUserNotificationsFromServer: ",t)}}getUserNotificationsFromServer(){return this.userNotificationsFromServer$.getValue()}setNotificationForDocumentIdInCache(e,t,r,a){try{let s=this.docService.getOrganizationConfig()?.organizationId??"",c=this.docService.getOrganizationMetadata(s);t||(t=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),c||(c=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(s)||{})));let p=this.notificationsByDocumentIdMap$.getValue(),g=p?.[e]?.notifications||[],f=this.docService.getLocationMetadatas(),I=r?.map(z=>{let G=z?.notification;return G?(G.metadata&&(G.metadata.documentName=t?.documentName||G.metadata.documentName,G.metadata.organizationMetadata=c||G.metadata.organizationMetadata,G.metadata.documentMetadata=t||G.metadata.documentMetadata),f&&(G=this.notificationUtilsService.mergeLocationWithNotification({notification:G},f)?.notification),G):null})?.filter(z=>!!z)||[],T=new Map(g.map(z=>[z.id,z]));I.forEach(z=>{T.set(z.id,z)});let B=Array.from(T.values()).sort((z,G)=>(G.timestamp||0)-(z.timestamp||0));this.notificationsByDocumentIdMap$.next(D(E({},p),{[e]:{notifications:B,documentMetadata:t}}))}catch(s){this.loggingService.catch("Error in NotificationService setNotificationForDocumentIdInCache: ",s)}}removeNotificationsForDocumentId(e){try{this.notificationsByDocumentIdSubscription[e]&&this.notificationsByDocumentIdSubscription[e].unsubscribe();let t=this.notificationsByDocumentIdMap$.getValue();delete t?.[e],this.notificationsByDocumentIdMap$.next(t)}catch(t){this.loggingService.catch("Error in NotificationService removeNotificationsForDocumentId: ",t)}}getStartAtTimestamp(){try{let e=new Date,t=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;return e.setDate(e.getDate()-t),e.getTime()}catch(e){return this.loggingService.catch("Error in NotificationService getStartAtTimestamp: ",e),0}}getNotificationsForYou(){try{return this.getUserNotificationsFromServer$().pipe(he(e=>le(e).pipe(Le(t=>!!t),de(t=>{let r=this.usersService.userDataProviderAvailable(),a=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable();if(r||a){let c=t?.reduce((p,g)=>(p[g.notificationId]=g,p),{});r&&(c=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:c||[]})),a&&(c=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:c||[]})),t=Object.values(c??{})}return t.forEach(c=>{c.notification=this.getClientNotificationObject(c)}),t.sort((c,p)=>p.timestamp-c.timestamp),t.map(c=>c.notification).filter(c=>!!c)}),he(t=>{let r={data:t?.reduce((a,s)=>(a[s.id]={notification:s},a),{}),operation:null};return this.commonDbUtilsService.mergeLocationMetadataWithData$({data:r,feature:"allUserNotifications"}).pipe(de(a=>Object.values(a?.data||{}).map(s=>s?.notification)))}))),he(e=>{let t=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(t).pipe(de(()=>e))}),he(e=>this.allowedDocumentMetadataMap$.pipe(de(()=>e))),de(e=>(e?.length&&(e=e.map(t=>{if(t?.metadata){let r=this.docService.getOrganizationConfig()?.organizationId??"",a=this.getAllowedDocumentMetadataByDocumentId(t.metadata.documentId),s=this.docService.getOrganizationMetadata(r);a||(a=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),s||(s=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(r)||{}))),t.metadata.documentName=a?.documentName||t.metadata.documentName,t.metadata.organizationMetadata=s||t.metadata.organizationMetadata,t.metadata.documentMetadata=a||t.metadata.documentMetadata}return t})),e===null?this.notificationsForYou$.next(null):e?.length?this.notificationsForYou$.next(JSON.parse(JSON.stringify(e))):this.notificationsForYou$.next([]),le(e))))}catch(e){return this.loggingService.catch("Error in NotificationService getNotificationsForYou: ",e),le({})}}subscribeNotificationsData(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let r,a;try{if(e&&(a=Nn(e)),t&&typeof t=="object"){let s=or(t);r=Nn(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return ei(this.afAuth).pipe(Le(s=>!!s),he(s=>this.isFeatureAllowed({firebaseUser:s})),he(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(de(c=>(s.featureAllowed=c,s))):le(s)),he(s=>!s.featureAllowed||s?.user?.organizationId?(this.notifications$.next([]),this.rawNotificationsByIdMap$.next(new Map),this.processedNotifications$.next([]),this.notificationsByIdMap$.next(new Map),this.notificationViews$.next({}),this.setNotificationsByIdMap(),le([])):le(s).pipe(he(c=>this.docService.getDocumentPaths$().pipe(de(p=>(this.documentPaths=p,c.documentPaths=p,c)))),he(c=>this.getDataFromDocumentId(a)))))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Le(t=>!!t),de(t=>D(E({},e),{config:t})),he(t=>this.authService.getUser$().pipe(de(r=>D(E({},t),{user:r})))),he(t=>ro(t.config,t.user,Re.NOTIFICATION)?le(D(E({},t),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),le(D(E({},t),{featureAllowed:!1})))))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Le(t=>!!t),he(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.views){let r=`${this.configService.getApiKey()}`;this.documentPaths?.organizationId&&(r+=`/${U.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let a=Ti(this.db,`${e?r+"/"+U.FIREBASE_PARTIAL_PATH_DOCS+"/"+e+"/"+U.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return PM(a).pipe(Un(s=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",s),le(null))),de(s=>{let c=[],p=new Map;s?.raw&&(Object.keys(s?.raw||{}).forEach(f=>{let I=s?.raw[f];I?.id&&c.push(I)}),c.forEach(f=>{f.id&&p.set(f.id,f)})),this.notifications$.next(c),this.rawNotificationsByIdMap$.next(p);let g=[];s?.processed&&Object.keys(s?.processed||{}).forEach(f=>{let I=s?.processed[f];I?.id&&g.push(I)}),this.processedNotifications$.next(g),this.setNotificationsByIdMap()}))}else return le(null)}))}setNotificationsByIdMap(){try{let e=this.authService.getUser();if(e){let t=this.notificationViews$.getValue(),r;e?.email&&(r=Tt(e?.email));let a;e?.userId&&(a=Tt(e?.userId));let s=new Map;this.processedNotifications$.getValue().forEach(p=>{if(p.id&&p?.displayHeadlineMessageTemplate){let g=!1;(r&&p.notifyUsers?.[r]||a&&p.notifyUsers?.[a])&&(g=!0);let f={id:p.id,notificationSource:p.notificationSource,actionType:p.actionType,actionUser:p.actionUser,timestamp:p.timestamp,targetAnnotationId:p.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(p),displayBodyMessage:this.getNotificationBodyMessage(p),forYou:g,notificationSourceData:p.notificationSourceData},I=this.getRawNotificationById(f.id);if(I?.metadata&&(f.metadata={apiKey:I.metadata.apiKey,organizationId:I.metadata.organizationId,clientOrganizationId:I.metadata.clientOrganizationId,documentId:I.metadata.documentId,clientDocumentId:I.metadata.clientDocumentId,location:I?.location,locationId:I?.locationId}),f?.notificationSource==="comment"&&f?.targetAnnotationId){let T=this.commentService?.getAnnotationById(f.targetAnnotationId);T||I?.annotationData&&(T=I.annotationData),T&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(T))}s.set(p.id,f)}}),s.forEach((p,g)=>{p.isUnread=p?.actionUser?.userSnippylyId!==e?.userSnippylyId&&!t?.notification?.[g]?.views?.[e?.userSnippylyId],s.set(g,p)}),this.notificationsByIdMap$.next(s)}}catch(e){this.loggingService.catch("Error in NotificationService setNotificationsByIdMap: ",e)}}getClientNotificationObject({processed:e,raw:t,metadata:r,views:a,notification:s}){try{let c=this.authService.getUser(),p=s||e;if(p.id&&p?.displayHeadlineMessageTemplate&&c){let g=null;c?.email&&(g=Tt(c?.email));let f=null;c?.userId&&(f=Tt(c?.userId));let I=!1,T=!0;(g&&p.notifyUsers?.[g]||f&&p.notifyUsersByUserId?.[f])&&(I=!0),f&&a?.[f]&&(T=!1);let B={id:p.id};if(s?B=D(E(E({},B),s),{displayHeadlineMessage:this.getNotificationHeadlineMessage(s),displayBodyMessage:this.getNotificationBodyMessage(s),forYou:I,isUnread:T}):B={id:e.id,notificationSource:e.notificationSource,actionType:e.actionType,actionUser:e.actionUser,timestamp:e.timestamp,targetAnnotationId:e.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(e),displayBodyMessage:this.getNotificationBodyMessage(e),forYou:I,isUnread:T,metadata:r},B?.notificationSource==="comment"&&B?.targetAnnotationId){let z=this.commentService?.getAnnotationById(B.targetAnnotationId);z||s?.notificationSourceData&&(z=s?.notificationSourceData),z||t?.annotationData&&(z=t.annotationData),z&&(B.notificationSourceData=this.commentService?.getCommentAnnotationForClient(z))}return t?.targetAnnotationData?.isCommentResolverUsed&&(B.isCommentResolverUsed=t?.targetAnnotationData?.isCommentResolverUsed),B}return}catch(c){this.loggingService.catch("Error in NotificationService getClientNotificationObject: ",c);return}}getNotificationsForYou$(){return this.notificationsForYou$.asObservable()}getNotificationsByDocumentId$(){return this.notificationsByDocumentIdMap$.asObservable().pipe(de(e=>e?Object.keys(e??{}).map(t=>{let r=e[t].notifications||[],a=r.filter(c=>c.isUnread).length,s=r.length>0&&r[0]?.timestamp||0;return{documentId:t,notifications:e[t]?.notifications,unreadNotificationsCount:a,latestNotificationTimestamp:s,documentMetadata:e[t]?.documentMetadata}}).filter(t=>t.notifications?.length>0).sort((t,r)=>r.latestNotificationTimestamp-t.latestNotificationTimestamp):null))}getAllNotifications$(){return this.getNotificationsByDocumentId$().pipe(de(e=>{let t=null;return e?(t=[],e.forEach(r=>{r.notifications.forEach(a=>{t?.push(a)})}),t?.sort((r,a)=>a.timestamp-r.timestamp)):null}))}processNotificationData(e){try{let t=e?.annotationData?.metadata,r=this.docService.getOrganizationConfig()?.organizationId;e.metadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(t?.documentId)||{})),e.metadata||(e.metadata={},this.loggingService.catch("Warning in NotificationService updateNotificationDatabase: ","Document metadata not found")),delete e.metadata.locations,e.metadata.documentMetadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(t?.documentId)||{})),e?.metadata?.documentMetadata?.clientDocumentId&&e?.metadata?.documentMetadata?.documentId&&(e.metadata.documentMetadata.documentId=e?.metadata?.documentMetadata?.clientDocumentId),delete e.metadata.documentMetadata.locations,e.metadata.organizationMetadata=JSON.parse(JSON.stringify(r?this.docService.getOrganizationMetadata(r)||{}:{})),e?.metadata?.organizationMetadata?.clientOrganizationId&&e?.metadata?.organizationMetadata?.organizationId&&(e.metadata.organizationMetadata.organizationId=e?.metadata?.organizationMetadata?.clientOrganizationId);let a=this.configService.getApiKey();e.metadata.apiKey=a,e.platform=this.configService.getSF()?"sf":"sdk",e.actionUser=this.authService.getUser();let s=t?.documentId?new Sm({apiKey:a,documentId:t.documentId,organizationId:t?.organizationId}):this.docService.getDocumentPaths();e?.actionUser?.organizationId&&(e.metadata.organizationId=s?.organizationId||e.actionUser.organizationId,e.metadata.clientOrganizationId=s?.clientOrganizationId||e.actionUser.clientOrganizationId);let c=this.docService.getLocation();c&&(e.location=c?.location,e.locationId=c?.locationId),this.loggingService.log(`[NOTIFICATION] ${e?.notificationSource} ${e?.actionType}`,e);let p=this.commonDbService.getServerTimestamp(),g=this.notificationUtilsService.formatNotification(e,p);return JSON.parse(JSON.stringify(g))}catch(t){return this.loggingService.catch("Error in NotificationService processNotificationData: ",t),null}}updateNotificationDatabase(e){try{let t=Ti(this.notificationsDb),r=this.processNotificationData(e);SM(t,JSON.parse(JSON.stringify(r)))}catch(t){this.loggingService.catch("Error in NotificationService updateNotificationDatabase: ",t)}}getRawNotifications$(){return this.notifications$.asObservable()}getProcessedNotifications$(){return this.processedNotifications$.asObservable()}getNotifications$(e){return this.authService.getUser$().pipe(he(t=>t?t.organizationId?this.getAllNotifications$().pipe(he(r=>this.notificationsForYou$.pipe(de(a=>{if(r||a){let s=new Map;return(!e?.type||["all","documents"].includes(e.type))&&(r||[]).forEach(c=>{c.id&&s.set(c.id,c)}),(!e?.type||["all","forYou"].includes(e.type))&&(a||[]).forEach(c=>{c.id&&!s.has(c.id)&&s.set(c.id,c)}),Array.from(s.values()).sort((c,p)=>(p.timestamp||0)-(c.timestamp||0))}else return null})))):this.notificationsByIdMap$.asObservable().pipe(de(r=>Array.from(r.values())),de(r=>r.sort((a,s)=>s.timestamp-a.timestamp)),Ku()):le(null)),Ct(Xt))}getRawNotificationById(e){try{return this.rawNotificationsByIdMap$.getValue()?.get(e)}catch(t){this.loggingService.catch("Error in NotificationService getRawNotificationById: ",t);return}}setNotificationViews(e){try{this.notificationViews$.next(e),this.setNotificationsByIdMap()}catch(t){this.loggingService.catch("Error in NotificationService setNotificationViews: ",t)}}getNotificationHeadlineMessage(e){try{let t=this.authService.getUser();if(e?.displayHeadlineMessageTemplate&&e?.displayHeadlineMessageTemplateData){let r=e.displayHeadlineMessageTemplate,a=e.displayHeadlineMessageTemplateData,s=/\{(\w+)\}/g,c=r.replace(s,(p,g)=>(g==="actionUser"||g==="recipientUser")&&a[g]?t?.email&&a[g].email===t?.email||t?.userId&&a[g]?.userId===t?.userId?"You":a[g].name||a[g].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':a[g]?a[g]:p);return this.domService.sanitizeHtml(c)}return this.domService.sanitizeHtml(e.displayHeadlineMessageTemplate||"")}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationHeadlineMessage: ",t),""}}getNotificationBodyMessage(e){try{if(e?.displayBodyMessageTemplate&&e?.displayBodyMessageTemplateData){let t=e?.displayBodyMessageTemplate;return e?.displayBodyMessageTemplateData&&e?.displayBodyMessageTemplateData?.users?.forEach(r=>{if(r?.userId){let a=this.usersService.getUserById(r?.userId);t=t?.replaceAll(`{{${r.userId}}}`,a?.name||a?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>'),t=t?.replaceAll(`@User ${r.userId}`,a?.name||a?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>')}}),this.domService.sanitizeHtml(t)}return this.domService.sanitizeHtml(e.displayBodyMessage||"")}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationBodyMessage: ",t),""}}setHistoryPanelVisibility(e,t=!1,r=!1){try{e?document.querySelector(U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(e):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(e),e?this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}toggleHistoryPanelVisibility(e=!1,t=!1){try{this.historyPanelVisible$.value?this.historyPanelVisible$.next(!this.historyPanelVisible$.value):document.querySelector(U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(Y.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${U.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(e){return Q(this,null,function*(){try{let t=JSON.parse(JSON.stringify(this.getUserNotificationsFromServer()??[]));if(e?.length){for(let c=0;c<e.length;c+=50){let g=e.slice(c,c+50).filter(T=>T?.id),f=g.map(T=>this.setNotificationAsRead({notification:T,userNotifications:JSON.parse(JSON.stringify(t))})),I=yield Promise.all(f);g.forEach((T,B)=>{let z=I[B];if(!z.some(J=>J.notificationId===T.id))t=t.filter(J=>J.notificationId!==T.id);else{let J=t.find(ve=>ve.notificationId===T.id),ne=z.find(ve=>ve.notificationId===T.id);J&&ne?.views&&(J.views=ne.views)}})}let a=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));e.forEach(c=>{let p=c.metadata?.documentId;if(p&&a?.[p]){let g=a?.[p]?.notifications||[],f=g.find(I=>I.id===c.id);f&&(f.isUnread=!1),a[p].notifications=g}}),this.notificationsByDocumentIdMap$.next(a),!hi(t,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(t)}}catch(t){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",t)}})}setAllNotificationsAsRead(e){return Q(this,null,function*(){try{if(e?.tabId==="for-you"){let t=this.notificationsForYou$.value||[];this.setNotificationsAsRead(t)}else this.getNotifications$().pipe(rt(1)).subscribe(t=>{t&&this.setNotificationsAsRead(t)})}catch(t){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",t)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(de(e=>e?.filter(r=>r?.isUnread)?.length??null),he(e=>this.getNotifications$().pipe(de(t=>{let r=t?.filter(a=>a?.isUnread)?.length??null;return{forYou:e,all:r}}))))}catch(e){return this.loggingService.catch("Error in NotificationService getUnreadNotificationsCount$: ",e),le({forYou:null,all:null})}}setNotificationAsRead(r){return Q(this,arguments,function*({notification:e,userNotifications:t}){try{let a=this.authService.getUser();if(a&&e?.id){let s=Tt(a?.userId),{metadata:c}=e;if(c){let{apiKey:p,organizationId:g,documentId:f}=c;if(p&&g&&f&&s){let I=yield this.commonDbService.getData({feature:"docNotification",properties:{id:e.id,organizationId:g,documentId:f,apiKey:p}});I?.notificationId&&(I?.views?.[s]||(I.views||(I.views={}),I.views[s]={timestamp:Date.now()},this.commonDbService.updateData({feature:"docNotificationViews",properties:{id:e.id,organizationId:g,documentId:f,apiKey:p},data:I})));let T=yield this.commonDbService.getData({feature:"userNotification",properties:{id:e.id,userId:s,documentId:f,organizationId:g}});if(T?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:e.id,userId:s,documentId:f,organizationId:g}}),t=t.filter(B=>B.notificationId!==e.id);else if(!T?.views?.[s]){T.views||(T.views={}),T.views[s]={timestamp:Date.now()};let B=t.find(z=>z.notificationId===e.id);B&&(B.views=T.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:e.id,userId:s,documentId:f,organizationId:g},data:T})}}}}}return t}catch(a){return this.loggingService.catch("Error in NotificationService setNotificationAsRead: ",a),t}})}setMaxDays(e){try{e>0?this.maxNotificationDays$.next(e):this.maxNotificationDays$.next(15)}catch(t){this.loggingService.catch("Error in NotificationService setMaxDays: ",t)}}setTabConfig(e){try{e&&this.tabConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setTabConfig: ",t)}}getTabConfig$(){return this.tabConfig$.asObservable()}getTabConfig(){return this.tabConfig$.value}enableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!0)}disableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!1)}getReadNotificationsOnForYouTab$(){return this.readNotificationsOnForYouTab$.asObservable()}getReadNotificationsOnForYouTab(){return this.readNotificationsOnForYouTab$.value}enableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!0)return;this.currentDocumentOnly$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableCurrentDocumentOnly: ",e)}}disableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!1)return;this.currentDocumentOnly$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableCurrentDocumentOnly: ",e)}}getCurrentDocumentOnly$(){return this.currentDocumentOnly$.asObservable()}getCurrentDocumentOnly(){return this.currentDocumentOnly$.value}markNotificationAsReadById(e){return Q(this,null,function*(){try{this.getNotifications$().pipe(rt(1)).subscribe(t=>{if(t){let r=t.filter(a=>a.id===e);this.setNotificationsAsRead(r)}})}catch(t){this.loggingService.catch("Error in NotificationService markNotificationAsReadById: ",t)}})}getAllowedDocumentMetadataByDocumentId(e){try{return this.allowedDocumentMetadataMap$.value?.[e]||null}catch(t){return this.loggingService.catch("Error in NotificationService getAllowedDocumentMetadataByDocumentId: ",t),null}}setSettingsConfig(e){try{this.enableSettings$.value&&this.settingsConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsConfig: ",t)}}setSettingsConfigWithDB(e){try{this.enableSettings$.value&&(this.settingsConfig$.next(e),this.updateSettingsConfigToDb())}catch(t){this.loggingService.catch("Error in NotificationService setSettingsConfigWithDB: ",t)}}getSettingsConfig$(){return this.settingsConfig$.asObservable()}getSettingsConfig(){return this.settingsConfig$.value}setMuteAllNotifications(){try{this.muteAllNotifications$.value!==!0&&this.muteAllNotifications$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService setSettingsMuteAll: ",e)}}getMuteAllNotifications$(){return this.muteAllNotifications$.asObservable()}getMuteAllNotifications(){return this.muteAllNotifications$.value}enableSettings(){try{this.enableSettings$.value!==!0&&this.enableSettings$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableSettings: ",e)}}enableSelfNotifications(){try{this.selfNotifications$.value!==!0&&this.selfNotifications$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService enableSelfNotifications: ",e)}}disableSelfNotifications(){try{this.selfNotifications$.value!==!1&&this.selfNotifications$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableSelfNotifications: ",e)}}disableSettings(){try{this.enableSettings$.value!==!1&&this.enableSettings$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService disableSettings: ",e)}}getEnableSettings$(){return this.enableSettings$.asObservable()}getEnableSettings(){return this.enableSettings$.value}setSettingsInitialConfig(e){try{let t=!1;if(e.forEach(r=>{["email","inbox"].includes(r.id)&&(t=!r.values?.every(a=>["ALL","NONE","MINE"].includes(a.id)))}),t){this.loggingService.catch("Invalid config values for email or inbox, It should have only ALL, NONE, MINE values");return}this.settingsInitialConfig$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsInitialConfig: ",t)}}getSettingsInitialConfig$(){return this.settingsInitialConfig$.asObservable()}getSettingsInitialConfig(){return this.settingsInitialConfig$.value}updateSettingsConfigToDb(e){return Q(this,null,function*(){try{let t=Tt(this.authService.getUser()?.userId??""),r=this.docService.getDocumentPaths(),a={apiKey:this.configService.getApiKey(),organizationId:r?.organizationId,documentId:r?.documentId,clientOrganizationId:r?.clientOrganizationId,clientDocumentId:r?.clientDocumentId,userId:t,clientUserId:this.authService.getUser()?.userId};t&&r?.documentId&&this.getEnableSettings()&&this.enableSettings$.value&&(yield this.commonDbService.updateData({feature:"userConfig",properties:{documentId:r.documentId,userId:t},data:{id:r.documentId,notificationsConfig:e||this.settingsConfig$.getValue(),metadata:a}}))}catch(t){this.loggingService.catch("Error in NotificationService updateSettingsConfigToDb: ",t)}})}openNotificationsPanel(){try{this.notificationsPanelVisible$.next(!0)}catch(e){this.loggingService.catch("Error in NotificationService openNotificationsPanel: ",e)}}closeNotificationsPanel(){try{this.notificationsPanelVisible$.next(!1)}catch(e){this.loggingService.catch("Error in NotificationService closeNotificationsPanel: ",e)}}getNotificationsPanelVisible$(){return this.notificationsPanelVisible$.asObservable()}getNotificationsPanelVisible(){return this.notificationsPanelVisible$.value}};o.\u0275fac=function(t){return new(t||o)(ee(Ri),ee(Qe),ee(je),ee(Ft),ee(un),ee(Im),ee(ru),ee(nl),ee(In),ee(ot),ee(Be),ee(En),ee(_),ee(x9),ee(Ln),ee(Do),ee(ss),ee(ni))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Wo=(()=>{let o=class o{constructor(e){this.loggingService=e,this._customStatusMap=new Ce(U.CommentAnnotationStatusMap),this._customPriorityMap=new Ce(U.CommentAnnotationPriorityMap),this._customCategoryMap=new Ce(U.CommentCategoryMap);try{let t=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP);t&&this._customPriorityMap.next(JSON.parse(t));let r=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP);r&&this._customStatusMap.next(JSON.parse(r));let a=sessionStorage.getItem(U.SESSION_STORAGE.VELT_CUSTOM_CATEGORY_MAP);a&&this._customCategoryMap.next(JSON.parse(a))}catch(t){this.loggingService.catch("Error in CustomFilterService constructor: ",t)}}setCustomStatusFilters(e){try{if(e.length<2){this._customStatusMap.next(U.CommentAnnotationStatusMap),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP,JSON.stringify(U.CommentAnnotationStatusMap)),this.loggingService.catch("Custom status filters must have at least 2 filters");return}let t={};e.forEach(r=>{t[r.id]=r,r.type||(r.type="ongoing")}),this._customStatusMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_STATUS_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomStatusFilters: ",t)}}setCustomPriorityFilters(e){try{if(e.length<2){this._customPriorityMap.next(U.CommentAnnotationPriorityMap),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP,JSON.stringify(U.CommentAnnotationPriorityMap)),this.loggingService.catch("Custom priority filters must have at least 2 filters");return}let t={};e.forEach(r=>{t[r.id]=r}),this._customPriorityMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_PRIORITY_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomPriorityFilters: ",t)}}setCustomCategories(e){try{let t={};e.forEach(r=>{t[r.id]=r}),this._customCategoryMap.next(t),sessionStorage.setItem(U.SESSION_STORAGE.VELT_CUSTOM_CATEGORY_MAP,JSON.stringify(t))}catch(t){this.loggingService.catch("Error in CustomFilterService setCustomCategories: ",t)}}get customStatusMap$(){return this._customStatusMap.asObservable()}get customPriorityMap$(){return this._customPriorityMap.asObservable()}get customCategoryMap$(){return this._customCategoryMap.asObservable()}get defaultStatus(){try{let t=Object.entries(this._customStatusMap.value).find(([r,a])=>a.type==="default");if(t)return t[1]}catch(e){this.loggingService.catch("Error in CustomFilterService defaultStatus: ",e)}return U.CommentAnnotationStatusMap.OPEN}get resolvedStatus(){try{let t=Object.entries(this._customStatusMap.value).find(([r,a])=>a.type==="terminal");if(t)return t[1]}catch(e){this.loggingService.catch("Error in CustomFilterService resolvedStatus: ",e)}return U.CommentAnnotationStatusMap.OPEN}get ongoingStatuses(){try{let t=Object.entries(this._customStatusMap.value).filter(([r,a])=>a.type==="ongoing");if(t)return t.map(r=>r[1])}catch(e){this.loggingService.catch("Error in CustomFilterService ongoingStatuses: ",e)}return[U.CommentAnnotationStatusMap.IN_PROGRESS]}convertLegacyAnnotationStatus(e){try{if(typeof e.status=="string"||e.status===void 0){let t=Object.entries(this._customStatusMap.value),r=t.find(([a,s])=>s.type==="default");switch(e.status){case"open":r&&(e.status=r[1]);break;case"inProgress":let a=t.find(([c,p])=>p.type==="ongoing");a&&(e.status=a[1]);break;case"resolved":let s=t.find(([c,p])=>p.type==="terminal");s&&(e.status=s[1]);break;default:r&&(e.status=r[1]);break}}return e}catch(t){return this.loggingService.catch("Error in CustomFilterService convertLegacyAnnotation: ",t),e}}convertLegacyPriority(e){try{typeof e.priority=="string"&&(e.priority=U.CommentAnnotationPriorityMap[e.priority])}catch(t){this.loggingService.catch("Error in CustomFilterService convertLegacyPriority: ",t)}return e}convertLegacyCategory(e){try{if(e.commentCategories===void 0||e.commentCategories===null||!Array.isArray(e.commentCategories)||e.commentCategories.length===0)return e;typeof e.commentCategories[0]=="string"&&(e.commentCategories=e.commentCategories.map(t=>U.CommentCategoryMap[t]))}catch(t){this.loggingService.catch("Error in CustomFilterService convertLegacyCategory: ",t)}return e}};o.\u0275fac=function(t){return new(t||o)(ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Sd=(()=>{let o=class o{constructor(e,t,r){this.domService=e,this.loggingService=t,this.sanitizer=r,this.emojis={};try{this.loggingService.log("%c[WB] Creating CLASS: EmojiService","color: blue;"),Object.keys(o.Icons).forEach(a=>{let s=o.Icons[a];this.emojis[a]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeSvg(s))}),Object.keys(o.GIF_PATHS).forEach(a=>{let s=`<img src="${o.GIF_PATHS[a]}" alt="${a}" />`;this.emojis[a]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(s))})}catch(a){this.loggingService.catch("Error in EmojiService constructor: ",a)}}getEmoji(e){try{return this.emojis[e]}catch{return""}}getEmojiFromIconUrl(e){try{return this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(`<img src="${e}" alt="emoji" />`))}catch{return""}}getEmojiFromIconEmoji(e,t){try{let r=`<span class="velt-emoji-icon velt-emoji-icon--emoji">${e}</span>`;return t&&(r=`<span class="velt-emoji-icon velt-emoji-icon--emoji" emoji-id=${t}>${e}</span>`),this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(r))}catch{return""}}setEmojiList(e){try{this.emojis={},Object.keys(e).forEach(t=>{let r=e[t];if(r.svg)this.emojis[t]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeSvg(r.svg));else if(r.url){let a=`<img src="${r.url}" alt="${t}" />`;this.emojis[t]=this.sanitizer.bypassSecurityTrustHtml(this.domService.sanitizeHtml(a))}else r.emoji&&(this.emojis[t]=this.getEmojiFromIconEmoji(this.domService.sanitizeHtml(r.emoji)))})}catch(t){this.loggingService.catch("Error in EmojiService setEmojiList: ",t)}}};o.Icons={RAISED_HANDS:`<svg width="58" height="57" viewBox="0 0 58 57" fill="none" xmlns="http://www.w3.org/2000/svg">
208
208
  <path d="M35.8477 11.6603L40.4962 5.23427" stroke="#B0BEC5" stroke-width="1.92685" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
209
209
  <path d="M21.8298 11.617L17.4655 6.02428" stroke="#B0BEC5" stroke-width="1.92685" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
210
210
  <path d="M28.7568 9.77682L28.7761 1" stroke="#B0BEC5" stroke-width="1.92685" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
@@ -531,7 +531,7 @@ This typically indicates that your device does not have a healthy Internet conne
531
531
  `||e.editCommentTextArea?.nativeElement?.innerText&&e.editCommentTextArea.nativeElement.innerText!==`
532
532
  `,r=e.selectedAttachments?.length>0||e.attachmentsToDelete?.length>0,a=e.localRecordedData?.length>0||e.recorderInitConfig&&e.recorderInitConfig?.panelId===e.commentDialogUniqueId;return t||r||a}catch(e){return this.catchError("Error in CommentDialogComponent hasComposerContent: ",e),!1}}onPointerOutCommentDialog(e){try{this.componentConfigSignal().commentsContainer?.nativeElement?.contains(e?.relatedTarget)||this.pointerOutFromCommentDialog.next(e)}catch(t){this.catchError("Error in CommentDialogComponent onPointerOutCommentDialog: ",t)}}onPointerUp(){try{this.pointerUp.next()}catch(e){this.catchError("Error in CommentDialogComponent onPointerUp: ",e)}}onMoreRepliesClick(){try{this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_MORE_REPLY_OPTION_CLICKED,{annotationId:this.componentConfigSignal().annotation?.annotationId,commentType:this.commentService.getCommentType(this.componentConfigSignal().annotation),uiLocation:this.componentConfigSignal().sidebarMode?"sidebar":"dialog",commentMode:this.commentService.getCommentMode()}),this.componentConfigSignal.update(e=>(e=D(E({},e),{showAllComments:!e.showAllComments}),e))}catch(e){this.catchError("Error in CommentDialogComponent onMoreRepliesClick: ",e)}}checkCommentDialogSelected(){try{let e=this.componentConfigSignal().commentPinSelected,t=this.componentConfigSignal().fullExpanded,r=e||t;r!==this.componentConfigSignal().commentDialogSelected&&this.componentConfigSignal.update(a=>(a=D(E({},a),{commentDialogSelected:r}),a)),e||this.componentConfigSignal.update(a=>(a=D(E({},a),{showReplyComposer:!1}),a))}catch(e){this.catchError("Error in CommentDialogComponent checkCommentDialogSelected: ",e)}}checkIsKnownUser(){try{this.componentConfigSignal().user&&!this.componentConfigSignal().user?.isReadOnly&&!this.componentConfigSignal().user?.isAnonymous?this.componentConfigSignal.update(e=>(e=D(E({},e),{isKnownUser:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{isKnownUser:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkIsKnownUser: ",e)}}checkDialogSelectedByKnownUser(){try{this.componentConfigSignal().user&&this.componentConfigSignal().isKnownUser?this.componentConfigSignal.update(e=>(e=D(E({},e),{dialogSelectedByKnownUser:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{dialogSelectedByKnownUser:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkDialogSelectedByKnownUser: ",e)}}checkCanResolveAnnotation(){try{this.componentConfigSignal().annotation&&!this.componentConfigSignal().disabled&&this.componentConfigSignal().enableResolve&&this.componentConfigSignal().dialogSelectedByKnownUser&&this.componentConfigSignal().annotation?.status?.type!=="terminal"&&!this.componentConfigSignal().isPlanExpired?this.componentConfigSignal.update(e=>(e=D(E({},e),{canResolveAnnotation:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{canResolveAnnotation:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkCanResolveAnnotation: ",e)}}checkCanUnresolveAnnotation(){try{this.componentConfigSignal().annotation&&!this.componentConfigSignal().disabled&&this.componentConfigSignal().enableResolve&&this.componentConfigSignal().dialogSelectedByKnownUser&&this.componentConfigSignal().annotation?.status?.type==="terminal"&&!this.componentConfigSignal().isPlanExpired?this.componentConfigSignal.update(e=>(e=D(E({},e),{canUnresolveAnnotation:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{canUnresolveAnnotation:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkCanUnresolveAnnotation: ",e)}}checkGetAnnotationDraftAttribute(){try{this.componentConfigSignal().newCommentTextArea?.nativeElement?.innerText&&this.componentConfigSignal().newCommentTextArea?.nativeElement?.innerText!==`
533
533
  `||this.componentConfigSignal().editCommentTextArea?.nativeElement?.innerText&&this.componentConfigSignal().editCommentTextArea?.nativeElement?.innerText!==`
534
- `||this.componentConfigSignal().selectedAttachments?.length||this.componentConfigSignal().attachmentsToDelete?.length||this.componentConfigSignal().recorderInitConfig&&this.componentConfigSignal().recorderInitConfig?.panelId===this.componentConfigSignal().commentDialogUniqueId||this.componentConfigSignal().localRecordedData?.length?this.componentConfigSignal.update(e=>(e=D(E({},e),{getAnnotationDraftAttribute:e.annotation?.annotationId}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{getAnnotationDraftAttribute:null}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkGetAnnotationDraftAttribute: ",e)}}checkShowGhostCommentMessage(){try{this.componentConfigSignal().ghostComment&&this.componentConfigSignal().enableGhostCommentsMessage&&![this.componentConfigSignal().commentAcceptedStatus?.id,this.componentConfigSignal().commentRejectedStatus?.id].includes(this.componentConfigSignal().annotation?.status?.id)?this.componentConfigSignal.update(e=>(e=D(E({},e),{showGhostCommentMessage:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{showGhostCommentMessage:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkShowGhostCommentMessage: ",e)}}checkShowSuggestionModeActions(){try{this.componentConfigSignal().suggestionMode&&this.componentConfigSignal().dialogSelectedByKnownUser&&this.componentConfigSignal().annotation?.status?.type!=="terminal"&&this.componentConfigSignal().annotation?.comments?.length?this.componentConfigSignal.update(e=>(e=D(E({},e),{showSuggestionModeActions:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{showSuggestionModeActions:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkShowSuggestionModeActions: ",e)}}ngOnDestroy(){super.ngOnDestroy(),this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.removeLinkClickListeners(),this.veltDynamicComponents.forEach(e=>{e.destroy()}),this.subscriptions.map(e=>{e.unsubscribe()}),this.domService.setRecordingInProgress(this.componentConfigSignal().annotation?.annotationId,!1),this.subscriptions=[],this.componentConfigSignal().recorderInitConfig?.panelId===this.componentConfigSignal().commentDialogUniqueId&&this.recorderService.clearRecording(),this.resizeObserver&&this.componentConfigSignal().commentsContainer?.nativeElement&&this.resizeObserver.unobserve(this.componentConfigSignal().commentsContainer?.nativeElement),clearTimeout(this.escapePressTimeout),this.componentConfigSignal().getAnnotationDraftAttribute&&this.commentService.getDraftMode()&&!this.componentConfigSignal().editComment&&this.componentConfigSignal().getAnnotationDraftAttribute&&this.addComment(void 0,!0)}catch(e){this.catchError("Error in CommentDialogComponent unsubscribe: ",e)}}closeDialog(){try{this.domService.resetSelectedAnnotationsMap()}catch(e){this.catchError("Error in CommentDialogComponent closeDialog: ",e)}}openDropdownIndex(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{openDropdownIndexValue:e}),t))}catch(t){this.catchError("Error in CommentDialogComponent openDropdownIndex: ",t)}}navigateToCommentEmit(){try{this.onCommentNavigationButtonClick.emit(this.componentConfigSignal().annotation)}catch(e){this.catchError("Error in CommentDialogComponent navigateToComment: ",e)}}moveCursorToEnd(e){try{if(!e?.isConnected)return;e.focus(),setTimeout(()=>{let t=document.createRange(),r=window.getSelection();t.selectNodeContents(e),t.collapse(!1),r?.removeAllRanges(),r?.addRange(t),setTimeout(()=>{this.autoScrollToBottom(e)},50)},0)}catch(t){this.catchError("Error in CommentDialogComponent moveCursorToEnd: ",t)}}focusOnComposerInput(){try{this.onComposerClick(),this.composerFocused.emit();let e=fce();this.componentConfigSignal().newCommentTextArea?.nativeElement&&(this.componentConfigSignal().newCommentTextArea.nativeElement?.contains(e)||this.moveCursorToEnd(this.componentConfigSignal().newCommentTextArea.nativeElement)),this.componentConfigSignal().editCommentTextArea?.nativeElement&&(this.componentConfigSignal().editCommentTextArea.nativeElement?.contains(e)||this.moveCursorToEnd(this.componentConfigSignal().editCommentTextArea.nativeElement))}catch(e){this.catchError("Error in CommentDialogComponent focusOnComposerInput: ",e)}}onComposerClick(){try{this.composerFocused.emit(),this.commentActionsService?.onComposerClick({commentAnnotation:this.componentConfigSignal().annotation}),this.componentConfigSignal().commentPinSelected||(this.componentConfigSignal().sidebarMode?this.domService.toggleAnnotationSelection(this.componentConfigSignal().annotation,this.componentConfigSignal().containerComponentId,"sidebarShowReplies"):this.domService.toggleAnnotationSelection(this.componentConfigSignal().annotation,this.componentConfigSignal().containerComponentId))}catch(e){this.catchError("Error in CommentDialogComponent onComposerClick: ",e)}}getCurrentDialogView(){try{let e={};if(this.componentConfigSignal().annotation?.annotationId){let t=this.componentConfigSignal().commentViews?.[this.componentConfigSignal().annotation?.annotationId]?.comments;Object.keys(t||{}).forEach(r=>{let a=[],s=0;Object.keys(t[r]?.views||{}).forEach(c=>{let p={};p.user=this.componentConfigSignal().userContactsBySnippylyId?.[c],p.viewedAt=t[r]?.views?.[c]?.timestamp,p.user?.userId!==this.componentConfigSignal().user?.userId&&p.user?.userId!==this.componentConfigSignal().annotation?.from?.userId&&(a.push(p),(p.user?.email||p.user?.name)&&s++)}),e[r]={count:s,views:a}})}this.componentConfigSignal.update(t=>(t=D(E({},t),{currentDialogView:e}),t))}catch(e){this.catchError("Error in CommentDialogComponent getCurrentDialogView: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}showReplyComposerHandler(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{showReplyComposer:!0}),e)),setTimeout(()=>{this.focusOnComposerInput()},100)}catch(e){this.catchError("Error in CommentDialogComponent showReplyComposerHandler: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(we),h(Zn),h(l7),h(Si),h(Be),h(bn),h(Cl),h(W1),h(_),h(Wo),h(En),h(ur),h(Ps),h(Ke),h(R),h(qi),h(Ge),h(ot),h(un),h(an),h(ad,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-dialog"]],viewQuery:function(t,r){if(t&1&&(it(sen,5),it(len,5),it(cen,5),it(B1e,7),it(B1e,5,Ci)),t&2){let a;Je(a=et())&&(r.commentsContainer=a.first),Je(a=et())&&(r.newCommentTextArea=a.first),Je(a=et())&&(r.editCommentTextArea=a.first),Je(a=et())&&(r.hostElement=a.first),Je(a=et())&&(r.hostViewContainer=a.first)}},hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{snippylyReadId:"snippylyReadId",screenshotDomain:"screenshotDomain",annotationIndex:"annotationIndex",userContacts:"userContacts",annotation:"annotation",multiThreadAnnotationId:"multiThreadAnnotationId",readOnly:"readOnly",dialogSelection:"dialogSelection",expandOnSelection:"expandOnSelection",user:"user",dialogMode:"dialogMode",sidebarMode:"sidebarMode",fullExpanded:"fullExpanded",inboxMode:"inboxMode",multiThread:"multiThread",inlineCommentMode:"inlineCommentMode",inlineCommentSectionMode:"inlineCommentSectionMode",commentComposerMode:"commentComposerMode",isInsidePdfViewer:"isInsidePdfViewer",locationDisplayName:"locationDisplayName",locationVersion:"locationVersion",commentPinSelected:"commentPinSelected",variant:"variant",shadowDom:"shadowDom",commentPinType:"commentPinType",composerMode:"composerMode",containerComponentId:"containerComponentId",focusedThreadMode:"focusedThreadMode",isFocusedThreadEnabled:"isFocusedThreadEnabled",openAnnotationInFocusMode:"openAnnotationInFocusMode",pageModeComposer:"pageModeComposer",composerPosition:"composerPosition",sortBy:"sortBy",sortOrder:"sortOrder",targetElementId:"targetElementId",dialogTemplate:"dialogTemplate"},outputs:{deleteCommentThread:"deleteCommentThread",saveComment:"saveComment",addCommentEmitter:"addComment",afterViewInit:"afterViewInit",signInToAccessFeature:"signInToAccessFeature",pointerOutFromCommentDialog:"pointerOutFromCommentDialog",pointerUp:"pointerUp",updateOverlayPosition:"updateOverlayPosition",onCommentNavigationButtonClick:"onCommentNavigationButtonClick",onOpenFocusedThread:"onOpenFocusedThread",composerFocused:"composerFocused"},standalone:!1,features:[L,Ze],decls:4,vars:68,consts:[["host","","commentsContainer",""],["defaultDialogRef",""],["commentsContainer",""],[1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup"],[4,"ngIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","inbox","velt-comment-dialog--inbox-mode","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--ghost-comment-annotation","inline-comment-mode","velt-comment-dialog--inline-comment-mode","velt-comment-dialog--multi-thread-mode","velt-comment-dialog--page-comment","velt-comment-dialog--inline-comment-section-mode","velt-comment-dialog--comment-composer-mode","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","sidebar","velt-comment-dialog--sidebar-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--ghost-comment-annotation","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","id","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","inbox","velt-comment-dialog--inbox-mode","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--ghost-comment-annotation","inline-comment-mode","velt-comment-dialog--inline-comment-mode","velt-comment-dialog--multi-thread-mode","velt-comment-dialog--page-comment","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--inline-comment-section-mode","velt-comment-dialog--comment-composer-mode","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container",1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup"],[3,"componentConfigSignal"],["class","line-div velt-comment-dialog--line-div",4,"ngIf"],["class","velt-action-bar velt-comment-dialog--action-bar",4,"ngIf"],[1,"line-div","velt-comment-dialog--line-div"],[1,"velt-action-bar","velt-comment-dialog--action-bar"],[3,"componentConfigSignal",4,"ngIf"],["class","velt-comment-dialog--action-bar-group",4,"ngIf"],[1,"velt-comment-dialog--action-bar-group"],["part","container",1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup","id"]],template:function(t,r){if(t&1){let a=K();y(0,"div",3,0),W("click",function(){return N(a),F(r.onClick())})("pointerout",function(c){return N(a),r.onPointerOutCommentDialog(c),F(c.stopPropagation())})("pointerdown",function(c){return N(a),F(c.stopPropagation())})("pointerup",function(c){return N(a),r.onPointerUp(),F(c.stopPropagation())}),b(),u(3,Ren,4,1,"ng-container",4)}if(t&2){let a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye,Ne,Ve,Ie,be,Ae,_e,fe,Oe,Fe,ao,bt,It,yt,Lt,Yt,zt,tn,Ii,nn,ti,Ei;pe("sidebar",(a=r.componentConfigSignal())==null?null:a.sidebarMode)("velt-comment-dialog--sidebar-mode",(s=r.componentConfigSignal())==null?null:s.sidebarMode)("dialog",(c=r.componentConfigSignal())==null?null:c.dialogMode)("velt-comment-dialog--dialog-mode",(p=r.componentConfigSignal())==null?null:p.dialogMode)("hide",(g=r.componentConfigSignal())==null?null:g.showDefault)("velt-comment-dialog--hide",(f=r.componentConfigSignal())==null?null:f.showDefault)("bottom-sheet",(I=r.componentConfigSignal())==null?null:I.bottomSheetMode)("velt-comment-dialog--bottom-sheet",(T=r.componentConfigSignal())==null?null:T.bottomSheetMode)("inbox",(B=r.componentConfigSignal())==null?null:B.inboxMode)("velt-comment-dialog--inbox-mode",(z=r.componentConfigSignal())==null?null:z.inboxMode)("readonly",((G=r.componentConfigSignal())==null||G.user==null?null:G.user.isReadOnly)||((G=r.componentConfigSignal())==null||G.user==null?null:G.user.isAnonymous))("velt-comment-dialog--readonly",((J=r.componentConfigSignal())==null||J.user==null?null:J.user.isReadOnly)||((J=r.componentConfigSignal())==null||J.user==null?null:J.user.isAnonymous))("no-comments",!(!((ne=r.componentConfigSignal())==null||ne.annotation==null||ne.annotation.comments==null)&&ne.annotation.comments.length))("velt-comment-dialog--no-comments",!(!((ve=r.componentConfigSignal())==null||ve.annotation==null||ve.annotation.comments==null)&&ve.annotation.comments.length))("selected",(ye=r.componentConfigSignal())==null?null:ye.commentDialogSelected)("velt-comment-dialog--selected",(Ne=r.componentConfigSignal())==null?null:Ne.commentDialogSelected)("screen-recording",((Ve=r.componentConfigSignal())==null||Ve.recorderInitConfig==null?null:Ve.recorderInitConfig.type)==="screen")("velt-comment-dialog--screen-recording",((Ie=r.componentConfigSignal())==null||Ie.recorderInitConfig==null?null:Ie.recorderInitConfig.type)==="screen")("s-ghost-comment-annotation",(be=r.componentConfigSignal())==null?null:be.showGhostCommentMessage)("velt-comment-dialog--ghost-comment-annotation",(Ae=r.componentConfigSignal())==null?null:Ae.showGhostCommentMessage)("velt-comment-dialog--focused-thread-mode",(_e=r.componentConfigSignal())==null?null:_e.focusedThreadMode)("inline-comment-mode",((fe=r.componentConfigSignal())==null?null:fe.inlineCommentMode)&&!((fe=r.componentConfigSignal())!=null&&fe.isInsidePdfViewer))("velt-comment-dialog--page-comment",(Oe=r.componentConfigSignal())==null||Oe.annotation==null?null:Oe.annotation.isPageAnnotation)("velt-comment-dialog--inline-comment-mode",((Fe=r.componentConfigSignal())==null?null:Fe.inlineCommentMode)&&!((Fe=r.componentConfigSignal())!=null&&Fe.isInsidePdfViewer))("velt-comment-dialog--multi-thread-mode",(ao=r.componentConfigSignal())==null?null:ao.multiThread)("velt-comment-dialog--comment-composer-mode",(bt=r.componentConfigSignal())==null?null:bt.commentComposerMode)("velt-comment-dialog--page-mode-composer",(It=r.componentConfigSignal())==null?null:It.pageModeComposer)("velt-comment-dialog--read-only",(yt=r.componentConfigSignal())==null?null:yt.readOnly)("private-comment",(Lt=r.componentConfigSignal())==null?null:Lt.isPrivateComment)("velt-comment-dialog--private-comment",(Yt=r.componentConfigSignal())==null?null:Yt.isPrivateComment),x("data-velt-annotation-draft",(zt=r.componentConfigSignal())==null?null:zt.getAnnotationDraftAttribute)("data-velt-annotation-edit-comment",(tn=r.componentConfigSignal())!=null&&tn.editComment?!0:void 0)("data-velt-comment-dialog-comments-count",((Ii=r.componentConfigSignal())==null||Ii.annotation==null||Ii.annotation.comments==null?null:Ii.annotation.comments.length)||"0")("data-velt-comment-dialog-comments-status",(nn=r.componentConfigSignal())==null||nn.annotation==null||nn.annotation.status==null?null:nn.annotation.status.id)("data-velt-comment-dialog-comments-status-type",(ti=r.componentConfigSignal())==null||ti.annotation==null||ti.annotation.status==null?null:ti.annotation.status.type)("data-velt-comment-dialog-comments-priority",(Ei=r.componentConfigSignal())==null||Ei.annotation==null||Ei.annotation.priority==null?null:Ei.annotation.priority.id)("data-testid",r.componentId+"-root"),m(3),d("ngIf",r.componentConfigSignal())}},dependencies:[X,Dt,b_,C_,I_,v_,S_,Mf,h_,x_,f_,w_,T_,Sn,P1],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)}[type=button][_ngcontent-%COMP%]:not(:disabled), [type=reset][_ngcontent-%COMP%]:not(:disabled), [type=submit][_ngcontent-%COMP%]:not(:disabled), button[_ngcontent-%COMP%]:not(:disabled){cursor:pointer}[_ngcontent-%COMP%]::-webkit-scrollbar{display:none;width:0;height:0}[_ngcontent-%COMP%]::-webkit-scrollbar{width:0;height:0}[_ngcontent-%COMP%]::-webkit-scrollbar-button{width:0;height:0} .velt-comment-dialog-thread-card-message--email-chip, .velt-autocomplete--contact-chip, .velt-autocomplete--group-chip{color:var(--velt-accent-text);background:var(--velt-accent-transparent);border-radius:var(--velt-border-radius-xs);padding:var(--velt-spacing-xs);word-break:break-word;font-size:var(--velt-font-size-sm);font-style:normal;font-weight:400;line-height:120%} .velt-comment-dialog-thread-card-message--email-chip.velt-autocomplete--contact-chip-current-user, .velt-autocomplete--contact-chip.velt-autocomplete--contact-chip-current-user, .velt-autocomplete--group-chip.velt-autocomplete--contact-chip-current-user{background-color:color-mix(in srgb,var(--velt-warning) 12%,transparent);color:color-mix(in srgb,var(--velt-warning) 32%,var(--velt-text-0))} velt-autocomplete-chip velt-skeleton-loader-internal{width:50px;border-radius:var(--velt-border-radius-xs);margin-block:6px} .velt-comment-dialog--here-chip{color:var(--velt-accent-text);background:var(--velt-accent-transparent);border-radius:var(--velt-border-radius-xs);padding:var(--velt-spacing-xs);word-break:break-word} .velt-attachment-tag{color:var(--velt-accent);word-break:break-word;display:inline-block;cursor:pointer} .velt-attachment-tag:hover{color:var(--velt-accent-hover)}.velt-comment-dialog--comment-link[_ngcontent-%COMP%]{color:var(--velt-accent);word-break:break-all;display:unset}.velt-comment-dialog-shake[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_shake .82s cubic-bezier(.36,.07,.19,.97) both}@keyframes _ngcontent-%COMP%_shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(2px,0,0)}30%,50%,70%{transform:translate3d(-4px,0,0)}40%,60%{transform:translate3d(4px,0,0)}}.velt-comment-dialog[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;gap:var(--velt-spacing-lg);border-radius:var(--velt-border-radius-md);box-shadow:0 8px 16px -8px #0f0f0f1a;box-sizing:border-box;width:361px;text-align:left;font-size:var(--velt-font-size-sm);padding:var(--velt-spacing-lg);background-color:var(--velt-background-0);border:1px solid var(--velt-border-4);color:var(--velt-text-3)}.velt-comment-dialog[_ngcontent-%COMP%] .velt-comment-dialog--line-div[_ngcontent-%COMP%]{border-top:1px solid var(--velt-border-4);width:100%}.velt-comment-dialog.velt-comment-dialog--no-comments[_ngcontent-%COMP%]{padding:0;gap:0}.velt-comment-dialog.velt-comment-dialog--multi-thread-mode[_ngcontent-%COMP%]{box-shadow:none;border:0;background-color:transparent}.velt-comment-dialog.velt-comment-dialog--sidebar-mode[_ngcontent-%COMP%]{width:100%;min-width:100%;box-shadow:none;background:transparent;border-color:transparent}.velt-comment-dialog.velt-comment-dialog--sidebar-mode[_ngcontent-%COMP%]:hover, .velt-comment-dialog.velt-comment-dialog--sidebar-mode.velt-comment-dialog--selected[_ngcontent-%COMP%]{background-color:var(--velt-background-0);border-color:var(--velt-border-4)}.velt-comment-dialog.velt-comment-dialog--page-mode-composer[_ngcontent-%COMP%]{width:100%;padding-inline:var(--velt-spacing-lg);box-shadow:none;background:transparent;border-color:transparent}.velt-comment-dialog.velt-comment-dialog--inline-comment-mode[_ngcontent-%COMP%]{padding:0;box-shadow:none;border-color:transparent;background:transparent;width:100%}.velt-comment-dialog.velt-comment-dialog--inline-comment-section-mode[_ngcontent-%COMP%]{width:100%;box-shadow:none}.velt-comment-dialog.velt-comment-dialog--inline-comment-section-mode.no-comments[_ngcontent-%COMP%]{padding:var(--velt-spacing-md) var(--velt-spacing-sm) var(--velt-spacing-md) var(--velt-spacing-lg)}.velt-comment-dialog.velt-comment-dialog--bottom-sheet[_ngcontent-%COMP%]{width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0} .snippyly-comment-rewriter-text{color:var(--velt-black);background-color:color-mix(in srgb,var(--velt-warning) 42%,var(--velt-white))}.velt-comment-dialog--hide[_ngcontent-%COMP%]{display:none}.velt-comment-dialog--action-bar[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:space-around;padding:var(--velt-spacing-lg);box-sizing:border-box;text-align:center;color:var(--velt-accent-text);gap:var(--velt-spacing-2xl)}.velt-comment-dialog--action-bar[_ngcontent-%COMP%]:empty{display:none}.velt-comment-dialog--action-bar[_ngcontent-%COMP%] .velt-comment-dialog--action-bar-group[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;justify-content:space-around;width:100%;box-sizing:border-box}.velt-comment-dialog--focused-thread-mode[_ngcontent-%COMP%]{border:none;height:100%}.velt-comment-dialog--focused-thread-mode[_ngcontent-%COMP%] app-comment-dialog-body[_ngcontent-%COMP%]{display:flex;flex-grow:1;min-height:0;width:100%;overflow:scroll}"],changeDetection:0});let i=o;return i})();var J7=(()=>{let o=class o{constructor(e,t,r,a){this.bottomSheet=e,this.domService=t,this.loggingService=r,this.elementRef=a,this.user=new zo,this.isInsidePdfViewer=!1,this.bottomSheetData$=new Ce(null),this.saveComment=new Me,this.veltElement=!0,this.subscriptions=[],this.componentId="velt-comment-bottom-sheet"}ngOnInit(){this.setupA11yAttributes()}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Comment bottom sheet")}catch(e){this.loggingService.catch("Error in CommentBottomSheetComponent setupA11yAttributes:",e)}}ngAfterViewInit(){this.openBottomSheet(),this.setBottomSheetData()}ngOnChanges(e){try{e?.annotation&&this.setBottomSheetData()}catch(t){this.catchError("Error in CommentBottomSheetComponent ngOnChanges: ",t)}}setBottomSheetData(){try{this.bottomSheetData$.next({annotation:this.annotation,user:this.user,commentPinSelected:!0,isInsidePdfViewer:this.isInsidePdfViewer,multiThreadAnnotationId:this.annotation?.type==="multiThread"?this.annotation.annotationId:null,saveComment:e=>{this.saveComment.emit(e)},dismiss:()=>{this.closeBottomSheet()}})}catch(e){this.catchError("Error in CommentBottomSheetComponent setBottomSheetData: ",e)}}openBottomSheet(){return Q(this,null,function*(){try{this.annotation.type==="multiThread"?(this.bottomSheetRef=this.bottomSheet.open(Rs,{data:this.bottomSheetData$.asObservable(),panelClass:["snippyly-comment-bottom-sheet-container","velt-mat-bottom-sheet-container"]}),this.subscriptions.push(this.bottomSheetRef.backdropClick().subscribe(()=>{this.domService.resetSelectedAnnotationsMap()}))):(this.bottomSheetRef=this.bottomSheet.open(ar,{data:this.bottomSheetData$.asObservable(),panelClass:["snippyly-comment-bottom-sheet-container","velt-mat-bottom-sheet-container"]}),this.subscriptions.push(this.bottomSheetRef.backdropClick().subscribe(()=>{this.domService.resetSelectedAnnotationsMap()})))}catch(e){this.catchError("Error in CommentBottomSheetComponent openBottomSheet: ",e)}})}closeBottomSheet(){try{this.bottomSheetRef&&this.bottomSheetRef.dismiss()}catch(e){this.catchError("Error in CommentBottomSheetComponent closeBottomSheet: ",e)}}ngOnDestroy(){this.closeBottomSheet(),this.subscriptions.forEach(e=>{e?.unsubscribe()})}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(sd),h(Be),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-bottom-sheet"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{annotation:"annotation",user:"user",isInsidePdfViewer:"isInsidePdfViewer"},outputs:{saveComment:"saveComment"},standalone:!1,features:[Ze],decls:0,vars:0,template:function(t,r){},styles:[".velt-mat-bottom-sheet-container.snippyly-comment-bottom-sheet-container{padding:0!important} .velt-mat-bottom-sheet-container.snippyly-comment-bottom-sheet-container .mat-bottom-sheet-container{padding:0!important}"],changeDetection:0});let i=o;return i})();function Fen(i,o){if(i&1){let n=K();y(0,"div",4),W("pointerup",function(t){return N(n),l(2).togglePinSelection(),F(t.stopPropagation())})("click",function(t){return N(n),F(t.stopPropagation())})("cdkDragStarted",function(){N(n);let t=l(2);return F(t.onPinDragStart())}),y(1,"snippyly-comment-pin",5),W("saveComment",function(t){N(n);let r=l(2);return F(r.saveComment(t))})("commentTargetElementClicked",function(){N(n);let t=l(2);return F(t.togglePinSelection())})("togglePinSelection",function(t){N(n);let r=l(2);return F(r.togglePinSelection(t))}),b()()}if(i&2){let n=l().ngIf,e=l();at("top",(n.commentPinAnnotation==null||n.commentPinAnnotation.position==null?null:n.commentPinAnnotation.position.top)-0+n.offsetTop,"px")("left",(n.commentPinAnnotation==null||n.commentPinAnnotation.position==null?null:n.commentPinAnnotation.position.left)-10+n.offsetLeft,"px"),d("id","comment-pin-container-"+(n.commentPinAnnotation==null?null:n.commentPinAnnotation.annotationId)),x("data-testid",e.componentId+"-popover")("role","button")("aria-expanded",n.commentPinSelected),m(),d("annotation",n.commentPinAnnotation)("containerComponentId",n.componentId)("commentPinSelected",n.commentPinSelected&&!n.annotationDragging)("multipleCommentPinSelected",n.commentPinSelected&&e.objectKeys(n.selectedAnnotationsMap).length>1)("targetElement",n.targetElement)("user",n.user)}}function Len(i,o){if(i&1){let n=K();y(0,"div",7),W("pointerup",function(t){return N(n),l(3).togglePinSelection(),F(t.stopPropagation())})("touchend",function(t){return N(n),t.stopPropagation(),F(t.preventDefault())})("mousedown",function(t){return N(n),F(t.stopPropagation())})("touchstart",function(t){return N(n),F(t.stopPropagation())})("pointerdown",function(t){return N(n),F(t.stopPropagation())})("click",function(t){return N(n),F(t.stopPropagation())})("cdkDragStarted",function(){N(n);let t=l(3);return F(t.onPinDragStart())})("cdkDragMoved",function(t){N(n);let r=l(3);return F(r.onPinMove(t))})("cdkDragReleased",function(){N(n);let t=l(3);return F(t.onPinRelease())}),y(1,"snippyly-comment-pin",8,1),W("togglePinSelection",function(t){N(n);let r=l(3);return F(r.togglePinSelection(t))})("saveComment",function(t){N(n);let r=l(3);return F(r.saveComment(t))}),b()()}if(i&2){let n=me(2),e=l(2).ngIf,t=l();at("top",e.annotationDragging?(e.dragPosition==null?null:e.dragPosition.top)-((n==null?null:n.COMMENT_PIN_SIZE)||40):(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.top)-((n==null?null:n.COMMENT_PIN_SIZE)||40)+e.offsetTop,"px")("left",e.annotationDragging?e.dragPosition==null?null:e.dragPosition.left:(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.left)+e.offsetLeft,"px")("--velt-comment-pin-transform",e.annotationDragging?"none":e.pinTransform??"none")("transform",!e.annotationDragging&&(!(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null)&&e.commentPinAnnotation.position.parentScaleX)?"scale("+1/((e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.parentScaleX)||1)+", "+1/((e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.parentScaleY)||1)+")":""),pe("pin-dragging",e.annotationDragging),d("id","comment-pin-container-"+(e.commentPinAnnotation==null?null:e.commentPinAnnotation.annotationId))("cdkDragDisabled",(e.commentPinAnnotation==null||e.commentPinAnnotation.from==null?null:e.commentPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("data-testid",t.componentId+"-default")("role","button")("aria-expanded",e.commentPinSelected)("aria-grabbed",e.annotationDragging)("data-transform-inside",e.transformContext?"true":"false"),m(),d("annotation",e.commentPinAnnotation)("annotationDragging",e.annotationDragging)("containerComponentId",e.componentId)("commentPinSelected",e.commentPinSelected&&!e.annotationDragging)("multipleCommentPinSelected",e.commentPinSelected&&t.objectKeys(e.selectedAnnotationsMap).length>1)("targetElement",e.targetElement)("user",e.user)}}function Ben(i,o){if(i&1&&u(0,Len,3,24,"div",6),i&2){let n=l().ngIf;d("ngIf",n.commentPinAnnotation==null?null:n.commentPinAnnotation.position)}}function Ven(i,o){if(i&1&&(v(0),u(1,Fen,2,14,"div",3)(2,Ben,1,1,"ng-template",null,0,Te),C()),i&2){let n=o.ngIf,e=me(3);m(),d("ngIf",n.popoverMode)("ngIfElse",e)}}var e8=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.analyticsService=e,this.authService=t,this.docService=r,this.domService=a,this.commentService=s,this.commentActionsService=c,this.loggingService=p,this.elementRef=g,this.multipleCommentPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.selectedAnnotationsLocationMap={},this.subscriptions=[],this.componentConfigSignal=xe({popoverMode:!1,commentPinAnnotation:void 0,commentPinSelected:!1,offsetLeft:0,offsetTop:0,selectedAnnotationsMap:{},annotationDragging:!1,dragPosition:null,targetElement:void 0,user:void 0,componentId:`comment-pin-portal-${vt()}`}),this.veltElement=!0,this.componentId="velt-comment-pin-portal",this.subscriptions.push(this.authService.getUser$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{user:f}),I))},f=>{this.catchError("Error in CommentPinPortalComponent getUser$ subscription: ",f)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{selectedAnnotationsMap:f}),I)),this.checkCommentPinSelected()},f=>{this.catchError("Error in CommentPinPortalComponent getSelectedAnnotationsMap$ subscription: ",f)})),this.subscriptions.push(this.domService.getSelectedAnnotationsLocationMap$().subscribe(f=>{this.selectedAnnotationsLocationMap=f||{},this.checkCommentPinSelected()},f=>{this.catchError("Error in CommentPinPortalComponent getSelectedAnnotationsLocationMap$ subscription: ",f)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{popoverMode:f}),I))},f=>{this.catchError("Error in CommentPinPortalComponent getPopoverMode subscription: ",f)}))}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.commentService.getTransformContext$().subscribe(e=>{this.componentConfigSignal.update(t=>{if(t=D(E({},t),{transformContext:e}),e&&this.isElementInsideTransformContainer(this.elementRef?.nativeElement,e.containerSelector)){let r=e.transforms.scale?1/e.transforms.scale:1;t.pinTransform=`scale(${r})`}else t.pinTransform=void 0;return t})}))}catch(e){this.loggingService.catch("Error in CommentPinPortalComponent ngOnInit:",e)}}isElementInsideTransformContainer(e,t){try{return document.querySelector(t)?.contains(e)??!1}catch(r){return this.loggingService.catch("Error in CommentPinPortalComponent isElementInsideTransformContainer:",r),!1}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinPortalComponent setupA11yAttributes:",e)}}setCommentPinAnnotation(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinAnnotation:e}),t)),this.id=this.componentConfigSignal().commentPinAnnotation?.annotationId,this.checkCommentPinSelected()}catch(t){this.catchError("Error in CommentPinPortalComponent setCommentPinAnnotation: ",t)}}setSourceId(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{sourceId:e}),t)),this.checkCommentPinSelected()}catch(t){this.catchError("Error in CommentPinPortalComponent setSourceId: ",t)}}getMultiThreadCommentAnnotations(){}checkCommentPinSelected(){try{let e=this.componentConfigSignal().selectedAnnotationsMap,t=this.componentConfigSignal().commentPinAnnotation,r=this.componentConfigSignal().sourceId;if(t){let a=!!e[t.annotationId];if(a)if(t?.isDraft)t?.sourceId&&(a=t?.sourceId===r,a&&this.domService.setSelectedAnnotationLocation(t.annotationId,this.componentConfigSignal().componentId));else{let s=this.selectedAnnotationsLocationMap?.[t.annotationId];s&&(a=s===this.componentConfigSignal().componentId)}a!==this.componentConfigSignal().commentPinSelected&&this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinSelected:a}),s))}}catch(e){this.catchError("Error in CommentPinPortalComponent checkCommentPinSelected: ",e)}}setTargetElement(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{targetElement:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setTargetElement: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(e){try{let t=e||this.componentConfigSignal().commentPinAnnotation;if(t&&this.commentActionsService.onCommentPinClick(t).catch(a=>{this.catchError("Error in CommentPinPortalComponent togglePinSelection onCommentPinClick: ",a)}),this.componentConfigSignal().selectedAnnotationsMap[t?.annotationId]&&this.selectedAnnotationsLocationMap?.[t?.annotationId]===this.componentConfigSignal().componentId)t?.ghostComment?.type!==Dl.DIFFERENT_DEVICE&&document.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}="${t?.annotationId}"]`)&&this.domService.resetSelectedAnnotationsMap(!0,"comments");else{let a=document.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);if(a||(a=(this.domService.getDraftCommentAnnotationDialogs()||[])[0]),a){let s=a.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_DRAFT);if(s){let c=document.getElementById(`comment-pin-container-${s}`)||document.querySelector(`[data-velt-id='${s}']`);c&&(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),this.domService.resetSelectedAnnotationsMap(!0,"comments"))}}else this.domService.resetSelectedAnnotationsMap(!0,"comments"),this.componentConfigSignal().targetElement&&this.domService.isElementVisibleOnScreen(this.componentConfigSignal().targetElement)&&(this.componentConfigSignal().annotationDragging||this.domService.toggleAnnotationSelection(t,this.componentConfigSignal().componentId,void 0,!0))}}catch(t){this.catchError("Error in CommentPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){try{this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation.annotationId]&&this.componentConfigSignal().commentPinAnnotation?.ghostComment?.type!==Dl.DIFFERENT_DEVICE&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation,this.componentConfigSignal().componentId);let e=document.getElementById(this.componentConfigSignal().commentPinAnnotation.annotationId);if(!e)return;this.parentElement=e.parentElement;let t=this.componentConfigSignal().commentPinAnnotation.position,r=this.componentConfigSignal().transformContext,a=this.parentElement.getBoundingClientRect(),s=a.left+t.left,c=a.top+t.top,p=r&&this.isElementInsideTransformContainer(e,r.containerSelector);this.componentConfigSignal.update(g=>(g=D(E({},g),{elementInTransformedContainer:p}),g)),e.style.width="20px",e.style.height="20px",e.style.margin="0",e.style.padding="0",e.style.display="block",e.style.visibility="visible",e.style.opacity="1",e.style.backgroundColor="var(--velt-comment-pin-background-color, #2d62ff)",e.style.borderRadius="50%",e.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.style.pointerEvents="auto",e.offsetWidth,document.body.appendChild(e),e.style.position="fixed",e.style.top=`${c}px`,e.style.left=`${s}px`,e.style.zIndex="10000",e.style.transform="none",e.offsetWidth,this.componentConfigSignal.update(g=>(g=D(E({},g),{annotationDragging:!0}),g))}catch(e){this.catchError("Error in CommentPinPortalComponent onPinDragStart: ",e)}}onPinMove(e){try{this.updateCurrentPinPosition(e)}catch(t){this.catchError("Error in CommentPinPortalComponent onPinMove: ",t)}}updateCurrentPinPosition(e){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let t=e.event,r=t?.touches?.length?t.touches[0]?.clientX:t.clientX,a=t?.touches?.length?t.touches[0]?.clientY:t.clientY,s=this.componentConfigSignal().transformContext,c=this.domService.getBackgroundElement(r,a);c&&this.commentService.isElementInsideAllowedElements(c)&&(this.componentConfigSignal.update(p=>(p=D(E({},p),{targetElement:c}),p)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=e.event,this.componentConfigSignal.update(p=>(p=D(E({},p),{dragPosition:{top:a,left:r}}),p)))}catch(t){this.catchError("Error in CommentPinPortalComponent updateCurrentPinPosition: ",t)}}onPinRelease(){try{let e=document.getElementById(this.componentConfigSignal().commentPinAnnotation.annotationId);if(!e||!this.parentElement)return;this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let t=this.domService.getElementFromXPath(this.componentConfigSignal().commentPinAnnotation.targetElement?.xpath),r=this.componentConfigSignal().commentPinAnnotation?.targetElement;if(this.pointerMoveEvent){let J=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent,!0,!0,!0,ne=>{if(this.commentService.getSvgAsImg()){let ve=ne?.closest(`[${U.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);ve&&ve instanceof HTMLElement&&(ne=ve)}return ne});J&&(r=J)}let a=this.domService.getElementFromXPath(r?.xpath),s=this.componentConfigSignal().commentPinAnnotation.targetElement?.xpath,c=r?.xpath,p=s===c;if(!a)return;let g=this.componentConfigSignal().dragPosition,f=a.getBoundingClientRect(),I=50,T=50;if(g){let J=g.left-f.left,ne=g.top-f.top;I=J/f.width*100,T=ne/f.height*100,I=Math.max(0,Math.min(100,I)),T=Math.max(0,Math.min(100,T))}let B=E({},this.componentConfigSignal().commentPinAnnotation);B.targetElement=E({},r),B.targetElement.leftPercentage=I,B.targetElement.topPercentage=T,this.commentService.calculateCommentAnnotationPosition(B),this.componentConfigSignal.update(J=>(J=D(E({},J),{commentPinAnnotation:B,targetElement:a}),J));let z=this.domService.isElementInsideAdditionalLocationContainer(t)||this.domService.isElementInsideAdditionalLocationContainer(a),G=this.docService.getAdditionalDocumentIdFromElement(a)||this.docService.getDocumentPaths()?.clientDocumentId;if(!this.componentConfigSignal().commentPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().commentPinAnnotation?.metadata?.clientDocumentId==G?(this.componentConfigSignal.update(J=>(J=D(E({},J),{commentPinAnnotation:D(E({},J.commentPinAnnotation),{targetElement:r})}),J)),this.commentService.updateComment(this.componentConfigSignal().commentPinAnnotation,z)):this.componentConfigSignal.update(J=>(J=D(E({},J),{targetElement:t}),J)),p){let J=this.componentConfigSignal().transformContext,ne=this.componentConfigSignal().elementInTransformedContainer,ve=J&&this.isElementInsideTransformContainer(a,J.containerSelector);this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{elementInTransformedContainer:ve}),Ne));let ye=e.getBoundingClientRect();if(!ne&&ve){e.style.transition="none";let Ne=ye.top,Ve=ye.left;this.parentElement.appendChild(e),e.style.position="fixed",e.style.top=`${Ne}px`,e.style.left=`${Ve}px`,e.offsetWidth,requestAnimationFrame(()=>{e.style.position="absolute",ve&&B.position.transformContext?(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`,B.position.transformContext.scale!==1&&(e.style.transform=`scale(${1/B.position.transformContext.scale})`)):(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`)})}else e.style.transition="none",this.parentElement.appendChild(e),e.style.position="absolute",e.style.width="20px",e.style.height="20px",e.style.backgroundColor="var(--velt-comment-pin-background-color, #2d62ff)",e.style.borderRadius="50%",e.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.style.visibility="visible",e.style.display="block",e.offsetWidth,ve&&B.position.transformContext?(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`):(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`);e.offsetWidth,this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{annotationDragging:!1,dragPosition:null}),Ne))}this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PIN_DRAGGED,{annotationId:this.componentConfigSignal().commentPinAnnotation.annotationId,commentMode:this.commentService.getCommentMode()})}catch(e){this.catchError("Error in CommentPinPortalComponent onPinRelease: ",e)}}saveComment(e){try{this.commentService.saveComment(this.componentConfigSignal().commentPinAnnotation,e)}catch(t){this.catchError("Error in CommentPinPortalComponent saveComment: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.catchError("Error in CommentPinPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentPinPortalComponent unsubscribe: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.commentPinAnnotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(ot),h(Be),h(we),h(Zn),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-pin-portal"]],hostVars:2,hostBindings:function(t,r){t&2&&(yr("id",r.id),x("data-velt-element",r.veltElement))},inputs:{multipleCommentPinsSelected:"multipleCommentPinsSelected",avatarErrorImage:"avatarErrorImage"},standalone:!1,decls:1,vars:1,consts:[["defaultPinPortalRef",""],["commentPinRef",""],[4,"ngIf"],["class","comment-pin-portal",3,"id","top","left","pointerup","click","cdkDragStarted",4,"ngIf","ngIfElse"],[1,"comment-pin-portal",3,"pointerup","click","cdkDragStarted","id"],[3,"saveComment","commentTargetElementClicked","togglePinSelection","annotation","containerComponentId","commentPinSelected","multipleCommentPinSelected","targetElement","user"],["class","comment-pin-portal","cdkDrag","","cdkDragHandle","",3,"id","pin-dragging","top","left","--velt-comment-pin-transform","transform","cdkDragDisabled","pointerup","touchend","mousedown","touchstart","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"comment-pin-portal",3,"pointerup","touchend","mousedown","touchstart","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased","id","cdkDragDisabled"],[3,"togglePinSelection","saveComment","annotation","annotationDragging","containerComponentId","commentPinSelected","multipleCommentPinSelected","targetElement","user"]],template:function(t,r){t&1&&u(0,Ven,4,2,"ng-container",2),t&2&&d("ngIf",r.componentConfigSignal())},styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}[_nghost-%COMP%]{position:absolute!important;top:0!important;left:0!important;box-sizing:border-box!important;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset!important;width:unset!important;text-align:left!important;z-index:var(--velt-comment-pin-z-index)!important}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit));-webkit-text-fill-color:initial!important}*[_ngcontent-%COMP%]:empty{display:revert!important}.comment-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:var(--velt-comment-pin-transform, none)!important;transform-origin:0 100%!important;transform-box:fill-box!important;top:0;left:0}.comment-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-comment-pin-z-index)!important}"],changeDetection:0});let i=o;return i})();var q1=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.commentService=e,this.domService=t,this.componentFactoryResolver=r,this.injector=a,this.appRef=s,this.loggingService=c,this.commentsPinById={},this.commentPinTemplate$=new Ce(null),this.customPinEvents$=new Xe}setCommentPin(e){try{if(!this.commentsPinById[e.annotationId])this.setPinPortal(e);else{let t=!1;if(e?.ghostComment?t=e?.ghostComment?.targetElement?.xpath!==this.commentsPinById[e.annotationId]?.[0]?.annotation?.ghostComment?.targetElement?.xpath:this.commentsPinById[e.annotationId]?.[0]?.annotation?.ghostComment?t=!0:t=e.targetElement?.xpath!==this.commentsPinById[e.annotationId]?.[0]?.annotation?.targetElement?.xpath,!t)this.commentsPinById[e.annotationId]?.forEach(r=>{let a=r.portalRef,s=r.userTargetElement,c=r.pinHostElement;if(document.body.contains(s)&&document.body.contains(c))a&&(a.instance.setCommentPinAnnotation(e),this.updateElementOffset(e));else{let p=r.pinHostDomPortalOutlet;p&&(this.removeCommentPinHostAttributes(e.annotationId,r.pinHostElement),this.removeCommentDisabledAttribute(c),p.detach(),delete this.commentsPinById[e.annotationId],e.ghostComment&&this.unselectCommentAnnotation(e),this.setPinPortal(e))}});else{let r=this.commentsPinById[e.annotationId]?.[0]?.pinHostDomPortalOutlet;r&&(this.removeCommentPinHostAttributes(e.annotationId,this.commentsPinById[e.annotationId]?.[0]?.pinHostElement),this.removeCommentDisabledAttribute(this.commentsPinById[e.annotationId]?.[0]?.pinHostElement),r.detach(),delete this.commentsPinById[e.annotationId],e.ghostComment&&this.unselectCommentAnnotation(e),this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in CommentPinPortalService setCommentPin: ",t)}}unselectCommentAnnotation(e){try{this.loggingService.log("%c[WB] Calling CommentPinPortalService FUNCTION: unselectCommentAnnotation","color: green;"),this.domService.getSelectedAnnotationsMap()?.[e?.annotationId]&&this.domService.toggleAnnotationSelection(e)}catch(t){this.loggingService.catch("Error in CommentPinPortalService unselectCommentAnnotation: ",t)}}setPinPortal(e){try{let t=this.commentService.getElementFromComments(e);t.length>0&&(this.commentsPinById[e.annotationId]=[],t.forEach(r=>{if(r){let a=this.domService.getHostElement(r),s=new lr(e8),c=new cr(a,this.appRef,this.injector),p=c.attach(s);p.instance.setCommentPinAnnotation(e),p.instance.setTargetElement(r);let g=r?.getAttribute(U.ATTRIBUTES.VELT_SOURCE_ID);g&&p.instance.setSourceId(g),this.commentsPinById[e.annotationId].push({pinHostDomPortalOutlet:c,pinPortal:s,portalRef:p,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:r,pinHostElement:a}),this.setCommentPinHostAttributes(e.annotationId,a),this.setCommentDisabledAttribute(a),this.updateElementOffset(e)}}))}catch(t){this.loggingService.catch("Error in CommentPinPortalService setPinPortal: ",t)}}setCommentPinHostAttributes(e,t){try{let r=t.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST);if(r){let a=r.split(",");a.includes(e)||(a.push(e),t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,a.join(",")))}else t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,e);window.getComputedStyle(t).position==="static"&&t.offsetHeight>0&&(gm(t)||t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST_STATIC,"true"))}catch(r){this.loggingService.catch("Error in CommentPinPortalService setCommentPinHostAttributes: ",r)}}removeCommentPinHostAttributes(e,t){try{let r=t.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST);if(r){let a=r.split(","),s=a.indexOf(e);s>-1&&(a.splice(s,1),a.length>0?t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,a.join(",")):t.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST))}t?.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST)||t.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST_STATIC)}catch(r){this.loggingService.catch("Error in CommentPinPortalService removeCommentPinHostAttributes: ",r)}}setCommentDisabledAttribute(e){try{this.commentService.getPopoverMode()&&e.setAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED,"auto")}catch(t){this.loggingService.catch("Error in CommentPinPortalService setCommentDisabledAttribute: ",t)}}removeCommentDisabledAttribute(e){try{e?.getAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED)==="auto"&&e.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED)}catch(t){this.loggingService.catch("Error in CommentPinPortalService removeCommentDisabledAttribute: ",t)}}updateElementOffset(e){try{for(let t of this.commentsPinById[e.annotationId]){let{portalRef:r,userTargetElement:a,pinHostElement:s}=t,c=this.domService.getElementOffset(a,s);r.instance.setOffsetLeft(c.offsetLeft),r.instance.setOffsetTop(c.offsetTop)}}catch(t){this.loggingService.catch("Error in CommentPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(r=>r.annotationId);Object.keys(this.commentsPinById).forEach(r=>{t.includes(r)||(this.commentService.customPinsById.has(r)&&this.commentService.customPinsById.delete(r),this.commentsPinById[r].forEach(s=>{s.pinHostDomPortalOutlet.detach(),this.removeCommentPinHostAttributes(r,s.pinHostElement),this.removeCommentDisabledAttribute(s.pinHostElement),this.domService.removeHighlightFromElement(s.pinHostElement),s.userTargetElement&&this.domService.removeHighlightFromElement(s.userTargetElement)}),delete this.commentsPinById[r])})}catch(t){this.loggingService.catch("Error in CommentPinPortalService checkPinsToRemove: ",t)}}getAnnotationIdsByUserTargetElement(e){try{let t=[];return Object.keys(this.commentsPinById||{}).forEach(r=>{this.commentsPinById[r]?.forEach(s=>{s.userTargetElement===e&&t.push(r)})}),t?.length>0?Array.from(new Set(t)):[]}catch(t){return this.loggingService.catch("Error in CommentPinPortalService getAnnotationIdsByUserTargetElement: ",t),[]}}setCommentPinOverrideTemplate(e){this.commentPinTemplate$.next(e)}getCommentPinTemplate$(){return this.commentPinTemplate$}emitCustomPinEvent(e){try{let{element:t,annotation:r}=e;r&&this.commentService.customPinsById.set(r.annotationId,t),this.customPinEvents$.next(e)}catch(t){this.loggingService.catch("Error in CommentPinPortalService emitCustomPinEvent",t)}}getCustomPinEvents$(){return this.customPinEvents$}};o.\u0275fac=function(t){return new(t||o)(ee(we),ee(Be),ee(ko),ee(St),ee(ii),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ie=(()=>{let o=class o{set veltDynamicTemplate({template:e,context:t,id:r,cloneTemplate:a,componentName:s,variant:c,suffix:p,setIfCondition:g,componentElementRef:f,replaceTemplate:I=!0}){try{if(p&&(s+=`--${p}`),c&&(s+=`---${c}`),s){let T=this.wireframeService.getConditionElement(s);if(!T&&e&&(T=e),T){let B=T?.getAttribute("velt-if");B&&g&&g(B),Array.from(T.attributes).forEach(z=>{f?.nativeElement.setAttribute(z.name,z.value)}),t?.componentConfigSignal?this.dynamicDataService.applyConditionalClasses(f?.nativeElement,t):this.dynamicDataService.applyConditionalClasses(f?.nativeElement)}}if(s&&!e){let T=this.wireframeService.getWireframe(s);if(T){let B=document.createElement(T.tagName);B.innerHTML=T.innerHTML,this.template=B}}else this.template=e;this.data=t,this.id=r,this.cloneTemplate=!!a,this.cloneTemplate&&e&&(this.template=this.domService.deepCloneElement(e)),this.checkToUpdateTemplate(I)}catch(T){this.loggingService.warn("Error in DynamicTemplateDirective veltDynamicTemplate: ",T)}}constructor(e,t,r,a,s,c,p,g){this.elementRef=e,this.templateRef=t,this.viewContainer=r,this.dynamicComponentService=a,this.loggingService=s,this.domService=c,this.wireframeService=p,this.dynamicDataService=g,this.directiveId=Math.random().toString(36).substring(7),this.isCustomTemplateMode=!1,this.isDefaultTemplateMode=!1,this.cloneTemplate=!1,this.injectedElements=[],this.componentRefs=[];try{this.loggingService.log("%c[WB] Creating CLASS: DynamicTemplateDirective","color: blue;")}catch(f){this.loggingService.catch("Error in DynamicTemplateDirective constructor: ",f)}}checkDataValue(e,t){let r=e.querySelectorAll("[data-velt]");function a(s,c){return c.split(".").reduce((p,g)=>p&&p[g],s)}r.forEach(s=>{let c=s.getAttribute("data-velt");if(c&&t){let p=a(t,c);s instanceof HTMLElement&&(s.innerText=JSON.stringify(p,null,2))}})}checkToUpdateTemplate(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: checkToUpdateTemplate","color: green;"),this.template&&e)if(this.isDefaultTemplateMode=!1,this.isCustomTemplateMode)this.updateDataOnComponentRefs(this.data);else{this.isCustomTemplateMode=!0,this.cleanUp();let t=document.createElement(this.template.tagName);t.innerHTML=this.template.innerHTML,this.injectElementNextToSibling(this.elementRef.nativeElement,t)}else this.isCustomTemplateMode=!1,this.isDefaultTemplateMode||(this.cleanUp(),this.viewContainer.createEmbeddedView(this.templateRef),this.isDefaultTemplateMode=!0)}catch(t){this.loggingService.catch("Error in DynamicTemplateDirective checkToUpdateTemplate: ",t)}}injectElementNextToSibling(e,t){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: injectElementNextToSibling","color: green;"),!t)return;this.cleanUp();let r=t;for(let s=0;s<r.children.length;s++){let c=r.children[s],p=this.dynamicComponentService.processAndReplaceVeltComponents(c,this.data,this.id?this.id:`from-directive-${this.directiveId}`,[],"from directive");p?.length&&this.componentRefs.push(...p)}r.setAttribute("data-velt-added-from-directive","true"),this.customTemplate=r;let a=Array.from(r.childNodes).reverse();e.nextSibling&&e.nextSibling&&e.nextSibling.getAttribute&&e.nextSibling.getAttribute("data-velt-added-from-directive")&&e.parentNode.removeChild(e.nextSibling),a.forEach(s=>{e.parentNode.insertBefore(s,e.nextSibling),s instanceof Element&&this.injectedElements.push(s)}),r.remove()}catch(r){this.loggingService.catch("Error in DynamicTemplateDirective injectElementNextToSibling: ",r)}}updateDataOnComponentRefs(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateDataOnComponentRefs","color: green;"),this.componentRefs.forEach(t=>{this.dynamicComponentService.setCommentRefData(e,t)})}catch(t){this.loggingService.catch("Error in DynamicTemplateDirective updateDataOnComponentRefs: ",t)}}ngOnDestroy(){try{this.cleanUp()}catch(e){this.loggingService.catch("Error in DynamicTemplateDirective ngOnDestroy: ",e)}}cleanUp(){try{this.componentRefs.forEach(e=>{e.destroy()}),this.injectedElements.forEach(e=>{e.remove()}),this.injectedElements=[],this.viewContainer.clear()}catch(e){this.loggingService.catch("Error in DynamicTemplateDirective cleanUp: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Eo),h(Ci),h(W1),h(_),h(Be),h(Ge),h(S))},o.\u0275dir=Gt({type:o,selectors:[["","veltDynamicTemplate",""]],inputs:{veltDynamicTemplate:"veltDynamicTemplate"},standalone:!1});let i=o;return i})();function Uen(i,o){if(i&1&&w(0,"div",7),i&2){let n=l(2);x("data-testid",n.componentId+"-unread-indicator")("aria-hidden","true")}}function jen(i,o){if(i&1&&(v(0),y(1,"div",1)(2,"div",2),ce(),y(3,"svg",3),P(4,"translate"),w(5,"path",4),b(),u(6,Uen,1,2,"div",5),b(),ht(),y(7,"span",6),te(8),b()(),C()),i&2){let n=o.ngIf,e=l();m(),x("data-testid",e.componentId)("role","status"),m(),x("data-testid",e.componentId+"-unread-container")("aria-hidden",!(n!=null&&n.unreadAnnotationCount)),m(),x("role","img")("aria-label",M(4,11,"Comment icon"))("focusable","false"),m(3),d("ngIf",n==null?null:n.unreadAnnotationCount),m(),x("data-testid",e.componentId+"-count")("aria-hidden","true"),m(),ze(n==null?null:n.count)}}var V1e=(()=>{let o=class o extends tt{constructor(e,t,r,a,s){super(s,a,void 0,e),this.commentService=e,this.loggingService=t,this.customFilterService=r,this.themeService=a,this.elementRef=s,this.componentConfigSignal=xe({unreadCommentsMap:null,count:0}),this.subscription=[],this.componentId="velt-comment-pin-bubble";try{this.subscription.push(this.commentService.getUnreadCommentsMap$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=E({},p),p.unreadCommentsMap=c,p))}))}catch(c){this.catchError("Error in CommentPinBubbleComponent constructor: ",c)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentPinBubbleComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinBubbleComponent setupA11yAttributes:",e)}}ngOnChanges(e){super.ngOnChanges(e);try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>{if(r=D(E({},r),{[t]:e[t].currentValue}),t==="annotation")if(r?.annotation?.type==="multiThread"){let a=Object.keys(r.unreadCommentsMap||{});r?.annotation?.commentAnnotationsMap&&(r.count=0,Object.values(r?.annotation?.commentAnnotationsMap||{}).forEach(s=>{s?.status?.id!==this.customFilterService.resolvedStatus?.id&&(r.count=(r?.count||0)+1),a.includes(s.annotationId)&&(r.unreadAnnotationCount=(r.unreadAnnotationCount||0)+1)}))}else r.count=r?.annotation?.comments?.length;return r})})}catch{}}ngOnDestroy(){super.ngOnDestroy();try{this.subscription.forEach(e=>e.unsubscribe())}catch(e){this.catchError("Error in CommentPinBubbleComponent ngOnDestroy: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(_),h(Wo),h(Ke),h(R))},o.\u0275cmp=O({type:o,selectors:[["velt-comment-pin-bubble-internal"]],inputs:{annotation:"annotation"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[[4,"ngIf"],[1,"velt-comment-pin-bubble-container"],[1,"velt-comment-pin-bubble--unread-indicator-container"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M12.6666 1.33325H3.33325C2.80282 1.33325 2.29411 1.54397 1.91904 1.91904C1.54397 2.29411 1.33325 2.80282 1.33325 3.33325V9.99992C1.33325 10.5304 1.54397 11.0391 1.91904 11.4141C2.29411 11.7892 2.80282 11.9999 3.33325 11.9999H11.0599L13.5266 14.4733C13.5889 14.535 13.6628 14.5839 13.744 14.6171C13.8252 14.6503 13.9122 14.6671 13.9999 14.6666C14.0874 14.6688 14.1741 14.6506 14.2533 14.6133C14.375 14.5632 14.4792 14.4783 14.5528 14.3692C14.6263 14.26 14.6659 14.1315 14.6666 13.9999V3.33325C14.6666 2.80282 14.4559 2.29411 14.0808 1.91904C13.7057 1.54397 13.197 1.33325 12.6666 1.33325ZM13.3333 12.3933L11.8066 10.8599C11.7443 10.7981 11.6704 10.7492 11.5892 10.7161C11.508 10.6829 11.421 10.6661 11.3333 10.6666H3.33325C3.15644 10.6666 2.98687 10.5963 2.86185 10.4713C2.73682 10.3463 2.66659 10.1767 2.66659 9.99992V3.33325C2.66659 3.15644 2.73682 2.98687 2.86185 2.86185C2.98687 2.73682 3.15644 2.66659 3.33325 2.66659H12.6666C12.8434 2.66659 13.013 2.73682 13.138 2.86185C13.263 2.98687 13.3333 3.15644 13.3333 3.33325V12.3933Z","fill","currentColor"],["class","velt-comment-pin-bubble--unread-indicator",4,"ngIf"],[1,"velt-comment-pin-bubble--count"],[1,"velt-comment-pin-bubble--unread-indicator"]],template:function(t,r){t&1&&u(0,jen,9,13,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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);display:flex;cursor:pointer}[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-comment-pin-bubble-container[_ngcontent-%COMP%]{display:flex;padding:var(--velt-spacing-xs);align-items:center;border-radius:var(--velt-border-radius-sm);box-shadow:0 0 1px #4551613d,0 2px 4px #45516124;color:var(--velt-accent-text);gap:var(--velt-spacing-xs);background-color:var(--velt-background-0);font-family:var(--velt-default-font-family)}.velt-comment-pin-bubble--unread-indicator-container[_ngcontent-%COMP%]{position:relative;display:flex}.velt-comment-pin-bubble--unread-indicator[_ngcontent-%COMP%]{position:absolute;top:-2px;right:-2px;display:block;width:8px;height:8px;margin-left:var(--velt-spacing-xs);border-radius:var(--velt-border-radius-full);background-color:var(--velt-error);color:var(--velt-error-foreground)}"],changeDetection:0});let i=o;return i})();var Hen=["commentDialogOverlay"],zen=["commentPinBubbleOverlay"],Gen=["*"],Wen=()=>["snippyly-overlay-panel","velt-comment-pin-bubble-overlay-panel","velt-overlay-panel"],U1e=i=>({trigger:i}),qen=()=>["snippyly-overlay-panel","velt-comment-dialog-overlay-panel","velt-overlay-panel"];function Yen(i,o){i&1&&He(0)}function Ken(i,o){if(i&1&&(v(0),u(1,Yen,1,0,"ng-container",13),C()),i&2){l();let n=me(1);l(2);let e=me(9);m(),d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,U1e,n))}}function Zen(i,o){if(i&1){let n=K();y(0,"div",11,4),P(2,"translate"),W("click",function(t){return N(n),F(t.preventDefault())})("pointerenter",function(t){return N(n),l(3).onBubblePointerOver(t),F(t.stopPropagation())})("pointerleave",function(){N(n);let t=l(3);return F(t.onBubblePointerOut())})("pointerup",function(){N(n);let t=l(3);return F(t.onPointerUpOnBubble())}),y(3,"velt-comment-pin-bubble-internal",12),W("afterViewInit",function(){N(n);let t=l(3);return F(t.onBubbleAfterViewInit())})("onDestroy",function(){N(n);let t=l(3);return F(t.onBubbleOnDestroy())}),b()(),u(4,Ken,2,4,"ng-container",6)}if(i&2){let n=l(2).ngIf;x("role","button")("aria-expanded",n.commentBubbleHover)("aria-label",M(2,5,"Comment bubble")),m(3),d("annotation",n.annotation),m(),d("ngIf",n.isBubbleInitialized)}}function Xen(i,o){if(i&1){let n=K();v(0),u(1,Zen,5,7,"ng-template",10,3,Te),W("positionChange",function(t){N(n);let r=l(2);return F(r.onCommentPinBubblePositionChange(t))}),C()}if(i&2){let n=l().ngIf,e=me(2);m(),d("cdkConnectedOverlayOrigin",e)("cdkConnectedOverlayOpen",!n.annotationDragging&&!!(n!=null&&n.user)&&(n.bubbleOnPinHover&&n.commentPinHover||n.commentBubbleHover||n.commentPinSelected))("cdkConnectedOverlayPanelClass",ut(10,Wen))("cdkConnectedOverlayOffsetY",n.popoverMode?0:n.commentPinBubbleOverlayOriginY==="top"?-8:2)("cdkConnectedOverlayOffsetX",n.popoverMode?n.commentPinBubbleOverlayOriginX==="end"?4:0:n.showCommentIndex&&n.commentPinBubbleOverlayOriginX==="end"?8:0)("cdkConnectedOverlayBackdropClass","velt-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",n.positions)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)}}function Qen(i,o){i&1&&He(0)}function Jen(i,o){if(i&1&&u(0,Qen,1,0,"ng-container",13),i&2){l();let n=me(2),e=me(9);d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,U1e,n))}}function etn(i,o){if(i&1){let n=K();v(0),y(1,"velt-multi-thread-comment-dialog-internal",14),P(2,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment.emit(t))})("updateOverlayPosition",function(){N(n);let t=l(4);return F(t.updateOverlayPosition())})("pointerOutFromCommentDialog",function(t){N(n);let r=l(4);return F(r.onPointerOutFromCommentDialog(t))})("pointerUp",function(t){N(n);let r=l(4);return F(r.onPointerUpOnDialog(t))}),b(),C()}if(i&2){let n=l(3).ngIf,e=l();m(),d("multiThreadAnnotationId",n.annotation==null?null:n.annotation.annotationId)("annotation",n.annotation)("user",n.user)("commentPinSelected",n.commentPinSelected)("containerComponentId",n.containerComponentId)("context",e.context)("readOnly",n.readOnly)("commentPinType",n.commentPinType),x("role","dialog")("aria-label",M(2,10,"Multi-thread comment dialog"))}}function ttn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",15),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment.emit(t))})("updateOverlayPosition",function(){N(n);let t=l(4);return F(t.updateOverlayPosition())})("pointerOutFromCommentDialog",function(t){N(n);let r=l(4);return F(r.onPointerOutFromCommentDialog(t))})("addComment",function(t){N(n);let r=l(4);return F(r.addCommentEmitter.emit(t))})("pointerUp",function(){N(n);let t=l(4);return F(t.onPointerUpOnDialog())}),b()}if(i&2){let n=l(3).ngIf;d("annotation",n.annotation)("user",n.user)("commentPinSelected",n.commentPinSelected)("containerComponentId",n.containerComponentId)("readOnly",n.readOnly)("commentPinType",n.commentPinType),x("role","dialog")("aria-label",M(1,8,"Comment dialog"))}}function ntn(i,o){if(i&1&&u(0,etn,3,12,"ng-container",8)(1,ttn,2,10,"ng-template",null,2,Te),i&2){let n=me(2),e=l(2).ngIf;d("ngIf",(e==null||e.annotation==null?null:e.annotation.type)==="multiThread")("ngIfElse",n)}}function itn(i,o){if(i&1){let n=K();u(0,ntn,3,2,"ng-template",10,5,Te),W("positionChange",function(t){N(n);let r=l(2);return F(r.onCommentDialogPositionChange(t))})}if(i&2){let n=o.trigger,e=l().ngIf;d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",(!e.commentBubbleAvailable||e.commentPinType==="bubble")&&!!(e!=null&&e.user)&&!e.annotationDragging&&(!e.isPhone||!e.mobileMode)&&!e.dialogOpenedInSidebar&&!e.streamMode&&!e.inboxMode&&e.floatingCommentsEnabled&&(e.commentPinSelected&&(e.commentPinType!=="bubble"||e.openDialog)||e.dialogOnHover&&(e.bubbleOnPin?e.commentBubbleHover:e.commentPinHover)&&(e.commentPinType!=="bubble"||e.openDialog)||e.commentPinType==="bubble"&&e.commentBubbleTargetPinHover&&e.openDialog))("cdkConnectedOverlayPanelClass",ut(10,qen))("cdkConnectedOverlayOffsetY",e.popoverMode?0:e.commentDialogOverlayOriginY==="top"?-8:2)("cdkConnectedOverlayOffsetX",e.popoverMode?e.commentDialogOverlayOriginX==="end"?4:0:e.showCommentIndex&&e.commentDialogOverlayOriginX==="end"?8:0)("cdkConnectedOverlayBackdropClass","velt-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",e.positions)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)}}function otn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-bottom-sheet",16),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(2);return F(r.saveComment.emit(t))}),b()}if(i&2){let n=l().ngIf;d("annotation",n.annotation)("user",n.user),x("role","dialog")("aria-label",M(1,4,"Comment bottom sheet"))}}function rtn(i,o){if(i&1){let n=K();v(0),y(1,"div",7,0),P(3,"translate"),W("click",function(t){return N(n),F(t.preventDefault())})("pointerenter",function(t){return N(n),l().onPointerOver(t),F(t.stopPropagation())})("pointerleave",function(){N(n);let t=l();return F(t.onPointerOut())}),jt(4),b(),u(5,Xen,3,11,"ng-container",8)(6,Jen,1,4,"ng-template",null,1,Te)(8,itn,2,11,"ng-template",null,2,Te)(10,otn,2,6,"snippyly-comment-bottom-sheet",9),C()}if(i&2){let n=o.ngIf,e=me(7),t=l();m(),x("data-testid",t.componentId+"-trigger")("role","button")("aria-expanded",n.commentPinSelected)("aria-haspopup","dialog")("aria-label",M(3,8,"Comment pin")),m(4),d("ngIf",n.bubbleOnPin&&!n.commentBubbleAvailable&&!n.dialogOpenedInSidebar)("ngIfElse",e),m(5),d("ngIf",(n==null?null:n.user)&&n.mobileMode&&n.isPhone&&!n.sidebarVisible&&!n.dialogOpenedInSidebar&&!n.inboxMode&&!n.streamMode&&n.floatingCommentsEnabled&&n.commentPinSelected)}}var Y1=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.breakpointObserver=e,this.commentService=t,this.domService=r,this.loggingService=a,this.elementRef=s,this.commentPinPortalService=c,this.commentPinSelected=!1,this.annotationDragging=!1,this.commentPinType="pin",this.commentBubbleTargetPinHover=!1,this.showBubbleOnHover=!1,this.bubbleOnPin=!1,this.bubbleOnPinHover=!1,this.readOnly=!1,this.openDialog=!0,this.saveComment=new Me,this.togglePinSelection=new Me,this.commentTargetElementClicked=new Me,this.addCommentEmitter=new Me,this.isDialogOnHoverEnabled=!1,this.isDialogOnTargetElementClickEnabled=!1,this.previouslySelectedAnnotations={},this.eventListenersSubscriptions=[],this.customScrollableParentEventsListenersSubscriptions=[],this.componentConfigSignal=xe({bubbleOnPin:!1,bubbleOnPinHover:!1,dialogOnHover:!1,commentBubbleAvailable:!1,commentPinHover:!1,commentBubbleHover:!1,commentPinSelected:!1,popoverMode:!1,showCommentIndex:!1,commentBubbleTargetPinHover:!1,isBubbleInitialized:!1,annotationDragging:!1,commentPinBubbleOverlayOriginX:"start",commentPinBubbleOverlayOriginY:"top",positions:[],annotation:void 0,commentPinType:"pin",isPhone:!1,mobileMode:!1,streamMode:!1,inboxMode:!1,floatingCommentsEnabled:!1,sidebarVisible:!1,dialogOpenedInSidebar:!1,readOnly:!1,openDialog:!0,commentDialogOverlayOriginX:"start",commentDialogOverlayOriginY:"top",user:void 0}),this.subscriptions=[],this.componentId="velt-comment-dialog-portal";try{this.loggingService.log("%c[WB] Creating COMPONENT CommentDialogPortalComponent","color: blue;"),this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(p=>{p.matches?this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!0}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!1}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent breakpointObserver subscription: ",p)})),this.subscriptions.push(this.commentService.getSidebarVisibility$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{sidebarVisible:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getSidebarVisibility$ subscription: ",p)})),this.subscriptions.push(this.commentService.getMobileMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{mobileMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getMobileMode$ subscription: ",p)})),this.subscriptions.push(this.commentService.getShowCommentIndex().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{showCommentIndex:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getShowCommentIndex subscription: ",p)})),this.subscriptions.push(this.commentService.getStreamMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{streamMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getStreamMode$ subscription: ",p)})),this.subscriptions.push(this.commentService.getInboxMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{inboxMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getInboxMode subscription: ",p)})),this.subscriptions.push(this.domService.getDialogOpenedInSidebar().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{dialogOpenedInSidebar:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getDialogOpenedInSidebar subscription: ",p)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{popoverMode:p}),g)),this.componentConfigSignal().popoverMode?this.componentConfigSignal.update(g=>(g=D(E({},g),{positions:U.OVERLAY_POSITIONS_FOR_POPOVER_MODE.map(f=>new di({originX:f.originX,originY:f.originY},{overlayX:f.overlayX,overlayY:f.overlayY}))}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{positions:U.OVERLAY_POSITIONS.map(f=>new di({originX:f.originX,originY:f.originY},{overlayX:f.overlayX,overlayY:f.overlayY}))}),g)),this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getPopoverMode subscription: ",p)})),this.subscriptions.push(this.commentService.showFloatingComments$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{floatingCommentsEnabled:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent showFloatingComments$ subscription: ",p)})),this.subscriptions.push(this.commentService.getEnableDialogOnHover$().subscribe(p=>{this.isDialogOnHoverEnabled=p,this.componentConfigSignal.update(g=>(g=D(E({},g),{dialogOnHover:p}),g)),this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getEnableDialogOnHover subscription: ",p)})),this.subscriptions.push(this.commentService.getEnableDialogOnTargetElementClick$().subscribe(p=>{this.isDialogOnTargetElementClickEnabled=p,this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getEnableDialogOnTargetElementClick subscription: ",p)})),this.subscriptions.push(this.commentService.getBubbleCommentAnnotationIds$().subscribe(p=>{if(p.includes(this.componentConfigSignal().annotation?.annotationId)){this.commentBubbleElement=this.commentService.getCommentBubbleElement(this.componentConfigSignal().annotation);let g=this.commentBubbleElement?.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_ID)||"";this.commentBubbleElementAnnotationId!==g&&(this.commentBubbleElementAnnotationId=g,this.componentConfigSignal.update(f=>(f=D(E({},f),{commentBubbleAvailable:!0}),f)))}else this.componentConfigSignal().commentBubbleAvailable&&(this.commentBubbleElement=null,this.commentBubbleElementAnnotationId="",this.componentConfigSignal.update(g=>(g=D(E({},g),{commentBubbleAvailable:!1}),g)))},p=>{this.catchError("Error in CommentDialogPortalComponent getBubbleCommentAnnotationIds$ subscription: ",p)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().pipe(Oi()).subscribe(([p,g])=>{this.previouslySelectedAnnotations=p||{},g&&!g[this.componentConfigSignal().annotation?.annotationId]&&this.componentConfigSignal().commentPinHover&&this.setCommentPinHover(!1)},p=>{this.catchError("Error in CommentDialogPortalComponent getSelectedAnnotationsMap$ subscription: ",p)}))}catch(p){this.catchError("Error in CommentDialogPortalComponent constructor: ",p)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentDialogPortalComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentDialogPortalComponent setupA11yAttributes:",e)}}ngAfterViewInit(){try{this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement()}catch(e){this.catchError("Error in CommentDialogPortalComponent AfterViewInit: ",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.commentPinSelected&&(this.componentConfigSignal().commentPinSelected&&this.setCommentPinHover(!1),this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement()),e?.targetElement&&(this.addEventListeners(),this.targetElement?this.setCustomScrollableParents(Ug(this.targetElement)):this.setCustomScrollableParents([]))}catch(t){this.catchError("Error in CommentDialogPortalComponent ngOnChanges: ",t)}}onBubbleAfterViewInit(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{isBubbleInitialized:!0}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubbleAfterViewInit: ",e)}}onBubbleOnDestroy(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{isBubbleInitialized:!1}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubbleOnDestroy: ",e)}}onCommentPinBubblePositionChange(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinBubbleOverlayOriginX:e.connectionPair.originX,commentPinBubbleOverlayOriginY:e.connectionPair.originY}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onCommentPinBubblePositionChange: ",t)}}onCommentDialogPositionChange(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentDialogOverlayOriginX:e.connectionPair.originX,commentDialogOverlayOriginY:e.connectionPair.originY}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onCommentDialogPositionChange: ",t)}}updateOverlayPosition(){try{this.loggingService.log("updateOverlayPosition",this.componentConfigSignal().annotation?.annotationId),this.commentPinBubbleOverlay&&this.commentPinBubbleOverlay?.overlayRef?.updatePosition(),this.commentDialogOverlay&&this.commentDialogOverlay?.overlayRef?.updatePosition()}catch{}}onPointerOutFromCommentDialog(e){try{!this.targetElement?.contains(e?.relatedTarget)&&!this.componentConfigSignal().commentPinSelected&&this.onPointerOut()}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerOutFromCommentDialog: ",t)}}onPointerOut(){try{this.componentConfigSignal().bubbleOnPin?setTimeout(()=>{this.setCommentPinHover(!1)},500):this.setCommentPinHover(!1)}catch(e){this.catchError("Error in CommentDialogPortalComponent onPointerOut: ",e)}}setCommentPinHover(e){try{e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.componentConfigSignal.update(r=>(r=D(E({},r),{commentPinHover:e}),r)),this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement();let t=this.commentBubbleElementRef?.nativeElement||this.commentBubbleElement;t&&(this.componentConfigSignal().commentPinHover?t.setAttribute("comment-bubble-target-pin-hover","true"):t.removeAttribute("comment-bubble-target-pin-hover"))}catch(t){this.catchError("Error in CommentDialogPortalComponent setCommentPinHover: ",t)}}addEventListeners(){try{this.removeEventListeners(),this.componentConfigSignal().popoverMode&&this.targetElement&&this.isDialogOnTargetElementClickEnabled&&this.componentConfigSignal().commentPinType!=="bubble"&&(this.isDialogOnHoverEnabled&&(this.eventListenersSubscriptions.push(vi(this.targetElement,"pointerover").subscribe(e=>{this.onPointerOver(e),e.stopPropagation()},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners pointerover subscription: ",e)})),this.eventListenersSubscriptions.push(vi(this.targetElement,"pointerout").subscribe(e=>{!this.targetElement?.contains(e?.relatedTarget)&&!e?.relatedTarget?.closest(U.TAGS.SNIPPYLY_COMMENT_DIALOG)&&this.onPointerOut()},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners pointerout subscription: ",e)}))),this.eventListenersSubscriptions.push(vi(this.targetElement,"click").subscribe(e=>{this.previouslySelectedAnnotations[this.componentConfigSignal().annotation?.annotationId]||(this.commentTargetElementClicked.emit(),e.stopPropagation())},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners click subscription: ",e)})))}catch(e){this.catchError("Error in CommentDialogPortalComponent addEventListeners: ",e)}}removeEventListeners(){try{this.eventListenersSubscriptions.map(e=>{e.unsubscribe()}),this.eventListenersSubscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent removeEventListeners: ",e)}}updateHighlightOnElement(){try{this.targetElement&&(this.componentConfigSignal().commentPinSelected||this.componentConfigSignal().commentPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(e){this.catchError("Error in CommentDialogPortalComponent updateHighlightOnElement: ",e)}}updateCommentActiveAttributeOnElement(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateCommentActiveAttributeOnElement","color: green;"),this.componentConfigSignal().commentPinSelected||this.componentConfigSignal().commentPinHover)this.targetElement&&(this.targetElement?.hasAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)||this.targetElement?.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE,"true"));else if(this.targetElement&&this.targetElement?.hasAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)){let e=this.commentPinPortalService.getAnnotationIdsByUserTargetElement(this.targetElement),t=!1;if(e&&e.length>0){let r=this.domService.getSelectedAnnotationsMap();e.forEach(a=>{if(r?.[a]){t=!0;return}})}t||this.targetElement?.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)}}catch(e){this.catchError("Error in CommentDialogPortalComponent onCommentFocusChange: ",e)}}onPointerUpOnDialog(e){try{(!this.componentConfigSignal().commentPinSelected||e)&&this.togglePinSelection.emit(e)}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerUpOnDialog: ",t)}}onPointerOver(e){try{if(this.componentConfigSignal().commentPinHover)return;e.buttons?this.componentConfigSignal().commentPinHover&&this.setCommentPinHover(!1):!this.componentConfigSignal().commentPinHover&&(this.componentConfigSignal().bubbleOnPin?this.componentConfigSignal().bubbleOnPinHover:this.isDialogOnHoverEnabled)&&this.setCommentPinHover(!0)}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerOver: ",t)}}setCustomScrollableParents(e){try{this.customScrollableParents=e,this.addCustomScrollableParentsEventListeners()}catch(t){this.catchError("Error in CommentDialogPortalComponent setCustomScrollableParents: ",t)}}addCustomScrollableParentsEventListeners(){try{this.removeCustomScrollableParentsEventListeners(),this.customScrollableParents?.length&&this.customScrollableParents?.forEach(e=>{this.customScrollableParentEventsListenersSubscriptions.push(vi(e,"scroll",{passive:!0}).subscribe(t=>{this.updateOverlayPosition()},t=>{this.catchError("Error in CommentDialogPortalComponent addCustomScrollableParentsEventListeners scroll subscription: ",t)}))})}catch(e){this.catchError("Error in CommentDialogPortalComponent addCustomScrollableParentsEventListeners: ",e)}}removeCustomScrollableParentsEventListeners(){try{this.customScrollableParentEventsListenersSubscriptions.map(e=>{e.unsubscribe()}),this.customScrollableParentEventsListenersSubscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent removeCustomScrollableParentsEventListeners: ",e)}}onBubblePointerOver(e){try{if(this.componentConfigSignal().commentBubbleHover)return;e.buttons||this.componentConfigSignal.update(t=>(t=D(E({},t),{commentBubbleHover:!0}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onBubblePointerOver: ",t)}}onBubblePointerOut(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{commentBubbleHover:!1}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubblePointerOut: ",e)}}onPointerUpOnBubble(){try{this.componentConfigSignal().commentPinSelected||this.togglePinSelection.emit()}catch(e){this.catchError("Error in CommentDialogPortalComponent onPointerUpOnBubble: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.catchError("Error in CommentDialogPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.removeEventListeners(),this.removeCustomScrollableParentsEventListeners(),this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent unsubscribe: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(wo),h(we),h(Be),h(_),h(R),h(q1))},o.\u0275cmp=O({type:o,selectors:[["velt-comment-dialog-portal-internal"]],viewQuery:function(t,r){if(t&1&&(it(Hen,5),it(zen,5)),t&2){let a;Je(a=et())&&(r.commentDialogOverlay=a.first),Je(a=et())&&(r.commentPinBubbleOverlay=a.first)}},inputs:{annotation:"annotation",context:"context",commentPinSelected:"commentPinSelected",annotationDragging:"annotationDragging",commentPinType:"commentPinType",commentBubbleTargetPinHover:"commentBubbleTargetPinHover",user:"user",targetElement:"targetElement",showBubbleOnHover:"showBubbleOnHover",bubbleOnPin:"bubbleOnPin",bubbleOnPinHover:"bubbleOnPinHover",containerComponentId:"containerComponentId",readOnly:"readOnly",openDialog:"openDialog",commentBubbleElementRef:"commentBubbleElementRef"},outputs:{saveComment:"saveComment",togglePinSelection:"togglePinSelection",commentTargetElementClicked:"commentTargetElementClicked",addCommentEmitter:"addComment"},standalone:!1,features:[Ze],ngContentSelectors:Gen,decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["defaultDialogViewRef",""],["commentDialogRef",""],["commentPinBubbleOverlay","cdkConnectedOverlay"],["bubbleOnHoverTrigger","cdkOverlayOrigin"],["commentDialogOverlay","cdkConnectedOverlay"],[4,"ngIf"],["cdkOverlayOrigin","",3,"click","pointerenter","pointerleave"],[4,"ngIf","ngIfElse"],[3,"annotation","user","saveComment",4,"ngIf"],["cdkConnectedOverlay","",3,"positionChange","cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayOffsetY","cdkConnectedOverlayOffsetX","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayLockPosition","cdkConnectedOverlayPositions","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayDisableClose"],["cdkOverlayOrigin","",3,"click","pointerenter","pointerleave","pointerup"],["veltAfterViewInit","",3,"afterViewInit","onDestroy","annotation"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"saveComment","updateOverlayPosition","pointerOutFromCommentDialog","pointerUp","multiThreadAnnotationId","annotation","user","commentPinSelected","containerComponentId","context","readOnly","commentPinType"],[3,"saveComment","updateOverlayPosition","pointerOutFromCommentDialog","addComment","pointerUp","annotation","user","commentPinSelected","containerComponentId","readOnly","commentPinType"],[3,"saveComment","annotation","user"]],template:function(t,r){t&1&&(Ht(),u(0,rtn,11,10,"ng-container",6)),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,ar,J7,yu,V1e,Rs,ge],encapsulation:2,changeDetection:0});let i=o;return i})();var atn=["pinRef"],stn=["commentDialogPortalRef"],ltn=["*"],H1e=i=>({componentConfigSignal:i}),ctn=(i,o)=>({condition:i,data:o}),$1e=()=>["bubble","chart"],dtn=(i,o,n,e,t)=>({template:i,context:o,componentName:"velt-comment-pin-wireframe",variant:n,setIfCondition:e,componentElementRef:t}),mtn=(i,o,n)=>({"velt-comment-pin--status-default":i,"velt-comment-pin--status-ongoing":o,"velt-comment-pin--status-terminal":n});function ptn(i,o){i&1&&He(0)}function gtn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,ptn,1,0,"ng-container",11),b()),i&2){l();let n=me(3),e=l(2);x("data-testid",e.componentId+"-shadow-dom"),m(),d("ngTemplateOutlet",n)}}function utn(i,o){if(i&1){let n=K();v(0),y(1,"div",14),W("click",function(t){return N(n),F(t.preventDefault())}),jt(2),b(),C()}i&2&&(m(),x("role","presentation"))}function htn(i,o){if(i&1&&(v(0),w(1,"app-comment-pin-triangle",15),C()),i&2){let n=l(5);m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.triangleTemplate)}}function ftn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",21)(2,"path",22),b())}function vtn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",23)(2,"path",24),b())}function Ctn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",25)(2,"path",26),b())}function _tn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",27)(2,"path",28),b())}function ytn(i,o){if(i&1&&(v(0)(1,18),u(2,ftn,3,0,"svg",19)(3,vtn,3,0,"svg",19)(4,Ctn,3,0,"svg",19)(5,_tn,3,0,"svg",19),C()()),i&2){let n=l(6).ngIf;m(),d("ngSwitch",n.annotation==null||n.annotation.pageInfo==null||n.annotation.pageInfo.deviceInfo==null?null:n.annotation.pageInfo.deviceInfo.deviceType),m(),d("ngSwitchCase","Mobile"),m(),d("ngSwitchCase","Tablet"),m(),d("ngSwitchCase","Desktop"),m(),d("ngSwitchCase","Monitor")}}function Stn(i,o){if(i&1&&w(0,"snippyly-user-avatar",29),i&2){let n=l(6).ngIf;d("user",n.annotation==null?null:n.annotation.from)}}function btn(i,o){if(i&1&&(v(0),w(1,"app-comment-pin-unread-comment-indicator",15),C()),i&2){let n=l(7);m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.unreadCommentIndicatorTemplate)}}function Itn(i,o){if(i&1&&w(0,"app-comment-pin-number",15)(1,"app-comment-pin-ghost-comment-indicator",15)(2,"app-comment-pin-private-comment-indicator",15),i&2){let n=l(7);d("componentConfigSignal",n.componentConfigSignal)("template",n.indexTemplate),m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.ghostCommentIndicatorTemplate),m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.privateCommentIndicatorTemplate)}}function Etn(i,o){if(i&1){let n=K();v(0),y(1,"div",17,5),W("click",function(t){return N(n),F(t.preventDefault())}),u(3,ytn,6,5,"ng-container",10)(4,Stn,1,1,"ng-template",null,6,Te)(6,btn,2,2,"ng-container",10)(7,Itn,3,6,"ng-template",null,7,Te),b(),C()}if(i&2){let n=me(5),e=me(8),t=l(5).ngIf,r=l();m(),at("--velt-internal-comment-pin-bg-color",(t.annotation==null||t.annotation.status==null?null:t.annotation.status.color)||null),pe("velt-comment-pin--marker-transparent",r.usingCustomCommentPin)("velt-comment-pin--marker-default",!r.usingCustomCommentPin),d("ngClass",$e(12,mtn,!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="default",!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="ongoing",!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="terminal")),x("role","presentation"),m(2),d("ngIf",t.isDeviceIndicatorOnCommentPinsEnabled&&t.isCommentAddedOnDifferentDeviceType)("ngIfElse",n),m(3),d("ngIf",!(t.user!=null&&t.user.isGuest)&&!(t.user!=null&&t.user.isAnonymous)&&(t==null||t.unreadCommentsMap==null?null:t.unreadCommentsMap[t.annotation==null?null:t.annotation.annotationId]))("ngIfElse",e)}}function xtn(i,o){if(i&1){let n=K();y(0,"div",14),W("click",function(t){return N(n),F(t.preventDefault())}),u(1,Etn,9,16,"ng-container",16),b()}if(i&2){let n=l(4).ngIf,e=l();x("role","presentation"),m(),d("veltDynamicTemplate",$(4,dtn,e.template,A(2,H1e,e.componentConfigSignal),n==null?null:n.variant,e.setIfCondition.bind(e),e.elementRef))}}function Ttn(i,o){if(i&1&&u(0,htn,2,2,"ng-container",10)(1,xtn,2,10,"ng-template",null,4,Te),i&2){let n=me(2),e=l(3).ngIf;d("ngIf",e.popoverMode)("ngIfElse",n)}}function Dtn(i,o){if(i&1){let n=K();y(0,"velt-comment-dialog-portal-internal",12,1),W("saveComment",function(t){N(n);let r=l(3);return F(r.saveComment.emit(t))})("togglePinSelection",function(t){N(n);let r=l(3);return F(r.onPinBubblePointerUp(t))})("pointerUp",function(){N(n);let t=l(3);return F(t.onPointerUpOnDialog())}),y(2,"div",13,2),u(4,utn,3,1,"ng-container",10)(5,Ttn,3,2,"ng-template",null,3,Te),b()()}if(i&2){let n=me(6),e=l(2).ngIf,t=l();d("annotation",e.annotation)("user",e.user)("commentPinSelected",e.commentPinSelected)("annotationDragging",e.annotationDragging)("commentPinType",e.commentPinType)("targetElement",e.targetElement)("bubbleOnPin",e.bubbleOnPin)("bubbleOnPinHover",e.bubbleOnPinHover)("containerComponentId",e.containerComponentId),m(2),at("--velt-internal-comment-pin-max-width",t.pinMaxWidth),pe("velt-comment-pin--ghost",!!(e.annotation!=null&&e.annotation.ghostComment))("velt-comment-pin--different-device",e.isDeviceIndicatorOnCommentPinsEnabled&&e.isCommentAddedOnDifferentDeviceType)("velt-comment-pin--outside-viewport",!e.annotationDragging&&t.isOutsideViewport)("velt-comment-pin-open",e.commentPinSelected&&!e.annotationDragging)("velt-comment-pin-unread-comment",!(e.user!=null&&e.user.isGuest)&&!(e.user!=null&&e.user.isAnonymous)&&(e==null||e.unreadCommentsMap==null?null:e.unreadCommentsMap[e.annotation==null?null:e.annotation.annotationId]))("velt-display-none",e.commentPinType!=="bubble"&&e.commentBubbleElementAnnotationId&&e.commentBubbleElementAnnotationId!==(e.annotation==null?null:e.annotation.annotationId)),x("data-testid",t.componentId)("role","button")("aria-expanded",e.commentPinSelected),m(2),d("ngIf",e.commentPinType==="bubble"||e.commentPinType==="chart")("ngIfElse",n)}}function wtn(i,o){if(i&1&&(v(0),u(1,gtn,2,2,"velt-shadow-dom-internal",10)(2,Dtn,7,28,"ng-template",null,0,Te),C()),i&2){let n=me(3),e=l().ngIf,t=l();m(),d("ngIf",!t.template&&t.pinShadowDOM&&!(ut(2,$1e)!=null&&ut(3,$1e).includes(e.commentPinType)))("ngIfElse",n)}}function Otn(i,o){if(i&1&&(v(0),u(1,wtn,4,4,"ng-container",9),C()),i&2){let n=l();m(),d("veltIf",k(3,ctn,n.conditionSignal(),A(1,H1e,n.componentConfigSignal)))}}var Eu=(()=>{let o=class o extends c7{constructor(e,t,r,a,s,c,p){super(c,p,r),this.commentService=e,this.domService=t,this.loggingService=r,this.commentPinPortalService=a,this.wireframeService=s,this.elementRef=c,this.dynamicDataService=p,this.commentPinSelected=!1,this.annotationDragging=!1,this.commentPinType="pin",this.usingCustomCommentPin=!1,this.multipleCommentPinsSelected=!1,this.avatarErrorImage="",this.saveComment=new Me,this.pinShadowDOM=!1,this.subscriptions=[],this.commentTargetElementClicked=new Me,this.togglePinSelection=new Me,this.commentBubbleAvailable=!1,this.commentPinPosition={top:0,left:0},this.isOutsideViewport=!1,this.pinMaxWidth="",this.previouslySelectedAnnotations={},this.deviceInfo=new Yn,this.COMMENT_PIN_SIZE=40,this.componentConfigSignal=xe({isGhostComment:!1,isPrivateComment:!1,showCommentIndex:!1,bubbleOnPin:!1,bubbleOnPinHover:!1,commentPinSelected:!1,annotationDragging:!1,popoverMode:!1,isDeviceIndicatorOnCommentPinsEnabled:!1,isCommentAddedOnDifferentDeviceType:!1,annotation:this.annotation,user:this.user,unreadCommentsMap:null,popoverTriangleComponent:!1}),this.veltElement=!0,this.componentId="velt-comment-pin",this.loggingService.log("%c[WB] Creating COMPONENT CommentPinComponent","color: blue;"),this.subscriptions.push(this.domService.getDeviceInfo$().subscribe(g=>{this.deviceInfo=g,this.checkIfCommentAddedOnDifferentDeviceType()})),this.subscriptions.push(this.commentService.getShowCommentIndex().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{showCommentIndex:g}),f))},g=>{this.catchError("Error in CommentPinComponent getShowCommentIndex subscription: ",g)})),this.subscriptions.push(this.commentService.getBubbleOnPin$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{bubbleOnPin:g}),f))},g=>{this.catchError("Error in CommentPinComponent getBubbleOnPin subscription: ",g)})),this.subscriptions.push(this.commentService.getBubbleOnPinHover$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{bubbleOnPinHover:g}),f))},g=>{this.catchError("Error in CommentPinComponent getBubbleOnPinHover subscription: ",g)})),this.subscriptions.push(this.commentService.getPopoverTriangleComponent$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{popoverTriangleComponent:g}),f))},g=>{this.catchError("Error in CommentPinComponent getPopoverTriangleComponent$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPinShadowDOM$().subscribe(g=>{this.pinShadowDOM=g},g=>{this.catchError("Error in CommentPinComponent getPinShadowDOM$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPinDarkMode$().subscribe(g=>{g!==null&&(g?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark"))},g=>{this.catchError("Error in CommentPinComponent pinDarkMode$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{popoverMode:g}),f))},g=>{this.catchError("Error in CommentPinComponent getPopoverMode subscription: ",g)})),this.subscriptions.push(this.commentService.getDeviceIndicatorOnCommentPins$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{isDeviceIndicatorOnCommentPinsEnabled:g}),f))},g=>{this.catchError("Error in CommentPinComponent getDeviceIndicatorOnCommentPins subscription: ",g)})),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{unreadCommentsMap:g}),f))})),this.subscriptions.push(this.commentService.getCustomStatusesShown$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{customStatusesShown:g}),f))}))}ngOnInit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;"),super.ngOnInit(),this.setupA11yAttributes(),!this.template){let e="velt-comment-pin-wireframe";this.variant&&(e+=`---${this.variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r,this.getChildTemplate()}}))}this.getChildTemplate()}catch(e){this.catchError("Error in CommentsToolComponent OnInit: ",e)}}getChildTemplate(){try{if(!this.ghostCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-ghost-comment-indicator-wireframe");Ye(e)||(this.ghostCommentIndicatorTemplate=e)}if(!this.indexTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-index-wireframe");Ye(e)||(this.indexTemplate=e)}if(!this.numberTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-number-wireframe");Ye(e)||(this.numberTemplate=e)}if(!this.privateCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-private-comment-indicator-wireframe");Ye(e)||(this.privateCommentIndicatorTemplate=e)}if(!this.triangleTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-triangle-wireframe");Ye(e)||(this.triangleTemplate=e)}if(!this.unreadCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-unread-comment-indicator-wireframe");Ye(e)||(this.unreadCommentIndicatorTemplate=e)}}catch(e){this.loggingService.catch("Error in CommentPinComponent getChildTemplate: ",e)}}ngAfterViewInit(){try{this.subscriptions.push(this.commentPinPortalService.getCommentPinTemplate$().subscribe(e=>{if(e!==null){let t=e?.cloneNode(!0);if(t.setAttribute("slot","comment-pin"),this.pinRef!==void 0){this.pinRef.nativeElement.appendChild(t);let r=g_(this.componentConfigSignal().annotation);this.injectAttributeData(t,r),this.usingCustomCommentPin=!0,this.commentPinPortalService.emitCustomPinEvent({annotation:this.componentConfigSignal().annotation,element:t}),this.pinRef.nativeElement.childNodes.forEach(a=>{a?.tagName?.toLowerCase()===U.TAGS.SNIPPYLY_USER_AVATAR&&a.remove()})}}else this.usingCustomCommentPin=!1})),this.subscriptions.push(this.commentService.getBubbleCommentAnnotationIds$().subscribe(e=>{if(e.includes(this.componentConfigSignal().annotation?.annotationId)){this.commentBubbleElement=this.commentService.getCommentBubbleElement(this.componentConfigSignal().annotation);let t=this.commentBubbleElement?.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_ID)||"";this.componentConfigSignal().commentBubbleElementAnnotationId!==t&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{commentBubbleElementAnnotationId:t}),r)),this.commentBubbleAvailable=!0)}else this.commentBubbleAvailable&&(this.commentBubbleElement=null,this.componentConfigSignal.update(t=>(t=D(E({},t),{commentBubbleElementAnnotationId:""}),t)),this.commentBubbleAvailable=!1)},e=>{this.catchError("Error in CommentPinComponent getBubbleCommentAnnotationIds$ subscription: ",e)}))}catch(e){this.catchError("Error in CommentPinComponent AfterViewInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{if(e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.annotation){if(this.commentService.customPinsById.has(this.componentConfigSignal().annotation.annotationId)){let r=this.commentService.getCustomPinById(this.componentConfigSignal().annotation.annotationId);if(r!==void 0){let a=g_(this.componentConfigSignal().annotation);this.injectAttributeData(r,a)}}this.setUserInitial(),this.componentConfigSignal.update(r=>(r=D(E({},r),{isPrivateComment:this.componentConfigSignal().annotation?.iam?.accessMode===uo.PRIVATE,isGhostComment:!!this.componentConfigSignal().annotation?.ghostComment}),r)),this.checkIfCommentAddedOnDifferentDeviceType();let t=JSON.parse(JSON.stringify(this.commentPinPosition||{}));this.commentPinPosition={top:this.componentConfigSignal().annotation?.position?.top||0,left:this.componentConfigSignal().annotation?.position?.left||0}}}catch(t){this.catchError("Error in CommentPinComponent ngOnChanges: ",t)}}detectCommentPinOutsideViewport(){try{this.loggingService.log("%c[WB] Calling FUNCTION: detectCommentPinOutsideViewport","color: green;");let e=this.pinRef?.nativeElement;if(e){let t=e?.getBoundingClientRect(),r=Math.max(document?.documentElement?.clientWidth||0,window?.innerWidth||0);if(t?.right>r){let a=r-t.left;a>0?(this.pinMaxWidth=`${a}px`,this.isOutsideViewport=!0):(this.isOutsideViewport=!1,this.pinMaxWidth="")}else this.isOutsideViewport=!1,this.pinMaxWidth=""}else this.isOutsideViewport=!1}catch(e){this.catchError("Error in CommentPinComponent detectCommentPinOutsideViewport: ",e)}}checkIfCommentAddedOnDifferentDeviceType(){try{this.componentConfigSignal().annotation?.pageInfo?.deviceInfo?.deviceType!==this.deviceInfo.deviceType?(this.componentConfigSignal.update(e=>(e=D(E({},e),{isCommentAddedOnDifferentDeviceType:!0}),e)),this.COMMENT_PIN_SIZE=34):(this.componentConfigSignal.update(e=>(e=D(E({},e),{isCommentAddedOnDifferentDeviceType:!1}),e)),this.COMMENT_PIN_SIZE=40)}catch(e){this.catchError("Error in CommentPinComponent checkIfCommentAddedOnDifferentDeviceType: ",e)}}updateOverlayPosition(){try{this.loggingService.log("updateOverlayPosition",this.componentConfigSignal().annotation?.annotationId),this.commentDialogPortalRef?.updateOverlayPosition()}catch(e){this.catchError("Error in CommentPinComponent updateOverlayPosition: ",e)}}onPointerUpOnDialog(){try{this.componentConfigSignal().commentPinSelected||this.togglePinSelection.emit()}catch(e){this.catchError("Error in CommentPinComponent onPointerUpOnDialog: ",e)}}onPinBubblePointerUp(e){try{(!this.componentConfigSignal().commentPinSelected||e)&&this.togglePinSelection.emit(e)}catch(t){this.catchError("Error in CommentPinComponent onPointerUpOnDialog: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(e){this.catchError("Error in CommentPinComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentPinComponent unsubscribe: ",e)}}setUserInitial(){try{this.userInitial=this.componentConfigSignal().annotation?.from?.initial||(this.componentConfigSignal().annotation?.from?.name?this.componentConfigSignal().annotation.from.name?.charAt(0).toUpperCase():this.componentConfigSignal().annotation?.from?.email?.charAt(0).toUpperCase()||"")}catch(e){this.catchError("Error in CommentPinComponent setUserInitial: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(Be),h(_),h(q1),h(Ge),h(R),h(S))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-pin"]],viewQuery:function(t,r){if(t&1&&(it(atn,5),it(stn,5)),t&2){let a;Je(a=et())&&(r.pinRef=a.first),Je(a=et())&&(r.commentDialogPortalRef=a.first)}},hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{annotation:"annotation",commentPinSelected:"commentPinSelected",annotationDragging:"annotationDragging",commentPinType:"commentPinType",multipleCommentPinsSelected:"multipleCommentPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",variant:"variant",containerComponentId:"containerComponentId",targetElement:"targetElement"},outputs:{saveComment:"saveComment",commentTargetElementClicked:"commentTargetElementClicked",togglePinSelection:"togglePinSelection"},standalone:!1,features:[V([S]),L,Ze],ngContentSelectors:ltn,decls:1,vars:1,consts:[["commentPinContainerRef",""],["commentDialogPortalRef",""],["trigger","cdkOverlayOrigin"],["normalPinRef",""],["defaultPinRef",""],["pinRef",""],["userAvatarRef",""],["readCommentIndicatorsRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],[3,"saveComment","togglePinSelection","pointerUp","annotation","user","commentPinSelected","annotationDragging","commentPinType","targetElement","bubbleOnPin","bubbleOnPinHover","containerComponentId"],["id","comment-pin-block","cdkOverlayOrigin","",1,"velt-comment-pin"],[3,"click"],[3,"componentConfigSignal","template"],[4,"veltDynamicTemplate"],[1,"velt-comment-pin--marker",3,"click","ngClass"],[3,"ngSwitch"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngSwitchCase"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M12.0357 1.5H5.96429C5.29365 1.5 4.75 2.17157 4.75 3V15C4.75 15.8284 5.29365 16.5 5.96429 16.5H12.0357C12.7063 16.5 13.25 15.8284 13.25 15V3C13.25 2.17157 12.7063 1.5 12.0357 1.5Z","stroke","white","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"],["d","M9 13.5H9.0075","stroke","white","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"],["fill-rule","evenodd","clip-rule","evenodd","d","M12.75 1.5H5.25C4.83579 1.5 4.5 1.83579 4.5 2.25V15.75C4.5 16.1642 4.83579 16.5 5.25 16.5H12.75C13.1642 16.5 13.5 16.1642 13.5 15.75V2.25C13.5 1.83579 13.1642 1.5 12.75 1.5ZM5.25 0C4.00736 0 3 1.00736 3 2.25V15.75C3 16.9926 4.00736 18 5.25 18H12.75C13.9926 18 15 16.9926 15 15.75V2.25C15 1.00736 13.9926 0 12.75 0H5.25Z","fill","white"],["d","M9.75 14.25C9.75 14.6642 9.41421 15 9 15C8.58579 15 8.25 14.6642 8.25 14.25C8.25 13.8358 8.58579 13.5 9 13.5C9.41421 13.5 9.75 13.8358 9.75 14.25Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.75 4.5L3.75 11.25L14.25 11.25L14.25 4.5C14.25 4.08579 13.9142 3.75 13.5 3.75L4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5ZM2.25 12.75L15.75 12.75L15.75 4.5C15.75 3.25736 14.7426 2.25 13.5 2.25L4.5 2.25C3.25736 2.25 2.25 3.25736 2.25 4.5L2.25 12.75Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M2.25 12.75L2.25 13.5C2.25 13.9142 2.58579 14.25 3 14.25L15 14.25C15.4142 14.25 15.75 13.9142 15.75 13.5L15.75 12.75L2.25 12.75ZM0.75 13.5C0.75 14.7426 1.75736 15.75 3 15.75L15 15.75C16.2426 15.75 17.25 14.7426 17.25 13.5L17.25 12C17.25 11.5858 16.9142 11.25 16.5 11.25L1.5 11.25C1.08579 11.25 0.75 11.5858 0.75 12L0.75 13.5Z","fill","white"],["d","M6.75 13.5H8.25V15H9.75V13.5H11.25V15H12C12.4142 15 12.75 15.3358 12.75 15.75C12.75 16.1642 12.4142 16.5 12 16.5H6C5.58579 16.5 5.25 16.1642 5.25 15.75C5.25 15.3358 5.58579 15 6 15H6.75V13.5Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3 4.5L3 10.5C3 11.3284 3.67157 12 4.5 12L13.5 12C14.3284 12 15 11.3284 15 10.5L15 4.5C15 3.67157 14.3284 3 13.5 3L4.5 3C3.67157 3 3 3.67157 3 4.5ZM1.5 10.5C1.5 12.1569 2.84315 13.5 4.5 13.5L13.5 13.5C15.1569 13.5 16.5 12.1569 16.5 10.5L16.5 4.5C16.5 2.84315 15.1569 1.5 13.5 1.5L4.5 1.5C2.84315 1.5 1.5 2.84315 1.5 4.5L1.5 10.5Z","fill","white"],[3,"user"]],template:function(t,r){t&1&&(Ht(),u(0,Otn,2,6,"ng-container",8)),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Xr,X,Dt,Xi,mo,sn,Jn,ie,L_,F_,V_,B_,Sn,Y1,se,G1],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);--velt-internal-comment-pin-bg-color: var(--velt-accent)}[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-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble{position:absolute;border-radius:100%;text-align:center;top:calc(var(--velt-spacing-sm) * -1);right:calc(var(--velt-spacing-sm) * -1);bottom:unset;left:unset;height:24px;width:24px;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--private-indicator{height:28px;width:28px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--ghost-indicator{height:28px;width:28px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--unread-indicator{background-color:var(--velt-error);color:var(--velt-error-foreground);height:16px;width:16px;top:calc(var(--velt-spacing-xs) * -1);right:calc(var(--velt-spacing-xs) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--index-3-digit{border-radius:100%;height:30px;width:30px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);bottom:unset;left:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--number-3-digit{border-radius:100%;height:30px;width:30px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);bottom:unset;left:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index{border:1px solid rgb(210,210,210);color:var(--velt-black);background:var(--velt-white)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index .comment-annotation-number{border-radius:100%;width:24px;height:24px;font-size:calc((.55rem + 0px) * var(--velt-base-rem-unit));display:inline-flex;justify-content:center;align-items:center;box-sizing:content-box;position:relative}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index .comment-annotation-number:after{content:attr(data-comment-annotation-number);position:absolute;font-weight:400;letter-spacing:normal;word-spacing:normal}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number{border:1px solid rgb(210,210,210);color:var(--velt-black);background:var(--velt-white)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number .comment-annotation-number{border-radius:100%;width:24px;height:24px;font-size:calc((.55rem + 0px) * var(--velt-base-rem-unit));display:inline-flex;justify-content:center;align-items:center;box-sizing:content-box;position:relative}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number .comment-annotation-number:after{content:attr(data-comment-annotation-number);position:absolute;font-weight:400;letter-spacing:normal;word-spacing:normal}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--private-indicator{color:var(--velt-white);background:linear-gradient(0deg,#000000bf 0% 100%),var(--velt-accent);border-radius:100%;border:1px solid rgba(255,255,255,.24);padding:var(--velt-spacing-sm)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--ghost-indicator{color:var(--velt-error-foreground);background:var(--velt-error);border-radius:100%;border:1px solid rgba(255,255,255,.24);padding:var(--velt-spacing-sm)}.velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--private-indicator[_ngcontent-%COMP%], .velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--ghost-indicator[_ngcontent-%COMP%]{padding:calc(var(--velt-spacing-md) / 2);width:24px;height:24px;top:calc(var(--velt-spacing-sm) * -1);right:calc(var(--velt-spacing-sm) * -1)}.velt-comment-pin--marker[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;position:relative;width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));border:2px solid var(--velt-border-3);border-radius:100% 100% 100% 2px;box-shadow:0 8px 16px -8px #0f0f0f1a;z-index:1;cursor:pointer;background:var(--velt-internal-comment-pin-bg-color);box-sizing:border-box}.velt-comment-pin--marker.velt-comment-pin--status-default[_ngcontent-%COMP%]{background:var(--velt-accent, var(--velt-internal-comment-pin-bg-color))}.velt-comment-pin--marker.velt-comment-pin--status-ongoing[_ngcontent-%COMP%]{background:var(--velt-warning, var(--velt-internal-comment-pin-bg-color))}.velt-comment-pin--marker.velt-comment-pin--status-terminal[_ngcontent-%COMP%]{background:var(--velt-success, var(--velt-internal-comment-pin-bg-color))}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem;background-color:var(--velt-gray);background-size:cover;border-radius:100%;display:flex;align-items:center;justify-content:center;position:relative}.velt-comment-pin--popover[_ngcontent-%COMP%]{width:0;height:0;border-style:solid;border-width:0 10px 10px 0;border-color:transparent var(--velt-accent) transparent transparent}.velt-comment-pin.velt-comment-pin--different-device[_ngcontent-%COMP%], .velt-comment-pin.velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--marker[_ngcontent-%COMP%]{width:calc((2.125rem + 0px) * var(--velt-base-rem-unit));height:calc((2.125rem + 0px) * var(--velt-base-rem-unit))}.velt-comment-pin.velt-comment-pin--ghost[_ngcontent-%COMP%] .velt-comment-pin--marker-default.velt-comment-pin--marker[_ngcontent-%COMP%]{background:var(--velt-gray)}.velt-comment-pin.velt-comment-pin--ghost[_ngcontent-%COMP%] .velt-comment-pin--popover[_ngcontent-%COMP%]{border-color:transparent var(--velt-gray) transparent transparent}.velt-comment-pin.velt-comment-pin--outside-viewport[_ngcontent-%COMP%]{max-width:var(--velt-internal-comment-pin-max-width);overflow:hidden} .velt-comment-dialog-overlay-panel{z-index:2147483567}.velt-comment-pin--marker-transparent[_ngcontent-%COMP%]{background:transparent;border:unset;border-radius:unset;box-shadow:unset}"],changeDetection:0});let i=o;return i})();function Atn(i,o){if(i&1){let n=K();v(0),y(1,"velt-multi-thread-comment-dialog-internal",6),W("afterViewInit",function(){N(n);let t=l().last,r=l(2);return F(t?r.calculatePosition():null)})("saveComment",function(t){N(n);let r=l().$implicit,a=l(2);return F(a.saveComment(r==null?null:r.annotation,t))}),b(),C()}if(i&2){let n=l().$implicit,e=l().ngIf,t=l();m(),d("multiThreadAnnotationId",n==null||n.annotation==null?null:n.annotation.annotationId)("annotation",n==null?null:n.annotation)("user",e.user)("commentPinSelected",!!e.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId]),x("data-testid",t.componentId+"-multi-thread-"+(n==null||n.annotation==null?null:n.annotation.annotationId))}}function Ptn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",7),W("afterViewInit",function(){N(n);let t=l().last,r=l(2);return F(t?r.calculatePosition():null)})("saveComment",function(t){N(n);let r=l().$implicit,a=l(2);return F(a.saveComment(r==null?null:r.annotation,t))}),b()}if(i&2){let n=l().$implicit,e=l().ngIf,t=l();d("annotation",n==null?null:n.annotation)("user",e.user)("commentPinSelected",!!e.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId])("inlineCommentMode",e.inlineCommentMode)("isInsidePdfViewer",n==null?null:n.isInsidePdfViewer),x("data-testid",t.componentId+"-single-thread-"+(n==null||n.annotation==null?null:n.annotation.annotationId))}}function Mtn(i,o){if(i&1){let n=K();v(0),y(1,"div",4),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.togglePinSelection(t==null?null:t.annotation))}),u(2,Atn,2,5,"ng-container",5)(3,Ptn,1,6,"ng-template",null,0,Te),b(),C()}if(i&2){let n=o.$implicit,e=me(4),t=l().ngIf,r=l();m(),at("top",n==null?null:n.top,"px"),pe("selected",t.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId]),d("id","snippyly-comments-on-right-block-"+(n==null||n.annotation==null?null:n.annotation.annotationId)),x("data-testid",r.componentId+"-block-"+(n==null||n.annotation==null?null:n.annotation.annotationId))("role","region")("tabindex",0),m(),d("ngIf",(n==null||n.annotation==null?null:n.annotation.type)==="multiThread")("ngIfElse",e)}}function ktn(i,o){if(i&1&&(v(0),y(1,"div",2),P(2,"translate"),u(3,Mtn,5,10,"ng-container",3),b(),C()),i&2){let n=o.ngIf,e=l();m(),x("data-testid",e.componentId)("role","complementary")("aria-label",M(2,5,"Comments panel")),m(2),d("ngForOf",n.commentPinAnnotationsArray)("ngForTrackBy",e.trackById)}}var z1e=(()=>{let o=class o{constructor(e,t,r,a,s){this.authService=e,this.commentService=t,this.domService=r,this.elementRef=a,this.loggingService=s,this.commentPinAnnotations=[],this.subscriptions=[],this.positionChangeDetectionSubscriptions=[],this.componentConfigSignal=xe({commentPinAnnotationsArray:[],selectedAnnotationsMap:{},user:void 0,inlineCommentMode:!1}),this.veltElement=!0,this.componentId="velt-comments-stream-view",this.subscriptions.push(this.authService.getUser$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{user:c}),p))},c=>{this.loggingService.catch("Error in CommentsStreamViewComponent getUser$ subscription: ",c)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{selectedAnnotationsMap:c}),p)),setTimeout(()=>{this.calculatePosition(),Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1&&this.goToAnnotation(this.componentConfigSignal().selectedAnnotationsMap[Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0]])},100)},c=>{this.loggingService.catch("Error in CommentsStreamViewComponent getSelectedAnnotationsMap$ subscription: ",c)})),this.subscriptions.push(this.commentService.getInlineCommentMode$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{inlineCommentMode:c}),p))}))}ngOnInit(){this.setupA11yAttributes()}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent setupA11yAttributes:",e)}}ngAfterViewInit(){this.streamViewContainerId&&(this.scrollableParentElement=document.getElementById(this.streamViewContainerId)),this.scrollableParentElement||(this.scrollableParentElement=J0(this.elementRef.nativeElement)),this.scrollableParentElement||(this.scrollableParentElement=document.documentElement),this.calculateTargetElementPositions()}ngOnChanges(e){try{e.commentPinAnnotations&&this.calculateTargetElementPositions()}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent ngOnChanges: ",t)}}goToAnnotation(e){let t=null;e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):t=document.querySelector(`[data-velt-id='${e.annotationId}']`),t&&t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}togglePinSelection(e){try{this.componentConfigSignal().selectedAnnotationsMap[e.annotationId]||(this.goToAnnotation(e),this.domService.toggleAnnotationSelection(e))}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent togglePinSelection: ",t)}}saveComment(e,t){try{this.commentService.saveComment(e,t)}catch(r){this.loggingService.catch("Error in CommentsStreamViewComponent saveComment: ",r)}}calculateTargetElementPositions(){try{this.positionChangeDetectionSubscriptions.forEach(t=>{t.unsubscribe()});let e=[];if(this.commentPinAnnotations.forEach(t=>{let r={},a=null;t.targetElement||t.areaAnnotationId?a=document.getElementById(`comment-pin-container-${t.annotationId}`):a=document.querySelector(`[data-velt-id='${t.annotationId}']`),a&&(r.annotation=t,r.targetElement=a,r.targetOffsetTop=sz(a,this.scrollableParentElement)?.top||0,r.isInsidePdfViewer=iC(a,U.ATTRIBUTES.VELT_PDF_VIEWER),e.push(r))}),e.sort((t,r)=>t.targetElement.getBoundingClientRect().top-r.targetElement.getBoundingClientRect().top),this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinAnnotationsArray:e}),t)),this.componentConfigSignal().commentPinAnnotationsArray?.length){let t=this.componentConfigSignal().commentPinAnnotationsArray[this.componentConfigSignal().commentPinAnnotationsArray.length-1]?.targetElement;this.detectPositionChange(t)}this.calculatePosition()}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent calculateTargetElementPositions: ",e)}}trackById(e,t){return t.annotation.annotationId}calculatePosition(){try{if(Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1){let e=Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0],t=this.componentConfigSignal().commentPinAnnotationsArray.findIndex(s=>s.annotation.annotationId===e),r=this.componentConfigSignal().commentPinAnnotationsArray.slice(0,t+1).reverse(),a=this.componentConfigSignal().commentPinAnnotationsArray.slice(t);this.calculateDialogPosition(r,!0),this.calculateDialogPosition(a),r.shift(),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotationsArray:[...r.reverse().slice(),...a.slice()]}),s))}else this.calculateDialogPosition(this.componentConfigSignal().commentPinAnnotationsArray)}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent calculatePosition: ",e)}}calculateDialogPosition(e,t=!1){try{e.forEach((r,a,s)=>{if(!r.dialogElement){let c=this.elementRef?.nativeElement?.querySelector(`[id="snippyly-comments-on-right-block-${r.annotation.annotationId}"]`);c&&(r.dialogElement=c,r.dialogOffsetTop=sz(c,this.scrollableParentElement)?.top||0)}if(!a)r.top=r.targetOffsetTop;else if(t){let c=s[a-1];if(r.dialogElement){let p=c.top-r.dialogElement?.getBoundingClientRect()?.height-24,g=r.targetOffsetTop;p<r.top?r.top=p:g&&(g<=p?r.top=g:r.top=p)}}else{let c=s[a-1];if(c.dialogElement){let p=c.top+c.dialogElement?.getBoundingClientRect()?.height+24,g=r.targetOffsetTop;p>r.dialogOffsetTop&&p>g?r.top=p:g&&(g>=p?r.top=g:r.top=p)}}})}catch(r){this.loggingService.catch("Error in CommentsStreamViewComponent calculateDialogPosition: ",r)}}detectPositionChange(e){try{let t=zm(0,$m).pipe(de(()=>{let r=e.getBoundingClientRect();return{top:r.top,left:r.left}}),Ct((r,a)=>r.top===a.top&&r.left===a.left),Oi());this.positionChangeDetectionSubscriptions.push(t.subscribe(()=>{this.calculateTargetElementPositions()},r=>{}))}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent detectPositionChange: ",t)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()})}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(we),h(Be),h(R),h(_))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comments-stream-view"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{commentPinAnnotations:"commentPinAnnotations",streamViewContainerId:"streamViewContainerId"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["commentDialogRef",""],[4,"ngIf"],["velt-ignore-change-detection","true",1,"snippyly-comments-on-right-container"],[4,"ngFor","ngForOf","ngForTrackBy"],["velt-ignore-change-detection","true",1,"snippyly-comments-on-right-block",3,"click","id"],[4,"ngIf","ngIfElse"],[3,"afterViewInit","saveComment","multiThreadAnnotationId","annotation","user","commentPinSelected"],[3,"afterViewInit","saveComment","annotation","user","commentPinSelected","inlineCommentMode","isInsidePdfViewer"]],template:function(t,r){t&1&&u(0,ktn,4,7,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,ar,Rs,ge],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}.snippyly-comments-on-right-container[_ngcontent-%COMP%]{position:absolute;top:0;right:10vw;width:300px;background:#90ee90}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block[_ngcontent-%COMP%]{position:absolute;box-shadow:none;transition:top .5s ease,left .5s ease,box-shadow .5s ease;left:0}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block.selected[_ngcontent-%COMP%]{left:-36px;z-index:1}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block .comment-dialog-container{transition:box-shadow .5s ease;box-shadow:none!important}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block.selected .comment-dialog-container{box-shadow:0 calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((3rem + 0px) * var(--velt-base-rem-unit)) #0000002d!important}"],changeDetection:0});let i=o;return i})();var Ntn=()=>["snippyly-inbox-panel","velt-overlay-panel"];function Ftn(i,o){i&1&&He(0)}function Ltn(i,o){if(i&1&&u(0,Ftn,1,0,"ng-container",7),i&2){l();let n=me(6);d("ngTemplateOutlet",n)}}function Btn(i,o){if(i&1){let n=K();y(0,"velt-multi-thread-comment-dialog-internal",11),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment(t))}),b()}if(i&2){let n=l(3).ngIf,e=l();d("multiThreadAnnotationId",n.commentAnnotation==null?null:n.commentAnnotation.annotationId)("annotation",n.commentAnnotation)("user",n.user)("commentPinSelected",!0)("inboxMode",!0),x("data-testid",e.componentId+"-multi-thread-dialog")("role","dialog")("aria-label",M(1,8,"Multi-thread comment dialog"))}}function Vtn(i,o){if(i&1&&(v(0),u(1,Btn,2,10,"velt-multi-thread-comment-dialog-internal",10),C()),i&2){let n=l(2).ngIf;m(),d("ngIf",n.commentAnnotation&&n.user)}}function Utn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",13),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment(t))}),b()}if(i&2){let n=l(3).ngIf,e=l();d("annotation",n.commentAnnotation)("user",n.user)("commentPinSelected",!0)("inboxMode",!0),x("data-testid",e.componentId+"-single-dialog")("role","dialog")("aria-label",M(1,7,"Single comment dialog"))}}function jtn(i,o){if(i&1&&u(0,Utn,2,9,"snippyly-comment-dialog",12),i&2){let n=l(2).ngIf;d("ngIf",n.commentAnnotation&&n.user)}}function $tn(i,o){if(i&1&&(y(0,"div",8),P(1,"translate"),u(2,Vtn,2,1,"ng-container",9)(3,jtn,1,1,"ng-template",null,3,Te),b()),i&2){let n=me(4),e=l().ngIf,t=l();pe("mobile",e.isPhone)("visible",!!e.commentAnnotation),x("data-testid",t.componentId)("role","region")("aria-label",M(1,10,"Comment inbox container"))("aria-expanded",!!e.commentAnnotation),m(2),d("ngIf",(e==null||e.commentAnnotation==null?null:e.commentAnnotation.type)==="multiThread")("ngIfElse",n)}}function Htn(i,o){if(i&1&&(v(0),w(1,"div",5,0),u(3,Ltn,1,1,"ng-template",6,1,Te)(5,$tn,5,12,"ng-template",null,2,Te),C()),i&2){let n=me(2),e=l();m(),x("data-testid",e.componentId+"-trigger")("aria-hidden",!0),m(2),d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",ut(6,Ntn))}}var G1e=(()=>{let o=class o extends tt{constructor(e,t,r,a,s,c){super(s,c),this.authService=e,this.breakpointObserver=t,this.commentService=r,this.loggingService=a,this.elementRef=s,this.themeService=c,this.componentConfigSignal=xe({isPhone:!1,sidebarVisible:!1}),this.subscriptions=[],this.componentId="velt-comment-inbox";try{this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(p=>{p.matches?this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!0}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!1}),g))},p=>{this.catchError("Error in CommentInboxComponent breakpointObserver subscription: ",p)}))}catch{}}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t))},e=>{this.catchError("Error in CommentInboxComponent getUser$ subscription: ",e)}))}catch(e){this.catchError("Error in CommentInboxComponent ngOnInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentInboxComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e.commentAnnotation&&this.componentConfigSignal.update(t=>(t=D(E({},t),{commentAnnotation:e.commentAnnotation.currentValue}),t))}catch(t){this.catchError("Error in CommentInboxComponent ngOnChanges: ",t)}}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),super.ngOnDestroy()}saveComment(e){try{(this.commentAnnotation||e.annotation)&&this.commentService.saveComment(this.commentAnnotation||e.annotation,e)}catch(t){this.catchError("Error in CommentInboxComponent saveComment: ",t)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.commentAnnotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(wo),h(we),h(_),h(R),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-inbox"]],inputs:{commentAnnotation:"commentAnnotation"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[["sidebarTrigger","cdkOverlayOrigin"],["sidebarOverlay","cdkConnectedOverlay"],["sidebarRef",""],["commentDialogRef",""],[4,"ngIf"],["cdkOverlayOrigin",""],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass"],[4,"ngTemplateOutlet"],["id","sCommentInboxContainer","data-velt-comment-disabled","true",1,"velt-comment-inbox--container","s-inbox-container"],[4,"ngIf","ngIfElse"],[3,"multiThreadAnnotationId","annotation","user","commentPinSelected","inboxMode","saveComment",4,"ngIf"],[3,"saveComment","multiThreadAnnotationId","annotation","user","commentPinSelected","inboxMode"],[3,"annotation","user","commentPinSelected","inboxMode","saveComment",4,"ngIf"],[3,"saveComment","annotation","user","commentPinSelected","inboxMode"]],template:function(t,r){t&1&&u(0,Htn,7,7,"ng-container",4),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,ar,Rs,ge],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)}*[_ngcontent-%COMP%]{box-sizing:border-box} .snippyly-inbox-panel{top:0!important;left:0!important}.s-overflow-hidden[_ngcontent-%COMP%]{overflow:hidden!important} .velt-comment-inbox--container{height:100vh;width:calc((26rem + 0px) * var(--velt-base-rem-unit));position:fixed;top:0;right:-100%;padding:var(--velt-spacing-lg);box-sizing:border-box;z-index:999999997;transition:width .5s ease-in-out,right .5s ease-in-out} .velt-comment-inbox--container.mobile{width:100%;height:100%;box-sizing:border-box;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)} .velt-comment-inbox--container.visible{right:0}"],changeDetection:0});let i=o;return i})();function Gtn(i,o){if(i&1){let n=K();v(0),y(1,"div",3),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.scrollToAnnotation(t==null?null:t.key))}),y(2,"div",4),te(3),P(4,"translate"),b()(),C()}if(i&2){let n=o.$implicit,e=l().ngIf,t=l();m(),at("top",n.value.top,"%")("transform","translate(0, -"+n.value.top+"%)"),pe("v-unread-comment",!(e.user!=null&&e.user.isGuest)&&!(e.user!=null&&e.user.isAnonymous)&&(e.unreadCommentsMap==null?null:e.unreadCommentsMap[n==null||n.value==null||n.value.annotation==null?null:n.value.annotation.annotationId])),x("data-testid",t.componentId+"-pin-"+n.key)("role","button")("tabindex",0),m(),x("role","tooltip")("aria-hidden","true"),m(),Se(" ",M(4,12,"Go to comments here.")," ")}}function Wtn(i,o){if(i&1&&(v(0),y(1,"div",1),P(2,"translate"),u(3,Gtn,5,14,"ng-container",2),P(4,"keyvalue"),b(),C()),i&2){let n=o.ngIf,e=l();m(),pe("velt-comments-minimap-container--target-scrollable-element",!!n.targetScrollableElementId)("velt-comments-minimap-position--left",n.position==="left"),x("data-testid",e.componentId)("role","navigation")("aria-label",M(2,9,"Comments minimap")),m(2),d("ngForOf",M(4,11,n.commentAnnotationPositionMap))("ngForTrackBy",e.trackByAnnotationId)}}var t8=(()=>{let o=class o{constructor(e,t,r){this.commentService=e,this.loggingService=t,this.elementRef=r,this.commentAnnotations=[],this.targetScrollableElementId=null,this.position="right",this.commentCountsByPosition={},this.minimapHeatmapGradient="",this.componentConfigSignal=xe({targetScrollableElementId:null,position:"right",commentAnnotationPositionMap:{},user:null,unreadCommentsMap:null}),this.subscriptions=[],this.componentId="velt-comments-minimap",this.loggingService.log("%c[WB] Creating CLASS: CommentsMinimapComponent","color: blue;")}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{unreadCommentsMap:e}),t))}))}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent ngOnInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.commentAnnotations&&setTimeout(()=>{this.setCommentAnnotationPositionMap()},200)}catch(t){this.loggingService.catch("Error in CommentsMinimapComponent ngOnChanges: ",t)}}trackByAnnotationId(e,t){return t?.annotation?.annotationId||e}setCommentAnnotationPositionMap(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{commentAnnotationPositionMap:{}}),e)),this.commentAnnotations.forEach(e=>{let t=null;if(e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):t=document.querySelector(`[data-velt-id='${e.annotationId}']`),t){let r=this.getElementPosition(t)?.percentageOfTotalHeight;r!=null&&this.componentConfigSignal.update(a=>(a=D(E({},a),{commentAnnotationPositionMap:D(E({},a.commentAnnotationPositionMap),{[e.annotationId]:{annotation:e,top:r,element:t}})}),a))}})}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent setCommentAnnotationPositionByCommentAnnotationIndex: ",e)}}scrollToAnnotation(e){try{let t=this.componentConfigSignal().commentAnnotationPositionMap[e];t&&t.element&&t.element.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}catch(t){this.loggingService.catch("Error in CommentsMinimapComponent scrollToAnnotation: ",t)}}getElementPosition(e){try{let t=0,r=e,a=this.componentConfigSignal().targetScrollableElementId&&document.getElementById(this.componentConfigSignal().targetScrollableElementId);for(;r&&(t+=r.offsetTop||0,r=r.offsetParent,!(a&&r===a)););let s=0;if(a)s=a.scrollHeight;else{let p=document.body,g=document.documentElement;s=Math.max(p.scrollHeight,p.offsetHeight,g.clientHeight,g.scrollHeight,g.offsetHeight)}let c=t/s*100;return{pixelsFromTop:t,percentageOfTotalHeight:c}}catch(t){return this.loggingService.catch("Error in CommentsMinimapComponent getElementPosition: ",t),null}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()})}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["app-comments-minimap"]],inputs:{commentAnnotations:"commentAnnotations",user:"user",targetScrollableElementId:"targetScrollableElementId",position:"position"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[[4,"ngIf"],[1,"v-comments-minimap-container"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"v-comment-minimap-pin",3,"click"],[1,"v-comment-count"]],template:function(t,r){t&1&&u(0,Wtn,5,13,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,Wd,ge],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)}.v-comments-minimap-container[_ngcontent-%COMP%]{display:block;position:fixed;height:100vh;top:0;right:0;background:#00000014;z-index:var(--velt-comments-minimap-z-index)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]{position:absolute;right:0;width:12px;height:4px;flex-shrink:0;border-radius:var(--velt-border-radius-2xs);border:1px solid rgba(255,255,255,.16);background:color-mix(in srgb,var(--velt-accent) 80%,transparent);cursor:pointer}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{position:absolute;top:50%;right:20px;z-index:1000;min-width:max-content;background:color-mix(in srgb,var(--velt-accent) 80%,transparent);font-size:var(--velt-font-size-xs);padding:var(--velt-spacing-xs) var(--velt-spacing-sm);border-radius:var(--velt-border-radius-xs);transform:translateY(-50%);color:var(--velt-accent-foreground);display:none}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{content:"";position:absolute;border-style:solid;border-width:4px 0 4px 4px;border-color:transparent color-mix(in srgb,var(--velt-accent) 80%,transparent);display:block;width:0;z-index:1;right:calc(var(--velt-spacing-xs) * -1);top:50%;transform:translateY(-50%)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]:hover .v-comment-count[_ngcontent-%COMP%]{display:block}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%]{background-color:color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{border-color:transparent color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container.velt-comments-minimap-container--target-scrollable-element[_ngcontent-%COMP%]{position:absolute;height:100%}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%], .v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]{right:auto;left:0}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{right:auto;left:20px}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{right:auto;left:calc(var(--velt-spacing-xs) * -1);border-width:4px 4px 4px 0}'],changeDetection:0});let i=o;return i})();function qtn(i,o){i&1&&He(0)}function Ytn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,qtn,1,0,"ng-container",6),b()),i&2){l();let n=me(3);m(),d("ngTemplateOutlet",n)}}function Ktn(i,o){if(i&1&&(w(0,"snippyly-comments-stream-view",10),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("commentPinAnnotations",n.commentPinAnnotationsForStreamView)("streamViewContainerId",e.streamViewContainerId),x("data-testid",e.componentId+"-stream")("role","complementary")("aria-label",M(1,5,"Comments stream view"))}}function Ztn(i,o){if(i&1&&(w(0,"snippyly-comment-inbox",11),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("darkMode",n.darkMode)("commentAnnotation",n.selectedCommentAnnotation),x("data-testid",e.componentId+"-inbox")("role","complementary")("aria-label",M(1,5,"Comments inbox"))}}function Xtn(i,o){if(i&1&&(w(0,"app-comments-minimap",12),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("commentAnnotations",n.commentPinAnnotations)("user",n.user)("position",n.minimapPosition),x("data-testid",e.componentId+"-minimap")("role","complementary")("aria-label",M(1,6,"Comments location overview"))}}function Qtn(i,o){if(i&1&&(w(0,"snippyly-comment-adder"),u(1,Ktn,2,7,"snippyly-comments-stream-view",7)(2,Ztn,2,7,"snippyly-comment-inbox",8)(3,Xtn,2,8,"app-comments-minimap",9)),i&2){let n=l(2).ngIf,e=l();x("data-testid",e.componentId+"-adder"),m(),d("ngIf",n.streamMode&&n.commentsOnDom),m(),d("ngIf",n.inboxMode&&n.commentsOnDom),m(),d("ngIf",n.minimapEnabled&&n.commentsOnDom)}}function Jtn(i,o){if(i&1&&(v(0),u(1,Ytn,2,1,"velt-shadow-dom-internal",5)(2,Qtn,4,4,"ng-template",null,0,Te),C()),i&2){let n=me(3),e=l().ngIf;m(),d("ngIf",e.shadowDOM)("ngIfElse",n)}}function enn(i,o){if(i&1){let n=K();v(0),u(1,Jtn,4,2,"ng-container",1),y(2,"div",2)(3,"slot",3),W("slotchange",function(t){N(n);let r=l();return F(r.handleCommentPinSlotChanged(t))}),b()(),w(4,"app-persistent-comment-mode",4),C()}if(i&2){let n=o.ngIf,e=l();m(),d("ngIf",n.isFirstComponent),m(),x("aria-hidden","true")("data-testid",e.componentId+"-slot-container"),m(2),d("componentConfigSignal",e.componentConfigSignal),x("data-testid",e.componentId+"-persistent-mode")}}var wq=(()=>{let o=class o{set textMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextComments():this.commentService.disableTextComments()}set popoverMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePopoverMode():this.commentService.disablePopoverMode()}set popoverTriangleComponent(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePopoverTriangleComponent():this.commentService.disablePopoverTriangleComponent()}set forceCloseAllOnEsc(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableForceCloseAllOnEsc():this.commentService.disableForceCloseAllOnEsc()}set collapsedComments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCollapsedComments():this.commentService.disableCollapsedComments()}set shortUserName(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShortUserName():this.commentService.disableShortUserName()}catch{}}set readOnly(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReadOnly():this.commentService.disableReadOnly()}catch{}}set deleteThreadWithFirstComment(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteThreadWithFirstComment():this.commentService.disableDeleteThreadWithFirstComment()}catch{}}set resolveStatusAccessAdminOnly(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableResolveStatusAccessAdminOnly():this.commentService.disableResolveStatusAccessAdminOnly()}set svgAsImg(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSvgAsImg():this.commentService.disableSvgAsImg()}catch{}}set commentToNearestAllowedElement(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentToNearestAllowedElement():this.commentService.disableCommentToNearestAllowedElement()}catch{}}set floatingCommentDialog(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.disableFloatingComments(!t)}set moderatorMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setModeratorMode(t)}set _streamMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setStreamMode(t)}set atHereLabel(e){e&&this.contactService.setAtHereLabel(e)}set _atHereEnabled(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.contactService.enableAtHere():this.contactService.disableAtHere()}set _deleteReplyConfirmation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteReplyConfirmation():this.commentService.disableDeleteReplyConfirmation()}set _expandMentionGroups(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableExpandMentionGroups():this.commentService.disableExpandMentionGroups()}set _showMentionGroupsFirst(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShowMentionGroupsFirst():this.commentService.disableShowMentionGroupsFirst()}set _linkCallback(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableLinkCallback():this.commentService.disableLinkCallback()}set _showMentionGroupsOnly(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShowMentionGroupsOnly():this.commentService.disableShowMentionGroupsOnly()}set _fullExpanded(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFullExpanded():this.commentService.disableFullExpanded()}catch{}}set _draftMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDraftMode():this.commentService.disableDraftMode()}catch{}}set atHereDescription(e){e&&this.contactService.setAtHereDescription(e)}set _persistentCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePersistentCommentMode():this.commentService.disablePersistentCommentMode()}set _seenByUsers(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSeenByUsers():this.commentService.disableSeenByUsers()}set signInButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableSignInButton(t)}set upgradeButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableUpgradeButton(t)}set attachments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableAttachment(t)}set recordings(e){let t=e;typeof e=="string"&&(t=e?.split(",")?.map(r=>r.trim()),this.commentService.setAllowedRecordings(t))}set reactions(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReactions():this.commentService.disableReactions()}set deviceInfo(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.showScreenSizeInfo(t)}set commentIndex(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.showCommentIndex(t)}set dialogOnHover(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableDialogOnHover(t)}set dialogOnTargetElementClick(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableDialogOnTargetElementClick(t)}set priority(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnablePriority(t)}set status(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableStatus(t)}set resolveButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableResolve(t)}set _inboxMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableInboxMode():this.commentService.disableInboxMode()}set _suggestionMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setSuggestionMode(t)}set _mobileMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setMobileMode(t)}set _inlineCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableInlineCommentMode():this.commentService.disableInlineCommentMode()}set _privateCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePrivateCommentMode():this.commentService.disablePrivateCommentMode()}set _minimap(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMinimap():this.commentService.disableMinimap()}set _minimapPosition(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimapPosition:e}),t)),this.commentService.setAnalyticsFeatureConfig({config:{minimapPosition:e}})}catch{}}set _ghostComments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGhostComments():this.commentService.disableGhostComments()}set _ghostCommentsIndicator(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGhostCommentsMessage():this.commentService.disableGhostCommentsMessage()}set _commentsOnDom(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.showCommentsOnDom():this.commentService.hideCommentsOnDom()}set _resolvedCommentsOnDom(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.showResolvedCommentsOnDom():this.commentService.hideResolvedCommentsOnDom()}set _filterCommentsOnDom(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFilterCommentsOnDom():this.commentService.disableFilterCommentsOnDom()}catch{}}set _bubbleOnPin(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableBubbleOnPin():this.commentService.disableBubbleOnPin()}catch{}}set _bubbleOnPinHover(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableBubbleOnPinHover():this.commentService.disableBubbleOnPinHover()}catch{}}set _multiThreadMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMultiThread():this.commentService.disableMultiThread()}catch{}}set _multiThread(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMultiThread():this.commentService.disableMultiThread()}catch{}}set _maxReplyAvatars(e){try{let t=e;typeof e=="string"&&(t=parseInt(e)),this.commentService.setMaxReplyAvatars(t)}catch{}}set _replyAvatars(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReplyAvatars():this.commentService.disableReplyAvatars()}catch{}}set _groupMultipleMatch(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGroupMatchedComments():this.commentService.disableGroupMatchedComments()}catch{}}set _groupMatchedComments(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGroupMatchedComments():this.commentService.disableGroupMatchedComments()}catch{}}set _commentTool(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentTool():this.commentService.disableCommentTool()}set _sidebarButtonOnCommentDialog(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarButtonOnCommentDialog():this.commentService.disableSidebarButtonOnCommentDialog()}set _deviceIndicatorOnCommentPins(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeviceIndicatorOnCommentPins():this.commentService.disableDeviceIndicatorOnCommentPins()}catch{}}set _scrollToComment(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableScrollToComment():this.commentService.disableScrollToComment()}set _userMentions(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableUserMentions():this.commentService.disableUserMentions()}set _paginatedContactList(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePaginatedContactList():this.commentService.disablePaginatedContactList()}set _deleteOnBackspace(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteOnBackspace():this.commentService.disableDeleteOnBackspace()}catch{}}set _hotkey(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableHotkey():this.commentService.disableHotkey()}catch{}}set _recordingSummary(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableRecordingSummary():this.commentService.disableRecordingSummary()}catch{}}set _recordingTranscription(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.recorderAnnotationService.enableRecordingTranscription():this.recorderAnnotationService.disableRecordingTranscription()}catch{}}set _allowedFileTypes(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedFileTypes(t)}catch{}}set _recordingCountdown(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableRecordingCountdown():this.commentService.disableRecordingCountdown()}catch{}}set _unreadIndicatorMode(e){try{this.commentService.setUnreadIndicatorMode(e)}catch{}}set _enterKeyToSubmit(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableEnterKeyToSubmit():this.commentService.disableEnterKeyToSubmit()}catch{}}set _pinShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePinShadowDOM():this.commentService.disablePinShadowDOM()}catch{}}set _dialogShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDialogShadowDOM():this.commentService.disableDialogShadowDOM()}catch{}}set _persistentCommentShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{persistentCommentShadowDOM:!!t}),r)),this.commentService.setAnalyticsFeatureConfig({config:{persistentCommentShadowDOM:!!t}})}catch{}}set _shadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{shadowDOM:!!t,persistentCommentShadowDOM:!!t}),r)),this.componentConfigSignal().shadowDOM?(this.commentService.enableDialogShadowDOM(),this.commentService.enablePinShadowDOM(),this.commentService.enableTextCommentToolShadowDOM(),this.commentService.enableTextCommentToolbarShadowDOM()):(this.commentService.disableDialogShadowDOM(),this.commentService.disablePinShadowDOM(),this.commentService.disableTextCommentToolShadowDOM(),this.commentService.disableTextCommentToolbarShadowDOM()),this.commentService.setAnalyticsFeatureConfig({config:{shadowDom:!!t}})}catch{}}set _textCommentToolShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolShadowDOM():this.commentService.disableTextCommentToolShadowDOM()}catch{}}set _pinDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePinDarkMode():this.commentService.disablePinDarkMode()}catch{}}set _textCommentToolDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolDarkMode():this.commentService.disableTextCommentToolDarkMode()}catch{}}set _textCommentToolbarDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolbarDarkMode():this.commentService.disableTextCommentToolbarDarkMode()}catch{}}set _textCommentToolbarShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolbarShadowDOM():this.commentService.disableTextCommentToolbarShadowDOM()}catch{}}set _changeDetectionInCommentMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableChangeDetectionInCommentMode():this.commentService.disableChangeDetectionInCommentMode()}catch{}}set _areaComment(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableAreaComment():this.commentService.disableAreaComment()}catch{}}set _screenshot(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableScreenshot():this.commentService.disableScreenshot()}catch{}}set _pinCursorImage(e){try{this.commentService.setPinCursorImage(e||"")}catch{}}set allowedElementIds(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementIds(t)}catch{}}set allowedElementClassNames(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementClassNames(t)}catch{}}set allowedElementQuerySelectors(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementQuerySelectors(t)}catch{}}set _commentPinHighlighter(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentPinHighlighter():this.commentService.disableCommentPinHighlighter()}catch{}}set _customReactions(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setCustomReactions(t)}catch{}}set customStatus(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setCustomStatuses(t)}set customListDataOnAnnotation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.createCustomListDataOnAnnotation(t)}set customListDataOnComment(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.autocompleteService.create(t)}set attachmentNameInMessage(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableAttachmentNameInMessage():this.commentService.disableAttachmentNameInMessage()}set customPriority(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.customFilterService.setCustomPriorityFilters(t)}set _customAutocompleteSearch(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCustomAutocompleteSearch():this.commentService.disableCustomAutocompleteSearch()}catch{}}set customCategory(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.customFilterService.setCustomCategories(t)}set composerMode(e){this.commentService.setComposerMode(e)}set autoCategorize(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableAutoCategorize(!!t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set commentplaceholder(e){try{let t=e;this.commentService.setCommentplaceholder(t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set replyplaceholder(e){try{let t=e;this.commentService.setReplyplaceholder(t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set isDarkMode(e){this._darkAttribute=e,this.checkDarkMode(),this.commentService.setCommentContainerDarkMode(e===""||e==="true")}constructor(e,t,r,a,s,c,p,g,f,I,T,B,z){this.analyticsService=e,this.authService=t,this.domService=r,this.commentService=a,this.commentPinPortalService=s,this.commentTextPortalService=c,this.customFilterService=p,this.loggingService=g,this.elementRef=f,this.autocompleteService=I,this.contactService=T,this.recorderAnnotationService=B,this.docService=z,this.onCommentAdd=new Me,this.onSignIn=new Me,this.onUpgrade=new Me,this.onCustomPinInject=new Me,this.onCommentUpdate=new Me,this.onCommentAccept=new Me,this.onCommentReject=new Me,this.onSidebarButtonOnCommentDialogClick=new Me,this.onCommentSelectionChange=new Me,this.onCopyLink=new Me,this.subscriptions=[],this.selectedAnnotationsMap={},this.commentAnnotationFocused=!1,this.enableGhostComments=!1,this.resolvedCommentsOnDom=!1,this.scrollToComment=!1,this.componentConfigSignal=xe({addCommentMode:!1,commentPinAnnotations:[],multiThreadCommentPinAnnotations:[],commentPinAnnotationsForStreamView:[],commentsOnDom:!1,inboxMode:!1,isFirstComponent:!0,minimapEnabled:!1,minimapPosition:"right",persistentCommentMode:!1,persistentModeBanner:!1,privateCommentModeEnabled:!1,selectedCommentAnnotation:void 0,shadowDOM:!0,streamMode:!1,user:null,darkMode:!1,disableCommentMode:this.disableCommentMode.bind(this),persistentCommentShadowDOM:!0}),this.veltId=vt(),this.veltElement=!0,this.componentId="velt-comments-container";try{this.loggingService.log("%c[WB] Creating CLASS: CommentsContainerComponent","color: blue;"),this._darkAttribute=this.elementRef.nativeElement.getAttribute("dark");let G=new URL(window.location.href);this.focusCommentAnnotationId=G.searchParams.get(U.URL_PARAMS.COMMENT_ID),this.commentService.setCommentAddedEmitter(this.onCommentAdd)}catch(G){this.loggingService.catch("Error in CommentsContainerComponent constructor: ",G)}}ngOnInit(){try{this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;"),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsContainerComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in SubtitlesComponent ngOnChanges: ",t)}}ngAfterViewInit(){try{let e=document.querySelector(U.TAGS.SNIPPYLY_COMMENTS),t=document.querySelector(U.TAGS.VELT_COMMENTS);document.querySelector(`${U.TAGS.VELT_COMMENTS}[${U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT}]`)||(t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(a=>(a=D(E({},a),{isFirstComponent:!0}),a)),t?.setAttribute(U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT,"true"),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(a=>(a=D(E({},a),{isFirstComponent:!0}),a)),e?.setAttribute(U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT,"true"),this.initComponent()))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.commentService.addAreaContainerTag(),this.subscriptions.push(this.authService.getUser$().pipe(Le(e=>!!e)).subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),e&&this.setCommentInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.subscriptions.push(this.commentService.getStreamMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{streamMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getStreamMode$ subscription: ",e)})),this.subscriptions.push(this.docService.getDocumentPaths$().subscribe(()=>{this.getAllCommentsOnCurrentDocument()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getDocumentPaths$ subscription: ",e)})),this.subscriptions.push(this.commentService.getInboxMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{inboxMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getInboxMode$ subscription: ",e)})),this.subscriptions.push(this.commentService.getMinimap$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimapEnabled:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getMinimap$ subscription: ",e)})),this.subscriptions.push(this.commentService.addCommentModeChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{addCommentMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent addCommentModeChange subscription: ",e)})),this.subscriptions.push(this.commentService.persistentCommentModeChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{persistentCommentMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent persistentCommentModeChange subscription: ",e)})),this.subscriptions.push(this.commentService.persistentModeBannerChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{persistentModeBanner:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent persistentModeBannerChange subscription: ",e)})),this.subscriptions.push(this.commentService.getPrivateCommentMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{privateCommentModeEnabled:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getPrivateCommentMode$ subscription: ",e)})),this.subscriptions.push(this.commentService.getScrollToComment$().subscribe(e=>{this.scrollToComment=e},e=>{this.loggingService.catch("Error in CommentsContainerComponent getScrollToComment$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSignInButtonClick$().subscribe(()=>{this.onSignIn.emit()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSignInButtonClick$ subscription: ",e)})),this.subscriptions.push(this.commentService.getUpgradeButtonClick$().subscribe(()=>{this.onUpgrade.emit()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getUpgradeButtonClick$ subscription: ",e)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(e=>{this.selectedAnnotationsMap=e},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.commentPinPortalService.getCustomPinEvents$().subscribe(e=>{this.onCustomPinInject.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getCustomPinEvents$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentUpdated$.subscribe(e=>{this.onCommentUpdate.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentUpdated$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentAccepted$.subscribe(e=>{this.onCommentAccept.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentAccepted$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentRejected$.subscribe(e=>{this.onCommentReject.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentRejected$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarButtonOnCommentDialogClick$().subscribe(e=>{this.onSidebarButtonOnCommentDialogClick.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSidebarButtonOnCommentDialogClick$ subscription: ",e)})),this.subscriptions.push(this.commentService.onCommentSelectionChange$().subscribe(e=>{this.onCommentSelectionChange.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent onCommentSelectionChange$ subscription: ",e)})),this.subscriptions.push(this.commentService.getCopyLink$().subscribe(e=>{this.onCopyLink.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getCopyLink$ subscription: ",e)})),this.getAllCommentsOnCurrentDocument()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent initComponent: ",e)}}getAllCommentsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.commentService.getCommentsOnDom$().pipe(he(e=>(this.componentConfigSignal.update(t=>(t=D(E({},t),{commentsOnDom:e}),t)),this.componentConfigSignal().commentsOnDom?mn([this.commentService.getAllCommentAnnotations({detectGhostComments:!0,addFilterCommentsOnDomCheck:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsContainer"}}}),this.commentService.getAllMultiThreadCommentAnnotations(void 0,void 0,void 0,!0)]).pipe(de(([t,r])=>[...t||[],...r||[]]),he(t=>this.commentService.getEnableGhostComments$().pipe(de(r=>(this.enableGhostComments=r,t)))),he(t=>this.commentService.getCommentsOnDom$().pipe(de(r=>(this.componentConfigSignal.update(a=>(a=D(E({},a),{commentsOnDom:r}),a)),t)))),he(t=>this.commentService.getResolvedCommentsOnDom$().pipe(de(r=>(this.resolvedCommentsOnDom=r,t)))),he(t=>this.domService.getSelectedAnnotationsMap$().pipe(de(r=>({filteredAnnotations:t||[],selectedAnnotationsMap:r||{}}))))):le({filteredAnnotations:[],selectedAnnotationsMap:{}})))).subscribe(e=>{try{this.loggingService.log(e),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotations:e?.filteredAnnotations}),s)),this.commentService.setCommentAnnotationsFromCommentsContainer(this.componentConfigSignal().commentPinAnnotations);let t;this.componentConfigSignal().commentPinAnnotations.forEach(s=>{this.selectedAnnotationsMap[s?.annotationId]&&(s?.multiThreadAnnotationId||(t=s))}),this.componentConfigSignal.update(s=>(s=D(E({},s),{selectedCommentAnnotation:t}),s));let r=this.componentConfigSignal().commentPinAnnotations.filter(s=>s.targetElement&&s?.position);r=r.filter(s=>{let c=!0;return s?.ghostComment?.type===Dl.DIFFERENT_DEVICE&&!s?.ghostComment?.isSameGroup&&(e.selectedAnnotationsMap[s.annotationId]||(c=!1)),s?.ghostComment&&!this.enableGhostComments&&(c=!1),!this.resolvedCommentsOnDom&&!(this.commentService.getFilterCommentsOnDom()&&this.commentService.getCommentsFromSidebarMap())&&s.status!==void 0&&s.status.type==="terminal"&&(e.selectedAnnotationsMap[s.annotationId]||(c=!1)),c}),this.commentPinPortalService.checkPinsToRemove(r),r.forEach(s=>{this.commentPinPortalService.setCommentPin(s)});let a=this.componentConfigSignal().commentPinAnnotations.filter(s=>s.targetTextRange);a=a.filter(s=>!(!this.resolvedCommentsOnDom&&!(this.commentService.getFilterCommentsOnDom()&&this.commentService.getCommentsFromSidebarMap())&&s.status!==void 0&&s.status.type==="terminal"&&!e.selectedAnnotationsMap[s.annotationId])),this.commentTextPortalService.updateTextCommentAnnotations(a),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotationsForStreamView:this.componentConfigSignal().commentPinAnnotations.slice()}),s)),this.focusCommentAnnotation()}catch(t){this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.commentService.setContextProvider(null),this.commentService.setCommentAddedEmitter(null),this.componentConfigSignal().isFirstComponent&&this.commentService.setCommentAnnotationsFromCommentsContainer([])}catch(e){this.loggingService.catch("Error in CommentsContainerComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in CommentsContainerComponent unsubscribe: ",e)}}handleCommentPinSlotChanged(e){try{let t=e.target;if(t.assignedElements().length>0){let r=t.assignedElements()[0];this.commentPinPortalService.setCommentPinOverrideTemplate(r)}}catch(t){this.loggingService.catch("Error in CommentsContainerComponent handleCommentPinSlotChanged: ")}}focusCommentAnnotation(){if(this.focusCommentAnnotationId&&!this.commentAnnotationFocused){let e=this.componentConfigSignal().commentPinAnnotations.find(t=>t.annotationId===this.focusCommentAnnotationId);e&&(this.commentAnnotationFocused=!0,sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e.annotationId),this.selectedAnnotationsMap[e.annotationId]||this.domService.toggleAnnotationSelection(e),setTimeout(()=>{let t=null;e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):(t=document.querySelector(`[data-velt-id='${e.annotationId}']`),sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e.annotationId)),t||(t=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e.annotationId}"]`)),t&&this.scrollToComment&&t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100))}}setCommentInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Re.COMMENT)}catch(e){this.loggingService.catch("Error in CommentsContainerComponent setCommentInstalledInAnalytics: ",e)}}disableCommentMode(){try{this.commentService.disableAddCommentMode()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent disableCommentMode: ",e)}}checkDarkMode(){try{this._darkAttribute===""?this.componentConfigSignal.update(e=>(e=D(E({},e),{darkMode:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{darkMode:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent checkDarkMode: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(Be),h(we),h(q1),h(l7),h(Wo),h(_),h(R),h(Ll),h(Si),h(Wi),h(ot))},o.\u0275cmp=O({type:o,selectors:[["app-comments-container"]],hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{textMode:"textMode",popoverMode:"popoverMode",popoverTriangleComponent:"popoverTriangleComponent",forceCloseAllOnEsc:"forceCloseAllOnEsc",collapsedComments:"collapsedComments",shortUserName:"shortUserName",readOnly:"readOnly",deleteThreadWithFirstComment:"deleteThreadWithFirstComment",resolveStatusAccessAdminOnly:"resolveStatusAccessAdminOnly",svgAsImg:"svgAsImg",commentToNearestAllowedElement:"commentToNearestAllowedElement",floatingCommentDialog:"floatingCommentDialog",moderatorMode:"moderatorMode",_streamMode:[0,"streamMode","_streamMode"],atHereLabel:"atHereLabel",_atHereEnabled:[0,"atHereEnabled","_atHereEnabled"],_deleteReplyConfirmation:[0,"deleteReplyConfirmation","_deleteReplyConfirmation"],_expandMentionGroups:[0,"expandMentionGroups","_expandMentionGroups"],_showMentionGroupsFirst:[0,"showMentionGroupsFirst","_showMentionGroupsFirst"],_linkCallback:[0,"linkCallback","_linkCallback"],_showMentionGroupsOnly:[0,"showMentionGroupsOnly","_showMentionGroupsOnly"],_fullExpanded:[0,"fullExpanded","_fullExpanded"],_draftMode:[0,"draftMode","_draftMode"],atHereDescription:"atHereDescription",_persistentCommentMode:[0,"persistentCommentMode","_persistentCommentMode"],_seenByUsers:[0,"seenByUsers","_seenByUsers"],signInButton:"signInButton",upgradeButton:"upgradeButton",attachments:"attachments",recordings:"recordings",reactions:"reactions",deviceInfo:"deviceInfo",commentIndex:"commentIndex",dialogOnHover:"dialogOnHover",dialogOnTargetElementClick:"dialogOnTargetElementClick",priority:"priority",status:"status",resolveButton:"resolveButton",_inboxMode:[0,"inboxMode","_inboxMode"],_suggestionMode:[0,"suggestionMode","_suggestionMode"],_mobileMode:[0,"mobileMode","_mobileMode"],_inlineCommentMode:[0,"inlineCommentMode","_inlineCommentMode"],_privateCommentMode:[0,"privateCommentMode","_privateCommentMode"],_minimap:[0,"minimap","_minimap"],_minimapPosition:[0,"minimapPosition","_minimapPosition"],_ghostComments:[0,"ghostComments","_ghostComments"],_ghostCommentsIndicator:[0,"ghostCommentsIndicator","_ghostCommentsIndicator"],_commentsOnDom:[0,"commentsOnDom","_commentsOnDom"],_resolvedCommentsOnDom:[0,"resolvedCommentsOnDom","_resolvedCommentsOnDom"],_filterCommentsOnDom:[0,"filterCommentsOnDom","_filterCommentsOnDom"],_bubbleOnPin:[0,"bubbleOnPin","_bubbleOnPin"],_bubbleOnPinHover:[0,"bubbleOnPinHover","_bubbleOnPinHover"],_multiThreadMode:[0,"multiThreadMode","_multiThreadMode"],_multiThread:[0,"multiThread","_multiThread"],_maxReplyAvatars:[0,"maxReplyAvatars","_maxReplyAvatars"],_replyAvatars:[0,"replyAvatars","_replyAvatars"],_groupMultipleMatch:[0,"groupMultipleMatch","_groupMultipleMatch"],_groupMatchedComments:[0,"groupMatchedComments","_groupMatchedComments"],_commentTool:[0,"commentTool","_commentTool"],_sidebarButtonOnCommentDialog:[0,"sidebarButtonOnCommentDialog","_sidebarButtonOnCommentDialog"],_deviceIndicatorOnCommentPins:[0,"deviceIndicatorOnCommentPins","_deviceIndicatorOnCommentPins"],_scrollToComment:[0,"scrollToComment","_scrollToComment"],_userMentions:[0,"userMentions","_userMentions"],_paginatedContactList:[0,"paginatedContactList","_paginatedContactList"],_deleteOnBackspace:[0,"deleteOnBackspace","_deleteOnBackspace"],_hotkey:[0,"hotkey","_hotkey"],_recordingSummary:[0,"recordingSummary","_recordingSummary"],_recordingTranscription:[0,"recordingTranscription","_recordingTranscription"],_allowedFileTypes:[0,"allowedFileTypes","_allowedFileTypes"],_recordingCountdown:[0,"recordingCountdown","_recordingCountdown"],_unreadIndicatorMode:[0,"unreadIndicatorMode","_unreadIndicatorMode"],_enterKeyToSubmit:[0,"enterKeyToSubmit","_enterKeyToSubmit"],_pinShadowDOM:[0,"pinShadowDom","_pinShadowDOM"],_dialogShadowDOM:[0,"dialogShadowDom","_dialogShadowDOM"],_persistentCommentShadowDOM:[0,"persistentCommentShadowDom","_persistentCommentShadowDOM"],_shadowDOM:[0,"shadowDom","_shadowDOM"],_textCommentToolShadowDOM:[0,"textCommentToolShadowDom","_textCommentToolShadowDOM"],_pinDarkMode:[0,"pinDarkMode","_pinDarkMode"],_textCommentToolDarkMode:[0,"textCommentToolDarkMode","_textCommentToolDarkMode"],_textCommentToolbarDarkMode:[0,"textCommentToolbarDarkMode","_textCommentToolbarDarkMode"],_textCommentToolbarShadowDOM:[0,"textCommentToolbarShadowDom","_textCommentToolbarShadowDOM"],_changeDetectionInCommentMode:[0,"changeDetectionInCommentMode","_changeDetectionInCommentMode"],_areaComment:[0,"areaComment","_areaComment"],_screenshot:[0,"screenshot","_screenshot"],_pinCursorImage:[0,"pinCursorImage","_pinCursorImage"],allowedElementIds:"allowedElementIds",allowedElementClassNames:"allowedElementClassNames",allowedElementQuerySelectors:"allowedElementQuerySelectors",_commentPinHighlighter:[0,"commentPinHighlighter","_commentPinHighlighter"],_customReactions:[0,"customReactions","_customReactions"],customStatus:"customStatus",customListDataOnAnnotation:"customListDataOnAnnotation",customListDataOnComment:"customListDataOnComment",attachmentNameInMessage:"attachmentNameInMessage",customPriority:"customPriority",_customAutocompleteSearch:[0,"customAutocompleteSearch","_customAutocompleteSearch"],customCategory:"customCategory",streamViewContainerId:"streamViewContainerId",composerMode:"composerMode",autoCategorize:"autoCategorize",commentplaceholder:[0,"commentPlaceholder","commentplaceholder"],replyplaceholder:[0,"replyPlaceholder","replyplaceholder"],isDarkMode:[0,"darkMode","isDarkMode"]},outputs:{onCommentAdd:"onCommentAdd",onSignIn:"onSignIn",onUpgrade:"onUpgrade",onCustomPinInject:"onCustomPinInject",onCommentUpdate:"onCommentUpdate",onCommentAccept:"onCommentAccept",onCommentReject:"onCommentReject",onSidebarButtonOnCommentDialogClick:"onSidebarButtonOnCommentDialogClick",onCommentSelectionChange:"onCommentSelectionChange",onCopyLink:"onCopyLink"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["commentsDataRef",""],[4,"ngIf"],[2,"display","none"],["id","comment-pin-slot","name","comment-pin",3,"slotchange"],[3,"componentConfigSignal"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],[3,"commentPinAnnotations","streamViewContainerId",4,"ngIf"],[3,"darkMode","commentAnnotation",4,"ngIf"],[3,"commentAnnotations","user","position",4,"ngIf"],[3,"commentPinAnnotations","streamViewContainerId"],[3,"darkMode","commentAnnotation"],[3,"commentAnnotations","user","position"]],template:function(t,r){t&1&&u(0,enn,5,5,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,fge,z1e,G1e,t8,Sn,E1,ge],encapsulation:2,changeDetection:0});let i=o;return i})();var tnn=["sidebarRef"],nnn=i=>({componentConfigSignal:i}),inn=(i,o)=>({condition:i,data:o}),onn=(i,o)=>({componentConfigSignal:i,sidebarRef:o}),rnn=(i,o)=>({template:i,context:o});function ann(i,o){if(i&1&&(y(0,"div",5,0),w(2,"app-comment-sidebar-skeleton",6)(3,"app-comment-sidebar-panel",7)(4,"app-comment-sidebar-focused-thread",8),b()),i&2){let n=me(1),e=l(3).ngIf,t=l();pe("s-overflow-hidden",e.moreFiltersVisible)("velt-sidebar--more-filters-visible",e.moreFiltersVisible),x("aria-expanded",e.sidebarVisible),m(2),d("componentConfigSignal",t.componentConfigSignal),m(),d("sidebarRef",n)("componentConfigSignal",t.componentConfigSignal),m(),d("componentConfigSignal",t.componentConfigSignal)("sidebarRef",n)}}function snn(i,o){if(i&1){let n=K();v(0),y(1,"div",3),P(2,"translate"),W("click",function(t){N(n);let r=l(3);return F(r.onClick(t))}),u(3,ann,5,10,"div",4),b(),C()}if(i&2){let n=l(2).ngIf,e=l();m(),pe("mobile",n.isPhone)("velt-sidebar-container--fullscreen",n.fullScreen)("visible",n.sidebarVisible||n.embedMode||n.floatingMode)("floating",n.floatingMode)("embed",n.embedMode)("page",n.pageMode)("velt-comment-sidebar--read-only",n.readOnly),d("ngClass",n.position),x("data-testid",e.componentId)("aria-label",M(2,18,"Comments sidebar")),m(2),d("veltDynamicTemplate",k(23,rnn,e.template,k(20,onn,e.componentConfigSignal,e.sidebarRef)))}}function lnn(i,o){if(i&1&&(v(0),u(1,snn,4,26,"ng-container",1),C()),i&2){let n=l().ngIf;m(),d("ngIf",n)}}function cnn(i,o){if(i&1&&(v(0),u(1,lnn,2,1,"ng-container",2),C()),i&2){let n=l();m(),d("veltIf",k(3,inn,n.conditionSignal(),A(1,nnn,n.componentConfigSignal)))}}var q1e=(()=>{let o=class o extends tt{constructor(e,t,r,a){super(e,t,void 0,void 0,void 0,a,r),this.elementRef=e,this.themeService=t,this.loggingService=r,this.dynamicDataService=a,this.onWrapperClick=new Me,this.componentId="velt-comments-sidebar-wrapper",super.initializeComponentConfigSignal(new qe)}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentsSidebarWrapperComponent ngOnInit:",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in CommentsSidebarWrapperComponent ngOnDestroy:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in setupA11yAttributes:",e)}}onClick(e){try{this.onWrapperClick.emit(e)}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Ke),h(_),h(S))},o.\u0275cmp=O({type:o,selectors:[["velt-comments-sidebar-wrapper-internal"]],viewQuery:function(t,r){if(t&1&&it(tnn,7),t&2){let a;Je(a=et())&&(r.sidebarRef=a.first)}},outputs:{onWrapperClick:"onWrapperClick"},standalone:!1,features:[V([S]),L],decls:1,vars:1,consts:[["sidebarRef",""],[4,"ngIf"],[4,"veltIf"],["data-velt-element","true","data-velt-comment-disabled","true","role","complementary",1,"velt-sidebar-container",3,"click","ngClass"],["class","velt-sidebar","role","region",3,"s-overflow-hidden","velt-sidebar--more-filters-visible",4,"veltDynamicTemplate"],["role","region",1,"velt-sidebar"],[3,"componentConfigSignal"],[3,"sidebarRef","componentConfigSignal"],[3,"componentConfigSignal","sidebarRef"]],template:function(t,r){t&1&&u(0,cnn,2,6,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Xr,X,ie,Rf,kf,O1,se,ge],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-sidebar-container[_ngcontent-%COMP%]{height:100vh;width:calc((26rem + 0px) * var(--velt-base-rem-unit));position:fixed;top:0;padding:var(--velt-spacing-lg);box-sizing:border-box;z-index:999999997}.velt-sidebar-container.velt-sidebar-container--fullscreen[_ngcontent-%COMP%]{width:100vw;padding:0}.velt-sidebar-container.velt-sidebar-container--fullscreen[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{border-radius:0;border:0}.velt-sidebar-container.velt-sidebar-container--fullscreen.left[_ngcontent-%COMP%], .velt-sidebar-container.velt-sidebar-container--fullscreen.right[_ngcontent-%COMP%]{transition:none}.velt-sidebar-container.left[_ngcontent-%COMP%]{left:-100%;transition:width .5s ease-in-out,left .5s ease-in-out}.velt-sidebar-container.left.visible[_ngcontent-%COMP%]{left:0}.velt-sidebar-container.right[_ngcontent-%COMP%]{right:-100%;transition:width .5s ease-in-out,right .5s ease-in-out}.velt-sidebar-container.right.visible[_ngcontent-%COMP%]{right:0}.velt-sidebar-container.mobile[_ngcontent-%COMP%]{width:100%;height:100%;box-sizing:border-box;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.velt-sidebar-container.embed[_ngcontent-%COMP%]{width:100%;height:100%;position:unset;border:0}.velt-sidebar-container.floating[_ngcontent-%COMP%]{height:90vh;position:unset;border:0;padding:0;width:calc((22.5rem + 0px) * var(--velt-base-rem-unit))}.velt-sidebar-container.floating.embed[_ngcontent-%COMP%]{width:100%;height:100%}.velt-sidebar-container.page[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{padding-bottom:0}.velt-sidebar-container[_ngcontent-%COMP%] *[_ngcontent-%COMP%]{box-sizing:border-box}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--velt-spacing-lg);font-weight:400;font-size:var(--velt-font-size-sm);line-height:21px;align-items:center;background:var(--velt-background-0);border-radius:var(--velt-border-radius-lg);width:100%;overflow-x:hidden;position:relative;height:100%;border:1px solid var(--velt-border-5)}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%] app-comment-sidebar-filter[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;-webkit-user-select:none;user-select:none;pointer-events:none}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar.velt-sidebar--more-filters-visible[_ngcontent-%COMP%] app-comment-sidebar-filter[_ngcontent-%COMP%]{pointer-events:initial;-webkit-user-select:initial;user-select:initial}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]::-webkit-scrollbar{display:none;width:0;height:0}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]:not(.s-overflow-hidden){overflow-y:auto}[_nghost-%COMP%] velt-comments-sidebar-wireframe{width:100%;height:100%;display:flex;flex-direction:column;gap:var(--velt-spacing-lg)}"],changeDetection:0});let i=o;return i})();var mnn=["sidebarOverlay"],pnn=["host"],gnn=i=>["snippyly-sidebar-panel","velt-overlay-panel",i];function unn(i,o){i&1&&He(0)}function hnn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,unn,1,0,"ng-container",7),b()),i&2){l(3);let n=me(3);m(),d("ngTemplateOutlet",n)}}function fnn(i,o){if(i&1&&(v(0),u(1,hnn,2,1,"velt-shadow-dom-internal",6),C()),i&2){l(2);let n=me(3),e=l();m(),d("ngIf",!e.template&&e.sidebarShadowDOM)("ngIfElse",n)}}function vnn(i,o){i&1&&He(0)}function Cnn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,vnn,1,0,"ng-container",7),b()),i&2){l(5);let n=me(3);m(),d("ngTemplateOutlet",n)}}function _nn(i,o){if(i&1&&(y(0,"div",11),u(1,Cnn,2,1,"velt-shadow-dom-internal",6),b()),i&2){let n=l(4).ngIf,e=me(3),t=l();pe("dark",n.darkMode),m(),d("ngIf",!t.template&&t.sidebarShadowDOM)("ngIfElse",e)}}function ynn(i,o){if(i&1&&u(0,_nn,2,4,"div",10),i&2){let n=l(3).ngIf;d("ngIf",n==null?null:n.sidebarVisible)}}function Snn(i,o){if(i&1&&(w(0,"div",8,2),u(2,ynn,1,1,"ng-template",9,3,Te)),i&2){let n=me(1),e=l(2).ngIf;m(2),d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",A(4,gnn,e.darkMode?"dark":""))}}function bnn(i,o){if(i&1&&u(0,fnn,2,2,"ng-container",6)(1,Snn,4,6,"ng-template",null,1,Te),i&2){let n=me(2),e=l().ngIf;d("ngIf",e.embedMode||e.floatingMode)("ngIfElse",n)}}function Inn(i,o){if(i&1){let n=K();y(0,"velt-comments-sidebar-wrapper-internal",12),P(1,"translate"),W("onWrapperClick",function(t){N(n);let r=l(2);return F(r.onClick(t))}),b()}if(i&2){let n=l().ngIf,e=l();d("componentConfigSignal",e.componentConfigSignal)("template",e.template)("darkMode",n.darkMode),x("data-testid",e.componentId)("aria-label",M(1,6,"Comments sidebar"))("aria-modal",!0)}}function Enn(i,o){if(i&1&&(v(0),u(1,bnn,3,2,"ng-template",5)(2,Inn,2,8,"ng-template",null,0,Te),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.isFirstComponent||n.floatingMode||n.embedMode)}}var n8=(()=>{let o=class o extends tt{set _pageMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{pageMode:t}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set _filterCount(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{filterCount:t}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _filterCount: ",t)}}set _customActions(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarCustomActions():this.commentService.disableSidebarCustomActions()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set focusedThreadMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFocusedThreadMode():this.commentService.disableFocusedThreadMode()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set _openAnnotationInFocusMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableOpenAnnotationInFocusMode():this.commentService.disableOpenAnnotationInFocusMode()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _openAnnotationInFocusMode: ",t)}}set _readOnly(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{sidebarReadMode:!!t}),r.readOnly=r.sidebarReadMode||this.commentService.getReadOnly(),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _readOnly: ",t)}}set _selection(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{selection:t!==!1}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _selection: ",t)}}set _expandOnSelection(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{expandOnSelection:t!==!1}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _expandOnSelection: ",t)}}set _sortData(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{sortData:e}),t))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _sortData: ",t)}}set enableUrlNavigation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarUrlNavigation():this.commentService.disableSidebarUrlNavigation()}set urlNavigation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarUrlNavigation():this.commentService.disableSidebarUrlNavigation()}set _queryParamsComments(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableQueryParamsComments():this.commentService.disableQueryParamsComments()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _queryParamsComments: ",t)}}set _fullScreen(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFullScreenInSidebar():this.commentService.disableFullScreenInSidebar()}catch{}}set _currentLocationSuffix(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{currentLocationSuffix:!!t}),r))}catch{}}set _filterOptionLayout(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{filterOptionLayout:e}),t))}catch{}}set _filterConfig(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.updateFilterConfig(t)}catch{}}set _groupConfig(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.componentConfigSignal.update(r=>(r=D(E({},r),{groupConfig:t}),r.groupConfig?.enable||(r.groupBy=null),r))}catch{}}set _filters(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.commentService.setCommentSidebarFilters(t)}catch{}}set _systemFiltersOperator(e){try{e&&this.commentService.setCommentSidebarSystemFiltersOperator(e)}catch{}}set _excludeLocationIds(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.commentService.setExcludeLocationIdsFromSidebar(t)}catch{}}set _fullExpanded(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{fullExpanded:!!t}),r))}catch{}}set _sidebarButtonCountType(e){try{this.commentService.setSidebarButtonCountType(e)}catch{}}set _filterGhostCommentsInSidebar(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFilterGhostCommentsInSidebar():this.commentService.disableFilterGhostCommentsInSidebar()}catch{}}set _sidebarShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{shadowDom:t}),r)),t?this.commentService.enableSidebarShadowDOM():this.commentService.disableSidebarShadowDOM()}catch{}}set _context(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.componentConfigSignal.update(r=>(r=D(E({},r),{context:t}),r))}catch{}}constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve){super(p,ve,void 0,r),this.analyticsService=e,this.authService=t,this.commentService=r,this.configService=a,this.domService=s,this.docService=c,this.elementRef=p,this.iamService=g,this.loggingService=f,this.breakpointObserver=I,this.customFilterService=T,this.translateService=B,this.cd=z,this.wireframeService=G,this.renderer=J,this.dynamicComponentService=ne,this.themeService=ve,this.embedMode=null,this.floatingMode=!1,this.dialogVariant="sidebar",this.focusedThreadDialogVariant="sidebar",this.filterPanelLayout="bottomSheet",this.pageModeComposerVariant="sidebar",this.searchPlaceholder="Search comments",this.openSidebar=new Me,this.onSidebarOpen=new Me,this.onSidebarCommentClick=new Me,this.onSidebarCommentClickEvent=new Me,this.onCommentClick=new Me,this.onSidebarClose=new Me,this.onCommentNavigationButtonClick=new Me,this.onFullscreen=new Me,this.subscriptions=[],this.locations={},this.commentAccessMode=uo,this.commentReadAnalyticsCalled=!0,this.peopleTypes={all:"All",other:"Other"},this.pageTypes={all:"All",other:"Other"},this.unsetType={id:"unset",name:"Not set"},this.objectKeys=Object.keys,this.filteredGroupedCommentAnnotationsObj={},this.filteredGroupedCommentAnnotations=[],this.veltId=vt(),this.veltElement=!0,this.defaultFilterConfig={location:{name:"Pages",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search pages",type:"system"},document:{name:"Documents",enable:!1,multiSelection:!0,enableGrouping:!1,placeholder:"Search documents",type:"system"},people:{name:"Author",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search authors",type:"system"},assigned:{name:"Assigned",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search assigned",type:"system"},tagged:{name:"Tagged",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search tagged",type:"system"},involved:{name:"Involved",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search involved",type:"system"},priority:{name:"Priority",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search priority",type:"system"},status:{name:"Status",enable:!1,multiSelection:!0,enableGrouping:!1,placeholder:"Search status",type:"system"},category:{name:"Category",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search category",type:"system"},commentType:{name:"Comment Type",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search comment type",type:"system"},version:{name:"Versions",enable:!0,multiSelection:!1,enableGrouping:!1,placeholder:"Search versions",type:"system"}},this.defaultGroupConfig={enable:!0,name:"Group By"},this.isUserGlobalContact=!1,this.resolvedCommentsOnDom=!1,this.position="right",this.commentRefId="",this.showDefault=!0,this.componentConfigSignal=xe({fullScreen:!1,embedMode:this.embedMode,floatingMode:this.floatingMode,pageMode:!1,currentLocationSuffix:!1,queryParamsComments:!1,variant:this.variant,dialogVariant:this.dialogVariant,focusedThreadDialogVariant:this.focusedThreadDialogVariant,pageModeComposerVariant:this.pageModeComposerVariant,fullExpanded:!1,systemFiltersOperator:dd.AND,annotations:[],filteredCommentPinAnnotations:[],filteredCommentAnnotationsCount:0,selectedAnnotationsMap:{},commentAnnotationsCountByFilters:{page:{},document:{},status:{},people:{},tagged:{},assigned:{},involved:{},version:{},priority:{},commentCategory:{},accessMode:{}},noCommentsFound:!1,noCommentsFoundForAppliedFilters:!1,pageCommentAnnotation:new Zo,commentCategoryMap:U.CommentCategoryMap,virtualScrollData:[],isFirstComponent:!1,searchPlaceholder:this.searchPlaceholder,enableAutoCategorize:!1,filterConfig:JSON.parse(JSON.stringify(this.defaultFilterConfig)),filters:{pages:[],documents:[],statuses:[],statusIds:[],people:[],assigned:[],tagged:[],involved:[],versions:[],versionIds:[],priorities:[],priorityIds:[],categories:[],categoryIds:[],accessModes:[],input:null},moreFiltersVisible:!1,groupByOptions:{},groupBy:null,peopleFilters:[],assignedFilters:[],taggedFilters:[],involvedFilters:[],enablePriority:!1,enableStatus:!0,appliedFiltersCount:0,priorities:[],statuses:[],accessModes:[{id:uo.PUBLIC,name:"Public"},{id:uo.PRIVATE,name:"Private"}],filterOptionLayout:"checkbox",filterCount:!0,sidebarVisible:!1,pages:{},documents:{},showAllPages:!1,showAllDocuments:!1,versions:[],groupConfig:JSON.parse(JSON.stringify(this.defaultGroupConfig)),user:null,currentPage:null,currentDocument:null,isUserAdmin:!1,isPrivateCommentAllowed:!1,isPhone:!1,darkMode:!1,skeletonLoading:!0,shadowDom:void 0,position:this.position,filterPanelLayout:this.filterPanelLayout,customActionsState:{},readOnly:!1,selection:!0,expandOnSelection:!0,sidebarReadMode:!1,filterRecentlyClosed:!1,location:null,fullscreenEnabled:!1,trackByCategoryId:this.trackByCategoryId.bind(this),trackByPriorityId:this.trackByPriorityId.bind(this),trackByCustomFilterId:this.trackByCustomFilterId.bind(this),trackByAccessModeId:this.trackByAccessModeId.bind(this),trackByPageKey:this.trackByPageKey.bind(this),trackByDocumentKey:this.trackByDocumentKey.bind(this),trackByPeople:this.trackByPeople.bind(this),trackByVersion:this.trackByVersion.bind(this),trackByGroupByOptionKey:this.trackByGroupByOptionKey.bind(this),onCommentAnnotationClick:this.onCommentAnnotationClick.bind(this),saveComment:this.saveComment.bind(this),trackCommentPinAnnotations:this.trackCommentPinAnnotations.bind(this),updateFilter:this.updateFilter.bind(this),toggleGroupedCommentAnnotations:this.toggleGroupedCommentAnnotations.bind(this),changeGroupBy:this.changeGroupBy.bind(this),closeSidebar:this.closeSidebar.bind(this),toggleMoreFilters:this.toggleMoreFilters.bind(this),openMoreFilters:this.openMoreFilters.bind(this),closeMoreFilters:this.closeMoreFilters.bind(this),savePageComment:this.savePageComment.bind(this),sortComments:this.sortComments.bind(this),goBackToAllComments:this.goBackToAllComments.bind(this),minimalFilterDropdownOpen:!1,minimalActionsDropdownOpen:!1,toggleMinimalFilterDropdown:this.toggleMinimalFilterDropdown.bind(this),unreadCommentsMap:null,minimalFilter:"all",filterCommentsByReadStatus:this.filterCommentsByReadStatus.bind(this),selectedMinimalFilterDropdownOption:{sorting:"date",filter:"all"},locationFilterDropdownOpen:!1,toggleLocationFilterDropdown:this.toggleLocationFilterDropdown.bind(this),documentFilterDropdownOpen:!1,toggleDocumentFilterDropdown:this.toggleDocumentFilterDropdown.bind(this),closeDocumentFilterDropdown:this.closeDocumentFilterDropdown.bind(this),markAllCommentAnnotationsAsRead:this.markAllCommentAnnotationsAsRead.bind(this),markAllCommentAnnotationsAsResolved:this.markAllCommentAnnotationsAsResolved.bind(this),toggleMinimalActionsDropdown:this.toggleMinimalActionsDropdown.bind(this),toggleCustomAction:this.toggleCustomAction.bind(this),focusedThreadMode:!1,openAnnotationInFocusMode:!1,focusedAnnotation:null,navigateToComment:this.navigateToComment.bind(this),resetFilters:this.resetFilters.bind(this),filterSearch:this.filterSearch.bind(this),customFilters:{},onDialogExpanded:this.onDialogExpanded.bind(this),onFullscreenClick:this.onFullscreenClick.bind(this)}),this.sidebarShadowDOM=!1,this.dataAvailable=!1,this.componentId="velt-comments-sidebar";try{this.subscriptions.push(super.onDarkModeChange().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{darkMode:Ne}),Ve))})),this.loggingService.log("%c[WB] Creating CLASS: CommentsSidebarComponent","color: blue;"),this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{groupBy:Ne.groupByOptions.page}),Ne.pageCommentAnnotation.isPageAnnotation=!0,Ne)),this.updateGroupByOptions(),this.subscriptions.push(this.commentService.getSidebarShadowDOM$().subscribe(Ne=>{this.sidebarShadowDOM=Ne})),this.subscriptions.push(this.commentService.getFocusedThreadMode$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{focusedThreadMode:Ne}),Ve))})),this.subscriptions.push(this.commentService.getOpenAnnotationInFocusMode$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{openAnnotationInFocusMode:Ne}),Ve))})),this.subscriptions.push(this.commentService.getReadOnly$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{readOnly:Ve.sidebarReadMode||Ne}),Ve))})),this.subscriptions.push(this.commentService.getQueryParamsComments$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{queryParamsComments:Ne}),Ve)),this.setPages(),this.setDocuments()})),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{unreadCommentsMap:Ne}),Ve))})),this.subscriptions.push(this.commentService.getFullScreenInSidebar$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{fullscreenEnabled:Ne}),Ve))})),this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(Ne=>{Ne.matches?this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{isPhone:!0}),Ve)):this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{isPhone:!1}),Ve))},Ne=>{this.loggingService.catch("Error in CommentsSidebarComponent breakpointObserver subscription: ",Ne)})),this.subscriptions.push(this.customFilterService.customStatusMap$.subscribe(Ne=>{this.statusMap=Ne,this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{statuses:Object.values(Ne)}),Ve)),this.pruneStaleStatuses()})),this.subscriptions.push(this.customFilterService.customPriorityMap$.subscribe(Ne=>{this.priorityMap=Ne,this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{priorities:[...Object.values(Ne),{id:"unset",name:"Not set",color:"#FFFFFF"}]}),Ve)),this.pruneStalePriorities()})),this.subscriptions.push(this.customFilterService.customCategoryMap$.subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{commentCategoryMap:D(E({},Ne),{other:{id:"other",name:"Other",color:"#00C48C"}})}),Ve)),this.pruneStaleCategories()}));let ye=sessionStorage.getItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE);ye&&this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{customActionsState:JSON.parse(ye)}),Ne))}catch(ye){this.loggingService.catch("Error in CommentsSidebarComponent constructor: ",ye)}}ngOnInit(){try{if(this.setupA11yAttributes(),sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)){let e=JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS));delete e?.input,e?.people?.length&&e.people.find(t=>typeof t=="string")&&(e.people=[]),e?.pages?.length&&e.pages?.forEach(t=>{t?.id||(t.id=t.displayName)}),sessionStorage.getItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_FILTERS_RESET)||(e.pages=[],sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_FILTERS_RESET,"true")),this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:e}),t)),this.pruneStaleStatuses(),this.pruneStalePriorities(),this.pruneStaleCategories()}if(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY)){let e=sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY);e&&this.componentConfigSignal.update(t=>(t=E({},t),Object.keys(t.groupByOptions).forEach(r=>{t.groupByOptions[r]===e&&(t.groupBy=e)}),t))}this.subscriptions.push(this.commentService.onCommentAdd$().subscribe(e=>{e?.annotation&&setTimeout(()=>{this.goToAnnotationInSidebar(e.annotation)},200)}))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent OnInit: ",e)}try{let e="velt-comments-sidebar-wireframe";this.variant&&(e+=`---${this.variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){this.commentRefId="comment-sidebar";let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r}}))}catch(e){this.loggingService.catch("Error in CommentDialogComponent OnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.forEach(e=>{e.unsubscribe()}),this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalFilterDropdownOpen:!1}),e)),this.commentService.setCommentsFromSidebarMap({comments:null,sidebarVisible:!1})}catch{}}ngAfterViewInit(){try{if(this.floatingMode||this.embedMode)this.initComponent();else{let e=document.querySelector(U.TAGS.SNIPPYLY_COMMENTS_SIDEBAR),t=document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR);t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),setTimeout(()=>{this.sidebarOverlay?.overlayRef?.hostElement&&(this.sidebarOverlay.overlayRef.hostElement.style.zIndex="1001")},100),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),setTimeout(()=>{this.sidebarOverlay?.overlayRef?.hostElement&&(this.sidebarOverlay.overlayRef.hostElement.style.zIndex="1001")},100),this.initComponent())}}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent AfterViewInit: ",e)}}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent ngOnChanges: ",t)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setupA11yAttributes:",e)}}onClick(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: onClick","color: green;");let t=e?.target?.tagName?.toLowerCase();t!==U.TAGS.VELT_COMMENT_DIALOG&&t!==U.TAGS.SNIPPYLY_COMMENT_DIALOG&&!e?.target?.closest(U.TAGS.VELT_COMMENT_DIALOG)&&!e?.target?.closest(U.TAGS.SNIPPYLY_COMMENT_DIALOG)&&this.domService.resetSelectedAnnotationsMap()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onClick: ",t)}}pruneStaleStatuses(){try{this.statusMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.statuses=e.filters.statuses.filter(t=>t.id in this.statusMap),e.filters.statusIds=e.filters.statuses?.map(t=>t?.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStaleStatuses: ",e)}}pruneStalePriorities(){try{this.priorityMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.priorities=e.filters.priorities.filter(t=>t.id in this.priorityMap),e.filters.priorityIds=e.filters.priorities?.map(t=>t.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStalePriorities: ",e)}}pruneStaleCategories(){try{this.componentConfigSignal().commentCategoryMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.categories=e.filters.categories?.filter(t=>t.id in e.commentCategoryMap),e.filters.categoryIds=e.filters.categories?.map(t=>t.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStaleCategories: ",e)}}trackByAnnotationGroup(e,t){return t?.displayName}trackByAnnotationId(e,t){return t?.annotationId}trackByCategoryId(e,t){return t?.value?.id||e}trackByPriorityId(e,t){return t?.id||e}trackByCustomFilterId(e,t){return t?.id||e}trackByAccessModeId(e,t){return t?.id||e}trackByPageKey(e,t){return t?.key||e}trackByDocumentKey(e,t){return t?.key||e}trackByPeople(e,t){return t?.id||e}trackByVersion(e,t){return t?.id||e}trackByGroupByOptionKey(e,t){return t?.key||e}initComponent(){try{this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),this.componentConfigSignal().user&&(this.setCommentSidebarInstalledInAnalytics(),this.setCommentSidebarEmbedModeInAnalytics(),this.setCommentSidebarFloatingModeInAnalytics())},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getUser$ subscription: ",e)})),this.subscriptions.push(this.docService.getDocumentPaths$().subscribe(e=>{this.documentPaths=e,this.getAllCommentsOnCurrentDocument()},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getDocumentPaths$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarCustomActionEventData().subscribe(e=>{e&&(this.componentConfigSignal.update(t=>(t=D(E({},t),{customActionsState:e.actions}),t)),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify(e.actions)))})),this.subscriptions.push(this.docService.getLocation$().subscribe(e=>{this.location=e,this.componentConfigSignal.update(a=>(a=D(E({},a),{location:e}),a));let t=this.commentService.getCommentSidebarFilters(),r=t?E({},t):{version:[]};this.location?.location?.version?r.version=[{id:this.location.location.version?.id,name:this.location.location.version?.name}]:r?.version||(r.version=[]),this.commentService.setCommentSidebarFilters(r),this.setPages(),this.filteredGroupedCommentAnnotationsObj={}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getLocation$ subscription: ",e)})),this.subscriptions.push(this.docService.getLocations$().subscribe(e=>{this.locations=e,this.filteredGroupedCommentAnnotationsObj={}})),this.subscriptions.push(this.commentService.getEnableStatus$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enableStatus:e}),t))})),this.subscriptions.push(this.commentService.getEnablePriority$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enablePriority:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getEnablePriority$ subscription: ",e)})),this.subscriptions.push(this.commentService.getEnableAutoCategorize$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enableAutoCategorize:e}),t))})),this.subscriptions.push(this.commentService.getSidebarVisibility$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{sidebarVisible:e}),t)),this.componentConfigSignal().sidebarVisible&&(this.commentReadAnalyticsCalled=!1,setTimeout(()=>{Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length&&this.goToAnnotationInSidebar(this.componentConfigSignal().selectedAnnotationsMap[Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0]])},500)),this.componentConfigSignal().sidebarVisible?(this.getAllCommentsOnCurrentDocument(),this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:this.componentConfigSignal().filteredCommentPinAnnotations,sidebarVisible:!0})):(this.commentService.getSidebarButtonCountType()==="default"&&this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:this.componentConfigSignal().filteredCommentPinAnnotations,sidebarVisible:!1}),this.componentConfigSignal().focusedThreadMode&&this.componentConfigSignal().focusedAnnotation&&this.goBackToAllComments())},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarButtonCountType$().subscribe(e=>{e==="filter"&&this.getAllCommentsOnCurrentDocument()})),this.subscriptions.push(this.commentService.getCommentSidebarFilters$().subscribe(e=>{this.mergeClientFilters(e)})),this.subscriptions.push(this.commentService.getCommentSidebarSystemFiltersOperator$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{systemFiltersOperator:e}),t)),this.filterCommentAnnotations()})),this.subscriptions.push(this.commentService.getOpenSidebar$().subscribe(e=>{this.openSidebar.emit(e),this.onSidebarOpen.emit(e)},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getOpenSidebar$ subscription: ",e)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(e=>{let t=this.componentConfigSignal().selectedAnnotationsMap;this.componentConfigSignal.update(c=>(c=D(E({},c),{selectedAnnotationsMap:e}),c)),Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1&&!this.commentService.showFloatingComments()&&this.commentService.setSidebarVisibility(!0);let r=Object.keys(e||{}),a=Object.keys(t||{}),s=r.find(c=>!a.includes(c));if(s){let c=this.componentConfigSignal().annotations.find(p=>p.annotationId===s);c&&(this.componentConfigSignal().focusedThreadMode&&this.componentConfigSignal().openAnnotationInFocusMode?this.componentConfigSignal.update(p=>(p=D(E({},p),{focusedAnnotation:c}),p)):setTimeout(()=>{this.goToAnnotationInSidebar(c)},100))}else{let c=this.componentConfigSignal().focusedAnnotation;this.componentConfigSignal().focusedThreadMode&&this.componentConfigSignal().openAnnotationInFocusMode&&c&&!r.includes(c?.annotationId)&&this.goBackToAllComments()}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.domService.onDocumentClick$().subscribe(e=>{try{if(this.componentConfigSignal().sidebarVisible&&e&&!this.elementRef?.nativeElement?.contains(e?.target)){let t=document.querySelectorAll(".cdk-overlay-container");Array.from(t).some(a=>a?.contains(e?.target))||!this.embedMode&&!this.commentService.isSidebarOpenedByCustomTrigger()&&(e?.target?.hasAttribute(U.ATTRIBUTES.VELT_DOWNLOAD_BUTTON)||(this.closeSidebar(),e?.stopPropagation()))}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onDocumentClick: ",t)}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent onDocumentClick$ subscription: ",e)})),this.subscriptions.push(this.iamService.isUserAdmin$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{isUserAdmin:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent isUserAdmin$ subscription: ",e)})),this.subscriptions.push(this.commentService.isPrivateCommentAllowed$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{isPrivateCommentAllowed:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent isPrivateCommentAllowed$ subscription: ",e)})),this.getAllCommentsOnCurrentDocument(),this.subscriptions.push(this.commentService.getSidebarCustomData().subscribe(e=>{this.updateVirtualScrollData(e)}))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent initComponent: ",e)}}updateVirtualScrollData(e){try{if(this.commentService.getSidebarCustomActionsValue()){let t=[];this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData=[],s)),e?.data?.forEach((s,c)=>{e?.options?.grouping!==!1&&this.componentConfigSignal.update(p=>(p=E({},p),p.virtualScrollData.push({type:"group",data:{displayName:s?.groupName,isExpanded:s?.isExpanded===void 0&&c===0||s?.isExpanded,annotations:s?.annotations}}),p)),(s?.isExpanded===void 0&&c===0||s?.isExpanded)&&s?.annotations?.forEach(p=>{this.componentConfigSignal.update(g=>(g=E({},g),g.virtualScrollData.push({type:"annotation",data:p}),g))}),t.push(...s?.annotations||[])}),this.componentConfigSignal.update(s=>(s=D(E({},s),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),s));let r=this.componentConfigSignal().embedMode||this.componentConfigSignal().sidebarVisible;this.commentService.setCommentsFromSidebarMap({comments:t,sidebarVisible:!!r}),this.componentConfigSignal.update(s=>(s=E({},s),s.filteredCommentAnnotationsCount=t?.length||0,s)),this.cd.markForCheck();let a=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;a&&(a.scrollTop=0)}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateVirtualScrollData: ",t)}}updateVirtualScrollDataGroupToggle(e){try{if(this.commentService.getSidebarCustomActionsValue()){this.componentConfigSignal.update(r=>(r=E({},r),r.virtualScrollData=[],r)),e?.forEach(r=>{r.type==="group"&&(this.componentConfigSignal.update(a=>(a=E({},a),a.virtualScrollData.push(r),a)),r?.data?.isExpanded&&r?.data?.annotations.forEach(a=>{this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData.push({type:"annotation",data:a}),s))}))}),this.componentConfigSignal.update(r=>(r=D(E({},r),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),r)),this.cd.markForCheck();let t=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;t&&(t.scrollTop=0)}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateVirtualScrollDataGroupToggle: ",t)}}getAllCommentsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentsOnCurrentDocument","color: green;");try{this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.componentConfigSignal.update(e=>(e=D(E({},e),{skeletonLoading:!0}),e)),this.getAllCommentAnnotationsSubscription=this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,fromCommentSidebar:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsSidebar"}}}).pipe(de(e=>(e||this.componentConfigSignal.update(t=>(t=D(E({},t),{skeletonLoading:!0}),t)),e)),Le(e=>!!e),de(e=>e?.filter(t=>t?.comments?.length)),he(e=>this.commentService.getFilterGhostCommentsInSidebar$().pipe(he(t=>t?this.commentService.getGhostCommentAnnotationMap$().pipe(de(r=>r?e?.filter(a=>!r?.[a?.annotationId]):e)):le(e)))),he(e=>this.commentService.getExcludeLocationIdsFromSidebar$().pipe(de(t=>t?.length&&e?.length?e.filter(r=>r?.location?.id?!t.includes(r.location.id):!0):e))),he(e=>this.commentService.getResolvedCommentsOnDom$().pipe(de(t=>(this.resolvedCommentsOnDom!==t&&(this.resolvedCommentsOnDom=t,t&&this.setResolvedStatusInFilter()),e))))).subscribe(e=>{if(this.dataAvailable=!0,this.componentConfigSignal.update(t=>{if(t=D(E({},t),{skeletonLoading:!1}),t.annotations=e?.filter(r=>!r?.isPageAnnotation||r?.comments?.length)||[],t.sortData==="asc"?t.annotations=t.annotations?.sort((r,a)=>r.lastUpdated-a.lastUpdated):t.sortData==="none"?t.annotations=t.annotations?.sort((r,a)=>a.createdAt-r.createdAt):t.annotations=t.annotations?.sort((r,a)=>a.lastUpdated-r.lastUpdated),t?.focusedAnnotation?.annotationId){let r=e?.find(a=>a.annotationId===t?.focusedAnnotation?.annotationId);r&&(t.focusedAnnotation=r)}return t}),this.setPages(),this.setDocuments(),this.setVersions(),this.setPeople(),this.filterCommentAnnotations(),this.updateAnnotationCountsByFilter(),this.componentConfigSignal().annotations?.length){let t=sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID);if(t){sessionStorage.removeItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID),this.commentService.setSidebarVisibility(!0);let r=this.componentConfigSignal().annotations.find(a=>a.annotationId===t);r&&this.goToAnnotation(r)}this.componentConfigSignal().sidebarVisible&&!this.commentReadAnalyticsCalled&&this.setCommentReadInAnalytics()}this.componentConfigSignal.update(t=>(t=D(E({},t),{noCommentsFound:!this.componentConfigSignal().annotations?.length}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getAllCommentsOnCurrentDocument subscription: ",e),this.componentConfigSignal.update(t=>(t=D(E({},t),{skeletonLoading:!1}),t))})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent getAllCommentsOnCurrentDocument: ",e)}}mergeClientFilters(e){try{if(Object.keys(e||{})?.length){if(e?.location&&(e?.location?.length?(this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{pages:[]})}),t)),e?.location?.forEach(t=>{if(t?.id&&(this.componentConfigSignal().filters?.pages||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{pages:[]})}),a)),!this.componentConfigSignal().filters.pages.find(a=>a.id===t.id))){let a=this.docService.genarateLocationId(t);this.componentConfigSignal.update(s=>(s=D(E({},s),{filters:D(E({},s.filters),{pages:[...s.filters.pages,{id:t.id,displayName:t.displayName,locationIds:[a],selected:!0}]})}),s))}})):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{pages:[]})}),t)),this.updatePageSelectedState()),e?.document&&(e?.document?.length?(this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{documents:[]})}),t)),e?.document?.forEach(t=>{(t?.id||t?.documentName)&&(this.componentConfigSignal().filters?.documents||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{documents:[]})}),a)),this.componentConfigSignal().filters.documents.find(a=>a.id===t.id||a.documentName===t.documentName)||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{documents:[...a.filters.documents,{id:t.id||t.documentName,documentName:t.documentName||t.id,selected:!0}]})}),a)))})):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{documents:[]})}),t)),this.updateDocumentSelectedState()),e?.priority)if(e?.priority?.length){let t=e.priority;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{priorities:r.priorities.filter(a=>t.includes(a.id)),priorityIds:t})}),r))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{priorities:[],priorityIds:[]})}),t));if(e?.category)if(e?.category?.length){if(this.componentConfigSignal().commentCategoryMap){let t=e.category;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{categories:Object.values(r.commentCategoryMap).filter(a=>t.includes(a.id)),categoryIds:t})}),r))}}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{categories:[],categoryIds:[]})}),t));if(e?.status)if(e?.status?.length){let t=e.status;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{statuses:r.statuses.filter(a=>t.includes(a.id)),statusIds:t})}),r))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{statuses:[],statusIds:[]})}),t));else sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)||this.setDefaultStatuses();if(e?.people){if(e?.people?.length){let t=[],r=this.componentConfigSignal().user;r&&e.people.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.people.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().peopleFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{people:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{people:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.assigned){if(e?.assigned?.length){let t=[],r=this.componentConfigSignal().user;r&&e.assigned.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.assigned.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().assignedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{assigned:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{assigned:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.tagged){if(e?.tagged?.length){let t=[],r=this.componentConfigSignal().user;r&&e.tagged.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.tagged.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().taggedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{tagged:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{tagged:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.involved){if(e?.involved?.length){let t=[],r=this.componentConfigSignal().user;r&&e.involved.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.involved.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().involvedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{involved:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{involved:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}e?.version&&(e?.version?.length?this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{versions:e.version?.map(r=>({id:r.id,name:r.name||r.id}))||[],versionIds:e.version?.map(r=>r.id)||[]})}),t)):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{versions:[],versionIds:[]})}),t)),this.setVersions()),Object.keys(this.componentConfigSignal().filterConfig).forEach(t=>{this.componentConfigSignal().filterConfig[t]?.type==="custom"&&Object.keys(e).includes(t)&&e?.[t]&&(e?.[t]?.length?this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{[t]:e[t]?.map(a=>({id:a.id,name:a.name||a.id}))||[],[t+"Ids"]:e[t]?.map(a=>a.id)||[]})}),r)):this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{[t]:[],[t+"Ids"]:[]})}),r)))}),this.filterCommentAnnotations(),this.updateAnnotationCountsByFilter(),this.setFiltersToStorage()}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent mergeClientFilters: ",t)}}onCommentAnnotationClick(e){try{let t=this.commentService.getCommentAnnotationForClient(e);if(this.emitOnSidebarCommentClick(t),!this.componentConfigSignal().selection)return;this.componentConfigSignal().focusedThreadMode?this.componentConfigSignal.update(r=>(r=D(E({},r),{focusedAnnotation:e}),r)):this.navigateToComment(e,!1)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onCommentAnnotationClick: ",t)}}navigateToComment(e,t=!0){try{if(t){let r=this.commentService.getCommentAnnotationForClient(e);this.emitOnCommentNavigationButtonClick(r)}if(this.commentService.getSidebarUrlNavigation()&&t)if(e?.pageInfo?.url&&e.pageInfo?.url!==window.location.href){sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID,e.annotationId);let r=e.pageInfo.url;try{let a=window.location.origin,s=new URL(e.pageInfo.url).origin;a!==s&&(r=r.replace(s,a))}catch(a){this.loggingService.catch("Error in CommentsSidebarComponent onCommentAnnotationClick in comparing url domains: ",a)}window.location.href===r?this.goToAnnotation(e,t):window.location.href=r}else this.goToAnnotation(e,t);else this.goToAnnotation(e,t)}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent navigateToComment: ",r)}}goToAnnotation(e,t=!0){try{if(this.componentConfigSignal().selectedAnnotationsMap[e.annotationId]||e?.targetTextRange&&sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.annotationId),t)this.domService.toggleAnnotationSelection(e,void 0,void 0,!0);else{let r=this.componentConfigSignal().expandOnSelection?"sidebarShowReplies":void 0;this.domService.toggleAnnotationSelection(e,void 0,r,!0)}t&&setTimeout(()=>{let r=null;e.targetElement||e.areaAnnotationId?r=document.getElementById(`comment-pin-container-${e.annotationId}`):r=document.querySelector(`[data-velt-id='${e.annotationId}']`),r||(r=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e.annotationId}"]`)),r&&r.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100)}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent goToAnnotation: ",r)}}goToAnnotationInSidebar(e,t="smooth"){try{let s=document?.querySelector(".velt-comments-sidebar-container")?.querySelector("velt-shadow-dom-internal")?.shadowRoot?.getElementById(`sidebar-${e.annotationId}`);s||(s=document.getElementById(`sidebar-${e.annotationId}`)),s&&s.scrollIntoView({behavior:t,block:"center",inline:"center"})}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent goToAnnotationInSidebar: ",r)}}saveComment(e,t){this.commentService.saveComment(e,t)}getDisplayNameFromPageInfo(e){try{return this.componentConfigSignal().queryParamsComments&&e&&e?.queryParams?`${e?.path||""}${e?.queryParams||""}`:e?.path||""}catch{return""}}setPages(){try{this.componentConfigSignal.update(a=>D(E({},a),{pages:{},currentPage:void 0}));let e=new Map,t={};this.componentConfigSignal().annotations.forEach(a=>{let s=a.locationId||a.documentParamsId;if(!s){t.other||(t.other={locationIds:[],displayName:"Others",id:"other"});return}let c=a?.location?.locationName||a?.documentParams?.locationName||this.getDisplayNameFromPageInfo(a?.pageInfo)||"",p=a?.location?.id||c;e.has(s)||(t[p]||(t[p]={locationIds:[],displayName:c,id:p}),e.set(s,p),t[p].locationIds.push(s))}),this.componentConfigSignal.update(a=>{let s=this.location?.locationId,c;if(s){let p=e.get(s);p&&(c=t[p].displayName)}else t.other&&(c="Others");return D(E({},a),{pages:t,currentPage:c})}),this.updateLocationInStorage(),this.componentConfigSignal().annotations?.length&&!sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)&&(this.updateFilter({key:"pages",value:null},!0),this.setDefaultStatuses()),this.updatePageSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setPages: ",e)}}setDocuments(){try{this.componentConfigSignal.update(a=>D(E({},a),{documents:{},currentDocument:void 0}));let e=new Map,t={};this.componentConfigSignal().annotations.forEach(a=>{let s=a?.metadata?.clientDocumentId?.toString(),c=a?.metadata?.documentId?.toString(),g=this.docService.getDocumentMetadata(c)?.documentName;if(!s){t.other||(t.other={id:"other",documentName:"Others"});return}if(e.has(s))return;let f=s;t[f]||(t[f]={id:s,documentName:g||s}),e.set(s,f)}),this.componentConfigSignal.update(a=>{let s=this.documentPaths?.clientDocumentId?.toString(),c;if(s){let p=e.get(s);p&&(c=t[p].id)}else t.other&&(c="other");return D(E({},a),{documents:t,currentDocument:c})}),this.componentConfigSignal().annotations?.length&&!sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)&&this.updateFilter({key:"documents",value:null},!0),this.updateDocumentSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setDocuments: ",e)}}setDefaultStatuses(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDefaultStatuses","color: green;"),this.componentConfigSignal.update(e=>(e=D(E({},e),{filters:D(E({},e.filters),{statuses:[this.customFilterService.defaultStatus,...this.customFilterService.ongoingStatuses],statusIds:[this.customFilterService.defaultStatus?.id,...this.customFilterService.ongoingStatuses.map(t=>t?.id)]})}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setDefaultStatuses: ",e)}}setResolvedStatusInFilter(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setResolvedStatusInFilter","color: green;"),this.componentConfigSignal().filters.statuses?.length&&this.customFilterService.resolvedStatus&&(this.componentConfigSignal().filters.statuses.find(t=>t?.id===this.customFilterService.resolvedStatus.id)||this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{statuses:[...t.filters.statuses,this.customFilterService.resolvedStatus],statusIds:[...t.filters.statuses.map(r=>r?.id),this.customFilterService.resolvedStatus.id]})}),t)))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setResolvedStatusInFilter: ",e)}}trackCommentPinAnnotations(e,t){return t?.type==="group"?t?.data?.displayName:t?.type==="annotation"?t?.data?.annotationId:e}updateCurrentLocationIdInStorage(){try{this.location?.locationId&&this.componentConfigSignal().filters?.pages?.length&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.pages.forEach(t=>{t?.displayName===e.currentPage&&(t?.locationIds?.includes(this.location?.locationId)||t.locationIds.push(this.location?.locationId))}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateCurrentLocationIdInStorage: ",e)}}updateLocationInStorage(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.filters.pages.forEach(t=>{e.pages[t.displayName]&&(t.locationIds=e.pages[t.displayName].locationIds?.slice())}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateLocationInStorage: ",e)}}updatePageSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.pages).forEach(t=>{let r=e.filters?.pages?.find(a=>a.id===t?.id);r?(t.selected=!0,r.displayName||(r.displayName=t.displayName)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updatePageSelectedState: ",e)}}setVersions(){try{let e=[];this.componentConfigSignal().annotations&&this.componentConfigSignal.update(t=>(t=E({},t),t.annotations.forEach(r=>{r?.location?.version&&(e.find(a=>a.id===r?.location?.version?.id)||e.push(r?.location?.version))}),t)),this.componentConfigSignal().filters?.versions?.length&&this.componentConfigSignal.update(t=>(t=E({},t),t.filters.versions.forEach(r=>{e.find(a=>a.id===r?.id)||r?.id!=="unset"&&e.push(r)}),t)),this.componentConfigSignal.update(t=>(t=E({},t),t.versions=e?.sort((r,a)=>r?.id?.localeCompare(a?.id)),t.versions.push({id:"unset",name:"Not set"}),t)),this.componentConfigSignal().annotations?.length&&!this.componentConfigSignal().versions?.length&&this.updateFilter({key:"versions",value:null},!0)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setVersions: ",e)}}setPeople(){try{let e=[],t=[],r=[],a=[],s=this.componentConfigSignal().user;s?.userId&&(e.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),t.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),r.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),a.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s})),this.componentConfigSignal().annotations&&this.componentConfigSignal.update(c=>(c=E({},c),c.annotations.forEach(p=>{p?.from?.userId&&c.user?.userId!==p?.from?.userId&&!e.find(g=>g.id===p?.from?.userId)&&e.push({id:p?.from?.userId,name:`${p?.from?.name||p?.from?.email}`,user:p?.from}),p?.assignedTo?.userId&&c.user?.userId!==p?.assignedTo?.userId&&!t.find(g=>g.id===p?.assignedTo?.userId)&&t.push({id:p?.assignedTo?.userId,name:`${p?.assignedTo?.name||p?.assignedTo?.email}`,user:p?.assignedTo}),p?.comments?.forEach(g=>{g?.taggedUserContacts?.forEach(f=>{f?.contact?.userId&&c.user?.userId!==f?.contact?.userId&&!r.find(I=>I.id===f?.contact?.userId)&&r.push({id:f?.contact?.userId,name:`${f?.contact?.name||f?.contact?.email}`,user:f?.contact})})}),p?.from?.userId&&c.user?.userId!==p?.from?.userId&&!a.find(g=>g.id===p?.from?.userId)&&a.push({id:p?.from?.userId,name:`${p?.from?.name||p?.from?.email}`,user:p?.from}),p?.assignedTo?.userId&&c.user?.userId!==p?.assignedTo?.userId&&!a.find(g=>g.id===p?.assignedTo?.userId)&&a.push({id:p?.assignedTo?.userId,name:`${p?.assignedTo?.name||p?.assignedTo?.email}`,user:p?.assignedTo}),p?.comments?.forEach(g=>{g?.taggedUserContacts?.forEach(f=>{f?.contact?.userId&&c.user?.userId!==f?.contact?.userId&&!a.find(I=>I.id===f?.contact?.userId)&&a.push({id:f?.contact?.userId,name:`${f?.contact?.name||f?.contact?.email}`,user:f?.contact})})})}),c)),this.componentConfigSignal().filters?.people?.length&&this.componentConfigSignal.update(c=>(c=E({},c),c.filters.people.forEach(p=>{e.find(g=>g.id===p?.id)||p?.id!=="other"&&e.push(p)}),c.filters.assigned.forEach(p=>{t.find(g=>g.id===p?.id)||p?.id!=="other"&&t.push(p)}),c.filters.tagged.forEach(p=>{r.find(g=>g.id===p?.id)||p?.id!=="other"&&r.push(p)}),c.filters.involved.forEach(p=>{a.find(g=>g.id===p?.id)||p?.id!=="other"&&a.push(p)}),c)),this.componentConfigSignal.update(c=>(c=D(E({},c),{peopleFilters:e,assignedFilters:t,taggedFilters:r,involvedFilters:a}),c)),this.componentConfigSignal().annotations?.length&&(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)||(this.updateFilter({key:"people",value:null},!0),this.updateFilter({key:"assigned",value:null},!0),this.updateFilter({key:"tagged",value:null},!0),this.updateFilter({key:"involved",value:null},!0))),this.updatePeopleSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setPeople: ",e)}}updatePeopleSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.peopleFilters.forEach(t=>{let r=e.filters?.people?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.assignedFilters.forEach(t=>{let r=e.filters?.assigned?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.taggedFilters.forEach(t=>{let r=e.filters?.tagged?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.involvedFilters.forEach(t=>{let r=e.filters?.involved?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updatePeopleSelectedState: ",e)}}updateFilterConfig(e){try{if(e){let t=this.componentConfigSignal().filters,r=JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS));r||(r={}),Object.keys(e).forEach(a=>{e[a]?.type==="custom"&&(r[a]?(t[a]=r[a],t[a+"Ids"]=r[a+"Ids"]):(t[a]=[],t[a+"Ids"]=[]))}),this.componentConfigSignal.update(a=>{let s=E(E({},this.defaultFilterConfig),e);return a=D(E({},a),{filterConfig:s,filters:t}),a}),this.setFiltersToStorage()}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filterConfig:JSON.parse(JSON.stringify(this.defaultFilterConfig))}),t));this.updateGroupByOptions(),this.filterCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateFilterConfig: ",t)}}updateGroupByOptions(){try{let e={};this.componentConfigSignal.update(r=>(r=E({},r),Object.keys(r.filterConfig).forEach(a=>{let s=r.filterConfig[a];s.enableGrouping&&(e[a]=s.name)}),r.groupByOptions=JSON.parse(JSON.stringify(e)),r));let t=!1;this.componentConfigSignal().groupBy&&Object.keys(this.componentConfigSignal().groupByOptions).forEach(r=>{this.componentConfigSignal().groupByOptions[r]===this.componentConfigSignal().groupBy&&(t=!0)}),(!this.componentConfigSignal().groupBy||!t)&&this.componentConfigSignal.update(r=>(r=D(E({},r),{groupBy:Object.values(r.groupByOptions)[0]}),r))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateGroupByOptions: ",e)}}updateFilter(e,t=!1){let{key:r,value:a}=e;try{if(r)switch(r){case"statuses":if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{statuses:[],statusIds:[]})}),g)),this.resolvedCommentsOnDom=!0;else{let g=this.componentConfigSignal().filters?.statuses||[];g.find(f=>f.id===a.id)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.statuses=g.filter(I=>I.id!==a.id),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters.statuses=[...g,a],f)),this.componentConfigSignal.update(f=>(f=D(E({},f),{filters:D(E({},f.filters),{statusIds:f.filters.statuses.map(I=>I?.id)})}),f))}break;case"pages":let s=this.componentConfigSignal().filters.pages||[];if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{pages:[]})}),g));else{let g=a?.id||a?.displayName;s.find(f=>f?.id===g||f?.displayName===g)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=s.filter(I=>I?.id!==g&&I?.displayName!==g),f)):this.componentConfigSignal().filterConfig?.location?.multiSelection?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=[...s,a],f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=[a],f))}this.sortPageFilters(),this.updatePageSelectedState();break;case"documents":let c=this.componentConfigSignal().filters.documents||[];if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{documents:[]})}),g));else{let g=a?.id;c.find(f=>f?.id===g)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.documents=c.filter(I=>I?.id!==g),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filterConfig?.document?.multiSelection?f.filters.documents=[...c,a]:f.filters.documents=[a],f))}this.updateDocumentSelectedState();break;case"people":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.people||[];return t?g.filters.people=[]:f.find(I=>I?.id===a?.id)?g.filters.people=f.filter(I=>I?.id!==a?.id):g.filterConfig?.people?.multiSelection?g.filters.people=[...f,a]:g.filters.people=[a],g}),this.updatePeopleSelectedState();break;case"tagged":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.tagged||[];return t?g.filters.tagged=[]:f.find(I=>I?.id===a?.id)?g.filters.tagged=f.filter(I=>I?.id!==a?.id):g.filterConfig?.tagged?.multiSelection?g.filters.tagged=[...f,a]:g.filters.tagged=[a],g}),this.updatePeopleSelectedState();break;case"assigned":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.assigned||[];return t?g.filters.assigned=[]:f.find(I=>I?.id===a?.id)?g.filters.assigned=f.filter(I=>I?.id!==a?.id):g.filterConfig?.assigned?.multiSelection?g.filters.assigned=[...f,a]:g.filters.assigned=[a],g}),this.updatePeopleSelectedState();break;case"involved":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.involved||[];return t?g.filters.involved=[]:f.find(I=>I?.id===a?.id)?g.filters.involved=f.filter(I=>I?.id!==a?.id):g.filterConfig?.involved?.multiSelection?g.filters.involved=[...f,a]:g.filters.involved=[a],g}),this.updatePeopleSelectedState();break;case"categories":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.categories||[];return t?g.filters.categories=[]:f.find(I=>I.id===a.id)?g.filters.categories=f.filter(I=>I!==a):g.filterConfig?.category?.multiSelection?g.filters.categories=[...f,a]:g.filters.categories=[a],g.filters.categoryIds=g.filters.categories?.map(I=>I.id),g});break;case"priorities":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.priorities||[];return t?g.filters.priorities=[]:f.find(I=>I.id===a.id)?g.filters.priorities=f.filter(I=>I.id!==a.id):g.filterConfig?.priority?.multiSelection?g.filters.priorities=[...f,a]:g.filters.priorities=[a],g.filters.priorityIds=g.filters.priorities?.map(I=>I.id),g});break;case"accessModes":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.accessModes||[];return t?g.filters.accessModes=[]:f.find(I=>I===a.id)?g.filters.accessModes=f.filter(I=>I!==a.id):g.filterConfig?.commentType?.multiSelection?g.filters.accessModes=[...f,a.id]:g.filters.accessModes=[a.id],g});break;case"versions":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.versions||[];return t?g.filters.versions=[]:f.find(I=>I.id===a.id)?g.filters.versions=f.filter(I=>I.id!==a.id):g.filterConfig?.version?.multiSelection?g.filters.versions=[...f,a]:g.filters.versions=[a],g.filters.versionIds=g.filters.versions?.map(I=>I?.id),g});break;default:let p=r+"Ids";if(this.componentConfigSignal().filterConfig[r]?.type==="custom")if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{[r]:[],[p]:[]})}),g)),this.resolvedCommentsOnDom=!0;else{let g=this.componentConfigSignal().filters?.[r]||[];this.componentConfigSignal().filterConfig[r]?.multiSelection?g.find(f=>f.id===a.id)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=g.filter(I=>I.id!==a.id),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=[...g,a],f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=[a],f)),this.componentConfigSignal.update(f=>(f=D(E({},f),{filters:D(E({},f.filters),{[p]:f.filters[r].map(I=>I?.id)})}),f))}else this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{[r]:a})}),g));break}this.filterCommentAnnotations(),this.setFiltersToStorage()}catch(s){this.loggingService.catch("Error in CommentsSidebarComponent updateFilter: ",s)}}sortPageFilters(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.filters?.pages?.sort((t,r)=>t?.id===e.location?.location?.id?-1:r?.id===e.location?.location?.id?1:t?.displayName?.localeCompare(r?.displayName)),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent sortPageFilters: ",e)}}updateAnnotationCountsByFilter(){try{if(!this.componentConfigSignal().filterCount)return;this.setAnnotationsCountPerPage(),this.setAnnotationsCountPerDocument(),this.setAnnotationsCountPerStatus(),this.setAnnotationsCountPerPeople(),this.setAnnotationsCountPerVersion(),this.setAnnotationsCountPerPriority(),this.setAnnotationsCountPerCommentCategory(),this.setAnnotationsCountPerAccessMode()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateAnnotationCountsByFilter: ",e)}}setAnnotationsCountPerPage(){try{this.componentConfigSignal().pages&&this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.pages).forEach(t=>{e.commentAnnotationsCountByFilters.page[t.id]=this.filterAnnotationsByPage(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPage: ",e)}}setAnnotationsCountPerDocument(){try{this.componentConfigSignal().documents&&this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.documents).forEach(t=>{e.commentAnnotationsCountByFilters.document[t.id]=this.filterAnnotationsByDocument(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerDocument: ",e)}}setAnnotationsCountPerStatus(){try{let e=this.componentConfigSignal();[this.customFilterService.defaultStatus,...this.customFilterService.ongoingStatuses,this.customFilterService.resolvedStatus].forEach(t=>{e.commentAnnotationsCountByFilters.status[t.id]=this.filterAnnotationsByStatus(t,e.annotations)?.length}),this.componentConfigSignal.update(t=>(t=D(E({},t),{commentAnnotationsCountByFilters:E({},t.commentAnnotationsCountByFilters)}),t))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerStatus: ",e)}}setAnnotationsCountPerPeople(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.peopleFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.people[t.id]=this.filterAnnotationsByPeople(t,e.annotations)?.length}),e.taggedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.tagged[t.id]=this.filterAnnotationsByTagged(t,e.annotations)?.length}),e.assignedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.assigned[t.id]=this.filterAnnotationsByAssigned(t,e.annotations)?.length}),e.involvedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.involved[t.id]=this.filterAnnotationsByInvolved(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPerson: ",e)}}setAnnotationsCountPerPriority(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.priorities.forEach(t=>{e.commentAnnotationsCountByFilters.priority[t.id]=this.filterAnnotationsByPriority(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPriority: ",e)}}setAnnotationsCountPerCommentCategory(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.commentCategoryMap).forEach(t=>{e.commentAnnotationsCountByFilters.commentCategory[t.id]=this.filterAnnotationsByCommentCategory(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerCommentCategory: ",e)}}setAnnotationsCountPerAccessMode(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.accessModes.forEach(t=>{e.commentAnnotationsCountByFilters.accessMode[t.id]=this.filterAnnotationsByAccessMode(t.id,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerAccessMode: ",e)}}setAnnotationsCountPerVersion(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.versions.forEach(t=>{e.commentAnnotationsCountByFilters.version[t.id]=this.filterAnnotationsByVersion(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerVersion: ",e)}}filterCommentAnnotations(){try{let e=this.componentConfigSignal(),t=!1,r=e.annotations.slice(),a=[],s=e.systemFiltersOperator;s===dd.AND?a=e.annotations.slice():a=[],e.appliedFiltersCount=0;let c=!1,p=new Set,g=I=>{try{s===dd.AND?a=a.filter(T=>I.some(B=>B.annotationId===T.annotationId)):I.forEach(T=>{p.add(T.annotationId)}),c=!0}catch{}};if(e.enablePriority&&e.filterConfig?.priority?.enable&&e.filters.priorities?.length){let I=[];e.filters.priorities?.forEach(T=>{I=[...I,...this.filterAnnotationsByPriority(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.location?.enable&&e.filters.pages?.length){let I=[];e.filters.pages?.forEach(T=>{I=[...I,...this.filterAnnotationsByPage(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filters.documents?.length){let I=[];e.filters.documents?.forEach(T=>{I=[...I,...this.filterAnnotationsByDocument(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.people?.enable&&e.filters.people?.length){let I=[];e.filters.people?.forEach(T=>{I=[...I,...this.filterAnnotationsByPeople(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.tagged?.enable&&e.filters.tagged?.length){let I=[];e.filters.tagged?.forEach(T=>{I=[...I,...this.filterAnnotationsByTagged(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.assigned?.enable&&e.filters.assigned?.length){let I=[];e.filters.assigned?.forEach(T=>{I=[...I,...this.filterAnnotationsByAssigned(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.involved?.enable&&e.filters.involved?.length){let I=[];e.filters.involved?.forEach(T=>{I=[...I,...this.filterAnnotationsByInvolved(T,r)]}),g(I),e.appliedFiltersCount++}if(e.enableAutoCategorize&&e.filterConfig?.category?.enable&&e.filters.categories?.length){let I=[];e.filters.categories?.forEach(T=>{I=[...I,...this.filterAnnotationsByCommentCategory(T,r)]}),g(I),e.appliedFiltersCount++}if(e.isPrivateCommentAllowed&&e.filterConfig?.commentType?.enable&&e.filters.accessModes?.length){let I=[];e.filters.accessModes?.forEach(T=>{I=[...I,...this.filterAnnotationsByAccessMode(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.version?.enable&&e.filters.versions?.length){let I=[];e.filters.versions?.forEach(T=>{I=[...I,...this.filterAnnotationsByVersion(T,r)]}),g(I),e.appliedFiltersCount++}if(e.enableStatus&&e.filters.statuses?.length){let I=[];e.filters.statuses?.forEach(T=>{T.id===this.customFilterService.resolvedStatus.id&&(t=!0),I=[...I,...this.filterAnnotationsByStatus(T,r)]}),g(I),e?.filterConfig?.status?.enable&&e.appliedFiltersCount++}s!==dd.AND&&(c?a=r.filter(I=>p.has(I.annotationId)):a=r),e.filters.input&&(a=this.filterAnnotationsByInput(e.filters.input,a));let f=a.slice();if(e.minimalFilter){!t&&e.minimalFilter==="resolved"||e.minimalFilter==="reset"?a=e.annotations.slice():a=f.slice();let I=a.length,T=0,B=0,z=0,G=0,J=0,ne=0;a=a.filter(ve=>{let ye=!1;switch(e.minimalFilter){case"all":!t&&!this.resolvedCommentsOnDom?ye=ve.status?.id!==this.customFilterService.resolvedStatus.id:ye=!0,ye&&z++;break;case"read":ye=!this.componentConfigSignal().unreadCommentsMap?.[ve.annotationId]&&ve.status?.id!==this.customFilterService.resolvedStatus.id,ye&&ne++;break;case"unread":let Ne=!!this.componentConfigSignal().unreadCommentsMap?.[ve.annotationId],Ve=ve.status?.id!==this.customFilterService.resolvedStatus.id,Ie=!!this.componentConfigSignal().selectedAnnotationsMap[ve.annotationId];ye=Ne&&Ve||Ie,ye&&B++;break;case"open":ye=ve.status?.type==="default",ye&&G++;break;case"resolved":ye=ve.status?.id===this.customFilterService.resolvedStatus.id,ye&&J++;break;case"reset":ye=!0,ye&&T++;break;default:ye=!0;break}return ye})}if(this.componentConfigSignal.update(I=>(I=D(E(E({},I),e),{filteredCommentPinAnnotations:a}),I)),!this.commentService.getSidebarCustomActionsValue()){let I=this.componentConfigSignal().embedMode||this.componentConfigSignal().sidebarVisible;this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:a,sidebarVisible:!!I}),this.componentConfigSignal.update(T=>(T=E({},T),T.filteredCommentAnnotationsCount=a?.length||0,T))}this.groupFilteredCommentAnnotations(),this.componentConfigSignal().sortData||this.sortComments(this.componentConfigSignal().selectedMinimalFilterDropdownOption.sorting)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterCommentAnnotations: ",e)}}toggleGroupedCommentAnnotations(e){try{e.isExpanded=!e.isExpanded,this.commentService.getSidebarCustomActionsValue()?(this.componentConfigSignal.update(t=>(t=E({},t),t)),this.updateVirtualScrollDataGroupToggle(this.componentConfigSignal().virtualScrollData)):this.setSidebarGroupedAnnotationsData()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent toggleGroupedCommentAnnotations: ",t)}}changeGroupBy(e){try{this.componentConfigSignal.update(t=>(t=E({},t),e?e===t.groupBy?t.groupBy=null:t.groupBy=e:t.groupBy=null,t)),sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY,this.componentConfigSignal().groupBy||""),this.groupFilteredCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent changeGroupBy: ",t)}}groupFilteredCommentAnnotations(){try{let e=this.filteredGroupedCommentAnnotationsObj,t=this.componentConfigSignal(),r=t.systemFiltersOperator===dd.AND;switch(t.groupBy){case t.groupByOptions.people:let a=t.filters.people?.length&&r?t.filters.people:t.peopleFilters;this.filteredGroupedCommentAnnotationsObj={},a.forEach(G=>{let J=this.filterAnnotationsByPeople(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.peopleFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.assigned:let s=t.filters.assigned?.length&&r?t.filters.assigned:t.assignedFilters;this.filteredGroupedCommentAnnotationsObj={},s.forEach(G=>{let J=this.filterAnnotationsByAssigned(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.assignedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.tagged:let c=t.filters.tagged?.length&&r?t.filters.tagged:t.taggedFilters;this.filteredGroupedCommentAnnotationsObj={},c.forEach(G=>{let J=this.filterAnnotationsByTagged(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.taggedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.involved:let p=t.filters.involved?.length&&r?t.filters.involved:t.involvedFilters;this.filteredGroupedCommentAnnotationsObj={},p.forEach(G=>{let J=this.filterAnnotationsByInvolved(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.involvedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.page:case t.groupByOptions.location:t=this.componentConfigSignal();let g=t.filters.pages?.length&&r?t.filters.pages:Object.values(t.pages||{});g?.sort((G,J)=>G?.id===t.location?.location?.id||!t.location?.location?.id&&G?.id==="other"?-1:J?.id===t.location?.location?.id||!t.location?.location?.id&&J?.id==="other"?1:0),this.filteredGroupedCommentAnnotationsObj={},g.forEach(G=>{let J=G?.id===t?.location?.location?.id||G?.id==="other"&&!t?.location?.location?.id;this.locations&&Object.keys(this.locations||{}).forEach(ve=>{let ye=this.locations[ve]?.location;ye?.id&&ye?.id===G?.id&&(J=!0)});let ne=this.filterAnnotationsByPage(G,this.componentConfigSignal().filteredCommentPinAnnotations);if((G.id||G?.displayName)&&ne?.length){let ve=G.id||G?.displayName||"";this.filteredGroupedCommentAnnotationsObj[ve]={displayName:G.displayName,annotations:ne,isExpanded:e[ve]?e[ve]?.isExpanded:!!J}}}),this.filteredGroupedCommentAnnotations=[];let f=t?.filterConfig?.location?.order||[];if(f?.length){let G=J=>{let ne=f.indexOf(J?.id);return ne===-1?1/0:ne};g.sort((J,ne)=>{let ve=G(J),ye=G(ne);return ve!==ye?ve-ye:g.indexOf(J)-g.indexOf(ne)})}g.forEach(G=>{let J=G.id||G?.displayName||"";J&&this.filteredGroupedCommentAnnotationsObj[J]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[J])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.priority:let I=t.filters.priorities?.length&&r?t.filters.priorities:t.priorities;this.filteredGroupedCommentAnnotationsObj={},I.forEach(G=>{let J=this.filterAnnotationsByPriority(G,this.componentConfigSignal().filteredCommentPinAnnotations);J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.priorities.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.category:let T=t.filters.categories?.length&&r?t.filters.categories:Object.values(t.commentCategoryMap||{});this.filteredGroupedCommentAnnotationsObj={},T.forEach(G=>{let J=this.filterAnnotationsByCommentCategory(G,this.componentConfigSignal().filteredCommentPinAnnotations);J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],T.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.document:t=this.componentConfigSignal();let B=t.filters.documents?.length&&r?t.filters.documents:Object.values(t.documents||{});B?.sort((G,J)=>G?.id===t.currentDocument?-1:J?.id===t.currentDocument?1:0),this.filteredGroupedCommentAnnotationsObj={},B.forEach(G=>{let J=G?.id===t?.currentDocument,ne=this.filterAnnotationsByDocument(G,this.componentConfigSignal().filteredCommentPinAnnotations);if(G.id&&ne?.length){let ve=G.id||"";this.filteredGroupedCommentAnnotationsObj[ve]={displayName:G.documentName||G.id||"",annotations:ne,isExpanded:e[ve]?e[ve]?.isExpanded:!!J}}}),this.filteredGroupedCommentAnnotations=[];let z=t?.filterConfig?.document?.order||[];if(z?.length){let G=J=>{let ne=z.indexOf(J?.id);return ne===-1?1/0:ne};B.sort((J,ne)=>{let ve=G(J),ye=G(ne);return ve!==ye?ve-ye:B.indexOf(J)-B.indexOf(ne)})}B.forEach(G=>{let J=G.id;J&&this.filteredGroupedCommentAnnotationsObj[J]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[J])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;default:this.filteredGroupedCommentAnnotationsObj={},this.filteredGroupedCommentAnnotationsObj={[this.pageTypes.all]:{displayName:this.pageTypes.all,annotations:this.componentConfigSignal().filteredCommentPinAnnotations,isExpanded:e[this.pageTypes.all]?e[this.pageTypes.all]?.isExpanded:!0}},this.filteredGroupedCommentAnnotations=[this.filteredGroupedCommentAnnotationsObj[this.pageTypes.all]];break}this.setSidebarGroupedAnnotationsData()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent groupFilteredCommentAnnotations: ",e)}}setSidebarGroupedAnnotationsData(){try{if(this.commentService.getSidebarCustomActionsValue()){if(this.commentService.getSidebarCustomActionsValue()&&this.dataAvailable){let e={};Object.keys(this.componentConfigSignal().filterConfig||{}).forEach(t=>{this.componentConfigSignal().filterConfig[t]?.type==="custom"&&(e[t]=this.componentConfigSignal().filterConfig[t]?.options?.map(r=>({id:r.id,name:r.name,selected:this.componentConfigSignal().filters[t+"Ids"]?.includes(r.id)})))}),this.componentConfigSignal.update(t=>(t=D(E({},t),{customFilters:e}),t)),this.commentService.getSidebarCustomActionEventDataOnInitValue()?this.commentService.setSidebarCustomActionEventDataAllChanges(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,e):this.commentService.setSidebarCustomActionEventDataOnInit(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,e)}}else{let e=this.filteredGroupedCommentAnnotations.length===1&&this.filteredGroupedCommentAnnotations[0].displayName==="Others";this.componentConfigSignal.update(r=>(r=E({},r),r.virtualScrollData=[],r)),this.filteredGroupedCommentAnnotations.forEach(r=>{!e&&r.annotations?.length&&this.componentConfigSignal.update(a=>(a=E({},a),a.virtualScrollData.push({type:"group",data:r}),a)),(r.isExpanded||e)&&r.annotations.forEach(a=>{this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData.push({type:"annotation",data:a}),s))})}),this.componentConfigSignal.update(r=>(r=D(E({},r),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),r)),this.cd.markForCheck();let t=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;t&&(t.scrollTop=0)}}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setSidebarGroupedAnnotationsData: ",e)}}filterAnnotationsByPage(e,t){try{return t?.filter(r=>e?.locationIds?.length?r?.locationId?r?.location?.id===e?.id||e?.locationIds?.includes(r?.locationId):r?.documentParams?.id===e?.id||e?.locationIds?.includes(r?.documentParamsId):!r?.locationId&&!r?.documentParamsId)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPage: ",r),[]}}filterAnnotationsByStatus(e,t){try{return t.filter(r=>r?.status?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByStatus: ",r),[]}}filterAnnotationsByPeople(e,t){try{return e.id?t.filter(r=>r?.from?.userId===e?.id||r?.from?.email===e?.id):t}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPeople: ",r),[]}}filterAnnotationsByTagged(e,t){try{return e.id===this.componentConfigSignal().user?.userId?t.filter(r=>{let a=!1;return r.comments.forEach(s=>{s.taggedUserContacts?.forEach(c=>{c?.contact?.userId===this.componentConfigSignal().user?.userId&&(a=!0)})}),a}):t.filter(r=>r?.comments?.some(a=>a?.taggedUserContacts?.some(s=>s?.contact?.userId===e?.id)))}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByTagged: ",r),[]}}filterAnnotationsByAssigned(e,t){try{return e.id===this.componentConfigSignal().user?.userId?t.filter(r=>r?.assignedTo?.userId===this.componentConfigSignal().user?.userId):t.filter(r=>r?.assignedTo?.userId===e?.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByAssigned: ",r),[]}}filterAnnotationsByInvolved(e,t){try{return t.filter(r=>{let a=r?.from?.userId===e?.id||r?.from?.email===e?.id,s=r?.assignedTo?.userId===e?.id,c=r?.comments?.some(p=>p?.taggedUserContacts?.some(g=>g?.contact?.userId===e?.id));return a||s||c})}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByInvolved: ",r),[]}}filterAnnotationsByPriority(e,t){try{return e.id==="unset"?t.filter(r=>!r?.priority):t.filter(r=>r?.priority?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPriority: ",r),[]}}filterAnnotationsByCommentCategory(e,t){try{switch(e?.id){case"other":return t?.filter(r=>!r?.commentCategories?.length||r?.commentCategories?.find(a=>a?.id===e?.id))}return t?.filter(r=>(r?.commentCategories||[])?.find(a=>a?.id===e?.id))}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByCommentCategory: ",r),[]}}filterAnnotationsByAccessMode(e,t){try{return e===uo.PRIVATE?t.filter(r=>r?.iam?.accessMode===uo.PRIVATE):t.filter(r=>!r?.iam?.accessMode||r?.iam?.accessMode===uo.PUBLIC)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByAccessMode: ",r),[]}}filterAnnotationsByVersion(e,t){try{return e.id==="unset"?t.filter(r=>!r?.location?.version):t.filter(r=>r?.location?.version?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByVersion: ",r),[]}}filterAnnotationsByInput(e,t){try{let r=e.match(/^#(\d+)$/);if(r){let a=parseInt(r[1]);return t.filter(s=>s.annotationNumber===a)}return t.filter(a=>{let s=!1;for(let c=0;c<a?.comments?.length;c++){let p=a?.comments[c];if(p?.commentText?.toLowerCase().includes(e.toLowerCase())){s=!0;break}else if(p?.from?.name?.toLowerCase().includes(e.toLowerCase())){s=!0;break}}return s})}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByInput: ",r),[]}}closeSidebar(){try{this.commentService.setSidebarVisibility(!1,!1,!0),this.onSidebarClose.emit()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent closeSidebar: ",e)}}emitOnSidebarCommentClick(e){try{let t=this.documentPaths?.clientDocumentId,r=e?.location;r||(r=e?.documentParams);let a={};e.context&&(a=e.context),this.onSidebarCommentClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.onSidebarCommentClickEvent.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.onCommentClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.commentService.onSidebarCommentClick({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onSidebarCommentClick: ",t)}}emitOnCommentNavigationButtonClick(e){try{let t=this.documentPaths?.clientDocumentId,r=e?.location;r||(r=e?.documentParams);let a={};e.context&&(a=e.context),this.onCommentNavigationButtonClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent emitOnCommentNavigationButtonClick: ",t)}}setFiltersToStorage(){try{let e=JSON.parse(JSON.stringify(this.componentConfigSignal().filters));delete e?.input;let t=JSON.stringify(e);sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS,t)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setFiltersToStorage: ",e)}}setCommentSidebarInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(sf.COMMENT_SIDEBAR)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarInstalledInAnalytics: ",e)}}setCommentSidebarEmbedModeInAnalytics(){try{this.componentConfigSignal().embedMode&&this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_EMBED_MODE_ENABLED,{commentMode:this.commentService.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarEmbedModeInAnalytics: ",e)}}setCommentSidebarFloatingModeInAnalytics(){try{this.componentConfigSignal().floatingMode&&this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_FLOATING_MODE_ENABLED,{commentMode:this.commentService.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarFloatingModeInAnalytics: ",e)}}setCommentReadInAnalytics(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentReadInAnalytics","color: green;"),this.commentReadAnalyticsCalled||(this.commentReadAnalyticsCalled=!0,this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_READ,{uiLocation:"sidebar",commentMode:this.commentService.getCommentMode(),readType:"hover"}))}catch(e){this.loggingService.catch("Error in CommentDialogComponent setCommentReadInAnalytics: ",e)}}toggleMoreFilters(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!t.moreFiltersVisible}),t)),e&&e?.scrollTo({top:0})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent toggleMoreFilters: ",t)}}closeMoreFilters(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!1,filterRecentlyClosed:!0}),t)),e&&e?.scrollTo({top:0}),setTimeout(()=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{filterRecentlyClosed:!1}),t))},100)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent closeMoreFilters: ",t)}}openMoreFilters(e){try{if(this.componentConfigSignal().filterRecentlyClosed)return;this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!0}),t)),e&&e?.scrollTo({top:0})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent openMoreFilters: ",t)}}savePageComment(e){try{let t=e?.updatedComment;t&&this.commentService.addComment(void 0,void 0,void 0,void 0,!0,[t],void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,e?.annotation?.assignedTo,void 0,void 0,this.componentConfigSignal().context),this.componentConfigSignal.update(r=>(r=E({},r),r.pageCommentAnnotation=new Zo,r.pageCommentAnnotation.isPageAnnotation=!0,r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent savePageComment: ",t)}}sortComments(e){try{this.componentConfigSignal.update(t=>{let r=[...t.virtualScrollData];return r.sort((a,s)=>{if(a.type==="annotation"&&s.type==="annotation"){if(e==="date"){let c=new Date(a.data.lastUpdated).getTime();return new Date(s.data.lastUpdated).getTime()-c}else if(e==="unread"){let c=t.unreadCommentsMap?.[a.data.annotationId]||0,p=t.unreadCommentsMap?.[s.data.annotationId]||0;if(c>0&&p===0)return-1;if(c===0&&p>0)return 1;let g=new Date(a.data.lastUpdated).getTime();return new Date(s.data.lastUpdated).getTime()-g}}return 0}),t=D(E({},t),{virtualScrollData:r}),t}),this.componentConfigSignal.update(t=>(t=D(E({},t),{minimalFilterDropdownOpen:!1,selectedMinimalFilterDropdownOption:D(E({},t.selectedMinimalFilterDropdownOption),{sorting:e})}),t))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent sortComments: ",t)}}toggleMinimalFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalFilterDropdownOpen:!e.minimalFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleMinimalFilterDropdown: ",e)}}filterCommentsByReadStatus(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimalFilter:e,minimalFilterDropdownOpen:!1,selectedMinimalFilterDropdownOption:D(E({},t.selectedMinimalFilterDropdownOption),{filter:e})}),t)),this.filterCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent filterCommentsByReadStatus: ",t)}}resetFilters(){try{this.componentConfigSignal.update(e=>{let t=e.filters;return Object.keys(t).forEach(r=>{t[r]?.length&&(t[r]=[])}),e=D(E({},e),{minimalFilter:"all",customActionsState:{all:!0},filters:D(E({},t),{input:""}),selectedMinimalFilterDropdownOption:D(E({},e.selectedMinimalFilterDropdownOption),{filter:"all"})}),e}),this.resolvedCommentsOnDom=!1,this.filterCommentsByReadStatus("all"),this.updateFilter({key:"pages",value:null},!0),this.updateFilter({key:"documents",value:null},!0),this.updateFilter({key:"people",value:null},!0),this.updateFilter({key:"assigned",value:null},!0),this.updateFilter({key:"tagged",value:null},!0),this.updateFilter({key:"statuses",value:null},!0),this.updateFilter({key:"priorities",value:null},!0),this.updateFilter({key:"categories",value:null},!0),this.updateFilter({key:"versions",value:null},!0),sessionStorage.removeItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent resetFilters: ",e)}}toggleLocationFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{locationFilterDropdownOpen:!e.locationFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleLocationFilterDropdown: ",e)}}toggleDocumentFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{documentFilterDropdownOpen:!e.documentFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleDocumentFilterDropdown: ",e)}}closeDocumentFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{documentFilterDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent closeDocumentFilterDropdown: ",e)}}toggleMinimalActionsDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!e.minimalActionsDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleMinimalActionsDropdown: ",e)}}markAllCommentAnnotationsAsRead(){try{this.commentService.setCommentAnnotationsAsRead(this.componentConfigSignal().filteredCommentPinAnnotations),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentAnnotationsAsRead: ",e)}}markAllCommentAnnotationsAsResolved(){try{this.commentService.setCommentAnnotationsAsResolved(this.componentConfigSignal().filteredCommentPinAnnotations),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent markAllCommentAnnotationsAsResolved: ",e)}}toggleCustomAction(e,t){try{t==="toggle"?(this.componentConfigSignal.update(r=>(r=D(E({},r),{customActionsState:{[e]:!r.customActionsState[e]}}),r)),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify(this.componentConfigSignal().customActionsState)),this.commentService.setSidebarCustomActionEventData(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,this.componentConfigSignal().customFilters)):(this.commentService.setSidebarCustomActionEventData({[e]:!0},this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,this.componentConfigSignal().customFilters),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify({[e]:!0})))}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent toggleCustomAction: ",r)}}goBackToAllComments(){try{let e=this.componentConfigSignal().focusedAnnotation;this.componentConfigSignal.update(t=>(t=D(E({},t),{focusedAnnotation:null}),t)),e&&setTimeout(()=>{this.goToAnnotationInSidebar(e,"instant")},100)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent goBackToAllComments: ",e)}}filterSearch(e,t){try{let r=this.componentConfigSignal();if(!r?.peopleFilters)return;let a,s;switch(t){case"people":a=r.peopleFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"assigned":a=r.assignedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"tagged":a=r.taggedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"involved":a=r.involvedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"pages":a=r.pages,!e||e===""?s=r.pages:(s={},Object.keys(a).filter(p=>p.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"documents":a=r.documents,!e||e===""?s=r.documents:(s={},Object.keys(a).filter(p=>a[p]?.documentName?.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"statuses":a=r.statuses,!e||e===""?s=a:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;case"priorities":a=r.priorities,!e||e===""?s=a:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;case"categories":a=r.commentCategoryMap,!e||e===""?s=r.commentCategoryMap:(s={},Object.keys(a).filter(p=>p.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"versions":a=r.versions,!e||e===""?s=r.versions:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;default:a=r.filterConfig[t]?.options,!e||e===""?s=r.filterConfig[t]?.options:s=a?.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break}return s}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterPeople: ",r),[]}}updateDocumentSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.documents).forEach(t=>{let r=e.filters?.documents?.find(a=>a.id===t?.id);r?(t.selected=!0,r.documentName||(r.documentName=t.documentName)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateDocumentSelectedState: ",e)}}filterAnnotationsByDocument(e,t){try{return t?.filter(r=>e?.id&&e.id!=="other"?r?.metadata?.clientDocumentId?.toString()===e.id:!r?.metadata?.clientDocumentId)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByDocument: ",r),[]}}onDialogExpanded(e){try{setTimeout(()=>{let t=this.componentConfigSignal().annotations.find(r=>r.annotationId===e);t&&this.goToAnnotationInSidebar(t)},200)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onDialogExpanded: ",t)}}onFullscreenClick(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{fullScreen:!e.fullScreen}),e)),this.onFullscreen.emit(this.componentConfigSignal().fullScreen)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent onFullscreenClick: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(we),h(Ft),h(Be),h(ot),h(R),h(En),h(_),h(wo),h(Wo),h(Bl),h(an),h(Ge),h(qi),h(W1),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["app-comments-sidebar"]],viewQuery:function(t,r){if(t&1&&(it(mnn,5),it(pnn,7)),t&2){let a;Je(a=et())&&(r.sidebarOverlay=a.first),Je(a=et())&&(r.hostElement=a.first)}},hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{embedMode:"embedMode",floatingMode:"floatingMode",_pageMode:[0,"pageMode","_pageMode"],_filterCount:[0,"filterCount","_filterCount"],_customActions:[0,"customActions","_customActions"],focusedThreadMode:"focusedThreadMode",_openAnnotationInFocusMode:[0,"openAnnotationInFocusMode","_openAnnotationInFocusMode"],_readOnly:[0,"readOnly","_readOnly"],_selection:[0,"dialogSelection","_selection"],_expandOnSelection:[0,"expandOnSelection","_expandOnSelection"],_sortData:[0,"sortData","_sortData"],enableUrlNavigation:"enableUrlNavigation",urlNavigation:"urlNavigation",_queryParamsComments:[0,"queryParamsComments","_queryParamsComments"],_fullScreen:[0,"fullScreen","_fullScreen"],_currentLocationSuffix:[0,"currentLocationSuffix","_currentLocationSuffix"],_filterOptionLayout:[0,"filterOptionLayout","_filterOptionLayout"],_filterConfig:[0,"filterConfig","_filterConfig"],_groupConfig:[0,"groupConfig","_groupConfig"],_filters:[0,"filters","_filters"],_systemFiltersOperator:[0,"systemFiltersOperator","_systemFiltersOperator"],_excludeLocationIds:[0,"excludeLocationIds","_excludeLocationIds"],_fullExpanded:[0,"fullExpanded","_fullExpanded"],_sidebarButtonCountType:[0,"sidebarButtonCountType","_sidebarButtonCountType"],_filterGhostCommentsInSidebar:[0,"filterGhostCommentsInSidebar","_filterGhostCommentsInSidebar"],dialogVariant:"dialogVariant",focusedThreadDialogVariant:"focusedThreadDialogVariant",filterPanelLayout:"filterPanelLayout",pageModeComposerVariant:"pageModeComposerVariant",searchPlaceholder:"searchPlaceholder",_sidebarShadowDOM:[0,"shadowDom","_sidebarShadowDOM"],_context:[0,"context","_context"],variant:"variant",position:"position"},outputs:{openSidebar:"openSidebar",onSidebarOpen:"onSidebarOpen",onSidebarCommentClick:"sidebarCommentClick",onSidebarCommentClickEvent:"onSidebarCommentClick",onCommentClick:"onCommentClick",onSidebarClose:"onSidebarClose",onCommentNavigationButtonClick:"onCommentNavigationButtonClick",onFullscreen:"onFullscreenClick"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[["sidebarRef",""],["defaultSidebarMode",""],["sidebarTrigger","cdkOverlayOrigin"],["sidebarOverlay","cdkConnectedOverlay"],[4,"ngIf"],[3,"ngIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["cdkOverlayOrigin",""],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass"],["class","velt-comments-sidebar-container",3,"dark",4,"ngIf"],[1,"velt-comments-sidebar-container"],["role","dialog",3,"onWrapperClick","componentConfigSignal","template","darkMode"]],template:function(t,r){t&1&&u(0,Enn,4,1,"ng-container",4),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,Sn,q1e,ge],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%]{width:100%} .snippyly-sidebar-panel .viewport .cdk-virtual-scroll-content-wrapper{max-width:100%}.s-overflow-hidden[_ngcontent-%COMP%]{overflow:hidden}"],changeDetection:0});let i=o;return i})();function xnn(i,o){if(i&1&&(y(0,"snippyly-cursor-pointer",5)(1,"slot",6),ce(),y(2,"svg",7)(3,"g",8),w(4,"path",9)(5,"path",10),b(),y(6,"defs")(7,"filter",11),w(8,"feFlood",12)(9,"feColorMatrix",13)(10,"feOffset",14)(11,"feGaussianBlur",15)(12,"feColorMatrix",16)(13,"feBlend",17)(14,"feBlend",18),b()()()()()),i&2){let n=l().$implicit,e=l(2).ngIf,t=l();d("cursorUser",n)("avatarMode",t.avatarMode)("huddleState",e.huddleOnCursorModeByAttendeeId[n==null?null:n.userSnippylyId]?e.attendeesByUserId[n==null?null:n.userSnippylyId]==null?null:e.attendeesByUserId[n==null?null:n.userSnippylyId].state:void 0)("stream",e.huddleOnCursorModeByAttendeeId[n==null?null:n.userSnippylyId]?e.remoteStreamsByUserId[n==null?null:n.userSnippylyId]==null?null:e.remoteStreamsByUserId[n==null?null:n.userSnippylyId].webcam:void 0),m(4),x("fill",n.color),m(),x("fill",n.color)}}function Tnn(i,o){if(i&1&&(v(0),u(1,xnn,15,6,"snippyly-cursor-pointer",4),C()),i&2){let n=o.$implicit;m(),d("ngIf",n==null?null:n.position)}}function Dnn(i,o){if(i&1&&(y(0,"snippyly-cursor-pointer",19)(1,"slot",6),ce(),y(2,"svg",7)(3,"g",8),w(4,"path",9)(5,"path",10),b(),y(6,"defs")(7,"filter",11),w(8,"feFlood",12)(9,"feColorMatrix",13)(10,"feOffset",14)(11,"feGaussianBlur",15)(12,"feColorMatrix",16)(13,"feBlend",17)(14,"feBlend",18),b()()()()()),i&2){let n=l(2).ngIf,e=l();d("cursorUser",n.currentCursorUser)("selfCursorPointer",!0)("avatarMode",e.avatarMode)("huddleState",n.huddleOnCursorMode?n.attendeesByUserId[n.currentCursorUser==null?null:n.currentCursorUser.userSnippylyId]==null?null:n.attendeesByUserId[n.currentCursorUser==null?null:n.currentCursorUser.userSnippylyId].state:void 0)("stream",n.localStream),m(4),x("fill",n.currentCursorUser.color),m(),x("fill",n.currentCursorUser.color)}}function wnn(i,o){if(i&1&&u(0,Tnn,2,1,"ng-container",2)(1,Dnn,15,7,"snippyly-cursor-pointer",3),i&2){let n=l().ngIf,e=l();d("ngForOf",n.cursorUsers)("ngForTrackBy",e.trackById),m(),d("ngIf",n.huddleJoined&&n.huddleOnCursorMode&&n.currentCursorUser)}}function Onn(i,o){if(i&1&&(v(0),u(1,wnn,2,3,"ng-template",1),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.isFirstComponent&&!(n.user!=null&&n.user.isAnonymous))}}var Oq=(()=>{let o=class o{get inactivityTime(){return this._inactivityTime}set inactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Cursor set inactivityTime: ","inactivity-time value is not a number."):(this._inactivityTime=e,this.cursorService.setInactivityTime(this._inactivityTime))}catch(t){this.loggingService.catch("Error in Cursor set inactivityTime: ",t)}}get allowedElementIds(){return this._allowedElementIds}set allowedElementIds(e){try{this._allowedElementIds=typeof e=="string"?JSON.parse(e):e,this.cursorService.setAllowedElementIds(this._allowedElementIds)}catch(t){this.loggingService.catch("Error in Cursor set allowedElementIds: ",t)}}constructor(e,t,r,a,s,c){this.analyticsService=e,this.authService=t,this.cursorService=r,this.domService=a,this.huddleService=s,this.loggingService=c,this.avatarMode=!1,this.onCursorUsersChanged=new Me,this.onCursorUserChange=new Me,this.subscriptions=[],this.constants=U,this.showInitials={},this.componentConfigSignal=xe({isFirstComponent:!1,user:void 0,cursorUsers:[],huddleOnCursorModeByAttendeeId:{},attendeesByUserId:{},remoteStreamsByUserId:{},huddleOnCursorMode:!1,huddleJoined:!1,currentCursorUser:new kC,localStream:void 0}),this.veltId=vt(),this.veltElement=!0,this._inactivityTime=5,this._allowedElementIds=[],this.loggingService.log("%c[WB] Creating CLASS: CursorComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(U.TAGS.SNIPPYLY_CURSOR),t=document.querySelector(U.TAGS.VELT_CURSOR);t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),this.initComponent())}catch(e){this.loggingService.catch("Error in CursorComponent AfterViewInit: ",e)}}initComponent(){try{this.cursorService.checkCursorTagAvailable(),this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),this.componentConfigSignal().user&&this.setCursorInstalledInAnalytics()},e=>{this.loggingService.catch("Error in CursorComponent getUser$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleJoined$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleJoined:e}),t))})),this.subscriptions.push(this.huddleService.getHuddleOnCursorMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleOnCursorMode:e}),t))},e=>{this.loggingService.catch("Error in CursorComponent getHuddleOnCursorMode$ subscription: ",e)})),this.subscriptions.push(this.huddleService.localStream$.subscribe(e=>{e?this.componentConfigSignal.update(t=>(t=D(E({},t),{localStream:e}),t)):this.componentConfigSignal.update(t=>(t=D(E({},t),{localStream:void 0}),t))})),this.subscriptions.push(this.huddleService.getRemoteStreamsByUserId$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{remoteStreamsByUserId:e}),t))},e=>{this.loggingService.catch("Error in CursorComponent getRemoteStreamsByUserId$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleAttendees$().subscribe(e=>{let t={};e?t=e.reduce((r,a)=>(r[a.userSnippylyId]=a,r),{}):t={},this.componentConfigSignal.update(r=>(r=D(E({},r),{attendeesByUserId:t}),r))},e=>{this.loggingService.catch("Error in CursorComponent getAttendees$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleOnCursorModeByAttendeeId$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleOnCursorModeByAttendeeId:e}),t))})),this.subscriptions.push(this.domService.onWindowPointerMove$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{currentCursorUser:D(E({},t.currentCursorUser),{position:{left:(e?.clientX||0)-2,top:(e?.clientY||0)-2}})}),t))},e=>{this.loggingService.catch("Error in CursorComponent onWindowPointerMove$ subscription: ",e)})),this.getCurrentCursorUser(),this.getLiveCursorsOnCurrentDocument()}catch(e){this.loggingService.catch("Error in CursorComponent initComponent: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in CursorComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in CursorComponent unsubscribe: ",e)}}getLiveCursorsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getLiveCursorsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.cursorService.getLiveCursorsOnCurrentDocument().pipe(Le(e=>!!e)).subscribe(e=>{this.loggingService.log(e),e&&(this.componentConfigSignal.update(t=>(t=D(E({},t),{cursorUsers:e}),t)),this.onCursorUsersChanged.emit(e),this.onCursorUserChange.emit(e))},e=>{this.loggingService.catch("Error in CursorComponent getLiveCursorsOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CursorComponent getLiveCursorsOnCurrentDocument: ",e)}}getCurrentCursorUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentCursorUser","color: green;");try{this.subscriptions.push(this.cursorService.getCursorUser().pipe(Le(e=>!!e)).subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{currentCursorUser:D(E({},e),{position:t.currentCursorUser?.position})}),t))},e=>{this.loggingService.catch("Error in CursorComponent getCurrentCursorUser subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CursorComponent getCurrentCursorUser: ",e)}}trackById(e,t){return t?.userId}onImageLoadError(e){this.loggingService.log("%c[WB] Calling FUNCTION: onImageLoadError","color: green;");try{this.showInitials[e.userId]=!0}catch(t){this.loggingService.catch("Error in CursorComponent onImageLoadError: ",t)}}setCursorInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Re.CURSOR)}catch(e){this.loggingService.catch("Error in CursorComponent setCursorInstalledInAnalytics: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(qC),h(Be),h(wr),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-cursor"]],hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{avatarMode:"avatarMode",inactivityTime:"inactivityTime",allowedElementIds:"allowedElementIds"},outputs:{onCursorUsersChanged:"cursorUsersChanged",onCursorUserChange:"onCursorUserChange"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],[3,"ngIf"],[4,"ngFor","ngForOf","ngForTrackBy"],[3,"cursorUser","selfCursorPointer","avatarMode","huddleState","stream",4,"ngIf"],[3,"cursorUser","avatarMode","huddleState","stream",4,"ngIf"],[3,"cursorUser","avatarMode","huddleState","stream"],["name","cursor"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"cursor-icon"],["filter","url(#filter0_d_6047_31299)"],["d","M7.68749 16.5142L5.42791 5.15177C5.26065 4.31067 6.16027 3.66301 6.90484 4.08848L16.8788 9.78786C17.6558 10.2319 17.503 11.3948 16.6376 11.623L12.3849 12.7447C12.1377 12.8098 11.9249 12.9672 11.7902 13.1844L9.51802 16.8464C9.03968 17.6174 7.86445 17.4041 7.68749 16.5142Z","fill","#625DF5"],["d","M4.93751 5.24929L7.19709 16.6118C7.46253 17.9466 9.22538 18.2664 9.94288 17.11L12.215 13.448C12.2824 13.3394 12.3888 13.2607 12.5124 13.2281L16.7651 12.1065C18.0632 11.7642 18.2924 10.0198 17.1268 9.35374L7.15291 3.65436C6.03605 3.01615 4.68662 3.98765 4.93751 5.24929Z","stroke","white","stroke-linecap","square"],["id","filter0_d_6047_31299","x","0.588557","y","0.405717","width","21.6129","height","23.0055","filterUnits","userSpaceOnUse","color-interpolation-filters","sRGB"],["flood-opacity","0","result","BackgroundImageFix"],["in","SourceAlpha","type","matrix","values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0","result","hardAlpha"],["dy","1.1"],["stdDeviation","1.2"],["type","matrix","values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.17 0"],["mode","normal","in2","BackgroundImageFix","result","effect1_dropShadow_6047_31299"],["mode","normal","in","SourceGraphic","in2","effect1_dropShadow_6047_31299","result","shape"],[3,"cursorUser","selfCursorPointer","avatarMode","huddleState","stream"]],template:function(t,r){t&1&&u(0,Onn,2,1,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,z1],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}*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;height:unset;width:unset;text-align:left;line-height:1.5;color:#000;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit));pointer-events:none!important}*:empty{display:revert}.cursor-icon path{stroke:#fff;stroke-width:1px;stroke-linejoin:round}
534
+ `||this.componentConfigSignal().selectedAttachments?.length||this.componentConfigSignal().attachmentsToDelete?.length||this.componentConfigSignal().recorderInitConfig&&this.componentConfigSignal().recorderInitConfig?.panelId===this.componentConfigSignal().commentDialogUniqueId||this.componentConfigSignal().localRecordedData?.length?this.componentConfigSignal.update(e=>(e=D(E({},e),{getAnnotationDraftAttribute:e.annotation?.annotationId}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{getAnnotationDraftAttribute:null}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkGetAnnotationDraftAttribute: ",e)}}checkShowGhostCommentMessage(){try{this.componentConfigSignal().ghostComment&&this.componentConfigSignal().enableGhostCommentsMessage&&![this.componentConfigSignal().commentAcceptedStatus?.id,this.componentConfigSignal().commentRejectedStatus?.id].includes(this.componentConfigSignal().annotation?.status?.id)?this.componentConfigSignal.update(e=>(e=D(E({},e),{showGhostCommentMessage:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{showGhostCommentMessage:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkShowGhostCommentMessage: ",e)}}checkShowSuggestionModeActions(){try{this.componentConfigSignal().suggestionMode&&this.componentConfigSignal().dialogSelectedByKnownUser&&this.componentConfigSignal().annotation?.status?.type!=="terminal"&&this.componentConfigSignal().annotation?.comments?.length?this.componentConfigSignal.update(e=>(e=D(E({},e),{showSuggestionModeActions:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{showSuggestionModeActions:!1}),e))}catch(e){this.catchError("Error in CommentDialogComponent checkShowSuggestionModeActions: ",e)}}ngOnDestroy(){super.ngOnDestroy(),this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.removeLinkClickListeners(),this.veltDynamicComponents.forEach(e=>{e.destroy()}),this.subscriptions.map(e=>{e.unsubscribe()}),this.domService.setRecordingInProgress(this.componentConfigSignal().annotation?.annotationId,!1),this.subscriptions=[],this.componentConfigSignal().recorderInitConfig?.panelId===this.componentConfigSignal().commentDialogUniqueId&&this.recorderService.clearRecording(),this.resizeObserver&&this.componentConfigSignal().commentsContainer?.nativeElement&&this.resizeObserver.unobserve(this.componentConfigSignal().commentsContainer?.nativeElement),clearTimeout(this.escapePressTimeout),this.componentConfigSignal().getAnnotationDraftAttribute&&this.commentService.getDraftMode()&&!this.componentConfigSignal().editComment&&this.componentConfigSignal().getAnnotationDraftAttribute&&this.addComment(void 0,!0)}catch(e){this.catchError("Error in CommentDialogComponent unsubscribe: ",e)}}closeDialog(){try{this.domService.resetSelectedAnnotationsMap()}catch(e){this.catchError("Error in CommentDialogComponent closeDialog: ",e)}}openDropdownIndex(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{openDropdownIndexValue:e}),t))}catch(t){this.catchError("Error in CommentDialogComponent openDropdownIndex: ",t)}}navigateToCommentEmit(){try{this.onCommentNavigationButtonClick.emit(this.componentConfigSignal().annotation)}catch(e){this.catchError("Error in CommentDialogComponent navigateToComment: ",e)}}moveCursorToEnd(e){try{if(!e?.isConnected)return;e.focus(),setTimeout(()=>{let t=document.createRange(),r=window.getSelection();t.selectNodeContents(e),t.collapse(!1),r?.removeAllRanges(),r?.addRange(t),setTimeout(()=>{this.autoScrollToBottom(e)},50)},0)}catch(t){this.catchError("Error in CommentDialogComponent moveCursorToEnd: ",t)}}focusOnComposerInput(){try{this.onComposerClick(),this.composerFocused.emit();let e=fce();this.componentConfigSignal().newCommentTextArea?.nativeElement&&(this.componentConfigSignal().newCommentTextArea.nativeElement?.contains(e)||this.moveCursorToEnd(this.componentConfigSignal().newCommentTextArea.nativeElement)),this.componentConfigSignal().editCommentTextArea?.nativeElement&&(this.componentConfigSignal().editCommentTextArea.nativeElement?.contains(e)||this.moveCursorToEnd(this.componentConfigSignal().editCommentTextArea.nativeElement))}catch(e){this.catchError("Error in CommentDialogComponent focusOnComposerInput: ",e)}}onComposerClick(){try{this.composerFocused.emit(),this.commentActionsService?.onComposerClick({commentAnnotation:this.componentConfigSignal().annotation}),this.componentConfigSignal().commentPinSelected||(this.componentConfigSignal().sidebarMode?this.domService.toggleAnnotationSelection(this.componentConfigSignal().annotation,this.componentConfigSignal().containerComponentId,"sidebarShowReplies"):this.domService.toggleAnnotationSelection(this.componentConfigSignal().annotation,this.componentConfigSignal().containerComponentId))}catch(e){this.catchError("Error in CommentDialogComponent onComposerClick: ",e)}}getCurrentDialogView(){try{let e={};if(this.componentConfigSignal().annotation?.annotationId){let t=this.componentConfigSignal().commentViews?.[this.componentConfigSignal().annotation?.annotationId]?.comments;Object.keys(t||{}).forEach(r=>{let a=[],s=0;Object.keys(t[r]?.views||{}).forEach(c=>{let p={};p.user=this.componentConfigSignal().userContactsBySnippylyId?.[c],p.viewedAt=t[r]?.views?.[c]?.timestamp,p.user?.userId!==this.componentConfigSignal().user?.userId&&p.user?.userId!==this.componentConfigSignal().annotation?.from?.userId&&(a.push(p),(p.user?.email||p.user?.name)&&s++)}),e[r]={count:s,views:a}})}this.componentConfigSignal.update(t=>(t=D(E({},t),{currentDialogView:e}),t))}catch(e){this.catchError("Error in CommentDialogComponent getCurrentDialogView: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}showReplyComposerHandler(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{showReplyComposer:!0}),e)),setTimeout(()=>{this.focusOnComposerInput()},100)}catch(e){this.catchError("Error in CommentDialogComponent showReplyComposerHandler: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(we),h(Zn),h(l7),h(Si),h(Be),h(bn),h(Cl),h(W1),h(_),h(Wo),h(En),h(ur),h(Ps),h(Ke),h(R),h(qi),h(Ge),h(ot),h(un),h(an),h(ad,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-dialog"]],viewQuery:function(t,r){if(t&1&&(it(sen,5),it(len,5),it(cen,5),it(B1e,7),it(B1e,5,Ci)),t&2){let a;Je(a=et())&&(r.commentsContainer=a.first),Je(a=et())&&(r.newCommentTextArea=a.first),Je(a=et())&&(r.editCommentTextArea=a.first),Je(a=et())&&(r.hostElement=a.first),Je(a=et())&&(r.hostViewContainer=a.first)}},hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{snippylyReadId:"snippylyReadId",screenshotDomain:"screenshotDomain",annotationIndex:"annotationIndex",userContacts:"userContacts",annotation:"annotation",multiThreadAnnotationId:"multiThreadAnnotationId",readOnly:"readOnly",dialogSelection:"dialogSelection",expandOnSelection:"expandOnSelection",user:"user",dialogMode:"dialogMode",sidebarMode:"sidebarMode",fullExpanded:"fullExpanded",inboxMode:"inboxMode",multiThread:"multiThread",inlineCommentMode:"inlineCommentMode",inlineCommentSectionMode:"inlineCommentSectionMode",commentComposerMode:"commentComposerMode",isInsidePdfViewer:"isInsidePdfViewer",locationDisplayName:"locationDisplayName",locationVersion:"locationVersion",commentPinSelected:"commentPinSelected",variant:"variant",shadowDom:"shadowDom",commentPinType:"commentPinType",composerMode:"composerMode",containerComponentId:"containerComponentId",focusedThreadMode:"focusedThreadMode",isFocusedThreadEnabled:"isFocusedThreadEnabled",openAnnotationInFocusMode:"openAnnotationInFocusMode",pageModeComposer:"pageModeComposer",composerPosition:"composerPosition",sortBy:"sortBy",sortOrder:"sortOrder",targetElementId:"targetElementId",dialogTemplate:"dialogTemplate"},outputs:{deleteCommentThread:"deleteCommentThread",saveComment:"saveComment",addCommentEmitter:"addComment",afterViewInit:"afterViewInit",signInToAccessFeature:"signInToAccessFeature",pointerOutFromCommentDialog:"pointerOutFromCommentDialog",pointerUp:"pointerUp",updateOverlayPosition:"updateOverlayPosition",onCommentNavigationButtonClick:"onCommentNavigationButtonClick",onOpenFocusedThread:"onOpenFocusedThread",composerFocused:"composerFocused"},standalone:!1,features:[L,Ze],decls:4,vars:68,consts:[["host","","commentsContainer",""],["defaultDialogRef",""],["commentsContainer",""],[1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup"],[4,"ngIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","inbox","velt-comment-dialog--inbox-mode","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--ghost-comment-annotation","inline-comment-mode","velt-comment-dialog--inline-comment-mode","velt-comment-dialog--multi-thread-mode","velt-comment-dialog--page-comment","velt-comment-dialog--inline-comment-section-mode","velt-comment-dialog--comment-composer-mode","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","sidebar","velt-comment-dialog--sidebar-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--ghost-comment-annotation","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","id","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container","class","modal-div velt-comment-dialog",3,"dialog","velt-comment-dialog--dialog-mode","bottom-sheet","velt-comment-dialog--bottom-sheet","inbox","velt-comment-dialog--inbox-mode","readonly","velt-comment-dialog--readonly","no-comments","velt-comment-dialog--no-comments","selected","velt-comment-dialog--selected","screen-recording","velt-comment-dialog--screen-recording","s-ghost-comment-annotation","velt-comment-dialog--ghost-comment-annotation","inline-comment-mode","velt-comment-dialog--inline-comment-mode","velt-comment-dialog--multi-thread-mode","velt-comment-dialog--page-comment","velt-comment-dialog--focused-thread-mode","velt-comment-dialog--inline-comment-section-mode","velt-comment-dialog--comment-composer-mode","velt-comment-dialog--page-mode-composer","velt-comment-dialog--read-only","private-comment","velt-comment-dialog--private-comment","click","pointerout","pointerdown","pointerup",4,"ngIf"],["part","container",1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup"],[3,"componentConfigSignal"],["class","line-div velt-comment-dialog--line-div",4,"ngIf"],["class","velt-action-bar velt-comment-dialog--action-bar",4,"ngIf"],[1,"line-div","velt-comment-dialog--line-div"],[1,"velt-action-bar","velt-comment-dialog--action-bar"],[3,"componentConfigSignal",4,"ngIf"],["class","velt-comment-dialog--action-bar-group",4,"ngIf"],[1,"velt-comment-dialog--action-bar-group"],["part","container",1,"modal-div","velt-comment-dialog",3,"click","pointerout","pointerdown","pointerup","id"]],template:function(t,r){if(t&1){let a=K();y(0,"div",3,0),W("click",function(){return N(a),F(r.onClick())})("pointerout",function(c){return N(a),r.onPointerOutCommentDialog(c),F(c.stopPropagation())})("pointerdown",function(c){return N(a),F(c.stopPropagation())})("pointerup",function(c){return N(a),r.onPointerUp(),F(c.stopPropagation())}),b(),u(3,Ren,4,1,"ng-container",4)}if(t&2){let a,s,c,p,g,f,I,T,B,z,G,J,ne,ve,ye,Ne,Ve,Ie,be,Ae,_e,fe,Oe,Fe,ao,bt,It,yt,Lt,Yt,zt,tn,Ii,nn,ti,Ei;pe("sidebar",(a=r.componentConfigSignal())==null?null:a.sidebarMode)("velt-comment-dialog--sidebar-mode",(s=r.componentConfigSignal())==null?null:s.sidebarMode)("dialog",(c=r.componentConfigSignal())==null?null:c.dialogMode)("velt-comment-dialog--dialog-mode",(p=r.componentConfigSignal())==null?null:p.dialogMode)("hide",(g=r.componentConfigSignal())==null?null:g.showDefault)("velt-comment-dialog--hide",(f=r.componentConfigSignal())==null?null:f.showDefault)("bottom-sheet",(I=r.componentConfigSignal())==null?null:I.bottomSheetMode)("velt-comment-dialog--bottom-sheet",(T=r.componentConfigSignal())==null?null:T.bottomSheetMode)("inbox",(B=r.componentConfigSignal())==null?null:B.inboxMode)("velt-comment-dialog--inbox-mode",(z=r.componentConfigSignal())==null?null:z.inboxMode)("readonly",((G=r.componentConfigSignal())==null||G.user==null?null:G.user.isReadOnly)||((G=r.componentConfigSignal())==null||G.user==null?null:G.user.isAnonymous))("velt-comment-dialog--readonly",((J=r.componentConfigSignal())==null||J.user==null?null:J.user.isReadOnly)||((J=r.componentConfigSignal())==null||J.user==null?null:J.user.isAnonymous))("no-comments",!(!((ne=r.componentConfigSignal())==null||ne.annotation==null||ne.annotation.comments==null)&&ne.annotation.comments.length))("velt-comment-dialog--no-comments",!(!((ve=r.componentConfigSignal())==null||ve.annotation==null||ve.annotation.comments==null)&&ve.annotation.comments.length))("selected",(ye=r.componentConfigSignal())==null?null:ye.commentDialogSelected)("velt-comment-dialog--selected",(Ne=r.componentConfigSignal())==null?null:Ne.commentDialogSelected)("screen-recording",((Ve=r.componentConfigSignal())==null||Ve.recorderInitConfig==null?null:Ve.recorderInitConfig.type)==="screen")("velt-comment-dialog--screen-recording",((Ie=r.componentConfigSignal())==null||Ie.recorderInitConfig==null?null:Ie.recorderInitConfig.type)==="screen")("s-ghost-comment-annotation",(be=r.componentConfigSignal())==null?null:be.showGhostCommentMessage)("velt-comment-dialog--ghost-comment-annotation",(Ae=r.componentConfigSignal())==null?null:Ae.showGhostCommentMessage)("velt-comment-dialog--focused-thread-mode",(_e=r.componentConfigSignal())==null?null:_e.focusedThreadMode)("inline-comment-mode",((fe=r.componentConfigSignal())==null?null:fe.inlineCommentMode)&&!((fe=r.componentConfigSignal())!=null&&fe.isInsidePdfViewer))("velt-comment-dialog--page-comment",(Oe=r.componentConfigSignal())==null||Oe.annotation==null?null:Oe.annotation.isPageAnnotation)("velt-comment-dialog--inline-comment-mode",((Fe=r.componentConfigSignal())==null?null:Fe.inlineCommentMode)&&!((Fe=r.componentConfigSignal())!=null&&Fe.isInsidePdfViewer))("velt-comment-dialog--multi-thread-mode",(ao=r.componentConfigSignal())==null?null:ao.multiThread)("velt-comment-dialog--comment-composer-mode",(bt=r.componentConfigSignal())==null?null:bt.commentComposerMode)("velt-comment-dialog--page-mode-composer",(It=r.componentConfigSignal())==null?null:It.pageModeComposer)("velt-comment-dialog--read-only",(yt=r.componentConfigSignal())==null?null:yt.readOnly)("private-comment",(Lt=r.componentConfigSignal())==null?null:Lt.isPrivateComment)("velt-comment-dialog--private-comment",(Yt=r.componentConfigSignal())==null?null:Yt.isPrivateComment),x("data-velt-annotation-draft",(zt=r.componentConfigSignal())==null?null:zt.getAnnotationDraftAttribute)("data-velt-annotation-edit-comment",(tn=r.componentConfigSignal())!=null&&tn.editComment?!0:void 0)("data-velt-comment-dialog-comments-count",((Ii=r.componentConfigSignal())==null||Ii.annotation==null||Ii.annotation.comments==null?null:Ii.annotation.comments.length)||"0")("data-velt-comment-dialog-comments-status",(nn=r.componentConfigSignal())==null||nn.annotation==null||nn.annotation.status==null?null:nn.annotation.status.id)("data-velt-comment-dialog-comments-status-type",(ti=r.componentConfigSignal())==null||ti.annotation==null||ti.annotation.status==null?null:ti.annotation.status.type)("data-velt-comment-dialog-comments-priority",(Ei=r.componentConfigSignal())==null||Ei.annotation==null||Ei.annotation.priority==null?null:Ei.annotation.priority.id)("data-testid",r.componentId+"-root"),m(3),d("ngIf",r.componentConfigSignal())}},dependencies:[X,Dt,b_,C_,I_,v_,S_,Mf,h_,x_,f_,w_,T_,Sn,P1],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)}[type=button][_ngcontent-%COMP%]:not(:disabled), [type=reset][_ngcontent-%COMP%]:not(:disabled), [type=submit][_ngcontent-%COMP%]:not(:disabled), button[_ngcontent-%COMP%]:not(:disabled){cursor:pointer}[_ngcontent-%COMP%]::-webkit-scrollbar{display:none;width:0;height:0}[_ngcontent-%COMP%]::-webkit-scrollbar{width:0;height:0}[_ngcontent-%COMP%]::-webkit-scrollbar-button{width:0;height:0} .velt-comment-dialog-thread-card-message--email-chip, .velt-autocomplete--contact-chip, .velt-autocomplete--group-chip{color:var(--velt-accent-text);background:var(--velt-accent-transparent);border-radius:var(--velt-border-radius-xs);padding:var(--velt-spacing-xs);word-break:break-word;font-size:var(--velt-font-size-sm);font-style:normal;font-weight:400;line-height:120%} .velt-comment-dialog-thread-card-message--email-chip.velt-autocomplete--contact-chip-current-user, .velt-autocomplete--contact-chip.velt-autocomplete--contact-chip-current-user, .velt-autocomplete--group-chip.velt-autocomplete--contact-chip-current-user{background-color:color-mix(in srgb,var(--velt-warning) 12%,transparent);color:color-mix(in srgb,var(--velt-warning) 32%,var(--velt-text-0))} velt-autocomplete-chip velt-skeleton-loader-internal{width:50px;border-radius:var(--velt-border-radius-xs);margin-block:6px} .velt-comment-dialog--here-chip{color:var(--velt-accent-text);background:var(--velt-accent-transparent);border-radius:var(--velt-border-radius-xs);padding:var(--velt-spacing-xs);word-break:break-word} .velt-attachment-tag{color:var(--velt-accent);word-break:break-word;display:inline-block;cursor:pointer} .velt-attachment-tag:hover{color:var(--velt-accent-hover)}.velt-comment-dialog--comment-link[_ngcontent-%COMP%]{color:var(--velt-accent);word-break:break-all;display:unset}.velt-comment-dialog-shake[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_shake .82s cubic-bezier(.36,.07,.19,.97) both}@keyframes _ngcontent-%COMP%_shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(2px,0,0)}30%,50%,70%{transform:translate3d(-4px,0,0)}40%,60%{transform:translate3d(4px,0,0)}}.velt-comment-dialog[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;gap:var(--velt-spacing-lg);border-radius:var(--velt-border-radius-md);box-shadow:0 8px 16px -8px #0f0f0f1a;box-sizing:border-box;width:361px;text-align:left;font-size:var(--velt-font-size-sm);padding:var(--velt-spacing-lg);background-color:var(--velt-background-0);border:1px solid var(--velt-border-4);color:var(--velt-text-3)}.velt-comment-dialog[_ngcontent-%COMP%] .velt-comment-dialog--line-div[_ngcontent-%COMP%]{border-top:1px solid var(--velt-border-4);width:100%}.velt-comment-dialog.velt-comment-dialog--no-comments[_ngcontent-%COMP%]{padding:0;gap:0}.velt-comment-dialog.velt-comment-dialog--multi-thread-mode[_ngcontent-%COMP%]{box-shadow:none;border:0;background-color:transparent}.velt-comment-dialog.velt-comment-dialog--sidebar-mode[_ngcontent-%COMP%]{width:100%;min-width:100%;box-shadow:none;background:transparent;border-color:transparent}.velt-comment-dialog.velt-comment-dialog--sidebar-mode[_ngcontent-%COMP%]:hover, .velt-comment-dialog.velt-comment-dialog--sidebar-mode.velt-comment-dialog--selected[_ngcontent-%COMP%]{background-color:var(--velt-background-0);border-color:var(--velt-border-4)}.velt-comment-dialog.velt-comment-dialog--page-mode-composer[_ngcontent-%COMP%]{width:100%;padding-inline:var(--velt-spacing-lg);box-shadow:none;background:transparent;border-color:transparent}.velt-comment-dialog.velt-comment-dialog--inline-comment-mode[_ngcontent-%COMP%]{padding:0;box-shadow:none;border-color:transparent;background:transparent;width:100%}.velt-comment-dialog.velt-comment-dialog--inline-comment-section-mode[_ngcontent-%COMP%]{width:100%;box-shadow:none}.velt-comment-dialog.velt-comment-dialog--inline-comment-section-mode.no-comments[_ngcontent-%COMP%]{padding:var(--velt-spacing-md) var(--velt-spacing-sm) var(--velt-spacing-md) var(--velt-spacing-lg)}.velt-comment-dialog.velt-comment-dialog--bottom-sheet[_ngcontent-%COMP%]{width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0} .snippyly-comment-rewriter-text{color:var(--velt-black);background-color:color-mix(in srgb,var(--velt-warning) 42%,var(--velt-white))}.velt-comment-dialog--hide[_ngcontent-%COMP%]{display:none}.velt-comment-dialog--action-bar[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:space-around;padding:var(--velt-spacing-lg);box-sizing:border-box;text-align:center;color:var(--velt-accent-text);gap:var(--velt-spacing-2xl)}.velt-comment-dialog--action-bar[_ngcontent-%COMP%]:empty{display:none}.velt-comment-dialog--action-bar[_ngcontent-%COMP%] .velt-comment-dialog--action-bar-group[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;justify-content:space-around;width:100%;box-sizing:border-box}.velt-comment-dialog--focused-thread-mode[_ngcontent-%COMP%]{border:none;height:100%}.velt-comment-dialog--focused-thread-mode[_ngcontent-%COMP%] app-comment-dialog-body[_ngcontent-%COMP%]{display:flex;flex-grow:1;min-height:0;width:100%;overflow:scroll}"],changeDetection:0});let i=o;return i})();var J7=(()=>{let o=class o{constructor(e,t,r,a){this.bottomSheet=e,this.domService=t,this.loggingService=r,this.elementRef=a,this.user=new zo,this.isInsidePdfViewer=!1,this.bottomSheetData$=new Ce(null),this.saveComment=new Me,this.veltElement=!0,this.subscriptions=[],this.componentId="velt-comment-bottom-sheet"}ngOnInit(){this.setupA11yAttributes()}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Comment bottom sheet")}catch(e){this.loggingService.catch("Error in CommentBottomSheetComponent setupA11yAttributes:",e)}}ngAfterViewInit(){this.openBottomSheet(),this.setBottomSheetData()}ngOnChanges(e){try{e?.annotation&&this.setBottomSheetData()}catch(t){this.catchError("Error in CommentBottomSheetComponent ngOnChanges: ",t)}}setBottomSheetData(){try{this.bottomSheetData$.next({annotation:this.annotation,user:this.user,commentPinSelected:!0,isInsidePdfViewer:this.isInsidePdfViewer,multiThreadAnnotationId:this.annotation?.type==="multiThread"?this.annotation.annotationId:null,saveComment:e=>{this.saveComment.emit(e)},dismiss:()=>{this.closeBottomSheet()}})}catch(e){this.catchError("Error in CommentBottomSheetComponent setBottomSheetData: ",e)}}openBottomSheet(){return Q(this,null,function*(){try{this.annotation.type==="multiThread"?(this.bottomSheetRef=this.bottomSheet.open(Rs,{data:this.bottomSheetData$.asObservable(),panelClass:["snippyly-comment-bottom-sheet-container","velt-mat-bottom-sheet-container"]}),this.subscriptions.push(this.bottomSheetRef.backdropClick().subscribe(()=>{this.domService.resetSelectedAnnotationsMap()}))):(this.bottomSheetRef=this.bottomSheet.open(ar,{data:this.bottomSheetData$.asObservable(),panelClass:["snippyly-comment-bottom-sheet-container","velt-mat-bottom-sheet-container"]}),this.subscriptions.push(this.bottomSheetRef.backdropClick().subscribe(()=>{this.domService.resetSelectedAnnotationsMap()})))}catch(e){this.catchError("Error in CommentBottomSheetComponent openBottomSheet: ",e)}})}closeBottomSheet(){try{this.bottomSheetRef&&this.bottomSheetRef.dismiss()}catch(e){this.catchError("Error in CommentBottomSheetComponent closeBottomSheet: ",e)}}ngOnDestroy(){this.closeBottomSheet(),this.subscriptions.forEach(e=>{e?.unsubscribe()})}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(sd),h(Be),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-bottom-sheet"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{annotation:"annotation",user:"user",isInsidePdfViewer:"isInsidePdfViewer"},outputs:{saveComment:"saveComment"},standalone:!1,features:[Ze],decls:0,vars:0,template:function(t,r){},styles:[".velt-mat-bottom-sheet-container.snippyly-comment-bottom-sheet-container{padding:0!important} .velt-mat-bottom-sheet-container.snippyly-comment-bottom-sheet-container .mat-bottom-sheet-container{padding:0!important}"],changeDetection:0});let i=o;return i})();function Fen(i,o){if(i&1){let n=K();y(0,"div",4),W("pointerup",function(t){return N(n),l(2).togglePinSelection(),F(t.stopPropagation())})("click",function(t){return N(n),F(t.stopPropagation())})("cdkDragStarted",function(){N(n);let t=l(2);return F(t.onPinDragStart())}),y(1,"snippyly-comment-pin",5),W("saveComment",function(t){N(n);let r=l(2);return F(r.saveComment(t))})("commentTargetElementClicked",function(){N(n);let t=l(2);return F(t.togglePinSelection())})("togglePinSelection",function(t){N(n);let r=l(2);return F(r.togglePinSelection(t))}),b()()}if(i&2){let n=l().ngIf,e=l();at("top",(n.commentPinAnnotation==null||n.commentPinAnnotation.position==null?null:n.commentPinAnnotation.position.top)-0+n.offsetTop,"px")("left",(n.commentPinAnnotation==null||n.commentPinAnnotation.position==null?null:n.commentPinAnnotation.position.left)-10+n.offsetLeft,"px"),d("id","comment-pin-container-"+(n.commentPinAnnotation==null?null:n.commentPinAnnotation.annotationId)),x("data-testid",e.componentId+"-popover")("role","button")("aria-expanded",n.commentPinSelected),m(),d("annotation",n.commentPinAnnotation)("containerComponentId",n.componentId)("commentPinSelected",n.commentPinSelected&&!n.annotationDragging)("multipleCommentPinSelected",n.commentPinSelected&&e.objectKeys(n.selectedAnnotationsMap).length>1)("targetElement",n.targetElement)("user",n.user)}}function Len(i,o){if(i&1){let n=K();y(0,"div",7),W("pointerup",function(t){return N(n),l(3).togglePinSelection(),F(t.stopPropagation())})("touchend",function(t){return N(n),t.stopPropagation(),F(t.preventDefault())})("mousedown",function(t){return N(n),F(t.stopPropagation())})("touchstart",function(t){return N(n),F(t.stopPropagation())})("pointerdown",function(t){return N(n),F(t.stopPropagation())})("click",function(t){return N(n),F(t.stopPropagation())})("cdkDragStarted",function(){N(n);let t=l(3);return F(t.onPinDragStart())})("cdkDragMoved",function(t){N(n);let r=l(3);return F(r.onPinMove(t))})("cdkDragReleased",function(){N(n);let t=l(3);return F(t.onPinRelease())}),y(1,"snippyly-comment-pin",8,1),W("togglePinSelection",function(t){N(n);let r=l(3);return F(r.togglePinSelection(t))})("saveComment",function(t){N(n);let r=l(3);return F(r.saveComment(t))}),b()()}if(i&2){let n=me(2),e=l(2).ngIf,t=l();at("top",e.annotationDragging?(e.dragPosition==null?null:e.dragPosition.top)-((n==null?null:n.COMMENT_PIN_SIZE)||40):(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.top)-((n==null?null:n.COMMENT_PIN_SIZE)||40)+e.offsetTop,"px")("left",e.annotationDragging?e.dragPosition==null?null:e.dragPosition.left:(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.left)+e.offsetLeft,"px")("--velt-comment-pin-transform",e.annotationDragging?"none":e.pinTransform??"none")("transform",!e.annotationDragging&&(!(e.commentPinAnnotation==null||e.commentPinAnnotation.position==null)&&e.commentPinAnnotation.position.parentScaleX)?"scale("+1/((e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.parentScaleX)||1)+", "+1/((e.commentPinAnnotation==null||e.commentPinAnnotation.position==null?null:e.commentPinAnnotation.position.parentScaleY)||1)+")":""),pe("pin-dragging",e.annotationDragging),d("id","comment-pin-container-"+(e.commentPinAnnotation==null?null:e.commentPinAnnotation.annotationId))("cdkDragDisabled",(e.commentPinAnnotation==null||e.commentPinAnnotation.from==null?null:e.commentPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("data-testid",t.componentId+"-default")("role","button")("aria-expanded",e.commentPinSelected)("aria-grabbed",e.annotationDragging)("data-transform-inside",e.transformContext?"true":"false"),m(),d("annotation",e.commentPinAnnotation)("annotationDragging",e.annotationDragging)("containerComponentId",e.componentId)("commentPinSelected",e.commentPinSelected&&!e.annotationDragging)("multipleCommentPinSelected",e.commentPinSelected&&t.objectKeys(e.selectedAnnotationsMap).length>1)("targetElement",e.targetElement)("user",e.user)}}function Ben(i,o){if(i&1&&u(0,Len,3,24,"div",6),i&2){let n=l().ngIf;d("ngIf",n.commentPinAnnotation==null?null:n.commentPinAnnotation.position)}}function Ven(i,o){if(i&1&&(v(0),u(1,Fen,2,14,"div",3)(2,Ben,1,1,"ng-template",null,0,Te),C()),i&2){let n=o.ngIf,e=me(3);m(),d("ngIf",n.popoverMode)("ngIfElse",e)}}var e8=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.analyticsService=e,this.authService=t,this.docService=r,this.domService=a,this.commentService=s,this.commentActionsService=c,this.loggingService=p,this.elementRef=g,this.multipleCommentPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.selectedAnnotationsLocationMap={},this.subscriptions=[],this.componentConfigSignal=xe({popoverMode:!1,commentPinAnnotation:void 0,commentPinSelected:!1,offsetLeft:0,offsetTop:0,selectedAnnotationsMap:{},annotationDragging:!1,dragPosition:null,targetElement:void 0,user:void 0,componentId:`comment-pin-portal-${vt()}`}),this.veltElement=!0,this.componentId="velt-comment-pin-portal",this.subscriptions.push(this.authService.getUser$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{user:f}),I))},f=>{this.catchError("Error in CommentPinPortalComponent getUser$ subscription: ",f)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{selectedAnnotationsMap:f}),I)),this.checkCommentPinSelected()},f=>{this.catchError("Error in CommentPinPortalComponent getSelectedAnnotationsMap$ subscription: ",f)})),this.subscriptions.push(this.domService.getSelectedAnnotationsLocationMap$().subscribe(f=>{this.selectedAnnotationsLocationMap=f||{},this.checkCommentPinSelected()},f=>{this.catchError("Error in CommentPinPortalComponent getSelectedAnnotationsLocationMap$ subscription: ",f)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(f=>{this.componentConfigSignal.update(I=>(I=D(E({},I),{popoverMode:f}),I))},f=>{this.catchError("Error in CommentPinPortalComponent getPopoverMode subscription: ",f)}))}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.commentService.getTransformContext$().subscribe(e=>{this.componentConfigSignal.update(t=>{if(t=D(E({},t),{transformContext:e}),e&&this.isElementInsideTransformContainer(this.elementRef?.nativeElement,e.containerSelector)){let r=e.transforms.scale?1/e.transforms.scale:1;t.pinTransform=`scale(${r})`}else t.pinTransform=void 0;return t})}))}catch(e){this.loggingService.catch("Error in CommentPinPortalComponent ngOnInit:",e)}}isElementInsideTransformContainer(e,t){try{return document.querySelector(t)?.contains(e)??!1}catch(r){return this.loggingService.catch("Error in CommentPinPortalComponent isElementInsideTransformContainer:",r),!1}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinPortalComponent setupA11yAttributes:",e)}}setCommentPinAnnotation(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinAnnotation:e}),t)),this.id=this.componentConfigSignal().commentPinAnnotation?.annotationId,this.checkCommentPinSelected()}catch(t){this.catchError("Error in CommentPinPortalComponent setCommentPinAnnotation: ",t)}}setSourceId(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{sourceId:e}),t)),this.checkCommentPinSelected()}catch(t){this.catchError("Error in CommentPinPortalComponent setSourceId: ",t)}}getMultiThreadCommentAnnotations(){}checkCommentPinSelected(){try{let e=this.componentConfigSignal().selectedAnnotationsMap,t=this.componentConfigSignal().commentPinAnnotation,r=this.componentConfigSignal().sourceId;if(t){let a=!!e[t.annotationId];if(a)if(t?.isDraft)t?.sourceId&&(a=t?.sourceId===r,a&&this.domService.setSelectedAnnotationLocation(t.annotationId,this.componentConfigSignal().componentId));else{let s=this.selectedAnnotationsLocationMap?.[t.annotationId];s&&(a=s===this.componentConfigSignal().componentId)}a!==this.componentConfigSignal().commentPinSelected&&this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinSelected:a}),s))}}catch(e){this.catchError("Error in CommentPinPortalComponent checkCommentPinSelected: ",e)}}setTargetElement(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{targetElement:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setTargetElement: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in CommentPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(e){try{let t=e||this.componentConfigSignal().commentPinAnnotation;if(t&&this.commentActionsService.onCommentPinClick(t).catch(a=>{this.catchError("Error in CommentPinPortalComponent togglePinSelection onCommentPinClick: ",a)}),this.componentConfigSignal().selectedAnnotationsMap[t?.annotationId]&&this.selectedAnnotationsLocationMap?.[t?.annotationId]===this.componentConfigSignal().componentId)t?.ghostComment?.type!==Dl.DIFFERENT_DEVICE&&document.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}="${t?.annotationId}"]`)&&this.domService.resetSelectedAnnotationsMap(!0,"comments");else{let a=document.querySelector(`[${U.ATTRIBUTES.VELT_ANNOTATION_DRAFT}]`);if(a||(a=(this.domService.getDraftCommentAnnotationDialogs()||[])[0]),a){let s=a.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_DRAFT);if(s){let c=document.getElementById(`comment-pin-container-${s}`)||document.querySelector(`[data-velt-id='${s}']`);c&&(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),this.domService.resetSelectedAnnotationsMap(!0,"comments"))}}else this.domService.resetSelectedAnnotationsMap(!0,"comments"),this.componentConfigSignal().targetElement&&this.domService.isElementVisibleOnScreen(this.componentConfigSignal().targetElement)&&(this.componentConfigSignal().annotationDragging||this.domService.toggleAnnotationSelection(t,this.componentConfigSignal().componentId,void 0,!0))}}catch(t){this.catchError("Error in CommentPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){try{this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation.annotationId]&&this.componentConfigSignal().commentPinAnnotation?.ghostComment?.type!==Dl.DIFFERENT_DEVICE&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation,this.componentConfigSignal().componentId);let e=document.getElementById(this.componentConfigSignal().commentPinAnnotation.annotationId);if(!e)return;this.parentElement=e.parentElement;let t=this.componentConfigSignal().commentPinAnnotation.position,r=this.componentConfigSignal().transformContext,a=this.parentElement.getBoundingClientRect(),s=a.left+t.left,c=a.top+t.top,p=r&&this.isElementInsideTransformContainer(e,r.containerSelector);this.componentConfigSignal.update(g=>(g=D(E({},g),{elementInTransformedContainer:p}),g)),e.style.width="20px",e.style.height="20px",e.style.margin="0",e.style.padding="0",e.style.display="block",e.style.visibility="visible",e.style.opacity="1",e.style.backgroundColor="var(--velt-comment-pin-background-color, #2d62ff)",e.style.borderRadius="50%",e.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.style.pointerEvents="auto",e.offsetWidth,document.body.appendChild(e),e.style.position="fixed",e.style.top=`${c}px`,e.style.left=`${s}px`,e.style.zIndex="10000",e.style.transform="none",e.offsetWidth,this.componentConfigSignal.update(g=>(g=D(E({},g),{annotationDragging:!0}),g))}catch(e){this.catchError("Error in CommentPinPortalComponent onPinDragStart: ",e)}}onPinMove(e){try{this.updateCurrentPinPosition(e)}catch(t){this.catchError("Error in CommentPinPortalComponent onPinMove: ",t)}}updateCurrentPinPosition(e){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let t=e.event,r=t?.touches?.length?t.touches[0]?.clientX:t.clientX,a=t?.touches?.length?t.touches[0]?.clientY:t.clientY,s=this.componentConfigSignal().transformContext,c=this.domService.getBackgroundElement(r,a);c&&this.commentService.isElementInsideAllowedElements(c)&&(this.componentConfigSignal.update(p=>(p=D(E({},p),{targetElement:c}),p)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=e.event,this.componentConfigSignal.update(p=>(p=D(E({},p),{dragPosition:{top:a,left:r}}),p)))}catch(t){this.catchError("Error in CommentPinPortalComponent updateCurrentPinPosition: ",t)}}onPinRelease(){try{let e=document.getElementById(this.componentConfigSignal().commentPinAnnotation.annotationId);if(!e||!this.parentElement)return;this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let t=this.domService.getElementFromXPath(this.componentConfigSignal().commentPinAnnotation.targetElement?.xpath),r=this.componentConfigSignal().commentPinAnnotation?.targetElement;if(this.pointerMoveEvent){let J=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent,!0,!0,!0,ne=>{if(this.commentService.getSvgAsImg()){let ve=ne?.closest(`[${U.ATTRIBUTES.VELT_COMMENT_CONTAINER}]`);ve&&ve instanceof HTMLElement&&(ne=ve)}return ne});J&&(r=J)}let a=this.domService.getElementFromXPath(r?.xpath),s=this.componentConfigSignal().commentPinAnnotation.targetElement?.xpath,c=r?.xpath,p=s===c;if(!a)return;let g=this.componentConfigSignal().dragPosition,f=a.getBoundingClientRect(),I=50,T=50;if(g){let J=g.left-f.left,ne=g.top-f.top;I=J/f.width*100,T=ne/f.height*100,I=Math.max(0,Math.min(100,I)),T=Math.max(0,Math.min(100,T))}let B=E({},this.componentConfigSignal().commentPinAnnotation);B.targetElement=E({},r),B.targetElement.leftPercentage=I,B.targetElement.topPercentage=T,this.commentService.calculateCommentAnnotationPosition(B),this.componentConfigSignal.update(J=>(J=D(E({},J),{commentPinAnnotation:B,targetElement:a}),J));let z=this.domService.isElementInsideAdditionalLocationContainer(t)||this.domService.isElementInsideAdditionalLocationContainer(a),G=this.docService.getAdditionalDocumentIdFromElement(a)||this.docService.getDocumentPaths()?.clientDocumentId;if(!this.componentConfigSignal().commentPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().commentPinAnnotation?.metadata?.clientDocumentId==G?(this.componentConfigSignal.update(J=>(J=D(E({},J),{commentPinAnnotation:D(E({},J.commentPinAnnotation),{targetElement:r})}),J)),this.commentService.updateComment(this.componentConfigSignal().commentPinAnnotation,z)):this.componentConfigSignal.update(J=>(J=D(E({},J),{targetElement:t}),J)),p){let J=this.componentConfigSignal().transformContext,ne=this.componentConfigSignal().elementInTransformedContainer,ve=J&&this.isElementInsideTransformContainer(a,J.containerSelector);this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{elementInTransformedContainer:ve}),Ne));let ye=e.getBoundingClientRect();if(!ne&&ve){e.style.transition="none";let Ne=ye.top,Ve=ye.left;this.parentElement.appendChild(e),e.style.position="fixed",e.style.top=`${Ne}px`,e.style.left=`${Ve}px`,e.offsetWidth,requestAnimationFrame(()=>{e.style.position="absolute",ve&&B.position.transformContext?(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`,B.position.transformContext.scale!==1&&(e.style.transform=`scale(${1/B.position.transformContext.scale})`)):(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`)})}else e.style.transition="none",this.parentElement.appendChild(e),e.style.position="absolute",e.style.width="20px",e.style.height="20px",e.style.backgroundColor="var(--velt-comment-pin-background-color, #2d62ff)",e.style.borderRadius="50%",e.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.style.visibility="visible",e.style.display="block",e.offsetWidth,ve&&B.position.transformContext?(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`):(e.style.top=`${B.position.top}px`,e.style.left=`${B.position.left}px`);e.offsetWidth,this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{annotationDragging:!1,dragPosition:null}),Ne))}this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_PIN_DRAGGED,{annotationId:this.componentConfigSignal().commentPinAnnotation.annotationId,commentMode:this.commentService.getCommentMode()})}catch(e){this.catchError("Error in CommentPinPortalComponent onPinRelease: ",e)}}saveComment(e){try{this.commentService.saveComment(this.componentConfigSignal().commentPinAnnotation,e)}catch(t){this.catchError("Error in CommentPinPortalComponent saveComment: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.catchError("Error in CommentPinPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentPinPortalComponent unsubscribe: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.commentPinAnnotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(ot),h(Be),h(we),h(Zn),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-pin-portal"]],hostVars:2,hostBindings:function(t,r){t&2&&(yr("id",r.id),x("data-velt-element",r.veltElement))},inputs:{multipleCommentPinsSelected:"multipleCommentPinsSelected",avatarErrorImage:"avatarErrorImage"},standalone:!1,decls:1,vars:1,consts:[["defaultPinPortalRef",""],["commentPinRef",""],[4,"ngIf"],["class","comment-pin-portal",3,"id","top","left","pointerup","click","cdkDragStarted",4,"ngIf","ngIfElse"],[1,"comment-pin-portal",3,"pointerup","click","cdkDragStarted","id"],[3,"saveComment","commentTargetElementClicked","togglePinSelection","annotation","containerComponentId","commentPinSelected","multipleCommentPinSelected","targetElement","user"],["class","comment-pin-portal","cdkDrag","","cdkDragHandle","",3,"id","pin-dragging","top","left","--velt-comment-pin-transform","transform","cdkDragDisabled","pointerup","touchend","mousedown","touchstart","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"comment-pin-portal",3,"pointerup","touchend","mousedown","touchstart","pointerdown","click","cdkDragStarted","cdkDragMoved","cdkDragReleased","id","cdkDragDisabled"],[3,"togglePinSelection","saveComment","annotation","annotationDragging","containerComponentId","commentPinSelected","multipleCommentPinSelected","targetElement","user"]],template:function(t,r){t&1&&u(0,Ven,4,2,"ng-container",2),t&2&&d("ngIf",r.componentConfigSignal())},styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}[_nghost-%COMP%]{position:absolute!important;top:0!important;left:0!important;box-sizing:border-box!important;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset!important;width:unset!important;text-align:left!important;z-index:var(--velt-comment-pin-z-index)!important}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit));-webkit-text-fill-color:initial!important}*[_ngcontent-%COMP%]:empty{display:revert!important}.comment-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:var(--velt-comment-pin-transform, none)!important;transform-origin:0 100%!important;transform-box:fill-box!important;top:0;left:0}.comment-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-comment-pin-z-index)!important}"],changeDetection:0});let i=o;return i})();var q1=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.commentService=e,this.domService=t,this.componentFactoryResolver=r,this.injector=a,this.appRef=s,this.loggingService=c,this.commentsPinById={},this.commentPinTemplate$=new Ce(null),this.customPinEvents$=new Xe}setCommentPin(e){try{if(!this.commentsPinById[e.annotationId])this.setPinPortal(e);else{let t=!1;if(e?.ghostComment?t=e?.ghostComment?.targetElement?.xpath!==this.commentsPinById[e.annotationId]?.[0]?.annotation?.ghostComment?.targetElement?.xpath:this.commentsPinById[e.annotationId]?.[0]?.annotation?.ghostComment?t=!0:t=e.targetElement?.xpath!==this.commentsPinById[e.annotationId]?.[0]?.annotation?.targetElement?.xpath,!t)this.commentsPinById[e.annotationId]?.forEach(r=>{let a=r.portalRef,s=r.userTargetElement,c=r.pinHostElement;if(document.body.contains(s)&&document.body.contains(c))a&&(a.instance.setCommentPinAnnotation(e),this.updateElementOffset(e));else{let p=r.pinHostDomPortalOutlet;p&&(this.removeCommentPinHostAttributes(e.annotationId,r.pinHostElement),this.removeCommentDisabledAttribute(c),p.detach(),delete this.commentsPinById[e.annotationId],e.ghostComment&&this.unselectCommentAnnotation(e),this.setPinPortal(e))}});else{let r=this.commentsPinById[e.annotationId]?.[0]?.pinHostDomPortalOutlet;r&&(this.removeCommentPinHostAttributes(e.annotationId,this.commentsPinById[e.annotationId]?.[0]?.pinHostElement),this.removeCommentDisabledAttribute(this.commentsPinById[e.annotationId]?.[0]?.pinHostElement),r.detach(),delete this.commentsPinById[e.annotationId],e.ghostComment&&this.unselectCommentAnnotation(e),this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in CommentPinPortalService setCommentPin: ",t)}}unselectCommentAnnotation(e){try{this.loggingService.log("%c[WB] Calling CommentPinPortalService FUNCTION: unselectCommentAnnotation","color: green;"),this.domService.getSelectedAnnotationsMap()?.[e?.annotationId]&&this.domService.toggleAnnotationSelection(e)}catch(t){this.loggingService.catch("Error in CommentPinPortalService unselectCommentAnnotation: ",t)}}setPinPortal(e){try{let t=this.commentService.getElementFromComments(e);t.length>0&&(this.commentsPinById[e.annotationId]=[],t.forEach(r=>{if(r){let a=this.domService.getHostElement(r),s=new lr(e8),c=new cr(a,this.appRef,this.injector),p=c.attach(s);p.instance.setCommentPinAnnotation(e),p.instance.setTargetElement(r);let g=r?.getAttribute(U.ATTRIBUTES.VELT_SOURCE_ID);g&&p.instance.setSourceId(g),this.commentsPinById[e.annotationId].push({pinHostDomPortalOutlet:c,pinPortal:s,portalRef:p,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:r,pinHostElement:a}),this.setCommentPinHostAttributes(e.annotationId,a),this.setCommentDisabledAttribute(a),this.updateElementOffset(e)}}))}catch(t){this.loggingService.catch("Error in CommentPinPortalService setPinPortal: ",t)}}setCommentPinHostAttributes(e,t){try{let r=t.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST);if(r){let a=r.split(",");a.includes(e)||(a.push(e),t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,a.join(",")))}else t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,e);window.getComputedStyle(t).position==="static"&&t.offsetHeight>0&&(gm(t)||t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST_STATIC,"true"))}catch(r){this.loggingService.catch("Error in CommentPinPortalService setCommentPinHostAttributes: ",r)}}removeCommentPinHostAttributes(e,t){try{let r=t.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST);if(r){let a=r.split(","),s=a.indexOf(e);s>-1&&(a.splice(s,1),a.length>0?t.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST,a.join(",")):t.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST))}t?.getAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST)||t.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_HOST_STATIC)}catch(r){this.loggingService.catch("Error in CommentPinPortalService removeCommentPinHostAttributes: ",r)}}setCommentDisabledAttribute(e){try{this.commentService.getPopoverMode()&&e.setAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED,"auto")}catch(t){this.loggingService.catch("Error in CommentPinPortalService setCommentDisabledAttribute: ",t)}}removeCommentDisabledAttribute(e){try{e?.getAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED)==="auto"&&e.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_DISABLED)}catch(t){this.loggingService.catch("Error in CommentPinPortalService removeCommentDisabledAttribute: ",t)}}updateElementOffset(e){try{for(let t of this.commentsPinById[e.annotationId]){let{portalRef:r,userTargetElement:a,pinHostElement:s}=t,c=this.domService.getElementOffset(a,s);r.instance.setOffsetLeft(c.offsetLeft),r.instance.setOffsetTop(c.offsetTop)}}catch(t){this.loggingService.catch("Error in CommentPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(r=>r.annotationId);Object.keys(this.commentsPinById).forEach(r=>{t.includes(r)||(this.commentService.customPinsById.has(r)&&this.commentService.customPinsById.delete(r),this.commentsPinById[r].forEach(s=>{s.pinHostDomPortalOutlet.detach(),this.removeCommentPinHostAttributes(r,s.pinHostElement),this.removeCommentDisabledAttribute(s.pinHostElement),this.domService.removeHighlightFromElement(s.pinHostElement),s.userTargetElement&&this.domService.removeHighlightFromElement(s.userTargetElement)}),delete this.commentsPinById[r])})}catch(t){this.loggingService.catch("Error in CommentPinPortalService checkPinsToRemove: ",t)}}getAnnotationIdsByUserTargetElement(e){try{let t=[];return Object.keys(this.commentsPinById||{}).forEach(r=>{this.commentsPinById[r]?.forEach(s=>{s.userTargetElement===e&&t.push(r)})}),t?.length>0?Array.from(new Set(t)):[]}catch(t){return this.loggingService.catch("Error in CommentPinPortalService getAnnotationIdsByUserTargetElement: ",t),[]}}setCommentPinOverrideTemplate(e){this.commentPinTemplate$.next(e)}getCommentPinTemplate$(){return this.commentPinTemplate$}emitCustomPinEvent(e){try{let{element:t,annotation:r}=e;r&&this.commentService.customPinsById.set(r.annotationId,t),this.customPinEvents$.next(e)}catch(t){this.loggingService.catch("Error in CommentPinPortalService emitCustomPinEvent",t)}}getCustomPinEvents$(){return this.customPinEvents$}};o.\u0275fac=function(t){return new(t||o)(ee(we),ee(Be),ee(ko),ee(St),ee(ii),ee(_))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var ie=(()=>{let o=class o{set veltDynamicTemplate({template:e,context:t,id:r,cloneTemplate:a,componentName:s,variant:c,suffix:p,setIfCondition:g,componentElementRef:f,replaceTemplate:I=!0}){try{if(p&&(s+=`--${p}`),c&&(s+=`---${c}`),s){let T=this.wireframeService.getConditionElement(s);if(!T&&e&&(T=e),T){let B=T?.getAttribute("velt-if");B&&g&&g(B),Array.from(T.attributes).forEach(z=>{f?.nativeElement.setAttribute(z.name,z.value)}),t?.componentConfigSignal?this.dynamicDataService.applyConditionalClasses(f?.nativeElement,t):this.dynamicDataService.applyConditionalClasses(f?.nativeElement)}}if(s&&!e){let T=this.wireframeService.getWireframe(s);if(T){let B=document.createElement(T.tagName);B.innerHTML=T.innerHTML,this.template=B}}else this.template=e;this.data=t,this.id=r,this.cloneTemplate=!!a,this.cloneTemplate&&e&&(this.template=this.domService.deepCloneElement(e)),this.checkToUpdateTemplate(I)}catch(T){this.loggingService.warn("Error in DynamicTemplateDirective veltDynamicTemplate: ",T)}}constructor(e,t,r,a,s,c,p,g){this.elementRef=e,this.templateRef=t,this.viewContainer=r,this.dynamicComponentService=a,this.loggingService=s,this.domService=c,this.wireframeService=p,this.dynamicDataService=g,this.directiveId=Math.random().toString(36).substring(7),this.isCustomTemplateMode=!1,this.isDefaultTemplateMode=!1,this.cloneTemplate=!1,this.injectedElements=[],this.componentRefs=[];try{this.loggingService.log("%c[WB] Creating CLASS: DynamicTemplateDirective","color: blue;")}catch(f){this.loggingService.catch("Error in DynamicTemplateDirective constructor: ",f)}}checkDataValue(e,t){let r=e.querySelectorAll("[data-velt]");function a(s,c){return c.split(".").reduce((p,g)=>p&&p[g],s)}r.forEach(s=>{let c=s.getAttribute("data-velt");if(c&&t){let p=a(t,c);s instanceof HTMLElement&&(s.innerText=JSON.stringify(p,null,2))}})}checkToUpdateTemplate(e){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: checkToUpdateTemplate","color: green;"),this.template&&e)if(this.isDefaultTemplateMode=!1,this.isCustomTemplateMode)this.updateDataOnComponentRefs(this.data);else{this.isCustomTemplateMode=!0,this.cleanUp();let t=document.createElement(this.template.tagName);t.innerHTML=this.template.innerHTML,this.injectElementNextToSibling(this.elementRef.nativeElement,t)}else this.isCustomTemplateMode=!1,this.isDefaultTemplateMode||(this.cleanUp(),this.viewContainer.createEmbeddedView(this.templateRef),this.isDefaultTemplateMode=!0)}catch(t){this.loggingService.catch("Error in DynamicTemplateDirective checkToUpdateTemplate: ",t)}}injectElementNextToSibling(e,t){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: injectElementNextToSibling","color: green;"),!t)return;this.cleanUp();let r=t;for(let s=0;s<r.children.length;s++){let c=r.children[s],p=this.dynamicComponentService.processAndReplaceVeltComponents(c,this.data,this.id?this.id:`from-directive-${this.directiveId}`,[],"from directive");p?.length&&this.componentRefs.push(...p)}r.setAttribute("data-velt-added-from-directive","true"),this.customTemplate=r;let a=Array.from(r.childNodes).reverse();e.nextSibling&&e.nextSibling&&e.nextSibling.getAttribute&&e.nextSibling.getAttribute("data-velt-added-from-directive")&&e.parentNode.removeChild(e.nextSibling),a.forEach(s=>{e.parentNode.insertBefore(s,e.nextSibling),s instanceof Element&&this.injectedElements.push(s)}),r.remove()}catch(r){this.loggingService.catch("Error in DynamicTemplateDirective injectElementNextToSibling: ",r)}}updateDataOnComponentRefs(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateDataOnComponentRefs","color: green;"),this.componentRefs.forEach(t=>{this.dynamicComponentService.setCommentRefData(e,t)})}catch(t){this.loggingService.catch("Error in DynamicTemplateDirective updateDataOnComponentRefs: ",t)}}ngOnDestroy(){try{this.cleanUp()}catch(e){this.loggingService.catch("Error in DynamicTemplateDirective ngOnDestroy: ",e)}}cleanUp(){try{this.componentRefs.forEach(e=>{e.destroy()}),this.injectedElements.forEach(e=>{e.remove()}),this.injectedElements=[],this.viewContainer.clear()}catch(e){this.loggingService.catch("Error in DynamicTemplateDirective cleanUp: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Eo),h(Ci),h(W1),h(_),h(Be),h(Ge),h(S))},o.\u0275dir=Gt({type:o,selectors:[["","veltDynamicTemplate",""]],inputs:{veltDynamicTemplate:"veltDynamicTemplate"},standalone:!1});let i=o;return i})();function Uen(i,o){if(i&1&&w(0,"div",7),i&2){let n=l(2);x("data-testid",n.componentId+"-unread-indicator")("aria-hidden","true")}}function jen(i,o){if(i&1&&(v(0),y(1,"div",1)(2,"div",2),ce(),y(3,"svg",3),P(4,"translate"),w(5,"path",4),b(),u(6,Uen,1,2,"div",5),b(),ht(),y(7,"span",6),te(8),b()(),C()),i&2){let n=o.ngIf,e=l();m(),x("data-testid",e.componentId)("role","status"),m(),x("data-testid",e.componentId+"-unread-container")("aria-hidden",!(n!=null&&n.unreadAnnotationCount)),m(),x("role","img")("aria-label",M(4,11,"Comment icon"))("focusable","false"),m(3),d("ngIf",n==null?null:n.unreadAnnotationCount),m(),x("data-testid",e.componentId+"-count")("aria-hidden","true"),m(),ze(n==null?null:n.count)}}var V1e=(()=>{let o=class o extends tt{constructor(e,t,r,a,s){super(s,a,void 0,e),this.commentService=e,this.loggingService=t,this.customFilterService=r,this.themeService=a,this.elementRef=s,this.componentConfigSignal=xe({unreadCommentsMap:null,count:0}),this.subscription=[],this.componentId="velt-comment-pin-bubble";try{this.subscription.push(this.commentService.getUnreadCommentsMap$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=E({},p),p.unreadCommentsMap=c,p))}))}catch(c){this.catchError("Error in CommentPinBubbleComponent constructor: ",c)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentPinBubbleComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinBubbleComponent setupA11yAttributes:",e)}}ngOnChanges(e){super.ngOnChanges(e);try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>{if(r=D(E({},r),{[t]:e[t].currentValue}),t==="annotation")if(r?.annotation?.type==="multiThread"){let a=Object.keys(r.unreadCommentsMap||{});r?.annotation?.commentAnnotationsMap&&(r.count=0,Object.values(r?.annotation?.commentAnnotationsMap||{}).forEach(s=>{s?.status?.id!==this.customFilterService.resolvedStatus?.id&&(r.count=(r?.count||0)+1),a.includes(s.annotationId)&&(r.unreadAnnotationCount=(r.unreadAnnotationCount||0)+1)}))}else r.count=r?.annotation?.comments?.length;return r})})}catch{}}ngOnDestroy(){super.ngOnDestroy();try{this.subscription.forEach(e=>e.unsubscribe())}catch(e){this.catchError("Error in CommentPinBubbleComponent ngOnDestroy: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(_),h(Wo),h(Ke),h(R))},o.\u0275cmp=O({type:o,selectors:[["velt-comment-pin-bubble-internal"]],inputs:{annotation:"annotation"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[[4,"ngIf"],[1,"velt-comment-pin-bubble-container"],[1,"velt-comment-pin-bubble--unread-indicator-container"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M12.6666 1.33325H3.33325C2.80282 1.33325 2.29411 1.54397 1.91904 1.91904C1.54397 2.29411 1.33325 2.80282 1.33325 3.33325V9.99992C1.33325 10.5304 1.54397 11.0391 1.91904 11.4141C2.29411 11.7892 2.80282 11.9999 3.33325 11.9999H11.0599L13.5266 14.4733C13.5889 14.535 13.6628 14.5839 13.744 14.6171C13.8252 14.6503 13.9122 14.6671 13.9999 14.6666C14.0874 14.6688 14.1741 14.6506 14.2533 14.6133C14.375 14.5632 14.4792 14.4783 14.5528 14.3692C14.6263 14.26 14.6659 14.1315 14.6666 13.9999V3.33325C14.6666 2.80282 14.4559 2.29411 14.0808 1.91904C13.7057 1.54397 13.197 1.33325 12.6666 1.33325ZM13.3333 12.3933L11.8066 10.8599C11.7443 10.7981 11.6704 10.7492 11.5892 10.7161C11.508 10.6829 11.421 10.6661 11.3333 10.6666H3.33325C3.15644 10.6666 2.98687 10.5963 2.86185 10.4713C2.73682 10.3463 2.66659 10.1767 2.66659 9.99992V3.33325C2.66659 3.15644 2.73682 2.98687 2.86185 2.86185C2.98687 2.73682 3.15644 2.66659 3.33325 2.66659H12.6666C12.8434 2.66659 13.013 2.73682 13.138 2.86185C13.263 2.98687 13.3333 3.15644 13.3333 3.33325V12.3933Z","fill","currentColor"],["class","velt-comment-pin-bubble--unread-indicator",4,"ngIf"],[1,"velt-comment-pin-bubble--count"],[1,"velt-comment-pin-bubble--unread-indicator"]],template:function(t,r){t&1&&u(0,jen,9,13,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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);display:flex;cursor:pointer}[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-comment-pin-bubble-container[_ngcontent-%COMP%]{display:flex;padding:var(--velt-spacing-xs);align-items:center;border-radius:var(--velt-border-radius-sm);box-shadow:0 0 1px #4551613d,0 2px 4px #45516124;color:var(--velt-accent-text);gap:var(--velt-spacing-xs);background-color:var(--velt-background-0);font-family:var(--velt-default-font-family)}.velt-comment-pin-bubble--unread-indicator-container[_ngcontent-%COMP%]{position:relative;display:flex}.velt-comment-pin-bubble--unread-indicator[_ngcontent-%COMP%]{position:absolute;top:-2px;right:-2px;display:block;width:8px;height:8px;margin-left:var(--velt-spacing-xs);border-radius:var(--velt-border-radius-full);background-color:var(--velt-error);color:var(--velt-error-foreground)}"],changeDetection:0});let i=o;return i})();var Hen=["commentDialogOverlay"],zen=["commentPinBubbleOverlay"],Gen=["*"],Wen=()=>["snippyly-overlay-panel","velt-comment-pin-bubble-overlay-panel","velt-overlay-panel"],U1e=i=>({trigger:i}),qen=()=>["snippyly-overlay-panel","velt-comment-dialog-overlay-panel","velt-overlay-panel"];function Yen(i,o){i&1&&He(0)}function Ken(i,o){if(i&1&&(v(0),u(1,Yen,1,0,"ng-container",13),C()),i&2){l();let n=me(1);l(2);let e=me(9);m(),d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,U1e,n))}}function Zen(i,o){if(i&1){let n=K();y(0,"div",11,4),P(2,"translate"),W("click",function(t){return N(n),F(t.preventDefault())})("pointerenter",function(t){return N(n),l(3).onBubblePointerOver(t),F(t.stopPropagation())})("pointerleave",function(){N(n);let t=l(3);return F(t.onBubblePointerOut())})("pointerup",function(){N(n);let t=l(3);return F(t.onPointerUpOnBubble())}),y(3,"velt-comment-pin-bubble-internal",12),W("afterViewInit",function(){N(n);let t=l(3);return F(t.onBubbleAfterViewInit())})("onDestroy",function(){N(n);let t=l(3);return F(t.onBubbleOnDestroy())}),b()(),u(4,Ken,2,4,"ng-container",6)}if(i&2){let n=l(2).ngIf;x("role","button")("aria-expanded",n.commentBubbleHover)("aria-label",M(2,5,"Comment bubble")),m(3),d("annotation",n.annotation),m(),d("ngIf",n.isBubbleInitialized)}}function Xen(i,o){if(i&1){let n=K();v(0),u(1,Zen,5,7,"ng-template",10,3,Te),W("positionChange",function(t){N(n);let r=l(2);return F(r.onCommentPinBubblePositionChange(t))}),C()}if(i&2){let n=l().ngIf,e=me(2);m(),d("cdkConnectedOverlayOrigin",e)("cdkConnectedOverlayOpen",!n.annotationDragging&&!!(n!=null&&n.user)&&(n.bubbleOnPinHover&&n.commentPinHover||n.commentBubbleHover||n.commentPinSelected))("cdkConnectedOverlayPanelClass",ut(10,Wen))("cdkConnectedOverlayOffsetY",n.popoverMode?0:n.commentPinBubbleOverlayOriginY==="top"?-8:2)("cdkConnectedOverlayOffsetX",n.popoverMode?n.commentPinBubbleOverlayOriginX==="end"?4:0:n.showCommentIndex&&n.commentPinBubbleOverlayOriginX==="end"?8:0)("cdkConnectedOverlayBackdropClass","velt-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",n.positions)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)}}function Qen(i,o){i&1&&He(0)}function Jen(i,o){if(i&1&&u(0,Qen,1,0,"ng-container",13),i&2){l();let n=me(2),e=me(9);d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,U1e,n))}}function etn(i,o){if(i&1){let n=K();v(0),y(1,"velt-multi-thread-comment-dialog-internal",14),P(2,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment.emit(t))})("updateOverlayPosition",function(){N(n);let t=l(4);return F(t.updateOverlayPosition())})("pointerOutFromCommentDialog",function(t){N(n);let r=l(4);return F(r.onPointerOutFromCommentDialog(t))})("pointerUp",function(t){N(n);let r=l(4);return F(r.onPointerUpOnDialog(t))}),b(),C()}if(i&2){let n=l(3).ngIf,e=l();m(),d("multiThreadAnnotationId",n.annotation==null?null:n.annotation.annotationId)("annotation",n.annotation)("user",n.user)("commentPinSelected",n.commentPinSelected)("containerComponentId",n.containerComponentId)("context",e.context)("readOnly",n.readOnly)("commentPinType",n.commentPinType),x("role","dialog")("aria-label",M(2,10,"Multi-thread comment dialog"))}}function ttn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",15),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment.emit(t))})("updateOverlayPosition",function(){N(n);let t=l(4);return F(t.updateOverlayPosition())})("pointerOutFromCommentDialog",function(t){N(n);let r=l(4);return F(r.onPointerOutFromCommentDialog(t))})("addComment",function(t){N(n);let r=l(4);return F(r.addCommentEmitter.emit(t))})("pointerUp",function(){N(n);let t=l(4);return F(t.onPointerUpOnDialog())}),b()}if(i&2){let n=l(3).ngIf;d("annotation",n.annotation)("user",n.user)("commentPinSelected",n.commentPinSelected)("containerComponentId",n.containerComponentId)("readOnly",n.readOnly)("commentPinType",n.commentPinType),x("role","dialog")("aria-label",M(1,8,"Comment dialog"))}}function ntn(i,o){if(i&1&&u(0,etn,3,12,"ng-container",8)(1,ttn,2,10,"ng-template",null,2,Te),i&2){let n=me(2),e=l(2).ngIf;d("ngIf",(e==null||e.annotation==null?null:e.annotation.type)==="multiThread")("ngIfElse",n)}}function itn(i,o){if(i&1){let n=K();u(0,ntn,3,2,"ng-template",10,5,Te),W("positionChange",function(t){N(n);let r=l(2);return F(r.onCommentDialogPositionChange(t))})}if(i&2){let n=o.trigger,e=l().ngIf;d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",(!e.commentBubbleAvailable||e.commentPinType==="bubble")&&!!(e!=null&&e.user)&&!e.annotationDragging&&(!e.isPhone||!e.mobileMode)&&!e.dialogOpenedInSidebar&&!e.streamMode&&!e.inboxMode&&e.floatingCommentsEnabled&&(e.commentPinSelected&&(e.commentPinType!=="bubble"||e.openDialog)||e.dialogOnHover&&(e.bubbleOnPin?e.commentBubbleHover:e.commentPinHover)&&(e.commentPinType!=="bubble"||e.openDialog)||e.commentPinType==="bubble"&&e.commentBubbleTargetPinHover&&e.openDialog))("cdkConnectedOverlayPanelClass",ut(10,qen))("cdkConnectedOverlayOffsetY",e.popoverMode?0:e.commentDialogOverlayOriginY==="top"?-8:2)("cdkConnectedOverlayOffsetX",e.popoverMode?e.commentDialogOverlayOriginX==="end"?4:0:e.showCommentIndex&&e.commentDialogOverlayOriginX==="end"?8:0)("cdkConnectedOverlayBackdropClass","velt-overlay-backdrop")("cdkConnectedOverlayLockPosition",!1)("cdkConnectedOverlayPositions",e.positions)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",!0)}}function otn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-bottom-sheet",16),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(2);return F(r.saveComment.emit(t))}),b()}if(i&2){let n=l().ngIf;d("annotation",n.annotation)("user",n.user),x("role","dialog")("aria-label",M(1,4,"Comment bottom sheet"))}}function rtn(i,o){if(i&1){let n=K();v(0),y(1,"div",7,0),P(3,"translate"),W("click",function(t){return N(n),F(t.preventDefault())})("pointerenter",function(t){return N(n),l().onPointerOver(t),F(t.stopPropagation())})("pointerleave",function(){N(n);let t=l();return F(t.onPointerOut())}),jt(4),b(),u(5,Xen,3,11,"ng-container",8)(6,Jen,1,4,"ng-template",null,1,Te)(8,itn,2,11,"ng-template",null,2,Te)(10,otn,2,6,"snippyly-comment-bottom-sheet",9),C()}if(i&2){let n=o.ngIf,e=me(7),t=l();m(),x("data-testid",t.componentId+"-trigger")("role","button")("aria-expanded",n.commentPinSelected)("aria-haspopup","dialog")("aria-label",M(3,8,"Comment pin")),m(4),d("ngIf",n.bubbleOnPin&&!n.commentBubbleAvailable&&!n.dialogOpenedInSidebar)("ngIfElse",e),m(5),d("ngIf",(n==null?null:n.user)&&n.mobileMode&&n.isPhone&&!n.sidebarVisible&&!n.dialogOpenedInSidebar&&!n.inboxMode&&!n.streamMode&&n.floatingCommentsEnabled&&n.commentPinSelected)}}var Y1=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.breakpointObserver=e,this.commentService=t,this.domService=r,this.loggingService=a,this.elementRef=s,this.commentPinPortalService=c,this.commentPinSelected=!1,this.annotationDragging=!1,this.commentPinType="pin",this.commentBubbleTargetPinHover=!1,this.showBubbleOnHover=!1,this.bubbleOnPin=!1,this.bubbleOnPinHover=!1,this.readOnly=!1,this.openDialog=!0,this.saveComment=new Me,this.togglePinSelection=new Me,this.commentTargetElementClicked=new Me,this.addCommentEmitter=new Me,this.isDialogOnHoverEnabled=!1,this.isDialogOnTargetElementClickEnabled=!1,this.previouslySelectedAnnotations={},this.eventListenersSubscriptions=[],this.customScrollableParentEventsListenersSubscriptions=[],this.componentConfigSignal=xe({bubbleOnPin:!1,bubbleOnPinHover:!1,dialogOnHover:!1,commentBubbleAvailable:!1,commentPinHover:!1,commentBubbleHover:!1,commentPinSelected:!1,popoverMode:!1,showCommentIndex:!1,commentBubbleTargetPinHover:!1,isBubbleInitialized:!1,annotationDragging:!1,commentPinBubbleOverlayOriginX:"start",commentPinBubbleOverlayOriginY:"top",positions:[],annotation:void 0,commentPinType:"pin",isPhone:!1,mobileMode:!1,streamMode:!1,inboxMode:!1,floatingCommentsEnabled:!1,sidebarVisible:!1,dialogOpenedInSidebar:!1,readOnly:!1,openDialog:!0,commentDialogOverlayOriginX:"start",commentDialogOverlayOriginY:"top",user:void 0}),this.subscriptions=[],this.componentId="velt-comment-dialog-portal";try{this.loggingService.log("%c[WB] Creating COMPONENT CommentDialogPortalComponent","color: blue;"),this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(p=>{p.matches?this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!0}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!1}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent breakpointObserver subscription: ",p)})),this.subscriptions.push(this.commentService.getSidebarVisibility$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{sidebarVisible:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getSidebarVisibility$ subscription: ",p)})),this.subscriptions.push(this.commentService.getMobileMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{mobileMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getMobileMode$ subscription: ",p)})),this.subscriptions.push(this.commentService.getShowCommentIndex().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{showCommentIndex:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getShowCommentIndex subscription: ",p)})),this.subscriptions.push(this.commentService.getStreamMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{streamMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getStreamMode$ subscription: ",p)})),this.subscriptions.push(this.commentService.getInboxMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{inboxMode:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getInboxMode subscription: ",p)})),this.subscriptions.push(this.domService.getDialogOpenedInSidebar().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{dialogOpenedInSidebar:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent getDialogOpenedInSidebar subscription: ",p)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{popoverMode:p}),g)),this.componentConfigSignal().popoverMode?this.componentConfigSignal.update(g=>(g=D(E({},g),{positions:U.OVERLAY_POSITIONS_FOR_POPOVER_MODE.map(f=>new di({originX:f.originX,originY:f.originY},{overlayX:f.overlayX,overlayY:f.overlayY}))}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{positions:U.OVERLAY_POSITIONS.map(f=>new di({originX:f.originX,originY:f.originY},{overlayX:f.overlayX,overlayY:f.overlayY}))}),g)),this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getPopoverMode subscription: ",p)})),this.subscriptions.push(this.commentService.showFloatingComments$().subscribe(p=>{this.componentConfigSignal.update(g=>(g=D(E({},g),{floatingCommentsEnabled:p}),g))},p=>{this.catchError("Error in CommentDialogPortalComponent showFloatingComments$ subscription: ",p)})),this.subscriptions.push(this.commentService.getEnableDialogOnHover$().subscribe(p=>{this.isDialogOnHoverEnabled=p,this.componentConfigSignal.update(g=>(g=D(E({},g),{dialogOnHover:p}),g)),this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getEnableDialogOnHover subscription: ",p)})),this.subscriptions.push(this.commentService.getEnableDialogOnTargetElementClick$().subscribe(p=>{this.isDialogOnTargetElementClickEnabled=p,this.addEventListeners()},p=>{this.catchError("Error in CommentDialogPortalComponent getEnableDialogOnTargetElementClick subscription: ",p)})),this.subscriptions.push(this.commentService.getBubbleCommentAnnotationIds$().subscribe(p=>{if(p.includes(this.componentConfigSignal().annotation?.annotationId)){this.commentBubbleElement=this.commentService.getCommentBubbleElement(this.componentConfigSignal().annotation);let g=this.commentBubbleElement?.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_ID)||"";this.commentBubbleElementAnnotationId!==g&&(this.commentBubbleElementAnnotationId=g,this.componentConfigSignal.update(f=>(f=D(E({},f),{commentBubbleAvailable:!0}),f)))}else this.componentConfigSignal().commentBubbleAvailable&&(this.commentBubbleElement=null,this.commentBubbleElementAnnotationId="",this.componentConfigSignal.update(g=>(g=D(E({},g),{commentBubbleAvailable:!1}),g)))},p=>{this.catchError("Error in CommentDialogPortalComponent getBubbleCommentAnnotationIds$ subscription: ",p)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().pipe(Oi()).subscribe(([p,g])=>{this.previouslySelectedAnnotations=p||{},g&&!g[this.componentConfigSignal().annotation?.annotationId]&&this.componentConfigSignal().commentPinHover&&this.setCommentPinHover(!1)},p=>{this.catchError("Error in CommentDialogPortalComponent getSelectedAnnotationsMap$ subscription: ",p)}))}catch(p){this.catchError("Error in CommentDialogPortalComponent constructor: ",p)}}ngOnInit(){try{this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentDialogPortalComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentDialogPortalComponent setupA11yAttributes:",e)}}ngAfterViewInit(){try{this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement()}catch(e){this.catchError("Error in CommentDialogPortalComponent AfterViewInit: ",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.commentPinSelected&&(this.componentConfigSignal().commentPinSelected&&this.setCommentPinHover(!1),this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement()),e?.targetElement&&(this.addEventListeners(),this.targetElement?this.setCustomScrollableParents(Ug(this.targetElement)):this.setCustomScrollableParents([]))}catch(t){this.catchError("Error in CommentDialogPortalComponent ngOnChanges: ",t)}}onBubbleAfterViewInit(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{isBubbleInitialized:!0}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubbleAfterViewInit: ",e)}}onBubbleOnDestroy(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{isBubbleInitialized:!1}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubbleOnDestroy: ",e)}}onCommentPinBubblePositionChange(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinBubbleOverlayOriginX:e.connectionPair.originX,commentPinBubbleOverlayOriginY:e.connectionPair.originY}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onCommentPinBubblePositionChange: ",t)}}onCommentDialogPositionChange(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{commentDialogOverlayOriginX:e.connectionPair.originX,commentDialogOverlayOriginY:e.connectionPair.originY}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onCommentDialogPositionChange: ",t)}}updateOverlayPosition(){try{this.loggingService.log("updateOverlayPosition",this.componentConfigSignal().annotation?.annotationId),this.commentPinBubbleOverlay&&this.commentPinBubbleOverlay?.overlayRef?.updatePosition(),this.commentDialogOverlay&&this.commentDialogOverlay?.overlayRef?.updatePosition()}catch{}}onPointerOutFromCommentDialog(e){try{!this.targetElement?.contains(e?.relatedTarget)&&!this.componentConfigSignal().commentPinSelected&&this.onPointerOut()}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerOutFromCommentDialog: ",t)}}onPointerOut(){try{this.componentConfigSignal().bubbleOnPin?setTimeout(()=>{this.setCommentPinHover(!1)},500):this.setCommentPinHover(!1)}catch(e){this.catchError("Error in CommentDialogPortalComponent onPointerOut: ",e)}}setCommentPinHover(e){try{e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.componentConfigSignal.update(r=>(r=D(E({},r),{commentPinHover:e}),r)),this.updateHighlightOnElement(),this.updateCommentActiveAttributeOnElement();let t=this.commentBubbleElementRef?.nativeElement||this.commentBubbleElement;t&&(this.componentConfigSignal().commentPinHover?t.setAttribute("comment-bubble-target-pin-hover","true"):t.removeAttribute("comment-bubble-target-pin-hover"))}catch(t){this.catchError("Error in CommentDialogPortalComponent setCommentPinHover: ",t)}}addEventListeners(){try{this.removeEventListeners(),this.componentConfigSignal().popoverMode&&this.targetElement&&this.isDialogOnTargetElementClickEnabled&&this.componentConfigSignal().commentPinType!=="bubble"&&(this.isDialogOnHoverEnabled&&(this.eventListenersSubscriptions.push(vi(this.targetElement,"pointerover").subscribe(e=>{this.onPointerOver(e),e.stopPropagation()},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners pointerover subscription: ",e)})),this.eventListenersSubscriptions.push(vi(this.targetElement,"pointerout").subscribe(e=>{!this.targetElement?.contains(e?.relatedTarget)&&!e?.relatedTarget?.closest(U.TAGS.SNIPPYLY_COMMENT_DIALOG)&&this.onPointerOut()},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners pointerout subscription: ",e)}))),this.eventListenersSubscriptions.push(vi(this.targetElement,"click").subscribe(e=>{this.previouslySelectedAnnotations[this.componentConfigSignal().annotation?.annotationId]||(this.commentTargetElementClicked.emit(),e.stopPropagation())},e=>{this.catchError("Error in CommentDialogPortalComponent addEventListeners click subscription: ",e)})))}catch(e){this.catchError("Error in CommentDialogPortalComponent addEventListeners: ",e)}}removeEventListeners(){try{this.eventListenersSubscriptions.map(e=>{e.unsubscribe()}),this.eventListenersSubscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent removeEventListeners: ",e)}}updateHighlightOnElement(){try{this.targetElement&&(this.componentConfigSignal().commentPinSelected||this.componentConfigSignal().commentPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(e){this.catchError("Error in CommentDialogPortalComponent updateHighlightOnElement: ",e)}}updateCommentActiveAttributeOnElement(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateCommentActiveAttributeOnElement","color: green;"),this.componentConfigSignal().commentPinSelected||this.componentConfigSignal().commentPinHover)this.targetElement&&(this.targetElement?.hasAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)||this.targetElement?.setAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE,"true"));else if(this.targetElement&&this.targetElement?.hasAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)){let e=this.commentPinPortalService.getAnnotationIdsByUserTargetElement(this.targetElement),t=!1;if(e&&e.length>0){let r=this.domService.getSelectedAnnotationsMap();e.forEach(a=>{if(r?.[a]){t=!0;return}})}t||this.targetElement?.removeAttribute(U.ATTRIBUTES.VELT_COMMENT_PIN_ACTIVE)}}catch(e){this.catchError("Error in CommentDialogPortalComponent onCommentFocusChange: ",e)}}onPointerUpOnDialog(e){try{(!this.componentConfigSignal().commentPinSelected||e)&&this.togglePinSelection.emit(e)}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerUpOnDialog: ",t)}}onPointerOver(e){try{if(this.componentConfigSignal().commentPinHover)return;e.buttons?this.componentConfigSignal().commentPinHover&&this.setCommentPinHover(!1):!this.componentConfigSignal().commentPinHover&&(this.componentConfigSignal().bubbleOnPin?this.componentConfigSignal().bubbleOnPinHover:this.isDialogOnHoverEnabled)&&this.setCommentPinHover(!0)}catch(t){this.catchError("Error in CommentDialogPortalComponent onPointerOver: ",t)}}setCustomScrollableParents(e){try{this.customScrollableParents=e,this.addCustomScrollableParentsEventListeners()}catch(t){this.catchError("Error in CommentDialogPortalComponent setCustomScrollableParents: ",t)}}addCustomScrollableParentsEventListeners(){try{this.removeCustomScrollableParentsEventListeners(),this.customScrollableParents?.length&&this.customScrollableParents?.forEach(e=>{this.customScrollableParentEventsListenersSubscriptions.push(vi(e,"scroll",{passive:!0}).subscribe(t=>{this.updateOverlayPosition()},t=>{this.catchError("Error in CommentDialogPortalComponent addCustomScrollableParentsEventListeners scroll subscription: ",t)}))})}catch(e){this.catchError("Error in CommentDialogPortalComponent addCustomScrollableParentsEventListeners: ",e)}}removeCustomScrollableParentsEventListeners(){try{this.customScrollableParentEventsListenersSubscriptions.map(e=>{e.unsubscribe()}),this.customScrollableParentEventsListenersSubscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent removeCustomScrollableParentsEventListeners: ",e)}}onBubblePointerOver(e){try{if(this.componentConfigSignal().commentBubbleHover)return;e.buttons||this.componentConfigSignal.update(t=>(t=D(E({},t),{commentBubbleHover:!0}),t))}catch(t){this.catchError("Error in CommentDialogPortalComponent onBubblePointerOver: ",t)}}onBubblePointerOut(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{commentBubbleHover:!1}),e))}catch(e){this.catchError("Error in CommentDialogPortalComponent onBubblePointerOut: ",e)}}onPointerUpOnBubble(){try{this.componentConfigSignal().commentPinSelected||this.togglePinSelection.emit()}catch(e){this.catchError("Error in CommentDialogPortalComponent onPointerUpOnBubble: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.catchError("Error in CommentDialogPortalComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.removeEventListeners(),this.removeCustomScrollableParentsEventListeners(),this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentDialogPortalComponent unsubscribe: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(wo),h(we),h(Be),h(_),h(R),h(q1))},o.\u0275cmp=O({type:o,selectors:[["velt-comment-dialog-portal-internal"]],viewQuery:function(t,r){if(t&1&&(it(Hen,5),it(zen,5)),t&2){let a;Je(a=et())&&(r.commentDialogOverlay=a.first),Je(a=et())&&(r.commentPinBubbleOverlay=a.first)}},inputs:{annotation:"annotation",context:"context",commentPinSelected:"commentPinSelected",annotationDragging:"annotationDragging",commentPinType:"commentPinType",commentBubbleTargetPinHover:"commentBubbleTargetPinHover",user:"user",targetElement:"targetElement",showBubbleOnHover:"showBubbleOnHover",bubbleOnPin:"bubbleOnPin",bubbleOnPinHover:"bubbleOnPinHover",containerComponentId:"containerComponentId",readOnly:"readOnly",openDialog:"openDialog",commentBubbleElementRef:"commentBubbleElementRef"},outputs:{saveComment:"saveComment",togglePinSelection:"togglePinSelection",commentTargetElementClicked:"commentTargetElementClicked",addCommentEmitter:"addComment"},standalone:!1,features:[Ze],ngContentSelectors:Gen,decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["defaultDialogViewRef",""],["commentDialogRef",""],["commentPinBubbleOverlay","cdkConnectedOverlay"],["bubbleOnHoverTrigger","cdkOverlayOrigin"],["commentDialogOverlay","cdkConnectedOverlay"],[4,"ngIf"],["cdkOverlayOrigin","",3,"click","pointerenter","pointerleave"],[4,"ngIf","ngIfElse"],[3,"annotation","user","saveComment",4,"ngIf"],["cdkConnectedOverlay","",3,"positionChange","cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayOffsetY","cdkConnectedOverlayOffsetX","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayLockPosition","cdkConnectedOverlayPositions","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayDisableClose"],["cdkOverlayOrigin","",3,"click","pointerenter","pointerleave","pointerup"],["veltAfterViewInit","",3,"afterViewInit","onDestroy","annotation"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"saveComment","updateOverlayPosition","pointerOutFromCommentDialog","pointerUp","multiThreadAnnotationId","annotation","user","commentPinSelected","containerComponentId","context","readOnly","commentPinType"],[3,"saveComment","updateOverlayPosition","pointerOutFromCommentDialog","addComment","pointerUp","annotation","user","commentPinSelected","containerComponentId","readOnly","commentPinType"],[3,"saveComment","annotation","user"]],template:function(t,r){t&1&&(Ht(),u(0,rtn,11,10,"ng-container",6)),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,ar,J7,yu,V1e,Rs,ge],encapsulation:2,changeDetection:0});let i=o;return i})();var atn=["pinRef"],stn=["commentDialogPortalRef"],ltn=["*"],H1e=i=>({componentConfigSignal:i}),ctn=(i,o)=>({condition:i,data:o}),$1e=()=>["bubble","chart"],dtn=(i,o,n,e,t)=>({template:i,context:o,componentName:"velt-comment-pin-wireframe",variant:n,setIfCondition:e,componentElementRef:t}),mtn=(i,o,n)=>({"velt-comment-pin--status-default":i,"velt-comment-pin--status-ongoing":o,"velt-comment-pin--status-terminal":n});function ptn(i,o){i&1&&He(0)}function gtn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,ptn,1,0,"ng-container",11),b()),i&2){l();let n=me(3),e=l(2);x("data-testid",e.componentId+"-shadow-dom"),m(),d("ngTemplateOutlet",n)}}function utn(i,o){if(i&1){let n=K();v(0),y(1,"div",14),W("click",function(t){return N(n),F(t.preventDefault())}),jt(2),b(),C()}i&2&&(m(),x("role","presentation"))}function htn(i,o){if(i&1&&(v(0),w(1,"app-comment-pin-triangle",15),C()),i&2){let n=l(5);m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.triangleTemplate)}}function ftn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",21)(2,"path",22),b())}function vtn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",23)(2,"path",24),b())}function Ctn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",25)(2,"path",26),b())}function _tn(i,o){i&1&&(ce(),y(0,"svg",20),w(1,"path",27)(2,"path",28),b())}function ytn(i,o){if(i&1&&(v(0)(1,18),u(2,ftn,3,0,"svg",19)(3,vtn,3,0,"svg",19)(4,Ctn,3,0,"svg",19)(5,_tn,3,0,"svg",19),C()()),i&2){let n=l(6).ngIf;m(),d("ngSwitch",n.annotation==null||n.annotation.pageInfo==null||n.annotation.pageInfo.deviceInfo==null?null:n.annotation.pageInfo.deviceInfo.deviceType),m(),d("ngSwitchCase","Mobile"),m(),d("ngSwitchCase","Tablet"),m(),d("ngSwitchCase","Desktop"),m(),d("ngSwitchCase","Monitor")}}function Stn(i,o){if(i&1&&w(0,"snippyly-user-avatar",29),i&2){let n=l(6).ngIf;d("user",n.annotation==null?null:n.annotation.from)}}function btn(i,o){if(i&1&&(v(0),w(1,"app-comment-pin-unread-comment-indicator",15),C()),i&2){let n=l(7);m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.unreadCommentIndicatorTemplate)}}function Itn(i,o){if(i&1&&w(0,"app-comment-pin-number",15)(1,"app-comment-pin-ghost-comment-indicator",15)(2,"app-comment-pin-private-comment-indicator",15),i&2){let n=l(7);d("componentConfigSignal",n.componentConfigSignal)("template",n.indexTemplate),m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.ghostCommentIndicatorTemplate),m(),d("componentConfigSignal",n.componentConfigSignal)("template",n.privateCommentIndicatorTemplate)}}function Etn(i,o){if(i&1){let n=K();v(0),y(1,"div",17,5),W("click",function(t){return N(n),F(t.preventDefault())}),u(3,ytn,6,5,"ng-container",10)(4,Stn,1,1,"ng-template",null,6,Te)(6,btn,2,2,"ng-container",10)(7,Itn,3,6,"ng-template",null,7,Te),b(),C()}if(i&2){let n=me(5),e=me(8),t=l(5).ngIf,r=l();m(),at("--velt-internal-comment-pin-bg-color",(t.annotation==null||t.annotation.status==null?null:t.annotation.status.color)||null),pe("velt-comment-pin--marker-transparent",r.usingCustomCommentPin)("velt-comment-pin--marker-default",!r.usingCustomCommentPin),d("ngClass",$e(12,mtn,!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="default",!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="ongoing",!t.customStatusesShown&&(t.annotation==null||t.annotation.status==null?null:t.annotation.status.type)==="terminal")),x("role","presentation"),m(2),d("ngIf",t.isDeviceIndicatorOnCommentPinsEnabled&&t.isCommentAddedOnDifferentDeviceType)("ngIfElse",n),m(3),d("ngIf",!(t.user!=null&&t.user.isGuest)&&!(t.user!=null&&t.user.isAnonymous)&&(t==null||t.unreadCommentsMap==null?null:t.unreadCommentsMap[t.annotation==null?null:t.annotation.annotationId]))("ngIfElse",e)}}function xtn(i,o){if(i&1){let n=K();y(0,"div",14),W("click",function(t){return N(n),F(t.preventDefault())}),u(1,Etn,9,16,"ng-container",16),b()}if(i&2){let n=l(4).ngIf,e=l();x("role","presentation"),m(),d("veltDynamicTemplate",$(4,dtn,e.template,A(2,H1e,e.componentConfigSignal),n==null?null:n.variant,e.setIfCondition.bind(e),e.elementRef))}}function Ttn(i,o){if(i&1&&u(0,htn,2,2,"ng-container",10)(1,xtn,2,10,"ng-template",null,4,Te),i&2){let n=me(2),e=l(3).ngIf;d("ngIf",e.popoverMode)("ngIfElse",n)}}function Dtn(i,o){if(i&1){let n=K();y(0,"velt-comment-dialog-portal-internal",12,1),W("saveComment",function(t){N(n);let r=l(3);return F(r.saveComment.emit(t))})("togglePinSelection",function(t){N(n);let r=l(3);return F(r.onPinBubblePointerUp(t))})("pointerUp",function(){N(n);let t=l(3);return F(t.onPointerUpOnDialog())}),y(2,"div",13,2),u(4,utn,3,1,"ng-container",10)(5,Ttn,3,2,"ng-template",null,3,Te),b()()}if(i&2){let n=me(6),e=l(2).ngIf,t=l();d("annotation",e.annotation)("user",e.user)("commentPinSelected",e.commentPinSelected)("annotationDragging",e.annotationDragging)("commentPinType",e.commentPinType)("targetElement",e.targetElement)("bubbleOnPin",e.bubbleOnPin)("bubbleOnPinHover",e.bubbleOnPinHover)("containerComponentId",e.containerComponentId),m(2),at("--velt-internal-comment-pin-max-width",t.pinMaxWidth),pe("velt-comment-pin--ghost",!!(e.annotation!=null&&e.annotation.ghostComment))("velt-comment-pin--different-device",e.isDeviceIndicatorOnCommentPinsEnabled&&e.isCommentAddedOnDifferentDeviceType)("velt-comment-pin--outside-viewport",!e.annotationDragging&&t.isOutsideViewport)("velt-comment-pin-open",e.commentPinSelected&&!e.annotationDragging)("velt-comment-pin-unread-comment",!(e.user!=null&&e.user.isGuest)&&!(e.user!=null&&e.user.isAnonymous)&&(e==null||e.unreadCommentsMap==null?null:e.unreadCommentsMap[e.annotation==null?null:e.annotation.annotationId]))("velt-display-none",e.commentPinType!=="bubble"&&e.commentBubbleElementAnnotationId&&e.commentBubbleElementAnnotationId!==(e.annotation==null?null:e.annotation.annotationId)),x("data-testid",t.componentId)("role","button")("aria-expanded",e.commentPinSelected),m(2),d("ngIf",e.commentPinType==="bubble"||e.commentPinType==="chart")("ngIfElse",n)}}function wtn(i,o){if(i&1&&(v(0),u(1,gtn,2,2,"velt-shadow-dom-internal",10)(2,Dtn,7,28,"ng-template",null,0,Te),C()),i&2){let n=me(3),e=l().ngIf,t=l();m(),d("ngIf",!t.template&&t.pinShadowDOM&&!(ut(2,$1e)!=null&&ut(3,$1e).includes(e.commentPinType)))("ngIfElse",n)}}function Otn(i,o){if(i&1&&(v(0),u(1,wtn,4,4,"ng-container",9),C()),i&2){let n=l();m(),d("veltIf",k(3,ctn,n.conditionSignal(),A(1,H1e,n.componentConfigSignal)))}}var Eu=(()=>{let o=class o extends c7{constructor(e,t,r,a,s,c,p){super(c,p,r),this.commentService=e,this.domService=t,this.loggingService=r,this.commentPinPortalService=a,this.wireframeService=s,this.elementRef=c,this.dynamicDataService=p,this.commentPinSelected=!1,this.annotationDragging=!1,this.commentPinType="pin",this.usingCustomCommentPin=!1,this.multipleCommentPinsSelected=!1,this.avatarErrorImage="",this.saveComment=new Me,this.pinShadowDOM=!1,this.subscriptions=[],this.commentTargetElementClicked=new Me,this.togglePinSelection=new Me,this.commentBubbleAvailable=!1,this.commentPinPosition={top:0,left:0},this.isOutsideViewport=!1,this.pinMaxWidth="",this.previouslySelectedAnnotations={},this.deviceInfo=new Yn,this.COMMENT_PIN_SIZE=40,this.componentConfigSignal=xe({isGhostComment:!1,isPrivateComment:!1,showCommentIndex:!1,bubbleOnPin:!1,bubbleOnPinHover:!1,commentPinSelected:!1,annotationDragging:!1,popoverMode:!1,isDeviceIndicatorOnCommentPinsEnabled:!1,isCommentAddedOnDifferentDeviceType:!1,annotation:this.annotation,user:this.user,unreadCommentsMap:null,popoverTriangleComponent:!1}),this.veltElement=!0,this.componentId="velt-comment-pin",this.loggingService.log("%c[WB] Creating COMPONENT CommentPinComponent","color: blue;"),this.subscriptions.push(this.domService.getDeviceInfo$().subscribe(g=>{this.deviceInfo=g,this.checkIfCommentAddedOnDifferentDeviceType()})),this.subscriptions.push(this.commentService.getShowCommentIndex().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{showCommentIndex:g}),f))},g=>{this.catchError("Error in CommentPinComponent getShowCommentIndex subscription: ",g)})),this.subscriptions.push(this.commentService.getBubbleOnPin$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{bubbleOnPin:g}),f))},g=>{this.catchError("Error in CommentPinComponent getBubbleOnPin subscription: ",g)})),this.subscriptions.push(this.commentService.getBubbleOnPinHover$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{bubbleOnPinHover:g}),f))},g=>{this.catchError("Error in CommentPinComponent getBubbleOnPinHover subscription: ",g)})),this.subscriptions.push(this.commentService.getPopoverTriangleComponent$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{popoverTriangleComponent:g}),f))},g=>{this.catchError("Error in CommentPinComponent getPopoverTriangleComponent$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPinShadowDOM$().subscribe(g=>{this.pinShadowDOM=g},g=>{this.catchError("Error in CommentPinComponent getPinShadowDOM$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPinDarkMode$().subscribe(g=>{g!==null&&(g?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark"))},g=>{this.catchError("Error in CommentPinComponent pinDarkMode$ subscription: ",g)})),this.subscriptions.push(this.commentService.getPopoverMode$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{popoverMode:g}),f))},g=>{this.catchError("Error in CommentPinComponent getPopoverMode subscription: ",g)})),this.subscriptions.push(this.commentService.getDeviceIndicatorOnCommentPins$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{isDeviceIndicatorOnCommentPinsEnabled:g}),f))},g=>{this.catchError("Error in CommentPinComponent getDeviceIndicatorOnCommentPins subscription: ",g)})),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{unreadCommentsMap:g}),f))})),this.subscriptions.push(this.commentService.getCustomStatusesShown$().subscribe(g=>{this.componentConfigSignal.update(f=>(f=D(E({},f),{customStatusesShown:g}),f))}))}ngOnInit(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;"),super.ngOnInit(),this.setupA11yAttributes(),!this.template){let e="velt-comment-pin-wireframe";this.variant&&(e+=`---${this.variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r,this.getChildTemplate()}}))}this.getChildTemplate()}catch(e){this.catchError("Error in CommentsToolComponent OnInit: ",e)}}getChildTemplate(){try{if(!this.ghostCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-ghost-comment-indicator-wireframe");Ye(e)||(this.ghostCommentIndicatorTemplate=e)}if(!this.indexTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-index-wireframe");Ye(e)||(this.indexTemplate=e)}if(!this.numberTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-number-wireframe");Ye(e)||(this.numberTemplate=e)}if(!this.privateCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-private-comment-indicator-wireframe");Ye(e)||(this.privateCommentIndicatorTemplate=e)}if(!this.triangleTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-triangle-wireframe");Ye(e)||(this.triangleTemplate=e)}if(!this.unreadCommentIndicatorTemplate&&this.template){let e=this.template.querySelector("velt-comment-pin-unread-comment-indicator-wireframe");Ye(e)||(this.unreadCommentIndicatorTemplate=e)}}catch(e){this.loggingService.catch("Error in CommentPinComponent getChildTemplate: ",e)}}ngAfterViewInit(){try{this.subscriptions.push(this.commentPinPortalService.getCommentPinTemplate$().subscribe(e=>{if(e!==null){let t=e?.cloneNode(!0);if(t.setAttribute("slot","comment-pin"),this.pinRef!==void 0){this.pinRef.nativeElement.appendChild(t);let r=g_(this.componentConfigSignal().annotation);this.injectAttributeData(t,r),this.usingCustomCommentPin=!0,this.commentPinPortalService.emitCustomPinEvent({annotation:this.componentConfigSignal().annotation,element:t}),this.pinRef.nativeElement.childNodes.forEach(a=>{a?.tagName?.toLowerCase()===U.TAGS.SNIPPYLY_USER_AVATAR&&a.remove()})}}else this.usingCustomCommentPin=!1})),this.subscriptions.push(this.commentService.getBubbleCommentAnnotationIds$().subscribe(e=>{if(e.includes(this.componentConfigSignal().annotation?.annotationId)){this.commentBubbleElement=this.commentService.getCommentBubbleElement(this.componentConfigSignal().annotation);let t=this.commentBubbleElement?.getAttribute(U.ATTRIBUTES.VELT_ANNOTATION_ID)||"";this.componentConfigSignal().commentBubbleElementAnnotationId!==t&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{commentBubbleElementAnnotationId:t}),r)),this.commentBubbleAvailable=!0)}else this.commentBubbleAvailable&&(this.commentBubbleElement=null,this.componentConfigSignal.update(t=>(t=D(E({},t),{commentBubbleElementAnnotationId:""}),t)),this.commentBubbleAvailable=!1)},e=>{this.catchError("Error in CommentPinComponent getBubbleCommentAnnotationIds$ subscription: ",e)}))}catch(e){this.catchError("Error in CommentPinComponent AfterViewInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentPinComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{if(e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.annotation){if(this.commentService.customPinsById.has(this.componentConfigSignal().annotation.annotationId)){let r=this.commentService.getCustomPinById(this.componentConfigSignal().annotation.annotationId);if(r!==void 0){let a=g_(this.componentConfigSignal().annotation);this.injectAttributeData(r,a)}}this.setUserInitial(),this.componentConfigSignal.update(r=>(r=D(E({},r),{isPrivateComment:this.componentConfigSignal().annotation?.iam?.accessMode===uo.PRIVATE,isGhostComment:!!this.componentConfigSignal().annotation?.ghostComment}),r)),this.checkIfCommentAddedOnDifferentDeviceType();let t=JSON.parse(JSON.stringify(this.commentPinPosition||{}));this.commentPinPosition={top:this.componentConfigSignal().annotation?.position?.top||0,left:this.componentConfigSignal().annotation?.position?.left||0}}}catch(t){this.catchError("Error in CommentPinComponent ngOnChanges: ",t)}}detectCommentPinOutsideViewport(){try{this.loggingService.log("%c[WB] Calling FUNCTION: detectCommentPinOutsideViewport","color: green;");let e=this.pinRef?.nativeElement;if(e){let t=e?.getBoundingClientRect(),r=Math.max(document?.documentElement?.clientWidth||0,window?.innerWidth||0);if(t?.right>r){let a=r-t.left;a>0?(this.pinMaxWidth=`${a}px`,this.isOutsideViewport=!0):(this.isOutsideViewport=!1,this.pinMaxWidth="")}else this.isOutsideViewport=!1,this.pinMaxWidth=""}else this.isOutsideViewport=!1}catch(e){this.catchError("Error in CommentPinComponent detectCommentPinOutsideViewport: ",e)}}checkIfCommentAddedOnDifferentDeviceType(){try{this.componentConfigSignal().annotation?.pageInfo?.deviceInfo?.deviceType!==this.deviceInfo.deviceType?(this.componentConfigSignal.update(e=>(e=D(E({},e),{isCommentAddedOnDifferentDeviceType:!0}),e)),this.COMMENT_PIN_SIZE=34):(this.componentConfigSignal.update(e=>(e=D(E({},e),{isCommentAddedOnDifferentDeviceType:!1}),e)),this.COMMENT_PIN_SIZE=40)}catch(e){this.catchError("Error in CommentPinComponent checkIfCommentAddedOnDifferentDeviceType: ",e)}}updateOverlayPosition(){try{this.loggingService.log("updateOverlayPosition",this.componentConfigSignal().annotation?.annotationId),this.commentDialogPortalRef?.updateOverlayPosition()}catch(e){this.catchError("Error in CommentPinComponent updateOverlayPosition: ",e)}}onPointerUpOnDialog(){try{this.componentConfigSignal().commentPinSelected||this.togglePinSelection.emit()}catch(e){this.catchError("Error in CommentPinComponent onPointerUpOnDialog: ",e)}}onPinBubblePointerUp(e){try{(!this.componentConfigSignal().commentPinSelected||e)&&this.togglePinSelection.emit(e)}catch(t){this.catchError("Error in CommentPinComponent onPointerUpOnDialog: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(e){this.catchError("Error in CommentPinComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.catchError("Error in CommentPinComponent unsubscribe: ",e)}}setUserInitial(){try{this.userInitial=this.componentConfigSignal().annotation?.from?.initial||(this.componentConfigSignal().annotation?.from?.name?this.componentConfigSignal().annotation.from.name?.charAt(0).toUpperCase():this.componentConfigSignal().annotation?.from?.email?.charAt(0).toUpperCase()||"")}catch(e){this.catchError("Error in CommentPinComponent setUserInitial: ",e)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.annotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(Be),h(_),h(q1),h(Ge),h(R),h(S))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-pin"]],viewQuery:function(t,r){if(t&1&&(it(atn,5),it(stn,5)),t&2){let a;Je(a=et())&&(r.pinRef=a.first),Je(a=et())&&(r.commentDialogPortalRef=a.first)}},hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{annotation:"annotation",commentPinSelected:"commentPinSelected",annotationDragging:"annotationDragging",commentPinType:"commentPinType",multipleCommentPinsSelected:"multipleCommentPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",variant:"variant",containerComponentId:"containerComponentId",targetElement:"targetElement"},outputs:{saveComment:"saveComment",commentTargetElementClicked:"commentTargetElementClicked",togglePinSelection:"togglePinSelection"},standalone:!1,features:[V([S]),L,Ze],ngContentSelectors:ltn,decls:1,vars:1,consts:[["commentPinContainerRef",""],["commentDialogPortalRef",""],["trigger","cdkOverlayOrigin"],["normalPinRef",""],["defaultPinRef",""],["pinRef",""],["userAvatarRef",""],["readCommentIndicatorsRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],[3,"saveComment","togglePinSelection","pointerUp","annotation","user","commentPinSelected","annotationDragging","commentPinType","targetElement","bubbleOnPin","bubbleOnPinHover","containerComponentId"],["id","comment-pin-block","cdkOverlayOrigin","",1,"velt-comment-pin"],[3,"click"],[3,"componentConfigSignal","template"],[4,"veltDynamicTemplate"],[1,"velt-comment-pin--marker",3,"click","ngClass"],[3,"ngSwitch"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngSwitchCase"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M12.0357 1.5H5.96429C5.29365 1.5 4.75 2.17157 4.75 3V15C4.75 15.8284 5.29365 16.5 5.96429 16.5H12.0357C12.7063 16.5 13.25 15.8284 13.25 15V3C13.25 2.17157 12.7063 1.5 12.0357 1.5Z","stroke","white","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"],["d","M9 13.5H9.0075","stroke","white","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"],["fill-rule","evenodd","clip-rule","evenodd","d","M12.75 1.5H5.25C4.83579 1.5 4.5 1.83579 4.5 2.25V15.75C4.5 16.1642 4.83579 16.5 5.25 16.5H12.75C13.1642 16.5 13.5 16.1642 13.5 15.75V2.25C13.5 1.83579 13.1642 1.5 12.75 1.5ZM5.25 0C4.00736 0 3 1.00736 3 2.25V15.75C3 16.9926 4.00736 18 5.25 18H12.75C13.9926 18 15 16.9926 15 15.75V2.25C15 1.00736 13.9926 0 12.75 0H5.25Z","fill","white"],["d","M9.75 14.25C9.75 14.6642 9.41421 15 9 15C8.58579 15 8.25 14.6642 8.25 14.25C8.25 13.8358 8.58579 13.5 9 13.5C9.41421 13.5 9.75 13.8358 9.75 14.25Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.75 4.5L3.75 11.25L14.25 11.25L14.25 4.5C14.25 4.08579 13.9142 3.75 13.5 3.75L4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5ZM2.25 12.75L15.75 12.75L15.75 4.5C15.75 3.25736 14.7426 2.25 13.5 2.25L4.5 2.25C3.25736 2.25 2.25 3.25736 2.25 4.5L2.25 12.75Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M2.25 12.75L2.25 13.5C2.25 13.9142 2.58579 14.25 3 14.25L15 14.25C15.4142 14.25 15.75 13.9142 15.75 13.5L15.75 12.75L2.25 12.75ZM0.75 13.5C0.75 14.7426 1.75736 15.75 3 15.75L15 15.75C16.2426 15.75 17.25 14.7426 17.25 13.5L17.25 12C17.25 11.5858 16.9142 11.25 16.5 11.25L1.5 11.25C1.08579 11.25 0.75 11.5858 0.75 12L0.75 13.5Z","fill","white"],["d","M6.75 13.5H8.25V15H9.75V13.5H11.25V15H12C12.4142 15 12.75 15.3358 12.75 15.75C12.75 16.1642 12.4142 16.5 12 16.5H6C5.58579 16.5 5.25 16.1642 5.25 15.75C5.25 15.3358 5.58579 15 6 15H6.75V13.5Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3 4.5L3 10.5C3 11.3284 3.67157 12 4.5 12L13.5 12C14.3284 12 15 11.3284 15 10.5L15 4.5C15 3.67157 14.3284 3 13.5 3L4.5 3C3.67157 3 3 3.67157 3 4.5ZM1.5 10.5C1.5 12.1569 2.84315 13.5 4.5 13.5L13.5 13.5C15.1569 13.5 16.5 12.1569 16.5 10.5L16.5 4.5C16.5 2.84315 15.1569 1.5 13.5 1.5L4.5 1.5C2.84315 1.5 1.5 2.84315 1.5 4.5L1.5 10.5Z","fill","white"],[3,"user"]],template:function(t,r){t&1&&(Ht(),u(0,Otn,2,6,"ng-container",8)),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Xr,X,Dt,Xi,mo,sn,Jn,ie,L_,F_,V_,B_,Sn,Y1,se,G1],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);--velt-internal-comment-pin-bg-color: var(--velt-accent)}[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-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble{position:absolute;border-radius:100%;text-align:center;top:calc(var(--velt-spacing-sm) * -1);right:calc(var(--velt-spacing-sm) * -1);bottom:unset;left:unset;height:24px;width:24px;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--private-indicator{height:28px;width:28px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--ghost-indicator{height:28px;width:28px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--unread-indicator{background-color:var(--velt-error);color:var(--velt-error-foreground);height:16px;width:16px;top:calc(var(--velt-spacing-xs) * -1);right:calc(var(--velt-spacing-xs) * -1);left:unset;bottom:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--index-3-digit{border-radius:100%;height:30px;width:30px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);bottom:unset;left:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--indicator-bubble.velt-comment-pin--number-3-digit{border-radius:100%;height:30px;width:30px;top:calc(var(--velt-spacing-md) * -1);right:calc(var(--velt-spacing-md) * -1);bottom:unset;left:unset}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index{border:1px solid rgb(210,210,210);color:var(--velt-black);background:var(--velt-white)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index .comment-annotation-number{border-radius:100%;width:24px;height:24px;font-size:calc((.55rem + 0px) * var(--velt-base-rem-unit));display:inline-flex;justify-content:center;align-items:center;box-sizing:content-box;position:relative}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--index .comment-annotation-number:after{content:attr(data-comment-annotation-number);position:absolute;font-weight:400;letter-spacing:normal;word-spacing:normal}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number{border:1px solid rgb(210,210,210);color:var(--velt-black);background:var(--velt-white)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number .comment-annotation-number{border-radius:100%;width:24px;height:24px;font-size:calc((.55rem + 0px) * var(--velt-base-rem-unit));display:inline-flex;justify-content:center;align-items:center;box-sizing:content-box;position:relative}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--number .comment-annotation-number:after{content:attr(data-comment-annotation-number);position:absolute;font-weight:400;letter-spacing:normal;word-spacing:normal}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--private-indicator{color:var(--velt-white);background:linear-gradient(0deg,#000000bf 0% 100%),var(--velt-accent);border-radius:100%;border:1px solid rgba(255,255,255,.24);padding:var(--velt-spacing-sm)}.velt-comment-pin[_ngcontent-%COMP%] .velt-comment-pin--ghost-indicator{color:var(--velt-error-foreground);background:var(--velt-error);border-radius:100%;border:1px solid rgba(255,255,255,.24);padding:var(--velt-spacing-sm)}.velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--private-indicator[_ngcontent-%COMP%], .velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--ghost-indicator[_ngcontent-%COMP%]{padding:calc(var(--velt-spacing-md) / 2);width:24px;height:24px;top:calc(var(--velt-spacing-sm) * -1);right:calc(var(--velt-spacing-sm) * -1)}.velt-comment-pin--marker[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;position:relative;width:calc((2.5rem + 0px) * var(--velt-base-rem-unit));height:calc((2.5rem + 0px) * var(--velt-base-rem-unit));border:2px solid var(--velt-border-3);border-radius:100% 100% 100% 2px;box-shadow:0 8px 16px -8px #0f0f0f1a;z-index:1;cursor:pointer;background:var(--velt-internal-comment-pin-bg-color);box-sizing:border-box}.velt-comment-pin--marker.velt-comment-pin--status-default[_ngcontent-%COMP%]{background:var(--velt-accent, var(--velt-internal-comment-pin-bg-color))}.velt-comment-pin--marker.velt-comment-pin--status-ongoing[_ngcontent-%COMP%]{background:var(--velt-warning, var(--velt-internal-comment-pin-bg-color))}.velt-comment-pin--marker.velt-comment-pin--status-terminal[_ngcontent-%COMP%]{background:var(--velt-success, var(--velt-internal-comment-pin-bg-color))}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem;background-color:var(--velt-gray);background-size:cover;border-radius:100%;display:flex;align-items:center;justify-content:center;position:relative}.velt-comment-pin--popover[_ngcontent-%COMP%]{width:0;height:0;border-style:solid;border-width:0 10px 10px 0;border-color:transparent var(--velt-accent) transparent transparent}.velt-comment-pin.velt-comment-pin--different-device[_ngcontent-%COMP%], .velt-comment-pin.velt-comment-pin--different-device[_ngcontent-%COMP%] .velt-comment-pin--marker[_ngcontent-%COMP%]{width:calc((2.125rem + 0px) * var(--velt-base-rem-unit));height:calc((2.125rem + 0px) * var(--velt-base-rem-unit))}.velt-comment-pin.velt-comment-pin--ghost[_ngcontent-%COMP%] .velt-comment-pin--marker-default.velt-comment-pin--marker[_ngcontent-%COMP%]{background:var(--velt-gray)}.velt-comment-pin.velt-comment-pin--ghost[_ngcontent-%COMP%] .velt-comment-pin--popover[_ngcontent-%COMP%]{border-color:transparent var(--velt-gray) transparent transparent}.velt-comment-pin.velt-comment-pin--outside-viewport[_ngcontent-%COMP%]{max-width:var(--velt-internal-comment-pin-max-width);overflow:hidden} .velt-comment-dialog-overlay-panel{z-index:2147483567}.velt-comment-pin--marker-transparent[_ngcontent-%COMP%]{background:transparent;border:unset;border-radius:unset;box-shadow:unset}"],changeDetection:0});let i=o;return i})();function Atn(i,o){if(i&1){let n=K();v(0),y(1,"velt-multi-thread-comment-dialog-internal",6),W("afterViewInit",function(){N(n);let t=l().last,r=l(2);return F(t?r.calculatePosition():null)})("saveComment",function(t){N(n);let r=l().$implicit,a=l(2);return F(a.saveComment(r==null?null:r.annotation,t))}),b(),C()}if(i&2){let n=l().$implicit,e=l().ngIf,t=l();m(),d("multiThreadAnnotationId",n==null||n.annotation==null?null:n.annotation.annotationId)("annotation",n==null?null:n.annotation)("user",e.user)("commentPinSelected",!!e.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId]),x("data-testid",t.componentId+"-multi-thread-"+(n==null||n.annotation==null?null:n.annotation.annotationId))}}function Ptn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",7),W("afterViewInit",function(){N(n);let t=l().last,r=l(2);return F(t?r.calculatePosition():null)})("saveComment",function(t){N(n);let r=l().$implicit,a=l(2);return F(a.saveComment(r==null?null:r.annotation,t))}),b()}if(i&2){let n=l().$implicit,e=l().ngIf,t=l();d("annotation",n==null?null:n.annotation)("user",e.user)("commentPinSelected",!!e.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId])("inlineCommentMode",e.inlineCommentMode)("isInsidePdfViewer",n==null?null:n.isInsidePdfViewer),x("data-testid",t.componentId+"-single-thread-"+(n==null||n.annotation==null?null:n.annotation.annotationId))}}function Mtn(i,o){if(i&1){let n=K();v(0),y(1,"div",4),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.togglePinSelection(t==null?null:t.annotation))}),u(2,Atn,2,5,"ng-container",5)(3,Ptn,1,6,"ng-template",null,0,Te),b(),C()}if(i&2){let n=o.$implicit,e=me(4),t=l().ngIf,r=l();m(),at("top",n==null?null:n.top,"px"),pe("selected",t.selectedAnnotationsMap[n==null||n.annotation==null?null:n.annotation.annotationId]),d("id","snippyly-comments-on-right-block-"+(n==null||n.annotation==null?null:n.annotation.annotationId)),x("data-testid",r.componentId+"-block-"+(n==null||n.annotation==null?null:n.annotation.annotationId))("role","region")("tabindex",0),m(),d("ngIf",(n==null||n.annotation==null?null:n.annotation.type)==="multiThread")("ngIfElse",e)}}function ktn(i,o){if(i&1&&(v(0),y(1,"div",2),P(2,"translate"),u(3,Mtn,5,10,"ng-container",3),b(),C()),i&2){let n=o.ngIf,e=l();m(),x("data-testid",e.componentId)("role","complementary")("aria-label",M(2,5,"Comments panel")),m(2),d("ngForOf",n.commentPinAnnotationsArray)("ngForTrackBy",e.trackById)}}var z1e=(()=>{let o=class o{constructor(e,t,r,a,s){this.authService=e,this.commentService=t,this.domService=r,this.elementRef=a,this.loggingService=s,this.commentPinAnnotations=[],this.subscriptions=[],this.positionChangeDetectionSubscriptions=[],this.componentConfigSignal=xe({commentPinAnnotationsArray:[],selectedAnnotationsMap:{},user:void 0,inlineCommentMode:!1}),this.veltElement=!0,this.componentId="velt-comments-stream-view",this.subscriptions.push(this.authService.getUser$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{user:c}),p))},c=>{this.loggingService.catch("Error in CommentsStreamViewComponent getUser$ subscription: ",c)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{selectedAnnotationsMap:c}),p)),setTimeout(()=>{this.calculatePosition(),Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1&&this.goToAnnotation(this.componentConfigSignal().selectedAnnotationsMap[Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0]])},100)},c=>{this.loggingService.catch("Error in CommentsStreamViewComponent getSelectedAnnotationsMap$ subscription: ",c)})),this.subscriptions.push(this.commentService.getInlineCommentMode$().subscribe(c=>{this.componentConfigSignal.update(p=>(p=D(E({},p),{inlineCommentMode:c}),p))}))}ngOnInit(){this.setupA11yAttributes()}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent setupA11yAttributes:",e)}}ngAfterViewInit(){this.streamViewContainerId&&(this.scrollableParentElement=document.getElementById(this.streamViewContainerId)),this.scrollableParentElement||(this.scrollableParentElement=J0(this.elementRef.nativeElement)),this.scrollableParentElement||(this.scrollableParentElement=document.documentElement),this.calculateTargetElementPositions()}ngOnChanges(e){try{e.commentPinAnnotations&&this.calculateTargetElementPositions()}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent ngOnChanges: ",t)}}goToAnnotation(e){let t=null;e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):t=document.querySelector(`[data-velt-id='${e.annotationId}']`),t&&t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}togglePinSelection(e){try{this.componentConfigSignal().selectedAnnotationsMap[e.annotationId]||(this.goToAnnotation(e),this.domService.toggleAnnotationSelection(e))}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent togglePinSelection: ",t)}}saveComment(e,t){try{this.commentService.saveComment(e,t)}catch(r){this.loggingService.catch("Error in CommentsStreamViewComponent saveComment: ",r)}}calculateTargetElementPositions(){try{this.positionChangeDetectionSubscriptions.forEach(t=>{t.unsubscribe()});let e=[];if(this.commentPinAnnotations.forEach(t=>{let r={},a=null;t.targetElement||t.areaAnnotationId?a=document.getElementById(`comment-pin-container-${t.annotationId}`):a=document.querySelector(`[data-velt-id='${t.annotationId}']`),a&&(r.annotation=t,r.targetElement=a,r.targetOffsetTop=sz(a,this.scrollableParentElement)?.top||0,r.isInsidePdfViewer=iC(a,U.ATTRIBUTES.VELT_PDF_VIEWER),e.push(r))}),e.sort((t,r)=>t.targetElement.getBoundingClientRect().top-r.targetElement.getBoundingClientRect().top),this.componentConfigSignal.update(t=>(t=D(E({},t),{commentPinAnnotationsArray:e}),t)),this.componentConfigSignal().commentPinAnnotationsArray?.length){let t=this.componentConfigSignal().commentPinAnnotationsArray[this.componentConfigSignal().commentPinAnnotationsArray.length-1]?.targetElement;this.detectPositionChange(t)}this.calculatePosition()}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent calculateTargetElementPositions: ",e)}}trackById(e,t){return t.annotation.annotationId}calculatePosition(){try{if(Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1){let e=Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0],t=this.componentConfigSignal().commentPinAnnotationsArray.findIndex(s=>s.annotation.annotationId===e),r=this.componentConfigSignal().commentPinAnnotationsArray.slice(0,t+1).reverse(),a=this.componentConfigSignal().commentPinAnnotationsArray.slice(t);this.calculateDialogPosition(r,!0),this.calculateDialogPosition(a),r.shift(),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotationsArray:[...r.reverse().slice(),...a.slice()]}),s))}else this.calculateDialogPosition(this.componentConfigSignal().commentPinAnnotationsArray)}catch(e){this.loggingService.catch("Error in CommentsStreamViewComponent calculatePosition: ",e)}}calculateDialogPosition(e,t=!1){try{e.forEach((r,a,s)=>{if(!r.dialogElement){let c=this.elementRef?.nativeElement?.querySelector(`[id="snippyly-comments-on-right-block-${r.annotation.annotationId}"]`);c&&(r.dialogElement=c,r.dialogOffsetTop=sz(c,this.scrollableParentElement)?.top||0)}if(!a)r.top=r.targetOffsetTop;else if(t){let c=s[a-1];if(r.dialogElement){let p=c.top-r.dialogElement?.getBoundingClientRect()?.height-24,g=r.targetOffsetTop;p<r.top?r.top=p:g&&(g<=p?r.top=g:r.top=p)}}else{let c=s[a-1];if(c.dialogElement){let p=c.top+c.dialogElement?.getBoundingClientRect()?.height+24,g=r.targetOffsetTop;p>r.dialogOffsetTop&&p>g?r.top=p:g&&(g>=p?r.top=g:r.top=p)}}})}catch(r){this.loggingService.catch("Error in CommentsStreamViewComponent calculateDialogPosition: ",r)}}detectPositionChange(e){try{let t=zm(0,$m).pipe(de(()=>{let r=e.getBoundingClientRect();return{top:r.top,left:r.left}}),Ct((r,a)=>r.top===a.top&&r.left===a.left),Oi());this.positionChangeDetectionSubscriptions.push(t.subscribe(()=>{this.calculateTargetElementPositions()},r=>{}))}catch(t){this.loggingService.catch("Error in CommentsStreamViewComponent detectPositionChange: ",t)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()})}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(we),h(Be),h(R),h(_))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comments-stream-view"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{commentPinAnnotations:"commentPinAnnotations",streamViewContainerId:"streamViewContainerId"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["commentDialogRef",""],[4,"ngIf"],["velt-ignore-change-detection","true",1,"snippyly-comments-on-right-container"],[4,"ngFor","ngForOf","ngForTrackBy"],["velt-ignore-change-detection","true",1,"snippyly-comments-on-right-block",3,"click","id"],[4,"ngIf","ngIfElse"],[3,"afterViewInit","saveComment","multiThreadAnnotationId","annotation","user","commentPinSelected"],[3,"afterViewInit","saveComment","annotation","user","commentPinSelected","inlineCommentMode","isInsidePdfViewer"]],template:function(t,r){t&1&&u(0,ktn,4,7,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,ar,Rs,ge],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}.snippyly-comments-on-right-container[_ngcontent-%COMP%]{position:absolute;top:0;right:10vw;width:300px;background:#90ee90}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block[_ngcontent-%COMP%]{position:absolute;box-shadow:none;transition:top .5s ease,left .5s ease,box-shadow .5s ease;left:0}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block.selected[_ngcontent-%COMP%]{left:-36px;z-index:1}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block .comment-dialog-container{transition:box-shadow .5s ease;box-shadow:none!important}.snippyly-comments-on-right-container[_ngcontent-%COMP%] .snippyly-comments-on-right-block.selected .comment-dialog-container{box-shadow:0 calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((3rem + 0px) * var(--velt-base-rem-unit)) #0000002d!important}"],changeDetection:0});let i=o;return i})();var Ntn=()=>["snippyly-inbox-panel","velt-overlay-panel"];function Ftn(i,o){i&1&&He(0)}function Ltn(i,o){if(i&1&&u(0,Ftn,1,0,"ng-container",7),i&2){l();let n=me(6);d("ngTemplateOutlet",n)}}function Btn(i,o){if(i&1){let n=K();y(0,"velt-multi-thread-comment-dialog-internal",11),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment(t))}),b()}if(i&2){let n=l(3).ngIf,e=l();d("multiThreadAnnotationId",n.commentAnnotation==null?null:n.commentAnnotation.annotationId)("annotation",n.commentAnnotation)("user",n.user)("commentPinSelected",!0)("inboxMode",!0),x("data-testid",e.componentId+"-multi-thread-dialog")("role","dialog")("aria-label",M(1,8,"Multi-thread comment dialog"))}}function Vtn(i,o){if(i&1&&(v(0),u(1,Btn,2,10,"velt-multi-thread-comment-dialog-internal",10),C()),i&2){let n=l(2).ngIf;m(),d("ngIf",n.commentAnnotation&&n.user)}}function Utn(i,o){if(i&1){let n=K();y(0,"snippyly-comment-dialog",13),P(1,"translate"),W("saveComment",function(t){N(n);let r=l(4);return F(r.saveComment(t))}),b()}if(i&2){let n=l(3).ngIf,e=l();d("annotation",n.commentAnnotation)("user",n.user)("commentPinSelected",!0)("inboxMode",!0),x("data-testid",e.componentId+"-single-dialog")("role","dialog")("aria-label",M(1,7,"Single comment dialog"))}}function jtn(i,o){if(i&1&&u(0,Utn,2,9,"snippyly-comment-dialog",12),i&2){let n=l(2).ngIf;d("ngIf",n.commentAnnotation&&n.user)}}function $tn(i,o){if(i&1&&(y(0,"div",8),P(1,"translate"),u(2,Vtn,2,1,"ng-container",9)(3,jtn,1,1,"ng-template",null,3,Te),b()),i&2){let n=me(4),e=l().ngIf,t=l();pe("mobile",e.isPhone)("visible",!!e.commentAnnotation),x("data-testid",t.componentId)("role","region")("aria-label",M(1,10,"Comment inbox container"))("aria-expanded",!!e.commentAnnotation),m(2),d("ngIf",(e==null||e.commentAnnotation==null?null:e.commentAnnotation.type)==="multiThread")("ngIfElse",n)}}function Htn(i,o){if(i&1&&(v(0),w(1,"div",5,0),u(3,Ltn,1,1,"ng-template",6,1,Te)(5,$tn,5,12,"ng-template",null,2,Te),C()),i&2){let n=me(2),e=l();m(),x("data-testid",e.componentId+"-trigger")("aria-hidden",!0),m(2),d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",ut(6,Ntn))}}var G1e=(()=>{let o=class o extends tt{constructor(e,t,r,a,s,c){super(s,c),this.authService=e,this.breakpointObserver=t,this.commentService=r,this.loggingService=a,this.elementRef=s,this.themeService=c,this.componentConfigSignal=xe({isPhone:!1,sidebarVisible:!1}),this.subscriptions=[],this.componentId="velt-comment-inbox";try{this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(p=>{p.matches?this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!0}),g)):this.componentConfigSignal.update(g=>(g=D(E({},g),{isPhone:!1}),g))},p=>{this.catchError("Error in CommentInboxComponent breakpointObserver subscription: ",p)}))}catch{}}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t))},e=>{this.catchError("Error in CommentInboxComponent getUser$ subscription: ",e)}))}catch(e){this.catchError("Error in CommentInboxComponent ngOnInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentInboxComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e.commentAnnotation&&this.componentConfigSignal.update(t=>(t=D(E({},t),{commentAnnotation:e.commentAnnotation.currentValue}),t))}catch(t){this.catchError("Error in CommentInboxComponent ngOnChanges: ",t)}}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),super.ngOnDestroy()}saveComment(e){try{(this.commentAnnotation||e.annotation)&&this.commentService.saveComment(this.commentAnnotation||e.annotation,e)}catch(t){this.catchError("Error in CommentInboxComponent saveComment: ",t)}}catchError(e,t,r){try{this.loggingService.catch(e,t,D(E({},r||{}),{annotationId:this.componentConfigSignal()?.commentAnnotation?.annotationId}))}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(wo),h(we),h(_),h(R),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["snippyly-comment-inbox"]],inputs:{commentAnnotation:"commentAnnotation"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[["sidebarTrigger","cdkOverlayOrigin"],["sidebarOverlay","cdkConnectedOverlay"],["sidebarRef",""],["commentDialogRef",""],[4,"ngIf"],["cdkOverlayOrigin",""],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass"],[4,"ngTemplateOutlet"],["id","sCommentInboxContainer","data-velt-comment-disabled","true",1,"velt-comment-inbox--container","s-inbox-container"],[4,"ngIf","ngIfElse"],[3,"multiThreadAnnotationId","annotation","user","commentPinSelected","inboxMode","saveComment",4,"ngIf"],[3,"saveComment","multiThreadAnnotationId","annotation","user","commentPinSelected","inboxMode"],[3,"annotation","user","commentPinSelected","inboxMode","saveComment",4,"ngIf"],[3,"saveComment","annotation","user","commentPinSelected","inboxMode"]],template:function(t,r){t&1&&u(0,Htn,7,7,"ng-container",4),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,ar,Rs,ge],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)}*[_ngcontent-%COMP%]{box-sizing:border-box} .snippyly-inbox-panel{top:0!important;left:0!important}.s-overflow-hidden[_ngcontent-%COMP%]{overflow:hidden!important} .velt-comment-inbox--container{height:100vh;width:calc((26rem + 0px) * var(--velt-base-rem-unit));position:fixed;top:0;right:-100%;padding:var(--velt-spacing-lg);box-sizing:border-box;z-index:999999997;transition:width .5s ease-in-out,right .5s ease-in-out} .velt-comment-inbox--container.mobile{width:100%;height:100%;box-sizing:border-box;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)} .velt-comment-inbox--container.visible{right:0}"],changeDetection:0});let i=o;return i})();function Gtn(i,o){if(i&1){let n=K();v(0),y(1,"div",3),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.scrollToAnnotation(t==null?null:t.key))}),y(2,"div",4),te(3),P(4,"translate"),b()(),C()}if(i&2){let n=o.$implicit,e=l().ngIf,t=l();m(),at("top",n.value.top,"%")("transform","translate(0, -"+n.value.top+"%)"),pe("v-unread-comment",!(e.user!=null&&e.user.isGuest)&&!(e.user!=null&&e.user.isAnonymous)&&(e.unreadCommentsMap==null?null:e.unreadCommentsMap[n==null||n.value==null||n.value.annotation==null?null:n.value.annotation.annotationId])),x("data-testid",t.componentId+"-pin-"+n.key)("role","button")("tabindex",0),m(),x("role","tooltip")("aria-hidden","true"),m(),Se(" ",M(4,12,"Go to comments here.")," ")}}function Wtn(i,o){if(i&1&&(v(0),y(1,"div",1),P(2,"translate"),u(3,Gtn,5,14,"ng-container",2),P(4,"keyvalue"),b(),C()),i&2){let n=o.ngIf,e=l();m(),pe("velt-comments-minimap-container--target-scrollable-element",!!n.targetScrollableElementId)("velt-comments-minimap-position--left",n.position==="left"),x("data-testid",e.componentId)("role","navigation")("aria-label",M(2,9,"Comments minimap")),m(2),d("ngForOf",M(4,11,n.commentAnnotationPositionMap))("ngForTrackBy",e.trackByAnnotationId)}}var t8=(()=>{let o=class o{constructor(e,t,r){this.commentService=e,this.loggingService=t,this.elementRef=r,this.commentAnnotations=[],this.targetScrollableElementId=null,this.position="right",this.commentCountsByPosition={},this.minimapHeatmapGradient="",this.componentConfigSignal=xe({targetScrollableElementId:null,position:"right",commentAnnotationPositionMap:{},user:null,unreadCommentsMap:null}),this.subscriptions=[],this.componentId="velt-comments-minimap",this.loggingService.log("%c[WB] Creating CLASS: CommentsMinimapComponent","color: blue;")}ngOnInit(){try{this.setupA11yAttributes(),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{unreadCommentsMap:e}),t))}))}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent ngOnInit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e?.commentAnnotations&&setTimeout(()=>{this.setCommentAnnotationPositionMap()},200)}catch(t){this.loggingService.catch("Error in CommentsMinimapComponent ngOnChanges: ",t)}}trackByAnnotationId(e,t){return t?.annotation?.annotationId||e}setCommentAnnotationPositionMap(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{commentAnnotationPositionMap:{}}),e)),this.commentAnnotations.forEach(e=>{let t=null;if(e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):t=document.querySelector(`[data-velt-id='${e.annotationId}']`),t){let r=this.getElementPosition(t)?.percentageOfTotalHeight;r!=null&&this.componentConfigSignal.update(a=>(a=D(E({},a),{commentAnnotationPositionMap:D(E({},a.commentAnnotationPositionMap),{[e.annotationId]:{annotation:e,top:r,element:t}})}),a))}})}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent setCommentAnnotationPositionByCommentAnnotationIndex: ",e)}}scrollToAnnotation(e){try{let t=this.componentConfigSignal().commentAnnotationPositionMap[e];t&&t.element&&t.element.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}catch(t){this.loggingService.catch("Error in CommentsMinimapComponent scrollToAnnotation: ",t)}}getElementPosition(e){try{let t=0,r=e,a=this.componentConfigSignal().targetScrollableElementId&&document.getElementById(this.componentConfigSignal().targetScrollableElementId);for(;r&&(t+=r.offsetTop||0,r=r.offsetParent,!(a&&r===a)););let s=0;if(a)s=a.scrollHeight;else{let p=document.body,g=document.documentElement;s=Math.max(p.scrollHeight,p.offsetHeight,g.clientHeight,g.scrollHeight,g.offsetHeight)}let c=t/s*100;return{pixelsFromTop:t,percentageOfTotalHeight:c}}catch(t){return this.loggingService.catch("Error in CommentsMinimapComponent getElementPosition: ",t),null}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()})}catch(e){this.loggingService.catch("Error in CommentsMinimapComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(we),h(_),h(R))},o.\u0275cmp=O({type:o,selectors:[["app-comments-minimap"]],inputs:{commentAnnotations:"commentAnnotations",user:"user",targetScrollableElementId:"targetScrollableElementId",position:"position"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[[4,"ngIf"],[1,"v-comments-minimap-container"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"v-comment-minimap-pin",3,"click"],[1,"v-comment-count"]],template:function(t,r){t&1&&u(0,Wtn,5,13,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,Wd,ge],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)}.v-comments-minimap-container[_ngcontent-%COMP%]{display:block;position:fixed;height:100vh;top:0;right:0;background:#00000014;z-index:var(--velt-comments-minimap-z-index)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]{position:absolute;right:0;width:12px;height:4px;flex-shrink:0;border-radius:var(--velt-border-radius-2xs);border:1px solid rgba(255,255,255,.16);background:color-mix(in srgb,var(--velt-accent) 80%,transparent);cursor:pointer}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{position:absolute;top:50%;right:20px;z-index:1000;min-width:max-content;background:color-mix(in srgb,var(--velt-accent) 80%,transparent);font-size:var(--velt-font-size-xs);padding:var(--velt-spacing-xs) var(--velt-spacing-sm);border-radius:var(--velt-border-radius-xs);transform:translateY(-50%);color:var(--velt-accent-foreground);display:none}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{content:"";position:absolute;border-style:solid;border-width:4px 0 4px 4px;border-color:transparent color-mix(in srgb,var(--velt-accent) 80%,transparent);display:block;width:0;z-index:1;right:calc(var(--velt-spacing-xs) * -1);top:50%;transform:translateY(-50%)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]:hover .v-comment-count[_ngcontent-%COMP%]{display:block}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%]{background-color:color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container[_ngcontent-%COMP%] .v-comment-minimap-pin.v-unread-comment[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{border-color:transparent color-mix(in srgb,var(--velt-error) 80%,transparent)}.v-comments-minimap-container.velt-comments-minimap-container--target-scrollable-element[_ngcontent-%COMP%]{position:absolute;height:100%}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%], .v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%]{right:auto;left:0}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]{right:auto;left:20px}.v-comments-minimap-container.velt-comments-minimap-position--left[_ngcontent-%COMP%] .v-comment-minimap-pin[_ngcontent-%COMP%] .v-comment-count[_ngcontent-%COMP%]:after{right:auto;left:calc(var(--velt-spacing-xs) * -1);border-width:4px 4px 4px 0}'],changeDetection:0});let i=o;return i})();function qtn(i,o){i&1&&He(0)}function Ytn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,qtn,1,0,"ng-container",6),b()),i&2){l();let n=me(3);m(),d("ngTemplateOutlet",n)}}function Ktn(i,o){if(i&1&&(w(0,"snippyly-comments-stream-view",10),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("commentPinAnnotations",n.commentPinAnnotationsForStreamView)("streamViewContainerId",e.streamViewContainerId),x("data-testid",e.componentId+"-stream")("role","complementary")("aria-label",M(1,5,"Comments stream view"))}}function Ztn(i,o){if(i&1&&(w(0,"snippyly-comment-inbox",11),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("darkMode",n.darkMode)("commentAnnotation",n.selectedCommentAnnotation),x("data-testid",e.componentId+"-inbox")("role","complementary")("aria-label",M(1,5,"Comments inbox"))}}function Xtn(i,o){if(i&1&&(w(0,"app-comments-minimap",12),P(1,"translate")),i&2){let n=l(3).ngIf,e=l();d("commentAnnotations",n.commentPinAnnotations)("user",n.user)("position",n.minimapPosition),x("data-testid",e.componentId+"-minimap")("role","complementary")("aria-label",M(1,6,"Comments location overview"))}}function Qtn(i,o){if(i&1&&(w(0,"snippyly-comment-adder"),u(1,Ktn,2,7,"snippyly-comments-stream-view",7)(2,Ztn,2,7,"snippyly-comment-inbox",8)(3,Xtn,2,8,"app-comments-minimap",9)),i&2){let n=l(2).ngIf,e=l();x("data-testid",e.componentId+"-adder"),m(),d("ngIf",n.streamMode&&n.commentsOnDom),m(),d("ngIf",n.inboxMode&&n.commentsOnDom),m(),d("ngIf",n.minimapEnabled&&n.commentsOnDom)}}function Jtn(i,o){if(i&1&&(v(0),u(1,Ytn,2,1,"velt-shadow-dom-internal",5)(2,Qtn,4,4,"ng-template",null,0,Te),C()),i&2){let n=me(3),e=l().ngIf;m(),d("ngIf",e.shadowDOM)("ngIfElse",n)}}function enn(i,o){if(i&1){let n=K();v(0),u(1,Jtn,4,2,"ng-container",1),y(2,"div",2)(3,"slot",3),W("slotchange",function(t){N(n);let r=l();return F(r.handleCommentPinSlotChanged(t))}),b()(),w(4,"app-persistent-comment-mode",4),C()}if(i&2){let n=o.ngIf,e=l();m(),d("ngIf",n.isFirstComponent),m(),x("aria-hidden","true")("data-testid",e.componentId+"-slot-container"),m(2),d("componentConfigSignal",e.componentConfigSignal),x("data-testid",e.componentId+"-persistent-mode")}}var wq=(()=>{let o=class o{set textMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextComments():this.commentService.disableTextComments()}set popoverMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePopoverMode():this.commentService.disablePopoverMode()}set popoverTriangleComponent(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePopoverTriangleComponent():this.commentService.disablePopoverTriangleComponent()}set forceCloseAllOnEsc(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableForceCloseAllOnEsc():this.commentService.disableForceCloseAllOnEsc()}set collapsedComments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCollapsedComments():this.commentService.disableCollapsedComments()}set shortUserName(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShortUserName():this.commentService.disableShortUserName()}catch{}}set readOnly(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReadOnly():this.commentService.disableReadOnly()}catch{}}set deleteThreadWithFirstComment(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteThreadWithFirstComment():this.commentService.disableDeleteThreadWithFirstComment()}catch{}}set resolveStatusAccessAdminOnly(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableResolveStatusAccessAdminOnly():this.commentService.disableResolveStatusAccessAdminOnly()}set svgAsImg(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSvgAsImg():this.commentService.disableSvgAsImg()}catch{}}set commentToNearestAllowedElement(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentToNearestAllowedElement():this.commentService.disableCommentToNearestAllowedElement()}catch{}}set floatingCommentDialog(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.disableFloatingComments(!t)}set moderatorMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setModeratorMode(t)}set _streamMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setStreamMode(t)}set atHereLabel(e){e&&this.contactService.setAtHereLabel(e)}set _atHereEnabled(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.contactService.enableAtHere():this.contactService.disableAtHere()}set _deleteReplyConfirmation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteReplyConfirmation():this.commentService.disableDeleteReplyConfirmation()}set _expandMentionGroups(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableExpandMentionGroups():this.commentService.disableExpandMentionGroups()}set _showMentionGroupsFirst(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShowMentionGroupsFirst():this.commentService.disableShowMentionGroupsFirst()}set _linkCallback(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableLinkCallback():this.commentService.disableLinkCallback()}set _showMentionGroupsOnly(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableShowMentionGroupsOnly():this.commentService.disableShowMentionGroupsOnly()}set _fullExpanded(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFullExpanded():this.commentService.disableFullExpanded()}catch{}}set _draftMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDraftMode():this.commentService.disableDraftMode()}catch{}}set atHereDescription(e){e&&this.contactService.setAtHereDescription(e)}set _persistentCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePersistentCommentMode():this.commentService.disablePersistentCommentMode()}set _seenByUsers(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSeenByUsers():this.commentService.disableSeenByUsers()}set signInButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableSignInButton(t)}set upgradeButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableUpgradeButton(t)}set attachments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.enableAttachment(t)}set recordings(e){let t=e;typeof e=="string"&&(t=e?.split(",")?.map(r=>r.trim()),this.commentService.setAllowedRecordings(t))}set reactions(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReactions():this.commentService.disableReactions()}set deviceInfo(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.showScreenSizeInfo(t)}set commentIndex(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.showCommentIndex(t)}set dialogOnHover(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableDialogOnHover(t)}set dialogOnTargetElementClick(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableDialogOnTargetElementClick(t)}set priority(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnablePriority(t)}set status(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableStatus(t)}set resolveButton(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableResolve(t)}set _inboxMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableInboxMode():this.commentService.disableInboxMode()}set _suggestionMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setSuggestionMode(t)}set _mobileMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setMobileMode(t)}set _inlineCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableInlineCommentMode():this.commentService.disableInlineCommentMode()}set _privateCommentMode(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePrivateCommentMode():this.commentService.disablePrivateCommentMode()}set _minimap(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMinimap():this.commentService.disableMinimap()}set _minimapPosition(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimapPosition:e}),t)),this.commentService.setAnalyticsFeatureConfig({config:{minimapPosition:e}})}catch{}}set _ghostComments(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGhostComments():this.commentService.disableGhostComments()}set _ghostCommentsIndicator(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGhostCommentsMessage():this.commentService.disableGhostCommentsMessage()}set _commentsOnDom(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.showCommentsOnDom():this.commentService.hideCommentsOnDom()}set _resolvedCommentsOnDom(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.showResolvedCommentsOnDom():this.commentService.hideResolvedCommentsOnDom()}set _filterCommentsOnDom(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFilterCommentsOnDom():this.commentService.disableFilterCommentsOnDom()}catch{}}set _bubbleOnPin(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableBubbleOnPin():this.commentService.disableBubbleOnPin()}catch{}}set _bubbleOnPinHover(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableBubbleOnPinHover():this.commentService.disableBubbleOnPinHover()}catch{}}set _multiThreadMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMultiThread():this.commentService.disableMultiThread()}catch{}}set _multiThread(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableMultiThread():this.commentService.disableMultiThread()}catch{}}set _maxReplyAvatars(e){try{let t=e;typeof e=="string"&&(t=parseInt(e)),this.commentService.setMaxReplyAvatars(t)}catch{}}set _replyAvatars(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableReplyAvatars():this.commentService.disableReplyAvatars()}catch{}}set _groupMultipleMatch(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGroupMatchedComments():this.commentService.disableGroupMatchedComments()}catch{}}set _groupMatchedComments(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableGroupMatchedComments():this.commentService.disableGroupMatchedComments()}catch{}}set _commentTool(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentTool():this.commentService.disableCommentTool()}set _sidebarButtonOnCommentDialog(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarButtonOnCommentDialog():this.commentService.disableSidebarButtonOnCommentDialog()}set _deviceIndicatorOnCommentPins(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeviceIndicatorOnCommentPins():this.commentService.disableDeviceIndicatorOnCommentPins()}catch{}}set _scrollToComment(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableScrollToComment():this.commentService.disableScrollToComment()}set _userMentions(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableUserMentions():this.commentService.disableUserMentions()}set _paginatedContactList(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePaginatedContactList():this.commentService.disablePaginatedContactList()}set _deleteOnBackspace(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDeleteOnBackspace():this.commentService.disableDeleteOnBackspace()}catch{}}set _hotkey(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableHotkey():this.commentService.disableHotkey()}catch{}}set _recordingSummary(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableRecordingSummary():this.commentService.disableRecordingSummary()}catch{}}set _recordingTranscription(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.recorderAnnotationService.enableRecordingTranscription():this.recorderAnnotationService.disableRecordingTranscription()}catch{}}set _allowedFileTypes(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedFileTypes(t)}catch{}}set _recordingCountdown(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableRecordingCountdown():this.commentService.disableRecordingCountdown()}catch{}}set _unreadIndicatorMode(e){try{this.commentService.setUnreadIndicatorMode(e)}catch{}}set _enterKeyToSubmit(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableEnterKeyToSubmit():this.commentService.disableEnterKeyToSubmit()}catch{}}set _pinShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePinShadowDOM():this.commentService.disablePinShadowDOM()}catch{}}set _dialogShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableDialogShadowDOM():this.commentService.disableDialogShadowDOM()}catch{}}set _persistentCommentShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{persistentCommentShadowDOM:!!t}),r)),this.commentService.setAnalyticsFeatureConfig({config:{persistentCommentShadowDOM:!!t}})}catch{}}set _shadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{shadowDOM:!!t,persistentCommentShadowDOM:!!t}),r)),this.componentConfigSignal().shadowDOM?(this.commentService.enableDialogShadowDOM(),this.commentService.enablePinShadowDOM(),this.commentService.enableTextCommentToolShadowDOM(),this.commentService.enableTextCommentToolbarShadowDOM()):(this.commentService.disableDialogShadowDOM(),this.commentService.disablePinShadowDOM(),this.commentService.disableTextCommentToolShadowDOM(),this.commentService.disableTextCommentToolbarShadowDOM()),this.commentService.setAnalyticsFeatureConfig({config:{shadowDom:!!t}})}catch{}}set _textCommentToolShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolShadowDOM():this.commentService.disableTextCommentToolShadowDOM()}catch{}}set _pinDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enablePinDarkMode():this.commentService.disablePinDarkMode()}catch{}}set _textCommentToolDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolDarkMode():this.commentService.disableTextCommentToolDarkMode()}catch{}}set _textCommentToolbarDarkMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolbarDarkMode():this.commentService.disableTextCommentToolbarDarkMode()}catch{}}set _textCommentToolbarShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableTextCommentToolbarShadowDOM():this.commentService.disableTextCommentToolbarShadowDOM()}catch{}}set _changeDetectionInCommentMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableChangeDetectionInCommentMode():this.commentService.disableChangeDetectionInCommentMode()}catch{}}set _areaComment(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableAreaComment():this.commentService.disableAreaComment()}catch{}}set _screenshot(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableScreenshot():this.commentService.disableScreenshot()}catch{}}set _pinCursorImage(e){try{this.commentService.setPinCursorImage(e||"")}catch{}}set allowedElementIds(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementIds(t)}catch{}}set allowedElementClassNames(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementClassNames(t)}catch{}}set allowedElementQuerySelectors(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setAllowedElementQuerySelectors(t)}catch{}}set _commentPinHighlighter(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCommentPinHighlighter():this.commentService.disableCommentPinHighlighter()}catch{}}set _customReactions(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setCustomReactions(t)}catch{}}set customStatus(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setCustomStatuses(t)}set customListDataOnAnnotation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.createCustomListDataOnAnnotation(t)}set customListDataOnComment(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.autocompleteService.create(t)}set attachmentNameInMessage(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableAttachmentNameInMessage():this.commentService.disableAttachmentNameInMessage()}set customPriority(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.customFilterService.setCustomPriorityFilters(t)}set _customAutocompleteSearch(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableCustomAutocompleteSearch():this.commentService.disableCustomAutocompleteSearch()}catch{}}set customCategory(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.customFilterService.setCustomCategories(t)}set composerMode(e){this.commentService.setComposerMode(e)}set autoCategorize(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.commentService.setEnableAutoCategorize(!!t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set commentplaceholder(e){try{let t=e;this.commentService.setCommentplaceholder(t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set replyplaceholder(e){try{let t=e;this.commentService.setReplyplaceholder(t)}catch(t){this.loggingService.catch("Error in CommentsContainerComponent set autoCategorize: ",t)}}set isDarkMode(e){this._darkAttribute=e,this.checkDarkMode(),this.commentService.setCommentContainerDarkMode(e===""||e==="true")}constructor(e,t,r,a,s,c,p,g,f,I,T,B,z){this.analyticsService=e,this.authService=t,this.domService=r,this.commentService=a,this.commentPinPortalService=s,this.commentTextPortalService=c,this.customFilterService=p,this.loggingService=g,this.elementRef=f,this.autocompleteService=I,this.contactService=T,this.recorderAnnotationService=B,this.docService=z,this.onCommentAdd=new Me,this.onSignIn=new Me,this.onUpgrade=new Me,this.onCustomPinInject=new Me,this.onCommentUpdate=new Me,this.onCommentAccept=new Me,this.onCommentReject=new Me,this.onSidebarButtonOnCommentDialogClick=new Me,this.onCommentSelectionChange=new Me,this.onCopyLink=new Me,this.subscriptions=[],this.selectedAnnotationsMap={},this.commentAnnotationFocused=!1,this.enableGhostComments=!1,this.resolvedCommentsOnDom=!1,this.scrollToComment=!1,this.componentConfigSignal=xe({addCommentMode:!1,commentPinAnnotations:[],multiThreadCommentPinAnnotations:[],commentPinAnnotationsForStreamView:[],commentsOnDom:!1,inboxMode:!1,isFirstComponent:!0,minimapEnabled:!1,minimapPosition:"right",persistentCommentMode:!1,persistentModeBanner:!1,privateCommentModeEnabled:!1,selectedCommentAnnotation:void 0,shadowDOM:!0,streamMode:!1,user:null,darkMode:!1,disableCommentMode:this.disableCommentMode.bind(this),persistentCommentShadowDOM:!0}),this.veltId=vt(),this.veltElement=!0,this.componentId="velt-comments-container";try{this.loggingService.log("%c[WB] Creating CLASS: CommentsContainerComponent","color: blue;"),this._darkAttribute=this.elementRef.nativeElement.getAttribute("dark");let G=new URL(window.location.href);this.focusCommentAnnotationId=G.searchParams.get(U.URL_PARAMS.COMMENT_ID),this.commentService.setCommentAddedEmitter(this.onCommentAdd)}catch(G){this.loggingService.catch("Error in CommentsContainerComponent constructor: ",G)}}ngOnInit(){try{this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;"),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent ngOnInit:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsContainerComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in SubtitlesComponent ngOnChanges: ",t)}}ngAfterViewInit(){try{let e=document.querySelector(U.TAGS.SNIPPYLY_COMMENTS),t=document.querySelector(U.TAGS.VELT_COMMENTS);document.querySelector(`${U.TAGS.VELT_COMMENTS}[${U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT}]`)||(t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(a=>(a=D(E({},a),{isFirstComponent:!0}),a)),t?.setAttribute(U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT,"true"),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(a=>(a=D(E({},a),{isFirstComponent:!0}),a)),e?.setAttribute(U.ATTRIBUTES.VELT_IS_FIRST_COMPONENT,"true"),this.initComponent()))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.commentService.addAreaContainerTag(),this.subscriptions.push(this.authService.getUser$().pipe(Le(e=>!!e)).subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),e&&this.setCommentInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.subscriptions.push(this.commentService.getStreamMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{streamMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getStreamMode$ subscription: ",e)})),this.subscriptions.push(this.docService.getDocumentPaths$().subscribe(()=>{this.getAllCommentsOnCurrentDocument()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getDocumentPaths$ subscription: ",e)})),this.subscriptions.push(this.commentService.getInboxMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{inboxMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getInboxMode$ subscription: ",e)})),this.subscriptions.push(this.commentService.getMinimap$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimapEnabled:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getMinimap$ subscription: ",e)})),this.subscriptions.push(this.commentService.addCommentModeChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{addCommentMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent addCommentModeChange subscription: ",e)})),this.subscriptions.push(this.commentService.persistentCommentModeChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{persistentCommentMode:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent persistentCommentModeChange subscription: ",e)})),this.subscriptions.push(this.commentService.persistentModeBannerChange().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{persistentModeBanner:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent persistentModeBannerChange subscription: ",e)})),this.subscriptions.push(this.commentService.getPrivateCommentMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{privateCommentModeEnabled:e}),t))},e=>{this.loggingService.catch("Error in CommentsContainerComponent getPrivateCommentMode$ subscription: ",e)})),this.subscriptions.push(this.commentService.getScrollToComment$().subscribe(e=>{this.scrollToComment=e},e=>{this.loggingService.catch("Error in CommentsContainerComponent getScrollToComment$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSignInButtonClick$().subscribe(()=>{this.onSignIn.emit()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSignInButtonClick$ subscription: ",e)})),this.subscriptions.push(this.commentService.getUpgradeButtonClick$().subscribe(()=>{this.onUpgrade.emit()},e=>{this.loggingService.catch("Error in CommentsContainerComponent getUpgradeButtonClick$ subscription: ",e)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(e=>{this.selectedAnnotationsMap=e},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.commentPinPortalService.getCustomPinEvents$().subscribe(e=>{this.onCustomPinInject.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getCustomPinEvents$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentUpdated$.subscribe(e=>{this.onCommentUpdate.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentUpdated$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentAccepted$.subscribe(e=>{this.onCommentAccept.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentAccepted$ subscription: ",e)})),this.subscriptions.push(this.commentService.commentRejected$.subscribe(e=>{this.onCommentReject.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent commentRejected$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarButtonOnCommentDialogClick$().subscribe(e=>{this.onSidebarButtonOnCommentDialogClick.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getSidebarButtonOnCommentDialogClick$ subscription: ",e)})),this.subscriptions.push(this.commentService.onCommentSelectionChange$().subscribe(e=>{this.onCommentSelectionChange.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent onCommentSelectionChange$ subscription: ",e)})),this.subscriptions.push(this.commentService.getCopyLink$().subscribe(e=>{this.onCopyLink.emit(e)},e=>{this.loggingService.catch("Error in CommentsContainerComponent getCopyLink$ subscription: ",e)})),this.getAllCommentsOnCurrentDocument()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent initComponent: ",e)}}getAllCommentsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.commentService.getCommentsOnDom$().pipe(he(e=>(this.componentConfigSignal.update(t=>(t=D(E({},t),{commentsOnDom:e}),t)),this.componentConfigSignal().commentsOnDom?mn([this.commentService.getAllCommentAnnotations({detectGhostComments:!0,addFilterCommentsOnDomCheck:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsContainer"}}}),this.commentService.getAllMultiThreadCommentAnnotations(void 0,void 0,void 0,!0)]).pipe(de(([t,r])=>[...t||[],...r||[]]),he(t=>this.commentService.getEnableGhostComments$().pipe(de(r=>(this.enableGhostComments=r,t)))),he(t=>this.commentService.getCommentsOnDom$().pipe(de(r=>(this.componentConfigSignal.update(a=>(a=D(E({},a),{commentsOnDom:r}),a)),t)))),he(t=>this.commentService.getResolvedCommentsOnDom$().pipe(de(r=>(this.resolvedCommentsOnDom=r,t)))),he(t=>this.domService.getSelectedAnnotationsMap$().pipe(de(r=>({filteredAnnotations:t||[],selectedAnnotationsMap:r||{}}))))):le({filteredAnnotations:[],selectedAnnotationsMap:{}})))).subscribe(e=>{try{this.loggingService.log(e),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotations:e?.filteredAnnotations}),s)),this.commentService.setCommentAnnotationsFromCommentsContainer(this.componentConfigSignal().commentPinAnnotations);let t;this.componentConfigSignal().commentPinAnnotations.forEach(s=>{this.selectedAnnotationsMap[s?.annotationId]&&(s?.multiThreadAnnotationId||(t=s))}),this.componentConfigSignal.update(s=>(s=D(E({},s),{selectedCommentAnnotation:t}),s));let r=this.componentConfigSignal().commentPinAnnotations.filter(s=>s.targetElement&&s?.position);r=r.filter(s=>{let c=!0;return s?.ghostComment?.type===Dl.DIFFERENT_DEVICE&&!s?.ghostComment?.isSameGroup&&(e.selectedAnnotationsMap[s.annotationId]||(c=!1)),s?.ghostComment&&!this.enableGhostComments&&(c=!1),!this.resolvedCommentsOnDom&&!(this.commentService.getFilterCommentsOnDom()&&this.commentService.getCommentsFromSidebarMap())&&s.status!==void 0&&s.status.type==="terminal"&&(e.selectedAnnotationsMap[s.annotationId]||(c=!1)),c}),this.commentPinPortalService.checkPinsToRemove(r),r.forEach(s=>{this.commentPinPortalService.setCommentPin(s)});let a=this.componentConfigSignal().commentPinAnnotations.filter(s=>s.targetTextRange);a=a.filter(s=>!(!this.resolvedCommentsOnDom&&!(this.commentService.getFilterCommentsOnDom()&&this.commentService.getCommentsFromSidebarMap())&&s.status!==void 0&&s.status.type==="terminal"&&!e.selectedAnnotationsMap[s.annotationId])),this.commentTextPortalService.updateTextCommentAnnotations(a),this.componentConfigSignal.update(s=>(s=D(E({},s),{commentPinAnnotationsForStreamView:this.componentConfigSignal().commentPinAnnotations.slice()}),s)),this.focusCommentAnnotation()}catch(t){this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent getAllCommentsOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.commentService.setContextProvider(null),this.commentService.setCommentAddedEmitter(null),this.componentConfigSignal().isFirstComponent&&this.commentService.setCommentAnnotationsFromCommentsContainer([])}catch(e){this.loggingService.catch("Error in CommentsContainerComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in CommentsContainerComponent unsubscribe: ",e)}}handleCommentPinSlotChanged(e){try{let t=e.target;if(t.assignedElements().length>0){let r=t.assignedElements()[0];this.commentPinPortalService.setCommentPinOverrideTemplate(r)}}catch(t){this.loggingService.catch("Error in CommentsContainerComponent handleCommentPinSlotChanged: ")}}focusCommentAnnotation(){if(this.focusCommentAnnotationId&&!this.commentAnnotationFocused){let e=this.componentConfigSignal().commentPinAnnotations.find(t=>t.annotationId===this.focusCommentAnnotationId);e&&(this.commentAnnotationFocused=!0,sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e.annotationId),this.selectedAnnotationsMap[e.annotationId]||this.domService.toggleAnnotationSelection(e),setTimeout(()=>{let t=null;e.targetElement||e.areaAnnotationId?t=document.getElementById(`comment-pin-container-${e.annotationId}`):(t=document.querySelector(`[data-velt-id='${e.annotationId}']`),sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e.annotationId)),t||(t=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e.annotationId}"]`)),t&&this.scrollToComment&&t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100))}}setCommentInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Re.COMMENT)}catch(e){this.loggingService.catch("Error in CommentsContainerComponent setCommentInstalledInAnalytics: ",e)}}disableCommentMode(){try{this.commentService.disableAddCommentMode()}catch(e){this.loggingService.catch("Error in CommentsContainerComponent disableCommentMode: ",e)}}checkDarkMode(){try{this._darkAttribute===""?this.componentConfigSignal.update(e=>(e=D(E({},e),{darkMode:!0}),e)):this.componentConfigSignal.update(e=>(e=D(E({},e),{darkMode:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsContainerComponent checkDarkMode: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(Be),h(we),h(q1),h(l7),h(Wo),h(_),h(R),h(Ll),h(Si),h(Wi),h(ot))},o.\u0275cmp=O({type:o,selectors:[["app-comments-container"]],hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{textMode:"textMode",popoverMode:"popoverMode",popoverTriangleComponent:"popoverTriangleComponent",forceCloseAllOnEsc:"forceCloseAllOnEsc",collapsedComments:"collapsedComments",shortUserName:"shortUserName",readOnly:"readOnly",deleteThreadWithFirstComment:"deleteThreadWithFirstComment",resolveStatusAccessAdminOnly:"resolveStatusAccessAdminOnly",svgAsImg:"svgAsImg",commentToNearestAllowedElement:"commentToNearestAllowedElement",floatingCommentDialog:"floatingCommentDialog",moderatorMode:"moderatorMode",_streamMode:[0,"streamMode","_streamMode"],atHereLabel:"atHereLabel",_atHereEnabled:[0,"atHereEnabled","_atHereEnabled"],_deleteReplyConfirmation:[0,"deleteReplyConfirmation","_deleteReplyConfirmation"],_expandMentionGroups:[0,"expandMentionGroups","_expandMentionGroups"],_showMentionGroupsFirst:[0,"showMentionGroupsFirst","_showMentionGroupsFirst"],_linkCallback:[0,"linkCallback","_linkCallback"],_showMentionGroupsOnly:[0,"showMentionGroupsOnly","_showMentionGroupsOnly"],_fullExpanded:[0,"fullExpanded","_fullExpanded"],_draftMode:[0,"draftMode","_draftMode"],atHereDescription:"atHereDescription",_persistentCommentMode:[0,"persistentCommentMode","_persistentCommentMode"],_seenByUsers:[0,"seenByUsers","_seenByUsers"],signInButton:"signInButton",upgradeButton:"upgradeButton",attachments:"attachments",recordings:"recordings",reactions:"reactions",deviceInfo:"deviceInfo",commentIndex:"commentIndex",dialogOnHover:"dialogOnHover",dialogOnTargetElementClick:"dialogOnTargetElementClick",priority:"priority",status:"status",resolveButton:"resolveButton",_inboxMode:[0,"inboxMode","_inboxMode"],_suggestionMode:[0,"suggestionMode","_suggestionMode"],_mobileMode:[0,"mobileMode","_mobileMode"],_inlineCommentMode:[0,"inlineCommentMode","_inlineCommentMode"],_privateCommentMode:[0,"privateCommentMode","_privateCommentMode"],_minimap:[0,"minimap","_minimap"],_minimapPosition:[0,"minimapPosition","_minimapPosition"],_ghostComments:[0,"ghostComments","_ghostComments"],_ghostCommentsIndicator:[0,"ghostCommentsIndicator","_ghostCommentsIndicator"],_commentsOnDom:[0,"commentsOnDom","_commentsOnDom"],_resolvedCommentsOnDom:[0,"resolvedCommentsOnDom","_resolvedCommentsOnDom"],_filterCommentsOnDom:[0,"filterCommentsOnDom","_filterCommentsOnDom"],_bubbleOnPin:[0,"bubbleOnPin","_bubbleOnPin"],_bubbleOnPinHover:[0,"bubbleOnPinHover","_bubbleOnPinHover"],_multiThreadMode:[0,"multiThreadMode","_multiThreadMode"],_multiThread:[0,"multiThread","_multiThread"],_maxReplyAvatars:[0,"maxReplyAvatars","_maxReplyAvatars"],_replyAvatars:[0,"replyAvatars","_replyAvatars"],_groupMultipleMatch:[0,"groupMultipleMatch","_groupMultipleMatch"],_groupMatchedComments:[0,"groupMatchedComments","_groupMatchedComments"],_commentTool:[0,"commentTool","_commentTool"],_sidebarButtonOnCommentDialog:[0,"sidebarButtonOnCommentDialog","_sidebarButtonOnCommentDialog"],_deviceIndicatorOnCommentPins:[0,"deviceIndicatorOnCommentPins","_deviceIndicatorOnCommentPins"],_scrollToComment:[0,"scrollToComment","_scrollToComment"],_userMentions:[0,"userMentions","_userMentions"],_paginatedContactList:[0,"paginatedContactList","_paginatedContactList"],_deleteOnBackspace:[0,"deleteOnBackspace","_deleteOnBackspace"],_hotkey:[0,"hotkey","_hotkey"],_recordingSummary:[0,"recordingSummary","_recordingSummary"],_recordingTranscription:[0,"recordingTranscription","_recordingTranscription"],_allowedFileTypes:[0,"allowedFileTypes","_allowedFileTypes"],_recordingCountdown:[0,"recordingCountdown","_recordingCountdown"],_unreadIndicatorMode:[0,"unreadIndicatorMode","_unreadIndicatorMode"],_enterKeyToSubmit:[0,"enterKeyToSubmit","_enterKeyToSubmit"],_pinShadowDOM:[0,"pinShadowDom","_pinShadowDOM"],_dialogShadowDOM:[0,"dialogShadowDom","_dialogShadowDOM"],_persistentCommentShadowDOM:[0,"persistentCommentShadowDom","_persistentCommentShadowDOM"],_shadowDOM:[0,"shadowDom","_shadowDOM"],_textCommentToolShadowDOM:[0,"textCommentToolShadowDom","_textCommentToolShadowDOM"],_pinDarkMode:[0,"pinDarkMode","_pinDarkMode"],_textCommentToolDarkMode:[0,"textCommentToolDarkMode","_textCommentToolDarkMode"],_textCommentToolbarDarkMode:[0,"textCommentToolbarDarkMode","_textCommentToolbarDarkMode"],_textCommentToolbarShadowDOM:[0,"textCommentToolbarShadowDom","_textCommentToolbarShadowDOM"],_changeDetectionInCommentMode:[0,"changeDetectionInCommentMode","_changeDetectionInCommentMode"],_areaComment:[0,"areaComment","_areaComment"],_screenshot:[0,"screenshot","_screenshot"],_pinCursorImage:[0,"pinCursorImage","_pinCursorImage"],allowedElementIds:"allowedElementIds",allowedElementClassNames:"allowedElementClassNames",allowedElementQuerySelectors:"allowedElementQuerySelectors",_commentPinHighlighter:[0,"commentPinHighlighter","_commentPinHighlighter"],_customReactions:[0,"customReactions","_customReactions"],customStatus:"customStatus",customListDataOnAnnotation:"customListDataOnAnnotation",customListDataOnComment:"customListDataOnComment",attachmentNameInMessage:"attachmentNameInMessage",customPriority:"customPriority",_customAutocompleteSearch:[0,"customAutocompleteSearch","_customAutocompleteSearch"],customCategory:"customCategory",streamViewContainerId:"streamViewContainerId",composerMode:"composerMode",autoCategorize:"autoCategorize",commentplaceholder:[0,"commentPlaceholder","commentplaceholder"],replyplaceholder:[0,"replyPlaceholder","replyplaceholder"],isDarkMode:[0,"darkMode","isDarkMode"]},outputs:{onCommentAdd:"onCommentAdd",onSignIn:"onSignIn",onUpgrade:"onUpgrade",onCustomPinInject:"onCustomPinInject",onCommentUpdate:"onCommentUpdate",onCommentAccept:"onCommentAccept",onCommentReject:"onCommentReject",onSidebarButtonOnCommentDialogClick:"onSidebarButtonOnCommentDialogClick",onCommentSelectionChange:"onCommentSelectionChange",onCopyLink:"onCopyLink"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["commentsDataRef",""],[4,"ngIf"],[2,"display","none"],["id","comment-pin-slot","name","comment-pin",3,"slotchange"],[3,"componentConfigSignal"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],[3,"commentPinAnnotations","streamViewContainerId",4,"ngIf"],[3,"darkMode","commentAnnotation",4,"ngIf"],[3,"commentAnnotations","user","position",4,"ngIf"],[3,"commentPinAnnotations","streamViewContainerId"],[3,"darkMode","commentAnnotation"],[3,"commentAnnotations","user","position"]],template:function(t,r){t&1&&u(0,enn,5,5,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,fge,z1e,G1e,t8,Sn,E1,ge],encapsulation:2,changeDetection:0});let i=o;return i})();var tnn=["sidebarRef"],nnn=i=>({componentConfigSignal:i}),inn=(i,o)=>({condition:i,data:o}),onn=(i,o)=>({componentConfigSignal:i,sidebarRef:o}),rnn=(i,o)=>({template:i,context:o});function ann(i,o){if(i&1&&(y(0,"div",5,0),w(2,"app-comment-sidebar-skeleton",6)(3,"app-comment-sidebar-panel",7)(4,"app-comment-sidebar-focused-thread",8),b()),i&2){let n=me(1),e=l(3).ngIf,t=l();pe("s-overflow-hidden",e.moreFiltersVisible)("velt-sidebar--more-filters-visible",e.moreFiltersVisible),x("aria-expanded",e.sidebarVisible),m(2),d("componentConfigSignal",t.componentConfigSignal),m(),d("sidebarRef",n)("componentConfigSignal",t.componentConfigSignal),m(),d("componentConfigSignal",t.componentConfigSignal)("sidebarRef",n)}}function snn(i,o){if(i&1){let n=K();v(0),y(1,"div",3),P(2,"translate"),W("click",function(t){N(n);let r=l(3);return F(r.onClick(t))}),u(3,ann,5,10,"div",4),b(),C()}if(i&2){let n=l(2).ngIf,e=l();m(),pe("mobile",n.isPhone)("velt-sidebar-container--fullscreen",n.fullScreen)("visible",n.sidebarVisible||n.embedMode||n.floatingMode)("floating",n.floatingMode)("embed",n.embedMode)("page",n.pageMode)("velt-comment-sidebar--read-only",n.readOnly),d("ngClass",n.position),x("data-testid",e.componentId)("aria-label",M(2,18,"Comments sidebar")),m(2),d("veltDynamicTemplate",k(23,rnn,e.template,k(20,onn,e.componentConfigSignal,e.sidebarRef)))}}function lnn(i,o){if(i&1&&(v(0),u(1,snn,4,26,"ng-container",1),C()),i&2){let n=l().ngIf;m(),d("ngIf",n)}}function cnn(i,o){if(i&1&&(v(0),u(1,lnn,2,1,"ng-container",2),C()),i&2){let n=l();m(),d("veltIf",k(3,inn,n.conditionSignal(),A(1,nnn,n.componentConfigSignal)))}}var q1e=(()=>{let o=class o extends tt{constructor(e,t,r,a){super(e,t,void 0,void 0,void 0,a,r),this.elementRef=e,this.themeService=t,this.loggingService=r,this.dynamicDataService=a,this.onWrapperClick=new Me,this.componentId="velt-comments-sidebar-wrapper",super.initializeComponentConfigSignal(new qe)}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in CommentsSidebarWrapperComponent ngOnInit:",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in CommentsSidebarWrapperComponent ngOnDestroy:",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in setupA11yAttributes:",e)}}onClick(e){try{this.onWrapperClick.emit(e)}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(R),h(Ke),h(_),h(S))},o.\u0275cmp=O({type:o,selectors:[["velt-comments-sidebar-wrapper-internal"]],viewQuery:function(t,r){if(t&1&&it(tnn,7),t&2){let a;Je(a=et())&&(r.sidebarRef=a.first)}},outputs:{onWrapperClick:"onWrapperClick"},standalone:!1,features:[V([S]),L],decls:1,vars:1,consts:[["sidebarRef",""],[4,"ngIf"],[4,"veltIf"],["data-velt-element","true","data-velt-comment-disabled","true","role","complementary",1,"velt-sidebar-container",3,"click","ngClass"],["class","velt-sidebar","role","region",3,"s-overflow-hidden","velt-sidebar--more-filters-visible",4,"veltDynamicTemplate"],["role","region",1,"velt-sidebar"],[3,"componentConfigSignal"],[3,"sidebarRef","componentConfigSignal"],[3,"componentConfigSignal","sidebarRef"]],template:function(t,r){t&1&&u(0,cnn,2,6,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Xr,X,ie,Rf,kf,O1,se,ge],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-sidebar-container[_ngcontent-%COMP%]{height:100vh;width:calc((26rem + 0px) * var(--velt-base-rem-unit));position:fixed;top:0;padding:var(--velt-spacing-lg);box-sizing:border-box;z-index:999999997}.velt-sidebar-container.velt-sidebar-container--fullscreen[_ngcontent-%COMP%]{width:100vw;padding:0}.velt-sidebar-container.velt-sidebar-container--fullscreen[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{border-radius:0;border:0}.velt-sidebar-container.velt-sidebar-container--fullscreen.left[_ngcontent-%COMP%], .velt-sidebar-container.velt-sidebar-container--fullscreen.right[_ngcontent-%COMP%]{transition:none}.velt-sidebar-container.left[_ngcontent-%COMP%]{left:-100%;transition:width .5s ease-in-out,left .5s ease-in-out}.velt-sidebar-container.left.visible[_ngcontent-%COMP%]{left:0}.velt-sidebar-container.right[_ngcontent-%COMP%]{right:-100%;transition:width .5s ease-in-out,right .5s ease-in-out}.velt-sidebar-container.right.visible[_ngcontent-%COMP%]{right:0}.velt-sidebar-container.mobile[_ngcontent-%COMP%]{width:100%;height:100%;box-sizing:border-box;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.velt-sidebar-container.embed[_ngcontent-%COMP%]{width:100%;height:100%;position:unset;border:0}.velt-sidebar-container.floating[_ngcontent-%COMP%]{height:90vh;position:unset;border:0;padding:0;width:calc((22.5rem + 0px) * var(--velt-base-rem-unit))}.velt-sidebar-container.floating.embed[_ngcontent-%COMP%]{width:100%;height:100%}.velt-sidebar-container.page[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{padding-bottom:0}.velt-sidebar-container[_ngcontent-%COMP%] *[_ngcontent-%COMP%]{box-sizing:border-box}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--velt-spacing-lg);font-weight:400;font-size:var(--velt-font-size-sm);line-height:21px;align-items:center;background:var(--velt-background-0);border-radius:var(--velt-border-radius-lg);width:100%;overflow-x:hidden;position:relative;height:100%;border:1px solid var(--velt-border-5)}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%] app-comment-sidebar-filter[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;-webkit-user-select:none;user-select:none;pointer-events:none}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar.velt-sidebar--more-filters-visible[_ngcontent-%COMP%] app-comment-sidebar-filter[_ngcontent-%COMP%]{pointer-events:initial;-webkit-user-select:initial;user-select:initial}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]::-webkit-scrollbar{display:none;width:0;height:0}.velt-sidebar-container[_ngcontent-%COMP%] .velt-sidebar[_ngcontent-%COMP%]:not(.s-overflow-hidden){overflow-y:auto}[_nghost-%COMP%] velt-comments-sidebar-wireframe{width:100%;height:100%;display:flex;flex-direction:column;gap:var(--velt-spacing-lg)}"],changeDetection:0});let i=o;return i})();var mnn=["sidebarOverlay"],pnn=["host"],gnn=i=>["snippyly-sidebar-panel","velt-overlay-panel",i];function unn(i,o){i&1&&He(0)}function hnn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,unn,1,0,"ng-container",7),b()),i&2){l(3);let n=me(3);m(),d("ngTemplateOutlet",n)}}function fnn(i,o){if(i&1&&(v(0),u(1,hnn,2,1,"velt-shadow-dom-internal",6),C()),i&2){l(2);let n=me(3),e=l();m(),d("ngIf",!e.template&&e.sidebarShadowDOM)("ngIfElse",n)}}function vnn(i,o){i&1&&He(0)}function Cnn(i,o){if(i&1&&(y(0,"velt-shadow-dom-internal"),u(1,vnn,1,0,"ng-container",7),b()),i&2){l(5);let n=me(3);m(),d("ngTemplateOutlet",n)}}function _nn(i,o){if(i&1&&(y(0,"div",11),u(1,Cnn,2,1,"velt-shadow-dom-internal",6),b()),i&2){let n=l(4).ngIf,e=me(3),t=l();pe("dark",n.darkMode),m(),d("ngIf",!t.template&&t.sidebarShadowDOM)("ngIfElse",e)}}function ynn(i,o){if(i&1&&u(0,_nn,2,4,"div",10),i&2){let n=l(3).ngIf;d("ngIf",n==null?null:n.sidebarVisible)}}function Snn(i,o){if(i&1&&(w(0,"div",8,2),u(2,ynn,1,1,"ng-template",9,3,Te)),i&2){let n=me(1),e=l(2).ngIf;m(2),d("cdkConnectedOverlayOrigin",n)("cdkConnectedOverlayOpen",!0)("cdkConnectedOverlayDisableClose",!0)("cdkConnectedOverlayPanelClass",A(4,gnn,e.darkMode?"dark":""))}}function bnn(i,o){if(i&1&&u(0,fnn,2,2,"ng-container",6)(1,Snn,4,6,"ng-template",null,1,Te),i&2){let n=me(2),e=l().ngIf;d("ngIf",e.embedMode||e.floatingMode)("ngIfElse",n)}}function Inn(i,o){if(i&1){let n=K();y(0,"velt-comments-sidebar-wrapper-internal",12),P(1,"translate"),W("onWrapperClick",function(t){N(n);let r=l(2);return F(r.onClick(t))}),b()}if(i&2){let n=l().ngIf,e=l();d("componentConfigSignal",e.componentConfigSignal)("template",e.template)("darkMode",n.darkMode),x("data-testid",e.componentId)("aria-label",M(1,6,"Comments sidebar"))("aria-modal",!0)}}function Enn(i,o){if(i&1&&(v(0),u(1,bnn,3,2,"ng-template",5)(2,Inn,2,8,"ng-template",null,0,Te),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.isFirstComponent||n.floatingMode||n.embedMode)}}var n8=(()=>{let o=class o extends tt{set _pageMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{pageMode:t}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set _filterCount(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{filterCount:t}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _filterCount: ",t)}}set _customActions(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarCustomActions():this.commentService.disableSidebarCustomActions()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set focusedThreadMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFocusedThreadMode():this.commentService.disableFocusedThreadMode()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _pageMode: ",t)}}set _openAnnotationInFocusMode(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableOpenAnnotationInFocusMode():this.commentService.disableOpenAnnotationInFocusMode()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _openAnnotationInFocusMode: ",t)}}set _readOnly(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{sidebarReadMode:!!t}),r.readOnly=r.sidebarReadMode||this.commentService.getReadOnly(),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _readOnly: ",t)}}set _selection(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{selection:t!==!1}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _selection: ",t)}}set _expandOnSelection(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{expandOnSelection:t!==!1}),r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _expandOnSelection: ",t)}}set _sortData(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{sortData:e}),t))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _sortData: ",t)}}set enableUrlNavigation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarUrlNavigation():this.commentService.disableSidebarUrlNavigation()}set urlNavigation(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableSidebarUrlNavigation():this.commentService.disableSidebarUrlNavigation()}set _queryParamsComments(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableQueryParamsComments():this.commentService.disableQueryParamsComments()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent _queryParamsComments: ",t)}}set _fullScreen(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFullScreenInSidebar():this.commentService.disableFullScreenInSidebar()}catch{}}set _currentLocationSuffix(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{currentLocationSuffix:!!t}),r))}catch{}}set _filterOptionLayout(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{filterOptionLayout:e}),t))}catch{}}set _filterConfig(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.updateFilterConfig(t)}catch{}}set _groupConfig(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.componentConfigSignal.update(r=>(r=D(E({},r),{groupConfig:t}),r.groupConfig?.enable||(r.groupBy=null),r))}catch{}}set _filters(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.commentService.setCommentSidebarFilters(t)}catch{}}set _systemFiltersOperator(e){try{e&&this.commentService.setCommentSidebarSystemFiltersOperator(e)}catch{}}set _excludeLocationIds(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.commentService.setExcludeLocationIdsFromSidebar(t)}catch{}}set _fullExpanded(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{fullExpanded:!!t}),r))}catch{}}set _sidebarButtonCountType(e){try{this.commentService.setSidebarButtonCountType(e)}catch{}}set _filterGhostCommentsInSidebar(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.commentService.enableFilterGhostCommentsInSidebar():this.commentService.disableFilterGhostCommentsInSidebar()}catch{}}set _sidebarShadowDOM(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.componentConfigSignal.update(r=>(r=D(E({},r),{shadowDom:t}),r)),t?this.commentService.enableSidebarShadowDOM():this.commentService.disableSidebarShadowDOM()}catch{}}set _context(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t&&typeof t=="object"&&this.componentConfigSignal.update(r=>(r=D(E({},r),{context:t}),r))}catch{}}constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J,ne,ve){super(p,ve,void 0,r),this.analyticsService=e,this.authService=t,this.commentService=r,this.configService=a,this.domService=s,this.docService=c,this.elementRef=p,this.iamService=g,this.loggingService=f,this.breakpointObserver=I,this.customFilterService=T,this.translateService=B,this.cd=z,this.wireframeService=G,this.renderer=J,this.dynamicComponentService=ne,this.themeService=ve,this.embedMode=null,this.floatingMode=!1,this.dialogVariant="sidebar",this.focusedThreadDialogVariant="sidebar",this.filterPanelLayout="bottomSheet",this.pageModeComposerVariant="sidebar",this.searchPlaceholder="Search comments",this.openSidebar=new Me,this.onSidebarOpen=new Me,this.onSidebarCommentClick=new Me,this.onSidebarCommentClickEvent=new Me,this.onCommentClick=new Me,this.onSidebarClose=new Me,this.onCommentNavigationButtonClick=new Me,this.onFullscreen=new Me,this.subscriptions=[],this.locations={},this.commentAccessMode=uo,this.commentReadAnalyticsCalled=!0,this.peopleTypes={all:"All",other:"Other"},this.pageTypes={all:"All",other:"Other"},this.unsetType={id:"unset",name:"Not set"},this.objectKeys=Object.keys,this.filteredGroupedCommentAnnotationsObj={},this.filteredGroupedCommentAnnotations=[],this.veltId=vt(),this.veltElement=!0,this.defaultFilterConfig={location:{name:"Pages",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search pages",type:"system"},document:{name:"Documents",enable:!1,multiSelection:!0,enableGrouping:!1,placeholder:"Search documents",type:"system"},people:{name:"Author",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search authors",type:"system"},assigned:{name:"Assigned",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search assigned",type:"system"},tagged:{name:"Tagged",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search tagged",type:"system"},involved:{name:"Involved",enable:!0,multiSelection:!0,enableGrouping:!0,placeholder:"Search involved",type:"system"},priority:{name:"Priority",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search priority",type:"system"},status:{name:"Status",enable:!1,multiSelection:!0,enableGrouping:!1,placeholder:"Search status",type:"system"},category:{name:"Category",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search category",type:"system"},commentType:{name:"Comment Type",enable:!0,multiSelection:!0,enableGrouping:!1,placeholder:"Search comment type",type:"system"},version:{name:"Versions",enable:!0,multiSelection:!1,enableGrouping:!1,placeholder:"Search versions",type:"system"}},this.defaultGroupConfig={enable:!0,name:"Group By"},this.isUserGlobalContact=!1,this.resolvedCommentsOnDom=!1,this.position="right",this.commentRefId="",this.showDefault=!0,this.componentConfigSignal=xe({fullScreen:!1,embedMode:this.embedMode,floatingMode:this.floatingMode,pageMode:!1,currentLocationSuffix:!1,queryParamsComments:!1,variant:this.variant,dialogVariant:this.dialogVariant,focusedThreadDialogVariant:this.focusedThreadDialogVariant,pageModeComposerVariant:this.pageModeComposerVariant,fullExpanded:!1,systemFiltersOperator:dd.AND,annotations:[],filteredCommentPinAnnotations:[],filteredCommentAnnotationsCount:0,selectedAnnotationsMap:{},commentAnnotationsCountByFilters:{page:{},document:{},status:{},people:{},tagged:{},assigned:{},involved:{},version:{},priority:{},commentCategory:{},accessMode:{}},noCommentsFound:!1,noCommentsFoundForAppliedFilters:!1,pageCommentAnnotation:new Zo,commentCategoryMap:U.CommentCategoryMap,virtualScrollData:[],isFirstComponent:!1,searchPlaceholder:this.searchPlaceholder,enableAutoCategorize:!1,filterConfig:JSON.parse(JSON.stringify(this.defaultFilterConfig)),filters:{pages:[],documents:[],statuses:[],statusIds:[],people:[],assigned:[],tagged:[],involved:[],versions:[],versionIds:[],priorities:[],priorityIds:[],categories:[],categoryIds:[],accessModes:[],input:null},moreFiltersVisible:!1,groupByOptions:{},groupBy:null,peopleFilters:[],assignedFilters:[],taggedFilters:[],involvedFilters:[],enablePriority:!1,enableStatus:!0,appliedFiltersCount:0,priorities:[],statuses:[],accessModes:[{id:uo.PUBLIC,name:"Public"},{id:uo.PRIVATE,name:"Private"}],filterOptionLayout:"checkbox",filterCount:!0,sidebarVisible:!1,pages:{},documents:{},showAllPages:!1,showAllDocuments:!1,versions:[],groupConfig:JSON.parse(JSON.stringify(this.defaultGroupConfig)),user:null,currentPage:null,currentDocument:null,isUserAdmin:!1,isPrivateCommentAllowed:!1,isPhone:!1,darkMode:!1,skeletonLoading:!0,shadowDom:void 0,position:this.position,filterPanelLayout:this.filterPanelLayout,customActionsState:{},readOnly:!1,selection:!0,expandOnSelection:!0,sidebarReadMode:!1,filterRecentlyClosed:!1,location:null,fullscreenEnabled:!1,trackByCategoryId:this.trackByCategoryId.bind(this),trackByPriorityId:this.trackByPriorityId.bind(this),trackByCustomFilterId:this.trackByCustomFilterId.bind(this),trackByAccessModeId:this.trackByAccessModeId.bind(this),trackByPageKey:this.trackByPageKey.bind(this),trackByDocumentKey:this.trackByDocumentKey.bind(this),trackByPeople:this.trackByPeople.bind(this),trackByVersion:this.trackByVersion.bind(this),trackByGroupByOptionKey:this.trackByGroupByOptionKey.bind(this),onCommentAnnotationClick:this.onCommentAnnotationClick.bind(this),saveComment:this.saveComment.bind(this),trackCommentPinAnnotations:this.trackCommentPinAnnotations.bind(this),updateFilter:this.updateFilter.bind(this),toggleGroupedCommentAnnotations:this.toggleGroupedCommentAnnotations.bind(this),changeGroupBy:this.changeGroupBy.bind(this),closeSidebar:this.closeSidebar.bind(this),toggleMoreFilters:this.toggleMoreFilters.bind(this),openMoreFilters:this.openMoreFilters.bind(this),closeMoreFilters:this.closeMoreFilters.bind(this),savePageComment:this.savePageComment.bind(this),sortComments:this.sortComments.bind(this),goBackToAllComments:this.goBackToAllComments.bind(this),minimalFilterDropdownOpen:!1,minimalActionsDropdownOpen:!1,toggleMinimalFilterDropdown:this.toggleMinimalFilterDropdown.bind(this),unreadCommentsMap:null,minimalFilter:"all",filterCommentsByReadStatus:this.filterCommentsByReadStatus.bind(this),selectedMinimalFilterDropdownOption:{sorting:"date",filter:"all"},locationFilterDropdownOpen:!1,toggleLocationFilterDropdown:this.toggleLocationFilterDropdown.bind(this),documentFilterDropdownOpen:!1,toggleDocumentFilterDropdown:this.toggleDocumentFilterDropdown.bind(this),closeDocumentFilterDropdown:this.closeDocumentFilterDropdown.bind(this),markAllCommentAnnotationsAsRead:this.markAllCommentAnnotationsAsRead.bind(this),markAllCommentAnnotationsAsResolved:this.markAllCommentAnnotationsAsResolved.bind(this),toggleMinimalActionsDropdown:this.toggleMinimalActionsDropdown.bind(this),toggleCustomAction:this.toggleCustomAction.bind(this),focusedThreadMode:!1,openAnnotationInFocusMode:!1,focusedAnnotation:null,navigateToComment:this.navigateToComment.bind(this),resetFilters:this.resetFilters.bind(this),filterSearch:this.filterSearch.bind(this),customFilters:{},onDialogExpanded:this.onDialogExpanded.bind(this),onFullscreenClick:this.onFullscreenClick.bind(this)}),this.sidebarShadowDOM=!1,this.dataAvailable=!1,this.componentId="velt-comments-sidebar";try{this.subscriptions.push(super.onDarkModeChange().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{darkMode:Ne}),Ve))})),this.loggingService.log("%c[WB] Creating CLASS: CommentsSidebarComponent","color: blue;"),this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{groupBy:Ne.groupByOptions.page}),Ne.pageCommentAnnotation.isPageAnnotation=!0,Ne)),this.updateGroupByOptions(),this.subscriptions.push(this.commentService.getSidebarShadowDOM$().subscribe(Ne=>{this.sidebarShadowDOM=Ne})),this.subscriptions.push(this.commentService.getFocusedThreadMode$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{focusedThreadMode:Ne}),Ve))})),this.subscriptions.push(this.commentService.getOpenAnnotationInFocusMode$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{openAnnotationInFocusMode:Ne}),Ve))})),this.subscriptions.push(this.commentService.getReadOnly$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{readOnly:Ve.sidebarReadMode||Ne}),Ve))})),this.subscriptions.push(this.commentService.getQueryParamsComments$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{queryParamsComments:Ne}),Ve)),this.setPages(),this.setDocuments()})),this.subscriptions.push(this.commentService.getUnreadCommentsMap$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{unreadCommentsMap:Ne}),Ve))})),this.subscriptions.push(this.commentService.getFullScreenInSidebar$().subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{fullscreenEnabled:Ne}),Ve))})),this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(Ne=>{Ne.matches?this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{isPhone:!0}),Ve)):this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{isPhone:!1}),Ve))},Ne=>{this.loggingService.catch("Error in CommentsSidebarComponent breakpointObserver subscription: ",Ne)})),this.subscriptions.push(this.customFilterService.customStatusMap$.subscribe(Ne=>{this.statusMap=Ne,this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{statuses:Object.values(Ne)}),Ve)),this.pruneStaleStatuses()})),this.subscriptions.push(this.customFilterService.customPriorityMap$.subscribe(Ne=>{this.priorityMap=Ne,this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{priorities:[...Object.values(Ne),{id:"unset",name:"Not set",color:"#FFFFFF"}]}),Ve)),this.pruneStalePriorities()})),this.subscriptions.push(this.customFilterService.customCategoryMap$.subscribe(Ne=>{this.componentConfigSignal.update(Ve=>(Ve=D(E({},Ve),{commentCategoryMap:D(E({},Ne),{other:{id:"other",name:"Other",color:"#00C48C"}})}),Ve)),this.pruneStaleCategories()}));let ye=sessionStorage.getItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE);ye&&this.componentConfigSignal.update(Ne=>(Ne=D(E({},Ne),{customActionsState:JSON.parse(ye)}),Ne))}catch(ye){this.loggingService.catch("Error in CommentsSidebarComponent constructor: ",ye)}}ngOnInit(){try{if(this.setupA11yAttributes(),sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)){let e=JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS));delete e?.input,e?.people?.length&&e.people.find(t=>typeof t=="string")&&(e.people=[]),e?.pages?.length&&e.pages?.forEach(t=>{t?.id||(t.id=t.displayName)}),sessionStorage.getItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_FILTERS_RESET)||(e.pages=[],sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_FILTERS_RESET,"true")),this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:e}),t)),this.pruneStaleStatuses(),this.pruneStalePriorities(),this.pruneStaleCategories()}if(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY)){let e=sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY);e&&this.componentConfigSignal.update(t=>(t=E({},t),Object.keys(t.groupByOptions).forEach(r=>{t.groupByOptions[r]===e&&(t.groupBy=e)}),t))}this.subscriptions.push(this.commentService.onCommentAdd$().subscribe(e=>{e?.annotation&&setTimeout(()=>{this.goToAnnotationInSidebar(e.annotation)},200)}))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent OnInit: ",e)}try{let e="velt-comments-sidebar-wireframe";this.variant&&(e+=`---${this.variant}`),this.subscriptions.push(this.wireframeService.getWireframe$(e).subscribe(t=>{if(t){this.commentRefId="comment-sidebar";let r=document.createElement(t.tagName);r.innerHTML=t.innerHTML,this.template=r}}))}catch(e){this.loggingService.catch("Error in CommentDialogComponent OnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.forEach(e=>{e.unsubscribe()}),this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalFilterDropdownOpen:!1}),e)),this.commentService.setCommentsFromSidebarMap({comments:null,sidebarVisible:!1})}catch{}}ngAfterViewInit(){try{if(this.floatingMode||this.embedMode)this.initComponent();else{let e=document.querySelector(U.TAGS.SNIPPYLY_COMMENTS_SIDEBAR),t=document.querySelector(U.TAGS.VELT_COMMENTS_SIDEBAR);t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),setTimeout(()=>{this.sidebarOverlay?.overlayRef?.hostElement&&(this.sidebarOverlay.overlayRef.hostElement.style.zIndex="1001")},100),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),setTimeout(()=>{this.sidebarOverlay?.overlayRef?.hostElement&&(this.sidebarOverlay.overlayRef.hostElement.style.zIndex="1001")},100),this.initComponent())}}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent AfterViewInit: ",e)}}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent ngOnChanges: ",t)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setupA11yAttributes:",e)}}onClick(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: onClick","color: green;");let t=e?.target?.tagName?.toLowerCase();t!==U.TAGS.VELT_COMMENT_DIALOG&&t!==U.TAGS.SNIPPYLY_COMMENT_DIALOG&&!e?.target?.closest(U.TAGS.VELT_COMMENT_DIALOG)&&!e?.target?.closest(U.TAGS.SNIPPYLY_COMMENT_DIALOG)&&this.domService.resetSelectedAnnotationsMap()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onClick: ",t)}}pruneStaleStatuses(){try{this.statusMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.statuses=e.filters.statuses.filter(t=>t.id in this.statusMap),e.filters.statusIds=e.filters.statuses?.map(t=>t?.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStaleStatuses: ",e)}}pruneStalePriorities(){try{this.priorityMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.priorities=e.filters.priorities.filter(t=>t.id in this.priorityMap),e.filters.priorityIds=e.filters.priorities?.map(t=>t.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStalePriorities: ",e)}}pruneStaleCategories(){try{this.componentConfigSignal().commentCategoryMap!==void 0&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.categories=e.filters.categories?.filter(t=>t.id in e.commentCategoryMap),e.filters.categoryIds=e.filters.categories?.map(t=>t.id),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterStaleCategories: ",e)}}trackByAnnotationGroup(e,t){return t?.displayName}trackByAnnotationId(e,t){return t?.annotationId}trackByCategoryId(e,t){return t?.value?.id||e}trackByPriorityId(e,t){return t?.id||e}trackByCustomFilterId(e,t){return t?.id||e}trackByAccessModeId(e,t){return t?.id||e}trackByPageKey(e,t){return t?.key||e}trackByDocumentKey(e,t){return t?.key||e}trackByPeople(e,t){return t?.id||e}trackByVersion(e,t){return t?.id||e}trackByGroupByOptionKey(e,t){return t?.key||e}initComponent(){try{this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),this.componentConfigSignal().user&&(this.setCommentSidebarInstalledInAnalytics(),this.setCommentSidebarEmbedModeInAnalytics(),this.setCommentSidebarFloatingModeInAnalytics())},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getUser$ subscription: ",e)})),this.subscriptions.push(this.docService.getDocumentPaths$().subscribe(e=>{this.documentPaths=e,this.getAllCommentsOnCurrentDocument()},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getDocumentPaths$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarCustomActionEventData().subscribe(e=>{e&&(this.componentConfigSignal.update(t=>(t=D(E({},t),{customActionsState:e.actions}),t)),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify(e.actions)))})),this.subscriptions.push(this.docService.getLocation$().subscribe(e=>{this.location=e,this.componentConfigSignal.update(a=>(a=D(E({},a),{location:e}),a));let t=this.commentService.getCommentSidebarFilters(),r=t?E({},t):{version:[]};this.location?.location?.version?r.version=[{id:this.location.location.version?.id,name:this.location.location.version?.name}]:r?.version||(r.version=[]),this.commentService.setCommentSidebarFilters(r),this.setPages(),this.filteredGroupedCommentAnnotationsObj={}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getLocation$ subscription: ",e)})),this.subscriptions.push(this.docService.getLocations$().subscribe(e=>{this.locations=e,this.filteredGroupedCommentAnnotationsObj={}})),this.subscriptions.push(this.commentService.getEnableStatus$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enableStatus:e}),t))})),this.subscriptions.push(this.commentService.getEnablePriority$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enablePriority:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getEnablePriority$ subscription: ",e)})),this.subscriptions.push(this.commentService.getEnableAutoCategorize$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{enableAutoCategorize:e}),t))})),this.subscriptions.push(this.commentService.getSidebarVisibility$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{sidebarVisible:e}),t)),this.componentConfigSignal().sidebarVisible&&(this.commentReadAnalyticsCalled=!1,setTimeout(()=>{Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length&&this.goToAnnotationInSidebar(this.componentConfigSignal().selectedAnnotationsMap[Object.keys(this.componentConfigSignal().selectedAnnotationsMap)[0]])},500)),this.componentConfigSignal().sidebarVisible?(this.getAllCommentsOnCurrentDocument(),this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:this.componentConfigSignal().filteredCommentPinAnnotations,sidebarVisible:!0})):(this.commentService.getSidebarButtonCountType()==="default"&&this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:this.componentConfigSignal().filteredCommentPinAnnotations,sidebarVisible:!1}),this.componentConfigSignal().focusedThreadMode&&this.componentConfigSignal().focusedAnnotation&&this.goBackToAllComments())},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.commentService.getSidebarButtonCountType$().subscribe(e=>{e==="filter"&&this.getAllCommentsOnCurrentDocument()})),this.subscriptions.push(this.commentService.getCommentSidebarFilters$().subscribe(e=>{this.mergeClientFilters(e)})),this.subscriptions.push(this.commentService.getCommentSidebarSystemFiltersOperator$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{systemFiltersOperator:e}),t)),this.filterCommentAnnotations()})),this.subscriptions.push(this.commentService.getOpenSidebar$().subscribe(e=>{this.openSidebar.emit(e),this.onSidebarOpen.emit(e)},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getOpenSidebar$ subscription: ",e)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(e=>{let t=this.componentConfigSignal().selectedAnnotationsMap;this.componentConfigSignal.update(c=>(c=D(E({},c),{selectedAnnotationsMap:e}),c)),Object.keys(this.componentConfigSignal().selectedAnnotationsMap).length===1&&!this.commentService.showFloatingComments()&&this.commentService.setSidebarVisibility(!0);let r=Object.keys(e||{}),a=Object.keys(t||{}),s=r.find(c=>!a.includes(c));if(s){let c=this.componentConfigSignal().annotations.find(p=>p.annotationId===s);c&&(this.componentConfigSignal().focusedThreadMode&&this.componentConfigSignal().openAnnotationInFocusMode?this.componentConfigSignal.update(p=>(p=D(E({},p),{focusedAnnotation:c}),p)):setTimeout(()=>{this.goToAnnotationInSidebar(c)},100))}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getSidebarVisibility$ subscription: ",e)})),this.subscriptions.push(this.domService.onDocumentClick$().subscribe(e=>{try{if(this.componentConfigSignal().sidebarVisible&&e&&!this.elementRef?.nativeElement?.contains(e?.target)){let t=document.querySelectorAll(".cdk-overlay-container");Array.from(t).some(a=>a?.contains(e?.target))||!this.embedMode&&!this.commentService.isSidebarOpenedByCustomTrigger()&&(e?.target?.hasAttribute(U.ATTRIBUTES.VELT_DOWNLOAD_BUTTON)||(this.closeSidebar(),e?.stopPropagation()))}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onDocumentClick: ",t)}},e=>{this.loggingService.catch("Error in CommentsSidebarComponent onDocumentClick$ subscription: ",e)})),this.subscriptions.push(this.iamService.isUserAdmin$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{isUserAdmin:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent isUserAdmin$ subscription: ",e)})),this.subscriptions.push(this.commentService.isPrivateCommentAllowed$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{isPrivateCommentAllowed:e}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent isPrivateCommentAllowed$ subscription: ",e)})),this.getAllCommentsOnCurrentDocument(),this.subscriptions.push(this.commentService.getSidebarCustomData().subscribe(e=>{this.updateVirtualScrollData(e)}))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent initComponent: ",e)}}updateVirtualScrollData(e){try{if(this.commentService.getSidebarCustomActionsValue()){let t=[];this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData=[],s)),e?.data?.forEach((s,c)=>{e?.options?.grouping!==!1&&this.componentConfigSignal.update(p=>(p=E({},p),p.virtualScrollData.push({type:"group",data:{displayName:s?.groupName,isExpanded:s?.isExpanded===void 0&&c===0||s?.isExpanded,annotations:s?.annotations}}),p)),(s?.isExpanded===void 0&&c===0||s?.isExpanded)&&s?.annotations?.forEach(p=>{this.componentConfigSignal.update(g=>(g=E({},g),g.virtualScrollData.push({type:"annotation",data:p}),g))}),t.push(...s?.annotations||[])}),this.componentConfigSignal.update(s=>(s=D(E({},s),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),s));let r=this.componentConfigSignal().embedMode||this.componentConfigSignal().sidebarVisible;this.commentService.setCommentsFromSidebarMap({comments:t,sidebarVisible:!!r}),this.componentConfigSignal.update(s=>(s=E({},s),s.filteredCommentAnnotationsCount=t?.length||0,s)),this.cd.markForCheck();let a=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;a&&(a.scrollTop=0)}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateVirtualScrollData: ",t)}}updateVirtualScrollDataGroupToggle(e){try{if(this.commentService.getSidebarCustomActionsValue()){this.componentConfigSignal.update(r=>(r=E({},r),r.virtualScrollData=[],r)),e?.forEach(r=>{r.type==="group"&&(this.componentConfigSignal.update(a=>(a=E({},a),a.virtualScrollData.push(r),a)),r?.data?.isExpanded&&r?.data?.annotations.forEach(a=>{this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData.push({type:"annotation",data:a}),s))}))}),this.componentConfigSignal.update(r=>(r=D(E({},r),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),r)),this.cd.markForCheck();let t=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;t&&(t.scrollTop=0)}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateVirtualScrollDataGroupToggle: ",t)}}getAllCommentsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllCommentsOnCurrentDocument","color: green;");try{this.getAllCommentAnnotationsSubscription&&this.getAllCommentAnnotationsSubscription.unsubscribe(),this.componentConfigSignal.update(e=>(e=D(E({},e),{skeletonLoading:!0}),e)),this.getAllCommentAnnotationsSubscription=this.commentService.getAllCommentAnnotations({excludeDomChanges:!0,skipPositionCalculation:!0,fromCommentSidebar:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsSidebar"}}}).pipe(de(e=>(e||this.componentConfigSignal.update(t=>(t=D(E({},t),{skeletonLoading:!0}),t)),e)),Le(e=>!!e),de(e=>e?.filter(t=>t?.comments?.length)),he(e=>this.commentService.getFilterGhostCommentsInSidebar$().pipe(he(t=>t?this.commentService.getGhostCommentAnnotationMap$().pipe(de(r=>r?e?.filter(a=>!r?.[a?.annotationId]):e)):le(e)))),he(e=>this.commentService.getExcludeLocationIdsFromSidebar$().pipe(de(t=>t?.length&&e?.length?e.filter(r=>r?.location?.id?!t.includes(r.location.id):!0):e))),he(e=>this.commentService.getResolvedCommentsOnDom$().pipe(de(t=>(this.resolvedCommentsOnDom!==t&&(this.resolvedCommentsOnDom=t,t&&this.setResolvedStatusInFilter()),e))))).subscribe(e=>{if(this.dataAvailable=!0,this.componentConfigSignal.update(t=>{if(t=D(E({},t),{skeletonLoading:!1}),t.annotations=e?.filter(r=>!r?.isPageAnnotation||r?.comments?.length)||[],t.sortData==="asc"?t.annotations=t.annotations?.sort((r,a)=>r.lastUpdated-a.lastUpdated):t.sortData==="none"?t.annotations=t.annotations?.sort((r,a)=>a.createdAt-r.createdAt):t.annotations=t.annotations?.sort((r,a)=>a.lastUpdated-r.lastUpdated),t?.focusedAnnotation?.annotationId){let r=e?.find(a=>a.annotationId===t?.focusedAnnotation?.annotationId);r&&(t.focusedAnnotation=r)}return t}),this.setPages(),this.setDocuments(),this.setVersions(),this.setPeople(),this.filterCommentAnnotations(),this.updateAnnotationCountsByFilter(),this.componentConfigSignal().annotations?.length){let t=sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID);if(t){sessionStorage.removeItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID),this.commentService.setSidebarVisibility(!0);let r=this.componentConfigSignal().annotations.find(a=>a.annotationId===t);r&&this.goToAnnotation(r)}this.componentConfigSignal().sidebarVisible&&!this.commentReadAnalyticsCalled&&this.setCommentReadInAnalytics()}this.componentConfigSignal.update(t=>(t=D(E({},t),{noCommentsFound:!this.componentConfigSignal().annotations?.length}),t))},e=>{this.loggingService.catch("Error in CommentsSidebarComponent getAllCommentsOnCurrentDocument subscription: ",e),this.componentConfigSignal.update(t=>(t=D(E({},t),{skeletonLoading:!1}),t))})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent getAllCommentsOnCurrentDocument: ",e)}}mergeClientFilters(e){try{if(Object.keys(e||{})?.length){if(e?.location&&(e?.location?.length?(this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{pages:[]})}),t)),e?.location?.forEach(t=>{if(t?.id&&(this.componentConfigSignal().filters?.pages||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{pages:[]})}),a)),!this.componentConfigSignal().filters.pages.find(a=>a.id===t.id))){let a=this.docService.genarateLocationId(t);this.componentConfigSignal.update(s=>(s=D(E({},s),{filters:D(E({},s.filters),{pages:[...s.filters.pages,{id:t.id,displayName:t.displayName,locationIds:[a],selected:!0}]})}),s))}})):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{pages:[]})}),t)),this.updatePageSelectedState()),e?.document&&(e?.document?.length?(this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{documents:[]})}),t)),e?.document?.forEach(t=>{(t?.id||t?.documentName)&&(this.componentConfigSignal().filters?.documents||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{documents:[]})}),a)),this.componentConfigSignal().filters.documents.find(a=>a.id===t.id||a.documentName===t.documentName)||this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{documents:[...a.filters.documents,{id:t.id||t.documentName,documentName:t.documentName||t.id,selected:!0}]})}),a)))})):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{documents:[]})}),t)),this.updateDocumentSelectedState()),e?.priority)if(e?.priority?.length){let t=e.priority;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{priorities:r.priorities.filter(a=>t.includes(a.id)),priorityIds:t})}),r))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{priorities:[],priorityIds:[]})}),t));if(e?.category)if(e?.category?.length){if(this.componentConfigSignal().commentCategoryMap){let t=e.category;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{categories:Object.values(r.commentCategoryMap).filter(a=>t.includes(a.id)),categoryIds:t})}),r))}}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{categories:[],categoryIds:[]})}),t));if(e?.status)if(e?.status?.length){let t=e.status;this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{statuses:r.statuses.filter(a=>t.includes(a.id)),statusIds:t})}),r))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{statuses:[],statusIds:[]})}),t));else sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)||this.setDefaultStatuses();if(e?.people){if(e?.people?.length){let t=[],r=this.componentConfigSignal().user;r&&e.people.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.people.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().peopleFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{people:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{people:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.assigned){if(e?.assigned?.length){let t=[],r=this.componentConfigSignal().user;r&&e.assigned.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.assigned.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().assignedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{assigned:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{assigned:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.tagged){if(e?.tagged?.length){let t=[],r=this.componentConfigSignal().user;r&&e.tagged.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.tagged.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().taggedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{tagged:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{tagged:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}if(e?.involved){if(e?.involved?.length){let t=[],r=this.componentConfigSignal().user;r&&e.involved.find(s=>s.userId&&s.userId===r?.userId||s.email&&s.email===r?.email)&&t.push({id:r.userId,name:r.name||r.email||r.userId||"",userId:r.userId,email:r.email}),e.involved.forEach(a=>{if(a?.userId||a?.email){let s=this.componentConfigSignal().involvedFilters.find(c=>a.userId&&c?.user?.userId===a.userId||a.email&&c?.user?.email===a.email);if(s&&s?.user?.userId!==r?.userId)t.push({id:s?.user?.userId,name:s?.user?.name,userId:s?.user?.userId,email:s?.user?.email});else{let c=a.userId;c&&c!==r?.userId&&t.push({id:c,name:a.name||a.email||a.userId,userId:a.userId,email:a.email})}}}),this.componentConfigSignal.update(a=>(a=D(E({},a),{filters:D(E({},a.filters),{involved:t})}),a))}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{involved:[]})}),t));this.setPeople(),this.updatePeopleSelectedState()}e?.version&&(e?.version?.length?this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{versions:e.version?.map(r=>({id:r.id,name:r.name||r.id}))||[],versionIds:e.version?.map(r=>r.id)||[]})}),t)):this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{versions:[],versionIds:[]})}),t)),this.setVersions()),Object.keys(this.componentConfigSignal().filterConfig).forEach(t=>{this.componentConfigSignal().filterConfig[t]?.type==="custom"&&Object.keys(e).includes(t)&&e?.[t]&&(e?.[t]?.length?this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{[t]:e[t]?.map(a=>({id:a.id,name:a.name||a.id}))||[],[t+"Ids"]:e[t]?.map(a=>a.id)||[]})}),r)):this.componentConfigSignal.update(r=>(r=D(E({},r),{filters:D(E({},r.filters),{[t]:[],[t+"Ids"]:[]})}),r)))}),this.filterCommentAnnotations(),this.updateAnnotationCountsByFilter(),this.setFiltersToStorage()}}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent mergeClientFilters: ",t)}}onCommentAnnotationClick(e){try{let t=this.commentService.getCommentAnnotationForClient(e);if(this.emitOnSidebarCommentClick(t),!this.componentConfigSignal().selection)return;this.componentConfigSignal().focusedThreadMode?this.componentConfigSignal.update(r=>(r=D(E({},r),{focusedAnnotation:e}),r)):this.navigateToComment(e,!1)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onCommentAnnotationClick: ",t)}}navigateToComment(e,t=!0){try{if(t){let r=this.commentService.getCommentAnnotationForClient(e);this.emitOnCommentNavigationButtonClick(r)}if(this.commentService.getSidebarUrlNavigation()&&t)if(e?.pageInfo?.url&&e.pageInfo?.url!==window.location.href){sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_SELECTED_ANNOTATION_ID,e.annotationId);let r=e.pageInfo.url;try{let a=window.location.origin,s=new URL(e.pageInfo.url).origin;a!==s&&(r=r.replace(s,a))}catch(a){this.loggingService.catch("Error in CommentsSidebarComponent onCommentAnnotationClick in comparing url domains: ",a)}window.location.href===r?this.goToAnnotation(e,t):window.location.href=r}else this.goToAnnotation(e,t);else this.goToAnnotation(e,t)}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent navigateToComment: ",r)}}goToAnnotation(e,t=!0){try{if(this.componentConfigSignal().selectedAnnotationsMap[e.annotationId]||e?.targetTextRange&&sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_AUTO_SELECT_ANNOTATION_ID,e?.annotationId),t)this.domService.toggleAnnotationSelection(e,void 0,void 0,!0);else{let r=this.componentConfigSignal().expandOnSelection?"sidebarShowReplies":void 0;this.domService.toggleAnnotationSelection(e,void 0,r,!0)}t&&setTimeout(()=>{let r=null;e.targetElement||e.areaAnnotationId?r=document.getElementById(`comment-pin-container-${e.annotationId}`):r=document.querySelector(`[data-velt-id='${e.annotationId}']`),r||(r=document.querySelector(`${U.TAGS.VELT_COMMENT_TEXT}[${U.ATTRIBUTES.ANNOTATION_ID}="${e.annotationId}"]`)),r&&r.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})},100)}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent goToAnnotation: ",r)}}goToAnnotationInSidebar(e,t="smooth"){try{let s=document?.querySelector(".velt-comments-sidebar-container")?.querySelector("velt-shadow-dom-internal")?.shadowRoot?.getElementById(`sidebar-${e.annotationId}`);s||(s=document.getElementById(`sidebar-${e.annotationId}`)),s&&s.scrollIntoView({behavior:t,block:"center",inline:"center"})}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent goToAnnotationInSidebar: ",r)}}saveComment(e,t){this.commentService.saveComment(e,t)}getDisplayNameFromPageInfo(e){try{return this.componentConfigSignal().queryParamsComments&&e&&e?.queryParams?`${e?.path||""}${e?.queryParams||""}`:e?.path||""}catch{return""}}setPages(){try{this.componentConfigSignal.update(a=>D(E({},a),{pages:{},currentPage:void 0}));let e=new Map,t={};this.componentConfigSignal().annotations.forEach(a=>{let s=a.locationId||a.documentParamsId;if(!s){t.other||(t.other={locationIds:[],displayName:"Others",id:"other"});return}let c=a?.location?.locationName||a?.documentParams?.locationName||this.getDisplayNameFromPageInfo(a?.pageInfo)||"",p=a?.location?.id||c;e.has(s)||(t[p]||(t[p]={locationIds:[],displayName:c,id:p}),e.set(s,p),t[p].locationIds.push(s))}),this.componentConfigSignal.update(a=>{let s=this.location?.locationId,c;if(s){let p=e.get(s);p&&(c=t[p].displayName)}else t.other&&(c="Others");return D(E({},a),{pages:t,currentPage:c})}),this.updateLocationInStorage(),this.componentConfigSignal().annotations?.length&&!sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)&&(this.updateFilter({key:"pages",value:null},!0),this.setDefaultStatuses()),this.updatePageSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setPages: ",e)}}setDocuments(){try{this.componentConfigSignal.update(a=>D(E({},a),{documents:{},currentDocument:void 0}));let e=new Map,t={};this.componentConfigSignal().annotations.forEach(a=>{let s=a?.metadata?.clientDocumentId?.toString(),c=a?.metadata?.documentId?.toString(),g=this.docService.getDocumentMetadata(c)?.documentName;if(!s){t.other||(t.other={id:"other",documentName:"Others"});return}if(e.has(s))return;let f=s;t[f]||(t[f]={id:s,documentName:g||s}),e.set(s,f)}),this.componentConfigSignal.update(a=>{let s=this.documentPaths?.clientDocumentId?.toString(),c;if(s){let p=e.get(s);p&&(c=t[p].id)}else t.other&&(c="other");return D(E({},a),{documents:t,currentDocument:c})}),this.componentConfigSignal().annotations?.length&&!sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)&&this.updateFilter({key:"documents",value:null},!0),this.updateDocumentSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setDocuments: ",e)}}setDefaultStatuses(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDefaultStatuses","color: green;"),this.componentConfigSignal.update(e=>(e=D(E({},e),{filters:D(E({},e.filters),{statuses:[this.customFilterService.defaultStatus,...this.customFilterService.ongoingStatuses],statusIds:[this.customFilterService.defaultStatus?.id,...this.customFilterService.ongoingStatuses.map(t=>t?.id)]})}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setDefaultStatuses: ",e)}}setResolvedStatusInFilter(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setResolvedStatusInFilter","color: green;"),this.componentConfigSignal().filters.statuses?.length&&this.customFilterService.resolvedStatus&&(this.componentConfigSignal().filters.statuses.find(t=>t?.id===this.customFilterService.resolvedStatus.id)||this.componentConfigSignal.update(t=>(t=D(E({},t),{filters:D(E({},t.filters),{statuses:[...t.filters.statuses,this.customFilterService.resolvedStatus],statusIds:[...t.filters.statuses.map(r=>r?.id),this.customFilterService.resolvedStatus.id]})}),t)))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setResolvedStatusInFilter: ",e)}}trackCommentPinAnnotations(e,t){return t?.type==="group"?t?.data?.displayName:t?.type==="annotation"?t?.data?.annotationId:e}updateCurrentLocationIdInStorage(){try{this.location?.locationId&&this.componentConfigSignal().filters?.pages?.length&&this.componentConfigSignal.update(e=>(e=E({},e),e.filters.pages.forEach(t=>{t?.displayName===e.currentPage&&(t?.locationIds?.includes(this.location?.locationId)||t.locationIds.push(this.location?.locationId))}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateCurrentLocationIdInStorage: ",e)}}updateLocationInStorage(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.filters.pages.forEach(t=>{e.pages[t.displayName]&&(t.locationIds=e.pages[t.displayName].locationIds?.slice())}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateLocationInStorage: ",e)}}updatePageSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.pages).forEach(t=>{let r=e.filters?.pages?.find(a=>a.id===t?.id);r?(t.selected=!0,r.displayName||(r.displayName=t.displayName)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updatePageSelectedState: ",e)}}setVersions(){try{let e=[];this.componentConfigSignal().annotations&&this.componentConfigSignal.update(t=>(t=E({},t),t.annotations.forEach(r=>{r?.location?.version&&(e.find(a=>a.id===r?.location?.version?.id)||e.push(r?.location?.version))}),t)),this.componentConfigSignal().filters?.versions?.length&&this.componentConfigSignal.update(t=>(t=E({},t),t.filters.versions.forEach(r=>{e.find(a=>a.id===r?.id)||r?.id!=="unset"&&e.push(r)}),t)),this.componentConfigSignal.update(t=>(t=E({},t),t.versions=e?.sort((r,a)=>r?.id?.localeCompare(a?.id)),t.versions.push({id:"unset",name:"Not set"}),t)),this.componentConfigSignal().annotations?.length&&!this.componentConfigSignal().versions?.length&&this.updateFilter({key:"versions",value:null},!0)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setVersions: ",e)}}setPeople(){try{let e=[],t=[],r=[],a=[],s=this.componentConfigSignal().user;s?.userId&&(e.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),t.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),r.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s}),a.push({id:s.userId,name:s.name||s.email||s.userId||"",user:s})),this.componentConfigSignal().annotations&&this.componentConfigSignal.update(c=>(c=E({},c),c.annotations.forEach(p=>{p?.from?.userId&&c.user?.userId!==p?.from?.userId&&!e.find(g=>g.id===p?.from?.userId)&&e.push({id:p?.from?.userId,name:`${p?.from?.name||p?.from?.email}`,user:p?.from}),p?.assignedTo?.userId&&c.user?.userId!==p?.assignedTo?.userId&&!t.find(g=>g.id===p?.assignedTo?.userId)&&t.push({id:p?.assignedTo?.userId,name:`${p?.assignedTo?.name||p?.assignedTo?.email}`,user:p?.assignedTo}),p?.comments?.forEach(g=>{g?.taggedUserContacts?.forEach(f=>{f?.contact?.userId&&c.user?.userId!==f?.contact?.userId&&!r.find(I=>I.id===f?.contact?.userId)&&r.push({id:f?.contact?.userId,name:`${f?.contact?.name||f?.contact?.email}`,user:f?.contact})})}),p?.from?.userId&&c.user?.userId!==p?.from?.userId&&!a.find(g=>g.id===p?.from?.userId)&&a.push({id:p?.from?.userId,name:`${p?.from?.name||p?.from?.email}`,user:p?.from}),p?.assignedTo?.userId&&c.user?.userId!==p?.assignedTo?.userId&&!a.find(g=>g.id===p?.assignedTo?.userId)&&a.push({id:p?.assignedTo?.userId,name:`${p?.assignedTo?.name||p?.assignedTo?.email}`,user:p?.assignedTo}),p?.comments?.forEach(g=>{g?.taggedUserContacts?.forEach(f=>{f?.contact?.userId&&c.user?.userId!==f?.contact?.userId&&!a.find(I=>I.id===f?.contact?.userId)&&a.push({id:f?.contact?.userId,name:`${f?.contact?.name||f?.contact?.email}`,user:f?.contact})})})}),c)),this.componentConfigSignal().filters?.people?.length&&this.componentConfigSignal.update(c=>(c=E({},c),c.filters.people.forEach(p=>{e.find(g=>g.id===p?.id)||p?.id!=="other"&&e.push(p)}),c.filters.assigned.forEach(p=>{t.find(g=>g.id===p?.id)||p?.id!=="other"&&t.push(p)}),c.filters.tagged.forEach(p=>{r.find(g=>g.id===p?.id)||p?.id!=="other"&&r.push(p)}),c.filters.involved.forEach(p=>{a.find(g=>g.id===p?.id)||p?.id!=="other"&&a.push(p)}),c)),this.componentConfigSignal.update(c=>(c=D(E({},c),{peopleFilters:e,assignedFilters:t,taggedFilters:r,involvedFilters:a}),c)),this.componentConfigSignal().annotations?.length&&(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS)||(this.updateFilter({key:"people",value:null},!0),this.updateFilter({key:"assigned",value:null},!0),this.updateFilter({key:"tagged",value:null},!0),this.updateFilter({key:"involved",value:null},!0))),this.updatePeopleSelectedState()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setPeople: ",e)}}updatePeopleSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.peopleFilters.forEach(t=>{let r=e.filters?.people?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.assignedFilters.forEach(t=>{let r=e.filters?.assigned?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.taggedFilters.forEach(t=>{let r=e.filters?.tagged?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e.involvedFilters.forEach(t=>{let r=e.filters?.involved?.find(a=>a.id===t?.id||a?.userId&&a?.userId===t?.user?.userId||a?.email&&a?.email===t?.user?.email);r?(t.selected=!0,r?.id||(r.id=t?.user?.userId)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updatePeopleSelectedState: ",e)}}updateFilterConfig(e){try{if(e){let t=this.componentConfigSignal().filters,r=JSON.parse(sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS));r||(r={}),Object.keys(e).forEach(a=>{e[a]?.type==="custom"&&(r[a]?(t[a]=r[a],t[a+"Ids"]=r[a+"Ids"]):(t[a]=[],t[a+"Ids"]=[]))}),this.componentConfigSignal.update(a=>{let s=E(E({},this.defaultFilterConfig),e);return a=D(E({},a),{filterConfig:s,filters:t}),a}),this.setFiltersToStorage()}else this.componentConfigSignal.update(t=>(t=D(E({},t),{filterConfig:JSON.parse(JSON.stringify(this.defaultFilterConfig))}),t));this.updateGroupByOptions(),this.filterCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent updateFilterConfig: ",t)}}updateGroupByOptions(){try{let e={};this.componentConfigSignal.update(r=>(r=E({},r),Object.keys(r.filterConfig).forEach(a=>{let s=r.filterConfig[a];s.enableGrouping&&(e[a]=s.name)}),r.groupByOptions=JSON.parse(JSON.stringify(e)),r));let t=!1;this.componentConfigSignal().groupBy&&Object.keys(this.componentConfigSignal().groupByOptions).forEach(r=>{this.componentConfigSignal().groupByOptions[r]===this.componentConfigSignal().groupBy&&(t=!0)}),(!this.componentConfigSignal().groupBy||!t)&&this.componentConfigSignal.update(r=>(r=D(E({},r),{groupBy:Object.values(r.groupByOptions)[0]}),r))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateGroupByOptions: ",e)}}updateFilter(e,t=!1){let{key:r,value:a}=e;try{if(r)switch(r){case"statuses":if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{statuses:[],statusIds:[]})}),g)),this.resolvedCommentsOnDom=!0;else{let g=this.componentConfigSignal().filters?.statuses||[];g.find(f=>f.id===a.id)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.statuses=g.filter(I=>I.id!==a.id),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters.statuses=[...g,a],f)),this.componentConfigSignal.update(f=>(f=D(E({},f),{filters:D(E({},f.filters),{statusIds:f.filters.statuses.map(I=>I?.id)})}),f))}break;case"pages":let s=this.componentConfigSignal().filters.pages||[];if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{pages:[]})}),g));else{let g=a?.id||a?.displayName;s.find(f=>f?.id===g||f?.displayName===g)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=s.filter(I=>I?.id!==g&&I?.displayName!==g),f)):this.componentConfigSignal().filterConfig?.location?.multiSelection?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=[...s,a],f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters.pages=[a],f))}this.sortPageFilters(),this.updatePageSelectedState();break;case"documents":let c=this.componentConfigSignal().filters.documents||[];if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{documents:[]})}),g));else{let g=a?.id;c.find(f=>f?.id===g)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters.documents=c.filter(I=>I?.id!==g),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filterConfig?.document?.multiSelection?f.filters.documents=[...c,a]:f.filters.documents=[a],f))}this.updateDocumentSelectedState();break;case"people":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.people||[];return t?g.filters.people=[]:f.find(I=>I?.id===a?.id)?g.filters.people=f.filter(I=>I?.id!==a?.id):g.filterConfig?.people?.multiSelection?g.filters.people=[...f,a]:g.filters.people=[a],g}),this.updatePeopleSelectedState();break;case"tagged":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.tagged||[];return t?g.filters.tagged=[]:f.find(I=>I?.id===a?.id)?g.filters.tagged=f.filter(I=>I?.id!==a?.id):g.filterConfig?.tagged?.multiSelection?g.filters.tagged=[...f,a]:g.filters.tagged=[a],g}),this.updatePeopleSelectedState();break;case"assigned":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.assigned||[];return t?g.filters.assigned=[]:f.find(I=>I?.id===a?.id)?g.filters.assigned=f.filter(I=>I?.id!==a?.id):g.filterConfig?.assigned?.multiSelection?g.filters.assigned=[...f,a]:g.filters.assigned=[a],g}),this.updatePeopleSelectedState();break;case"involved":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.involved||[];return t?g.filters.involved=[]:f.find(I=>I?.id===a?.id)?g.filters.involved=f.filter(I=>I?.id!==a?.id):g.filterConfig?.involved?.multiSelection?g.filters.involved=[...f,a]:g.filters.involved=[a],g}),this.updatePeopleSelectedState();break;case"categories":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.categories||[];return t?g.filters.categories=[]:f.find(I=>I.id===a.id)?g.filters.categories=f.filter(I=>I!==a):g.filterConfig?.category?.multiSelection?g.filters.categories=[...f,a]:g.filters.categories=[a],g.filters.categoryIds=g.filters.categories?.map(I=>I.id),g});break;case"priorities":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.priorities||[];return t?g.filters.priorities=[]:f.find(I=>I.id===a.id)?g.filters.priorities=f.filter(I=>I.id!==a.id):g.filterConfig?.priority?.multiSelection?g.filters.priorities=[...f,a]:g.filters.priorities=[a],g.filters.priorityIds=g.filters.priorities?.map(I=>I.id),g});break;case"accessModes":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.accessModes||[];return t?g.filters.accessModes=[]:f.find(I=>I===a.id)?g.filters.accessModes=f.filter(I=>I!==a.id):g.filterConfig?.commentType?.multiSelection?g.filters.accessModes=[...f,a.id]:g.filters.accessModes=[a.id],g});break;case"versions":this.componentConfigSignal.update(g=>{g=E({},g);let f=g.filters.versions||[];return t?g.filters.versions=[]:f.find(I=>I.id===a.id)?g.filters.versions=f.filter(I=>I.id!==a.id):g.filterConfig?.version?.multiSelection?g.filters.versions=[...f,a]:g.filters.versions=[a],g.filters.versionIds=g.filters.versions?.map(I=>I?.id),g});break;default:let p=r+"Ids";if(this.componentConfigSignal().filterConfig[r]?.type==="custom")if(t)this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{[r]:[],[p]:[]})}),g)),this.resolvedCommentsOnDom=!0;else{let g=this.componentConfigSignal().filters?.[r]||[];this.componentConfigSignal().filterConfig[r]?.multiSelection?g.find(f=>f.id===a.id)?this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=g.filter(I=>I.id!==a.id),f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=[...g,a],f)):this.componentConfigSignal.update(f=>(f=E({},f),f.filters[r]=[a],f)),this.componentConfigSignal.update(f=>(f=D(E({},f),{filters:D(E({},f.filters),{[p]:f.filters[r].map(I=>I?.id)})}),f))}else this.componentConfigSignal.update(g=>(g=D(E({},g),{filters:D(E({},g.filters),{[r]:a})}),g));break}this.filterCommentAnnotations(),this.setFiltersToStorage()}catch(s){this.loggingService.catch("Error in CommentsSidebarComponent updateFilter: ",s)}}sortPageFilters(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.filters?.pages?.sort((t,r)=>t?.id===e.location?.location?.id?-1:r?.id===e.location?.location?.id?1:t?.displayName?.localeCompare(r?.displayName)),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent sortPageFilters: ",e)}}updateAnnotationCountsByFilter(){try{if(!this.componentConfigSignal().filterCount)return;this.setAnnotationsCountPerPage(),this.setAnnotationsCountPerDocument(),this.setAnnotationsCountPerStatus(),this.setAnnotationsCountPerPeople(),this.setAnnotationsCountPerVersion(),this.setAnnotationsCountPerPriority(),this.setAnnotationsCountPerCommentCategory(),this.setAnnotationsCountPerAccessMode()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateAnnotationCountsByFilter: ",e)}}setAnnotationsCountPerPage(){try{this.componentConfigSignal().pages&&this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.pages).forEach(t=>{e.commentAnnotationsCountByFilters.page[t.id]=this.filterAnnotationsByPage(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPage: ",e)}}setAnnotationsCountPerDocument(){try{this.componentConfigSignal().documents&&this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.documents).forEach(t=>{e.commentAnnotationsCountByFilters.document[t.id]=this.filterAnnotationsByDocument(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerDocument: ",e)}}setAnnotationsCountPerStatus(){try{let e=this.componentConfigSignal();[this.customFilterService.defaultStatus,...this.customFilterService.ongoingStatuses,this.customFilterService.resolvedStatus].forEach(t=>{e.commentAnnotationsCountByFilters.status[t.id]=this.filterAnnotationsByStatus(t,e.annotations)?.length}),this.componentConfigSignal.update(t=>(t=D(E({},t),{commentAnnotationsCountByFilters:E({},t.commentAnnotationsCountByFilters)}),t))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerStatus: ",e)}}setAnnotationsCountPerPeople(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.peopleFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.people[t.id]=this.filterAnnotationsByPeople(t,e.annotations)?.length}),e.taggedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.tagged[t.id]=this.filterAnnotationsByTagged(t,e.annotations)?.length}),e.assignedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.assigned[t.id]=this.filterAnnotationsByAssigned(t,e.annotations)?.length}),e.involvedFilters?.forEach(t=>{e.commentAnnotationsCountByFilters.involved[t.id]=this.filterAnnotationsByInvolved(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPerson: ",e)}}setAnnotationsCountPerPriority(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.priorities.forEach(t=>{e.commentAnnotationsCountByFilters.priority[t.id]=this.filterAnnotationsByPriority(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerPriority: ",e)}}setAnnotationsCountPerCommentCategory(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.commentCategoryMap).forEach(t=>{e.commentAnnotationsCountByFilters.commentCategory[t.id]=this.filterAnnotationsByCommentCategory(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerCommentCategory: ",e)}}setAnnotationsCountPerAccessMode(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.accessModes.forEach(t=>{e.commentAnnotationsCountByFilters.accessMode[t.id]=this.filterAnnotationsByAccessMode(t.id,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerAccessMode: ",e)}}setAnnotationsCountPerVersion(){try{this.componentConfigSignal.update(e=>(e=E({},e),e.versions.forEach(t=>{e.commentAnnotationsCountByFilters.version[t.id]=this.filterAnnotationsByVersion(t,e.annotations)?.length}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setAnnotationsCountPerVersion: ",e)}}filterCommentAnnotations(){try{let e=this.componentConfigSignal(),t=!1,r=e.annotations.slice(),a=[],s=e.systemFiltersOperator;s===dd.AND?a=e.annotations.slice():a=[],e.appliedFiltersCount=0;let c=!1,p=new Set,g=I=>{try{s===dd.AND?a=a.filter(T=>I.some(B=>B.annotationId===T.annotationId)):I.forEach(T=>{p.add(T.annotationId)}),c=!0}catch{}};if(e.enablePriority&&e.filterConfig?.priority?.enable&&e.filters.priorities?.length){let I=[];e.filters.priorities?.forEach(T=>{I=[...I,...this.filterAnnotationsByPriority(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.location?.enable&&e.filters.pages?.length){let I=[];e.filters.pages?.forEach(T=>{I=[...I,...this.filterAnnotationsByPage(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filters.documents?.length){let I=[];e.filters.documents?.forEach(T=>{I=[...I,...this.filterAnnotationsByDocument(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.people?.enable&&e.filters.people?.length){let I=[];e.filters.people?.forEach(T=>{I=[...I,...this.filterAnnotationsByPeople(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.tagged?.enable&&e.filters.tagged?.length){let I=[];e.filters.tagged?.forEach(T=>{I=[...I,...this.filterAnnotationsByTagged(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.assigned?.enable&&e.filters.assigned?.length){let I=[];e.filters.assigned?.forEach(T=>{I=[...I,...this.filterAnnotationsByAssigned(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.involved?.enable&&e.filters.involved?.length){let I=[];e.filters.involved?.forEach(T=>{I=[...I,...this.filterAnnotationsByInvolved(T,r)]}),g(I),e.appliedFiltersCount++}if(e.enableAutoCategorize&&e.filterConfig?.category?.enable&&e.filters.categories?.length){let I=[];e.filters.categories?.forEach(T=>{I=[...I,...this.filterAnnotationsByCommentCategory(T,r)]}),g(I),e.appliedFiltersCount++}if(e.isPrivateCommentAllowed&&e.filterConfig?.commentType?.enable&&e.filters.accessModes?.length){let I=[];e.filters.accessModes?.forEach(T=>{I=[...I,...this.filterAnnotationsByAccessMode(T,r)]}),g(I),e.appliedFiltersCount++}if(e.filterConfig?.version?.enable&&e.filters.versions?.length){let I=[];e.filters.versions?.forEach(T=>{I=[...I,...this.filterAnnotationsByVersion(T,r)]}),g(I),e.appliedFiltersCount++}if(e.enableStatus&&e.filters.statuses?.length){let I=[];e.filters.statuses?.forEach(T=>{T.id===this.customFilterService.resolvedStatus.id&&(t=!0),I=[...I,...this.filterAnnotationsByStatus(T,r)]}),g(I),e?.filterConfig?.status?.enable&&e.appliedFiltersCount++}s!==dd.AND&&(c?a=r.filter(I=>p.has(I.annotationId)):a=r),e.filters.input&&(a=this.filterAnnotationsByInput(e.filters.input,a));let f=a.slice();if(e.minimalFilter){!t&&e.minimalFilter==="resolved"||e.minimalFilter==="reset"?a=e.annotations.slice():a=f.slice();let I=a.length,T=0,B=0,z=0,G=0,J=0,ne=0;a=a.filter(ve=>{let ye=!1;switch(e.minimalFilter){case"all":!t&&!this.resolvedCommentsOnDom?ye=ve.status?.id!==this.customFilterService.resolvedStatus.id:ye=!0,ye&&z++;break;case"read":ye=!this.componentConfigSignal().unreadCommentsMap?.[ve.annotationId]&&ve.status?.id!==this.customFilterService.resolvedStatus.id,ye&&ne++;break;case"unread":let Ne=!!this.componentConfigSignal().unreadCommentsMap?.[ve.annotationId],Ve=ve.status?.id!==this.customFilterService.resolvedStatus.id,Ie=!!this.componentConfigSignal().selectedAnnotationsMap[ve.annotationId];ye=Ne&&Ve||Ie,ye&&B++;break;case"open":ye=ve.status?.type==="default",ye&&G++;break;case"resolved":ye=ve.status?.id===this.customFilterService.resolvedStatus.id,ye&&J++;break;case"reset":ye=!0,ye&&T++;break;default:ye=!0;break}return ye})}if(this.componentConfigSignal.update(I=>(I=D(E(E({},I),e),{filteredCommentPinAnnotations:a}),I)),!this.commentService.getSidebarCustomActionsValue()){let I=this.componentConfigSignal().embedMode||this.componentConfigSignal().sidebarVisible;this.commentService.setCommentsFromSidebarMap({comments:this.componentConfigSignal().skeletonLoading?void 0:a,sidebarVisible:!!I}),this.componentConfigSignal.update(T=>(T=E({},T),T.filteredCommentAnnotationsCount=a?.length||0,T))}this.groupFilteredCommentAnnotations(),this.componentConfigSignal().sortData||this.sortComments(this.componentConfigSignal().selectedMinimalFilterDropdownOption.sorting)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent filterCommentAnnotations: ",e)}}toggleGroupedCommentAnnotations(e){try{e.isExpanded=!e.isExpanded,this.commentService.getSidebarCustomActionsValue()?(this.componentConfigSignal.update(t=>(t=E({},t),t)),this.updateVirtualScrollDataGroupToggle(this.componentConfigSignal().virtualScrollData)):this.setSidebarGroupedAnnotationsData()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent toggleGroupedCommentAnnotations: ",t)}}changeGroupBy(e){try{this.componentConfigSignal.update(t=>(t=E({},t),e?e===t.groupBy?t.groupBy=null:t.groupBy=e:t.groupBy=null,t)),sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_GROUP_BY,this.componentConfigSignal().groupBy||""),this.groupFilteredCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent changeGroupBy: ",t)}}groupFilteredCommentAnnotations(){try{let e=this.filteredGroupedCommentAnnotationsObj,t=this.componentConfigSignal(),r=t.systemFiltersOperator===dd.AND;switch(t.groupBy){case t.groupByOptions.people:let a=t.filters.people?.length&&r?t.filters.people:t.peopleFilters;this.filteredGroupedCommentAnnotationsObj={},a.forEach(G=>{let J=this.filterAnnotationsByPeople(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.peopleFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.assigned:let s=t.filters.assigned?.length&&r?t.filters.assigned:t.assignedFilters;this.filteredGroupedCommentAnnotationsObj={},s.forEach(G=>{let J=this.filterAnnotationsByAssigned(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.assignedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.tagged:let c=t.filters.tagged?.length&&r?t.filters.tagged:t.taggedFilters;this.filteredGroupedCommentAnnotationsObj={},c.forEach(G=>{let J=this.filterAnnotationsByTagged(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.taggedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.involved:let p=t.filters.involved?.length&&r?t.filters.involved:t.involvedFilters;this.filteredGroupedCommentAnnotationsObj={},p.forEach(G=>{let J=this.filterAnnotationsByInvolved(G,this.componentConfigSignal().filteredCommentPinAnnotations),ne=t.user?.userId===G.id;J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:ne?"Me":G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.involvedFilters.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])});break;case t.groupByOptions.page:case t.groupByOptions.location:t=this.componentConfigSignal();let g=t.filters.pages?.length&&r?t.filters.pages:Object.values(t.pages||{});g?.sort((G,J)=>G?.id===t.location?.location?.id||!t.location?.location?.id&&G?.id==="other"?-1:J?.id===t.location?.location?.id||!t.location?.location?.id&&J?.id==="other"?1:0),this.filteredGroupedCommentAnnotationsObj={},g.forEach(G=>{let J=G?.id===t?.location?.location?.id||G?.id==="other"&&!t?.location?.location?.id;this.locations&&Object.keys(this.locations||{}).forEach(ve=>{let ye=this.locations[ve]?.location;ye?.id&&ye?.id===G?.id&&(J=!0)});let ne=this.filterAnnotationsByPage(G,this.componentConfigSignal().filteredCommentPinAnnotations);if((G.id||G?.displayName)&&ne?.length){let ve=G.id||G?.displayName||"";this.filteredGroupedCommentAnnotationsObj[ve]={displayName:G.displayName,annotations:ne,isExpanded:e[ve]?e[ve]?.isExpanded:!!J}}}),this.filteredGroupedCommentAnnotations=[];let f=t?.filterConfig?.location?.order||[];if(f?.length){let G=J=>{let ne=f.indexOf(J?.id);return ne===-1?1/0:ne};g.sort((J,ne)=>{let ve=G(J),ye=G(ne);return ve!==ye?ve-ye:g.indexOf(J)-g.indexOf(ne)})}g.forEach(G=>{let J=G.id||G?.displayName||"";J&&this.filteredGroupedCommentAnnotationsObj[J]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[J])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.priority:let I=t.filters.priorities?.length&&r?t.filters.priorities:t.priorities;this.filteredGroupedCommentAnnotationsObj={},I.forEach(G=>{let J=this.filterAnnotationsByPriority(G,this.componentConfigSignal().filteredCommentPinAnnotations);J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],t.priorities.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.category:let T=t.filters.categories?.length&&r?t.filters.categories:Object.values(t.commentCategoryMap||{});this.filteredGroupedCommentAnnotationsObj={},T.forEach(G=>{let J=this.filterAnnotationsByCommentCategory(G,this.componentConfigSignal().filteredCommentPinAnnotations);J?.length&&(this.filteredGroupedCommentAnnotationsObj[G.id]={displayName:G.name,annotations:J,isExpanded:e[G.id]?e[G.id]?.isExpanded:!0})}),this.filteredGroupedCommentAnnotations=[],T.forEach(G=>{this.filteredGroupedCommentAnnotationsObj[G.id]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[G.id])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;case t.groupByOptions.document:t=this.componentConfigSignal();let B=t.filters.documents?.length&&r?t.filters.documents:Object.values(t.documents||{});B?.sort((G,J)=>G?.id===t.currentDocument?-1:J?.id===t.currentDocument?1:0),this.filteredGroupedCommentAnnotationsObj={},B.forEach(G=>{let J=G?.id===t?.currentDocument,ne=this.filterAnnotationsByDocument(G,this.componentConfigSignal().filteredCommentPinAnnotations);if(G.id&&ne?.length){let ve=G.id||"";this.filteredGroupedCommentAnnotationsObj[ve]={displayName:G.documentName||G.id||"",annotations:ne,isExpanded:e[ve]?e[ve]?.isExpanded:!!J}}}),this.filteredGroupedCommentAnnotations=[];let z=t?.filterConfig?.document?.order||[];if(z?.length){let G=J=>{let ne=z.indexOf(J?.id);return ne===-1?1/0:ne};B.sort((J,ne)=>{let ve=G(J),ye=G(ne);return ve!==ye?ve-ye:B.indexOf(J)-B.indexOf(ne)})}B.forEach(G=>{let J=G.id;J&&this.filteredGroupedCommentAnnotationsObj[J]&&this.filteredGroupedCommentAnnotations.push(this.filteredGroupedCommentAnnotationsObj[J])}),this.componentConfigSignal.update(G=>(G=E(E({},G),t),G));break;default:this.filteredGroupedCommentAnnotationsObj={},this.filteredGroupedCommentAnnotationsObj={[this.pageTypes.all]:{displayName:this.pageTypes.all,annotations:this.componentConfigSignal().filteredCommentPinAnnotations,isExpanded:e[this.pageTypes.all]?e[this.pageTypes.all]?.isExpanded:!0}},this.filteredGroupedCommentAnnotations=[this.filteredGroupedCommentAnnotationsObj[this.pageTypes.all]];break}this.setSidebarGroupedAnnotationsData()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent groupFilteredCommentAnnotations: ",e)}}setSidebarGroupedAnnotationsData(){try{if(this.commentService.getSidebarCustomActionsValue()){if(this.commentService.getSidebarCustomActionsValue()&&this.dataAvailable){let e={};Object.keys(this.componentConfigSignal().filterConfig||{}).forEach(t=>{this.componentConfigSignal().filterConfig[t]?.type==="custom"&&(e[t]=this.componentConfigSignal().filterConfig[t]?.options?.map(r=>({id:r.id,name:r.name,selected:this.componentConfigSignal().filters[t+"Ids"]?.includes(r.id)})))}),this.componentConfigSignal.update(t=>(t=D(E({},t),{customFilters:e}),t)),this.commentService.getSidebarCustomActionEventDataOnInitValue()?this.commentService.setSidebarCustomActionEventDataAllChanges(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,e):this.commentService.setSidebarCustomActionEventDataOnInit(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,e)}}else{let e=this.filteredGroupedCommentAnnotations.length===1&&this.filteredGroupedCommentAnnotations[0].displayName==="Others";this.componentConfigSignal.update(r=>(r=E({},r),r.virtualScrollData=[],r)),this.filteredGroupedCommentAnnotations.forEach(r=>{!e&&r.annotations?.length&&this.componentConfigSignal.update(a=>(a=E({},a),a.virtualScrollData.push({type:"group",data:r}),a)),(r.isExpanded||e)&&r.annotations.forEach(a=>{this.componentConfigSignal.update(s=>(s=E({},s),s.virtualScrollData.push({type:"annotation",data:a}),s))})}),this.componentConfigSignal.update(r=>(r=D(E({},r),{noCommentsFoundForAppliedFilters:!this.componentConfigSignal().virtualScrollData?.length}),r)),this.cd.markForCheck();let t=this.componentConfigSignal().virtualScrollViewportRef?.elementRef?.nativeElement;t&&(t.scrollTop=0)}}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setSidebarGroupedAnnotationsData: ",e)}}filterAnnotationsByPage(e,t){try{return t?.filter(r=>e?.locationIds?.length?r?.locationId?r?.location?.id===e?.id||e?.locationIds?.includes(r?.locationId):r?.documentParams?.id===e?.id||e?.locationIds?.includes(r?.documentParamsId):!r?.locationId&&!r?.documentParamsId)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPage: ",r),[]}}filterAnnotationsByStatus(e,t){try{return t.filter(r=>r?.status?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByStatus: ",r),[]}}filterAnnotationsByPeople(e,t){try{return e.id?t.filter(r=>r?.from?.userId===e?.id||r?.from?.email===e?.id):t}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPeople: ",r),[]}}filterAnnotationsByTagged(e,t){try{return e.id===this.componentConfigSignal().user?.userId?t.filter(r=>{let a=!1;return r.comments.forEach(s=>{s.taggedUserContacts?.forEach(c=>{c?.contact?.userId===this.componentConfigSignal().user?.userId&&(a=!0)})}),a}):t.filter(r=>r?.comments?.some(a=>a?.taggedUserContacts?.some(s=>s?.contact?.userId===e?.id)))}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByTagged: ",r),[]}}filterAnnotationsByAssigned(e,t){try{return e.id===this.componentConfigSignal().user?.userId?t.filter(r=>r?.assignedTo?.userId===this.componentConfigSignal().user?.userId):t.filter(r=>r?.assignedTo?.userId===e?.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByAssigned: ",r),[]}}filterAnnotationsByInvolved(e,t){try{return t.filter(r=>{let a=r?.from?.userId===e?.id||r?.from?.email===e?.id,s=r?.assignedTo?.userId===e?.id,c=r?.comments?.some(p=>p?.taggedUserContacts?.some(g=>g?.contact?.userId===e?.id));return a||s||c})}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByInvolved: ",r),[]}}filterAnnotationsByPriority(e,t){try{return e.id==="unset"?t.filter(r=>!r?.priority):t.filter(r=>r?.priority?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByPriority: ",r),[]}}filterAnnotationsByCommentCategory(e,t){try{switch(e?.id){case"other":return t?.filter(r=>!r?.commentCategories?.length||r?.commentCategories?.find(a=>a?.id===e?.id))}return t?.filter(r=>(r?.commentCategories||[])?.find(a=>a?.id===e?.id))}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByCommentCategory: ",r),[]}}filterAnnotationsByAccessMode(e,t){try{return e===uo.PRIVATE?t.filter(r=>r?.iam?.accessMode===uo.PRIVATE):t.filter(r=>!r?.iam?.accessMode||r?.iam?.accessMode===uo.PUBLIC)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByAccessMode: ",r),[]}}filterAnnotationsByVersion(e,t){try{return e.id==="unset"?t.filter(r=>!r?.location?.version):t.filter(r=>r?.location?.version?.id===e.id)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByVersion: ",r),[]}}filterAnnotationsByInput(e,t){try{let r=e.match(/^#(\d+)$/);if(r){let a=parseInt(r[1]);return t.filter(s=>s.annotationNumber===a)}return t.filter(a=>{let s=!1;for(let c=0;c<a?.comments?.length;c++){let p=a?.comments[c];if(p?.commentText?.toLowerCase().includes(e.toLowerCase())){s=!0;break}else if(p?.from?.name?.toLowerCase().includes(e.toLowerCase())){s=!0;break}}return s})}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByInput: ",r),[]}}closeSidebar(){try{this.commentService.setSidebarVisibility(!1,!1,!0),this.onSidebarClose.emit()}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent closeSidebar: ",e)}}emitOnSidebarCommentClick(e){try{let t=this.documentPaths?.clientDocumentId,r=e?.location;r||(r=e?.documentParams);let a={};e.context&&(a=e.context),this.onSidebarCommentClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.onSidebarCommentClickEvent.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.onCommentClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e}),this.commentService.onSidebarCommentClick({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onSidebarCommentClick: ",t)}}emitOnCommentNavigationButtonClick(e){try{let t=this.documentPaths?.clientDocumentId,r=e?.location;r||(r=e?.documentParams);let a={};e.context&&(a=e.context),this.onCommentNavigationButtonClick.emit({documentId:t,location:r,targetElementId:e?.targetElementId,context:a,annotation:e})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent emitOnCommentNavigationButtonClick: ",t)}}setFiltersToStorage(){try{let e=JSON.parse(JSON.stringify(this.componentConfigSignal().filters));delete e?.input;let t=JSON.stringify(e);sessionStorage.setItem(U.SESSION_STORAGE.SNIPPYLY_COMMENT_SIDEBAR_FILTERS,t)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setFiltersToStorage: ",e)}}setCommentSidebarInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(sf.COMMENT_SIDEBAR)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarInstalledInAnalytics: ",e)}}setCommentSidebarEmbedModeInAnalytics(){try{this.componentConfigSignal().embedMode&&this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_EMBED_MODE_ENABLED,{commentMode:this.commentService.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarEmbedModeInAnalytics: ",e)}}setCommentSidebarFloatingModeInAnalytics(){try{this.componentConfigSignal().floatingMode&&this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_SIDEBAR_FLOATING_MODE_ENABLED,{commentMode:this.commentService.getCommentMode()})}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentSidebarFloatingModeInAnalytics: ",e)}}setCommentReadInAnalytics(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setCommentReadInAnalytics","color: green;"),this.commentReadAnalyticsCalled||(this.commentReadAnalyticsCalled=!0,this.analyticsService.trackEvent(Y.Events.Comments.COMMENT_READ,{uiLocation:"sidebar",commentMode:this.commentService.getCommentMode(),readType:"hover"}))}catch(e){this.loggingService.catch("Error in CommentDialogComponent setCommentReadInAnalytics: ",e)}}toggleMoreFilters(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!t.moreFiltersVisible}),t)),e&&e?.scrollTo({top:0})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent toggleMoreFilters: ",t)}}closeMoreFilters(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!1,filterRecentlyClosed:!0}),t)),e&&e?.scrollTo({top:0}),setTimeout(()=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{filterRecentlyClosed:!1}),t))},100)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent closeMoreFilters: ",t)}}openMoreFilters(e){try{if(this.componentConfigSignal().filterRecentlyClosed)return;this.componentConfigSignal.update(t=>(t=D(E({},t),{moreFiltersVisible:!0}),t)),e&&e?.scrollTo({top:0})}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent openMoreFilters: ",t)}}savePageComment(e){try{let t=e?.updatedComment;t&&this.commentService.addComment(void 0,void 0,void 0,void 0,!0,[t],void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,e?.annotation?.assignedTo,void 0,void 0,this.componentConfigSignal().context),this.componentConfigSignal.update(r=>(r=E({},r),r.pageCommentAnnotation=new Zo,r.pageCommentAnnotation.isPageAnnotation=!0,r))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent savePageComment: ",t)}}sortComments(e){try{this.componentConfigSignal.update(t=>{let r=[...t.virtualScrollData];return r.sort((a,s)=>{if(a.type==="annotation"&&s.type==="annotation"){if(e==="date"){let c=new Date(a.data.lastUpdated).getTime();return new Date(s.data.lastUpdated).getTime()-c}else if(e==="unread"){let c=t.unreadCommentsMap?.[a.data.annotationId]||0,p=t.unreadCommentsMap?.[s.data.annotationId]||0;if(c>0&&p===0)return-1;if(c===0&&p>0)return 1;let g=new Date(a.data.lastUpdated).getTime();return new Date(s.data.lastUpdated).getTime()-g}}return 0}),t=D(E({},t),{virtualScrollData:r}),t}),this.componentConfigSignal.update(t=>(t=D(E({},t),{minimalFilterDropdownOpen:!1,selectedMinimalFilterDropdownOption:D(E({},t.selectedMinimalFilterDropdownOption),{sorting:e})}),t))}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent sortComments: ",t)}}toggleMinimalFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalFilterDropdownOpen:!e.minimalFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleMinimalFilterDropdown: ",e)}}filterCommentsByReadStatus(e){try{this.componentConfigSignal.update(t=>(t=D(E({},t),{minimalFilter:e,minimalFilterDropdownOpen:!1,selectedMinimalFilterDropdownOption:D(E({},t.selectedMinimalFilterDropdownOption),{filter:e})}),t)),this.filterCommentAnnotations()}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent filterCommentsByReadStatus: ",t)}}resetFilters(){try{this.componentConfigSignal.update(e=>{let t=e.filters;return Object.keys(t).forEach(r=>{t[r]?.length&&(t[r]=[])}),e=D(E({},e),{minimalFilter:"all",customActionsState:{all:!0},filters:D(E({},t),{input:""}),selectedMinimalFilterDropdownOption:D(E({},e.selectedMinimalFilterDropdownOption),{filter:"all"})}),e}),this.resolvedCommentsOnDom=!1,this.filterCommentsByReadStatus("all"),this.updateFilter({key:"pages",value:null},!0),this.updateFilter({key:"documents",value:null},!0),this.updateFilter({key:"people",value:null},!0),this.updateFilter({key:"assigned",value:null},!0),this.updateFilter({key:"tagged",value:null},!0),this.updateFilter({key:"statuses",value:null},!0),this.updateFilter({key:"priorities",value:null},!0),this.updateFilter({key:"categories",value:null},!0),this.updateFilter({key:"versions",value:null},!0),sessionStorage.removeItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent resetFilters: ",e)}}toggleLocationFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{locationFilterDropdownOpen:!e.locationFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleLocationFilterDropdown: ",e)}}toggleDocumentFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{documentFilterDropdownOpen:!e.documentFilterDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleDocumentFilterDropdown: ",e)}}closeDocumentFilterDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{documentFilterDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent closeDocumentFilterDropdown: ",e)}}toggleMinimalActionsDropdown(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!e.minimalActionsDropdownOpen}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent toggleMinimalActionsDropdown: ",e)}}markAllCommentAnnotationsAsRead(){try{this.commentService.setCommentAnnotationsAsRead(this.componentConfigSignal().filteredCommentPinAnnotations),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent setCommentAnnotationsAsRead: ",e)}}markAllCommentAnnotationsAsResolved(){try{this.commentService.setCommentAnnotationsAsResolved(this.componentConfigSignal().filteredCommentPinAnnotations),this.componentConfigSignal.update(e=>(e=D(E({},e),{minimalActionsDropdownOpen:!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent markAllCommentAnnotationsAsResolved: ",e)}}toggleCustomAction(e,t){try{t==="toggle"?(this.componentConfigSignal.update(r=>(r=D(E({},r),{customActionsState:{[e]:!r.customActionsState[e]}}),r)),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify(this.componentConfigSignal().customActionsState)),this.commentService.setSidebarCustomActionEventData(this.componentConfigSignal().customActionsState,this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,this.componentConfigSignal().customFilters)):(this.commentService.setSidebarCustomActionEventData({[e]:!0},this.componentConfigSignal().annotations,this.componentConfigSignal().unreadCommentsMap,this.componentConfigSignal().filteredCommentPinAnnotations,this.componentConfigSignal().customFilters),sessionStorage.setItem(U.SESSION_STORAGE.VELT_COMMENT_SIDEBAR_CUSTOM_ACTIONS_STATE,JSON.stringify({[e]:!0})))}catch(r){this.loggingService.catch("Error in CommentsSidebarComponent toggleCustomAction: ",r)}}goBackToAllComments(){try{let e=this.componentConfigSignal().focusedAnnotation;this.componentConfigSignal.update(t=>(t=D(E({},t),{focusedAnnotation:null}),t)),e&&setTimeout(()=>{this.goToAnnotationInSidebar(e,"instant")},100)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent goBackToAllComments: ",e)}}filterSearch(e,t){try{let r=this.componentConfigSignal();if(!r?.peopleFilters)return;let a,s;switch(t){case"people":a=r.peopleFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"assigned":a=r.assignedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"tagged":a=r.taggedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"involved":a=r.involvedFilters,!e||e===""?s=a:s=a.filter(c=>c?.name?.toLowerCase().includes(e.toLowerCase()));break;case"pages":a=r.pages,!e||e===""?s=r.pages:(s={},Object.keys(a).filter(p=>p.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"documents":a=r.documents,!e||e===""?s=r.documents:(s={},Object.keys(a).filter(p=>a[p]?.documentName?.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"statuses":a=r.statuses,!e||e===""?s=a:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;case"priorities":a=r.priorities,!e||e===""?s=a:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;case"categories":a=r.commentCategoryMap,!e||e===""?s=r.commentCategoryMap:(s={},Object.keys(a).filter(p=>p.toLowerCase().includes(e.toLowerCase())).forEach(p=>{s[p]=a[p]}));break;case"versions":a=r.versions,!e||e===""?s=r.versions:s=a.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break;default:a=r.filterConfig[t]?.options,!e||e===""?s=r.filterConfig[t]?.options:s=a?.filter(c=>c.name.toLowerCase().includes(e.toLowerCase()));break}return s}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterPeople: ",r),[]}}updateDocumentSelectedState(){try{this.componentConfigSignal.update(e=>(e=E({},e),Object.values(e.documents).forEach(t=>{let r=e.filters?.documents?.find(a=>a.id===t?.id);r?(t.selected=!0,r.documentName||(r.documentName=t.documentName)):t.selected=!1}),e))}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent updateDocumentSelectedState: ",e)}}filterAnnotationsByDocument(e,t){try{return t?.filter(r=>e?.id&&e.id!=="other"?r?.metadata?.clientDocumentId?.toString()===e.id:!r?.metadata?.clientDocumentId)}catch(r){return this.loggingService.catch("Error in CommentsSidebarComponent filterAnnotationsByDocument: ",r),[]}}onDialogExpanded(e){try{setTimeout(()=>{let t=this.componentConfigSignal().annotations.find(r=>r.annotationId===e);t&&this.goToAnnotationInSidebar(t)},200)}catch(t){this.loggingService.catch("Error in CommentsSidebarComponent onDialogExpanded: ",t)}}onFullscreenClick(){try{this.componentConfigSignal.update(e=>(e=D(E({},e),{fullScreen:!e.fullScreen}),e)),this.onFullscreen.emit(this.componentConfigSignal().fullScreen)}catch(e){this.loggingService.catch("Error in CommentsSidebarComponent onFullscreenClick: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(we),h(Ft),h(Be),h(ot),h(R),h(En),h(_),h(wo),h(Wo),h(Bl),h(an),h(Ge),h(qi),h(W1),h(Ke))},o.\u0275cmp=O({type:o,selectors:[["app-comments-sidebar"]],viewQuery:function(t,r){if(t&1&&(it(mnn,5),it(pnn,7)),t&2){let a;Je(a=et())&&(r.sidebarOverlay=a.first),Je(a=et())&&(r.hostElement=a.first)}},hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{embedMode:"embedMode",floatingMode:"floatingMode",_pageMode:[0,"pageMode","_pageMode"],_filterCount:[0,"filterCount","_filterCount"],_customActions:[0,"customActions","_customActions"],focusedThreadMode:"focusedThreadMode",_openAnnotationInFocusMode:[0,"openAnnotationInFocusMode","_openAnnotationInFocusMode"],_readOnly:[0,"readOnly","_readOnly"],_selection:[0,"dialogSelection","_selection"],_expandOnSelection:[0,"expandOnSelection","_expandOnSelection"],_sortData:[0,"sortData","_sortData"],enableUrlNavigation:"enableUrlNavigation",urlNavigation:"urlNavigation",_queryParamsComments:[0,"queryParamsComments","_queryParamsComments"],_fullScreen:[0,"fullScreen","_fullScreen"],_currentLocationSuffix:[0,"currentLocationSuffix","_currentLocationSuffix"],_filterOptionLayout:[0,"filterOptionLayout","_filterOptionLayout"],_filterConfig:[0,"filterConfig","_filterConfig"],_groupConfig:[0,"groupConfig","_groupConfig"],_filters:[0,"filters","_filters"],_systemFiltersOperator:[0,"systemFiltersOperator","_systemFiltersOperator"],_excludeLocationIds:[0,"excludeLocationIds","_excludeLocationIds"],_fullExpanded:[0,"fullExpanded","_fullExpanded"],_sidebarButtonCountType:[0,"sidebarButtonCountType","_sidebarButtonCountType"],_filterGhostCommentsInSidebar:[0,"filterGhostCommentsInSidebar","_filterGhostCommentsInSidebar"],dialogVariant:"dialogVariant",focusedThreadDialogVariant:"focusedThreadDialogVariant",filterPanelLayout:"filterPanelLayout",pageModeComposerVariant:"pageModeComposerVariant",searchPlaceholder:"searchPlaceholder",_sidebarShadowDOM:[0,"shadowDom","_sidebarShadowDOM"],_context:[0,"context","_context"],variant:"variant",position:"position"},outputs:{openSidebar:"openSidebar",onSidebarOpen:"onSidebarOpen",onSidebarCommentClick:"sidebarCommentClick",onSidebarCommentClickEvent:"onSidebarCommentClick",onCommentClick:"onCommentClick",onSidebarClose:"onSidebarClose",onCommentNavigationButtonClick:"onCommentNavigationButtonClick",onFullscreen:"onFullscreenClick"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[["sidebarRef",""],["defaultSidebarMode",""],["sidebarTrigger","cdkOverlayOrigin"],["sidebarOverlay","cdkConnectedOverlay"],[4,"ngIf"],[3,"ngIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["cdkOverlayOrigin",""],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayDisableClose","cdkConnectedOverlayPanelClass"],["class","velt-comments-sidebar-container",3,"dark",4,"ngIf"],[1,"velt-comments-sidebar-container"],["role","dialog",3,"onWrapperClick","componentConfigSignal","template","darkMode"]],template:function(t,r){t&1&&u(0,Enn,4,1,"ng-container",4),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Dt,dn,sn,Sn,q1e,ge],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%]{width:100%} .snippyly-sidebar-panel .viewport .cdk-virtual-scroll-content-wrapper{max-width:100%}.s-overflow-hidden[_ngcontent-%COMP%]{overflow:hidden}"],changeDetection:0});let i=o;return i})();function xnn(i,o){if(i&1&&(y(0,"snippyly-cursor-pointer",5)(1,"slot",6),ce(),y(2,"svg",7)(3,"g",8),w(4,"path",9)(5,"path",10),b(),y(6,"defs")(7,"filter",11),w(8,"feFlood",12)(9,"feColorMatrix",13)(10,"feOffset",14)(11,"feGaussianBlur",15)(12,"feColorMatrix",16)(13,"feBlend",17)(14,"feBlend",18),b()()()()()),i&2){let n=l().$implicit,e=l(2).ngIf,t=l();d("cursorUser",n)("avatarMode",t.avatarMode)("huddleState",e.huddleOnCursorModeByAttendeeId[n==null?null:n.userSnippylyId]?e.attendeesByUserId[n==null?null:n.userSnippylyId]==null?null:e.attendeesByUserId[n==null?null:n.userSnippylyId].state:void 0)("stream",e.huddleOnCursorModeByAttendeeId[n==null?null:n.userSnippylyId]?e.remoteStreamsByUserId[n==null?null:n.userSnippylyId]==null?null:e.remoteStreamsByUserId[n==null?null:n.userSnippylyId].webcam:void 0),m(4),x("fill",n.color),m(),x("fill",n.color)}}function Tnn(i,o){if(i&1&&(v(0),u(1,xnn,15,6,"snippyly-cursor-pointer",4),C()),i&2){let n=o.$implicit;m(),d("ngIf",n==null?null:n.position)}}function Dnn(i,o){if(i&1&&(y(0,"snippyly-cursor-pointer",19)(1,"slot",6),ce(),y(2,"svg",7)(3,"g",8),w(4,"path",9)(5,"path",10),b(),y(6,"defs")(7,"filter",11),w(8,"feFlood",12)(9,"feColorMatrix",13)(10,"feOffset",14)(11,"feGaussianBlur",15)(12,"feColorMatrix",16)(13,"feBlend",17)(14,"feBlend",18),b()()()()()),i&2){let n=l(2).ngIf,e=l();d("cursorUser",n.currentCursorUser)("selfCursorPointer",!0)("avatarMode",e.avatarMode)("huddleState",n.huddleOnCursorMode?n.attendeesByUserId[n.currentCursorUser==null?null:n.currentCursorUser.userSnippylyId]==null?null:n.attendeesByUserId[n.currentCursorUser==null?null:n.currentCursorUser.userSnippylyId].state:void 0)("stream",n.localStream),m(4),x("fill",n.currentCursorUser.color),m(),x("fill",n.currentCursorUser.color)}}function wnn(i,o){if(i&1&&u(0,Tnn,2,1,"ng-container",2)(1,Dnn,15,7,"snippyly-cursor-pointer",3),i&2){let n=l().ngIf,e=l();d("ngForOf",n.cursorUsers)("ngForTrackBy",e.trackById),m(),d("ngIf",n.huddleJoined&&n.huddleOnCursorMode&&n.currentCursorUser)}}function Onn(i,o){if(i&1&&(v(0),u(1,wnn,2,3,"ng-template",1),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.isFirstComponent&&!(n.user!=null&&n.user.isAnonymous))}}var Oq=(()=>{let o=class o{get inactivityTime(){return this._inactivityTime}set inactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Cursor set inactivityTime: ","inactivity-time value is not a number."):(this._inactivityTime=e,this.cursorService.setInactivityTime(this._inactivityTime))}catch(t){this.loggingService.catch("Error in Cursor set inactivityTime: ",t)}}get allowedElementIds(){return this._allowedElementIds}set allowedElementIds(e){try{this._allowedElementIds=typeof e=="string"?JSON.parse(e):e,this.cursorService.setAllowedElementIds(this._allowedElementIds)}catch(t){this.loggingService.catch("Error in Cursor set allowedElementIds: ",t)}}constructor(e,t,r,a,s,c){this.analyticsService=e,this.authService=t,this.cursorService=r,this.domService=a,this.huddleService=s,this.loggingService=c,this.avatarMode=!1,this.onCursorUsersChanged=new Me,this.onCursorUserChange=new Me,this.subscriptions=[],this.constants=U,this.showInitials={},this.componentConfigSignal=xe({isFirstComponent:!1,user:void 0,cursorUsers:[],huddleOnCursorModeByAttendeeId:{},attendeesByUserId:{},remoteStreamsByUserId:{},huddleOnCursorMode:!1,huddleJoined:!1,currentCursorUser:new kC,localStream:void 0}),this.veltId=vt(),this.veltElement=!0,this._inactivityTime=5,this._allowedElementIds=[],this.loggingService.log("%c[WB] Creating CLASS: CursorComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(U.TAGS.SNIPPYLY_CURSOR),t=document.querySelector(U.TAGS.VELT_CURSOR);t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),this.initComponent()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>(r=D(E({},r),{isFirstComponent:!0}),r)),this.initComponent())}catch(e){this.loggingService.catch("Error in CursorComponent AfterViewInit: ",e)}}initComponent(){try{this.cursorService.checkCursorTagAvailable(),this.subscriptions.push(this.authService.getUser$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{user:e}),t)),this.componentConfigSignal().user&&this.setCursorInstalledInAnalytics()},e=>{this.loggingService.catch("Error in CursorComponent getUser$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleJoined$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleJoined:e}),t))})),this.subscriptions.push(this.huddleService.getHuddleOnCursorMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleOnCursorMode:e}),t))},e=>{this.loggingService.catch("Error in CursorComponent getHuddleOnCursorMode$ subscription: ",e)})),this.subscriptions.push(this.huddleService.localStream$.subscribe(e=>{e?this.componentConfigSignal.update(t=>(t=D(E({},t),{localStream:e}),t)):this.componentConfigSignal.update(t=>(t=D(E({},t),{localStream:void 0}),t))})),this.subscriptions.push(this.huddleService.getRemoteStreamsByUserId$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{remoteStreamsByUserId:e}),t))},e=>{this.loggingService.catch("Error in CursorComponent getRemoteStreamsByUserId$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleAttendees$().subscribe(e=>{let t={};e?t=e.reduce((r,a)=>(r[a.userSnippylyId]=a,r),{}):t={},this.componentConfigSignal.update(r=>(r=D(E({},r),{attendeesByUserId:t}),r))},e=>{this.loggingService.catch("Error in CursorComponent getAttendees$ subscription: ",e)})),this.subscriptions.push(this.huddleService.getHuddleOnCursorModeByAttendeeId$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleOnCursorModeByAttendeeId:e}),t))})),this.subscriptions.push(this.domService.onWindowPointerMove$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{currentCursorUser:D(E({},t.currentCursorUser),{position:{left:(e?.clientX||0)-2,top:(e?.clientY||0)-2}})}),t))},e=>{this.loggingService.catch("Error in CursorComponent onWindowPointerMove$ subscription: ",e)})),this.getCurrentCursorUser(),this.getLiveCursorsOnCurrentDocument()}catch(e){this.loggingService.catch("Error in CursorComponent initComponent: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in CursorComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in CursorComponent unsubscribe: ",e)}}getLiveCursorsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getLiveCursorsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.cursorService.getLiveCursorsOnCurrentDocument().pipe(Le(e=>!!e)).subscribe(e=>{this.loggingService.log(e),e&&(this.componentConfigSignal.update(t=>(t=D(E({},t),{cursorUsers:e}),t)),this.onCursorUsersChanged.emit(e),this.onCursorUserChange.emit(e))},e=>{this.loggingService.catch("Error in CursorComponent getLiveCursorsOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CursorComponent getLiveCursorsOnCurrentDocument: ",e)}}getCurrentCursorUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getCurrentCursorUser","color: green;");try{this.subscriptions.push(this.cursorService.getCursorUser().pipe(Le(e=>!!e)).subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{currentCursorUser:D(E({},e),{position:t.currentCursorUser?.position})}),t))},e=>{this.loggingService.catch("Error in CursorComponent getCurrentCursorUser subscription: ",e)}))}catch(e){this.loggingService.catch("Error in CursorComponent getCurrentCursorUser: ",e)}}trackById(e,t){return t?.userId}onImageLoadError(e){this.loggingService.log("%c[WB] Calling FUNCTION: onImageLoadError","color: green;");try{this.showInitials[e.userId]=!0}catch(t){this.loggingService.catch("Error in CursorComponent onImageLoadError: ",t)}}setCursorInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Re.CURSOR)}catch(e){this.loggingService.catch("Error in CursorComponent setCursorInstalledInAnalytics: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(qC),h(Be),h(wr),h(_))},o.\u0275cmp=O({type:o,selectors:[["app-cursor"]],hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{avatarMode:"avatarMode",inactivityTime:"inactivityTime",allowedElementIds:"allowedElementIds"},outputs:{onCursorUsersChanged:"cursorUsersChanged",onCursorUserChange:"onCursorUserChange"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],[3,"ngIf"],[4,"ngFor","ngForOf","ngForTrackBy"],[3,"cursorUser","selfCursorPointer","avatarMode","huddleState","stream",4,"ngIf"],[3,"cursorUser","avatarMode","huddleState","stream",4,"ngIf"],[3,"cursorUser","avatarMode","huddleState","stream"],["name","cursor"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"cursor-icon"],["filter","url(#filter0_d_6047_31299)"],["d","M7.68749 16.5142L5.42791 5.15177C5.26065 4.31067 6.16027 3.66301 6.90484 4.08848L16.8788 9.78786C17.6558 10.2319 17.503 11.3948 16.6376 11.623L12.3849 12.7447C12.1377 12.8098 11.9249 12.9672 11.7902 13.1844L9.51802 16.8464C9.03968 17.6174 7.86445 17.4041 7.68749 16.5142Z","fill","#625DF5"],["d","M4.93751 5.24929L7.19709 16.6118C7.46253 17.9466 9.22538 18.2664 9.94288 17.11L12.215 13.448C12.2824 13.3394 12.3888 13.2607 12.5124 13.2281L16.7651 12.1065C18.0632 11.7642 18.2924 10.0198 17.1268 9.35374L7.15291 3.65436C6.03605 3.01615 4.68662 3.98765 4.93751 5.24929Z","stroke","white","stroke-linecap","square"],["id","filter0_d_6047_31299","x","0.588557","y","0.405717","width","21.6129","height","23.0055","filterUnits","userSpaceOnUse","color-interpolation-filters","sRGB"],["flood-opacity","0","result","BackgroundImageFix"],["in","SourceAlpha","type","matrix","values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0","result","hardAlpha"],["dy","1.1"],["stdDeviation","1.2"],["type","matrix","values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.17 0"],["mode","normal","in2","BackgroundImageFix","result","effect1_dropShadow_6047_31299"],["mode","normal","in","SourceGraphic","in2","effect1_dropShadow_6047_31299","result","shape"],[3,"cursorUser","selfCursorPointer","avatarMode","huddleState","stream"]],template:function(t,r){t&1&&u(0,Onn,2,1,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,z1],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}*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;height:unset;width:unset;text-align:left;line-height:1.5;color:#000;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit));pointer-events:none!important}*:empty{display:revert}.cursor-icon path{stroke:#fff;stroke-width:1px;stroke-linejoin:round}
535
535
  `],encapsulation:3,changeDetection:0});let i=o;return i})();function Ann(i,o){if(i&1&&(y(0,"span",7),te(1),P(2,"translate"),b()),i&2){let n=l(2).ngIf;m(),Se(" ",n.user!=null&&n.user.name?n.user==null||n.user.name==null?null:n.user.name.charAt(0):M(2,1,n.user==null||n.user.email==null?null:n.user.email.charAt(0)))}}function Pnn(i,o){if(i&1){let n=K();y(0,"img",8),W("error",function(){N(n);let t=l(3);return F(t.onImageLoadError())}),b()}if(i&2){let n=l(2).ngIf;d("src",n.user.photoUrl,vn)}}function Mnn(i,o){if(i&1&&(y(0,"div",3)(1,"span",4),P(2,"translate"),u(3,Ann,3,3,"span",5)(4,Pnn,1,1,"ng-template",null,0,Te),b(),w(6,"audio",6),b()),i&2){let n=me(5),e=l().ngIf;m(),at("color",e.user.color+" !important")("background-color",e.user.color+" !important"),d("title",M(2,8,(e.user==null?null:e.user.name)||(e.user==null?null:e.user.email))),m(2),d("ngIf",e.showInitial)("ngIfElse",n),m(3),d("srcObject",e.remoteAudioStream)}}function knn(i,o){if(i&1&&(v(0),u(1,Mnn,7,10,"div",2),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.user)}}var Y1e=(()=>{let o=class o{constructor(e){this.loggingService=e,this.veltElement=!0,this.componentConfigSignal=xe({user:this.user,showInitial:!1,remoteAudioStream:this.remoteAudioStream})}ngOnInit(){}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling AudioHuddleUserComponent FUNCTION: ngOnChanges","color: green;"),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in AudioHuddleUserComponent ngOnChanges: ",t)}}onImageLoadError(){this.loggingService.log("%c[WB] Calling FUNCTION: onImageLoadError","color: green;");try{this.componentConfigSignal.update(e=>(e=D(E({},e),{showInitial:!0}),e))}catch(e){this.loggingService.catch("Error in AudioHuddleUserComponent onImageLoadError: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(_))},o.\u0275cmp=O({type:o,selectors:[["snippyly-audio-huddle-user"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{user:"user",remoteAudioStream:"remoteAudioStream"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["showAvatarImgRef",""],[4,"ngIf"],["class","audio-huddle-user photo-container",4,"ngIf"],[1,"audio-huddle-user","photo-container"],["velt-ignore-change-detection","true",1,"audio-huddle-user",3,"title"],["class","audio-huddle-user-initial",4,"ngIf","ngIfElse"],["autoplay","true",3,"srcObject"],[1,"audio-huddle-user-initial"],["referrerpolicy","no-referrer","loading","lazy",1,"audio-huddle-user-image",3,"error","src"]],template:function(t,r){t&1&&u(0,knn,2,1,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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}.audio-huddle-user[_ngcontent-%COMP%]{display:none!important}.photo-container[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:40px;height:40px;box-sizing:border-box;background-clip:padding-box;border-radius:50%;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:top .12s ease-in-out,width .12s ease-in-out,height .12s ease-in-out}.photo-container[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:50%;object-fit:cover}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.s-presence-container[_ngcontent-%COMP%]{display:inline-flex;flex-direction:row-reverse;align-items:center}.audio-huddle-user[_ngcontent-%COMP%]{position:relative;box-shadow:0 0 0 3px;border-radius:50%;overflow:hidden;width:calc((2rem + 0px) * var(--velt-base-rem-unit));height:calc((2rem + 0px) * var(--velt-base-rem-unit));min-width:calc((2rem + 0px) * var(--velt-base-rem-unit));min-height:calc((2rem + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.audio-huddle-user.more-users[_ngcontent-%COMP%]{background:#4578a7;box-shadow:0 0 0 3px #4578a7}.audio-huddle-user[_ngcontent-%COMP%]:not(:last-child):not(.more-users){margin-left:calc((-.5rem + 0px) * var(--velt-base-rem-unit))!important}.audio-huddle-user-image[_ngcontent-%COMP%]{width:100%;height:100%;display:block;object-fit:cover}.audio-huddle-user-image-small[_ngcontent-%COMP%]{width:calc((1.6rem + 0px) * var(--velt-base-rem-unit));height:100%;display:block;object-fit:cover}.audio-huddle-user-initial[_ngcontent-%COMP%]{color:#fff}.away[_ngcontent-%COMP%]{filter:grayscale(1)}"],changeDetection:0});let i=o;return i})();function Nnn(i,o){if(i&1){let n=K();y(0,"div",18),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.selectAudioDevice(t))}),te(1),P(2,"translate"),b()}if(i&2){let n=o.$implicit,e=l(2);pe("selected",n.deviceId===(e.selectedAudioDevice==null?null:e.selectedAudioDevice.deviceId)),m(),Se(" ",M(2,3,n.label)," ")}}function Fnn(i,o){if(i&1&&(y(0,"div",12)(1,"div",13),te(2),P(3,"translate"),b(),te(4),P(5,"translate"),y(6,"div",14)(7,"div",15),u(8,Nnn,3,5,"div",16),b(),te(9),P(10,"translate"),ce(),y(11,"svg",4),w(12,"path",17),b()()()),i&2){let n=l();m(2),ze(M(3,4,"Audio")),m(2),Se(" ",M(5,6,"Microphone")," "),m(4),d("ngForOf",n.audioDevices),m(),Se(" ",M(10,8,n.selectedAudioDevice==null?null:n.selectedAudioDevice.label)," ")}}function Lnn(i,o){if(i&1){let n=K();y(0,"div",18),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.selectVideoDevice(t))}),te(1),P(2,"translate"),b()}if(i&2){let n=o.$implicit,e=l(2);pe("selected",n.deviceId===(e.selectedVideoDevice==null?null:e.selectedVideoDevice.deviceId)),m(),Se(" ",M(2,3,n.label)," ")}}function Bnn(i,o){if(i&1&&(y(0,"div",12)(1,"div",13),te(2),P(3,"translate"),b(),te(4),P(5,"translate"),y(6,"div",14)(7,"div",15),u(8,Lnn,3,5,"div",16),b(),te(9),P(10,"translate"),ce(),y(11,"svg",4),w(12,"path",17),b()()()),i&2){let n=l();m(2),ze(M(3,4,"Video")),m(2),Se(" ",M(5,6,"Camera")," "),m(4),d("ngForOf",n.videoDevices),m(),Se(" ",M(10,8,n.selectedVideoDevice==null?null:n.selectedVideoDevice.label)," ")}}var K1e=(()=>{let o=class o{constructor(e,t,r){this.loggingService=e,this.dialogRef=t,this.devices=[],this.audioDevices=[],this.videoDevices=[],this.settingsVisible={audio:!0,video:!0},this.defaultMediaSourceOptions=gd(),this.veltElement=!0;try{r&&(this.selectedAudioDevice=r.selectedAudioDevice,this.selectedVideoDevice=r.selectedVideoDevice,r.settingsVisible&&(this.settingsVisible=r.settingsVisible)),this.getDevices()}catch(a){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent constructor: ",a)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-media-source-options-dialog")}catch(e){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent ngOnInit: ",e)}}getDevices(){return Q(this,null,function*(){try{let e=new Yn;if(e.getBrowserName()?.toLowerCase()==="safari"||e.getBrowserName()?.toLowerCase()==="firefox")try{let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!0});t&&t.getTracks().forEach(r=>r.stop())}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices getUserMedia catch: ",t)}navigator.mediaDevices.enumerateDevices().then(t=>{if(this.devices=t.filter(r=>r.kind==="audioinput"||r.kind==="videoinput"),this.audioDevices=this.devices.filter(r=>r.kind==="audioinput"),this.videoDevices=this.devices.filter(r=>r.kind==="videoinput"),this.audioDevices.length>0&&!this.selectedAudioDevice){if(this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId){let r=this.audioDevices.find(a=>a.deviceId===this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId);r&&(this.selectedAudioDevice=r)}this.selectedAudioDevice||(this.selectedAudioDevice=this.audioDevices[0])}if(this.videoDevices.length>0&&!this.selectedVideoDevice){if(this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId){let r=this.videoDevices.find(a=>a.deviceId===this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId);r&&(this.selectedVideoDevice=r)}this.selectedVideoDevice||(this.selectedVideoDevice=this.videoDevices[0])}}).catch(t=>{this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices enumerateDevices catch: ",t)})}catch(e){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices: ",e)}})}selectAudioDevice(e){try{this.selectedAudioDevice=e}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectAudioDevice: ",t)}}selectVideoDevice(e){try{this.selectedVideoDevice=e}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectVideoDevice: ",t)}}saveChanges(){try{let e={};this.settingsVisible.audio&&(e.selectedAudioDevice=this.selectedAudioDevice),this.settingsVisible.video&&(e.selectedVideoDevice=this.selectedVideoDevice),localStorage.setItem(U.LOCAL_STORAGE.SNIPPYLY_DEFAULT_MEDIA_SOURCE_OPTIONS,JSON.stringify(e||{})),this.closeDialog(e)}catch(e){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent saveChanges: ",e)}}closeDialog(e){try{this.dialogRef.close(e)}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent closeDialog: ",t)}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(dr),h(rc,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-media-source-options-dialog"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},standalone:!1,decls:17,vars:10,consts:[["mediaSourceOptionsDialogRef",""],[1,"s-video-settings-modal",3,"pointerdown","pointerup","click","snippylyOverlay","snippylyOverlayZIndex"],[1,"s-video-header"],[1,"s-video-header-name"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63 2 9.2 2.38 9.14 2.88L8.85 5.19C8.44 5.38 8.05 5.61 7.68 5.87L5.53 4.96C5.07 4.76 4.53 4.94 4.28 5.38L2.41 8.62C2.16 9.06 2.27 9.61 2.67 9.92L4.53 11.33C4.51 11.55 4.5 11.77 4.5 12C4.5 12.23 4.51 12.45 4.53 12.68L2.67 14.09C2.27 14.39 2.16 14.95 2.41 15.39L4.28 18.62C4.53 19.06 5.07 19.24 5.53 19.04L7.68 18.13C8.05 18.39 8.44 18.62 8.85 18.81L9.14 21.12C9.2 21.62 9.63 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54 13.93 8.54 12C8.54 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","white"],[1,"s-icon-button",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","white"],["class","s-video-settings-modal-item",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary","s-save-button",3,"click"],[1,"s-video-settings-modal-item"],[1,"s-heading"],[1,"s-input","dropdown"],[1,"dropdown-content"],["class","dropdown-item",3,"selected","click",4,"ngFor","ngForOf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#80808A"],[1,"dropdown-item",3,"click"]],template:function(t,r){if(t&1){let a=K();y(0,"div",1,0),W("pointerdown",function(c){return N(a),F(c.stopPropagation())})("pointerup",function(c){return N(a),F(c.stopPropagation())})("click",function(c){return N(a),F(c.stopPropagation())}),y(2,"div",2)(3,"div",3),ce(),y(4,"svg",4),w(5,"path",5),b(),te(6),P(7,"translate"),b(),ht(),y(8,"div",6),W("click",function(){return N(a),F(r.closeDialog())}),ce(),y(9,"svg",7),w(10,"path",8),b()()(),u(11,Fnn,13,10,"div",9)(12,Bnn,13,10,"div",9),ht(),w(13,"div",10),y(14,"div",11),W("click",function(){return N(a),F(r.saveChanges())}),te(15),P(16,"translate"),b()()}if(t&2){let a=me(1);d("snippylyOverlay",a)("snippylyOverlayZIndex",3e3),m(6),Se(" ",M(7,6,"Settings")," "),m(5),d("ngIf",r.settingsVisible==null?null:r.settingsVisible.audio),m(),d("ngIf",r.settingsVisible==null?null:r.settingsVisible.video),m(3),ze(M(16,8,"Save changes"))}},dependencies:[Et,X,gi,ge],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%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%]{display:flex!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#91919c!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;background:#141416!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:calc((40rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important;align-items:center!important}.s-video-header-name[_ngcontent-%COMP%]{gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;font-weight:600!important;font-size:calc((1.2rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:hover{background:#4f4bbf!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important}.s-input[_ngcontent-%COMP%]{position:relative!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#91919c!important;width:100%!important;justify-content:space-between!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:0!important;right:0!important;z-index:1!important}.dropdown-content[_ngcontent-%COMP%]{width:100%!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;color:#91919c!important;background:#141416!important;cursor:pointer!important;visibility:hidden!important;opacity:0!important;transition:all .1s ease!important}.dropdown[_ngcontent-%COMP%]:hover .dropdown-content[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:calc((1.2rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:all .1s ease!important;color:#91919c!important}.dropdown-item.selected[_ngcontent-%COMP%]{color:#fff!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-icon-button[_ngcontent-%COMP%]{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important;justify-content:center!important;border-radius:100px!important;cursor:pointer!important}.s-icon-button[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.s-icon-button[_ngcontent-%COMP%]:hover{background:#222226!important}.s-icon-button[_ngcontent-%COMP%]:hover svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#fff!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog{max-width:unset} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}@media screen and (max-width: 768px){.s-video-settings-modal[_ngcontent-%COMP%]{width:calc(.8 * var(--legacy-velt-viewport-width))!important}}@media screen and (max-width: 425px){ .velt-mat-dialog-container.snippyly-media-source-options-dialog{width:calc(1 * var(--legacy-velt-viewport-width))!important;max-width:calc(1 * var(--legacy-velt-viewport-width))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:calc((0rem + 0px) * var(--velt-base-rem-unit))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-video-settings-modal{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-save-button{width:100%!important}}"],changeDetection:0});let i=o;return i})();var Z1e=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g){this.authService=e,this.configService=t,this.contactService=r,this.docService=a,this.commonDbService=s,this.databaseService=c,this.loggingService=p,this.notificationService=g,this.documentUsers$=new Ce([]);try{this.databaseService.getDb().pipe(Le(f=>!!f),rt(1)).subscribe(f=>{f&&this.subscribeUsersFromDocument()}),this.authService.getUser$().subscribe(f=>{if(f?.email){this.subscribeUsersFromDocument();let I=Tt(f.email);f?.organizationId&&(I=Tt(f.userId)),this.getDocumentUserByIdFromDb(I).then(T=>{T&&(T.user.name=f.name,T.user.photoUrl=f.photoUrl,this.updateDocumentUser(T))}).catch(T=>{this.loggingService.catch("Error in DocumentUserAccessService getDocumentUserByIdFromDb:",T)})}},f=>{this.loggingService.catch("Error in DocumentUserAccessService getUser$:",f)})}catch(f){this.loggingService.catch("Error in DocService constructor:",f)}}getDocumentUserByIdFromDb(e){return Q(this,null,function*(){try{let t=this.docService.getDocumentPaths();return t?(yield this.commonDbService.dbListener({feature:"documentUser",properties:{documentId:t?.documentId,organizationId:t?.organizationId,isCollection:!1,id:e}}).pipe(rt(1)).toPromise())?.data:void 0}catch(t){this.loggingService.catch("Error in DocService getDocumentUserById:",t);return}})}subscribeUsersFromDocument(){try{this.documentUsersSubscription&&this.documentUsersSubscription.unsubscribe(),this.documentUsersSubscription=this.authService.getUser$().pipe(he(e=>e?this.docService.getDocumentPaths$().pipe(Le(t=>!!t),he(t=>this.commonDbService.dbListener({feature:"allDocumentUsers",properties:{documentId:t?.documentId,organizationId:t?.organizationId,isCollection:!0}}).pipe(de(r=>r?.data?Object.values(r?.data):[])))):le([]))).subscribe(e=>{this.documentUsers$.next(e)},e=>{this.loggingService.catch("Error in DocService subscribeUsersFromDocument subscription:",e)})}catch(e){this.loggingService.catch("Error in DocService subscribeUsersFromDocument:",e)}}getDocumentUsers$(){return this.documentUsers$.asObservable()}addDocumentUser(e){try{let t=this.authService.getUser();if(t){if(this.configService.getSF()){if(e?.role?.name===go.ADMIN)this.contactService.addGlobalContact(e.user);else if(e?.role?.name===go.COMMENTER){let a=t.groupId;if(a){let s=JSON.parse(JSON.stringify(e.user));s.visibility="group",this.contactService.setLoggedInUserGroupContacts(a,[s])}}}e.id=Tt(e?.user?.email),e.invitedBy=t,e.invitedDate=this.timestamp;let r=this.docService.getDocumentPaths();r&&this.commonDbService.updateData({feature:"documentUserAccess",properties:{id:e.id,documentId:r?.documentId??"",organizationId:r?.organizationId??""},data:JSON.parse(JSON.stringify(e))}),this.updateNotificationsDatabase(e)}else this.loggingService.error("Error in DocService addDocumentUser: User not found")}catch(t){this.loggingService.catch("Error in DocService addDocumentUser:",t)}}updateDocumentUser(e,t={}){try{let r=this.authService.getUser();if(r){e.updatedBy=r,e.updatedDate=this.timestamp;let a=this.docService.getDocumentPaths();this.commonDbService.updateData({feature:"documentUserAccess",properties:{id:e.id,documentId:a?.documentId??"",organizationId:a?.organizationId??""},data:JSON.parse(JSON.stringify(e))}),this.updateNotificationsDatabase(e)}}catch(r){this.loggingService.catch("Error in DocumentUserAccessService updateDocumentUser:",r)}}removeDocumentUser(e){try{let t=this.docService.getDocumentPaths();this.commonDbService.deleteData({feature:"documentUserAccess",properties:{id:e.id,documentId:t?.documentId??"",organizationId:t?.organizationId??""}})}catch(t){this.loggingService.catch("Error in DocumentUserAccessService removeDocumentUser:",t)}}updateNotificationsDatabase(e={}){try{let t=E({notificationSource:"user"},e);this.notificationService.updateNotificationDatabase(t)}catch(t){this.loggingService.catch("Error in DocumentUserAccessService updateNotificationsDatabase: ",t)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};o.\u0275fac=function(t){return new(t||o)(ee(je),ee(Ft),ee(Si),ee(ot),ee(un),ee(In),ee(_),ee(hn))},o.\u0275prov=Pe({token:o,factory:o.\u0275fac,providedIn:"root"});let i=o;return i})();var Unn=["triggerTemplate"],jnn=["tooltipTemplate"],$nn=["trigger"],Hnn=["overlay"],znn=()=>["snippyly-overlay-panel","snippyly-reaction-dialog-overlay-panel","velt-overlay-panel"];function Gnn(i,o){i&1&&He(0)}function Wnn(i,o){i&1&&He(0)}function qnn(i,o){if(i&1){let n=K();y(0,"div",6,2),W("pointerenter",function(){N(n);let t=l();return F(t.showTooltip())})("pointerleave",function(){N(n);let t=l();return F(t.hideTooltip())}),u(2,Wnn,1,0,"ng-container",4),b()}if(i&2){let n=me(1),e=l();d("snippylyOverlay",n)("snippylyOverlayZIndex",2e3),x("data-velt-element",!0),m(2),d("ngTemplateOutlet",e.tooltipTemplate)}}var Pm=(()=>{let o=class o{constructor(e){this.loggingService=e,this.positions=[],this.disableClose=!0,this.disabled=!1,this.componentConfigSignal=xe({disabled:!1,tooltipVisible:!1,overlayPositions:[]}),this.veltElement=!0}ngOnInit(){}ngOnChanges(e){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnChanges","color: green;");try{e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))}),e.positions&&this.componentConfigSignal.update(t=>(t=D(E({},t),{overlayPositions:this.positions.map(r=>new di({originX:r.originX,originY:r.originY},{overlayX:r.overlayX,overlayY:r.overlayY}))}),t))}catch(t){this.loggingService.catch("Error in OverlayTooltipComponent ngOnChanges: ",t)}}showTooltip(){this.loggingService.log("%c[WB] Calling FUNCTION: showTooltip","color: green;");try{this.hideTooltipTimeout&&clearTimeout(this.hideTooltipTimeout),this.componentConfigSignal.update(e=>(e=D(E({},e),{tooltipVisible:!0}),e))}catch(e){this.loggingService.catch("Error in OverlayTooltipComponent showTooltip: ",e)}}hideTooltip(){this.loggingService.log("%c[WB] Calling FUNCTION: hideTooltip","color: green;");try{this.hideTooltipTimeout&&clearTimeout(this.hideTooltipTimeout),this.hideTooltipTimeout=setTimeout(()=>{this.componentConfigSignal.update(e=>(e=D(E({},e),{tooltipVisible:!1}),e))},200)}catch(e){this.loggingService.catch("Error in OverlayTooltipComponent hideTooltip: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.hideTooltip()}catch(e){this.loggingService.catch("Error in OverlayTooltipComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(_))},o.\u0275cmp=O({type:o,selectors:[["app-overlay-tooltip"]],contentQueries:function(t,r,a){if(t&1&&(js(a,Unn,7),js(a,jnn,7)),t&2){let s;Je(s=et())&&(r.triggerTemplate=s.first),Je(s=et())&&(r.tooltipTemplate=s.first)}},viewQuery:function(t,r){if(t&1&&(it($nn,5),it(Hnn,5)),t&2){let a;Je(a=et())&&(r.trigger=a.first),Je(a=et())&&(r.overlay=a.first)}},hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{positions:"positions",disableClose:"disableClose",disabled:"disabled"},standalone:!1,features:[Ze],decls:5,vars:8,consts:[["trigger","cdkOverlayOrigin"],["overlay","cdkConnectedOverlay"],["overlayContent",""],["cdkOverlayOrigin","",3,"pointerenter","pointerleave"],[4,"ngTemplateOutlet"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayPanelClass","cdkConnectedOverlayOpen","cdkConnectedOverlayPositions","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayDisableClose"],["data-velt-comment-disabled","true",3,"pointerenter","pointerleave","snippylyOverlay","snippylyOverlayZIndex"]],template:function(t,r){if(t&1){let a=K();y(0,"div",3,0),W("pointerenter",function(){return N(a),F(r.showTooltip())})("pointerleave",function(){return N(a),F(r.hideTooltip())}),u(2,Gnn,1,0,"ng-container",4),b(),u(3,qnn,3,4,"ng-template",5,1,Te)}if(t&2){let a=me(1);m(2),d("ngTemplateOutlet",r.triggerTemplate),m(),d("cdkConnectedOverlayOrigin",a)("cdkConnectedOverlayPanelClass",ut(7,znn))("cdkConnectedOverlayOpen",!r.componentConfigSignal().disabled&&r.componentConfigSignal().tooltipVisible)("cdkConnectedOverlayPositions",r.componentConfigSignal().overlayPositions)("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayDisableClose",r.disableClose)}},dependencies:[Dt,dn,sn,gi],encapsulation:2,changeDetection:0});let i=o;return i})();var Ynn=["matAutocomplete"],Knn=["matAutocompleteTrigger"],Znn=["autocompletePanelInput"],Xnn=["viewport"],Qnn=i=>({componentConfigSignal:i}),Jnn=(i,o)=>({condition:i,data:o}),X1e=i=>({$implicit:i}),Q1e=(i,o)=>({$implicit:i,isNewContact:o});function ein(i,o){if(i&1){let n=K();y(0,"input",9,2),W("keyup",function(t){return N(n),F(t.stopPropagation())})("keydown",function(t){return N(n),F(t.stopPropagation())})("keyup.escape",function(t){return N(n),l().closePanel(),F(t.stopPropagation())})("input",function(t){return N(n),l().handleInput(t),F(t.stopPropagation())}),b()}if(i&2){let n=l(),e=me(4);d("placeholder",n.placeholder||"")("matAutocomplete",e)("matAutocompleteDisabled",!n.enableOnFocus)("matAutocompletePosition",n.position),x("aria-label",n.placeholder||"Search")("aria-autocomplete","list")("aria-controls",n.componentId+"-input")("data-testid",n.componentId+"-input")}}function tin(i,o){if(i&1&&(v(0),w(1,"velt-autocomplete-group-option-internal",17),C()),i&2){let n=l().$implicit,e=l(3);m(),d("componentConfigSignal",e.componentConfigSignal)("group",n.group)("groupName",n.groupName)}}function nin(i,o){i&1&&He(0)}function iin(i,o){if(i&1&&(v(0),y(1,"div",18),u(2,nin,1,0,"ng-container",19),b(),C()),i&2){let n=l().$implicit;l(3);let e=me(7);m(2),d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,X1e,n.originalItem))}}function oin(i,o){i&1&&He(0)}function rin(i,o){if(i&1&&(v(0),u(1,oin,1,0,"ng-container",19),C()),i&2){let n=l().$implicit;l(3);let e=me(7);m(),d("ngTemplateOutlet",e)("ngTemplateOutletContext",k(2,Q1e,n.originalItem,n.isNewContact))}}function ain(i,o){if(i&1){let n=K();y(0,"mat-option",15),W("pointerdown",function(t){return N(n),t.stopPropagation(),F(t.preventDefault())})("pointerup",function(t){let r=N(n).$implicit,a=l(3);return t.stopPropagation(),r.isGroupHeader?t.preventDefault():a.onOptionClick(r.originalItem),F(t.preventDefault())}),u(1,tin,2,3,"ng-container",16)(2,iin,3,4,"ng-container",16)(3,rin,2,5,"ng-container",16),b()}if(i&2){let n=o.$implicit;pe("velt-group-option",n.isGroupHeader)("velt-group-member-option",n.isGroupMember),d("disabled",n==null?null:n.disabled)("value",n.originalItem),x("id",n.id)("aria-disabled",n==null?null:n.disabled)("data-testid",n.testId),m(),d("ngIf",n.isGroupHeader),m(),d("ngIf",n.isGroupMember),m(),d("ngIf",!n.isGroupHeader&&!n.isGroupMember)}}function sin(i,o){if(i&1&&(y(0,"cdk-virtual-scroll-viewport",13,3),u(2,ain,4,12,"mat-option",14),P(3,"async"),b()),i&2){let n=l(2);m(2),d("cdkVirtualForOf",M(3,2,n.componentConfigSignal().flattenedItems$))("cdkVirtualForTrackBy",n.trackByFlattenedItem)}}function lin(i,o){if(i&1&&(v(0),w(1,"velt-autocomplete-group-option-internal",17),C()),i&2){let n=l().$implicit,e=l(3);m(),d("componentConfigSignal",e.componentConfigSignal)("group",n.group)("groupName",n.groupName)}}function cin(i,o){i&1&&He(0)}function din(i,o){if(i&1&&(v(0),y(1,"div",18),u(2,cin,1,0,"ng-container",19),b(),C()),i&2){let n=l().$implicit;l(3);let e=me(7);m(2),d("ngTemplateOutlet",e)("ngTemplateOutletContext",A(2,X1e,n.originalItem))}}function min(i,o){i&1&&He(0)}function pin(i,o){if(i&1&&(v(0),u(1,min,1,0,"ng-container",19),C()),i&2){let n=l().$implicit;l(3);let e=me(7);m(),d("ngTemplateOutlet",e)("ngTemplateOutletContext",k(2,Q1e,n.originalItem,n.isNewContact))}}function gin(i,o){if(i&1){let n=K();y(0,"mat-option",15),W("pointerdown",function(t){return N(n),t.stopPropagation(),F(t.preventDefault())})("pointerup",function(t){let r=N(n).$implicit,a=l(3);return t.stopPropagation(),r.isGroupHeader?t.preventDefault():a.onOptionClick(r.originalItem),F(t.preventDefault())}),u(1,lin,2,3,"ng-container",16)(2,din,3,4,"ng-container",16)(3,pin,2,5,"ng-container",16),b()}if(i&2){let n=o.$implicit;pe("velt-group-option",n.isGroupHeader)("velt-group-member-option",n.isGroupMember),d("disabled",n==null?null:n.disabled)("value",n.originalItem),x("id",n.id)("aria-disabled",n==null?null:n.disabled)("data-testid",n.testId),m(),d("ngIf",n.isGroupHeader),m(),d("ngIf",n.isGroupMember),m(),d("ngIf",!n.isGroupHeader&&!n.isGroupMember)}}function uin(i,o){if(i&1&&(y(0,"div",20),u(1,gin,4,12,"mat-option",21),P(2,"async"),b()),i&2){let n=l(2);m(),d("ngForOf",M(2,2,n.componentConfigSignal().flattenedItems$))("ngForTrackBy",n.trackByFlattenedItem)}}function hin(i,o){if(i&1&&(y(0,"div",10),u(1,sin,4,4,"cdk-virtual-scroll-viewport",11),P(2,"async"),u(3,uin,3,4,"div",12),P(4,"async"),b()),i&2){let n,e,t=l();pe("s-comment-autocomplete-panel-dark",t.darkMode),x("data-testid",t.componentId+"-options-container"),m(),d("ngIf",(((n=M(2,5,t.componentConfigSignal().flattenedItems$))==null?null:n.length)||0)>6),m(2),d("ngIf",(((e=M(4,7,t.componentConfigSignal().flattenedItems$))==null?null:e.length)||0)<=6)}}function fin(i,o){if(i&1&&w(0,"velt-autocomplete-option-internal",22),i&2){let n=o.$implicit,e=o.isNewContact,t=l();d("componentConfigSignal",t.componentConfigSignal)("selectorItem",n)("isNewContact",e)}}var xu=(()=>{let o=class o extends tt{get trigger(){return this._trigger}set trigger(e){this._trigger=e,this.setTriggerToMatAutocomplete(),this.trigger&&(this.trigger.autocompleteDisabled=!this.enableOnFocus,this.trigger._handleInput=this.handleInput.bind(this))}get triggerElement(){return this._triggerElement}set triggerElement(e){if(this._triggerElement=e,this.triggerElement){let t=new R(this.triggerElement);this.trigger=new l2(t,this.overlay,this.viewContainerRef,{run:r=>r(),runOutsideAngular:r=>r()},this.cd,null,this.directionality,null,document,this.viewportRuler)}}get enableOnFocus(){return this._enableOnFocus}set enableOnFocus(e){this._enableOnFocus=e,this.trigger&&(this.trigger.autocompleteDisabled=!this.enableOnFocus)}get excludeContacts(){return this._excludeContacts}set excludeContacts(e){this._excludeContacts=e,this.filterOptions()}constructor(e,t,r,a,s,c,p,g,f,I,T,B,z,G,J){super(s,T,void 0,void 0,void 0,B,a),this.authService=e,this.autocompleteService=t,this.contactService=r,this.loggingService=a,this.elementRef=s,this.overlay=c,this.viewContainerRef=p,this.cd=g,this.directionality=f,this.viewportRuler=I,this.themeService=T,this.dynamicDataService=B,this.commentActionsService=z,this.commentService=G,this.metadataService=J,this.type="contact",this._enableOnFocus=!1,this.position="auto",this._excludeContacts=[],this.showAtHere=!1,this.optionSelected=new Me,this.atHereSelected=new Me,this.userContactOptionSelected=new Me,this.customOptionSelected=new Me,this.groupOptionSelected=new Me,this.enterPressed=new Me,this.autocompleteStateChanged=new Me,this.userContacts=[],this.paginatedContactList=!1,this.user=null,this.inputFilterFormControl=new zae,this.oldText="",this.newText="",this.wordIndex=-1,this.deviceInfo=new Yn,this.userDocumentContacts=[],this.organizationGroups=[],this.subscriptions=[],this.autocompleteDisabledPositions=new Set,this.veltId=vt(),this.veltElement=!0,this.componentConfigSignal=xe({flattenedItems$:le([]),trackByFlattenedItem:this.trackByFlattenedItem.bind(this),onOptionClick:this.onOptionClick.bind(this),newUserContactError:void 0,newUserContact:void 0,customAutocompleteSearch:!1,expandMentionGroups:!1,showMentionGroupsFirst:!1,showMentionGroupsOnly:!1,customGroupsEnabled:!1}),this.hereUserContact={name:"here",email:"",userId:"here",visibility:"here"},this.atHereDescription=null,this.dataList=[],this.autocompleteDataMap={},this.atHereEnabled=!1,this.componentId="velt-autocomplete-panel",this.MAX_VISIBLE_ITEMS=10,this.ITEM_SIZE=55;try{this.subscriptions.push(this.commentService.getCustomAutocompleteSearch$().subscribe(ne=>{this.componentConfigSignal.update(ve=>(ve=D(E({},ve),{customAutocompleteSearch:ne}),ve))})),this.subscriptions.push(this.authService.getUser$().subscribe(ne=>{this.user=ne,this.filterOptions()})),this.subscriptions.push(this.autocompleteService.getAutocompleteDataMap$().subscribe(ne=>{this.autocompleteDataMap=ne,this.filterOptions()})),this.subscriptions.push(this.inputFilterFormControl.valueChanges.pipe(Bi(150),Ct()).subscribe(()=>{this.filterOptions()}))}catch(ne){this.loggingService.catch("Error in AutocompletePanelComponent ngOnInit:",ne)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes(),this.type==="contact"?this.selectedAutocompleteData={hotkey:"",type:"contact",data:[]}:this.selectedAutocompleteData=void 0,this.subscriptions.push(this.contactService.getAtHereLabel().subscribe(e=>{this.hereUserContact.name=e})),this.subscriptions.push(this.contactService.getAtHereDescription().subscribe(e=>{this.atHereDescription=e})),this.subscriptions.push(this.contactService.getUserContacts$(this.metadata).subscribe(e=>{this.userContacts=e?.slice(),this.atHereEnabled&&(this.userContacts?.find(t=>t?.visibility=="here")||this.userContacts.unshift(this.hereUserContact)),this.filterOptions()})),this.subscriptions.push(this.contactService.getAtHereEnabled$().subscribe(e=>{this.atHereEnabled=e,e?this.userContacts?.find(t=>t?.visibility=="here")||this.userContacts.unshift(this.hereUserContact):this.userContacts=this.userContacts.filter(t=>t?.visibility!=="here"),this.filterOptions()})),this.subscriptions.push(this.contactService.getOrganizationGroups$().subscribe(e=>{this.organizationGroups=e,this.filterOptions()})),this.subscriptions.push(this.commentService.getExpandMentionGroups$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{expandMentionGroups:e}),t))})),this.subscriptions.push(this.commentService.getShowMentionGroupsFirst$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{showMentionGroupsFirst:e}),t))})),this.subscriptions.push(this.commentService.getShowMentionGroupsOnly$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{showMentionGroupsOnly:e}),t))})),this.subscriptions.push(this.commentService.getPaginatedContactList$().subscribe(e=>{this.paginatedContactList=e})),this.subscriptions.push(this.contactService.getUserDocumentContacts$().subscribe(e=>{this.userDocumentContacts=e,this.filterOptions()}))}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent ngOnInit: ",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("role","listbox"),e.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent setupA11yAttributes:",e)}}ngAfterViewInit(){try{this.setTriggerToMatAutocomplete(),requestAnimationFrame(()=>{if(this.autocompletePanelInput?.nativeElement){this.autocompletePanelInput.nativeElement.focus();let e=this.getViewport();if(e){let t=this.ITEM_SIZE*this.MAX_VISIBLE_ITEMS;e.style.height=`${t}px`,e.style.maxHeight=`${t}px`}this.openPanelOptimized()}this.triggerElement?this.subscriptions.push(vi(this.triggerElement,"blur").subscribe(()=>{requestAnimationFrame(()=>this.closePanel())})):this.autocompletePanelInput&&this.subscriptions.push(vi(this.autocompletePanelInput.nativeElement,"blur").subscribe(()=>{requestAnimationFrame(()=>this.closePanel())}))})}catch(e){this.loggingService.catch("Error in ngAfterViewInit:",e)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.forEach(e=>e.unsubscribe())}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent ngOnDestroy:",e)}}filterOptions(){return Q(this,null,function*(){try{if(this.selectedAutocompleteData)if(this.selectedAutocompleteData.type==="contact"){let e=this.inputFilterFormControl.value,t=new Pp,r=e?.toLowerCase()?.trim();t.email=r;let a=new RegExp(U.REGEX_EMAIL).test("@"+t?.email),s=this.userContacts.slice();this.componentConfigSignal().customAutocompleteSearch||(e?(s=this._filter(t),this.paginatedContactList&&s.length<3&&(yield this.fetchFilteredUsersFromDb(e),s=this.userContacts.slice(),s=this._filter(t))):s=this.userContacts.slice()),this.atHereEnabled&&this.hereUserContact?.name?.includes(r)&&!s?.find(T=>T?.userId=="here")&&(s=[this.hereUserContact,...s]),s=s.filter(T=>!this.excludeContacts?.find(B=>B?.email===T?.email));let c=e?this._filterGroup(e):this.organizationGroups,p=s.map(T=>{let B=!1;return T.visibility==="here"&&(this.atHereDescription?(T.email=`${this.atHereDescription}`,T.description=this.atHereDescription):this.user?.organizationId&&(T.email=`${this.userDocumentContacts?.length||0} members`,T.description=`${this.userDocumentContacts?.length||0} members`)),{type:"contact",contact:T,disabled:B}}),g=c.map(T=>({type:"group",group:T})),f=[...p,...g];if(this.componentConfigSignal().expandMentionGroups){let T=[],B={},z=new Map;f.forEach(ye=>{if(ye.contact?.userId){let Ne=Tt(ye.contact?.userId);z.set(Ne,ye),B[ye.contact?.userId]=!1}});let G=new Map;this.organizationGroups.forEach(ye=>{G.set(ye.metadata.clientGroupId,{id:ye.metadata.clientGroupId,name:ye.metadata.groupName,members:[],userIds:Object.keys(ye.users||{})})}),G.forEach(ye=>{ye.userIds.forEach(Ne=>{let Ve=z.get(Ne);Ve&&(ye.members.push(Ve),Ve.contact?.userId&&(B[Ve.contact.userId]=!0))})}),f.forEach(ye=>{ye.type==="contact"&&ye.contact?.userId&&!B[ye.contact?.userId]&&T.push(ye)});let J=Array.from(G.values()),ne=f.length?void 0:{type:"contact",contact:t},ve=this.createFlattenedItems({allItems:f,contactsWithoutGroup:T,groups:J,newUserContact:ne,isExpandedGroups:!0,isCustomGroups:!1});this.componentConfigSignal.update(ye=>D(E({},ye),{flattenedItems$:le(ve),newUserContactError:a?void 0:"Invalid email",newUserContact:ne,contactsWithoutGroup:T,groups:J}))}else{let T=f.length?void 0:{type:"contact",contact:t},B=this.createFlattenedItems({allItems:f,newUserContact:T,isExpandedGroups:!1,isCustomGroups:!1});this.componentConfigSignal.update(z=>D(E({},z),{flattenedItems$:le(B),newUserContactError:a?void 0:"Invalid email",newUserContact:T}))}let I=this.getViewport();if(I){let T=this.ITEM_SIZE*this.MAX_VISIBLE_ITEMS;I.style.height=`${T}px`,I.style.maxHeight=`${T}px`}this.openPanelOptimized(),this.cd.markForCheck()}else{let e=this.inputFilterFormControl.value,t=this.autocompleteDataMap?.[this.selectedAutocompleteData?.hotkey],r=t?.data?.slice()||[];if(this.componentConfigSignal().customAutocompleteSearch||(e?r=this._filterCustom(e):r=this.selectedAutocompleteData?.data?.slice()||[]),t?.groups&&t.groups.length>0){let c=[],p=new Map;t.groups?.forEach(I=>{p.set(I.id,{id:I.id,name:I.name,members:[]})}),r.forEach(I=>{let T={type:"custom",custom:I};I.groupId&&p.has(I.groupId)?p.get(I.groupId)?.members.push(T):c.push(T)});let g=Array.from(p.values()).filter(I=>I.members.length>0),f=this.createFlattenedItems({allItems:[],contactsWithoutGroup:c,groups:g,isExpandedGroups:!1,isCustomGroups:!0});this.componentConfigSignal.update(I=>D(E({},I),{customGroupsEnabled:!0,flattenedItems$:le(f),contactsWithoutGroup:c,groups:g}))}else{let c=r.map(g=>({type:"custom",custom:g})),p=this.createFlattenedItems({allItems:c,isExpandedGroups:!1,isCustomGroups:!1});this.componentConfigSignal.update(g=>D(E({},g),{customGroupsEnabled:!1,flattenedItems$:le(p)}))}let s=this.getViewport();if(s){let c=this.ITEM_SIZE*this.MAX_VISIBLE_ITEMS;s.style.height=`${c}px`,s.style.maxHeight=`${c}px`}this.openPanelOptimized(),this.cd.markForCheck()}}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent filterOptions: ",e)}})}displayFn(e){try{return e?.name||e?.email||""}catch(t){return this.loggingService.catch("Error in AutocompletePanelComponent displayFn: ",t),""}}trackByFlattenedItem(e,t){try{return t.id||e.toString()}catch(r){return this.loggingService.catch("Error in AutocompletePanelComponent trackByFlattenedItem: ",r),e.toString()}}createFlattenedItems(e){try{let{allItems:t,contactsWithoutGroup:r,groups:a,newUserContact:s,isExpandedGroups:c=!1,isCustomGroups:p=!1}=e,g=[];if(c||p){if(!this.componentConfigSignal().showMentionGroupsOnly&&!this.componentConfigSignal().showMentionGroupsFirst&&r?.forEach((f,I)=>{let T=new wm;T.originalItem=f,T.disabled=!!f.disabled,T.id=p?`velt-option-custom-ungrouped-${I}`:`velt-option-user-${I}`,T.testId=p?`${this.componentId}-custom-ungrouped-${I}`:`${this.componentId}-user-${I}`,g.push(T)}),a?.forEach((f,I)=>{if(f?.members?.length){let T=new wm;T.originalItem={type:"group",group:f},T.isGroupHeader=!0,T.disabled=!0,T.group=f,T.id=p?`velt-option-custom-group-${I}`:`velt-option-group-${I}`,T.testId=p?`${this.componentId}-custom-group-${I}`:`${this.componentId}-group-${I}`,g.push(T),f.members.forEach((B,z)=>{let G=new wm;G.originalItem=B,G.isGroupMember=!0,G.disabled=B.disabled||!1,G.id=p?`velt-option-custom-group-${I}-member-${z}`:`velt-option-group-${I}-member-${z}`,G.testId=p?`${this.componentId}-custom-group-${I}-member-${z}`:`${this.componentId}-group-${I}-member-${z}`,g.push(G)})}}),!this.componentConfigSignal().showMentionGroupsOnly&&this.componentConfigSignal().showMentionGroupsFirst&&r?.length){let f=new wm;f.originalItem={type:"group"},f.isGroupHeader=!0,f.disabled=!0,f.groupName="Ungrouped",f.id="velt-option-ungrouped",f.testId=`${this.componentId}-ungrouped`,g.push(f),r.forEach((I,T)=>{let B=new wm;B.originalItem=I,B.isGroupMember=!0,B.disabled=I.disabled||!1,B.id=`velt-option-user-${T}`,B.testId=`${this.componentId}-user-${T}`,g.push(B)})}}else t.forEach((f,I)=>{let T=new wm;T.originalItem=f,T.disabled=f.disabled||!1,T.id=`velt-option-${I}`,T.testId=`${this.componentId}-${I}`,g.push(T)});if(s?.contact?.email){let f=new wm;f.originalItem=s,f.isNewContact=!0,f.id="velt-new-contact-option",f.testId=`${this.componentId}-new-contact`,g.push(f)}return g}catch(t){return this.loggingService.catch("Error in AutocompletePanelComponent createFlattenedItems: ",t),[]}}setTriggerToMatAutocomplete(){try{this.matAutocomplete&&this.trigger&&(this.trigger.autocomplete=this.matAutocomplete)}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent setTriggerToMatAutocomplete: ",e)}}handleInput(e){try{if(e?.target?.hasAttribute("contenteditable")){let t="",r=this.autocompleteDataMap?Object.keys(this.autocompleteDataMap):["@"];if(e?.data===" "&&(t=tC(e?.target,r),t&&r.includes(t.trim()))){this.closePanel();return}if(["safari","firefox"].includes(this.deviceInfo?.browserName?.toLowerCase())?(!this.trigger?.panelOpen&&!this.autocompleteDataMap[e?.data||""]&&(this.oldText=e.target.innerText),this.newText=e.target.innerText,t=this.getWordAtCursorForSafari()):t=tC(e?.target,r),e?.target?.innerHTML.length===1&&(this.selectedAutocompleteData=void 0),t){let a=t.charAt(0),s=window.getSelection(),c=!1;if(s&&s.rangeCount>0){let p=s.getRangeAt(0),g=p.startOffset,f=p.commonAncestorContainer?.textContent||"";c=this.isAutocompleteDisabledAtPosition(f,g,r)}if(!c&&(!this.selectedAutocompleteData||this.autocompleteDataMap[a])&&(this.selectedAutocompleteData=this.autocompleteDataMap[a]),!c&&this.selectedAutocompleteData){this.trigger?.panelOpen||(this.openPanelOptimized(),this.filterOptions());let p=t.substring(1);this.inputFilterFormControl.setValue(p);let g=!1;if(this.componentConfigSignal().customAutocompleteSearch&&(this.trigger?.panelOpen?a===this.selectedAutocompleteData.hotkey&&(g=!0):g=!0,g)){let f={event:e,searchText:p,type:this.selectedAutocompleteData?.type};this.commentActionsService.autocompleteSearch(f)}}else this.inputFilterFormControl.setValue(t),c&&this.trigger?.panelOpen&&(this.trigger.closePanel(),this.selectedAutocompleteData=void 0)}else this.inputFilterFormControl.setValue(""),this.trigger?.panelOpen&&(this.trigger.closePanel(),this.selectedAutocompleteData=void 0)}else{let t=e?.target?.value;if(this.inputFilterFormControl.setValue(t),!this.matAutocompleteTrigger?.panelOpen&&(this.openPanelOptimized(),this.componentConfigSignal().customAutocompleteSearch)){let r={event:e,searchText:t,type:this.selectedAutocompleteData?.type};this.commentActionsService.autocompleteSearch(r)}}e.stopPropagation()}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent handleInput: ",t)}}getWordAtCursorForSafari(){try{let e=this.oldText?.split(/\s+/)?.filter(a=>a),t=this.newText?.split(/\s+/)?.filter(a=>a);this.wordIndex=-1;let r="";return t?.forEach((a,s)=>{e[s]!==a&&(r=a,this.wordIndex=s)}),r}catch(e){return this.loggingService.catch("Error in AutocompletePanelComponent getWordAtCursorForSafari: ",e),""}}onOptionSelected(e){try{if(this.enterPressed.emit(),this.selectedAutocompleteData)if(e.option.value?.type==="group"){let t=e.option.value.group;this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null,a=this.replaceWordAtCursor(r,t?.metadata?.groupName);a&&this.groupOptionSelected.emit({text:a,groupId:t?.metadata?.groupId,clientGroupId:t?.metadata?.clientGroupId})}else if(this.selectedAutocompleteData.type==="contact"){let t=e.option.value.contact;if(t?.visibility=="here"){this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null;this.replaceWordAtCursor(r,t?.name),this.atHereSelected.emit(t)}else if(!t?.email||new RegExp(U.REGEX_EMAIL).test("@"+t?.email)){this.addContact(),this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let a=this.trigger?this.trigger._element?.nativeElement:null,s=t?.name||t?.email,c=this.replaceWordAtCursor(a,s);this.optionSelected.emit(t),this.userContactOptionSelected.emit({text:c,userId:t.userId,contact:t}),this.callbackOnOptionSelected(t)}}else{let t=e.option.value.custom;this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null,a=this.replaceWordAtCursor(r,t.name);a&&this.customOptionSelected.emit({text:a,custom:t})}this.closePanel()}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent onOptionSelected: ",t)}}onOptionClick(e){try{if(this.selectedAutocompleteData)if(this.selectedAutocompleteData.type==="custom"){let t=e.custom;if(t){this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null,a=this.replaceWordAtCursor(r,t.name);a&&this.customOptionSelected.emit({text:a,custom:t}),this.closePanel()}}else if(e?.type==="group"){let t=e.group;if(t){this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null,a=this.replaceWordAtCursor(r,t?.metadata?.groupName);a&&this.groupOptionSelected.emit({text:a,groupId:t?.metadata?.groupId,clientGroupId:t?.metadata?.clientGroupId}),this.closePanel()}}else{let t=e.contact;if(t)if(t?.visibility==="here"){this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let r=this.trigger?this.trigger._element?.nativeElement:null;this.replaceWordAtCursor(r,t.name),this.atHereSelected.emit(t),this.closePanel()}else{if(!t?.email||new RegExp(U.REGEX_EMAIL).test("@"+t?.email)){this.addContact(),this.autocompletePanelInput?.nativeElement&&(this.autocompletePanelInput.nativeElement.value=""),this.inputFilterFormControl.setValue(null);let a=this.trigger?this.trigger._element?.nativeElement:null,s=t?.name||t?.email,c=this.replaceWordAtCursor(a,s);this.optionSelected.emit(t),this.userContactOptionSelected.emit({text:c,userId:t.userId,contact:t}),this.callbackOnOptionSelected(t)}this.closePanel()}}}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent onOptionClick: ",t)}}addContact(){try{this.componentConfigSignal().newUserContact?.contact&&(this.contactService.addUserContact(this.componentConfigSignal().newUserContact?.contact),this.componentConfigSignal.update(e=>(e=D(E({},e),{newUserContact:void 0}),e)))}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent addContact: ",e)}}replaceWordAtCursor(e,t){try{let r="";if(e){let a=s=>{let c=s.charAt(0);return this.selectedAutocompleteData?.hotkey===c?c:""};if(["safari","firefox"].includes(this.deviceInfo?.browserName?.toLowerCase())){let s=this.newText?.split(/\s+/)?.filter(f=>f),c=s[this.wordIndex];r=(a(c||"")||"")+t,s[this.wordIndex]=r;let g=s.join(" ");e.innerText=g}else{let s=this.autocompleteDataMap?Object.keys(this.autocompleteDataMap):["@"],c=tC(e,s);r=(a(c||"")||"")+t,Wk(e,r,s)}}return r}catch(r){return this.loggingService.catch("Error in AutocompletePanelComponent replaceWordAtCursor: ",r),""}}_filter(e){try{let t=e.email?.toLowerCase();return this.userContacts?.filter(r=>r?.email?.includes(t)||r?.name?.toLowerCase()?.includes(t)||r?.organizationName?.toLowerCase()?.includes(t))}catch(t){return this.loggingService.catch("Error in AutocompletePanelComponent _filter: ",t),[]}}_filterCustom(e){try{return this.selectedAutocompleteData?.data?.filter(t=>t.name?.toLowerCase()?.includes(e?.toLowerCase()))||[]}catch(t){return this.loggingService.catch("Error in AutocompletePanelComponent _filterCustom: ",t),[]}}_filterGroup(e){try{return this.organizationGroups?.filter(t=>t?.metadata?.groupName?.toLowerCase()?.includes(e?.toLowerCase()))}catch(t){return this.loggingService.catch("Error in AutocompletePanelComponent _filterGroup: ",t),[]}}fetchFilteredUsersFromDb(e){return Q(this,null,function*(){try{yield this.contactService.searchUsers(e)}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent fetchFilteredUsersFromDb: ",t)}})}setAutocompletePosition(){try{this.matAutocompleteTrigger&&(this.matAutocompleteTrigger.position=this.position)}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent setAutocompletePosition: ",e)}}callbackOnOptionSelected(e){try{this.contactService.onContactSelected(e)}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent callbackOnOptionSelected: ",t)}}getViewport(){try{return this.matAutocompleteTrigger?._overlayRef?.overlayElement?.querySelector("cdk-virtual-scroll-viewport")||null}catch(e){return this.loggingService.catch("Error in AutocompletePanelComponent getViewport: ",e),null}}openPanelOptimized(){try{this.trigger?requestAnimationFrame(()=>{this.trigger?.openPanel(),this.trigger?.updatePosition(),setTimeout(()=>{this.autocompleteStateChanged.emit(!0)},10)}):this.matAutocompleteTrigger&&(this.matAutocompleteTrigger?.panelOpen||requestAnimationFrame(()=>{this.matAutocompleteTrigger?.openPanel(),this.matAutocompleteTrigger?.updatePosition(),setTimeout(()=>{this.autocompleteStateChanged.emit(!0)},10)})),setTimeout(()=>{this.viewport?.scrollToIndex(1),this.viewport?.scrollToIndex(0)},50)}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent openPanelOptimized: ",e)}}closePanel(){try{this.trigger?(this.trigger.closePanel(),this.inputFilterFormControl.setValue("")):this.matAutocompleteTrigger&&this.matAutocompleteTrigger.closePanel(),this.type!=="contact"&&(this.selectedAutocompleteData=void 0),setTimeout(()=>{this.autocompleteStateChanged.emit(!1)},300)}catch(e){this.loggingService.catch("Error in AutocompletePanelComponent closePanel: ",e)}}disableAutocompleteAtPosition(e){try{this.autocompleteDisabledPositions.add(e),setTimeout(()=>{this.autocompleteDisabledPositions.delete(e)},3e4)}catch(t){this.loggingService.catch("Error in AutocompletePanelComponent disableAutocompleteAtPosition: ",t)}}isAutocompleteDisabledAtPosition(e,t,r){try{let a=-1;for(let s of r){let c=e.lastIndexOf(s,t);c>a&&(a=c)}return a!==-1&&this.autocompleteDisabledPositions.has(a)}catch(a){return this.loggingService.catch("Error in AutocompletePanelComponent isAutocompleteDisabledAtPosition: ",a),!1}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(Ll),h(Si),h(_),h(R),h(Kd),h(Ci),h(an),h(Jr),h(Ja),h(Ke),h(S),h(Zn),h(we),h(il))},o.\u0275cmp=O({type:o,selectors:[["velt-autocomplete-panel-internal"]],viewQuery:function(t,r){if(t&1&&(it(Ynn,5),it(Knn,5),it(Znn,5),it(Xnn,5)),t&2){let a;Je(a=et())&&(r.matAutocomplete=a.first),Je(a=et())&&(r.matAutocompleteTrigger=a.first),Je(a=et())&&(r.autocompletePanelInput=a.first),Je(a=et())&&(r.viewport=a.first)}},hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{type:"type",trigger:[0,"autocompletePanelTrigger","trigger"],triggerElement:[0,"autocompletePanelTriggerElement","triggerElement"],hideInput:"hideInput",placeholder:"placeholder",metadata:"metadata",enableOnFocus:"enableOnFocus",position:[0,"autocompletePanelPosition","position"],excludeContacts:"excludeContacts",showAtHere:"showAtHere"},outputs:{optionSelected:"optionSelected",atHereSelected:"atHereSelected",userContactOptionSelected:"userContactOptionSelected",customOptionSelected:"customOptionSelected",groupOptionSelected:"groupOptionSelected",enterPressed:"enterPressed",autocompleteStateChanged:"autocompleteStateChanged"},standalone:!1,features:[V([S]),L],decls:8,vars:17,consts:[["matAutocomplete","matAutocomplete"],["userContactRef",""],["autocompletePanelInput","","matAutocompleteTrigger","matAutocompleteTrigger"],["viewport",""],["role","combobox",1,"velt-autocomplete-panel"],[1,"velt-autocomplete-panel--input"],["type","text","autofocus","","autofocus","",3,"placeholder","matAutocomplete","matAutocompleteDisabled","matAutocompletePosition","keyup","keydown","keyup.escape","input",4,"ngIf"],["role","listbox",1,"velt-autocomplete-panel--autocomplete",3,"optionSelected","autoActiveFirstOption","hideSingleSelectionIndicator","snippylyOverlay","snippylyOverlayZIndex","displayWith"],["class","velt-autocomplete-panel--container",3,"s-comment-autocomplete-panel-dark",4,"veltIf"],["type","text","autofocus","","autofocus","",3,"keyup","keydown","keyup.escape","input","placeholder","matAutocomplete","matAutocompleteDisabled","matAutocompletePosition"],[1,"velt-autocomplete-panel--container"],["itemSize","55","minBufferPx","350","maxBufferPx","600","templateCacheSize","350","class","velt-autocomplete-panel--viewport",4,"ngIf"],["class","velt-autocomplete-panel--normal-viewport",4,"ngIf"],["itemSize","55","minBufferPx","350","maxBufferPx","600","templateCacheSize","350",1,"velt-autocomplete-panel--viewport"],[3,"disabled","value","velt-group-option","velt-group-member-option","pointerdown","pointerup",4,"cdkVirtualFor","cdkVirtualForOf","cdkVirtualForTrackBy"],[3,"pointerdown","pointerup","disabled","value"],[4,"ngIf"],[3,"componentConfigSignal","group","groupName"],[1,"velt-group-member"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"velt-autocomplete-panel--normal-viewport"],[3,"disabled","value","velt-group-option","velt-group-member-option","pointerdown","pointerup",4,"ngFor","ngForOf","ngForTrackBy"],[3,"componentConfigSignal","selectorItem","isNewContact"]],template:function(t,r){if(t&1){let a=K();y(0,"div",4)(1,"div",5),u(2,ein,3,8,"input",6),b()(),y(3,"mat-autocomplete",7,0),W("optionSelected",function(c){return N(a),F(r.onOptionSelected(c))}),u(5,hin,5,9,"div",8),b(),u(6,fin,1,3,"ng-template",null,1,Te)}if(t&2){let a=me(4);x("data-testid",r.componentId)("aria-expanded",r.trigger==null?null:r.trigger.panelOpen)("aria-haspopup",!0)("aria-controls",r.componentId),m(),x("data-testid",r.componentId+"-input-container"),m(),d("ngIf",!r.hideInput),m(),d("autoActiveFirstOption",!0)("hideSingleSelectionIndicator",!0)("snippylyOverlay",a)("snippylyOverlayZIndex",2147483627)("displayWith",r.displayFn),m(2),d("veltIf",k(14,Jnn,r.conditionSignal(),A(12,Qnn,r.componentConfigSignal)))}},dependencies:[Et,X,Dt,KB,DS,qv,Xb,U0,Qb,gi,JC,M1,se,TB],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-autocomplete-panel--autocomplete{--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-autocomplete-panel--autocomplete:has(>.s-comment-autocomplete-panel-dark){--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)}[_nghost-%COMP%] *[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;line-height:1.5;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit));font-family:var(--velt-default-font-family)}[_nghost-%COMP%] *[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert}.velt-autocomplete-panel[_ngcontent-%COMP%]{position:relative;width:100%}.velt-autocomplete-panel--input[_ngcontent-%COMP%]{width:100%}.velt-autocomplete-panel--input[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{width:100%;padding:8px;border-radius:var(--velt-border-radius-sm);background:var(--velt-background-0);color:var(--velt-text-1);font-size:14px;line-height:1.5;outline:none}.velt-autocomplete-panel--input[_ngcontent-%COMP%] input[_ngcontent-%COMP%]:focus{border-color:var(--velt-border-4)} .velt-autocomplete-panel--autocomplete{background:var(--velt-background-0);border:1px solid var(--velt-border-2);box-shadow:0 2px 4px #0000001a;max-height:256px;overflow:auto} .velt-autocomplete-panel--autocomplete::-webkit-scrollbar{display:none;width:0;height:0} .velt-autocomplete-panel--autocomplete::-webkit-scrollbar{width:0;height:0} .velt-autocomplete-panel--autocomplete::-webkit-scrollbar-button{width:0;height:0} .velt-autocomplete-panel--autocomplete.mat-mdc-autocomplete-panel{padding:0;border-radius:var(--velt-border-radius-md)!important} .velt-autocomplete-panel--autocomplete.mat-mdc-autocomplete-panel .mat-mdc-option.mdc-list-item{font-size:14px;line-height:1.5;height:auto;padding:8px 16px;background:var(--velt-background-0)} .velt-autocomplete-panel--autocomplete.mat-mdc-autocomplete-panel .mat-mdc-option.mdc-list-item:hover:not(.mdc-list-item--disabled){background:var(--velt-background-2)} .velt-autocomplete-panel--autocomplete.mat-mdc-autocomplete-panel .mat-mdc-option.mdc-list-item.mat-mdc-option-active{background:var(--velt-background-3)} .velt-autocomplete-panel--autocomplete.mat-mdc-autocomplete-panel .mat-mdc-option.mdc-list-item .mdc-list-item__primary-text{color:var(--velt-text-1);width:100%} .velt-autocomplete-panel--autocomplete .cdk-virtual-scroll-viewport{height:100%;width:100%;max-height:256px;background:var(--velt-background-0)} .velt-autocomplete-panel--autocomplete .cdk-virtual-scroll-viewport .cdk-virtual-scroll-content-wrapper{max-width:100%;width:100%;box-sizing:border-box} .velt-autocomplete-panel--autocomplete .velt-autocomplete-panel--container{background:var(--velt-background-0)}.velt-autocomplete-panel--viewport[_ngcontent-%COMP%]{height:256px;width:100%;background:var(--velt-background-0);scrollbar-width:none}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%]{max-height:256px;width:100%;overflow-y:auto;background:var(--velt-background-0);scrollbar-width:none}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%] .velt-group-option[_ngcontent-%COMP%]{overflow:hidden;color:var(--velt-text-6, #666);text-overflow:ellipsis;font-size:12px;font-style:normal;font-weight:400;line-height:normal;text-transform:uppercase;padding:4px 12px;border-top:1px solid var(--velt-border-2);margin-top:12px}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%] .velt-group-option[_ngcontent-%COMP%]:first-child{border-top:none;margin-top:0}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%] .velt-group-toggle[_ngcontent-%COMP%]{font-size:10px;color:var(--velt-text-2)}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%] .velt-group-member-option[_ngcontent-%COMP%]{padding-left:28px;background-color:var(--velt-background-0)}.velt-autocomplete-panel--expanded-groups[_ngcontent-%COMP%] .velt-group-member[_ngcontent-%COMP%]{width:100%}"],changeDetection:0});let i=o;return i})();function vin(i,o){if(i&1){let n=K();v(0),y(1,"div",23)(2,"div",24),te(3),b(),y(4,"div",25),W("click",function(){let t=N(n).$implicit,r=l();return F(r.removeSelectedUserToInvite(t))}),ce(),y(5,"svg",26),w(6,"path",7),b()()(),C()}if(i&2){let n=o.$implicit;m(3),ze((n==null||n.user==null?null:n.user.name)||(n==null||n.user==null?null:n.user.email))}}function Cin(i,o){if(i&1){let n=K();v(0),y(1,"div",31),W("click",function(){let t=N(n).$implicit,r=l(2);return F(r.selectRole(t))}),ce(),y(2,"svg",32),w(3,"path",33),b(),ht(),y(4,"div")(5,"h4"),te(6),P(7,"translate"),b(),y(8,"p"),te(9),P(10,"translate"),b()()(),C()}if(i&2){let n=o.$implicit,e=o.first,t=l(2);m(),pe("border-top",!e),m(),at("visibility",(t.selectedUserRole==null?null:t.selectedUserRole.id)===(n==null?null:n.id)?"visible":"hidden"),m(4),ze(M(7,6,n==null?null:n.name)),m(3),ze(M(10,8,n==null?null:n.description))}}function _in(i,o){if(i&1&&(y(0,"div",27)(1,"div",28),u(2,Cin,11,10,"ng-container",12),b(),te(3),P(4,"translate"),ce(),y(5,"svg",29),w(6,"path",30),b()()),i&2){let n=l();pe("disabled",!n.isUserAdmin),m(2),d("ngForOf",n.userRoles),m(),Se(" ",M(4,4,n.selectedUserRole==null?null:n.selectedUserRole.name)," ")}}function yin(i,o){i&1&&(ce(),y(0,"svg",32),w(1,"path",44),b())}function Sin(i,o){if(i&1&&(y(0,"div",41),te(1),P(2,"translate"),u(3,yin,2,0,"svg",43),b()),i&2){let n=l().$implicit,e=l(2);m(),Se(" ",M(2,2,n==null||n.role==null?null:n.role.name)," "),m(2),d("ngIf",e.isUserAdmin&&(n==null||n.user==null?null:n.user.email)!==(e.user==null?null:e.user.email))}}function bin(i,o){if(i&1){let n=K();y(0,"div",28)(1,"div",45),W("click",function(){N(n);let t=l().$implicit,r=l(2);return F(r.removeUser(t))}),te(2),P(3,"translate"),b()()}i&2&&(m(2),Se(" ",M(3,1,"Remove")," "))}function Iin(i,o){if(i&1&&(v(0),y(1,"div",38)(2,"div",39),w(3,"snippyly-user-avatar",40),te(4),b(),y(5,"div",41)(6,"app-overlay-tooltip",42),u(7,Sin,4,4,"ng-template",null,1,Te)(9,bin,4,3,"ng-template",null,2,Te),b()()(),C()),i&2){let n=o.$implicit,e=l(2);m(3),d("user",n==null?null:n.user)("background","#625DF5"),m(),Se(" ",(n==null||n.user==null?null:n.user.name)||(n==null||n.user==null?null:n.user.email)," "),m(2),d("disabled",!(e.isUserAdmin&&(n==null||n.user==null?null:n.user.email)!==(e.user==null?null:e.user.email)))}}function Ein(i,o){i&1&&(v(0),y(1,"div"),te(2),P(3,"translate"),b(),C()),i&2&&(m(2),ze(M(3,1,"No users are added.")))}function xin(i,o){if(i&1&&(y(0,"div",34)(1,"div",35),te(2),P(3,"translate"),b(),u(4,Iin,11,4,"ng-container",36)(5,Ein,4,3,"ng-container",37),b()),i&2){let n=l();m(2),ze(M(3,4,"People on this project")),m(2),d("ngForOf",n.documentUsers)("ngForTrackBy",n.trackByDocumentUserId),m(),d("ngIf",!(n.documentUsers!=null&&n.documentUsers.length))}}function Tin(i,o){if(i&1&&(v(0),y(1,"div",38)(2,"div",39),w(3,"snippyly-user-avatar",40),te(4),P(5,"translate"),b()(),C()),i&2){let n=o.$implicit;m(3),d("user",n)("background","#625DF5"),m(),Se(" ",M(5,3,(n==null?null:n.name)||(n==null?null:n.email))," ")}}function Din(i,o){if(i&1&&(y(0,"div",38)(1,"div",39),w(2,"snippyly-user-avatar",40),te(3),P(4,"translate"),b(),y(5,"div",27),te(6),P(7,"translate"),b()()),i&2){let n=l().$implicit;m(2),d("user",n)("background","#625DF5"),m(),Se(" ",M(4,4,(n==null?null:n.name)||(n==null?null:n.email))," "),m(3),Se(" ",M(7,6,"Invited")," ")}}function win(i,o){if(i&1&&(v(0),u(1,Din,8,8,"div",46),C()),i&2){let n=o.$implicit,e=l(2);m(),d("ngIf",!e.huddleUsersByEmailMap[n==null?null:n.email])}}function Oin(i,o){if(i&1&&(y(0,"div",34)(1,"div",35),te(2),P(3,"translate"),b(),u(4,Tin,6,5,"ng-container",36)(5,win,2,1,"ng-container",36),b()),i&2){let n=l();m(2),ze(M(3,5,"People on this huddle")),m(2),d("ngForOf",n.huddleUsers)("ngForTrackBy",n.trackByHuddleUserId),m(),d("ngForOf",n.huddleInvitees)("ngForTrackBy",n.trackByHuddleInviteeId)}}function Ain(i,o){if(i&1){let n=K();y(0,"div",47)(1,"div",48),te(2),P(3,"translate"),b(),y(4,"div",49)(5,"div",28)(6,"div",31),W("click",function(){N(n);let t=l();return F(t.changeDocumentAccessType(t.DocumentAccessTypes.PUBLIC))}),ce(),y(7,"svg",32),w(8,"path",33),b(),ht(),y(9,"div")(10,"h3"),te(11),P(12,"translate"),P(13,"titlecase"),b(),y(14,"p"),te(15),P(16,"translate"),b()()(),y(17,"div",45),W("click",function(){N(n);let t=l();return F(t.changeDocumentAccessType(t.DocumentAccessTypes.RESTRICTED))}),ce(),y(18,"svg",32),w(19,"path",33),b(),ht(),y(20,"div")(21,"h3"),te(22),P(23,"translate"),P(24,"titlecase"),b(),y(25,"p"),te(26),P(27,"translate"),b()()()(),ce(),y(28,"svg",32),w(29,"path",50)(30,"path",51)(31,"path",52),b(),ht(),y(32,"div",53)(33,"h3"),te(34),P(35,"translate"),P(36,"titlecase"),b(),y(37,"p"),te(38),P(39,"translate"),b()()()()}if(i&2){let n=l();m(2),ze(M(3,11,"General access")),m(5),at("visibility",!n.documentAccessType||n.documentAccessType===n.DocumentAccessTypes.PUBLIC?"visible":"hidden"),m(4),ze(M(13,15,M(12,13,n.DocumentAccessTypes.PUBLIC))),m(4),ze(M(16,17,n.documentAccessTypeMap[n.DocumentAccessTypes.PUBLIC]==null?null:n.documentAccessTypeMap[n.DocumentAccessTypes.PUBLIC].description)),m(3),at("visibility",n.documentAccessType===n.DocumentAccessTypes.RESTRICTED?"visible":"hidden"),m(4),ze(M(24,21,M(23,19,n.DocumentAccessTypes.RESTRICTED))),m(4),ze(M(27,23,n.documentAccessTypeMap[n.DocumentAccessTypes.RESTRICTED]==null?null:n.documentAccessTypeMap[n.DocumentAccessTypes.RESTRICTED].description)),m(8),ze(M(36,27,M(35,25,n.documentAccessType||n.DocumentAccessTypes.PUBLIC))),m(4),Se("",M(39,29,n.documentAccessTypeMap[n.documentAccessType?n.documentAccessType:n.DocumentAccessTypes.PUBLIC]==null?null:n.documentAccessTypeMap[n.documentAccessType?n.documentAccessType:n.DocumentAccessTypes.PUBLIC].description)," ")}}function Pin(i,o){i&1&&(ce(),y(0,"svg",54),w(1,"path",55),b())}function Min(i,o){i&1&&(ce(),y(0,"svg",56),w(1,"path",57),b())}var eye=(()=>{let o=class o{constructor(e,t,r,a,s,c,p,g,f,I,T){this.analyticsService=e,this.authService=t,this.configService=r,this.docService=a,this.documentUserAccessService=s,this.huddleService=c,this.loggingService=p,this.iamService=g,this.toastService=f,this.dialogRef=I,this.usersToInvite=[],this.documentUsers=[],this.huddleInvitees=[],this.huddleUsers=[],this.huddleUsersByEmailMap={},this.userRoles=[],this.excludeContacts=[],this.linkCopied=!1,this.hideAccessControlDropdown=!1,this.subscriptions=[],this.title="Share project",this.placeholder="Add email address",this.documentAccessType="",this.DocumentAccessTypes=Di,this.isUserAdmin=!1,this.documentAccessTypeMap=U.DocumentAccessTypeMap,this.documentUserAccessList=!0,this.veltElement=!0;try{T&&(this.hideAccessControlDropdown=!!T.hideAccessControlDropdown,this.type=T.type,this.source=T.source,T.title&&(this.title=T.title),T.placeholder&&(this.placeholder=T.placeholder),this.documentUserAccessList=!!T.documentUserAccessList,this.inviteUrl=T.inviteUrl),this.subscriptions.push(this.authService.getUser$().subscribe(B=>{this.user=B})),this.subscriptions.push(this.iamService.isUserAdmin$().subscribe(B=>{this.isUserAdmin=B})),this.subscriptions.push(this.configService.getSF$().subscribe(B=>{B?this.documentAccessTypeMap=U.DocumentAccessTypeMapSF:this.documentAccessTypeMap=U.DocumentAccessTypeMap})),this.type!=="invite"&&this.subscriptions.push(this.documentUserAccessService.getDocumentUsers$().subscribe(B=>{this.documentUsers=B,this.updateExcludeContacts()})),this.type!=="invite"&&this.subscriptions.push(this.iamService.getRoles$().subscribe(B=>{this.userRoles=B,this.userRoles?.length&&(this.selectedUserRole=this.userRoles?.find(z=>z.name===go.COMMENTER))})),this.type!=="invite"&&this.subscriptions.push(this.iamService.getDocumentIAM$().subscribe(B=>{this.documentAccessType=this.docService.getDocumentAccessType(B)})),this.type==="invite"&&(this.subscriptions.push(this.huddleService.getHuddleAttendees$().subscribe(B=>{this.huddleUsers=B,this.huddleUsersByEmailMap={},B.forEach(z=>{z.email&&(this.huddleUsersByEmailMap[z.email]=z)})})),this.subscriptions.push(this.huddleService.getHuddleInvitees$().subscribe(B=>{this.huddleInvitees=B})))}catch(B){this.loggingService.catch("Error in UserInviteDialogComponent constructor: ",B)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-user-invite-dialog"),this.userRoles?.length&&(this.selectedUserRole=this.userRoles?.find(e=>e.name===go.COMMENTER))}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent ngOnInit: ",e)}}updateExcludeContacts(){try{this.excludeContacts=[],this.excludeContacts.push(...this.documentUsers.map(e=>e.user)),this.excludeContacts.push(...this.usersToInvite.map(e=>e.user))}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent updateExcludeContacts: ",e)}}trackByDocumentUserId(e,t){return t.id}trackByHuddleUserId(e,t){return t.userSnippylyId||t.userId}trackByHuddleInviteeId(e,t){return t.userId||t.email}selectRole(e){try{this.selectedUserRole=e}catch(t){this.loggingService.catch("Error in UserInviteDialogComponent selectRole: ",t)}}onUserSelected(e){try{let t=new r9;t.id=e.email?Tt(e.email):Tt(e.userId),t.user=e,this.usersToInvite.find(r=>r.id===t.id)||this.usersToInvite.push(t),this.updateExcludeContacts()}catch(t){this.loggingService.catch("Error in UserInviteDialogComponent onUserSelected: ",t)}}inviteSelectedUsers(){try{if(this.usersToInvite?.length)if(this.type==="invite"){let e=this.usersToInvite.map(t=>t.user);this.analyticsService.trackEvent(Y.Events.InviteDialog.USER_INVITED,{source:this.source}),this.huddleService.inviteUsers(e),this.toastService.setToast({message:"Invitation sent!",type:"success",duration:2e3})}else{this.usersToInvite.forEach(a=>{this.selectedUserRole&&(a.role=this.selectedUserRole)});let e=this.usersToInvite.filter(a=>a.role?.name===go.ADMIN).map(a=>a.user.email),t=this.usersToInvite.filter(a=>a.role?.name===go.COMMENTER).map(a=>a.user.email),r={actionType:ez.INVITE,userInvite:{admin:e?.length?{emails:e,emailProperties:{url:this.getInviteUrl()}}:void 0,commenter:t?.length?{emails:t,clientDocumentId:this.docService.getDocumentPaths()?.clientDocumentId,documentId:this.docService.getDocumentPaths()?.documentId,clientOrganizationId:this.user?.clientOrganizationId,organizationId:this.user?.organizationId,emailProperties:{url:this.getInviteUrl()}}:void 0}};this.documentUserAccessService.updateNotificationsDatabase(r),this.toastService.setToast({message:"Invitation sent!",type:"success",duration:2e3})}this.usersToInvite=[]}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent inviteSelectedUsers: ",e)}}removeSelectedUserToInvite(e){try{this.usersToInvite=this.usersToInvite.filter(t=>t.id!==e.id),this.updateExcludeContacts()}catch(t){this.loggingService.catch("Error in UserInviteDialogComponent removeSelectedUserToInvite: ",t)}}updateUserRole(e,t){try{let r=e?.role?.name,a=t?.name;e.role=t,this.documentUserAccessService.updateDocumentUser(e,{oldAccess:r,newAccess:a})}catch(r){this.loggingService.catch("Error in UserInviteDialogComponent updateUserRole: ",r)}}removeUser(e){try{this.analyticsService.trackEvent(Y.Events.ShareDialog.DOCUMENT_USER_ACCESS_REMOVED,{targetUserId:e?.user?.userId,targetUserEmail:e?.user?.email,roleType:e?.role?.name}),this.documentUserAccessService.removeDocumentUser(e),this.toastService.setToast({message:"User removed!",type:"success",duration:2e3})}catch(t){this.loggingService.catch("Error in UserInviteDialogComponent removeUser: ",t)}}getInviteUrl(){try{return this.inviteUrl||window.location.href}catch(e){return this.loggingService.catch("Error in UserInviteDialogComponent getInviteUrl: ",e),""}}copyLink(){try{let e=this.getInviteUrl();this.linkCopied=!0,Qs(e),setTimeout(()=>{this.linkCopied=!1},2e3),this.type==="invite"?this.analyticsService.trackEvent(Y.Events.InviteDialog.INVITE_LINK_COPIED,{source:this.source}):this.type==="share"&&this.analyticsService.trackEvent(Y.Events.ShareDialog.SHARE_LINK_COPIED)}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent copyLink: ",e)}}changeDocumentAccessType(e){try{this.documentAccessType!==e&&(this.analyticsService.trackEvent(Y.Events.ShareDialog.DOCUMENT_ACCESS_CHANGED,{oldAccessType:this.documentAccessType,newAccessType:e}),this.docService.changeDocumentAccessType(e),this.toastService.setToast({message:"Access changed to '"+e+"'.",type:"success",duration:2e3}))}catch(t){this.loggingService.catch("Error in UserInviteDialogComponent changeDocumentAccessType: ",t)}}closeDialog(){try{this.dialogRef.close()}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent closeDialog: ",e)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>e.unsubscribe())}catch(e){this.loggingService.catch("Error in UserInviteDialogComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(Ft),h(ot),h(Z1e),h(wr),h(_),h(En),h(Tm),h(dr),h(rc,8))},o.\u0275cmp=O({type:o,selectors:[["snippyly-user-invite-dialog"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},standalone:!1,decls:32,vars:27,consts:[["userSelectorRef",""],["triggerTemplate",""],["tooltipTemplate",""],[1,"s-video-settings-modal",3,"click","pointerdown","pointerup"],[1,"s-video-header"],[1,"s-video-header-name"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg",1,"s-cursor-pointer",3,"click"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","#80808A"],[1,"s-video-settings-modal-item"],[1,"s-input"],[1,"s-input-chip-list-container"],[1,"s-chip-list"],[4,"ngFor","ngForOf"],[1,"s-input-user-selector",3,"optionSelected","placeholder","enableOnFocus"],["class","s-role dropdown",3,"disabled",4,"ngIf"],["class","s-video-settings-modal-item s-people-list-container",4,"ngIf"],["class","s-general-access-container",4,"ngIf"],[1,"s-buttons-wrap"],[1,"s-button","s-secondary",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["width","20","height","20","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary",3,"click"],[1,"s-chip"],[1,"s-chip-user"],[1,"s-chip-remove",3,"click"],["width","14","height","14","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],[1,"s-role","dropdown"],[1,"dropdown-content"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"dropdown-icon"],["fill-rule","evenodd","clip-rule","evenodd","d","M7.79289 9.79289C8.18342 9.40237 8.81658 9.40237 9.20711 9.79289L12 12.5858L14.7929 9.79289C15.1834 9.40237 15.8166 9.40237 16.2071 9.79289C16.5976 10.1834 16.5976 10.8166 16.2071 11.2071L12.7071 14.7071C12.3166 15.0976 11.6834 15.0976 11.2929 14.7071L7.79289 11.2071C7.40237 10.8166 7.40237 10.1834 7.79289 9.79289Z","fill","#D4D6DF"],[1,"dropdown-item",3,"click"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M18.7071 7.29289C19.0976 7.68342 19.0976 8.31658 18.7071 8.70711L10.7071 16.7071C10.3166 17.0976 9.68342 17.0976 9.29289 16.7071L5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929C5.68342 10.9024 6.31658 10.9024 6.70711 11.2929L10 14.5858L17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289Z","fill","#80808A"],[1,"s-video-settings-modal-item","s-people-list-container"],[1,"s-people-list-title"],[4,"ngFor","ngForOf","ngForTrackBy"],[4,"ngIf"],[1,"s-user"],[1,"s-user-info"],[1,"s-flex",3,"user","background"],[1,"s-role"],[3,"disabled"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#404044"],[1,"dropdown-item","border-top",3,"click"],["class","s-user",4,"ngIf"],[1,"s-general-access-container"],[1,"s-general-access-title"],[1,"s-button","s-secondary","s-document-access-btn","dropdown"],["fill-rule","evenodd","clip-rule","evenodd","d","M12 11C10.2274 11 8.64844 11.0646 7.35838 11.1466C6.13471 11.2243 5.19379 12.158 5.10597 13.373C5.0435 14.2373 5 15.1481 5 16C5 16.8519 5.0435 17.7627 5.10597 18.627C5.19379 19.842 6.13471 20.7757 7.35838 20.8534C8.64844 20.9354 10.2274 21 12 21C13.7726 21 15.3516 20.9354 16.6416 20.8534C17.8653 20.7757 18.8062 19.842 18.894 18.627C18.9565 17.7627 19 16.8519 19 16C19 15.1481 18.9565 14.2373 18.894 13.373C18.8062 12.158 17.8653 11.2243 16.6416 11.1466C15.3516 11.0646 13.7726 11 12 11ZM7.2315 9.15059C5.01376 9.29156 3.27137 11.0124 3.11117 13.2288C3.04652 14.1234 3 15.085 3 16C3 16.915 3.04652 17.8766 3.11118 18.7712C3.27137 20.9876 5.01376 22.7084 7.23151 22.8494C8.55778 22.9337 10.1795 23 12 23C13.8205 23 15.4422 22.9337 16.7685 22.8494C18.9862 22.7084 20.7286 20.9876 20.8888 18.7712C20.9535 17.8766 21 16.915 21 16C21 15.085 20.9535 14.1234 20.8888 13.2288C20.7286 11.0124 18.9862 9.29156 16.7685 9.15059C15.4422 9.06629 13.8205 9 12 9C10.1795 9 8.55778 9.06629 7.2315 9.15059Z","fill","#777E91"],["fill-rule","evenodd","clip-rule","evenodd","d","M13 16.7324C13.5978 16.3866 14 15.7403 14 15C14 13.8954 13.1046 13 12 13C10.8954 13 10 13.8954 10 15C10 15.7403 10.4022 16.3866 11 16.7324V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V16.7324Z","fill","#777E91"],["fill-rule","evenodd","clip-rule","evenodd","d","M7 6C7 3.23858 9.23858 1 12 1C14.7614 1 17 3.23858 17 6V10C17 10.5523 16.5523 11 16 11C15.4477 11 15 10.5523 15 10V6C15 4.34315 13.6569 3 12 3C10.3431 3 9 4.34315 9 6V10C9 10.5523 8.55228 11 8 11C7.44772 11 7 10.5523 7 10V6Z","fill","#777E91"],[1,"s-document-access-btn-content"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M6.49027 2.50491C6.46607 2.50996 6.34731 2.53007 6.22635 2.54966C5.17052 2.72053 4.19457 3.45245 3.69214 4.45019C3.56689 4.69886 3.43711 5.08311 3.37864 5.3784C3.31829 5.68302 3.31829 14.3108 3.37864 14.6154C3.52088 15.3336 3.85013 15.9526 4.36233 16.4647C4.76978 16.8722 5.22723 17.1555 5.75266 17.3256C6.23219 17.4809 6.32453 17.4891 7.59205 17.4891H8.76711L8.88599 17.4104C9.06906 17.2893 9.14407 17.146 9.14407 16.9173C9.14407 16.6887 9.06909 16.5453 8.88611 16.4242L8.76728 16.3455L7.6068 16.3286C6.3852 16.3109 6.35854 16.3081 5.96566 16.1588C5.43291 15.9564 4.86723 15.3934 4.67143 14.8707C4.49992 14.4129 4.51091 14.747 4.51091 9.9969C4.51091 5.24677 4.49992 5.58091 4.67143 5.12308C4.88025 4.56564 5.45367 4.01728 6.0476 3.80712C6.46364 3.65989 6.4966 3.65865 9.67189 3.66895C12.8862 3.67939 12.6707 3.6688 13.1239 3.83838C13.3521 3.92374 13.6919 4.15074 13.8939 4.35272C14.0958 4.5547 14.3228 4.89447 14.4082 5.12264C14.5641 5.53916 14.5639 5.53763 14.5816 6.87392L14.5983 8.13484L14.6679 8.24677C14.7061 8.30835 14.791 8.39412 14.8563 8.43737C14.9554 8.50291 15.0078 8.51605 15.1701 8.51605C15.3324 8.51605 15.3848 8.50291 15.4839 8.43737C15.5492 8.39412 15.6341 8.30835 15.6723 8.24677L15.7419 8.13484V6.85925C15.7419 5.89002 15.7321 5.53438 15.7012 5.3784C15.4231 3.97403 14.4078 2.9182 13.0001 2.56948C12.7554 2.50887 12.6941 2.50764 9.64257 2.50177C7.93299 2.49849 6.51446 2.4999 6.49027 2.50491ZM10.1326 4.86732C10.0008 4.90764 9.81429 5.10144 9.77661 5.23721C9.75922 5.29976 9.74547 5.6244 9.74538 5.97344C9.74517 6.73161 9.7789 6.93488 9.97026 7.32843C10.0835 7.56132 10.1471 7.64839 10.358 7.85928C10.5687 8.06997 10.6561 8.13387 10.8888 8.24715C11.3004 8.44752 11.4993 8.4781 12.3174 8.46675L12.9899 8.4574L13.1087 8.37872C13.2923 8.25712 13.3667 8.11437 13.3667 7.88344C13.3667 7.72342 13.3533 7.6705 13.288 7.57182C13.2448 7.50646 13.159 7.42162 13.0974 7.38336C12.9898 7.31647 12.9581 7.31319 12.2817 7.29876C11.6484 7.28524 11.5646 7.27759 11.4445 7.22234C11.2497 7.13276 11.1074 6.99491 11.0146 6.80594C10.9336 6.64091 10.9327 6.63267 10.9182 5.93556C10.904 5.25876 10.9008 5.2275 10.8339 5.11986C10.6956 4.89741 10.3918 4.788 10.1326 4.86732ZM15.7049 9.14973C15.3168 9.21439 14.8688 9.42637 14.5091 9.71547C14.1903 9.97168 12.9551 11.227 12.785 11.4677C12.6151 11.708 12.4379 12.0846 12.3662 12.3575C12.2934 12.6347 12.2934 13.2178 12.3662 13.4864C12.4763 13.8923 12.7739 14.3816 12.9941 14.5185C13.1571 14.6198 13.4451 14.6146 13.6071 14.5074C13.7916 14.3853 13.8652 14.2433 13.8652 14.0094C13.8652 13.8346 13.8552 13.8007 13.7698 13.6869C13.7174 13.6169 13.6316 13.474 13.5792 13.3691C13.4922 13.1949 13.4842 13.1559 13.4861 12.9146C13.4901 12.4126 13.6018 12.2459 14.588 11.2695C15.3768 10.4885 15.479 10.4117 15.8541 10.3176C16.4471 10.1688 17.0959 10.642 17.1542 11.2659C17.1867 11.6138 17.0539 11.95 16.7418 12.3102C16.554 12.527 16.5067 12.6446 16.5261 12.8468C16.5522 13.1185 16.7716 13.3292 17.0627 13.362C17.163 13.3733 17.2272 13.3595 17.3476 13.3006C17.6751 13.1404 18.1188 12.4832 18.2617 11.9469C18.4137 11.3768 18.3213 10.7383 18.0102 10.209C17.8837 9.99361 17.4606 9.57059 17.2452 9.444C16.7724 9.16618 16.2292 9.06241 15.7049 9.14973ZM14.7568 12.1471C14.6858 12.1846 14.588 12.2715 14.5396 12.3402C14.4628 12.4494 14.4517 12.4903 14.4517 12.6643C14.4517 12.846 14.4612 12.8773 14.5601 13.021C14.869 13.4698 14.893 13.8775 14.6373 14.3344C14.5091 14.5636 13.051 16.0217 12.8218 16.15C12.3282 16.4261 11.818 16.3718 11.4502 16.0041C11.1691 15.723 11.0679 15.3616 11.1645 14.9843C11.2245 14.75 11.3364 14.5523 11.5457 14.3107C11.7336 14.0939 11.7808 13.9764 11.7614 13.7742C11.7353 13.5024 11.5159 13.2917 11.2249 13.259C11.1245 13.2476 11.0603 13.2615 10.9399 13.3204C10.6125 13.4806 10.1687 14.1377 10.0258 14.674C9.87388 15.2442 9.96627 15.8826 10.2773 16.4119C10.4039 16.6273 10.8269 17.0504 11.0423 17.177C11.5716 17.488 12.2101 17.5804 12.7802 17.4284C13.0265 17.3628 13.41 17.1783 13.6407 17.0145C13.8608 16.858 14.9432 15.8056 15.2867 15.4139C15.9653 14.64 16.1624 13.7239 15.8293 12.8919C15.562 12.2242 15.1512 11.9389 14.7568 12.1471Z","fill","#80808A"],["width","20","height","20","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M18.7071 7.29289C19.0976 7.68342 19.0976 8.31658 18.7071 8.70711L10.7071 16.7071C10.3166 17.0976 9.68342 17.0976 9.29289 16.7071L5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929C5.68342 10.9024 6.31658 10.9024 6.70711 11.2929L10 14.5858L17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289Z","fill","#ABABB5"]],template:function(t,r){if(t&1){let a=K();y(0,"div",3),W("click",function(c){return N(a),F(c.stopPropagation())})("pointerdown",function(c){return N(a),F(c.stopPropagation())})("pointerup",function(c){return N(a),F(c.stopPropagation())}),y(1,"div",4)(2,"div",5),te(3),P(4,"translate"),b(),ce(),y(5,"svg",6),W("click",function(){return N(a),F(r.closeDialog())}),w(6,"path",7),b()(),ht(),y(7,"div",8),te(8),P(9,"translate"),y(10,"div",9)(11,"div",10)(12,"div",11),u(13,vin,7,1,"ng-container",12),b(),y(14,"velt-autocomplete-panel-internal",13,0),P(16,"translate"),W("optionSelected",function(c){return N(a),F(r.onUserSelected(c))}),b()(),u(17,_in,7,6,"div",14),b()(),u(18,xin,6,6,"div",15)(19,Oin,6,7,"div",15)(20,Ain,40,31,"div",16),y(21,"div",17)(22,"div",18),W("click",function(){return N(a),F(r.copyLink())}),u(23,Pin,2,0,"svg",19)(24,Min,2,0,"svg",20),te(25),P(26,"translate"),P(27,"translate"),b(),w(28,"div",21),y(29,"div",22),W("click",function(){return N(a),F(r.inviteSelectedUsers())}),te(30),P(31,"translate"),b()()()}t&2&&(m(3),Se(" ",M(4,15,r.title)," "),m(5),Se(" ",M(9,17,"Invite users")," "),m(5),d("ngForOf",r.usersToInvite),m(),d("placeholder",M(16,19,r.placeholder))("enableOnFocus",!1),m(3),d("ngIf",!r.hideAccessControlDropdown),m(),d("ngIf",r.documentUserAccessList&&(r.documentUsers==null?null:r.documentUsers.length)),m(),d("ngIf",(r.huddleInvitees==null?null:r.huddleInvitees.length)||(r.huddleUsers==null?null:r.huddleUsers.length)),m(),d("ngIf",r.isUserAdmin&&!r.hideAccessControlDropdown),m(3),d("ngIf",!r.linkCopied),m(),d("ngIf",r.linkCopied),m(),Se(" ",r.linkCopied?M(26,21,"Link Copied!"):M(27,23,"Copy Link")," "),m(4),pe("s-disabled",!(r.usersToInvite!=null&&r.usersToInvite.length)),m(),ze(M(31,25,"Send invite")))},dependencies:[Et,X,Jn,Pm,xu,DB,ge],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%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#dcdde0!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}*[_ngcontent-%COMP%]{box-sizing:border-box}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%], .s-buttons-wrap[_ngcontent-%COMP%], .s-role[_ngcontent-%COMP%], .s-user[_ngcontent-%COMP%], .s-user-info[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#ababb5!important;font-size:.8rem!important;gap:1rem!important}.s-people-list-container[_ngcontent-%COMP%]{overflow:auto!important}.s-people-list-container[_ngcontent-%COMP%] .s-people-list-title[_ngcontent-%COMP%]{position:sticky!important;top:0!important;background:#141416!important;width:100%!important;z-index:1!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:2rem!important;gap:2rem!important;background:#141416!important;border-radius:1rem!important;max-width:42rem!important;width:80vw!important;border:2px solid #303034!important;overflow:auto!important;max-height:80vh!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important}.s-video-header-name[_ngcontent-%COMP%]{gap:.5rem!important;font-weight:600!important;font-size:1.2rem!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:not(.s-disabled):hover{background:#4f4bbf!important}.s-disabled[_ngcontent-%COMP%]{background:#939393!important;cursor:not-allowed!important}.s-secondary[_ngcontent-%COMP%]{border:2px solid #303034!important;border-radius:.5rem!important;color:#ababb5!important;gap:.5rem!important}.s-secondary[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:1rem!important;color:#fff!important;padding:.5rem 0!important}.s-input[_ngcontent-%COMP%]{padding:1rem!important;color:#ababb5!important;width:100%!important;justify-content:space-between!important;border-radius:1rem!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.s-buttons-wrap[_ngcontent-%COMP%]{width:100%!important;justify-content:space-between!important;align-items:stretch!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-user[_ngcontent-%COMP%]{width:100%!important;justify-content:space-between!important}.s-user-info[_ngcontent-%COMP%]{color:#ababb5!important;gap:.75rem!important}.s-user[_ngcontent-%COMP%] .s-role[_ngcontent-%COMP%]{color:#404044!important}.s-role[_ngcontent-%COMP%]{position:relative!important;cursor:pointer!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:100%!important;right:0!important;z-index:10!important}.dropdown[_ngcontent-%COMP%] .dropdown-content.top[_ngcontent-%COMP%]{top:auto!important;bottom:2rem!important}.dropdown-content[_ngcontent-%COMP%]{min-width:max-content!important;overflow:hidden!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:.5rem!important;border:1px solid #303034!important;font-style:normal!important;font-weight:400!important;font-size:1em!important;line-height:1em!important;color:#ababb5!important;background:#141416!important;cursor:pointer!important;transition:.2s ease!important}.dropdown-content[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:#ababb5!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{display:none!important;visibility:hidden!important;opacity:0!important}.dropdown[_ngcontent-%COMP%] .dropdown-icon[_ngcontent-%COMP%]{width:24px!important;min-width:24px!important}.dropdown.disabled[_ngcontent-%COMP%] .dropdown-icon[_ngcontent-%COMP%]{display:none!important}.dropdown[_ngcontent-%COMP%]:not(.disabled):hover .dropdown-content[_ngcontent-%COMP%]{display:flex!important;visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:1em 2rem 1rem 1rem!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:1em!important;line-height:1rem!important;border-radius:0!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown-item[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{color:#fff!important;margin:0!important}.dropdown-item[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0!important}.border-top[_ngcontent-%COMP%]{outline:solid 1px #303034!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important}.s-input-chip-list-container[_ngcontent-%COMP%]{display:flex;width:100%!important;gap:8px!important;flex-wrap:wrap!important;align-items:center!important}.s-input-chip-list-container[_ngcontent-%COMP%] .s-chip-list[_ngcontent-%COMP%]{display:flex!important;gap:8px!important;flex-wrap:wrap!important}.s-input-chip-list-container[_ngcontent-%COMP%] .s-chip-list[_ngcontent-%COMP%] .s-chip[_ngcontent-%COMP%]{padding:8px 16px!important;background:#222226!important;color:#dcdde0!important;border-radius:100px!important;display:flex!important;align-items:center!important;gap:8px!important}.s-input-chip-list-container[_ngcontent-%COMP%] .s-chip-list[_ngcontent-%COMP%] .s-chip[_ngcontent-%COMP%] .s-chip-remove[_ngcontent-%COMP%]{display:flex!important;cursor:pointer!important}.s-input-chip-list-container[_ngcontent-%COMP%] velt-autocomplete-panel-internal.s-input-user-selector[_ngcontent-%COMP%]{flex-basis:250px!important}.s-general-access-container[_ngcontent-%COMP%]{display:flex!important;flex-direction:column!important;width:100%!important;gap:8px!important}.s-general-access-container[_ngcontent-%COMP%] .s-document-access-btn-content[_ngcontent-%COMP%]{position:relative!important}.s-general-access-container[_ngcontent-%COMP%] .s-document-access-btn-content[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important}.s-general-access-container[_ngcontent-%COMP%] .s-document-access-btn[_ngcontent-%COMP%]{position:relative!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;justify-content:flex-start!important}.s-general-access-container[_ngcontent-%COMP%] .s-document-access-btn[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{left:0!important;top:auto!important;bottom:100%!important}.s-general-access-container[_ngcontent-%COMP%] .s-document-access-btn[_ngcontent-%COMP%] *[_ngcontent-%COMP%]{color:#ababb5!important} .velt-mat-dialog-container.snippyly-user-invite-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:20px!important} .velt-mat-dialog-container.snippyly-user-invite-dialog mat-dialog-container velt-autocomplete-panel-internal.s-input-user-selector{flex-grow:1!important} .velt-mat-dialog-container.snippyly-user-invite-dialog mat-dialog-container velt-autocomplete-panel-internal.s-input-user-selector input{background:transparent!important;border:0!important;outline:0!important;color:#fff!important}@media screen and (max-width: 425px){ .velt-mat-dialog-container.snippyly-user-invite-dialog{width:100vw!important;max-width:100vw!important;height:100vh!important} .velt-mat-dialog-container.snippyly-user-invite-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{border-radius:0!important} .velt-mat-dialog-container.snippyly-user-invite-dialog .s-video-settings-modal{width:100vw!important;height:100vh!important;max-width:100vw!important;max-height:100vh!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-user-invite-dialog .s-chip-user{word-break:break-all!important}}"],changeDetection:0});let i=o;return i})();function kin(i,o){i&1&&(y(0,"div",4),ce(),y(1,"svg",5)(2,"g"),w(3,"path",6)(4,"path",7)(5,"path",8),b()()())}function Rin(i,o){if(i&1){let n=K();y(0,"div")(1,"slot",9),W("slotchange",function(){N(n);let t=l();return F(t.onButtonSlotChange())}),y(2,"div",10),ce(),y(3,"svg",11),w(4,"path",12),b()()()()}}var LA=(()=>{let o=class o extends tt{set _disabled(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.disabled=t}set _documentUserAccessList(e){let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.documentUserAccessList=t}constructor(e,t,r,a,s,c){super(s,r,void 0,void 0,void 0,c,t),this.analyticsService=e,this.loggingService=t,this.themeService=r,this.dialog=a,this.elementRef=s,this.dynamicDataService=c,this.type="share",this.disabled=!1,this.documentUserAccessList=!0,this.hideAccessControlDropdown=!1,this.accessControlDropdown=!0,this.veltElement=!0,this.customButtonAdded=!1}ngOnDestroy(){try{super.ngOnDestroy()}catch{}}onButtonSlotChange(){this.customButtonAdded=!0}openInviteDialog(){try{this.disabled||(this.type==="share"&&this.analyticsService.trackEvent(Y.Events.ShareDialog.SHARE_BUTTON_CLICKED),this.dialog.open(eye,{panelClass:"velt-mat-dialog-container",backdropClass:"s-background-blur-1",data:{title:this.title,placeholder:this.placeholder,hideAccessControlDropdown:this.hideAccessControlDropdown||!this.accessControlDropdown,type:this.type,source:this.source,documentUserAccessList:this.documentUserAccessList,inviteUrl:this.inviteUrl}}))}catch(e){this.loggingService.catch("Error in UserInviteToolComponent openInviteDialog: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(_),h(Ke),h(po),h(R),h(S))},o.\u0275cmp=O({type:o,selectors:[["snippyly-user-invite-tool-internal"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{type:"type",source:"source",title:"title",placeholder:"placeholder",inviteUrl:"inviteUrl",_disabled:[0,"disabled","_disabled"],_documentUserAccessList:[0,"documentUserAccessList","_documentUserAccessList"],hideAccessControlDropdown:"hideAccessControlDropdown",accessControlDropdown:"accessControlDropdown"},standalone:!1,features:[V([S]),L],decls:4,vars:3,consts:[["part","container",1,"s-user-invite-tool-container","s-cursor-pointer",3,"click"],[1,"s-user-invite-tool-default",3,"ngSwitch"],["class","s-user-invite-tool-button",4,"ngSwitchCase"],[4,"ngSwitchCase"],[1,"s-user-invite-tool-button"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.3589 13.3008C17.3965 13.3008 15.6521 14.2519 14.5622 15.7174C14.1206 15.6247 13.6692 15.5768 13.2136 15.5768C9.6054 15.5768 6.66992 18.5123 6.66992 22.1205C6.66992 22.5918 7.05207 22.974 7.52344 22.974H14.67C15.7651 24.3594 17.4599 25.25 19.3589 25.25C22.6533 25.25 25.3335 22.5698 25.3335 19.2754C25.3335 15.981 22.6533 13.3008 19.3589 13.3008ZM8.45235 21.2669C8.85669 19.0058 10.8378 17.2839 13.2136 17.2839C13.3823 17.2839 13.5501 17.2933 13.7166 17.3104C13.5016 17.9261 13.3843 18.5873 13.3843 19.2754C13.3843 19.9735 13.505 20.6437 13.726 21.2669H8.45235ZM19.3589 23.543C17.0057 23.543 15.0913 21.6286 15.0913 19.2754C15.0913 16.9223 17.0057 15.0078 19.3589 15.0078C21.712 15.0078 23.6265 16.9223 23.6265 19.2754C23.6265 21.6286 21.712 23.543 19.3589 23.543Z","fill","white"],["d","M13.2132 13.8716C15.182 13.8716 16.7837 12.2699 16.7837 10.3011C16.7837 8.33224 15.182 6.73047 13.2132 6.73047C11.2443 6.73047 9.64258 8.33224 9.64258 10.3011C9.64258 12.2699 11.2443 13.8716 13.2132 13.8716ZM13.2132 8.4375C14.2408 8.4375 15.0767 9.2735 15.0767 10.3011C15.0767 11.3286 14.2408 12.1645 13.2132 12.1645C12.1856 12.1645 11.3496 11.3286 11.3496 10.3011C11.3496 9.2735 12.1856 8.4375 13.2132 8.4375Z","fill","white"],["d","M21.0664 18.4219H20.2129V17.5684C20.2129 17.097 19.8308 16.7148 19.3594 16.7148C18.888 16.7148 18.5059 17.097 18.5059 17.5684V18.4219H17.6523C17.181 18.4219 16.7988 18.804 16.7988 19.2754C16.7988 19.7468 17.181 20.1289 17.6523 20.1289H18.5059V20.9824C18.5059 21.4538 18.888 21.836 19.3594 21.836C19.8308 21.836 20.2129 21.4538 20.2129 20.9824V20.1289H21.0664C21.5378 20.1289 21.9199 19.7468 21.9199 19.2754C21.9199 18.804 21.5378 18.4219 21.0664 18.4219Z","fill","white"],["name","button",3,"slotchange"],["part","button-container",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M8.57143 9.42858H7.71429C7.25963 9.42858 6.82359 9.60919 6.5021 9.93068C6.18061 10.2522 6 10.6882 6 11.1429V18C6 18.4547 6.18061 18.8907 6.5021 19.2122C6.82359 19.5337 7.25963 19.7143 7.71429 19.7143H16.2857C16.7404 19.7143 17.1764 19.5337 17.4979 19.2122C17.8194 18.8907 18 18.4547 18 18V11.1429C18 10.6882 17.8194 10.2522 17.4979 9.93068C17.1764 9.60919 16.7404 9.42858 16.2857 9.42858H15.4286M12 13.7143V4.28572M12 4.28572L9.42857 6.85715M12 4.28572L14.5714 6.85715","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"]],template:function(t,r){t&1&&(y(0,"div",0),W("click",function(){return r.openInviteDialog()}),y(1,"div",1),u(2,kin,6,0,"div",2)(3,Rin,5,0,"div",3),b()()),t&2&&(m(),d("ngSwitch",r.type),m(),d("ngSwitchCase","invite"),m(),d("ngSwitchCase","share"))},dependencies:[Xi,mo],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}:host{display:inline-flex!important}.s-user-invite-tool-container{display:inline-block!important}.s-user-invite-tool-button{display:flex!important}.action-btn{display:inline-flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color);color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn .action-btn-label{font-size:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;padding-right:4px!important;font-weight:700!important;color:currentColor!important}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:currentColor}.action-btn .toolbar-icon-dropdown-arrow{width:16px;height:16px;color:currentColor}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color);color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:focus .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color);color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:hover .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color);color:var(--legacy-velt-tool-active-icon-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:active .toolbar-icon-dropdown-arrow,.action-btn.active .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-active-icon-color)}
536
536
  `],encapsulation:3,changeDetection:0});let i=o;return i})();var Fin=["*"];function Lin(i,o){if(i&1&&(v(0),ce(),y(1,"svg",7),w(2,"path",8)(3,"path",9),b(),C()),i&2){let n=l(2);m(),x("data-testid",n.componentId+"-video-icon")}}function Bin(i,o){if(i&1&&(v(0),ce(),y(1,"svg",7),w(2,"path",10)(3,"path",9),b(),C()),i&2){let n=l(2);m(),x("data-testid",n.componentId+"-audio-icon")}}function Vin(i,o){if(i&1){let n=K();v(0),y(1,"div",3),W("click",function(){N(n);let t=l();return F(t.openPermissionDeniedDialog())}),ce(),y(2,"svg",4),w(3,"rect",5)(4,"path",6),b(),ht(),v(5,0),u(6,Lin,4,1,"ng-container",1)(7,Bin,4,1,"ng-container",1),C(),b(),C()}if(i&2){let n=l();m(),pe("thread-mode",n.mode==="thread"),x("aria-expanded",!1)("data-testid",n.componentId+"-denied"),m(),x("data-testid",n.componentId+"-info-icon"),m(3),d("ngSwitch",n.type),m(),d("ngSwitchCase","video"),m(),d("ngSwitchCase","audio")}}function Uin(i,o){i&1&&(v(0),jt(1),C())}var K1=(()=>{let o=class o extends tt{constructor(e,t,r,a){super(a,r),this.devicePermissionService=e,this.loggingService=t,this.themeService=r,this.elementRef=a,this.type="audio",this.state=null,this.mode=null,this.veltElement=!0,this.subscriptions=[],this.componentId="velt-device-permission-button",this.loggingService.log("%c[WB] Creating CLASS: DevicePermissionButtonComponent","color: blue;")}ngOnInit(){try{this.loggingService.log("%c[WB] Calling DevicePermissionButtonComponent FUNCTION: ngOnInit","color: green;"),this.subscriptions.push(this.devicePermissionService.getPermissionState$(this.type).subscribe(e=>{this.state=e})),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in DevicePermissionButtonComponent onInit: ",e)}}setupA11yAttributes(){try{let e=this.elementRef.nativeElement;e.setAttribute("data-testid",this.componentId+"-container"),e.setAttribute("role","button"),e.setAttribute("aria-label",`Device permission button for ${this.type}`)}catch(e){this.loggingService.catch("Error in DevicePermissionButtonComponent setupA11yAttributes:",e)}}openPermissionDeniedDialog(){try{this.loggingService.log("%c[WB] Calling DevicePermissionButtonComponent FUNCTION: openPermissionDeniedDialog","color: green;"),this.devicePermissionService.openDevicePermissionDeniedDialog(this.type,{darkMode:this.darkMode})}catch(e){this.loggingService.catch("Error in DevicePermissionButtonComponent openPermissionDeniedDialog: ",e)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.forEach(e=>{e.unsubscribe()})}catch{}}};o.\u0275fac=function(t){return new(t||o)(h(Em),h(_),h(Ke),h(R))},o.\u0275cmp=O({type:o,selectors:[["app-device-permission-button"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{type:"type",state:"state",mode:"mode"},standalone:!1,features:[L],ngContentSelectors:Fin,decls:3,vars:2,consts:[[3,"ngSwitch"],[4,"ngSwitchCase"],[4,"ngSwitchDefault"],["role","button","tabindex","0","aria-label","Camera or microphone access is blocked. Click to learn how to enable it",1,"velt-device-permission-button--denied",3,"click"],["width","12","height","12","viewBox","0 0 12 12","fill","none","xmlns","http://www.w3.org/2000/svg","aria-hidden","true","role","img",1,"velt-device-permission-button--info-icon"],["width","12","height","12","rx","6","fill","currentColor"],["d","M6 9.495V9.5M6 7V2.5","stroke","white","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["width","28","height","28","viewBox","0 0 28 28","fill","none","xmlns","http://www.w3.org/2000/svg","aria-hidden","true","role","img"],["d","M20.9375 17.6068C21.1017 17.5503 21.2442 17.444 21.345 17.3027C21.4459 17.1614 21.5 16.9921 21.5 16.8184V11.1818C21.4999 11.0398 21.4636 10.9002 21.3944 10.7762C21.3252 10.6522 21.2255 10.5479 21.1047 10.4733C20.9839 10.3986 20.846 10.3561 20.7042 10.3497C20.5623 10.3433 20.4212 10.3733 20.2942 10.4368L16.5 12.3334V13.1668V10.6667C16.5 10.2246 16.3244 9.80072 16.0118 9.48816C15.6993 9.17559 15.2754 9 14.8333 9H12.3333M16.5 16.5V17.3333C16.5 17.7754 16.3244 18.1993 16.0118 18.5118C15.6993 18.8244 15.2754 19 14.8333 19H8.16667C7.72464 19 7.30072 18.8244 6.98816 18.5118C6.67559 18.1993 6.5 17.7754 6.5 17.3333V10.6667C6.5 10.2246 6.67559 9.80072 6.98816 9.48816C7.30072 9.17559 7.72464 9 8.16667 9H9","stroke","currentColor","stroke-opacity","0.52","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M6.5 6.5L21.5 21.5","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M11.5013 8.1665C11.5013 7.50346 11.7647 6.86758 12.2335 6.39874C12.7024 5.9299 13.3383 5.6665 14.0013 5.6665C14.6643 5.6665 15.3002 5.9299 15.7691 6.39874C16.2379 6.86758 16.5013 7.50346 16.5013 8.1665V12.3332C16.5013 12.58 16.4648 12.8254 16.393 13.0615M14.7263 14.7282C14.3527 14.8414 13.9578 14.8655 13.5732 14.7987C13.1885 14.7318 12.8249 14.5758 12.5114 14.3432C12.198 14.1105 11.9433 13.8077 11.7679 13.459C11.5925 13.1102 11.5012 12.7252 11.5013 12.3348V11.5015M8.16797 12.3332C8.16779 13.386 8.45252 14.4192 8.99198 15.3232C9.53144 16.2273 10.3055 16.9685 11.2321 17.4683C12.1587 17.9681 13.2033 18.2078 14.2551 18.162C15.3069 18.1162 16.3267 17.7866 17.2063 17.2082M18.873 15.5415C19.5012 14.5896 19.835 13.4737 19.833 12.3332M10.668 21.4998H17.3346M14.0013 18.1665V21.4998","stroke","currentColor","stroke-opacity","0.52","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"]],template:function(t,r){t&1&&(Ht(),v(0,0),u(1,Vin,8,8,"ng-container",1)(2,Uin,2,0,"ng-container",2),C()),t&2&&(d("ngSwitch",r.state),m(),d("ngSwitchCase","denied"))},dependencies:[Xi,mo,rp],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-button--denied[_ngcontent-%COMP%]{padding:var(--velt-spacing-md);display:flex;align-items:center;justify-content:center;border-radius:var(--velt-border-radius-full);cursor:pointer;background:var(--velt-error-transparent);position:relative;color:var(--velt-error)}.velt-device-permission-button--denied.thread-mode[_ngcontent-%COMP%]{background:none;padding:var(--velt-spacing-2xs)}.velt-device-permission-button--info-icon[_ngcontent-%COMP%]{position:absolute;top:1px;right:1px}"],changeDetection:0});let i=o;return i})();function $in(i,o){if(i&1){let n=K();y(0,"div",22),W("click",function(){N(n);let t=l().$implicit,r=l(2);return F(r.followUser(t))}),w(1,"snippyly-user-avatar",23),b()}if(i&2){let n=l().$implicit,e=l().ngIf;pe("s-current-user",(e.user==null?null:e.user.userSnippylyId)===(n==null?null:n.userSnippylyId)),m(),d("user",n)}}function Hin(i,o){if(i&1&&(v(0),u(1,$in,2,3,"div",21),C()),i&2){let n=o.index,e=l().ngIf;m(),d("ngIf",n<e.maxAttendees)}}function zin(i,o){if(i&1&&(y(0,"button"),te(1),b()),i&2){let n=l().ngIf;m(),ze("+"+((n.attendees==null?null:n.attendees.length)-n.maxAttendees))}}function Gin(i,o){i&1&&(ce(),y(0,"svg",24),w(1,"path",25),b())}function Win(i,o){i&1&&(ce(),y(0,"svg",26),w(1,"path",27)(2,"path",28),b())}function qin(i,o){i&1&&(ce(),y(0,"svg",29),w(1,"path",30),b())}function Yin(i,o){i&1&&(ce(),y(0,"svg",26)(1,"g"),w(2,"path",31)(3,"path",28),b(),y(4,"defs")(5,"clipPath",32),w(6,"rect",33),b()()())}function Kin(i,o){i&1&&(v(0),ce(),y(1,"svg",26)(2,"g"),w(3,"path",35)(4,"path",36)(5,"path",37)(6,"path",38)(7,"path",28),b(),y(8,"defs")(9,"clipPath",39),w(10,"rect",33),b()()(),C())}function Zin(i,o){i&1&&(ce(),y(0,"svg",26)(1,"g"),w(2,"path",40)(3,"path",41)(4,"path",37)(5,"path",38)(6,"path",28),b(),y(7,"defs")(8,"clipPath",42),w(9,"rect",33),b()()())}function Xin(i,o){i&1&&(ce(),y(0,"svg",26),w(1,"path",43)(2,"path",44)(3,"path",45)(4,"path",46),b())}function Qin(i,o){if(i&1&&u(0,Zin,10,0,"svg",11)(1,Xin,5,0,"svg",11),i&2){let n=l(2).ngIf;d("ngIf",!n.screenSharingState),m(),d("ngIf",n.screenSharingState)}}function Jin(i,o){if(i&1){let n=K();y(0,"button",8),W("click",function(){N(n);let t=l(2);return F(t.onToggleScreenSharingClick())}),y(1,"div",9),te(2),P(3,"translate"),P(4,"translate"),b(),u(5,Kin,11,0,"ng-container",34)(6,Qin,2,2,"ng-template",null,0,Te),b()}if(i&2){let n=me(7),e=l().ngIf;m(2),Se("",e.screenSharingState?M(3,3,"Stop sharing"):M(4,5,"Share screen")," "),m(3),d("ngIf",e.screenSharingDisabled)("ngIfElse",n)}}function eon(i,o){i&1&&(ce(),y(0,"svg",26),w(1,"path",47),b())}function ton(i,o){i&1&&(ce(),y(0,"svg",26),w(1,"path",48),b())}function non(i,o){if(i&1){let n=K();y(0,"button",8),W("click",function(){N(n);let t=l(2);return F(t.onToggleHuddleCursorModeClick())}),u(1,eon,2,0,"svg",11)(2,ton,2,0,"svg",11),b()}if(i&2){let n=l().ngIf;m(),d("ngIf",!n.huddleOnCursorMode),m(),d("ngIf",n.huddleOnCursorMode)}}function ion(i,o){if(i&1){let n=K();y(0,"button",8),W("click",function(){N(n);let t=l(2);return F(t.toggleMessagesPanel())}),y(1,"div",9),te(2),P(3,"translate"),b(),ce(),y(4,"svg",17),w(5,"path",49),b()()}i&2&&(m(2),ze(M(3,1,"Chat with everyone")))}function oon(i,o){if(i&1){let n=K();v(0),y(1,"div",2)(2,"div",3)(3,"div",4),u(4,Hin,2,1,"ng-container",5)(5,zin,2,1,"button",1),b(),y(6,"div",6)(7,"app-device-permission-button",7)(8,"button",8),W("click",function(){N(n);let t=l();return F(t.onToggleAudioClick())}),y(9,"div",9),te(10),P(11,"translate"),P(12,"translate"),b(),u(13,Gin,2,0,"svg",10)(14,Win,3,0,"svg",11),b()(),y(15,"app-device-permission-button",12)(16,"button",8),W("click",function(){N(n);let t=l();return F(t.onToggleVideoClick())}),y(17,"div",9),te(18),P(19,"translate"),P(20,"translate"),b(),u(21,qin,2,0,"svg",13)(22,Yin,7,0,"svg",11),b()(),u(23,Jin,8,7,"button",14)(24,non,3,2,"button",14),w(25,"snippyly-user-invite-tool-internal",15),P(26,"translate"),P(27,"translate"),u(28,ion,6,3,"button",14),y(29,"button",16),W("click",function(){N(n);let t=l();return F(t.openMediaSourceOptionsDialog())}),y(30,"div",9),te(31),P(32,"translate"),P(33,"translate"),b(),ce(),y(34,"svg",17),w(35,"path",18),b()()(),ht(),y(36,"div",19)(37,"button",20),W("click",function(){N(n);let t=l();return F(t.onLeaveClick())}),te(38),P(39,"translate"),b()()()(),C()}if(i&2){let n=o.ngIf,e=l();m(4),d("ngForOf",n.attendees)("ngForTrackBy",e.trackByAttendeeId),m(),d("ngIf",(n.attendees==null?null:n.attendees.length)>n.maxAttendees),m(2),d("darkMode",!0),m(3),Se("",n.audioState?M(11,20,"Click to mute"):M(12,22,"Click to unmute")," "),m(3),d("ngIf",n.audioState),m(),d("ngIf",!n.audioState),m(),d("darkMode",!0),m(3),Se("",n.videoState?M(19,24,"Turn off video"):M(20,26,"Turn on video")," "),m(3),d("ngIf",n.videoState),m(),d("ngIf",!n.videoState),m(),d("ngIf",n.screenSharingSupported),m(),d("ngIf",!n.hideHuddleOnCursor),m(),d("title",M(26,28,"Invite users to join this huddle"))("placeholder",M(27,30,"Please select a contact to invite"))("hideAccessControlDropdown",!0),m(3),d("ngIf",n.chatEnabled),m(),d("disabled",!n.audioState&&!n.videoState),m(2),ze(!n.audioState&&!n.videoState?M(32,32,"Enable audio or video to change the settings"):M(33,34,"Change audio/video settings")),m(7),ze(M(39,36,"Leave"))}}var tye=(()=>{let o=class o{constructor(e,t,r,a,s,c){this.analyticsService=e,this.configService=t,this.flockService=r,this.huddleService=a,this.loggingService=s,this.dialog=c,this.attendees=[],this.toggleAudio=new Me,this.toggleVideo=new Me,this.toggleScreenSharing=new Me,this.leave=new Me,this.subscriptions=[],this.veltElement=!0,this.componentConfigSignal=xe({attendees:this.attendees,maxAttendees:4,audioState:this.audioState,videoState:this.videoState,chatEnabled:!1,huddleOnCursorMode:!1,hideHuddleOnCursor:!1,screenSharingState:this.screenSharingState,screenSharingDisabled:this.screenSharingDisabled,screenSharingSupported:!!navigator?.mediaDevices?.getDisplayMedia,user:this.user})}ngOnInit(){try{this.subscriptions.push(this.configService.getConfig$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{hideHuddleOnCursor:!e?.featureAllowList?.find(r=>r===Re.CURSOR)}),t))},e=>{this.loggingService.catch("Error in HuddleMenuPanelComponent getConfig$: ",e)})),this.subscriptions.push(this.huddleService.getHuddleOnCursorMode$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{huddleOnCursorMode:e}),t))},e=>{this.loggingService.catch("Error in HuddleMenuPanelComponent getHuddleOnCursorMode$: ",e)})),this.subscriptions.push(this.huddleService.getChatEnabled$().subscribe(e=>{this.componentConfigSignal.update(t=>(t=D(E({},t),{chatEnabled:e}),t))},e=>{this.loggingService.catch("Error in HuddleMenuPanelComponent getChatEnabled$: ",e)}))}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent ngOnInit: ",e)}}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling HuddleMenuPanelComponent FUNCTION: ngOnChanges","color: green;"),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in HuddleMenuPanelComponent ngOnChanges: ",t)}}trackByAttendeeId(e,t){return t?.userId}onToggleAudioClick(){try{this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_AUDIO_BUTTON_CLICKED,{huddleType:this.huddleService.getInitialHuddleType(),totalUsers:this.huddleService.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.huddleService.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userId)}),this.toggleAudio.emit()}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent onToggleAudioClick: ",e)}}onToggleVideoClick(){try{this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_VIDEO_BUTTON_CLICKED,{huddleType:this.huddleService.getInitialHuddleType(),totalUsers:this.huddleService.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.huddleService.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userId)}),this.toggleVideo.emit()}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent onToggleVideoClick: ",e)}}onToggleScreenSharingClick(){try{this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_SCREENSHARING_BUTTON_CLICKED,{huddleType:this.huddleService.getInitialHuddleType(),totalUsers:this.huddleService.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.huddleService.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userId)}),this.toggleScreenSharing.emit()}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent onToggleScreenSharingClick: ",e)}}onToggleHuddleCursorModeClick(){try{this.componentConfigSignal().huddleOnCursorMode?this.huddleService.disableHuddleOnCursorMode():this.huddleService.enableHuddleOnCursorMode()}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent onToggleHuddleCursorModeClick: ",e)}}openMediaSourceOptionsDialog(){try{this.subscriptions.push(this.dialog.open(K1e,{panelClass:"velt-mat-dialog-container",data:{settingsVisible:{audio:this.componentConfigSignal().audioState,video:this.componentConfigSignal().videoState}}}).afterClosed().pipe(rt(1)).subscribe(e=>{e&&(this.componentConfigSignal().audioState&&this.huddleService.toggleLocalStreamAudio(!0),this.componentConfigSignal().videoState&&this.huddleService.toggleLocalStreamVideo(!0))}))}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent mediaSourceOptionsDialog: ",e)}}onLeaveClick(){this.leave.emit()}toggleMessagesPanel(){try{this.loggingService.log("%c[WB] Calling FUNCTION: toggleMessagesPanel","color: green;"),this.huddleService.toggleMessagesPanel()}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent toggleMessagesPanel: ",e)}}followUser(e){try{this.huddleService.getFlockModeOnAvatarClick()&&this.flockService.getFlockMode()&&this.componentConfigSignal().user?.userSnippylyId!==e.userSnippylyId&&this.flockService.setFlockLeader(e.userSnippylyId,e.name)}catch(t){this.loggingService.catch("Error in HuddleMenuPanelComponent followUser: ",t)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>e?.unsubscribe())}catch(e){this.loggingService.catch("Error in HuddleMenuPanelComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(Ft),h(Ed),h(wr),h(_),h(po))},o.\u0275cmp=O({type:o,selectors:[["snippyly-huddle-menu-panel"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{stream:"stream",selected:"selected",isRemoteStream:"isRemoteStream",user:"user",audioState:"audioState",videoState:"videoState",screenSharingState:"screenSharingState",screenSharingDisabled:"screenSharingDisabled",attendees:"attendees"},outputs:{toggleAudio:"toggleAudio",toggleVideo:"toggleVideo",toggleScreenSharing:"toggleScreenSharing",leave:"leave"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["screenSharingToggleBtnRef",""],[4,"ngIf"],[1,"reply-div","input-text-wrap"],[1,"action-menu"],[1,"pins-wrap"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"actions-wrap"],["type","audio",3,"darkMode"],[1,"action__button","tooltip",3,"click"],[1,"tooltiptext"],["width","20","height","20","viewBox","0 0 13 19","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["type","video",3,"darkMode"],["width","20","height","20","viewBox","0 0 19 11","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["class","action__button tooltip",3,"click",4,"ngIf"],["type","invite","source","Huddle",3,"title","placeholder","hideAccessControlDropdown"],[1,"action__button","tooltip",3,"click","disabled"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63003 2 9.20003 2.38 9.14003 2.88L8.85003 5.19C8.44003 5.38 8.05003 5.61 7.68003 5.87L5.53003 4.96C5.07003 4.76 4.53003 4.94 4.28003 5.38L2.41003 8.62C2.16003 9.06 2.27003 9.61 2.67003 9.92L4.53003 11.33C4.51003 11.55 4.50003 11.77 4.50003 12C4.50003 12.23 4.51003 12.45 4.53003 12.68L2.67003 14.09C2.27003 14.39 2.16003 14.95 2.41003 15.39L4.28003 18.62C4.53003 19.06 5.07003 19.24 5.53003 19.04L7.68003 18.13C8.05003 18.39 8.44003 18.62 8.85003 18.81L9.14003 21.12C9.20003 21.62 9.63003 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54003 13.93 8.54003 12C8.54003 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","#fff"],[1,"buttons-wrap"],[1,"secondary",3,"click"],["class","pin2",3,"s-current-user","click",4,"ngIf"],[1,"pin2",3,"click"],[1,"huddle-menu-panel-user-avatar",3,"user"],["width","20","height","20","viewBox","0 0 13 19","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M5.77526 0.888917C4.98766 1.03653 4.34477 1.39041 3.76525 1.99544C3.26289 2.51988 2.94255 3.10884 2.75974 3.84431C2.69679 4.09753 2.6908 4.39635 2.6908 7.29276C2.6908 10.7979 2.68044 10.6352 2.94799 11.327C3.299 12.2346 4.07584 13.0561 4.94368 13.4374C5.82412 13.8243 6.82444 13.8531 7.71552 13.5173C8.69181 13.1494 9.53872 12.2934 9.92297 11.2862C10.1713 10.6354 10.1631 10.7714 10.1631 7.29276C10.1631 3.78764 10.1735 3.95032 9.90592 3.25855C9.62932 2.54335 9.02923 1.81042 8.38767 1.40419C7.61998 0.918084 6.64549 0.725873 5.77526 0.888917ZM6.9551 2.18212C7.80033 2.36379 8.55484 3.08137 8.82443 3.95997C8.91085 4.24162 8.9112 4.25479 8.9112 7.29276C8.9112 10.3307 8.91085 10.3439 8.82443 10.6256C8.578 11.4287 7.92854 12.0994 7.15071 12.3538C6.92897 12.4264 6.7875 12.4431 6.40739 12.4415C6.00213 12.4398 5.89869 12.425 5.65097 12.3333C5.00401 12.0936 4.49038 11.6376 4.2051 11.0497C3.92221 10.4667 3.92452 10.4977 3.92452 7.29276C3.92452 4.09736 3.92315 4.11587 4.19825 3.55135C4.71228 2.49645 5.83136 1.94067 6.9551 2.18212ZM0.537139 8.64006C0.373453 8.71677 0.215048 8.92183 0.182929 9.09861C0.133831 9.36895 0.199086 10.6794 0.283042 11.1082C0.737953 13.4317 2.32631 15.2803 4.50075 16.017C4.75328 16.1025 5.14915 16.2055 5.38044 16.2458L5.801 16.3192V16.9744V17.6296L5.06042 17.6421C4.38416 17.6536 4.31046 17.6619 4.21195 17.738C4.00671 17.8964 3.94271 18.0255 3.94271 18.2809C3.94271 18.5363 4.00679 18.6655 4.21206 18.8237C4.31804 18.9055 4.36006 18.907 6.42696 18.907C8.49385 18.907 8.53586 18.9055 8.64185 18.8237C8.84712 18.6655 8.9112 18.5363 8.9112 18.2809C8.9112 18.0255 8.8472 17.8964 8.64196 17.738C8.54346 17.6619 8.46975 17.6536 7.79349 17.6421L7.05291 17.6296V16.9744V16.3192L7.47347 16.2469C9.74567 15.8564 11.6474 14.1569 12.3699 11.8711C12.6066 11.1222 12.6648 10.7131 12.6659 9.79054C12.6668 9.05017 12.6614 8.98828 12.5862 8.8841C12.4332 8.67197 12.3081 8.60568 12.0605 8.60568C11.8131 8.60568 11.6881 8.67181 11.5348 8.88378C11.4622 8.9842 11.4515 9.07453 11.4282 9.79025C11.4001 10.6516 11.3449 11.0079 11.1515 11.5749C10.8931 12.3325 10.527 12.9264 9.95298 13.5192C9.22696 14.2689 8.41181 14.7274 7.405 14.9524C6.91168 15.0626 5.87256 15.0542 5.38588 14.936C4.37192 14.6897 3.6185 14.2601 2.90093 13.5192C2.32689 12.9264 1.96079 12.3325 1.70239 11.5749C1.50901 11.0079 1.45377 10.6516 1.42568 9.79025C1.39755 8.92635 1.3871 8.88689 1.13621 8.69342C1.00672 8.5936 0.695505 8.56589 0.537139 8.64006Z","fill","#FF7162"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M9.77526 0.888917C8.98766 1.03653 8.34477 1.39041 7.76525 1.99544C7.26289 2.51988 6.94255 3.10884 6.75974 3.84431C6.69679 4.09753 6.6908 4.39635 6.6908 7.29276C6.6908 10.7979 6.68044 10.6352 6.94799 11.327C7.299 12.2346 8.07584 13.0561 8.94368 13.4374C9.82412 13.8243 10.8244 13.8531 11.7155 13.5173C12.6918 13.1494 13.5387 12.2934 13.923 11.2862C14.1713 10.6354 14.1631 10.7714 14.1631 7.29276C14.1631 3.78764 14.1735 3.95032 13.9059 3.25855C13.6293 2.54335 13.0292 1.81042 12.3877 1.40419C11.62 0.918084 10.6455 0.725873 9.77526 0.888917ZM10.9551 2.18212C11.8003 2.36379 12.5548 3.08137 12.8244 3.95997C12.9108 4.24162 12.9112 4.25479 12.9112 7.29276C12.9112 10.3307 12.9108 10.3439 12.8244 10.6256C12.578 11.4287 11.9285 12.0994 11.1507 12.3538C10.929 12.4264 10.7875 12.4431 10.4074 12.4415C10.0021 12.4398 9.89869 12.425 9.65097 12.3333C9.00401 12.0936 8.49038 11.6376 8.2051 11.0497C7.92221 10.4667 7.92452 10.4977 7.92452 7.29276C7.92452 4.09736 7.92315 4.11587 8.19825 3.55135C8.71228 2.49645 9.83136 1.94067 10.9551 2.18212ZM4.53714 8.64006C4.37345 8.71677 4.21505 8.92183 4.18293 9.09861C4.13383 9.36895 4.19909 10.6794 4.28304 11.1082C4.73795 13.4317 6.32631 15.2803 8.50075 16.017C8.75328 16.1025 9.14915 16.2055 9.38044 16.2458L9.801 16.3192V16.9744V17.6296L9.06042 17.6421C8.38416 17.6536 8.31046 17.6619 8.21195 17.738C8.00671 17.8964 7.94271 18.0255 7.94271 18.2809C7.94271 18.5363 8.00679 18.6655 8.21206 18.8237C8.31804 18.9055 8.36006 18.907 10.427 18.907C12.4938 18.907 12.5359 18.9055 12.6418 18.8237C12.8471 18.6655 12.9112 18.5363 12.9112 18.2809C12.9112 18.0255 12.8472 17.8964 12.642 17.738C12.5435 17.6619 12.4697 17.6536 11.7935 17.6421L11.0529 17.6296V16.9744V16.3192L11.4735 16.2469C13.7457 15.8564 15.6474 14.1569 16.3699 11.8711C16.6066 11.1222 16.6648 10.7131 16.6659 9.79054C16.6668 9.05017 16.6614 8.98828 16.5862 8.8841C16.4332 8.67197 16.3081 8.60568 16.0605 8.60568C15.8131 8.60568 15.6881 8.67181 15.5348 8.88378C15.4622 8.9842 15.4515 9.07453 15.4282 9.79025C15.4001 10.6516 15.3449 11.0079 15.1515 11.5749C14.8931 12.3325 14.527 12.9264 13.953 13.5192C13.227 14.2689 12.4118 14.7274 11.405 14.9524C10.9117 15.0626 9.87256 15.0542 9.38588 14.936C8.37192 14.6897 7.6185 14.2601 6.90093 13.5192C6.32689 12.9264 5.96079 12.3325 5.70239 11.5749C5.50901 11.0079 5.45377 10.6516 5.42568 9.79025C5.39755 8.92636 5.3871 8.88689 5.13621 8.69342C5.00672 8.5936 4.69551 8.56589 4.53714 8.64006Z","fill","white"],["d","M19 1L1 19","stroke","#FF7162","stroke-width","1.4","stroke-linecap","round"],["width","20","height","20","viewBox","0 0 19 11","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M2.55139 0.23203C1.68754 0.455725 1.06855 1.0239 0.766641 1.87017L0.666016 2.15221V5.58961V9.027L0.766892 9.30905C1.0535 10.1102 1.64038 10.6751 2.43987 10.9192L2.70863 11.0013H7.1343H11.56L11.8467 10.9053C12.6234 10.645 13.2099 10.0654 13.47 9.30122C13.56 9.03659 13.5637 8.9921 13.5769 8.03104C13.5844 7.48324 13.6004 7.03508 13.6125 7.03508C13.661 7.03508 15.0857 7.85713 15.8518 8.32715C16.7188 8.85908 16.9126 8.93887 17.338 8.93887C18.0692 8.93887 18.7509 8.40866 18.947 7.6873C19.0174 7.42849 19.0165 3.7478 18.946 3.48726C18.7883 2.90449 18.278 2.40845 17.7016 2.27772C17.4483 2.22025 17.0895 2.2339 16.8373 2.31054C16.6848 2.35687 16.3699 2.52617 15.9107 2.80867C15.3288 3.16675 13.6405 4.14414 13.6039 4.14414C13.5979 4.14414 13.5847 3.71184 13.5747 3.18343C13.5543 2.10543 13.5363 1.99899 13.2916 1.50796C13.0166 0.956034 12.475 0.494788 11.8467 0.277192L11.56 0.177913L7.18806 0.170686C2.95948 0.163705 2.80747 0.165715 2.55139 0.23203ZM11.3211 1.83643C11.5404 1.90052 11.7306 2.05381 11.8398 2.25463L11.9183 2.399V5.57293V8.74683L11.8268 8.92184C11.7122 9.14091 11.4929 9.30852 11.2552 9.35869C11.0123 9.40995 3.20786 9.41115 2.98224 9.35999C2.74243 9.30559 2.53297 9.14483 2.42553 8.93266L2.33236 8.74873V5.58961V2.43048L2.42553 2.24656C2.52985 2.04059 2.7435 1.87225 2.96604 1.82078C3.04208 1.80318 4.88581 1.78753 7.11882 1.78556C10.641 1.78245 11.1578 1.78873 11.3211 1.83643ZM17.3116 5.59366V7.28997L17.2309 7.23801C16.8358 6.98339 15.6936 6.30427 15.1359 5.99233C14.7573 5.78052 14.4468 5.5987 14.4461 5.5883C14.4453 5.57787 14.7874 5.37536 15.2062 5.13827C15.6251 4.90114 16.258 4.52634 16.6128 4.30536C16.9675 4.08438 17.2699 3.90215 17.2847 3.90045C17.2995 3.89876 17.3116 4.6607 17.3116 5.59366Z","fill","#FF7162"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.55139 4.23203C2.68754 4.45573 2.06855 5.0239 1.76664 5.87017L1.66602 6.15221V9.58961V13.027L1.76689 13.309C2.0535 14.1102 2.64038 14.6751 3.43987 14.9192L3.70863 15.0013H8.1343H12.56L12.8467 14.9053C13.6234 14.645 14.2099 14.0654 14.47 13.3012C14.56 13.0366 14.5637 12.9921 14.5769 12.031C14.5844 11.4832 14.6004 11.0351 14.6125 11.0351C14.661 11.0351 16.0857 11.8571 16.8518 12.3271C17.7188 12.8591 17.9126 12.9389 18.338 12.9389C19.0692 12.9389 19.7509 12.4087 19.947 11.6873C20.0174 11.4285 20.0165 7.7478 19.946 7.48726C19.7883 6.90449 19.278 6.40845 18.7016 6.27772C18.4483 6.22025 18.0895 6.2339 17.8373 6.31054C17.6848 6.35687 17.3699 6.52617 16.9107 6.80867C16.3288 7.16675 14.6405 8.14414 14.6039 8.14414C14.5979 8.14414 14.5847 7.71184 14.5747 7.18343C14.5543 6.10543 14.5363 5.99899 14.2916 5.50796C14.0166 4.95603 13.475 4.49479 12.8467 4.27719L12.56 4.17791L8.18806 4.17069C3.95948 4.16371 3.80747 4.16571 3.55139 4.23203ZM12.3211 5.83643C12.5404 5.90052 12.7306 6.05381 12.8398 6.25463L12.9183 6.399V9.57293V12.7468L12.8268 12.9218C12.7122 13.1409 12.4929 13.3085 12.2552 13.3587C12.0123 13.4099 4.20786 13.4111 3.98224 13.36C3.74243 13.3056 3.53297 13.1448 3.42553 12.9327L3.33236 12.7487V9.58961V6.43048L3.42553 6.24656C3.52985 6.04059 3.7435 5.87225 3.96604 5.82078C4.04208 5.80318 5.88581 5.78753 8.11882 5.78556C11.641 5.78245 12.1578 5.78873 12.3211 5.83643ZM18.3116 9.59366V11.29L18.2309 11.238C17.8358 10.9834 16.6936 10.3043 16.1359 9.99233C15.7573 9.78052 15.4468 9.5987 15.4461 9.5883C15.4453 9.57787 15.7874 9.37536 16.2062 9.13827C16.6251 8.90114 17.258 8.52634 17.6128 8.30536C17.9675 8.08438 18.2699 7.90215 18.2847 7.90045C18.2995 7.89876 18.3116 8.6607 18.3116 9.59366Z","fill","white"],["id","clip0_2334_10689"],["width","20","height","20","fill","white"],[4,"ngIf","ngIfElse"],["d","M7.50016 15H9.16683V16.6667H10.8335V15H12.5002V16.6667H13.3335C13.7937 16.6667 14.1668 17.0398 14.1668 17.5C14.1668 17.9602 13.7937 18.3333 13.3335 18.3333H6.66683C6.20659 18.3333 5.8335 17.9602 5.8335 17.5C5.8335 17.0398 6.20659 16.6667 6.66683 16.6667H7.50016V15Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.33317 5L3.33317 11.6667C3.33317 12.5871 4.07936 13.3333 4.99984 13.3333L14.9998 13.3333C15.9203 13.3333 16.6665 12.5871 16.6665 11.6667L16.6665 5C16.6665 4.07953 15.9203 3.33333 14.9998 3.33333L4.99984 3.33333C4.07936 3.33333 3.33317 4.07953 3.33317 5ZM1.6665 11.6667C1.6665 13.5076 3.15889 15 4.99984 15L14.9998 15C16.8408 15 18.3332 13.5076 18.3332 11.6667L18.3332 5C18.3332 3.15905 16.8408 1.66667 14.9998 1.66667L4.99984 1.66667C3.15889 1.66667 1.6665 3.15905 1.6665 5L1.6665 11.6667Z","fill","white"],["d","M5.83333 5C5.3731 5 5 5.3731 5 5.83333C5 6.29357 5.3731 6.66667 5.83333 6.66667H11.6667C12.1269 6.66667 12.5 6.29357 12.5 5.83333C12.5 5.3731 12.1269 5 11.6667 5H5.83333Z","fill","white"],["d","M5.83333 8.33333C5.3731 8.33333 5 8.70643 5 9.16667C5 9.6269 5.3731 10 5.83333 10H7.5C7.96024 10 8.33333 9.6269 8.33333 9.16667C8.33333 8.70643 7.96024 8.33333 7.5 8.33333H5.83333Z","fill","white"],["id","clip0_2260_32847"],["d","M7.50065 15H9.16732V16.6667H10.834V15H12.5007V16.6667H13.334C13.7942 16.6667 14.1673 17.0398 14.1673 17.5C14.1673 17.9602 13.7942 18.3333 13.334 18.3333H6.66732C6.20708 18.3333 5.83398 17.9602 5.83398 17.5C5.83398 17.0398 6.20708 16.6667 6.66732 16.6667H7.50065V15Z","fill","white"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.33268 5L3.33268 11.6667C3.33268 12.5871 4.07887 13.3333 4.99935 13.3333L14.9993 13.3333C15.9198 13.3333 16.666 12.5871 16.666 11.6667L16.666 5C16.666 4.07953 15.9198 3.33333 14.9993 3.33333L4.99935 3.33333C4.07887 3.33333 3.33268 4.07953 3.33268 5ZM1.66602 11.6667C1.66602 13.5076 3.1584 15 4.99935 15L14.9993 15C16.8403 15 18.3327 13.5076 18.3327 11.6667L18.3327 5C18.3327 3.15905 16.8403 1.66667 14.9993 1.66667L4.99935 1.66667C3.1584 1.66667 1.66602 3.15905 1.66602 5L1.66602 11.6667Z","fill","white"],["id","clip0_2305_6167"],["d","M7.50016 15H9.16683V16.6667H10.8335V15H12.5002V16.6667H13.3335C13.7937 16.6667 14.1668 17.0398 14.1668 17.5C14.1668 17.9602 13.7937 18.3333 13.3335 18.3333H6.66683C6.20659 18.3333 5.8335 17.9602 5.8335 17.5C5.8335 17.0398 6.20659 16.6667 6.66683 16.6667H7.50016V15Z","fill","#FF7162"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.33317 5L3.33317 11.6667C3.33317 12.5871 4.07936 13.3333 4.99984 13.3333L14.9998 13.3333C15.9203 13.3333 16.6665 12.5871 16.6665 11.6667L16.6665 5C16.6665 4.07953 15.9203 3.33333 14.9998 3.33333L4.99984 3.33333C4.07936 3.33333 3.33317 4.07953 3.33317 5ZM1.6665 11.6667C1.6665 13.5076 3.15889 15 4.99984 15L14.9998 15C16.8408 15 18.3332 13.5076 18.3332 11.6667L18.3332 5C18.3332 3.15905 16.8408 1.66667 14.9998 1.66667L4.99984 1.66667C3.15889 1.66667 1.6665 3.15905 1.6665 5L1.6665 11.6667Z","fill","#FF7162"],["d","M5.83333 5C5.3731 5 5 5.3731 5 5.83333C5 6.29357 5.3731 6.66667 5.83333 6.66667H11.6667C12.1269 6.66667 12.5 6.29357 12.5 5.83333C12.5 5.3731 12.1269 5 11.6667 5H5.83333Z","fill","#FF7162"],["d","M5.83333 8.33333C5.3731 8.33333 5 8.70643 5 9.16667C5 9.6269 5.3731 10 5.83333 10H7.5C7.96024 10 8.33333 9.6269 8.33333 9.16667C8.33333 8.70643 7.96024 8.33333 7.5 8.33333H5.83333Z","fill","#FF7162"],["d","M4.69231 5.29805L6.9519 16.6605C7.26158 18.2178 9.31823 18.591 10.1553 17.2418L12.4275 13.5798C12.4611 13.5255 12.5143 13.4861 12.5761 13.4699L16.8289 12.3482C18.3433 11.9488 18.6107 9.91372 17.2509 9.13668L7.27695 3.4373C5.97394 2.69272 4.3996 3.82614 4.69231 5.29805Z","stroke","#E5E5E9","stroke-width","1.5","stroke-linecap","square"],["d","M4.69231 5.29805L6.9519 16.6605C7.26158 18.2178 9.31823 18.591 10.1553 17.2418L12.4275 13.5798C12.4611 13.5255 12.5143 13.4861 12.5761 13.4699L16.8289 12.3482C18.3433 11.9488 18.6107 9.91372 17.2509 9.13668L7.27695 3.4373C5.97394 2.69272 4.3996 3.82614 4.69231 5.29805Z","stroke","#FF7162","stroke-width","1.5","stroke-linecap","square"],["fill-rule","evenodd","clip-rule","evenodd","d","M13.8325 2.04946C17.7809 2.65969 20.8233 5.37592 21.8636 9.21997C22.1983 10.457 22.1983 12.6637 21.8636 13.9007C20.922 17.3797 18.4001 19.9016 14.921 20.8432C14.2284 21.0307 13.7495 21.0787 12.5807 21.0777C10.9937 21.0764 10.2354 20.9338 8.89576 20.3847L8.17885 20.0909L5.96793 20.6411C3.89884 21.156 3.73807 21.1807 3.46234 21.0259C2.91579 20.7191 2.9196 20.4879 3.50969 18.1292L4.05124 15.965L3.75679 15.2466C3.20719 13.9056 3.06459 13.1477 3.06328 11.5603C3.06231 10.3914 3.11031 9.9126 3.29775 9.21997C4.23324 5.76343 6.77214 3.21049 10.1836 2.29591C10.9867 2.08059 13.1072 1.93745 13.8325 2.04946ZM10.2766 4.07773C8.99188 4.49235 8.06085 5.06677 7.07399 6.05364C5.60817 7.51946 4.87896 9.14649 4.77653 11.1793C4.71394 12.4216 4.88419 13.4239 5.34355 14.5187C5.50236 14.8972 5.68807 15.3419 5.7561 15.5069C5.85962 15.7577 5.81488 16.0697 5.48277 17.4105C5.26419 18.2927 5.09471 19.0236 5.10603 19.035C5.11735 19.0463 5.8483 18.8768 6.73045 18.6582C8.0713 18.3261 8.38328 18.2814 8.63408 18.3849C8.7991 18.4529 9.24377 18.6386 9.62225 18.7974C10.7171 19.2568 11.7194 19.427 12.9617 19.3645C14.9945 19.262 16.6215 18.5328 18.0873 17.067C19.0668 16.0875 19.6379 15.1663 20.0725 13.8644C20.3166 13.1336 20.3512 12.8471 20.3512 11.5603C20.3512 10.2736 20.3166 9.98706 20.0725 9.25621C19.6379 7.95433 19.0668 7.0331 18.0873 6.05364C16.4266 4.39297 14.6419 3.68684 12.3085 3.76717C11.4187 3.79787 10.8968 3.87755 10.2766 4.07773Z","fill","#fff"]],template:function(t,r){t&1&&u(0,oon,40,38,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,Jn,LA,K1,ge],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%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}*[_ngcontent-%COMP%]:not(svg *){height:unset;width:unset}.s-presence-avatar-initial[_ngcontent-%COMP%]{color:#fff!important}.pin2[_ngcontent-%COMP%]{position:relative!important;display:flex!important;justify-content:center!important;align-items:center!important;width:2.25em!important;height:2.25em!important;background:linear-gradient(145deg,#6941ff,#ff5f7a,#ffa113)!important;border-radius:2em!important;overflow:hidden!important;margin-left:-.5em!important;transition:transform .2s ease}.pin2[_ngcontent-%COMP%]:not(.s-current-user){cursor:pointer!important}.pin2[_ngcontent-%COMP%]:hover{z-index:2!important;transform:scale(1.1)!important}.modal-author__image[_ngcontent-%COMP%]{width:2em!important;height:2em!important;background-size:cover!important;border-radius:50%!important;border:1px solid!important}.pins-wrap[_ngcontent-%COMP%]{position:relative!important;display:flex!important;width:max-content!important;justify-content:center!important;align-items:center!important;margin-left:.5em!important}button[_ngcontent-%COMP%]{background:#e6e8ec00!important;transition:.5s!important;font-style:normal!important;font-weight:600!important;font-size:14px!important;line-height:1em!important;outline:0!important;border:0!important;color:#fff!important}button[_ngcontent-%COMP%]:hover{background:#23262f!important;cursor:pointer!important}.action-menu[_ngcontent-%COMP%]{position:relative!important;display:flex!important;width:max-content!important;justify-content:center!important;gap:1em!important}.buttons-wrap[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:flex-start!important;gap:.25em!important}.primary[_ngcontent-%COMP%]{color:#fff!important;padding:.5em .75em!important;background:#625df580!important;border-radius:5.6em!important}.secondary[_ngcontent-%COMP%]:hover{background:#625df5!important;border:2px solid rgb(98,93,245)!important}.secondary[_ngcontent-%COMP%]:focus{background:#625df5!important;outline:0!important}.secondary[_ngcontent-%COMP%]:active{background:#3b3893!important}.secondary[_ngcontent-%COMP%]{padding:.5em .75em!important;border-radius:5.6em!important;border:2px solid #E6E8EC!important}.line-div[_ngcontent-%COMP%]{border-top:1px solid #e6e8ec!important;width:100%!important}.reply-div[_ngcontent-%COMP%], .single-comment-disable-div[_ngcontent-%COMP%]{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:flex-start!important}.value-div[_ngcontent-%COMP%]{gap:.25em!important}.modal-div[_ngcontent-%COMP%]{position:relative!important;display:flex!important;flex-direction:column!important;gap:1em!important;border-radius:.75em!important;background-color:#fff!important;box-sizing:border-box!important;width:max-content!important;text-align:left!important;font-size:14px!important;color:#141416!important}.modal-header[_ngcontent-%COMP%]{display:flex!important;justify-content:flex-end!important;gap:.75em!important}.modal-header__button[_ngcontent-%COMP%]{border:0!important;border-radius:50%!important;width:2em!important;height:2em!important;flex-shrink:0!important;display:flex!important;align-items:center!important;justify-content:center!important}.modal-messages[_ngcontent-%COMP%]{display:flex!important;flex-direction:column!important;gap:1em!important}.modal-author[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;gap:.25em!important}.modal-author__image[_ngcontent-%COMP%]{width:2em!important;height:2em!important;background-color:#d3d3d3!important;background-size:cover!important;border-radius:50%!important}.modal-author__name[_ngcontent-%COMP%]{flex-grow:1!important;font-style:normal!important;font-weight:600!important;font-size:16px!important;line-height:1.5!important;color:#141416!important}.modal-author__last-message[_ngcontent-%COMP%]{font-style:normal!important;font-weight:400!important;font-size:12px!important;line-height:1.5!important;display:flex!important;align-items:center!important;text-align:right!important;color:#777e91!important}.modal-author__text[_ngcontent-%COMP%]{flex-grow:1!important;padding-left:2.6em!important}.action__button[_ngcontent-%COMP%]{border:0!important;border-radius:50%!important;width:2.4em!important;height:2.4em!important;flex-shrink:0!important;display:flex!important;align-items:center!important;justify-content:center!important}.action__button[_ngcontent-%COMP%]:disabled{cursor:not-allowed!important}.action__button[_ngcontent-%COMP%]:disabled svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.actions-wrap[_ngcontent-%COMP%]{position:relative!important;height:2.4em!important;display:flex!important;flex-direction:line!important;align-items:center!important;justify-content:flex-start!important;gap:.25em!important}.input-text-wrap[_ngcontent-%COMP%]{width:max-content!important;height:100%!important;border-radius:.5em!important;background-color:#141416!important;border:0!important;box-sizing:border-box!important;position:relative!important;box-shadow:0 0 24px -2px #ffffff61;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((25rem + 0px) * var(--velt-base-rem-unit))!important}.input-text[_ngcontent-%COMP%]{font-style:normal!important;font-weight:400!important;font-size:14px!important;line-height:1.5em!important;padding:.25em!important;width:100%!important;height:100%!important;background-color:#fcfcfd!important;box-sizing:border-box!important;outline:0!important;overflow:hidden!important}.tooltip[_ngcontent-%COMP%]{position:relative!important;display:flex!important;flex-direction:column!important}.tooltip-link[_ngcontent-%COMP%]{font-style:normal!important;font-weight:400!important;font-size:12px!important;line-height:1.5em!important}.tooltip[_ngcontent-%COMP%] .tooltiptext[_ngcontent-%COMP%]{visibility:hidden!important;block-size:auto!important;width:max-content!important;top:135%!important;background-color:#000!important;color:#fff!important;text-align:left!important;padding:6px 12px!important;border-radius:6px!important;font-style:normal!important;font-weight:400!important;font-size:14px!important;line-height:2em!important;position:absolute!important;z-index:1!important;opacity:0!important;transition:opacity .5s!important}.tooltip[_ngcontent-%COMP%]:hover .tooltiptext[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.tooltip[_ngcontent-%COMP%] .tooltiptext[_ngcontent-%COMP%]:after{content:" "!important;position:absolute!important;top:0!important;left:50%!important;width:12px!important;height:12px!important;background-color:#000!important;border-radius:4px!important;transform:translate(-50%,-41%) rotate(45deg)!important;transform-origin:center!important} snippyly-user-avatar.huddle-menu-panel-user-avatar{display:flex} snippyly-user-avatar.huddle-menu-panel-user-avatar .s-user-avatar-initial{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important} snippyly-user-avatar.huddle-menu-panel-user-avatar .s-user-avatar-image{border:1px solid black!important;border-radius:50%!important}'],changeDetection:0});let i=o;return i})();var nye=(()=>{let o=class o{constructor(e,t){this.loggingService=e,this.dragDrop=t,this.currentX=0,this.currentY=0,this.destroy$=new Xe,this.subscriptions=[],this.loggingService.log("%c[WB] Creating CLASS: DraggableOverlayDirective","color: blue;")}ngOnInit(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: ngOnInit","color: green;"),this.setupDraggableOverlay()}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective ngOnInit: ",e)}}setupDraggableOverlay(){try{if(this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: setupDraggableOverlay","color: green;"),this.connectedOverlay&&this.connectedOverlay.overlayRef){let e=this.connectedOverlay.overlayRef.overlayElement;this.dragRef=this.dragDrop.createDrag(e),this.subscriptions.push(this.dragRef.moved.pipe(yo(this.destroy$)).subscribe(t=>{let r=this.connectedOverlay?.overlayRef.getConfig().positionStrategy;this.updatePosition(r,t.distance.x,t.distance.y)},t=>{this.loggingService.catch("Error in DraggableOverlayDirective dragRef.moved subscription: ",t)})),this.dragRef.ended.pipe(yo(this.destroy$)).subscribe(t=>{this.currentX+=t.distance.x,this.currentY+=t.distance.y},t=>{this.loggingService.catch("Error in DraggableOverlayDirective dragRef.ended subscription: ",t)})}}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective setupDraggableOverlay: ",e)}}updatePosition(e,t,r){try{if(e){let a=this.currentX+t,s=this.currentY+r;e.withDefaultOffsetX(a).withDefaultOffsetY(s),this.connectedOverlay?.overlayRef?.updatePosition()}}catch{}}cleanupDraggableOverlay(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: cleanupDraggableOverlay","color: green;"),this.dragRef&&this.dragRef.dispose()}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective cleanupDraggableOverlay: ",e)}}ngOnDestroy(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: ngOnDestroy","color: green;"),this.cleanupDraggableOverlay(),this.destroy$.next(),this.destroy$.complete(),this.subscriptions.forEach(e=>{e.unsubscribe()})}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(_),h(QP))},o.\u0275dir=Gt({type:o,selectors:[["","veltDraggableOverlay",""]],inputs:{connectedOverlay:[0,"veltDraggableOverlay","connectedOverlay"]},standalone:!1});let i=o;return i})();var son=()=>["snippyly-overlay-panel","snippyly-huddle-menu-panel-overlay-panel","velt-overlay-panel"],lon=()=>["snippyly-overlay-panel","snippyly-huddle-banner-panel","velt-overlay-panel"];function con(i,o){if(i&1){let n=K();y(0,"div",20),W("click",function(){N(n);let t=l(2);return F(t.onHuddleToolClick("audio"))}),y(1,"slot",21),W("slotchange",function(){N(n);let t=l(2);return F(t.onButtonSlotChange())}),y(2,"div",22),ce(),y(3,"svg",23),w(4,"path",24),b()()()()}}function don(i,o){if(i&1){let n=K();y(0,"div",20),W("click",function(){N(n);let t=l(2);return F(t.onHuddleToolClick("video"))}),y(1,"slot",21),W("slotchange",function(){N(n);let t=l(2);return F(t.onButtonSlotChange())}),y(2,"div",22),ce(),y(3,"svg",25),w(4,"path",26)(5,"path",27),b()()()()}}function mon(i,o){if(i&1){let n=K();y(0,"div",20),W("click",function(){N(n);let t=l(3);return F(t.onHuddleToolClick("presentation"))}),y(1,"slot",21),W("slotchange",function(){N(n);let t=l(3);return F(t.onButtonSlotChange())}),y(2,"div",22),ce(),y(3,"svg",23),w(4,"path",28),b()()()()}}function pon(i,o){i&1&&u(0,mon,5,0,"div",7),i&2&&d("ngSwitchCase","presentation")}function gon(i,o){if(i&1){let n=K();y(0,"div",29,4)(2,"slot",21),W("slotchange",function(){N(n);let t=l(2);return F(t.onButtonSlotChange())}),y(3,"div",30),ce(),y(4,"svg",31),w(5,"path",24),b(),y(6,"svg",32),w(7,"path",33),b()()()()}if(i&2){let n=me(1);l();let e=me(8);d("matMenuTriggerFor",e),m(3),pe("active",n==null?null:n.menuOpen)}}function uon(i,o){if(i&1){let n=K();y(0,"div",11),W("click",function(){N(n);let t=l(2);return F(t.onHuddleToolClick("presentation"))}),ce(),y(1,"svg",12),w(2,"path",34),b(),ht(),y(3,"span"),te(4),P(5,"translate"),b()()}if(i&2){let n=l().ngIf;d("disabled",n.disabled),m(4),ze(M(5,2,"Screen Huddle"))}}function hon(i,o){if(i&1){let n=K();y(0,"snippyly-huddle-menu-panel",36),W("toggleAudio",function(){N(n);let t=l(3);return F(t.toggleAudio())})("toggleVideo",function(){N(n);let t=l(3);return F(t.toggleVideo())})("toggleScreenSharing",function(){N(n);let t=l(3);return F(t.toggleScreenSharing())})("leave",function(){N(n);let t=l(3);return F(t.dropCall())}),b()}if(i&2){let n=l(2).ngIf,e=me(24);d("veltDraggableOverlay",e)("attendees",n.huddleAttendees)("user",n.user)("audioState",n.localStreamState==null?null:n.localStreamState.audioState)("videoState",n.localStreamState==null?null:n.localStreamState.videoState)("screenSharingState",n.localStreamState==null?null:n.localStreamState.screenSharingState)}}function fon(i,o){if(i&1&&u(0,hon,1,6,"snippyly-huddle-menu-panel",35),i&2){let n=l().ngIf;d("ngIf",n.meetingJoined)}}function von(i,o){if(i&1){let n=K();y(0,"div",38)(1,"div")(2,"div"),ce(),y(3,"svg",39),w(4,"path",40),b()(),ht(),y(5,"div")(6,"h3",41),te(7),P(8,"translate"),P(9,"translate"),P(10,"translate"),b(),y(11,"p",42),te(12),P(13,"translate"),b(),y(14,"div",43)(15,"button",44),W("click",function(){N(n);let t=l(3);return F(t.onJoinButtonClick())}),te(16,"Join"),b(),y(17,"button",45),W("click",function(){N(n);let t=l(3);return F(t.removeBanner())}),te(18,"Cancel"),b()()(),y(19,"div"),ce(),y(20,"svg",46),W("click",function(){N(n);let t=l(3);return F(t.removeBanner())}),w(21,"path",47),b()()()()}if(i&2){let n=l(2).ngIf;m(7),br("",(n.huddleAttendees==null?null:n.huddleAttendees.length)===1?M(8,3,"1 person is"):(n.huddleAttendees==null?null:n.huddleAttendees.length)+" "+M(9,5,"people are")," ",M(10,7,"on a call now")),m(5),ze(M(13,9,"You can join the call"))}}function Con(i,o){if(i&1&&u(0,von,22,11,"div",37),i&2){let n=l().ngIf;d("ngIf",n.isFirstComponent&&!n.meetingJoined&&!n.bannerRemoved&&(n.huddleAttendees==null?null:n.huddleAttendees.length))}}function _on(i,o){if(i&1){let n=K();v(0),y(1,"div",6,0),u(3,con,5,0,"div",7)(4,don,6,0,"div",7)(5,pon,1,1,"ng-template",8)(6,gon,8,3,"div",9),b(),y(7,"mat-menu",10,1)(9,"div",11),W("click",function(){N(n);let t=l();return F(t.onHuddleToolClick("audio"))}),ce(),y(10,"svg",12),w(11,"path",13),b(),ht(),y(12,"span"),te(13),P(14,"translate"),b()(),y(15,"div",11),W("click",function(){N(n);let t=l();return F(t.onHuddleToolClick("video"))}),ce(),y(16,"svg",12),w(17,"path",14)(18,"path",15),b(),ht(),y(19,"span"),te(20),P(21,"translate"),b()(),u(22,uon,6,4,"div",16),b(),u(23,fon,1,1,"ng-template",17,2,Te),w(25,"div",18,3),u(27,Con,1,1,"ng-template",19,2,Te),C()}if(i&2){let n=o.ngIf,e=me(2),t=me(26),r=l();m(),d("ngSwitch",n.type),m(2),d("ngSwitchCase","audio"),m(),d("ngSwitchCase","video"),m(),d("ngIf",n.screenSharingSupported),m(),d("ngSwitchCase","all"),m(3),d("disabled",n.disabled),m(4),ze(M(14,21,"Audio Huddle")),m(2),d("disabled",n.disabled),m(5),ze(M(21,23,"Video Huddle")),m(2),d("ngIf",n.screenSharingSupported),m(),d("cdkConnectedOverlayOrigin",e)("cdkConnectedOverlayOpen",n.meetingJoined&&n.joinedHuddleToolComponentId===r.veltId)("cdkConnectedOverlayPanelClass",ut(25,son))("cdkConnectedOverlayBackdropClass","snippyly-overlay-backdrop")("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayPositions",n.positions)("cdkConnectedOverlayDisableClose",!0),m(4),d("cdkConnectedOverlayOrigin",t)("cdkConnectedOverlayOpen",n.isFirstComponent&&!n.meetingJoined&&!n.bannerRemoved&&!!(n.huddleAttendees!=null&&n.huddleAttendees.length))("cdkConnectedOverlayPanelClass",ut(26,lon))("cdkConnectedOverlayPositions",n.positions)}}var Aq=(()=>{let o=class o extends tt{constructor(e,t,r,a,s,c,p){super(p,c),this.analyticsService=e,this.authService=t,this.huddleService=r,this.iamService=a,this.loggingService=s,this.themeService=c,this.elementRef=p,this.type="audio",this.remoteStreams=[],this.huddleStarted=!1,this.initialHuddleType="audio",this.customButtonAdded=!1,this.subscriptions=[],this.veltId=vt(),this.veltElement=!0,this.componentConfigSignal=xe({type:this.type,screenSharingSupported:!!navigator?.mediaDevices?.getDisplayMedia,disabled:!1,meetingJoined:!1,joinedHuddleToolComponentId:null,positions:U.OVERLAY_POSITIONS.map(g=>new di({originX:g.originX,originY:g.originY},{overlayX:g.overlayX,overlayY:g.overlayY})),user:null,localStreamState:{},huddleAttendees:[],isFirstComponent:!1,bannerRemoved:!1}),this.subscriptions.push(this.authService.getUser$().pipe(Le(g=>!!g)).subscribe(g=>{g&&(this.componentConfigSignal.update(f=>D(E({},f),{user:g})),this.checkToAutoJoinHuddle())},g=>{this.loggingService.catch("Error in getUser: ",g)})),this.subscriptions.push(this.huddleService.getRemoteStream().subscribe(g=>{try{g||(this.remoteStreams=[])}catch(f){this.loggingService.catch("Error in HuddleToolComponent getRemoteStream:",f)}},g=>{this.loggingService.catch("Error in getRemoteStream: ",g)})),this.subscriptions.push(this.huddleService.getLocalStreamState().subscribe(g=>{this.componentConfigSignal.update(f=>D(E({},f),{localStreamState:g}))},g=>{this.loggingService.catch("Error in getLocalStreamState: ",g)})),this.subscriptions.push(this.huddleService.getHuddleToolComponentId().subscribe(g=>{this.componentConfigSignal.update(f=>D(E({},f),{joinedHuddleToolComponentId:g}))},g=>{this.loggingService.catch("Error in getHuddleToolComponentId: ",g)})),this.subscriptions.push(this.iamService.getFeaturesAccessLevel$().subscribe(g=>{this.componentConfigSignal.update(f=>D(E({},f),{disabled:!!g?.all?.disabled}))})),this.getHuddleAttendees()}ngOnInit(){}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in HuddleToolComponent ngOnChanges: ",t)}}ngAfterViewInit(){try{let e=document.querySelector(U.TAGS.SNIPPYLY_HUDDLE_TOOL),t=document.querySelector(U.TAGS.VELT_HUDDLE_TOOL);t||e?t?this.veltId===t?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>D(E({},r),{isFirstComponent:!0})),this.checkToAutoJoinHuddle()):this.veltId===e?.getAttribute(U.ATTRIBUTES.VELT_ID)&&(this.componentConfigSignal.update(r=>D(E({},r),{isFirstComponent:!0})),this.checkToAutoJoinHuddle()):(document.querySelector(U.TAGS.SNIPPYLY_PLUGIN)||document.querySelector(U.TAGS.SUPERFLOW_TOOLBAR))&&(this.componentConfigSignal.update(r=>D(E({},r),{isFirstComponent:!0})),this.checkToAutoJoinHuddle())}catch(e){this.loggingService.catch("Error in HuddleToolComponent AfterViewInit: ",e)}}onButtonSlotChange(){this.customButtonAdded=!0}checkToAutoJoinHuddle(){try{if(this.componentConfigSignal().user&&this.componentConfigSignal().isFirstComponent){let e=sessionStorage.getItem(U.SESSION_STORAGE.SNIPPYLY_HUDDLE_DATA);if(e&&!this.huddleStarted){let t=JSON.parse(e).type;this.joinHuddle(t)}}}catch(e){this.loggingService.catch("Error in checkToAutoJoinHuddle: ",e)}}getHuddleAttendees(){this.subscriptions.push(this.huddleService.getHuddleAttendees$().subscribe(e=>{try{e?(this.componentConfigSignal.update(t=>D(E({},t),{huddleAttendees:e.slice()})),this.huddleStarted=!!e?.length,(this.componentConfigSignal().meetingJoined||!this.componentConfigSignal().huddleAttendees?.length)&&this.componentConfigSignal.update(t=>D(E({},t),{bannerRemoved:!1})),this.componentConfigSignal.update(t=>D(E({},t),{meetingJoined:!!e.find(r=>r?.userSnippylyId===this.componentConfigSignal().user?.userSnippylyId)})),this.componentConfigSignal().huddleAttendees?.length&&(this.initialHuddleType=this.componentConfigSignal().huddleAttendees[0].initialHuddleType)):(this.huddleStarted=!1,this.componentConfigSignal.update(t=>D(E({},t),{meetingJoined:!1})),this.componentConfigSignal.update(t=>D(E({},t),{bannerRemoved:!1})),this.componentConfigSignal.update(t=>D(E({},t),{huddleAttendees:[]})),this.initialHuddleType="audio")}catch(t){this.loggingService.catch("Error in HuddleToolComponent getHuddleAttendees:",t)}}))}onHuddleToolClick(e){try{if(this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_TOOL_CLICKED,{huddleType:e,toolType:this.customButtonAdded?`custom - ${this.componentConfigSignal().type}`:`default - ${this.componentConfigSignal().type}`}),this.componentConfigSignal().disabled){this.loggingService.catch("Huddle feature is disabled.");return}this.joinHuddle(e)}catch(t){this.loggingService.catch("Error in HuddleToolComponent onHuddleToolClick:",t)}}onJoinButtonClick(){try{this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_JOIN_BUTTON_CLICKED,{huddleType:this.initialHuddleType,huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(e=>e?.userId)}),this.joinHuddle(void 0)}catch(e){this.loggingService.catch("Error in HuddleToolComponent onJoinButtonClick:",e)}}joinHuddle(e){return Q(this,null,function*(){try{e?this.huddleStarted||(this.initialHuddleType=e||"audio"):e=this.initialHuddleType||"audio";let t=this.huddleService.getHuddleSessionData();if(this.componentConfigSignal().meetingJoined&&(yield this.dropCall(),yield pm(1e3)),!this.componentConfigSignal().meetingJoined)if(this.componentConfigSignal().user&&!this.componentConfigSignal().meetingJoined){this.huddleService.setHuddleToolComponentId(this.veltId);let r=U.HUDDLE_TYPE_CONFIGS[e],a=JSON.parse(JSON.stringify(r));r&&(a.audio=t?!!t.audio:r.audio,a.video=t?!!t.video:r.video,a.presentation=t?!!t.presentation:r.presentation,yield this.huddleService.setLocalStream(E({},a)),(t?t?.presentation:r.presentation)&&!this.huddleStarted?yield this.huddleService.setScreenSharingStream():a.presentation=!1,this.huddleService.updateHuddleSessionData("","",E({type:e},a)),this.componentConfigSignal.update(s=>D(E({},s),{meetingJoined:!0})),this.huddleService.joinHuddle(this.initialHuddleType),this.componentConfigSignal().huddleAttendees?.length?(this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_JOINED,{huddleType:this.initialHuddleType,totalUsers:this.huddleService.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.huddleService.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(s=>s?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(s=>s?.userId)}),this.huddleService.updateNotificationsDatabase({actionType:Pk.JOINED})):(this.huddleService.clearHuddleInvitees(),this.analyticsService.trackEvent(Y.Events.Huddle.HUDDLE_CREATED,{huddleType:this.initialHuddleType,totalUsers:this.huddleService.getHuddleAttendees()?.length||0,totalUserHuddleDuration:this.huddleService.getTotalUserHuddleDuration(),huddleSnippylyUserIds:this.huddleService.getHuddleAttendees()?.map(s=>s?.userSnippylyId),huddleClientUserIds:this.huddleService.getHuddleAttendees()?.map(s=>s?.userId)}),this.huddleService.updateNotificationsDatabase({actionType:Pk.CREATED})))}else this.componentConfigSignal().user||this.loggingService.catch("Velt sdk not authenticated.")}catch(t){this.loggingService.catch("Error in HuddleToolComponent joinHuddle:",t)}})}toggleAudio(){try{this.huddleService.updateHuddleSessionData("audio",!this.componentConfigSignal().localStreamState?.audioState),this.huddleService.toggleLocalStreamAudio()}catch(e){this.loggingService.catch("Error in HuddleToolComponent toggleAudio:",e)}}toggleVideo(){try{this.huddleService.updateHuddleSessionData("video",!this.componentConfigSignal().localStreamState?.videoState),this.huddleService.toggleLocalStreamVideo()}catch(e){this.loggingService.catch("Error in HuddleToolComponent toggleVideo:",e)}}toggleScreenSharing(){return Q(this,null,function*(){try{this.huddleService.updateHuddleSessionData("presentation",!this.componentConfigSignal().localStreamState?.screenSharingState),yield this.huddleService.toggleLocalScreenSharing()}catch(e){this.loggingService.catch("Error in HuddleToolComponent toggleScreenSharing:",e)}})}dropCall(){return Q(this,null,function*(){try{this.componentConfigSignal.update(e=>D(E({},e),{huddleAttendees:[]})),yield this.huddleService.dropCall(),yield this.huddleService.removeLocalStream(),yield this.huddleService.removeAttendee()}catch(e){this.loggingService.catch("Error in HuddleToolComponent dropCall:",e)}})}copyUrl(){Qs(window.location.href)}removeBanner(){try{this.componentConfigSignal.update(e=>D(E({},e),{bannerRemoved:!0}))}catch(e){this.loggingService.catch("Error in HuddleToolComponent removeBanner:",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(e){this.loggingService.catch("Error in HuddleToolComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in HuddleToolComponent unsubscribe: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(Qe),h(je),h(wr),h(En),h(_),h(Ke),h(R))},o.\u0275cmp=O({type:o,selectors:[["snippyly-huddle-tool"]],hostVars:2,hostBindings:function(t,r){t&2&&x("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},inputs:{type:"type"},standalone:!1,features:[L,Ze],decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["allMenu","matMenu"],["overlay","cdkConnectedOverlay"],["huddleBannerTrigger","cdkOverlayOrigin"],["allMenuTrigger","matMenuTrigger"],[4,"ngIf"],["part","container","cdkOverlayOrigin","",1,"huddle-tool-container",3,"ngSwitch"],[3,"click",4,"ngSwitchCase"],[3,"ngIf"],[3,"matMenuTriggerFor",4,"ngSwitchCase"],[1,"velt-menu","huddle-all-menu-panel"],["mat-menu-item","",3,"click","disabled"],["width","25","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M5.5 14.625C5.5 14.1609 5.68437 13.7158 6.01256 13.3876C6.34075 13.0594 6.78587 12.875 7.25 12.875H8.125C8.58913 12.875 9.03425 13.0594 9.36244 13.3876C9.69063 13.7158 9.875 14.1609 9.875 14.625V17.25C9.875 17.7141 9.69063 18.1592 9.36244 18.4874C9.03425 18.8156 8.58913 19 8.125 19H7.25C6.78587 19 6.34075 18.8156 6.01256 18.4874C5.68437 18.1592 5.5 17.7141 5.5 17.25V14.625ZM5.5 14.625V12C5.5 10.1435 6.2375 8.36301 7.55025 7.05025C8.86301 5.7375 10.6435 5 12.5 5C14.3565 5 16.137 5.7375 17.4497 7.05025C18.7625 8.36301 19.5 10.1435 19.5 12V14.625M19.5 14.625C19.5 14.1609 19.3156 13.7158 18.9874 13.3876C18.6592 13.0594 18.2141 12.875 17.75 12.875H16.875C16.4109 12.875 15.9658 13.0594 15.6376 13.3876C15.3094 13.7158 15.125 14.1609 15.125 14.625V17.25C15.125 17.7141 15.3094 18.1592 15.6376 18.4874C15.9658 18.8156 16.4109 19 16.875 19H17.75C18.2141 19 18.6592 18.8156 18.9874 18.4874C19.3156 18.1592 19.5 17.7141 19.5 17.25V14.625Z","stroke","#8F95B2","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M15.1667 10.2228L19.2138 8.19966C19.3493 8.13195 19.4998 8.09999 19.6511 8.10681C19.8024 8.11362 19.9495 8.15899 20.0783 8.23859C20.2072 8.3182 20.3135 8.42941 20.3873 8.56167C20.4611 8.69394 20.4999 8.84286 20.5 8.99432V15.0068C20.4999 15.1582 20.4611 15.3072 20.3873 15.4394C20.3135 15.5717 20.2072 15.6829 20.0783 15.7625C19.9495 15.8421 19.8024 15.8875 19.6511 15.8943C19.4998 15.9011 19.3493 15.8691 19.2138 15.8014L15.1667 13.7783V10.2228Z","stroke","#8F95B2","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M4.5 8.44445C4.5 7.97295 4.6873 7.52077 5.0207 7.18737C5.3541 6.85397 5.80628 6.66667 6.27778 6.66667H13.3889C13.8604 6.66667 14.3126 6.85397 14.646 7.18737C14.9794 7.52077 15.1667 7.97295 15.1667 8.44445V15.5556C15.1667 16.0271 14.9794 16.4792 14.646 16.8126C14.3126 17.146 13.8604 17.3333 13.3889 17.3333H6.27778C5.80628 17.3333 5.3541 17.146 5.0207 16.8126C4.6873 16.4792 4.5 16.0271 4.5 15.5556V8.44445Z","stroke","#8F95B2","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["mat-menu-item","",3,"disabled","click",4,"ngIf"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayPositions","cdkConnectedOverlayDisableClose"],["cdkOverlayOrigin",""],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayPositions"],[3,"click"],["name","button",3,"slotchange"],["part","button-container",1,"action-btn"],["part","button-icon","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M5.5 14.625C5.5 14.1609 5.68437 13.7158 6.01256 13.3876C6.34075 13.0594 6.78587 12.875 7.25 12.875H8.125C8.58913 12.875 9.03425 13.0594 9.36244 13.3876C9.69063 13.7158 9.875 14.1609 9.875 14.625V17.25C9.875 17.7141 9.69063 18.1592 9.36244 18.4874C9.03425 18.8156 8.58913 19 8.125 19H7.25C6.78587 19 6.34075 18.8156 6.01256 18.4874C5.68437 18.1592 5.5 17.7141 5.5 17.25V14.625ZM5.5 14.625V12C5.5 10.1435 6.2375 8.36301 7.55025 7.05025C8.86301 5.7375 10.6435 5 12.5 5C14.3565 5 16.137 5.7375 17.4497 7.05025C18.7625 8.36301 19.5 10.1435 19.5 12V14.625M19.5 14.625C19.5 14.1609 19.3156 13.7158 18.9874 13.3876C18.6592 13.0594 18.2141 12.875 17.75 12.875H16.875C16.4109 12.875 15.9658 13.0594 15.6376 13.3876C15.3094 13.7158 15.125 14.1609 15.125 14.625V17.25C15.125 17.7141 15.3094 18.1592 15.6376 18.4874C15.9658 18.8156 16.4109 19 16.875 19H17.75C18.2141 19 18.6592 18.8156 18.9874 18.4874C19.3156 18.1592 19.5 17.7141 19.5 17.25V14.625Z","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["part","button-icon","width","25","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M15.1667 10.2228L19.2138 8.19966C19.3493 8.13195 19.4998 8.09999 19.6511 8.10681C19.8024 8.11362 19.9495 8.15899 20.0783 8.23859C20.2072 8.3182 20.3135 8.42941 20.3873 8.56167C20.4611 8.69394 20.4999 8.84286 20.5 8.99432V15.0068C20.4999 15.1582 20.4611 15.3072 20.3873 15.4394C20.3135 15.5717 20.2072 15.6829 20.0783 15.7625C19.9495 15.8421 19.8024 15.8875 19.6511 15.8943C19.4998 15.9011 19.3493 15.8691 19.2138 15.8014L15.1667 13.7783V10.2228Z","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M4.5 8.44445C4.5 7.97295 4.6873 7.52077 5.0207 7.18737C5.3541 6.85397 5.80628 6.66667 6.27778 6.66667H13.3889C13.8604 6.66667 14.3126 6.85397 14.646 7.18737C14.9794 7.52077 15.1667 7.97295 15.1667 8.44445V15.5556C15.1667 16.0271 14.9794 16.4792 14.646 16.8126C14.3126 17.146 13.8604 17.3333 13.3889 17.3333H6.27778C5.80628 17.3333 5.3541 17.146 5.0207 16.8126C4.6873 16.4792 4.5 16.0271 4.5 15.5556V8.44445Z","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M19 12V14.1667C19 14.3582 18.9239 14.5419 18.7885 14.6773C18.653 14.8128 18.4693 14.8889 18.2778 14.8889H6.72222C6.53068 14.8889 6.34698 14.8128 6.21153 14.6773C6.07609 14.5419 6 14.3582 6 14.1667V6.94444C6 6.75289 6.07609 6.56919 6.21153 6.43375C6.34698 6.2983 6.53068 6.22221 6.72222 6.22221H13.2222M8.88889 17.7778H16.1111M10.3333 14.8889V17.7778M14.6667 14.8889V17.7778M16.1111 6.22221H19M19 6.22221V9.1111M19 6.22221L15.3889 9.83333","stroke","currentColor","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],[3,"matMenuTriggerFor"],["part","button-container",1,"action-btn","action-dropdown"],["part","button-icon","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon","action-dropdown-icon"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg",1,"toolbar-icon-dropdown-arrow"],["fill-rule","evenodd","clip-rule","evenodd","d","M12.2071 5.79289C11.8166 5.40237 11.1834 5.40237 10.7929 5.79289L8 8.58579L5.20711 5.79289C4.81658 5.40237 4.18342 5.40237 3.79289 5.79289C3.40237 6.18342 3.40237 6.81658 3.79289 7.20711L7.29289 10.7071C7.68342 11.0976 8.31658 11.0976 8.70711 10.7071L12.2071 7.20711C12.5976 6.81658 12.5976 6.18342 12.2071 5.79289Z","fill","currentColor"],["d","M19 12V14.1667C19 14.3582 18.9239 14.5419 18.7885 14.6773C18.653 14.8128 18.4693 14.8889 18.2778 14.8889H6.72222C6.53068 14.8889 6.34698 14.8128 6.21153 14.6773C6.07609 14.5419 6 14.3582 6 14.1667V6.94444C6 6.75289 6.07609 6.56919 6.21153 6.43375C6.34698 6.2983 6.53068 6.22221 6.72222 6.22221H13.2222M8.88889 17.7778H16.1111M10.3333 14.8889V17.7778M14.6667 14.8889V17.7778M16.1111 6.22221H19M19 6.22221V9.1111M19 6.22221L15.3889 9.83333","stroke","#8F95B2","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],[3,"veltDraggableOverlay","attendees","user","audioState","videoState","screenSharingState","toggleAudio","toggleVideo","toggleScreenSharing","leave",4,"ngIf"],[3,"toggleAudio","toggleVideo","toggleScreenSharing","leave","veltDraggableOverlay","attendees","user","audioState","videoState","screenSharingState"],["class","huddle-banner",4,"ngIf"],[1,"huddle-banner"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 17C11.45 17 11 16.55 11 16V12C11 11.45 11.45 11 12 11C12.55 11 13 11.45 13 12V16C13 16.55 12.55 17 12 17ZM13 9H11V7H13V9Z","fill","#625DF5"],[1,"title"],[1,"subtitle"],[1,"action-btn-container"],[1,"join-btn",3,"click"],[1,"cancel-btn",3,"click"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"close-btn",3,"click"],["fill-rule","evenodd","clip-rule","evenodd","d","M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z","fill","#777E91"]],template:function(t,r){t&1&&u(0,_on,29,27,"ng-container",5),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,Xi,mo,dn,sn,ac,Tl,Lg,tye,nye,ge],styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}*{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;text-align:left!important;line-height:1.5!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert!important}.huddle-tool-container{width:max-content}.icon-btn{border:1px solid #2d2d2d;border-radius:100%;width:40px!important;height:40px!important;display:flex;align-items:center;justify-content:center;color:#2d2d2d!important;fill:#2d2d2d!important;cursor:pointer}.icon-btn:hover{background:#fff5}.icon-btn.background-red{background:red!important;border-color:red!important;color:#fff!important;fill:#fff!important}.icon-btn.background-royalblue{background:#4169e1!important;border-color:#4169e1!important}.icon-btn:before{content:""}.drop-call-btn{transform:rotate(135deg)!important}.action-btn{display:inline-flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color);color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn .action-btn-label{font-size:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;padding-right:4px!important;font-weight:700!important;color:currentColor!important}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:currentColor}.action-btn .toolbar-icon-dropdown-arrow{width:16px;height:16px;color:currentColor}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color);color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:focus .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color);color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:hover .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color);color:var(--legacy-velt-tool-active-icon-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:active .toolbar-icon-dropdown-arrow,.action-btn.active .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-active-icon-color)}
537
537
  `],encapsulation:3,changeDetection:0});let i=o;return i})();function yon(i,o){if(i&1&&(y(0,"span",11),te(1),P(2,"translate"),b()),i&2){let n=l(2).ngIf;m(),Se(" ",n.user!=null&&n.user.name?n.user==null||n.user.name==null?null:n.user.name.charAt(0):M(2,1,n.user==null||n.user.email==null?null:n.user.email.charAt(0)))}}function Son(i,o){if(i&1){let n=K();y(0,"img",12),W("error",function(){N(n);let t=l(3);return F(t.onImageLoadError())}),b()}if(i&2){let n=l(2).ngIf;d("src",n.user==null?null:n.user.photoUrl,vn)}}function bon(i,o){if(i&1&&(y(0,"span"),te(1),P(2,"translate"),b()),i&2){let n=l(2).ngIf;m(),ze(n.isRemoteStream?n.user==null||n.user.name==null?null:n.user.name.split(" ")[0]:M(2,1,"You"))}}function Ion(i,o){i&1&&(ce(),y(0,"svg",15),w(1,"path",16),b())}function Eon(i,o){i&1&&(ce(),y(0,"svg",17),w(1,"path",18)(2,"path",19),b())}function xon(i,o){if(i&1&&(v(0),u(1,Ion,2,0,"svg",13)(2,Eon,3,0,"svg",14),C()),i&2){let n=l(2).ngIf;m(),d("ngIf",n.audioState),m(),d("ngIf",!n.audioState)}}function Ton(i,o){i&1&&(ce(),y(0,"svg",15),w(1,"path",16),b())}function Don(i,o){i&1&&(ce(),y(0,"svg",17),w(1,"path",18)(2,"path",19),b())}function won(i,o){i&1&&(ce(),y(0,"svg",23),w(1,"path",24),b())}function Oon(i,o){i&1&&(ce(),y(0,"svg",17)(1,"g"),w(2,"path",25)(3,"path",19),b()())}function Aon(i,o){if(i&1){let n=K();y(0,"div",20),W("click",function(t){return N(n),F(t.stopPropagation())}),y(1,"div",21),W("click",function(){N(n);let t=l(3);return F(t.onToggleAudioClick())}),u(2,Ton,2,0,"svg",13)(3,Don,3,0,"svg",14),b(),y(4,"div",21),W("click",function(){N(n);let t=l(3);return F(t.onToggleVideoClick())}),u(5,won,2,0,"svg",22)(6,Oon,4,0,"svg",14),b()()}if(i&2){let n=l(2).ngIf;m(2),d("ngIf",n.audioState),m(),d("ngIf",!n.audioState),m(2),d("ngIf",n.videoState),m(),d("ngIf",!n.videoState)}}function Pon(i,o){if(i&1){let n=K();y(0,"div",20),W("click",function(t){return N(n),F(t.stopPropagation())}),y(1,"div",21),W("click",function(){N(n);let t=l(3);return F(t.onToggleHuddleOnCursor())}),ce(),y(2,"svg",17),w(3,"path",26),b()()()}}function Mon(i,o){if(i&1){let n=K();y(0,"div",3),W("click",function(){N(n);let t=l(2);return F(t.toggleSelection())}),y(1,"div",4),w(2,"video",5),y(3,"div",6)(4,"span",7),P(5,"translate"),u(6,yon,3,3,"span",8)(7,Son,1,1,"ng-template",null,0,Te),b()(),y(9,"div",9),u(10,bon,3,3,"span",1)(11,xon,3,2,"ng-container",1),b()(),u(12,Aon,7,4,"div",10)(13,Pon,4,0,"div",10),b()}if(i&2){let n=me(8),e=l().ngIf,t=l();pe("local-stream",!e.isRemoteStream)("video-off",!e.videoState)("speaking",e.audioState)("selected",t.selected),m(2),pe("flip",!e.isRemoteStream),d("srcObject",e.isRemoteStream?e.remoteVideoStream:e.stream)("muted",e.isRemoteStream?null:"muted")("volume",e.isRemoteStream?1:0),m(2),at("color",(e.user==null?null:e.user.color)+" !important")("background-color",(e.user==null?null:e.user.color)+" !important"),d("title",M(5,24,(e.user==null?null:e.user.name)||(e.user==null?null:e.user.email))),m(2),d("ngIf",e.showInitials)("ngIfElse",n),m(4),d("ngIf",e.user==null?null:e.user.name),m(),d("ngIf",e.isRemoteStream),m(),d("ngIf",!e.isRemoteStream),m(),d("ngIf",e.isRemoteStream)}}function kon(i,o){if(i&1&&(v(0),u(1,Mon,14,26,"div",2),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.isRemoteStream?n.remoteVideoStream:n.stream)}}var iye=(()=>{let o=class o{get remoteStream(){return this._remoteStream}set remoteStream(e){this._remoteStream=e}constructor(e){this.loggingService=e,this.toggleAudio=new Me,this.toggleVideo=new Me,this.toggleHuddleOnCursor=new Me,this.veltElement=!0,this.componentConfigSignal=xe({isRemoteStream:this.isRemoteStream,remoteVideoStream:this.remoteVideoStream,stream:this.stream,videoState:this.videoState,audioState:this.audioState,user:this.user,selected:this.selected,showInitials:!1})}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling VideoHuddleUserComponent FUNCTION: ngOnChanges","color: green;"),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in VideoHuddleUserComponent ngOnChanges: ",t)}}onToggleAudioClick(){this.toggleAudio.emit()}onToggleVideoClick(){this.toggleVideo.emit()}toggleSelection(){this.componentConfigSignal.update(e=>(e.selected=!e.selected,e))}onImageLoadError(){this.loggingService.log("%c[WB] Calling FUNCTION: onImageLoadError","color: green;");try{this.componentConfigSignal.update(e=>(e=D(E({},e),{showInitials:!0}),e))}catch(e){this.loggingService.catch("Error in VideoHuddleUserComponent onImageLoadError: ",e)}}onToggleHuddleOnCursor(){this.loggingService.log("%c[WB] Calling FUNCTION: onToggleHuddleOnCursor","color: green;");try{this.toggleHuddleOnCursor.emit()}catch(e){this.loggingService.catch("Error in VideoHuddleUserComponent onToggleHuddleOnCursor: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(_))},o.\u0275cmp=O({type:o,selectors:[["snippyly-video-huddle-user"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{stream:"stream",selected:"selected",isRemoteStream:"isRemoteStream",user:"user",audioState:"audioState",videoState:"videoState",remoteStream:"remoteStream",remoteVideoStream:"remoteVideoStream"},outputs:{toggleAudio:"toggleAudio",toggleVideo:"toggleVideo",toggleHuddleOnCursor:"toggleHuddleOnCursor"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[["showAvatarImgRef",""],[4,"ngIf"],["class","video-huddle-block",3,"local-stream","video-off","speaking","selected","click",4,"ngIf"],[1,"video-huddle-block",3,"click"],[1,"video-player-container"],["playsinline","","autoplay","true",3,"srcObject","muted","volume"],[1,"user-profile-container"],["velt-ignore-change-detection","true",1,"s-presence-avatar",3,"title"],["class","s-presence-avatar-initial",4,"ngIf","ngIfElse"],[1,"video-player-overlay"],["class","video-huddle-actions-panel",3,"click",4,"ngIf"],[1,"s-presence-avatar-initial"],["referrerpolicy","no-referrer","loading","lazy",1,"s-presence-avatar-image",3,"error","src"],["width","13","height","19","viewBox","0 0 13 19","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["width","13","height","19","viewBox","0 0 13 19","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M5.77526 0.888917C4.98766 1.03653 4.34477 1.39041 3.76525 1.99544C3.26289 2.51988 2.94255 3.10884 2.75974 3.84431C2.69679 4.09753 2.6908 4.39635 2.6908 7.29276C2.6908 10.7979 2.68044 10.6352 2.94799 11.327C3.299 12.2346 4.07584 13.0561 4.94368 13.4374C5.82412 13.8243 6.82444 13.8531 7.71552 13.5173C8.69181 13.1494 9.53872 12.2934 9.92297 11.2862C10.1713 10.6354 10.1631 10.7714 10.1631 7.29276C10.1631 3.78764 10.1735 3.95032 9.90592 3.25855C9.62932 2.54335 9.02923 1.81042 8.38767 1.40419C7.61998 0.918084 6.64549 0.725873 5.77526 0.888917ZM6.9551 2.18212C7.80033 2.36379 8.55484 3.08137 8.82443 3.95997C8.91085 4.24162 8.9112 4.25479 8.9112 7.29276C8.9112 10.3307 8.91085 10.3439 8.82443 10.6256C8.578 11.4287 7.92854 12.0994 7.15071 12.3538C6.92897 12.4264 6.7875 12.4431 6.40739 12.4415C6.00213 12.4398 5.89869 12.425 5.65097 12.3333C5.00401 12.0936 4.49038 11.6376 4.2051 11.0497C3.92221 10.4667 3.92452 10.4977 3.92452 7.29276C3.92452 4.09736 3.92315 4.11587 4.19825 3.55135C4.71228 2.49645 5.83136 1.94067 6.9551 2.18212ZM0.537139 8.64006C0.373453 8.71677 0.215048 8.92183 0.182929 9.09861C0.133831 9.36895 0.199086 10.6794 0.283042 11.1082C0.737953 13.4317 2.32631 15.2803 4.50075 16.017C4.75328 16.1025 5.14915 16.2055 5.38044 16.2458L5.801 16.3192V16.9744V17.6296L5.06042 17.6421C4.38416 17.6536 4.31046 17.6619 4.21195 17.738C4.00671 17.8964 3.94271 18.0255 3.94271 18.2809C3.94271 18.5363 4.00679 18.6655 4.21206 18.8237C4.31804 18.9055 4.36006 18.907 6.42696 18.907C8.49385 18.907 8.53586 18.9055 8.64185 18.8237C8.84712 18.6655 8.9112 18.5363 8.9112 18.2809C8.9112 18.0255 8.8472 17.8964 8.64196 17.738C8.54346 17.6619 8.46975 17.6536 7.79349 17.6421L7.05291 17.6296V16.9744V16.3192L7.47347 16.2469C9.74567 15.8564 11.6474 14.1569 12.3699 11.8711C12.6066 11.1222 12.6648 10.7131 12.6659 9.79054C12.6668 9.05017 12.6614 8.98828 12.5862 8.8841C12.4332 8.67197 12.3081 8.60568 12.0605 8.60568C11.8131 8.60568 11.6881 8.67181 11.5348 8.88378C11.4622 8.9842 11.4515 9.07453 11.4282 9.79025C11.4001 10.6516 11.3449 11.0079 11.1515 11.5749C10.8931 12.3325 10.527 12.9264 9.95298 13.5192C9.22696 14.2689 8.41181 14.7274 7.405 14.9524C6.91168 15.0626 5.87256 15.0542 5.38588 14.936C4.37192 14.6897 3.6185 14.2601 2.90093 13.5192C2.32689 12.9264 1.96079 12.3325 1.70239 11.5749C1.50901 11.0079 1.45377 10.6516 1.42568 9.79025C1.39755 8.92635 1.3871 8.88689 1.13621 8.69342C1.00672 8.5936 0.695505 8.56589 0.537139 8.64006Z","fill","#FF7162"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M9.77526 0.888917C8.98766 1.03653 8.34477 1.39041 7.76525 1.99544C7.26289 2.51988 6.94255 3.10884 6.75974 3.84431C6.69679 4.09753 6.6908 4.39635 6.6908 7.29276C6.6908 10.7979 6.68044 10.6352 6.94799 11.327C7.299 12.2346 8.07584 13.0561 8.94368 13.4374C9.82412 13.8243 10.8244 13.8531 11.7155 13.5173C12.6918 13.1494 13.5387 12.2934 13.923 11.2862C14.1713 10.6354 14.1631 10.7714 14.1631 7.29276C14.1631 3.78764 14.1735 3.95032 13.9059 3.25855C13.6293 2.54335 13.0292 1.81042 12.3877 1.40419C11.62 0.918084 10.6455 0.725873 9.77526 0.888917ZM10.9551 2.18212C11.8003 2.36379 12.5548 3.08137 12.8244 3.95997C12.9108 4.24162 12.9112 4.25479 12.9112 7.29276C12.9112 10.3307 12.9108 10.3439 12.8244 10.6256C12.578 11.4287 11.9285 12.0994 11.1507 12.3538C10.929 12.4264 10.7875 12.4431 10.4074 12.4415C10.0021 12.4398 9.89869 12.425 9.65097 12.3333C9.00401 12.0936 8.49038 11.6376 8.2051 11.0497C7.92221 10.4667 7.92452 10.4977 7.92452 7.29276C7.92452 4.09736 7.92315 4.11587 8.19825 3.55135C8.71228 2.49645 9.83136 1.94067 10.9551 2.18212ZM4.53714 8.64006C4.37345 8.71677 4.21505 8.92183 4.18293 9.09861C4.13383 9.36895 4.19909 10.6794 4.28304 11.1082C4.73795 13.4317 6.32631 15.2803 8.50075 16.017C8.75328 16.1025 9.14915 16.2055 9.38044 16.2458L9.801 16.3192V16.9744V17.6296L9.06042 17.6421C8.38416 17.6536 8.31046 17.6619 8.21195 17.738C8.00671 17.8964 7.94271 18.0255 7.94271 18.2809C7.94271 18.5363 8.00679 18.6655 8.21206 18.8237C8.31804 18.9055 8.36006 18.907 10.427 18.907C12.4938 18.907 12.5359 18.9055 12.6418 18.8237C12.8471 18.6655 12.9112 18.5363 12.9112 18.2809C12.9112 18.0255 12.8472 17.8964 12.642 17.738C12.5435 17.6619 12.4697 17.6536 11.7935 17.6421L11.0529 17.6296V16.9744V16.3192L11.4735 16.2469C13.7457 15.8564 15.6474 14.1569 16.3699 11.8711C16.6066 11.1222 16.6648 10.7131 16.6659 9.79054C16.6668 9.05017 16.6614 8.98828 16.5862 8.8841C16.4332 8.67197 16.3081 8.60568 16.0605 8.60568C15.8131 8.60568 15.6881 8.67181 15.5348 8.88378C15.4622 8.9842 15.4515 9.07453 15.4282 9.79025C15.4001 10.6516 15.3449 11.0079 15.1515 11.5749C14.8931 12.3325 14.527 12.9264 13.953 13.5192C13.227 14.2689 12.4118 14.7274 11.405 14.9524C10.9117 15.0626 9.87256 15.0542 9.38588 14.936C8.37192 14.6897 7.6185 14.2601 6.90093 13.5192C6.32689 12.9264 5.96079 12.3325 5.70239 11.5749C5.50901 11.0079 5.45377 10.6516 5.42568 9.79025C5.39755 8.92636 5.3871 8.88689 5.13621 8.69342C5.00672 8.5936 4.69551 8.56589 4.53714 8.64006Z","fill","white"],["d","M19 1L1 19","stroke","#FF7162","stroke-width","1.4","stroke-linecap","round"],[1,"video-huddle-actions-panel",3,"click"],[1,"video-huddle-action-button",3,"click"],["width","19","height","11","viewBox","0 0 19 11","fill","none","xmlns","http://www.w3.org/2000/svg",4,"ngIf"],["width","19","height","11","viewBox","0 0 19 11","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M2.55139 0.23203C1.68754 0.455725 1.06855 1.0239 0.766641 1.87017L0.666016 2.15221V5.58961V9.027L0.766892 9.30905C1.0535 10.1102 1.64038 10.6751 2.43987 10.9192L2.70863 11.0013H7.1343H11.56L11.8467 10.9053C12.6234 10.645 13.2099 10.0654 13.47 9.30122C13.56 9.03659 13.5637 8.9921 13.5769 8.03104C13.5844 7.48324 13.6004 7.03508 13.6125 7.03508C13.661 7.03508 15.0857 7.85713 15.8518 8.32715C16.7188 8.85908 16.9126 8.93887 17.338 8.93887C18.0692 8.93887 18.7509 8.40866 18.947 7.6873C19.0174 7.42849 19.0165 3.7478 18.946 3.48726C18.7883 2.90449 18.278 2.40845 17.7016 2.27772C17.4483 2.22025 17.0895 2.2339 16.8373 2.31054C16.6848 2.35687 16.3699 2.52617 15.9107 2.80867C15.3288 3.16675 13.6405 4.14414 13.6039 4.14414C13.5979 4.14414 13.5847 3.71184 13.5747 3.18343C13.5543 2.10543 13.5363 1.99899 13.2916 1.50796C13.0166 0.956034 12.475 0.494788 11.8467 0.277192L11.56 0.177913L7.18806 0.170686C2.95948 0.163705 2.80747 0.165715 2.55139 0.23203ZM11.3211 1.83643C11.5404 1.90052 11.7306 2.05381 11.8398 2.25463L11.9183 2.399V5.57293V8.74683L11.8268 8.92184C11.7122 9.14091 11.4929 9.30852 11.2552 9.35869C11.0123 9.40995 3.20786 9.41115 2.98224 9.35999C2.74243 9.30559 2.53297 9.14483 2.42553 8.93266L2.33236 8.74873V5.58961V2.43048L2.42553 2.24656C2.52985 2.04059 2.7435 1.87225 2.96604 1.82078C3.04208 1.80318 4.88581 1.78753 7.11882 1.78556C10.641 1.78245 11.1578 1.78873 11.3211 1.83643ZM17.3116 5.59366V7.28997L17.2309 7.23801C16.8358 6.98339 15.6936 6.30427 15.1359 5.99233C14.7573 5.78052 14.4468 5.5987 14.4461 5.5883C14.4453 5.57787 14.7874 5.37536 15.2062 5.13827C15.6251 4.90114 16.258 4.52634 16.6128 4.30536C16.9675 4.08438 17.2699 3.90215 17.2847 3.90045C17.2995 3.89876 17.3116 4.6607 17.3116 5.59366Z","fill","#FF7162"],["fill-rule","evenodd","clip-rule","evenodd","d","M3.55139 4.23203C2.68754 4.45573 2.06855 5.0239 1.76664 5.87017L1.66602 6.15221V9.58961V13.027L1.76689 13.309C2.0535 14.1102 2.64038 14.6751 3.43987 14.9192L3.70863 15.0013H8.1343H12.56L12.8467 14.9053C13.6234 14.645 14.2099 14.0654 14.47 13.3012C14.56 13.0366 14.5637 12.9921 14.5769 12.031C14.5844 11.4832 14.6004 11.0351 14.6125 11.0351C14.661 11.0351 16.0857 11.8571 16.8518 12.3271C17.7188 12.8591 17.9126 12.9389 18.338 12.9389C19.0692 12.9389 19.7509 12.4087 19.947 11.6873C20.0174 11.4285 20.0165 7.7478 19.946 7.48726C19.7883 6.90449 19.278 6.40845 18.7016 6.27772C18.4483 6.22025 18.0895 6.2339 17.8373 6.31054C17.6848 6.35687 17.3699 6.52617 16.9107 6.80867C16.3288 7.16675 14.6405 8.14414 14.6039 8.14414C14.5979 8.14414 14.5847 7.71184 14.5747 7.18343C14.5543 6.10543 14.5363 5.99899 14.2916 5.50796C14.0166 4.95603 13.475 4.49479 12.8467 4.27719L12.56 4.17791L8.18806 4.17069C3.95948 4.16371 3.80747 4.16571 3.55139 4.23203ZM12.3211 5.83643C12.5404 5.90052 12.7306 6.05381 12.8398 6.25463L12.9183 6.399V9.57293V12.7468L12.8268 12.9218C12.7122 13.1409 12.4929 13.3085 12.2552 13.3587C12.0123 13.4099 4.20786 13.4111 3.98224 13.36C3.74243 13.3056 3.53297 13.1448 3.42553 12.9327L3.33236 12.7487V9.58961V6.43048L3.42553 6.24656C3.52985 6.04059 3.7435 5.87225 3.96604 5.82078C4.04208 5.80318 5.88581 5.78753 8.11882 5.78556C11.641 5.78245 12.1578 5.78873 12.3211 5.83643ZM18.3116 9.59366V11.29L18.2309 11.238C17.8358 10.9834 16.6936 10.3043 16.1359 9.99233C15.7573 9.78052 15.4468 9.5987 15.4461 9.5883C15.4453 9.57787 15.7874 9.37536 16.2062 9.13827C16.6251 8.90114 17.258 8.52634 17.6128 8.30536C17.9675 8.08438 18.2699 7.90215 18.2847 7.90045C18.2995 7.89876 18.3116 8.6607 18.3116 9.59366Z","fill","white"],["d","M4.69231 5.29805L6.9519 16.6605C7.26158 18.2178 9.31823 18.591 10.1553 17.2418L12.4275 13.5798C12.4611 13.5255 12.5143 13.4861 12.5761 13.4699L16.8289 12.3482C18.3433 11.9488 18.6107 9.91372 17.2509 9.13668L7.27695 3.4373C5.97394 2.69272 4.3996 3.82614 4.69231 5.29805Z","stroke","#E5E5E9","stroke-width","1.5","stroke-linecap","square"]],template:function(t,r){t&1&&u(0,kon,2,1,"ng-container",1),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[X,ge],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%]{-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}*[_ngcontent-%COMP%]:not(svg *){height:unset;width:unset}.video-huddle-block[_ngcontent-%COMP%] video[_ngcontent-%COMP%]{width:100%!important;height:100%!important;pointer-events:none!important}.video-huddle-block[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:20px!important;height:20px!important}.video-huddle-block[_ngcontent-%COMP%] .video-player-container[_ngcontent-%COMP%]{position:relative!important}.video-huddle-block[_ngcontent-%COMP%] .video-player-container[_ngcontent-%COMP%] .video-player-overlay[_ngcontent-%COMP%]{width:100%!important;height:100%!important;position:absolute!important;top:0!important;background:#56565670!important;border-radius:100%!important;display:none!important;flex-direction:column;justify-content:center;align-items:center}.video-huddle-block[_ngcontent-%COMP%] .video-player-container[_ngcontent-%COMP%] .video-player-overlay[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{margin:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important}.video-huddle-block[_ngcontent-%COMP%] .video-player-container[_ngcontent-%COMP%]:hover .video-player-overlay[_ngcontent-%COMP%], .video-huddle-block.video-off[_ngcontent-%COMP%] .user-profile-container[_ngcontent-%COMP%]{display:flex!important}.video-huddle-block.video-off[_ngcontent-%COMP%] video[_ngcontent-%COMP%]{display:none!important}.video-huddle-block[_ngcontent-%COMP%] .user-profile-container[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:none!important;align-items:center!important;justify-content:center!important;background:#232323!important;border-radius:50%!important}.s-presence-avatar[_ngcontent-%COMP%]{position:relative!important;box-shadow:0 0 0 3px!important;border-radius:50%!important;overflow:hidden!important;width:100%!important;height:100%!important;min-width:100%!important;min-height:100%!important;display:flex!important;align-items:center!important;justify-content:center!important}.s-presence-avatar.more-users[_ngcontent-%COMP%]{background:#4578a7!important;box-shadow:0 0 0 3px #4578a7!important}.attendees-container[_ngcontent-%COMP%]{display:inline-flex!important;flex-direction:row-reverse!important;align-items:center!important;margin:0 16px 0 8px!important}.s-presence-avatar[_ngcontent-%COMP%]:not(:last-child):not(.more-users){margin-left:calc((-.5rem + 0px) * var(--velt-base-rem-unit))!important}.s-presence-avatar-image[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block!important;object-fit:cover!important}.s-presence-avatar-image-small[_ngcontent-%COMP%]{width:calc((1.6rem + 0px) * var(--velt-base-rem-unit))!important;height:100%!important;display:block!important;object-fit:cover!important}.s-presence-avatar-initial[_ngcontent-%COMP%]{color:#fff!important;font-size:calc((3rem + 0px) * var(--velt-base-rem-unit))!important}"],changeDetection:0});let i=o;return i})();var Non=(i,o,n)=>({large:i,medium:o,small:n});function Fon(i,o){if(i&1){let n=K();y(0,"div",3),w(1,"video",4),y(2,"div",5)(3,"div",6),W("click",function(){N(n);let t=l(2);return F(t.onToggleScreenSharing())}),te(4),P(5,"translate"),b()()()}if(i&2){let n=l().ngIf;m(),d("srcObject",n.stream)("volume",0),m(3),ze(M(5,3,"Stop Sharing"))}}function Lon(i,o){if(i&1){let n=K();y(0,"div",7),w(1,"video",4),y(2,"div",5)(3,"div"),te(4),P(5,"translate"),b(),y(6,"div",8),ce(),y(7,"svg",9),W("click",function(){N(n);let t=l(2);return F(t.changeViewportSize("large"))}),w(8,"path",10)(9,"path",11),b(),y(10,"svg",12),W("click",function(){N(n);let t=l(2);return F(t.changeViewportSize("medium"))}),w(11,"path",13)(12,"path",14),b(),y(13,"svg",15),W("click",function(){N(n);let t=l(2);return F(t.changeViewportSize("small"))}),w(14,"path",16)(15,"path",17),b()()()()}if(i&2){let n=l().ngIf;d("ngClass",$e(13,Non,n.viewportSize==="large",n.viewportSize==="medium",n.viewportSize==="small")),m(),d("srcObject",n.stream)("volume",0),m(3),br("",(n.user==null?null:n.user.name)||(n.user==null?null:n.user.email)," ",M(5,11,"is sharing now.")),m(3),pe("selected",n.viewportSize==="large"),m(3),pe("selected",n.viewportSize==="medium"),m(3),pe("selected",n.viewportSize==="small")}}function Bon(i,o){if(i&1&&(v(0),u(1,Fon,6,5,"div",1)(2,Lon,16,17,"div",2),C()),i&2){let n=o.ngIf;m(),d("ngIf",n.stream&&!n.isRemoteStream),m(),d("ngIf",n.stream&&n.isRemoteStream)}}var oye=(()=>{let o=class o{constructor(e){this.loggingService=e,this.isRemoteStream=!1,this.toggleScreenSharing=new Me,this.viewportSizeChange=new Me,this.veltElement=!0,this.componentConfigSignal=xe({stream:this.stream,isRemoteStream:this.isRemoteStream,viewportSize:"small",user:this.user})}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling ScreenSharingHuddleComponent FUNCTION: ngOnChanges","color: green;"),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(r=>(r=D(E({},r),{[t]:e[t].currentValue}),r))})}catch(t){this.loggingService.catch("Error in ScreenSharingHuddleComponent ngOnChanges: ",t)}}changeViewportSize(e){this.componentConfigSignal.update(t=>D(E({},t),{viewportSize:e})),this.viewportSizeChange.emit(this.componentConfigSignal().viewportSize)}onToggleScreenSharing(){this.toggleScreenSharing.emit()}};o.\u0275fac=function(t){return new(t||o)(h(_))},o.\u0275cmp=O({type:o,selectors:[["snippyly-screen-sharing-huddle"]],hostVars:1,hostBindings:function(t,r){t&2&&x("data-velt-element",r.veltElement)},inputs:{user:"user",stream:"stream",isRemoteStream:"isRemoteStream"},outputs:{toggleScreenSharing:"toggleScreenSharing",viewportSizeChange:"viewportSizeChange"},standalone:!1,features:[Ze],decls:1,vars:1,consts:[[4,"ngIf"],["class","screen-sharing-container local-screen-sharing-container",4,"ngIf"],["class","screen-sharing-container remote-screen-sharing-container",3,"ngClass",4,"ngIf"],[1,"screen-sharing-container","local-screen-sharing-container"],["autoplay","","muted","true","playsinline","",3,"srcObject","volume"],[1,"screen-sharing-overlay"],[1,"stop-sharing-btn",3,"click"],[1,"screen-sharing-container","remote-screen-sharing-container",3,"ngClass"],[1,"screen-sharing-resize-container"],["width","21","height","20","viewBox","0 0 21 20","fill","none","xmlns","http://www.w3.org/2000/svg",3,"click"],["d","M18.0006 2.5H3.00065C2.08018 2.5 1.33398 3.24619 1.33398 4.16667V13.3333C1.33398 14.2538 2.08018 15 3.00065 15H5.06885C5.33962 15 5.59351 14.8684 5.74966 14.6472L8.45823 10.8101C9.45427 9.39904 11.547 9.39904 12.5431 10.8101L15.2516 14.6472C15.4078 14.8684 15.6617 15 15.9324 15H18.0006C18.9211 15 19.6673 14.2538 19.6673 13.3333V4.16667C19.6673 3.24619 18.9211 2.5 18.0006 2.5Z"],["d","M6.50021 16.1684L9.83354 11.724C10.1669 11.2795 10.8335 11.2795 11.1669 11.724L14.5002 16.1684C14.9122 16.7178 14.5202 17.5017 13.8335 17.5017H7.16688C6.48017 17.5017 6.08819 16.7178 6.50021 16.1684Z"],["width","15","height","12","viewBox","0 0 15 12","fill","none","xmlns","http://www.w3.org/2000/svg",3,"click"],["d","M13.6364 0.167969H1.36364C0.610521 0.167969 0 0.748339 0 1.46426V8.59387C0 9.3098 0.610521 9.89017 1.36364 9.89017H3.0558C3.27734 9.89017 3.48507 9.78785 3.61283 9.61579L5.82893 6.63136C6.64387 5.53387 8.35613 5.53387 9.17107 6.63136L11.3872 9.61579C11.5149 9.78785 11.7227 9.89017 11.9442 9.89017H13.6364C14.3895 9.89017 15 9.3098 15 8.59387V1.46426C15 0.748339 14.3895 0.167969 13.6364 0.167969Z"],["d","M4.22745 10.7981L6.95472 7.34129C7.22745 6.99561 7.7729 6.99561 8.04563 7.34129L10.7729 10.7981C11.11 11.2254 10.7893 11.8351 10.2274 11.8351H4.7729C4.21105 11.8351 3.89034 11.2254 4.22745 10.7981Z"],["width","11","height","10","viewBox","0 0 11 10","fill","none","xmlns","http://www.w3.org/2000/svg",3,"click"],["d","M9.59091 0.832031H1.40909C0.907014 0.832031 0.5 1.24658 0.5 1.75795V6.85053C0.5 7.36191 0.907014 7.77646 1.40909 7.77646H2.5372C2.68489 7.77646 2.82338 7.70337 2.90855 7.58048L4.38595 5.44874C4.92925 4.66482 6.07075 4.66482 6.61405 5.44874L8.09145 7.58048C8.17662 7.70337 8.31511 7.77646 8.4628 7.77646H9.59091C10.093 7.77646 10.5 7.36191 10.5 6.85053V1.75795C10.5 1.24658 10.093 0.832031 9.59091 0.832031Z"],["d","M3.3183 8.42384L5.13648 5.95472C5.3183 5.7078 5.68193 5.7078 5.86375 5.95472L7.68193 8.42384C7.90667 8.72905 7.69286 9.16458 7.3183 9.16458H3.68193C3.30737 9.16458 3.09356 8.72905 3.3183 8.42384Z"]],template:function(t,r){t&1&&u(0,Bon,3,2,"ng-container",0),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Xr,X,ge],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%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}*[_ngcontent-%COMP%]:not(svg *){height:unset;width:unset}[_nghost-%COMP%]{position:fixed;bottom:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;right:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;z-index:2147483607!important}.screen-sharing-container.local-screen-sharing-container[_ngcontent-%COMP%]{width:326px!important;height:216px!important;padding:calc((1.5rem + 0px) * var(--velt-base-rem-unit))!important;background:#fff!important;box-shadow:0 1px 4px #00000029!important;border-radius:20px!important;position:relative!important;overflow:hidden!important}.screen-sharing-container.local-screen-sharing-container[_ngcontent-%COMP%] *[_ngcontent-%COMP%]{color:#fff!important}.screen-sharing-container.local-screen-sharing-container[_ngcontent-%COMP%] .screen-sharing-overlay[_ngcontent-%COMP%]{position:absolute!important;width:100%!important;height:100%!important;top:0!important;background:#fff!important;display:none!important;align-items:center;justify-content:center;color:#fff!important;background:#000000b3!important;left:0!important;font-size:calc((1.5rem + 0px) * var(--velt-base-rem-unit))!important}.screen-sharing-container.local-screen-sharing-container[_ngcontent-%COMP%]:hover .screen-sharing-overlay[_ngcontent-%COMP%]{display:flex!important}.screen-sharing-container.local-screen-sharing-container[_ngcontent-%COMP%] .stop-sharing-btn[_ngcontent-%COMP%]{cursor:pointer!important}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%]{width:30vw!important;height:20vh!important;padding:calc((1.5rem + 0px) * var(--velt-base-rem-unit))!important;background:#fff!important;box-shadow:0 1px 4px #00000029!important;border-radius:20px!important;position:relative!important;overflow:hidden!important;transition:width .2s ease-in-out,height .2s ease-in-out}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%] *[_ngcontent-%COMP%]{color:#fff!important;text-align:center!important}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%] .screen-sharing-overlay[_ngcontent-%COMP%]{position:absolute!important;width:100%!important;height:100%!important;top:0!important;background:#fff!important;display:none!important;align-items:center;justify-content:center;color:#fff!important;background:#000000b3!important;left:0!important;font-size:calc((1.5rem + 0px) * var(--velt-base-rem-unit))!important;flex-direction:column}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%] .screen-sharing-overlay[_ngcontent-%COMP%] .screen-sharing-resize-container[_ngcontent-%COMP%]{margin-top:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;background:#000;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center;justify-content:center}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%] .screen-sharing-overlay[_ngcontent-%COMP%] .screen-sharing-resize-container[_ngcontent-%COMP%] > svg[_ngcontent-%COMP%]{margin:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;cursor:pointer!important;fill:#b1b5c4!important}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%] .screen-sharing-overlay[_ngcontent-%COMP%] .screen-sharing-resize-container[_ngcontent-%COMP%] > svg.selected[_ngcontent-%COMP%]{fill:#fff!important}.screen-sharing-container.remote-screen-sharing-container[_ngcontent-%COMP%]:hover .screen-sharing-overlay[_ngcontent-%COMP%]{display:flex!important}.screen-sharing-container.remote-screen-sharing-container.medium[_ngcontent-%COMP%]{width:60vw!important;height:60vh!important}.screen-sharing-container.remote-screen-sharing-container.large[_ngcontent-%COMP%]{width:calc(100vw - 5rem)!important;height:calc(100vh - 5rem)!important}video[_ngcontent-%COMP%]{width:100%!important;height:100%!important;border-radius:8px!important}"],changeDetection:0});let i=o;return i})();var Tu=(()=>{let o=class o{constructor(e){this.translateService=e}transform(e,...t){try{let a=(new Date().getTime()-new Date(e).getTime())/1e3;if(a<1)return this.translateService.translate("now");let s={y:31536e3,mo:2592e3,w:604800,d:86400,h:3600,m:60,s:1};for(let c in s){let p=Math.floor(a/s[c]);if(p>0)return`${p}${this.translateService.translate(c)}`}return e}catch{return e}}};o.\u0275fac=function(t){return new(t||o)(h(Bl,16))},o.\u0275pipe=Ui({name:"timeAgo",type:o,pure:!0,standalone:!1});let i=o;return i})();var Du=(()=>{let o=class o{constructor(e,t){this.domService=e,this.sanitizer=t}transform(e,t=!0){try{let r=t?this.domService.sanitizeHtml(e):e;return this.sanitizer.bypassSecurityTrustHtml(r)}catch{return e}}};o.\u0275fac=function(t){return new(t||o)(h(Be,16),h(Cl,16))},o.\u0275pipe=Ui({name:"safeHtml",type:o,pure:!0,standalone:!1});let i=o;return i})();function Uon(i,o){if(i&1&&(y(0,"div",21),te(1),P(2,"translate"),P(3,"translate"),b()),i&2){let n=l().$implicit,e=l().ngIf;m(),Se(" ",(n==null||n.from==null?null:n.from.userId)===(e.user==null?null:e.user.userId)?M(2,1,"Me"):M(3,3,(n==null||n.from==null?null:n.from.name)||(n==null||n.from==null?null:n.from.email))," ")}}function jon(i,o){i&1&&w(0,"velt-skeleton-loader-internal",22)}function $on(i,o){if(i&1&&(v(0),y(1,"div",15),w(2,"snippyly-user-avatar",16),y(3,"div",17),u(4,Uon,4,5,"div",18)(5,jon,1,0,"ng-template",null,1,Te),y(7,"div",19),te(8),P(9,"timeAgo"),b(),w(10,"div",20),P(11,"translate"),P(12,"safeHtml"),b()(),C()),i&2){let n=o.$implicit,e=me(6),t=l().ngIf;m(2),d("user",n==null?null:n.from),m(2),d("ngIf",(n==null||n.from==null?null:n.from.userId)===(t.user==null?null:t.user.userId)||(n==null||n.from==null?null:n.from.name)||(n==null||n.from==null?null:n.from.email))("ngIfElse",e),m(4),ze(M(9,5,n==null?null:n.timestamp)),m(2),d("innerHTML",M(12,9,M(11,7,(n==null?null:n.message)||"")),oo)}}function Hon(i,o){if(i&1){let n=K();v(0),y(1,"div",3)(2,"div",4,0)(4,"div",5)(5,"div"),te(6),P(7,"translate"),b(),y(8,"div"),ce(),y(9,"svg",6),W("click",function(){N(n);let t=l();return F(t.toggleMessagesPanel())}),w(10,"path",7),b()()(),ht(),y(11,"div",8),u(12,$on,13,11,"ng-container",9),b(),y(13,"div",10)(14,"textarea",11),P(15,"translate"),kr("ngModelChange",function(t){let r=N(n).ngIf;return Zr(r.message,t)||(r.message=t),F(t)}),W("keydown.enter",function(t){N(n);let r=l();return t.preventDefault(),F(r.sendMessage())}),b(),y(16,"button",12),W("click",function(){N(n);let t=l();return F(t.sendMessage())}),ce(),y(17,"svg",13),w(18,"path",14),b()()()()(),C()}if(i&2){let n=o.ngIf,e=l();m(),pe("visible",n.messagesPanelVisible)("mobile",n.isPhone),m(5),ze(M(7,11,"In-call messages")),m(6),d("ngForOf",n.messages)("ngForTrackBy",e.trackByMessageId),m(2),d("placeholder",rS(M(15,13,"Type here..."))),Mr("ngModel",n.message),m(2),d("disabled",!(n.message!=null&&n.message.trim()))}}var sye=(()=>{let o=class o{constructor(e,t,r,a){this.authService=e,this.huddleService=t,this.loggingService=r,this.breakpointObserver=a,this.subscriptions=[],this.componentConfigSignal=xe({isPhone:!1,user:null,messages:[],message:"",messagesPanelVisible:!1});try{this.loggingService.log("%c[WB] Creating CLASS: HuddleMessagesPanelComponent","color: blue;"),this.subscriptions.push(this.huddleService.getMessages$().subscribe(s=>{s.sort((c,p)=>c?.timestamp-p?.timestamp),this.componentConfigSignal.update(c=>D(E({},c),{messages:s}))})),this.subscriptions.push(this.huddleService.getMessagesPanelVisible$().subscribe(s=>{this.componentConfigSignal.update(c=>D(E({},c),{messagesPanelVisible:s}))})),this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.componentConfigSignal.update(c=>D(E({},c),{user:s}))})),this.subscriptions.push(this.breakpointObserver.observe(Hi.XSmall).subscribe(s=>{s.matches?this.componentConfigSignal.update(c=>D(E({},c),{isPhone:!0})):this.componentConfigSignal.update(c=>D(E({},c),{isPhone:!1}))},s=>{this.loggingService.catch("Error in HuddleMessagesPanelComponent breakpointObserver subscription: ",s)}))}catch(s){this.loggingService.catch("Error in HuddleMessagesPanelComponent constructor: ",s)}}ngOnInit(){}trackByMessageId(e,t){return t.id||e}highlightLinks(e){this.loggingService.log("%c[WB] Calling FUNCTION: highlightLinks","color: green;");try{return e&&(e=e?.replaceAll("&amp;","&")),e.replaceAll(U.REGEX_URL,r=>new RegExp(U.REGEX_EMAIL).test("@"+r)?r:`<a class="message-link" href="${r}" target="_blank">${r}</a>`)}catch(t){return this.loggingService.catch("Error in HuddleMessagesPanelComponent highlightLinks: ",t),""}}sendMessage(){this.loggingService.log("%c[WB] Calling FUNCTION: sendMessage","color: green;");try{let e=this.componentConfigSignal().message?.trim();if(!e)return;e=this.highlightLinks(e),this.huddleService.sendMessage(e),this.componentConfigSignal.update(t=>D(E({},t),{message:""}))}catch(e){this.loggingService.catch("Error in HuddleMessagesPanelComponent sendMessage: ",e)}}toggleMessagesPanel(){try{this.loggingService.log("%c[WB] Calling FUNCTION: toggleMessagesPanel","color: green;"),this.huddleService.toggleMessagesPanel()}catch(e){this.loggingService.catch("Error in HuddleMessagesPanelComponent toggleMessagesPanel: ",e)}}ngOnDestroy(){try{this.loggingService.log("%c[WB] Calling FUNCTION: onDestroy","color: green;"),this.subscriptions.forEach(e=>e.unsubscribe())}catch(e){this.loggingService.catch("Error in HuddleMessagesPanelComponent ngOnDestroy: ",e)}}};o.\u0275fac=function(t){return new(t||o)(h(je),h(wr),h(_),h(wo))},o.\u0275cmp=O({type:o,selectors:[["velt-huddle-messages-panel-internal"]],standalone:!1,decls:1,vars:1,consts:[["sidebarRef",""],["loadingTemplateRef",""],[4,"ngIf"],["part","container","data-velt-element","true","data-velt-comment-disabled","true",1,"s-sidebar-container"],[1,"s-sidebar"],[1,"v-huddle-messages-header"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"v-huddle-message-panel-close-btn",3,"click"],["fill-rule","evenodd","clip-rule","evenodd","d","M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z","fill","#777E91"],[1,"v-huddle-messages-container"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"v-huddle-message-box-container"],["name","message","rows","1",1,"v-huddle-message-box-input",3,"ngModelChange","keydown.enter","placeholder","ngModel"],[1,"v-huddle-message-box-send-btn",3,"click","disabled"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M20.8089 10.1394L4.6724 3.15546C3.9926 2.8612 3.22459 2.99065 2.66814 3.49311C2.1117 3.99565 1.87896 4.76995 2.06084 5.51382L3.49713 11.3888H10.5294C10.853 11.3888 11.1154 11.6625 11.1154 12C11.1154 12.3375 10.853 12.6112 10.5294 12.6112H3.49713L2.06084 18.4862C1.87896 19.2301 2.11166 20.0044 2.66814 20.5069C3.22572 21.0104 3.99381 21.1382 4.67244 20.8445L20.8089 13.8606C21.5436 13.5426 22 12.8297 22 12C22 11.1703 21.5436 10.4574 20.8089 10.1394Z","fill","#777E90"],[1,"v-huddle-message-block"],[3,"user"],[1,"v-huddle-message-block-right"],["class","v-huddle-message-block-user",4,"ngIf","ngIfElse"],[1,"v-huddle-message-block-time"],[1,"v-huddle-message-block-message",3,"innerHTML"],[1,"v-huddle-message-block-user"],["height","20px","width","80px","borderRadius","20px"]],template:function(t,r){t&1&&u(0,Hon,19,15,"ng-container",2),t&2&&d("ngIf",r.componentConfigSignal())},dependencies:[Et,X,ka,xs,ns,Jn,Xo,Tu,Du,ge],styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}:host{--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)}:host[dark]{--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)}.s-sidebar-container{height:100vh;width:calc((22rem + 0px) * var(--velt-base-rem-unit));position:fixed;top:0;right:-100%;padding:calc((1rem + 0px) * var(--velt-base-rem-unit));box-sizing:border-box;z-index:999999997;transition:width .5s ease-in-out,right .5s ease-in-out}.s-sidebar-container.mobile{width:100%!important;height:100%!important;box-sizing:border-box!important;-webkit-backdrop-filter:blur(2px)!important;backdrop-filter:blur(2px)!important}.s-sidebar-container.visible{right:0}.s-sidebar-container .s-sidebar{background:var(--velt-background-0);padding:calc((1rem + 0px) * var(--velt-base-rem-unit));border-radius:var(--velt-border-radius-lg);width:100%;overflow-x:hidden;box-sizing:border-box;position:relative;height:100%;border:1px solid var(--velt-border-5);display:flex;flex-direction:column;justify-content:space-between;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))}.s-sidebar-container .s-sidebar::-webkit-scrollbar{display:none;width:0;height:0}.s-sidebar-container .s-sidebar:not(.s-overflow-hidden){overflow-y:auto}.s-sidebar-container .v-huddle-message-panel-close-btn{cursor:pointer}.s-sidebar-container .v-huddle-messages-header{display:flex;justify-content:space-between}.s-sidebar-container .v-huddle-messages-container{overflow:auto;flex-grow:1}.s-sidebar-container .v-huddle-messages-container::-webkit-scrollbar{display:none;width:0;height:0}.s-sidebar-container .v-huddle-message-block{display:flex;gap:calc((1rem + 0px) * var(--velt-base-rem-unit));margin-bottom:calc((1rem + 0px) * var(--velt-base-rem-unit))}.s-sidebar-container .v-huddle-message-block .v-huddle-message-block-time{font-size:calc((.5rem + 0px) * var(--velt-base-rem-unit));color:gray;margin-bottom:calc((.25rem + 0px) * var(--velt-base-rem-unit))}.s-sidebar-container .v-huddle-message-block .v-huddle-message-block-message{font-size:calc((.75rem + 0px) * var(--velt-base-rem-unit));word-break:break-word;white-space:pre-wrap}.s-sidebar-container .v-huddle-message-box-container{display:flex;gap:calc((1rem + 0px) * var(--velt-base-rem-unit));align-items:center}.s-sidebar-container .v-huddle-message-box-container .v-huddle-message-box-input{padding:calc((.75rem + 0px) * var(--velt-base-rem-unit));border-radius:8px;border:0;outline:0;background:#f7f7f7;flex-grow:1;font-family:var(--velt-default-font-family);resize:none}.s-sidebar-container .v-huddle-message-box-container .v-huddle-message-box-send-btn{background:transparent;border:0;outline:0;border-radius:100%;width:32px;height:32px;display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer;opacity:1}.s-sidebar-container .v-huddle-message-box-container .v-huddle-message-box-send-btn[disabled]{opacity:.5;cursor:not-allowed}