@veltdev/sdk-staging 6.0.6 → 6.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/velt-area.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt.js +2 -2
- /package/{chunk-KIYMQJSM.js → chunk-JZ3DIQVE.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltdev/sdk-staging",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.7",
|
|
4
4
|
"description": "Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.",
|
|
5
5
|
"homepage": "https://velt.dev",
|
|
6
6
|
"keywords": [
|
package/velt-area.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ht,d as gt}from"./chunk-2Q3745J2.js";import{t as Ft}from"./chunk-5CFN76GI.js";import"./chunk-O6NHFZMD.js";import"./chunk-2ZGVZZFS.js";import{a as zt}from"./chunk-ZFEUGJVC.js";import"./chunk-7UFH2MQ5.js";import"./chunk-4FUBGV7B.js";import"./chunk-FR7BEDQT.js";import{b as Bt}from"./chunk-XJT64ZXP.js";import"./chunk-N72BHERH.js";import{a as kt}from"./chunk-LTCLU4T3.js";import{a as fe}from"./chunk-75Z7SIQI.js";import{a as vt}from"./chunk-PB5PWSQS.js";import{I as At,Y as Pt,r as pt,t as ut,v as ft}from"./chunk-6VMBIKMK.js";import{$ as ge,Ab as nt,Ai as Lt,Bb as it,Bf as Oe,C as $e,Ch as M,Db as ot,Dg as Dt,E as j,Eb as rt,Ed as St,Ee as h,Fa as D,Fb as at,Fh as Rt,Fi as ue,Gc as pe,He as Ct,Ib as st,J as he,Jb as U,Kb as ee,Kc as lt,L as ae,Lc as mt,M as je,Ma as Je,Me as _t,Mf as It,Pa as C,Pc as dt,Pi as Nt,T as A,Ta as Ye,Ua as ne,Uf as bt,Uh as te,Va as Ze,Vf as yt,Y as Ie,Yf as Tt,_a as W,a as p,aa as We,ac as Te,b as S,bb as Qe,ca as _,ch as we,db as ie,dh as Me,di as wt,eg as $,fh as Ot,g as le,gg as se,ha as b,ia as y,ii as X,ja as Xe,ji as G,ki as T,l as re,la as Ge,lb as x,li as Mt,mb as O,me as De,nb as L,o as Ue,ob as qe,oe as w,p as me,pc as ct,pe as Et,qa as Ke,qg as xe,qh as xt,r as P,sb as be,sh as Le,si as K,tb as ye,ti as J,ub as et,ug as Re,ui as Ne,v as f,vb as oe,w as de,wb as tt,xb as R,zb as v,zi as H}from"./chunk-KWXZADQY.js";var k=(()=>{let l=class l{constructor(e,t,n,o,s,a,r,c,d,u,I,E,z){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=s,this.authService=a,this.domService=r,this.afAuth=c,this.iamService=d,this.dialog=u,this.loggingService=I,this.userPermissionService=E,this.serviceBook=z,this.areaAnnotationById$=new re({}),this.documentPaths=null,this.areaEnabled$=new re(!0),this.allowedElementIds$=new re([]),this.addAreaMode$=new re(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(Rt).subscribe(g=>this.notificationService=g),this.databaseService.getDb().pipe(j(g=>!!g),he(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in AreaService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&(this.isElementInsideAllowedElements(V)?Re(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=V,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addAreaMode$.value&&this.disableAddAreaMode()},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addAreaMode$.value){if(g.preventDefault(),g.stopPropagation(),!Re(g.target)){let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&this.isElementInsideAllowedElements(V)&&this.addArea(g)}this.disableAddAreaMode()}},g=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",g)}),this.addAreaMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",g)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllAreaAnnotations(e,t,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let o,s;try{if(e&&(s=Oe(e)),t&&typeof t=="object"){let a=Tt(t);o=Oe(JSON.stringify(a))}}catch(a){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",a)}return this.authService.getAuthState$().pipe(j(a=>!!a),A(a=>this.isFeatureAllowed({firebaseUser:a,annotations:[],filteredAnnotations:[]})),A(a=>a.featureAllowed?this.iamService.isUserAllowed$().pipe(f(r=>(a.featureAllowed=r,a))):P(a)),A(a=>a.featureAllowed?this.authService.isPlanExpired$().pipe(f(r=>(a.featureAllowed=!r,a))):P(a)),A(a=>a.featureAllowed?P(a).pipe(A(r=>this.docService.getDocumentPaths$().pipe(f(c=>(this.documentPaths=c,r.documentPaths=c,r)))),A(r=>s?this.getDataFromDocumentIds([s]).pipe(f(c=>(r.annotations=c||[],p({},r)))):this.docService.getDocumentIds$().pipe(A(c=>{let d=c?.length>0?c.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(d).pipe(f(u=>(r.annotations=u||[],p({},r))))}))),A(r=>this.docService.getLocation$().pipe(f(c=>(r.location=c,r)))),A(r=>this.docService.getLocations$().pipe(f(c=>(r.customLocations=c,r)))),f(r=>{if(r.filteredAnnotations=[],s&&!o)return r.filteredAnnotations=r.annotations?.slice(),r;{let c=[],d=[];return o?c.push(o):(c.push(r?.location?.locationId),c.push(...Object.values(r?.customLocations||[]).map(u=>u.locationId)),r?.location?.location?.id&&d.push(r?.location?.location?.id)),r.filteredAnnotations=this.filterAnnotationsByLocationIds(r?.annotations,c,d),r}}),A(r=>n?P(r):r?.annotations?.length?this.domService.onWindowResize$().pipe(f(()=>r)):P(r)),A(r=>n?P(r):r?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(f(()=>r)):P(r)),f(r=>(r.filteredAnnotations=r.filteredAnnotations?.map(c=>{let d=Object.assign({},c);return d.areaProperties=this.calculateAreaAnnotationPosition(d),d}),r)),A(r=>r?.filteredAnnotations?P(r?.filteredAnnotations||[]):P([])),A(r=>{if(this.authService.isFeatureAllowed(w.COMMENT))return P(r);{let c=r?.filter(d=>!d?.targetAnnotations?.filter(u=>u?.type===w.COMMENT)?.length);return P(c)}})):P([])),ae(xt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(j(t=>!!t),f(t=>S(p({},e),{config:t})),A(t=>this.authService.getUser$().pipe(f(n=>S(p({},t),{user:n})))),A(t=>bt(t.config,t.user,w.AREA)?P(S(p({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),P(S(p({},t),{featureAllowed:!1})))),ae((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:n}=e;if(t?.some(r=>!r)||!this.documentPaths)return P([]);let o=this.docService.getDocumentPaths()?.veltFolderId,s=P([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(a.documentId=t?.length?t[0]:void 0,a.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let r=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],c=[];for(let d=0;d<(r?.length??0);d+=h.LISTENER_CONTEXT_BATCH_SIZE)c.push(r?.slice(d,d+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);s=de(c.map(d=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",t),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[],...d?.length?[H("context.accessFields","array-contains-any",d)]:[])]})}).pipe(Ie()))).pipe(f(d=>Le(d)))}else{let r=[];for(let c=0;c<(t?.length??0);c+=h.LISTENER_BATCH_SIZE)r.push(t?.slice(c,c+h.LISTENER_BATCH_SIZE)??[]);s=de(r.map(c=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",c),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[])]})}).pipe(Ie()))).pipe(f(c=>Le(c)))}return s.pipe(f(({data:r,operation:c})=>{let d=[];return r&&(d=Object.values(r??{}).filter(u=>typeof u=="object")),{data:d,operation:c}}),f(({data:r,operation:c})=>{if(!t)return{data:r,documentMap:{},operation:c};let d=r.reduce((u,I)=>{let E=I.metadata?.documentId;return E&&(u[E]||(u[E]=[]),u[E].push(I)),u},{});return{data:r,documentMap:d,operation:c}}),f(({data:r,documentMap:c,operation:d})=>{if(!n)if(d?.type==="removed"){if(d?.ids?.length){let u=this.areaAnnotationById$.value;d?.ids?.forEach(I=>{delete u?.[I]}),this.areaAnnotationById$.next(u)}}else Object.entries(c??{}).forEach(([u,I])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,annotations:I})});return r}))}else return P([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:n,queryHash:o}){try{if(t){e||(e=h.NO_ORGANIZATION_ID),o||(o=h.DEFAULT_QUERY_HASH);let s={};n?.forEach(r=>{r?.annotationId&&(s[r?.annotationId]=r)});let a=p(p({},this.areaAnnotationById$.value),s);this.areaAnnotationById$.next(a)}}catch(s){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",s)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}filterAnnotationsByLocationIds(e,t,n){try{return e.filter(o=>t.includes(o.locationId)||n?.includes(o?.location?.id)||t?.find(s=>s==o?.location?.id)||n?.find(s=>s==o?.locationId+""))}catch(o){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",o),[]}}calculateAreaAnnotationPosition(e,t=!1){try{if(e.targetElements?.length){let n=e.targetElements[0],o=e.targetElements[1];if(n?.xpath&&o?.xpath||n?.anchor&&o?.anchor){let s=null,a=null;if(n?.anchor){let r=this.domService.resolveAnchorRecord(n.anchor);r?.element&&r?.element instanceof HTMLElement&&!$(r.element)&&this.domService.isElementVisible(r.element)&&se(r.element)&&(s=r.element)}else n?.xpath&&(s=this.domService.getElementFromXPath(n.xpath),s&&$(s)&&(s=null),this.domService.isXpathWithId(n.xpath)||(!s&&n.cfXpath&&(s=this.domService.getElementFromXPath(n.cfXpath),s&&$(s)&&(s=null)),!s&&n.fXpath&&(s=this.domService.getElementFromXPath(n.fXpath),s&&$(s)&&(s=null))));if(o?.anchor){let r=this.domService.resolveAnchorRecord(o.anchor);r?.element&&r?.element instanceof HTMLElement&&!$(r.element)&&this.domService.isElementVisible(r.element)&&se(r.element)&&(a=r.element)}else o?.xpath&&(a=this.domService.getElementFromXPath(o.xpath),a&&$(a)&&(a=null),this.domService.isXpathWithId(o.xpath)||(!a&&o.cfXpath&&(a=this.domService.getElementFromXPath(o.cfXpath),a&&$(a)&&(a=null)),!a&&o.fXpath&&(a=this.domService.getElementFromXPath(o.fXpath),a&&$(a)&&(a=null))));if(s&&a){let r=we(s,a);if(r){let c=s,d=a,u=c.getBoundingClientRect(),I=d.getBoundingClientRect(),E=t?u.width:c.offsetWidth||u.width,z=t?u.height:c.offsetHeight||u.height,g=t?I.width:d.offsetWidth||I.width,V=t?I.height:d.offsetHeight||I.height,Ce={};E&&z&&(Ce={top:z*n.topPercentage/100,left:E*n.leftPercentage/100});let _e={};g&&V&&(_e={top:V*o.topPercentage/100,left:g*o.leftPercentage/100});let Ve=!t,N=Me(Ce.left,Ce.top,s,r,Ve),B=Me(_e.left,_e.top,a,r,Ve),Y,Z,Q,q,F={};N.x>B.x?N.y>B.y?(q={x:N.x,y:N.y},Y={x:B.x,y:B.y},F.handle1=q,F.handle2=Y):(Z={x:N.x,y:N.y},Q={x:B.x,y:B.y},F.handle1=Z,F.handle2=Q):N.y>B.y?(Q={x:N.x,y:N.y},Z={x:B.x,y:B.y},F.handle1=Q,F.handle2=Z):(Y={x:N.x,y:N.y},q={x:B.x,y:B.y},F.handle1=Y,F.handle2=q);let jt={topLeft:Y||{x:Q?.x,y:Z?.y},bottomRight:q||{x:Z?.x,y:Q?.y},topRight:Z||{x:q?.x,y:Y?.y},bottomLeft:Q||{x:Y?.x,y:q?.y}};return F.coordinates=jt,F.targetElement=this.domService.getXPath(r),F}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,s,a){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let r=this.authService.getUser();if(r)if(r.isReadOnly||r.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let c=new _t;o&&(c.annotationId=o),c.from=r,c.color=h.DEFAULT_ANNOTATION_COLOR,c.lastUpdated=this.timestamp,n&&(c.targetAnnotations=[n]),c.props=new Ct;let d=this.domService.getCurrentWindowSizeValue();if(c.props.screenWidth=d.screenWidth,c.props.screenHeight=d.screenHeight,c.props.screenScrollHeight=d.screenScrollHeight,c.props.viewportWidth=window.innerWidth,c.props.viewportHeight=window.innerHeight,e||t?.length>0){let E=e?this.getPointsForAreaPinAnnotation(e):t;c.targetElements=[],E.forEach(z=>{c.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(c),s&&(c.locationId=s.locationId,c.location=s.location),c.pageInfo=xe(),c.pageInfo&&(c.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let u=this.getElementForAreaAnnotation(c),I=this.docService.getBaseMetadata("area",{element:u});if(c?.metadata||(c.metadata={}),c.metadata=p(p({},c.metadata),I),a?.access&&a?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:r.userId,accessFields:a.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}a.accessFields.some(E=>It(E))||(c.context={access:a.access,accessFields:a.accessFields})}return this.saveAreaToDb(c),c}return}catch(r){this.loggingService.catch("Error in AreaService addArea: ",r);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);s?.element&&this.domService.isElementVisible(s.element)&&se(s.element)&&(n=s.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let s=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);s?.element&&this.domService.isElementVisible(s.element)&&se(s.element)&&(o=s.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=we(n,o)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(w.AREA)&&de([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe(j(([t,n])=>!!t&&!!n),he(1),A(([t,n])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let o=JSON.parse(JSON.stringify(e));if(o.position=null,!o?.metadata?.documentId){o?.metadata||(o.metadata={});let r=this.docService.getBaseMetadata("area");o.metadata=p(p({},o?.metadata),r)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(M.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:s,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:s,organizationId:a},data:JSON.parse(JSON.stringify(o))})}else return P(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,n){try{n&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,De.UPDATED),this.updateAreaToDb(e)}catch(o){this.loggingService.catch("Error in AreaService updateArea: ",o)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(w.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let s=this.docService.getBaseMetadata("area");t.metadata=p(p({},t?.metadata),s)}let{documentId:n,organizationId:o}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:n,organizationId:o},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),o=[];Object.keys(t??{}).forEach(s=>le(this,null,function*(){let a=t[s];a.type==="area"&&n&&a.from&&(n?.isAdmin||a.from.userId===n.userId)&&o.push(a)})),o?.length&&(this.analyticsService.trackEvent(M.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(s=>s.annotationId).join()}),this.dialog.open(Bt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(he(1)).subscribe(s=>{s&&(o.forEach(a=>le(this,null,function*(){yield this.deleteAreaPinAnnotation(a)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(r=>{this.domService.removeHighlightFromElement(r)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let n={};return Object.values(this.areaAnnotationById$.value??{}).forEach(o=>{o?.metadata?.documentId==t&&o?.metadata?.organizationId==e&&(n[o?.annotationId]=o)}),Object.values(n??{})}catch(n){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",n),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let o=Object.values(this.areaAnnotationById$.value||{}),s;t?s=o.find(a=>a?.annotationId===t):s=o.find(a=>a?.targetAnnotations?.find(r=>r?.annotationId===e)),s&&(s.targetAnnotations=s.targetAnnotations?.filter(a=>a?.annotationId!==e),s.targetAnnotations?.length?this.updateAreaToDb(s):this.deleteAreaPinAnnotation(s))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(w.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,De.DELETED),this.analyticsService.trackEvent(M.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:n}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:n}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),P(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(w.AREA)?(this.analyticsService.trackEvent(M.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(M.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],n=e,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,s=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:s}),t.push({x:o+100,y:s+100}),t}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let n={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",n)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=xe(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t;try{t=new URL(e?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in AreaService generateAreaUrl: ",n),t=new URL(window.location.href)}return t.searchParams.delete(h.URL_PARAMS.TAG_ID),t.searchParams.append(h.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return le(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield Dt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(_(G),_(Mt),_(ue),_(Lt),_(Nt),_(J),_(K),_(St),_(fe),_(Pt),_(T),_(zt),_(X))},l.\u0275prov=ge({token:l,factory:l.\u0275fac,providedIn:"root"});let m=l;return m})();var Vt=()=>({bottom:"calc(100% - 8px)",color:"green"});function Kt(m,l){if(m&1){let i=oe();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),L()()}if(m&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",Te(9,Vt))("annotationDragging",i.isResizing)("annotation",i.commentPinAnnotation)("commentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length===1)("multipleCommentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function Jt(m,l){if(m&1){let i=oe();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),L()()}if(m&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",Te(9,Vt))("annotationDragging",i.isResizing)("annotation",i.multiThreadCommentAnnotation)("commentPinSelected",!!i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId])("multipleCommentPinSelected",i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function Yt(m,l){if(m&1){let i=oe();be(0),O(1,"div",1),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),L(),O(2,"div",2),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),L(),O(3,"div",3),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),L(),O(4,"div",4),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),L(),O(5,"div",5),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("topLeft"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),L(),O(6,"div",6),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),W(7,Kt,2,10,"div",7)(8,Jt,2,10,"div",7),L(),ye()}if(m&2){let i=v().ngIf,e=v();D(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),ee("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),x("ngIf",i.commentPinAnnotation),D(),x("ngIf",i.multiThreadCommentAnnotation)}}function Zt(m,l){if(m&1&&(be(0),W(1,Yt,9,68,"ng-container",0),ye()),m&2){let i=l.ngIf,e=v();D(),x("ngIf",!i.hideAreaAnnotation||e.selected)}}var He=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,s,a,r){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=s,this.areaService=a,this.loggingService=r,this.multipleAreaPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.annotationDragging=!1,this.dragPosition=null,this.LINE_THICKNESS=0,this.DRAG_HANDLE_SIZE=10,this.skipValueUpdate=!1,this.areaPinHover=!1,this.resolvedCommentsOnDom=!1,this.componentConfigSignal=Ke({hideAreaAnnotation:!1,selected:!1,areaAnnotationColor:"#625DF5",areaProperties:void 0,resizingOffset:{top:0,left:0},offsetLeft:0,offsetTop:0,isResizing:!1,areaPinAnnotation:void 0,user:void 0,commentPinAnnotation:void 0,selectedAnnotationsMap:{},pinDragEnabled:!0}),this.selected=!1,this.veltElement=!0,this.commentService=null,this.serviceBook.observe(te).subscribe(c=>{this.commentService=c}),this.subscriptions.push(this.authService.getUser$().subscribe(c=>{this.user=c},c=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",c)})),this.subscriptions.push(this.serviceBook.observe(te).pipe(A(c=>c?c.getPinDrag$():me)).subscribe(c=>{this.componentConfigSignal.update(d=>S(p({},d),{pinDragEnabled:c}))},c=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",c)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(c=>{this.componentConfigSignal.update(d=>(d=S(p({},d),{selectedAnnotationsMap:c}),d)),this.componentConfigSignal().areaPinAnnotation?.annotationId&&this.componentConfigSignal().selectedAnnotationsMap&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().areaPinAnnotation.annotationId],this.componentConfigSignal().commentPinAnnotation?this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation?.annotationId]:this.componentConfigSignal().multiThreadCommentAnnotation&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().multiThreadCommentAnnotation?.annotationId])),this.updateAreaActiveAttributeOnElement()},c=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",c)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(A(n=>n?n.getCommentAnnotationByAnnotationId(e):me),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{commentPinAnnotation:n}),o.commentPinAnnotation?(o.areaAnnotationColor=o.commentPinAnnotation?.status.color,!this.resolvedCommentsOnDom&&!(this.commentService?.getFilterCommentsOnDom()&&this.commentService?.getCommentsFromSidebarMap())&&o.commentPinAnnotation?.status.type==="terminal"?o.hideAreaAnnotation=!0:o.hideAreaAnnotation=!1):o.hideAreaAnnotation=!0,o))}))):t?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(te).pipe(A(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):me),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=S(p({},n),{areaAnnotationColor:this.componentConfigSignal().areaPinAnnotation?.from?.color||"#625DF5"}),n)),this.componentConfigSignal().areaPinAnnotation?.targetElements?.length&&this.componentConfigSignal().areaPinAnnotation?.targetElements?.forEach(n=>{if(n?.xpath){let o=this.domService.getElementFromXPath(n?.xpath);!o&&n?.cfXpath&&(o=this.domService.getElementFromXPath(n?.cfXpath)),!o&&n?.fXpath&&(o=this.domService.getElementFromXPath(n?.fXpath)),o&&this.detectPositionChange(o)}})}catch(e){this.catchError("Error in AreaPinPortalComponent ngAfterViewInit: ",e)}}setAreaPinAnnotation(e){try{this.componentConfigSignal.update(t=>(!this.skipValueUpdate&&!t.isResizing&&(t=S(p({},t),{areaPinAnnotation:e}),this.id=e.annotationId,t.isResizing||(t.areaProperties=e.areaProperties)),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinAnnotation: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=S(p({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=S(p({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(){try{let e=!0;this.componentConfigSignal().commentPinAnnotation&&(e=!(this.domService.getDraftCommentAnnotationDialogs()||[])?.length,this.domService.resetSelectedAnnotationsMap(!0,"comments")),e&&(this.domService.toggleAnnotationSelection(this.componentConfigSignal().areaPinAnnotation),this.componentConfigSignal().commentPinAnnotation?this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation):this.componentConfigSignal().multiThreadCommentAnnotation&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().multiThreadCommentAnnotation))}catch(e){this.catchError("Error in AreaPinPortalComponent togglePinSelection: ",e)}}saveComment(e){try{this.componentConfigSignal().commentPinAnnotation?this.commentService?.saveComment(this.componentConfigSignal().commentPinAnnotation,e):this.componentConfigSignal().multiThreadCommentAnnotation&&this.commentService?.saveComment(this.componentConfigSignal().multiThreadCommentAnnotation,e)}catch(t){this.catchError("Error in AreaPinPortalComponent saveComment: ",t)}}veltEmit(e){return typeof CustomEvent<"u"&&e instanceof CustomEvent?e.detail:e}calculateResizingOffset(e){try{if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=t.left+window.scrollX;return{top:t.top+window.scrollY,left:n}}catch(t){return this.catchError("Error in AreaPinPortalComponent calculateResizingOffset: ",t),{top:0,left:0}}}onResizeHandleDragStart(e){try{document.body.classList.add(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.componentConfigSignal.update(r=>(r=S(p({},r),{isResizing:!0}),r));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),s=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),a=this.areaService.calculateAreaAnnotationPosition(s,!0);this.componentConfigSignal.update(r=>(r=p(S(p({},r),{resizingOffset:o}),a?{areaProperties:a}:{}),r))}catch(t){this.catchError("Error in AreaPinPortalComponent onResizeHandleDragStart: ",t)}}onResizeHandleDragMove(e,t){try{let n=this.domService.getTargetElementForCursorPosition(e.event);if(this.componentConfigSignal().commentPinAnnotation){let o=this.domService.getElementFromXPath(n?.xpath);if(o&&!this.commentService?.isElementInsideAllowedElements(o))return}if(n){let o=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),s=o.targetElements||[];switch(t){case"topLeft":s[0]=n;break;case"bottomRight":s[1]=n;break;default:break}o.targetElements=s;let a=this.areaService.calculateAreaAnnotationPosition(o,!0),r=this.componentConfigSignal().areaProperties?.targetElement,c=a?.targetElement,d=r!==c,u,I;if(d&&a?.targetElement){let E=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(E);u=z.top,I=z.left}else{let E=this.componentConfigSignal().resizingOffset;u=E.top,I=E.left}this.componentConfigSignal.update(E=>(E=S(p({},E),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),E))}}catch(n){this.catchError("Error in AreaPinComponent onResizeHandleDragMove: ",n)}}onResizeHandleDragEnd(e){try{document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&this.parentElement&&(this.parentElement.appendChild(t),t.style.opacity="0");let n=this.componentConfigSignal().areaPinAnnotationOnResize||this.componentConfigSignal().areaPinAnnotation;if(n){let a=this.areaService.calculateAreaAnnotationPosition(n,!1);a&&this.componentConfigSignal.update(r=>(r=S(p({},r),{areaProperties:a}),r))}this.componentConfigSignal.update(a=>(a=S(p({},a),{isResizing:!1}),a)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),s=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==s?(this.componentConfigSignal.update(a=>(a=p({},a),a.areaPinAnnotationOnResize&&(a.areaPinAnnotation=JSON.parse(JSON.stringify(a.areaPinAnnotationOnResize))),delete a.areaPinAnnotationOnResize,a)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(M.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(a=>(a=p({},a),a.areaProperties=a.areaPinAnnotation.areaProperties,a)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=$e(0,Ue).pipe(f(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),ae((n,o)=>n.top===o.top&&n.left===o.left),je());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=S(p({},n),{areaProperties:this.areaService.calculateAreaAnnotationPosition(n.areaPinAnnotation)}),n))},n=>{}))}catch(t){this.catchError("Error in AreaPinPortalComponent detectPositionChange: ",t)}}setAreaPinHover(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaPinHover","color: green;"),e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.areaPinHover=e,this.updateAreaActiveAttributeOnElement()}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinHover: ",t)}}updateAreaActiveAttributeOnElement(){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaActiveAttributeOnElement","color: green;"),this.selected||this.areaPinHover?this.targetElement&&(this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)||this.targetElement?.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE,"true")):this.targetElement&&this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)&&this.targetElement?.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)}catch(e){this.catchError("Error in AreaPinPortalComponent updateAreaActiveAttributeOnElement: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.componentConfigSignal()?.isResizing&&document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING)}catch(e){this.catchError("Error in AreaPinPortalComponent 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 AreaPinPortalComponent unsubscribe: ",e)}}catchError(e,t,n){try{this.loggingService.catch(e,t,S(p({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(J),C(X),C(ue),C(K),C(k),C(T))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&R("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(tt("id",n.id),ie("data-velt-element",n.veltElement),ee("selected",n.selected)("resizing",n.resizing))},inputs:{multipleAreaPinsSelected:"multipleAreaPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],["id","line1",1,"line","vertical",3,"click"],["id","line2",1,"line","horizontal",3,"click"],["id","line3",1,"line","vertical",3,"click"],["id","line4",1,"line","horizontal",3,"click"],["id","handle1","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],["id","handle2","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],[3,"id","click",4,"ngIf"],[3,"click","id"],[3,"saveComment","ngStyle","annotationDragging","annotation","commentPinSelected","multipleCommentPinSelected","user"]],template:function(t,n){t&1&&W(0,Zt,2,1,"ng-container",0),t&2&&x("ngIf",n.componentConfigSignal())},dependencies:[pe,lt,ht],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}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events: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}.line[_ngcontent-%COMP%]{position:absolute;opacity:.4;transition:opacity .2s ease-in-out}.line.vertical[_ngcontent-%COMP%]{border-left:1px dashed;border-right:1px dashed}.line.horizontal[_ngcontent-%COMP%]{border-top:1px dashed;border-bottom:1px dashed}.handle[_ngcontent-%COMP%]{position:absolute;transform:none!important;border-radius:100%}.handle[_ngcontent-%COMP%]:not(.drag-disabled){cursor:grab}#handle1[_ngcontent-%COMP%]{opacity:.4;transition:opacity,transform .2s ease-in-out}#handle2[_ngcontent-%COMP%]{background-color:transparent!important}.resizing[_nghost-%COMP%] div[_ngcontent-%COMP%]{z-index:1}.resizing[_nghost-%COMP%] .handle[_ngcontent-%COMP%]{cursor:grabbing}[_nghost-%COMP%]:hover #handle1[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] #handle1[_ngcontent-%COMP%], .selected[_nghost-%COMP%] #handle1[_ngcontent-%COMP%]{opacity:1;transform:scale(2)!important}[_nghost-%COMP%]:hover .line[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] .line[_ngcontent-%COMP%], .selected[_nghost-%COMP%] .line[_ngcontent-%COMP%]{opacity:1}snippyly-comment-pin[_ngcontent-%COMP%], velt-comment-pin-embed[_ngcontent-%COMP%], snippyly-comment-pin-embed[_ngcontent-%COMP%]{position:absolute;bottom:calc(100% - 8px)}.s-metadata[_ngcontent-%COMP%]{position:fixed;bottom:10px;right:10px;background:#fff;font-size:14px;border:1px solid;padding:10px;box-shadow:1px 1px 1px 1px;border-radius:4px}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{border-collapse:collapse}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid;padding:4px 8px}"],changeDetection:0});let m=l;return m})();var Ut=(()=>{let l=class l{constructor(e,t,n,o,s){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=s,this.areasPinById={}}setAreaPin(e){try{if(!this.areasPinById[e.annotationId])this.setPinPortal(e);else{let t=this.areasPinById[e.annotationId].portalRef?.instance?.componentConfigSignal().isResizing;if(e.areaProperties?.targetElement===this.areasPinById[e.annotationId]?.annotation?.areaProperties?.targetElement||t){let n=this.areasPinById[e.annotationId].portalRef,o=this.areasPinById[e.annotationId].userTargetElement,s=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(s))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let a=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;a&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),a.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}else{let n=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;n&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),n.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setAreaPin: ",t)}}setPinPortal(e){try{if(e?.areaProperties?.targetElement){let t=this.domService.getElementFromXPath(e?.areaProperties?.targetElement);if(t){let n=this.domService.getHostElement(t),o=new pt(He),s=new ut(n,this.appRef,this.injector),a=s.attach(o);a.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),a.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:s,pinPortal:o,portalRef:a,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:t,pinHostElement:n},this.setAreaPinHostAttributes(e.annotationId,n),this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setPinPortal: ",t)}}setAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(",");o.includes(e)||(o.push(e),t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")))}else t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,e);this.domService.isElementOriginallyStatic(t)&&(Ot(t)||t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC,"true"))}catch(n){this.loggingService.catch("Error in AreaPinPortalService setAreaPinHostAttributes: ",n)}}removeAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(","),s=o.indexOf(e);s>-1&&(o.splice(s,1),o.length>0?t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")):t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST))}t?.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST)||t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC)}catch(n){this.loggingService.catch("Error in AreaPinPortalService removeAreaPinHostAttributes: ",n)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:n,pinHostElement:o}=this.areasPinById[e.annotationId],s=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(s.offsetLeft),t.instance.setOffsetTop(s.offsetTop)}catch(t){this.loggingService.catch("Error in AreaPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(n=>n.annotationId);Object.keys(this.areasPinById).forEach(n=>{if(!t.includes(n)){let o=this.areasPinById[n];o.pinHostDomPortalOutlet.detach(),this.removeAreaPinHostAttributes(n,o.pinHostElement),this.domService.removeHighlightFromElement(o.pinHostElement),delete this.areasPinById[n]}})}catch(t){this.loggingService.catch("Error in AreaPinPortalService checkPinsToRemove: ",t)}}};l.\u0275fac=function(t){return new(t||l)(_(K),_(Je),_(Ge),_(Qe),_(T))},l.\u0275prov=ge({token:l,factory:l.\u0275fac,providedIn:"root"});let m=l;return m})();var ve=(()=>{let l=class l{constructor(e,t,n,o,s,a,r){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=s,this.serviceBook=a,this.loggingService=r,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=yt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(te).subscribe(c=>{this.commentService=c})}catch(c){this.loggingService.catch("Error in AreasContainerComponent constructor: ",c)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(h.TAGS.SNIPPYLY_AREAS),t=document.querySelector(h.TAGS.VELT_AREAS);t?this.veltId===t?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===e?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(e){this.loggingService.catch("Error in AreasContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(j(e=>!!e)).subscribe(e=>{e&&this.setAreaInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.getAllAreasOnCurrentDocument()}catch(e){this.loggingService.catch("Error in AreasContainerComponent initComponent: ",e)}}getAllAreasOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreasOnCurrentDocument","color: green;");try{this.subscriptions.push(this.areaService.getAllAreaAnnotations().pipe(j(e=>!!e),A(e=>this.domService.getSelectedAnnotationsMap$().pipe(f(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),A(e=>(this.commentService?.getCommentsOnDom$()??P(!0)).pipe(f(t=>(this.commentsOnDom=t,{annotations:e.annotations,selectedAnnotationsMap:e.selectedAnnotationsMap,commentsOnDom:t||{}}))))).subscribe(e=>{try{this.loggingService.log(e),this.areaPinAnnotations=e?.annotations,this.commentsOnDom||(this.areaPinAnnotations=this.areaPinAnnotations?.filter(n=>!n?.targetAnnotations?.filter(o=>o?.type===w.COMMENT)?.length));let t=this.areaPinAnnotations.filter(n=>n?.areaProperties?.targetElement);this.areaPinPortalService.checkPinsToRemove(t),t.forEach(n=>{this.areaPinPortalService.setAreaPin(n)})}catch(t){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasContainerComponent 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 AreasContainerComponent unsubscribe: ",e)}}setAreaInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Et.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(J),C(K),C(k),C(Ut),C(X),C(T))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ie("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},standalone:!1,decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0});let m=l;return m})();var qt=["customBtnRef"],en=["*"];function tn(m,l){if(m&1&&(O(0,"div",6),Xe(),O(1,"svg",7),qe(2,"path",8),L()()),m&2){let i=v();D(),ee("active",i.addAreaMode)}}function nn(m,l){m&1&&et(0)}function on(m,l){m&1&&it(0)}var Se=(()=>{let l=class l{constructor(e,t,n,o,s){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=s,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.user=a},a=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",a)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0),this.subscriptions.push(this.areaService.addAreaModeChange().subscribe(e=>{this.addAreaMode=e}))}catch(e){this.loggingService.catch("Error in AreasToolComponent AfterViewInit: ",e)}}addArea(){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{this.analyticsService.trackEvent(M.Events.Area.AREA_TOOL_CLICKED,{toolType:this.customBtnRef?.nativeElement?.children?.length?"custom":"default"}),this.user&&(this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add areas."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.areaService.enableAddAreaMode():this.loggingService.catch("User does not have permission to add areas."))}catch(e){this.loggingService.catch("Error in AreasToolComponent addArea: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasToolComponent 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 AreasToolComponent unsubscribe: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(J),C(k),C(fe),C(T))},l.\u0275cmp=ne({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&ot(qt,5),t&2){let o;rt(o=at())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ie("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:en,decls:7,vars:4,consts:[["customBtnRef",""],["content",""],[1,"snippyly-area-btn-container",3,"click"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[4,"ngTemplateOutlet"],[1,"action-btn"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["fill-rule","evenodd","clip-rule","evenodd","d","M22.6315 18.0207C23.3673 17.9913 23.9399 17.371 23.9105 16.6352L23.6567 10.2894C23.6289 9.59486 23.0723 9.03819 22.3778 9.01041L16.0319 8.75654C15.2961 8.7271 14.6758 9.29972 14.6463 10.0355C14.6169 10.7713 15.1895 11.3916 15.9253 11.4211L19.2283 11.5532L10.0679 20.7136C9.54724 21.2343 9.54724 22.0785 10.0679 22.5992C10.5886 23.1199 11.4329 23.1199 11.9536 22.5992L21.1139 13.4389L21.246 16.7418C21.2754 17.4775 21.8957 18.0502 22.6315 18.0207Z","fill","#8F95B2"]],template:function(t,n){if(t&1){let o=oe();nt(),O(0,"div",2),R("click",function(a){return b(o),n.addArea(),y(a.stopPropagation())}),W(1,tn,3,2,"div",3),O(2,"div",4,0),W(4,nn,1,0,"ng-container",5),L()(),W(5,on,1,0,"ng-template",null,1,ct)}if(t&2){let o=st(6);ee("active",n.addAreaMode),D(),x("ngIf",n.showDefaultBtn),D(3),x("ngTemplateOutlet",o)}},dependencies:[pe,mt],encapsulation:2,changeDetection:0});let m=l;return m})();var Pe=class extends kt{constructor(l){super(l),this.getService(T).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(M.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(k).enableArea()}catch(l){this.getService(T).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(M.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(k).disableArea()}catch(l){this.getService(T).catch("Error in _disableAreaComment: ",l)}}};var $t=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=Ze({type:l}),l.\u0275inj=We({imports:[dt,At,ft,gt,Ft]});let m=l;return m})();function rn(m){m.get(T).log("%c[WB] Loading area feature chunk","color: blue;"),m.get(X).set(wt,m.get(k));let t=Ye($t,m).injector;return Ee(t,h.TAGS.VELT_AREA_TOOL,Se),Ee(t,h.TAGS.SNIPPYLY_AREA_TOOL,Se),Ee(t,h.TAGS.VELT_AREAS,ve),Ee(t,h.TAGS.SNIPPYLY_AREAS,ve),new Pe(m)}function Ee(m,l,i){if(customElements.get(l))return;let e=vt(i,{injector:m});customElements.define(l,e)}export{rn as default};
|
|
1
|
+
import{c as ht,d as gt}from"./chunk-2Q3745J2.js";import{t as Ft}from"./chunk-5CFN76GI.js";import"./chunk-O6NHFZMD.js";import"./chunk-2ZGVZZFS.js";import{a as Ht}from"./chunk-ZFEUGJVC.js";import"./chunk-7UFH2MQ5.js";import"./chunk-4FUBGV7B.js";import"./chunk-FR7BEDQT.js";import{b as kt}from"./chunk-XJT64ZXP.js";import"./chunk-N72BHERH.js";import{a as zt}from"./chunk-LTCLU4T3.js";import{a as Ae}from"./chunk-75Z7SIQI.js";import{a as vt}from"./chunk-PB5PWSQS.js";import{I as At,Y as Pt,r as pt,t as ut,v as ft}from"./chunk-6VMBIKMK.js";import{$ as he,Ab as nt,Ai as Nt,Bb as it,Bf as xe,C as $e,Ch as L,Db as ot,Dg as Dt,E as $,Eb as rt,Ed as St,Ee as h,Fa as D,Fb as at,Fh as wt,Fi as fe,Gc as ge,He as Ct,Ib as st,J as me,Jb as U,Kb as q,Kc as lt,L as re,Lc as dt,M as je,Ma as Je,Me as _t,Mf as It,Pa as C,Pc as mt,Pi as Bt,T as A,Ta as Ye,Ua as te,Uf as bt,Uh as ee,Va as Ze,Vf as yt,Y as be,Yf as Tt,_a as j,a as p,aa as We,ac as De,b as S,bb as Qe,ca as _,ch as ue,db as ne,dh as Le,di as Lt,eg as ae,fh as Ot,g as ce,gg as pe,ha as b,ia as y,ii as W,ja as Ge,ji as G,ki as T,l as oe,la as Xe,lb as x,li as Mt,mb as O,me as Oe,nb as M,o as Ue,ob as qe,oe as w,oh as xt,p as le,pc as ct,pe as Et,qa as Ke,qg as Re,qh as Rt,r as P,sb as ye,sh as Me,si as X,tb as Te,ti as K,ub as et,ug as we,ui as Ne,v as f,vb as ie,w as de,wb as tt,xb as R,zb as v,zi as H}from"./chunk-KWXZADQY.js";var F=(()=>{let l=class l{constructor(e,t,n,o,c,a,r,s,m,u,I,E,z){this.analyticsService=e,this.configService=t,this.docService=n,this.databaseService=o,this.commonDbService=c,this.authService=a,this.domService=r,this.afAuth=s,this.iamService=m,this.dialog=u,this.loggingService=I,this.userPermissionService=E,this.serviceBook=z,this.areaAnnotationById$=new oe({}),this.documentPaths=null,this.areaEnabled$=new oe(!0),this.allowedElementIds$=new oe([]),this.addAreaMode$=new oe(!1),this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: AreaService","color: blue;"),this.serviceBook.observe(wt).subscribe(g=>this.notificationService=g),this.databaseService.getDb().pipe($(g=>!!g),me(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in AreaService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addAreaMode$.value){this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement);let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&(this.isElementInsideAllowedElements(V)?we(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement=V,this.domService.highlightElement(this.highlightElement,h.CURSOR.AREA_PIN)):this.domService.removeClassFromElement(document.body,"show-pin-cursor"))}},g=>{this.loggingService.catch("Error in AreaService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addAreaMode$.value&&this.disableAddAreaMode()},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addAreaMode$.value){if(g.preventDefault(),g.stopPropagation(),!we(g.target)){let V=this.domService.getBackgroundElement(g.clientX,g.clientY);V&&this.isElementInsideAllowedElements(V)&&this.addArea(g)}this.disableAddAreaMode()}},g=>{this.loggingService.catch("Error in AreaService onDocumentClick$ subscription: ",g)}),this.addAreaMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-area-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-area-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in AreaService addAreaMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteAreaPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in AreaService onWindowKeyupDelete$ subscription: ",g)})}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in AreaService","color: green;");try{this.areaAnnotationById$.next({}),this.areaEnabled$.next(!0),this.allowedElementIds$.next([]),this.addAreaMode$.next(!1),this.highlightElement=null}catch(e){this.loggingService.catch("Error in AreaService clearCache: ",e)}}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(e){this.allowedElementIds$.next(e||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllAreaAnnotations(e,t,n){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreaAnnotations","color: green;");let o,c;try{if(e&&(c=xe(e)),t&&typeof t=="object"){let a=Tt(t);o=xe(JSON.stringify(a))}}catch(a){this.loggingService.catch("Error in AreaService getAllAreaAnnotations: ",a)}return this.authService.getAuthState$().pipe($(a=>!!a),A(a=>this.isFeatureAllowed({firebaseUser:a,annotations:[],filteredAnnotations:[]})),A(a=>a.featureAllowed?this.iamService.isUserAllowed$().pipe(f(r=>(a.featureAllowed=r,a))):P(a)),A(a=>a.featureAllowed?this.authService.isPlanExpired$().pipe(f(r=>(a.featureAllowed=!r,a))):P(a)),A(a=>a.featureAllowed?P(a).pipe(A(r=>this.docService.getDocumentPaths$().pipe(f(s=>(this.documentPaths=s,r.documentPaths=s,r)))),A(r=>c?this.getDataFromDocumentIds([c]).pipe(f(s=>(r.annotations=s||[],p({},r)))):this.docService.getDocumentIds$().pipe(A(s=>{let m=s?.length>0?s.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(m).pipe(f(u=>(r.annotations=u||[],p({},r))))}))),A(r=>this.docService.getLocation$().pipe(f(s=>(r.location=s,r)))),A(r=>this.docService.getLocations$().pipe(f(s=>(r.customLocations=s,r)))),A(r=>this.docService.getExcludedLocationIds$().pipe(f(s=>(r.excludedLocationIds=s,r)))),f(r=>{if(r.filteredAnnotations=[],c&&!o)return r.filteredAnnotations=r.annotations?.slice(),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r;{let s=[],m=[];return o?s.push(o):(s.push(r?.location?.locationId),s.push(...Object.values(r?.customLocations||[]).map(u=>u.locationId)),r?.location?.location?.id&&m.push(r?.location?.location?.id),m.push(...Object.values(r?.customLocations||{}).map(u=>u.location?.id).filter(u=>!!u))),r.filteredAnnotations=this.filterAnnotationsByLocationIds(r?.annotations,s,m),r.filteredAnnotations=this.applyExcludedLocationIds(r.filteredAnnotations,r.excludedLocationIds),r}}),A(r=>n?P(r):r?.annotations?.length?this.domService.onWindowResize$().pipe(f(()=>r)):P(r)),A(r=>n?P(r):r?.annotations?.length?this.domService.onDomChange$("AreaService getAllAreaAnnotations").pipe(f(()=>r)):P(r)),f(r=>(r.filteredAnnotations=r.filteredAnnotations?.map(s=>{let m=Object.assign({},s);return this.shouldSkipAreaPositionCalculation(m)?m.areaProperties=void 0:m.areaProperties=this.calculateAreaAnnotationPosition(m),m}),r)),A(r=>r?.filteredAnnotations?P(r?.filteredAnnotations||[]):P([])),A(r=>{if(this.authService.isFeatureAllowed(w.COMMENT))return P(r);{let s=r?.filter(m=>!m?.targetAnnotations?.filter(u=>u?.type===w.COMMENT)?.length);return P(s)}})):P([])),re(Rt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe($(t=>!!t),f(t=>S(p({},e),{config:t})),A(t=>this.authService.getUser$().pipe(f(n=>S(p({},t),{user:n})))),A(t=>bt(t.config,t.user,w.AREA)?P(S(p({},t),{featureAllowed:!0})):(this.loggingService.warn("Area feature is not allowed."),P(S(p({},t),{featureAllowed:!1})))),re((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getDataFromDocuments(e){if(this.configService.getApiKey()){let{documentIds:t,filters:n}=e;if(t?.some(r=>!r)||!this.documentPaths)return P([]);let o=this.docService.getDocumentPaths()?.veltFolderId,c=P([]),a={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(a.documentId=t?.length?t[0]:void 0,a.organizationId=this.documentPaths?.organizationId),this.userPermissionService?.getIsContextEnabled()){let r=[h.DEFAULT_VELT_CONTEXT,...this.docService.getProcessedDocContext()],s=[];for(let m=0;m<(r?.length??0);m+=h.LISTENER_CONTEXT_BATCH_SIZE)s.push(r?.slice(m,m+h.LISTENER_CONTEXT_BATCH_SIZE)??[]);c=de(s.map(m=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",t),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[],...m?.length?[H("context.accessFields","array-contains-any",m)]:[])]})}).pipe(be()))).pipe(f(m=>Me(m)))}else{let r=[];for(let s=0;s<(t?.length??0);s+=h.LISTENER_BATCH_SIZE)r.push(t?.slice(s,s+h.LISTENER_BATCH_SIZE)??[]);c=de(r.map(s=>this.commonDbService.dbListener({feature:"allAreas",properties:S(p({},a),{firestoreQuery:[Ne(H("metadata.apiKey","==",this.configService?.getApiKey()),H("metadata.documentId","in",s),H("metadata.organizationId","==",this.documentPaths?.organizationId),...o?[H("metadata.veltFolderId","==",o)]:[])]})}).pipe(be()))).pipe(f(s=>Me(s)))}return c.pipe(f(({data:r,operation:s})=>{let m=[];return r&&(m=Object.values(r??{}).filter(u=>typeof u=="object")),{data:m,operation:s}}),f(({data:r,operation:s})=>{if(!t)return{data:r,documentMap:{},operation:s};let m=r.reduce((u,I)=>{let E=I.metadata?.documentId;return E&&(u[E]||(u[E]=[]),u[E].push(I)),u},{});return{data:r,documentMap:m,operation:s}}),f(({data:r,documentMap:s,operation:m})=>{if(!n)if(m?.type==="removed"){if(m?.ids?.length){let u=this.areaAnnotationById$.value;m?.ids?.forEach(I=>{delete u?.[I]}),this.areaAnnotationById$.next(u)}}else Object.entries(s??{}).forEach(([u,I])=>{this.setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,annotations:I})});return r}))}else return P([])}setAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,annotations:n,queryHash:o}){try{if(t){e||(e=h.NO_ORGANIZATION_ID),o||(o=h.DEFAULT_QUERY_HASH);let c={};n?.forEach(r=>{r?.annotationId&&(c[r?.annotationId]=r)});let a=p(p({},this.areaAnnotationById$.value),c);this.areaAnnotationById$.next(a)}}catch(c){this.loggingService.catch("Error in AreaService setAreaAnnotationsByOrganizationIdAndDocumentId:",c)}}getAnnotationById(e){try{return this.areaAnnotationById$.value?.[e]?this.areaAnnotationById$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in AreaService getAnnotationById: ",t);return}}applyExcludedLocationIds(e,t){return t?.length?e?.filter(n=>n?.location?.id?!t.includes(n.location.id):!0):e}filterAnnotationsByLocationIds(e,t,n){try{return e.filter(o=>t.includes(o.locationId)||n?.includes(o?.location?.id)||t?.find(c=>c==o?.location?.id)||n?.find(c=>c==o?.locationId+""))}catch(o){return this.loggingService.catch("Error in AreaService filterAnnotationsByLocations:",o),[]}}calculateAreaAnnotationPosition(e,t=!1){try{if(e.targetElements?.length){let n=e.targetElements[0],o=e.targetElements[1];if(n?.xpath&&o?.xpath||n?.anchor&&o?.anchor){let c=null,a=null;if(c=this.resolveAreaPointElement(n),a=this.resolveAreaPointElement(o),c&&a){let r=ue(c,a);if(r){let s=c,m=a,u=s.getBoundingClientRect(),I=m.getBoundingClientRect(),E=t?u.width:s.offsetWidth||u.width,z=t?u.height:s.offsetHeight||u.height,g=t?I.width:m.offsetWidth||I.width,V=t?I.height:m.offsetHeight||I.height,_e={};E&&z&&(_e={top:z*n.topPercentage/100,left:E*n.leftPercentage/100});let Ie={};g&&V&&(Ie={top:V*o.topPercentage/100,left:g*o.leftPercentage/100});let Ve=!t,N=Le(_e.left,_e.top,c,r,Ve),B=Le(Ie.left,Ie.top,a,r,Ve),J,Y,Z,Q,k={};N.x>B.x?N.y>B.y?(Q={x:N.x,y:N.y},J={x:B.x,y:B.y},k.handle1=Q,k.handle2=J):(Y={x:N.x,y:N.y},Z={x:B.x,y:B.y},k.handle1=Y,k.handle2=Z):N.y>B.y?(Z={x:N.x,y:N.y},Y={x:B.x,y:B.y},k.handle1=Z,k.handle2=Y):(J={x:N.x,y:N.y},Q={x:B.x,y:B.y},k.handle1=J,k.handle2=Q);let Wt={topLeft:J||{x:Z?.x,y:Y?.y},bottomRight:Q||{x:Y?.x,y:Z?.y},topRight:Y||{x:Q?.x,y:J?.y},bottomLeft:Z||{x:J?.x,y:Q?.y}};return k.coordinates=Wt,k.targetElement=this.domService.getXPath(r),k}}}}return}catch(n){this.loggingService.catch("Error in AreaService calculateAreaAnnotationPosition:",n);return}}addArea(e,t=[],n,o,c,a){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{let r=this.authService.getUser();if(r)if(r.isReadOnly||r.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add areas.");else{let s=new _t;o&&(s.annotationId=o),s.from=r,s.color=h.DEFAULT_ANNOTATION_COLOR,s.lastUpdated=this.timestamp,n&&(s.targetAnnotations=[n]),s.props=new Ct;let m=this.domService.getCurrentWindowSizeValue();if(s.props.screenWidth=m.screenWidth,s.props.screenHeight=m.screenHeight,s.props.screenScrollHeight=m.screenScrollHeight,s.props.viewportWidth=window.innerWidth,s.props.viewportHeight=window.innerHeight,e||t?.length>0){let E=e?this.getPointsForAreaPinAnnotation(e):t;s.targetElements=[],E.forEach(z=>{s.targetElements.push(this.domService.getTargetElementForCursorPosition(e,void 0,void 0,void 0,void 0,!0,{clientX:z.x,clientY:z.y}))})}this.setLocationToAreaAnnotation(s),c&&(s.locationId=c.locationId,s.location=c.location),s.pageInfo=Re(),s.pageInfo&&(s.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth);let u=this.getElementForAreaAnnotation(s),I=this.docService.getBaseMetadata("area",{element:u});if(s?.metadata||(s.metadata={}),s.metadata=p(p({},s.metadata),I),a?.access&&a?.accessFields){if(!this.userPermissionService?.hasUserContextAccess({userId:r.userId,accessFields:a.accessFields})){this.loggingService.catch("User does not have context access to add area annotation.",void 0,void 0,!0);return}a.accessFields.some(E=>It(E))||(s.context={access:a.access,accessFields:a.accessFields})}return this.saveAreaToDb(s),s}return}catch(r){this.loggingService.catch("Error in AreaService addArea: ",r);return}}setLocationToAreaAnnotation(e){try{let t=this.docService.getLocation();t?(e.locationId=t.locationId,e.location=t.location):(delete e.locationId,delete e.location)}catch(t){this.loggingService.catch("Error in AreaService setLocationToAreaAnnotation:",t)}}shouldSkipAreaPositionCalculation(e){try{if(!e?.locationId)return!1;let t=this.docService.getLocation();if(xt({location:t?.location,locationId:t?.locationId},{location:e?.location,locationId:e?.locationId}))return!1;let n=this.resolveAreaCommonParent(e),o=this.docService.getAdditionLocationFromElement(n),c=o?this.docService.genarateLocationId(o):void 0,a;return e?.location?.id&&e?.location?.id===o?.id||c&&c===e?.locationId?a=!1:a=!0,a}catch(t){return this.loggingService.catch("Error in AreaService shouldSkipAreaPositionCalculation:",t),!1}}resolveAreaPointElement(e){let t=null;if(e?.anchor){let n=this.domService.resolveAnchorRecord(e.anchor);return n?.element&&n?.element instanceof HTMLElement&&!ae(n.element)&&this.domService.isElementVisible(n.element)&&pe(n.element)&&(t=n.element),t}return e?.xpath&&(t=this.domService.getElementFromXPath(e.xpath),t&&ae(t)&&(t=null),this.domService.isXpathWithId(e.xpath)||(!t&&e.cfXpath&&(t=this.domService.getElementFromXPath(e.cfXpath),t&&ae(t)&&(t=null)),!t&&e.fXpath&&(t=this.domService.getElementFromXPath(e.fXpath),t&&ae(t)&&(t=null)))),t}resolveAreaCommonParent(e){let t=this.resolveAreaPointElement(e?.targetElements?.[0]),n=this.resolveAreaPointElement(e?.targetElements?.[1]);return t&&n?ue(t,n):null}getElementForAreaAnnotation(e){try{let t,n,o;if(e.targetElements?.length){if(e.targetElements[0]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[0].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(n=c.element)}else e.targetElements[0]?.xpath&&(n=this.domService.getElementFromXPath(e.targetElements[0].xpath));if(e.targetElements[1]?.anchor){let c=this.domService.resolveAnchorRecord(e.targetElements[1].anchor);c?.element&&this.domService.isElementVisible(c.element)&&pe(c.element)&&(o=c.element)}else e.targetElements[1]?.xpath&&(o=this.domService.getElementFromXPath(e.targetElements[1].xpath))}return n&&o&&(t=ue(n,o)),t}catch(t){return this.loggingService.catch("Error in AreaService getElementForAreaAnnotation: ",t),null}}saveAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: saveAreaToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(w.AREA)&&de([this.docService.getDocumentPaths$(),this.databaseService.getDb()]).pipe($(([t,n])=>!!t&&!!n),me(1),A(([t,n])=>{if(this.documentPaths=t,this.documentPaths?.area){e.annotationId||(e.annotationId=this.commonDbService.generateDocumentId()),e.pageInfo&&(e.pageInfo.areaUrl=this.generateAreaUrl(e));let o=JSON.parse(JSON.stringify(e));if(o.position=null,!o?.metadata?.documentId){o?.metadata||(o.metadata={});let r=this.docService.getBaseMetadata("area");o.metadata=p(p({},o?.metadata),r)}this.domService.toggleAnnotationSelection(o),this.analyticsService.trackEvent(L.Events.Area.AREA_ADDED,{annotationId:e.annotationId});let{documentId:c,organizationId:a}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:c,organizationId:a},data:JSON.parse(JSON.stringify(o))})}else return P(null)})).subscribe(()=>{},t=>{this.loggingService.catch("Error in AreaService saveAreaToDb subscription: ",t)})}catch(t){this.loggingService.catch("Error in AreaService saveAreaToDb: ",t)}}getDocumentIdAndOrganizationIdFromAreaAnnotation(e){try{return{documentId:e?.metadata?.documentId,organizationId:e?.metadata?.organizationId}}catch(t){return this.loggingService.catch("Error in AreaService getDocumentIdAndOrganizationIdFromAreaAnnotation: ",t),{}}}updateArea(e,t=!1,n){try{n&&this.setLocationToAreaAnnotation(e),t&&this.updateNotificationsDatabase(e,Oe.UPDATED),this.updateAreaToDb(e)}catch(o){this.loggingService.catch("Error in AreaService updateArea: ",o)}}updateAreaToDb(e){this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaToDb","color: green;");try{if(this.domService.updateSelectedAnnotationInMap([e]),this.authService.getUser()&&this.authService.isFeatureAllowed(w.AREA)){let t=JSON.parse(JSON.stringify(e));if(t.position=null,!t?.metadata?.documentId){t?.metadata||(t.metadata={});let c=this.docService.getBaseMetadata("area");t.metadata=p(p({},t?.metadata),c)}let{documentId:n,organizationId:o}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);this.commonDbService.setData({feature:"area",properties:{id:e.annotationId,documentId:n,organizationId:o},data:JSON.parse(JSON.stringify(t))})}}catch(t){this.loggingService.catch("Error in AreaService updateAreaToDb: ",t)}}deleteAreaPinAnnotations(e){try{let t=this.domService.getSelectedAnnotationsMap(),n=this.authService.getUser(),o=[];Object.keys(t??{}).forEach(c=>ce(this,null,function*(){let a=t[c];a.type==="area"&&n&&a.from&&(n?.isAdmin||a.from.userId===n.userId)&&o.push(a)})),o?.length&&(this.analyticsService.trackEvent(L.Events.Area.AREA_DELETE_TRIGGERED,{triggerType:e,annotationId:o.map(c=>c.annotationId).join()}),this.dialog.open(kt,{panelClass:"velt-mat-dialog-container",data:{title:"Delete area?",message:"This selected area will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"area"}}).afterClosed().pipe(me(1)).subscribe(c=>{c&&(o.forEach(a=>ce(this,null,function*(){yield this.deleteAreaPinAnnotation(a)})),setTimeout(()=>{document.querySelectorAll(`[${h.SNIPPYLY_HIGHLIGHT}]`).forEach(r=>{this.domService.removeHighlightFromElement(r)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"area")}catch(t){this.loggingService.catch("Error in AreaService deleteAreaPinAnnotations: ",t)}}getAreaAnnotationsByOrganizationIdAndDocumentId({organizationId:e,documentId:t}){try{let n={};return Object.values(this.areaAnnotationById$.value??{}).forEach(o=>{o?.metadata?.documentId==t&&o?.metadata?.organizationId==e&&(n[o?.annotationId]=o)}),Object.values(n??{})}catch(n){return this.loggingService.catch("Error in AreaService getAreaAnnotationsByOrganizationIdAndDocumentId:",n),[]}}onDeleteTargetAnnotation(e,t){try{if(this.docService.getDocumentId()&&this.areaAnnotationById$.value){let o=Object.values(this.areaAnnotationById$.value||{}),c;t?c=o.find(a=>a?.annotationId===t):c=o.find(a=>a?.targetAnnotations?.find(r=>r?.annotationId===e)),c&&(c.targetAnnotations=c.targetAnnotations?.filter(a=>a?.annotationId!==e),c.targetAnnotations?.length?this.updateAreaToDb(c):this.deleteAreaPinAnnotation(c))}}catch(n){this.loggingService.catch("Error in AreaService onDeleteTargetAnnotation: ",n)}}deleteAreaPinAnnotation(e){if(this.authService.isFeatureAllowed(w.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,Oe.DELETED),this.analyticsService.trackEvent(L.Events.Area.AREA_DELETED,{annotationId:e.annotationId});let{documentId:t,organizationId:n}=this.getDocumentIdAndOrganizationIdFromAreaAnnotation(e);return this.commonDbService.deleteData({feature:"area",properties:{id:e.annotationId,documentId:t,organizationId:n}})}else return Promise.resolve()}enableArea(){try{this.areaEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in AreaService enableArea: ",e)}}disableArea(){try{this.areaEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in AreaService disableArea: ",e)}}getAreaEnabled$(){try{return this.areaEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled$: ",e),P(!1)}}getAreaEnabled(){try{return this.areaEnabled$.value}catch(e){return this.loggingService.catch("Error in AreaService getAreaEnabled: ",e),!1}}enableAddAreaMode(){this.authService.isFeatureAllowed(w.AREA)?(this.analyticsService.trackEvent(L.Events.Area.AREA_ADD_MODE_ENABLED),this.addAreaMode$.next(!0)):this.loggingService.catch("Error in AreaService enableAddAreaMode: ","Area feature is not enabled.")}disableAddAreaMode(){this.analyticsService.trackEvent(L.Events.Area.AREA_ADD_MODE_DISABLED),this.addAreaMode$.next(!1)}addAreaModeChange(){return this.addAreaMode$.asObservable()}getPointsForAreaPinAnnotation(e){let t=[],n=e,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,c=n?.touches?.length?n.touches[0]?.clientY:n.clientY;return t.push({x:o,y:c}),t.push({x:o+100,y:c+100}),t}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(e){try{return this.domService.isElementInsideListedElementIds(e,this.allowedElementIds$.value)}catch(t){return this.loggingService.catch("Error in AreaService isElementInsideAllowedElements: ",t),!1}}updateNotificationsDatabase(e,t){try{let n={annotationData:e,actionType:t,notificationSource:"area"};this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in AreaService updateNotificationsDatabase: ",n)}}getAreaUrl(e){try{return e?.pageInfo?.areaUrl?e.pageInfo.areaUrl:(e?.pageInfo||(e.pageInfo=Re(),e.pageInfo&&(e.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),e.pageInfo.areaUrl=this.generateAreaUrl(e),this.updateArea(e),e.pageInfo?.areaUrl)}catch(t){this.loggingService.catch("Error in AreaService getAreaUrl: ",t);return}}generateAreaUrl(e){let t;try{t=new URL(e?.pageInfo?.url||window.location.href)}catch(n){this.loggingService.catch("Error in AreaService generateAreaUrl: ",n),t=new URL(window.location.href)}return t.searchParams.delete(h.URL_PARAMS.TAG_ID),t.searchParams.append(h.URL_PARAMS.TAG_ID,e.annotationId),t.href}generateAreaAnnotationId(){return ce(this,null,function*(){try{if(this.docService.getDocumentPaths()?.area){let t=this.commonDbService.generateDocumentId();return yield Dt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(_(G),_(Mt),_(fe),_(Nt),_(Bt),_(K),_(X),_(St),_(Ae),_(Pt),_(T),_(Ht),_(W))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Ut=()=>({bottom:"calc(100% - 8px)",color:"green"});function Jt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("annotationDragging",i.isResizing)("annotation",i.commentPinAnnotation)("commentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length===1)("multipleCommentPinSelected",i.selectedAnnotationsMap[i.commentPinAnnotation==null?null:i.commentPinAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function Yt(d,l){if(d&1){let i=ie();O(0,"div",8),R("click",function(){b(i);let t=v(3);return y(t.togglePinSelection())}),O(1,"velt-comment-pin-embed",9),R("saveComment",function(t){b(i);let n=v(3);return y(n.saveComment(n.veltEmit(t)))}),M()()}if(d&2){let i=v(2).ngIf,e=v();x("id","comment-pin-container-"+(i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",De(9,Ut))("annotationDragging",i.isResizing)("annotation",i.multiThreadCommentAnnotation)("commentPinSelected",!!i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId])("multipleCommentPinSelected",i.selectedAnnotationsMap[i.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId]&&e.objectKeys(i.selectedAnnotationsMap).length>1)("user",e.user)}}function Zt(d,l){if(d&1){let i=ie();ye(0),O(1,"div",1),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(2,"div",2),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(3,"div",3),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(4,"div",4),R("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(5,"div",5),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("topLeft"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"topLeft"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("topLeft"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),M(),O(6,"div",6),R("cdkDragStarted",function(){b(i);let t=v(2);return y(t.onResizeHandleDragStart("bottomRight"))})("cdkDragMoved",function(t){b(i);let n=v(2);return y(n.onResizeHandleDragMove(t,"bottomRight"))})("cdkDragEnded",function(){b(i);let t=v(2);return y(t.onResizeHandleDragEnd("bottomRight"))})("click",function(){b(i);let t=v(2);return y(t.togglePinSelection())}),j(7,Jt,2,10,"div",7)(8,Yt,2,10,"div",7),M(),Te()}if(d&2){let i=v().ngIf,e=v();D(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topLeft==null?null:i.areaProperties.coordinates.topLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("width",e.LINE_THICKNESS,"px")("height",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.y)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomRight==null?null:i.areaProperties.coordinates.bottomRight.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("border-color",i.areaAnnotationColor)("height",e.LINE_THICKNESS,"px")("width",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.topRight==null?null:i.areaProperties.coordinates.topRight.x)-(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x),"px")("left",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft),"px")("top",(i.areaProperties==null||i.areaProperties.coordinates==null||i.areaProperties.coordinates.bottomLeft==null?null:i.areaProperties.coordinates.bottomLeft.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop),"px"),D(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle1==null?null:i.areaProperties.handle1.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),U("background-color",i.areaAnnotationColor)("width",e.DRAG_HANDLE_SIZE,"px")("height",e.DRAG_HANDLE_SIZE,"px")("left",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.x)+(i.isResizing?i.resizingOffset.left:i.offsetLeft)-e.DRAG_HANDLE_SIZE/2,"px")("top",(i.areaProperties==null||i.areaProperties.handle2==null?null:i.areaProperties.handle2.y)+(i.isResizing?i.resizingOffset.top:i.offsetTop)-e.DRAG_HANDLE_SIZE/2,"px"),q("drag-disabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),x("cdkDragDisabled",!i.pinDragEnabled||(i.areaPinAnnotation==null||i.areaPinAnnotation.from==null?null:i.areaPinAnnotation.from.userId)!==(e.user==null?null:e.user.userId)),D(),x("ngIf",i.commentPinAnnotation),D(),x("ngIf",i.multiThreadCommentAnnotation)}}function Qt(d,l){if(d&1&&(ye(0),j(1,Zt,9,68,"ng-container",0),Te()),d&2){let i=l.ngIf,e=v();D(),x("ngIf",!i.hideAreaAnnotation||e.selected)}}var He=(()=>{let l=class l{get resizing(){return this.componentConfigSignal().isResizing}onMouseEnter(){this.setAreaPinHover(!0)}onMouseLeave(){this.setAreaPinHover(!1)}constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.serviceBook=n,this.docService=o,this.domService=c,this.areaService=a,this.loggingService=r,this.multipleAreaPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.annotationDragging=!1,this.dragPosition=null,this.LINE_THICKNESS=0,this.DRAG_HANDLE_SIZE=10,this.skipValueUpdate=!1,this.areaPinHover=!1,this.resolvedCommentsOnDom=!1,this.componentConfigSignal=Ke({hideAreaAnnotation:!1,selected:!1,areaAnnotationColor:"#625DF5",areaProperties:void 0,resizingOffset:{top:0,left:0},offsetLeft:0,offsetTop:0,isResizing:!1,areaPinAnnotation:void 0,user:void 0,commentPinAnnotation:void 0,selectedAnnotationsMap:{},pinDragEnabled:!0}),this.selected=!1,this.veltElement=!0,this.commentService=null,this.serviceBook.observe(ee).subscribe(s=>{this.commentService=s}),this.subscriptions.push(this.authService.getUser$().subscribe(s=>{this.user=s},s=>{this.catchError("Error in AreaPinPortalComponent getUser$ subscription: ",s)})),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(s=>s?s.getPinDrag$():le)).subscribe(s=>{this.componentConfigSignal.update(m=>S(p({},m),{pinDragEnabled:s}))},s=>{this.catchError("Error in AreaPinPortalComponent getPinDrag$ subscription: ",s)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(s=>{this.componentConfigSignal.update(m=>(m=S(p({},m),{selectedAnnotationsMap:s}),m)),this.componentConfigSignal().areaPinAnnotation?.annotationId&&this.componentConfigSignal().selectedAnnotationsMap&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().areaPinAnnotation.annotationId],this.componentConfigSignal().commentPinAnnotation?this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().commentPinAnnotation?.annotationId]:this.componentConfigSignal().multiThreadCommentAnnotation&&(this.selected=!!this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().multiThreadCommentAnnotation?.annotationId])),this.updateAreaActiveAttributeOnElement()},s=>{this.catchError("Error in AreaPinPortalComponent getSelectedAnnotationsMap$ subscription: ",s)}))}ngOnInit(){}ngAfterViewInit(){try{let e=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===w.MULTI_THREAD)?.annotationId;e?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getCommentAnnotationByAnnotationId(e):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{commentPinAnnotation:n}),o.commentPinAnnotation?(o.areaAnnotationColor=o.commentPinAnnotation?.status.color,!this.resolvedCommentsOnDom&&!(this.commentService?.getFilterCommentsOnDom()&&this.commentService?.getCommentsFromSidebarMap())&&o.commentPinAnnotation?.status.type==="terminal"?o.hideAreaAnnotation=!0:o.hideAreaAnnotation=!1):o.hideAreaAnnotation=!0,o))}))):t?(this.componentConfigSignal.update(n=>(n=S(p({},n),{hideAreaAnnotation:!0}),n)),this.subscriptions.push(this.serviceBook.observe(ee).pipe(A(n=>n?n.getMultiThreadCommentAnnotationByAnnotationId(t):le),A(n=>(this.commentService?.getResolvedCommentsOnDom$()??P(!0)).pipe(f(o=>(this.resolvedCommentsOnDom=o,n))))).subscribe(n=>{this.componentConfigSignal.update(o=>(o=S(p({},o),{multiThreadCommentAnnotation:n}),o.hideAreaAnnotation=!1,o))}))):this.componentConfigSignal.update(n=>(n=S(p({},n),{areaAnnotationColor:this.componentConfigSignal().areaPinAnnotation?.from?.color||"#625DF5"}),n)),this.componentConfigSignal().areaPinAnnotation?.targetElements?.length&&this.componentConfigSignal().areaPinAnnotation?.targetElements?.forEach(n=>{if(n?.xpath){let o=this.domService.getElementFromXPath(n?.xpath);!o&&n?.cfXpath&&(o=this.domService.getElementFromXPath(n?.cfXpath)),!o&&n?.fXpath&&(o=this.domService.getElementFromXPath(n?.fXpath)),o&&this.detectPositionChange(o)}})}catch(e){this.catchError("Error in AreaPinPortalComponent ngAfterViewInit: ",e)}}setAreaPinAnnotation(e){try{this.componentConfigSignal.update(t=>(!this.skipValueUpdate&&!t.isResizing&&(t=S(p({},t),{areaPinAnnotation:e}),this.id=e.annotationId,t.isResizing||(t.areaProperties=e.areaProperties)),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinAnnotation: ",t)}}setOffsetLeft(e){try{this.componentConfigSignal.update(t=>(t=S(p({},t),{offsetLeft:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetLeft: ",t)}}setOffsetTop(e){try{this.componentConfigSignal.update(t=>(t=S(p({},t),{offsetTop:e}),t))}catch(t){this.catchError("Error in AreaPinPortalComponent setOffsetTop: ",t)}}togglePinSelection(){try{let e=!0;this.componentConfigSignal().commentPinAnnotation&&(e=!(this.domService.getDraftCommentAnnotationDialogs()||[])?.length,this.domService.resetSelectedAnnotationsMap(!0,"comments")),e&&(this.domService.toggleAnnotationSelection(this.componentConfigSignal().areaPinAnnotation),this.componentConfigSignal().commentPinAnnotation?this.domService.toggleAnnotationSelection(this.componentConfigSignal().commentPinAnnotation):this.componentConfigSignal().multiThreadCommentAnnotation&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().multiThreadCommentAnnotation))}catch(e){this.catchError("Error in AreaPinPortalComponent togglePinSelection: ",e)}}saveComment(e){try{this.componentConfigSignal().commentPinAnnotation?this.commentService?.saveComment(this.componentConfigSignal().commentPinAnnotation,e):this.componentConfigSignal().multiThreadCommentAnnotation&&this.commentService?.saveComment(this.componentConfigSignal().multiThreadCommentAnnotation,e)}catch(t){this.catchError("Error in AreaPinPortalComponent saveComment: ",t)}}veltEmit(e){return typeof CustomEvent<"u"&&e instanceof CustomEvent?e.detail:e}calculateResizingOffset(e){try{if(!e)return{top:0,left:0};let t=e.getBoundingClientRect(),n=t.left+window.scrollX;return{top:t.top+window.scrollY,left:n}}catch(t){return this.catchError("Error in AreaPinPortalComponent calculateResizingOffset: ",t),{top:0,left:0}}}onResizeHandleDragStart(e){try{document.body.classList.add(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,document.body.appendChild(t)),this.componentConfigSignal.update(r=>(r=S(p({},r),{isResizing:!0}),r));let n=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),o=this.calculateResizingOffset(n),c=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),a=this.areaService.calculateAreaAnnotationPosition(c,!0);this.componentConfigSignal.update(r=>(r=p(S(p({},r),{resizingOffset:o}),a?{areaProperties:a}:{}),r))}catch(t){this.catchError("Error in AreaPinPortalComponent onResizeHandleDragStart: ",t)}}onResizeHandleDragMove(e,t){try{let n=this.domService.getTargetElementForCursorPosition(e.event);if(this.componentConfigSignal().commentPinAnnotation){let o=this.domService.getElementFromXPath(n?.xpath);if(o&&!this.commentService?.isElementInsideAllowedElements(o))return}if(n){let o=JSON.parse(JSON.stringify(this.componentConfigSignal().areaPinAnnotation)),c=o.targetElements||[];switch(t){case"topLeft":c[0]=n;break;case"bottomRight":c[1]=n;break;default:break}o.targetElements=c;let a=this.areaService.calculateAreaAnnotationPosition(o,!0),r=this.componentConfigSignal().areaProperties?.targetElement,s=a?.targetElement,m=r!==s,u,I;if(m&&a?.targetElement){let E=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(E);u=z.top,I=z.left}else{let E=this.componentConfigSignal().resizingOffset;u=E.top,I=E.left}this.componentConfigSignal.update(E=>(E=S(p({},E),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),E))}}catch(n){this.catchError("Error in AreaPinComponent onResizeHandleDragMove: ",n)}}onResizeHandleDragEnd(e){try{document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING);let t=document.getElementById(this.componentConfigSignal().areaPinAnnotation.annotationId);t&&this.parentElement&&(this.parentElement.appendChild(t),t.style.opacity="0");let n=this.componentConfigSignal().areaPinAnnotationOnResize||this.componentConfigSignal().areaPinAnnotation;if(n){let a=this.areaService.calculateAreaAnnotationPosition(n,!1);a&&this.componentConfigSignal.update(r=>(r=S(p({},r),{areaProperties:a}),r))}this.componentConfigSignal.update(a=>(a=S(p({},a),{isResizing:!1}),a)),this.skipValueUpdate=!0;let o=this.domService.getElementFromXPath(this.componentConfigSignal().areaProperties?.targetElement),c=this.docService.getAdditionalDocumentIdFromElement(o)||this.docService.getDocumentPaths()?.clientDocumentId;!this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId||this.componentConfigSignal().areaPinAnnotation?.metadata?.clientDocumentId==c?(this.componentConfigSignal.update(a=>(a=p({},a),a.areaPinAnnotationOnResize&&(a.areaPinAnnotation=JSON.parse(JSON.stringify(a.areaPinAnnotationOnResize))),delete a.areaPinAnnotationOnResize,a)),this.areaService.updateArea(this.componentConfigSignal().areaPinAnnotation,!1),this.analyticsService.trackEvent(L.Events.Area.AREA_DRAGGED,{annotationId:this.componentConfigSignal().areaPinAnnotation.annotationId})):this.componentConfigSignal.update(a=>(a=p({},a),a.areaProperties=a.areaPinAnnotation.areaProperties,a)),setTimeout(()=>{this.skipValueUpdate=!1,t&&(t.style.opacity="1")},50)}catch(t){this.catchError("Error in AreaPinComponent onResizeHandleDragEnd: ",t)}}detectPositionChange(e){try{let t=$e(0,Ue).pipe(f(()=>{let n=e.getBoundingClientRect();return{top:n.top,left:n.left}}),re((n,o)=>n.top===o.top&&n.left===o.left),je());this.subscriptions.push(t.subscribe(()=>{this.componentConfigSignal.update(n=>(n=S(p({},n),{areaProperties:this.areaService.calculateAreaAnnotationPosition(n.areaPinAnnotation)}),n))},n=>{}))}catch(t){this.catchError("Error in AreaPinPortalComponent detectPositionChange: ",t)}}setAreaPinHover(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAreaPinHover","color: green;"),e&&this.targetElement&&!this.domService.isElementVisibleOnScreen(this.targetElement)&&(e=!1),this.areaPinHover=e,this.updateAreaActiveAttributeOnElement()}catch(t){this.catchError("Error in AreaPinPortalComponent setAreaPinHover: ",t)}}updateAreaActiveAttributeOnElement(){try{this.loggingService.log("%c[WB] Calling FUNCTION: updateAreaActiveAttributeOnElement","color: green;"),this.selected||this.areaPinHover?this.targetElement&&(this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)||this.targetElement?.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE,"true")):this.targetElement&&this.targetElement?.hasAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)&&this.targetElement?.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_ACTIVE)}catch(e){this.catchError("Error in AreaPinPortalComponent updateAreaActiveAttributeOnElement: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),this.componentConfigSignal()?.isResizing&&document.body.classList.remove(h.BODY_CLASSES.VELT_PIN_DRAGGING)}catch(e){this.catchError("Error in AreaPinPortalComponent 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 AreaPinPortalComponent unsubscribe: ",e)}}catchError(e,t,n){try{this.loggingService.catch(e,t,S(p({},n||{}),{annotationId:this.componentConfigSignal()?.areaPinAnnotation?.annotationId}))}catch{}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(W),C(fe),C(X),C(F),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-pin-portal"]],hostVars:6,hostBindings:function(t,n){t&1&&R("mouseenter",function(){return n.onMouseEnter()})("mouseleave",function(){return n.onMouseLeave()}),t&2&&(tt("id",n.id),ne("data-velt-element",n.veltElement),q("selected",n.selected)("resizing",n.resizing))},inputs:{multipleAreaPinsSelected:"multipleAreaPinsSelected",avatarErrorImage:"avatarErrorImage",user:"user",targetElement:"targetElement"},standalone:!1,decls:1,vars:1,consts:[[4,"ngIf"],["id","line1",1,"line","vertical",3,"click"],["id","line2",1,"line","horizontal",3,"click"],["id","line3",1,"line","vertical",3,"click"],["id","line4",1,"line","horizontal",3,"click"],["id","handle1","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],["id","handle2","cdkDrag","",1,"handle",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","click","cdkDragDisabled"],[3,"id","click",4,"ngIf"],[3,"click","id"],[3,"saveComment","ngStyle","annotationDragging","annotation","commentPinSelected","multipleCommentPinSelected","user"]],template:function(t,n){t&1&&j(0,Qt,2,1,"ng-container",0),t&2&&x("ngIf",n.componentConfigSignal())},dependencies:[ge,lt,ht],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}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events: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}.line[_ngcontent-%COMP%]{position:absolute;opacity:.4;transition:opacity .2s ease-in-out}.line.vertical[_ngcontent-%COMP%]{border-left:1px dashed;border-right:1px dashed}.line.horizontal[_ngcontent-%COMP%]{border-top:1px dashed;border-bottom:1px dashed}.handle[_ngcontent-%COMP%]{position:absolute;transform:none!important;border-radius:100%}.handle[_ngcontent-%COMP%]:not(.drag-disabled){cursor:grab}#handle1[_ngcontent-%COMP%]{opacity:.4;transition:opacity,transform .2s ease-in-out}#handle2[_ngcontent-%COMP%]{background-color:transparent!important}.resizing[_nghost-%COMP%] div[_ngcontent-%COMP%]{z-index:1}.resizing[_nghost-%COMP%] .handle[_ngcontent-%COMP%]{cursor:grabbing}[_nghost-%COMP%]:hover #handle1[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] #handle1[_ngcontent-%COMP%], .selected[_nghost-%COMP%] #handle1[_ngcontent-%COMP%]{opacity:1;transform:scale(2)!important}[_nghost-%COMP%]:hover .line[_ngcontent-%COMP%], .resizing[_nghost-%COMP%] .line[_ngcontent-%COMP%], .selected[_nghost-%COMP%] .line[_ngcontent-%COMP%]{opacity:1}snippyly-comment-pin[_ngcontent-%COMP%], velt-comment-pin-embed[_ngcontent-%COMP%], snippyly-comment-pin-embed[_ngcontent-%COMP%]{position:absolute;bottom:calc(100% - 8px)}.s-metadata[_ngcontent-%COMP%]{position:fixed;bottom:10px;right:10px;background:#fff;font-size:14px;border:1px solid;padding:10px;box-shadow:1px 1px 1px 1px;border-radius:4px}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{border-collapse:collapse}.s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%], .s-metadata[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid;padding:4px 8px}"],changeDetection:0});let d=l;return d})();var $t=(()=>{let l=class l{constructor(e,t,n,o,c){this.domService=e,this.componentFactoryResolver=t,this.injector=n,this.appRef=o,this.loggingService=c,this.areasPinById={}}setAreaPin(e){try{if(!this.areasPinById[e.annotationId])this.setPinPortal(e);else{let t=this.areasPinById[e.annotationId].portalRef?.instance?.componentConfigSignal().isResizing;if(e.areaProperties?.targetElement===this.areasPinById[e.annotationId]?.annotation?.areaProperties?.targetElement||t){let n=this.areasPinById[e.annotationId].portalRef,o=this.areasPinById[e.annotationId].userTargetElement,c=this.areasPinById[e.annotationId].pinHostElement;if(document.body.contains(o)&&document.body.contains(c))n&&(n.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),this.updateElementOffset(e));else{let a=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;a&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),a.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}else{let n=this.areasPinById[e.annotationId].pinHostDomPortalOutlet;n&&(this.removeAreaPinHostAttributes(e.annotationId,this.areasPinById[e.annotationId].pinHostElement),n.detach(),delete this.areasPinById[e.annotationId],this.setPinPortal(e))}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setAreaPin: ",t)}}setPinPortal(e){try{if(e?.areaProperties?.targetElement){let t=this.domService.getElementFromXPath(e?.areaProperties?.targetElement);if(t){let n=this.domService.getHostElement(t),o=new pt(He),c=new ut(n,this.appRef,this.injector),a=c.attach(o);a.instance.setAreaPinAnnotation(JSON.parse(JSON.stringify(e))),a.instance.targetElement=t,this.areasPinById[e.annotationId]={pinHostDomPortalOutlet:c,pinPortal:o,portalRef:a,annotation:JSON.parse(JSON.stringify(e)),userTargetElement:t,pinHostElement:n},this.setAreaPinHostAttributes(e.annotationId,n),this.updateElementOffset(e)}}}catch(t){this.loggingService.catch("Error in AreaPinPortalService setPinPortal: ",t)}}setAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(",");o.includes(e)||(o.push(e),t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")))}else t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,e);this.domService.isElementOriginallyStatic(t)&&(Ot(t)||t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC,"true"))}catch(n){this.loggingService.catch("Error in AreaPinPortalService setAreaPinHostAttributes: ",n)}}removeAreaPinHostAttributes(e,t){try{let n=t.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST);if(n){let o=n.split(","),c=o.indexOf(e);c>-1&&(o.splice(c,1),o.length>0?t.setAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST,o.join(",")):t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST))}t?.getAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST)||t.removeAttribute(h.ATTRIBUTES.VELT_AREA_PIN_HOST_STATIC)}catch(n){this.loggingService.catch("Error in AreaPinPortalService removeAreaPinHostAttributes: ",n)}}updateElementOffset(e){try{let{portalRef:t,userTargetElement:n,pinHostElement:o}=this.areasPinById[e.annotationId],c=this.domService.getElementOffset(n,o);t.instance.setOffsetLeft(c.offsetLeft),t.instance.setOffsetTop(c.offsetTop)}catch(t){this.loggingService.catch("Error in AreaPinPortalService updateElementOffset: ",t)}}checkPinsToRemove(e){try{let t=e.map(n=>n.annotationId);Object.keys(this.areasPinById).forEach(n=>{if(!t.includes(n)){let o=this.areasPinById[n];o.pinHostDomPortalOutlet.detach(),this.removeAreaPinHostAttributes(n,o.pinHostElement),this.domService.removeHighlightFromElement(o.pinHostElement),delete this.areasPinById[n]}})}catch(t){this.loggingService.catch("Error in AreaPinPortalService checkPinsToRemove: ",t)}}};l.\u0275fac=function(t){return new(t||l)(_(X),_(Je),_(Xe),_(Qe),_(T))},l.\u0275prov=he({token:l,factory:l.\u0275fac,providedIn:"root"});let d=l;return d})();var Se=(()=>{let l=class l{constructor(e,t,n,o,c,a,r){this.analyticsService=e,this.authService=t,this.domService=n,this.areaService=o,this.areaPinPortalService=c,this.serviceBook=a,this.loggingService=r,this.areaPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.commentsOnDom=!0,this.commentService=null,this.veltId=yt(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: AreasContainerComponent","color: blue;"),this.serviceBook.observe(ee).subscribe(s=>{this.commentService=s})}catch(s){this.loggingService.catch("Error in AreasContainerComponent constructor: ",s)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let e=document.querySelector(h.TAGS.SNIPPYLY_AREAS),t=document.querySelector(h.TAGS.VELT_AREAS);t?this.veltId===t?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===e?.getAttribute(h.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(e){this.loggingService.catch("Error in AreasContainerComponent AfterViewInit: ",e)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe($(e=>!!e)).subscribe(e=>{e&&this.setAreaInstalledInAnalytics()},e=>{this.loggingService.catch("Error in getUser: ",e)})),this.getAllAreasOnCurrentDocument()}catch(e){this.loggingService.catch("Error in AreasContainerComponent initComponent: ",e)}}getAllAreasOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllAreasOnCurrentDocument","color: green;");try{this.subscriptions.push(this.areaService.getAllAreaAnnotations().pipe($(e=>!!e),A(e=>this.domService.getSelectedAnnotationsMap$().pipe(f(t=>({annotations:e,selectedAnnotationsMap:t||{}})))),A(e=>(this.commentService?.getCommentsOnDom$()??P(!0)).pipe(f(t=>(this.commentsOnDom=t,{annotations:e.annotations,selectedAnnotationsMap:e.selectedAnnotationsMap,commentsOnDom:t||{}}))))).subscribe(e=>{try{this.loggingService.log(e),this.areaPinAnnotations=e?.annotations,this.commentsOnDom||(this.areaPinAnnotations=this.areaPinAnnotations?.filter(n=>!n?.targetAnnotations?.filter(o=>o?.type===w.COMMENT)?.length));let t=this.areaPinAnnotations.filter(n=>n?.areaProperties?.targetElement);this.areaPinPortalService.checkPinsToRemove(t),t.forEach(n=>{this.areaPinPortalService.setAreaPin(n)})}catch(t){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument inside subscription: ",t)}},e=>{this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in AreasContainerComponent getAllAreasOnCurrentDocument: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasContainerComponent 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 AreasContainerComponent unsubscribe: ",e)}}setAreaInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(Et.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(X),C(F),C($t),C(W),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-container"]],hostVars:2,hostBindings:function(t,n){t&2&&ne("data-velt-id",n.veltId)("data-velt-element",n.veltElement)},standalone:!1,decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0});let d=l;return d})();var en=["customBtnRef"],tn=["*"];function nn(d,l){if(d&1&&(O(0,"div",6),Ge(),O(1,"svg",7),qe(2,"path",8),M()()),d&2){let i=v();D(),q("active",i.addAreaMode)}}function on(d,l){d&1&&et(0)}function rn(d,l){d&1&&it(0)}var Pe=(()=>{let l=class l{constructor(e,t,n,o,c){this.analyticsService=e,this.authService=t,this.areaService=n,this.iamService=o,this.loggingService=c,this.showDefaultBtn=!1,this.addAreaMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(a=>{this.user=a},a=>{this.loggingService.catch("Error in AreasToolComponent getUser$ subscription: ",a)}))}ngOnInit(){}ngAfterViewInit(){try{this.customBtnRef?.nativeElement?.children?.length||(this.showDefaultBtn=!0),this.subscriptions.push(this.areaService.addAreaModeChange().subscribe(e=>{this.addAreaMode=e}))}catch(e){this.loggingService.catch("Error in AreasToolComponent AfterViewInit: ",e)}}addArea(){this.loggingService.log("%c[WB] Calling FUNCTION: addArea","color: green;");try{this.analyticsService.trackEvent(L.Events.Area.AREA_TOOL_CLICKED,{toolType:this.customBtnRef?.nativeElement?.children?.length?"custom":"default"}),this.user&&(this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add areas."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.areaService.enableAddAreaMode():this.loggingService.catch("User does not have permission to add areas."))}catch(e){this.loggingService.catch("Error in AreasToolComponent addArea: ",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in AreasToolComponent 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 AreasToolComponent unsubscribe: ",e)}}};l.\u0275fac=function(t){return new(t||l)(C(G),C(K),C(F),C(Ae),C(T))},l.\u0275cmp=te({type:l,selectors:[["snippyly-area-tool"]],viewQuery:function(t,n){if(t&1&&ot(en,5),t&2){let o;rt(o=at())&&(n.customBtnRef=o.first)}},hostVars:1,hostBindings:function(t,n){t&2&&ne("data-velt-element",n.veltElement)},standalone:!1,ngContentSelectors:tn,decls:7,vars:4,consts:[["customBtnRef",""],["content",""],[1,"snippyly-area-btn-container",3,"click"],["class","action-btn",4,"ngIf"],[1,"custom-btn-container"],[4,"ngTemplateOutlet"],[1,"action-btn"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["fill-rule","evenodd","clip-rule","evenodd","d","M22.6315 18.0207C23.3673 17.9913 23.9399 17.371 23.9105 16.6352L23.6567 10.2894C23.6289 9.59486 23.0723 9.03819 22.3778 9.01041L16.0319 8.75654C15.2961 8.7271 14.6758 9.29972 14.6463 10.0355C14.6169 10.7713 15.1895 11.3916 15.9253 11.4211L19.2283 11.5532L10.0679 20.7136C9.54724 21.2343 9.54724 22.0785 10.0679 22.5992C10.5886 23.1199 11.4329 23.1199 11.9536 22.5992L21.1139 13.4389L21.246 16.7418C21.2754 17.4775 21.8957 18.0502 22.6315 18.0207Z","fill","#8F95B2"]],template:function(t,n){if(t&1){let o=ie();nt(),O(0,"div",2),R("click",function(a){return b(o),n.addArea(),y(a.stopPropagation())}),j(1,nn,3,2,"div",3),O(2,"div",4,0),j(4,on,1,0,"ng-container",5),M()(),j(5,rn,1,0,"ng-template",null,1,ct)}if(t&2){let o=st(6);q("active",n.addAreaMode),D(),x("ngIf",n.showDefaultBtn),D(3),x("ngTemplateOutlet",o)}},dependencies:[ge,dt],encapsulation:2,changeDetection:0});let d=l;return d})();var Ee=class extends zt{constructor(l){super(l),this.getService(T).log("%c[WB] Creating CLASS: AreaElement","color: blue;"),this.enableArea=this._enableAreaComment,this.disableArea=this._disableAreaComment,this.enableAreaComment=this._enableAreaComment,this.disableAreaComment=this._disableAreaComment}_enableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: enableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.ENABLE_AREA_COMMENT_TRIGGERED),this.getService(F).enableArea()}catch(l){this.getService(T).catch("Error in _enableAreaComment: ",l)}}_disableAreaComment(){this.getService(T).log("%c[WB] Calling FUNCTION: disableAreaComment","color: green;");try{this.trackEvent(L.Events.Area.DISABLE_AREA_COMMENT_TRIGGERED),this.getService(F).disableArea()}catch(l){this.getService(T).catch("Error in _disableAreaComment: ",l)}}};var jt=(()=>{let l=class l{};l.\u0275fac=function(t){return new(t||l)},l.\u0275mod=Ze({type:l}),l.\u0275inj=We({imports:[mt,At,ft,gt,Ft]});let d=l;return d})();function an(d){d.get(T).log("%c[WB] Loading area feature chunk","color: blue;"),d.get(W).set(Lt,d.get(F));let t=Ye(jt,d).injector;return Ce(t,h.TAGS.VELT_AREA_TOOL,Pe),Ce(t,h.TAGS.SNIPPYLY_AREA_TOOL,Pe),Ce(t,h.TAGS.VELT_AREAS,Se),Ce(t,h.TAGS.SNIPPYLY_AREAS,Se),new Ee(d)}function Ce(d,l,i){if(customElements.get(l))return;let e=vt(i,{injector:d});customElements.define(l,e)}export{an as default};
|