@veltdev/sdk-dev 6.0.0-beta.3 → 6.0.0-beta.30
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/app/client/snippyly.model.d.ts +12 -3
- package/app/models/data/comment-events.data.model.d.ts +39 -0
- package/app/models/data/config.data.model.d.ts +154 -0
- package/app/models/data/reaction-resolver.data.model.d.ts +1 -0
- package/app/models/data/selection.model.d.ts +10 -8
- package/app/models/data/suggestion.data.model.d.ts +47 -2
- package/app/models/data/user-resolver.data.model.d.ts +11 -9
- package/app/models/data/user.data.model.d.ts +21 -18
- package/app/models/element/activity-element.model.d.ts +0 -1
- package/app/models/element/area-element.model.d.ts +0 -1
- package/app/models/element/arrow-element.model.d.ts +1 -2
- package/app/models/element/autocomplete-element.model.d.ts +0 -1
- package/app/models/element/comment-element.model.d.ts +103 -77
- package/app/models/element/contact-element.model.d.ts +1 -2
- package/app/models/element/crdt-element.model.d.ts +1 -1
- package/app/models/element/cursor-element.model.d.ts +1 -2
- package/app/models/element/huddle-element.model.d.ts +1 -2
- package/app/models/element/live-state-sync-element.model.d.ts +1 -1
- package/app/models/element/notification-element.model.d.ts +33 -2
- package/app/models/element/presence-element.model.d.ts +32 -11
- package/app/models/element/reaction-element.model.d.ts +1 -1
- package/app/models/element/recorder-element.model.d.ts +21 -2
- package/app/models/element/rewriter-element.model.d.ts +43 -1
- package/app/models/element/selection-element.model.d.ts +1 -1
- package/app/models/element/suggestion-element.model.d.ts +0 -1
- package/app/models/element/tag-element.model.d.ts +7 -8
- package/app/models/element/views-element.model.d.ts +1 -1
- package/app/utils/enums.d.ts +97 -83
- package/{chunk-6SOP2T3L.js → chunk-2XFMMSIA.js} +1 -1
- package/{chunk-USRSVPHC.js → chunk-35J3HFXX.js} +1 -1
- package/{chunk-Y6QKEGWK.js → chunk-7KKEGN3R.js} +1 -1
- package/{chunk-XQZVQUQK.js → chunk-7USARX44.js} +3 -3
- package/{chunk-Q7BPHHBS.js → chunk-7YVQR4BL.js} +1 -1
- package/{chunk-5FKOPJVO.js → chunk-AAZAJXGE.js} +7 -7
- package/{chunk-N4SGYLNB.js → chunk-B4IA4XDT.js} +1 -1
- package/{chunk-2HGBJS2C.js → chunk-BYJ7FNFA.js} +1 -1
- package/{chunk-7W553TUZ.js → chunk-DJYRZD7H.js} +1 -1
- package/chunk-FXUDI3M6.js +167 -0
- package/{chunk-YBQBSGLX.js → chunk-G35OSTOG.js} +1 -1
- package/{chunk-SALUJBOS.js → chunk-GBHISGGX.js} +1 -1
- package/{chunk-JFRM6MNS.js → chunk-GGPJ6IKC.js} +1 -1
- package/chunk-GRHEZULW.js +1 -0
- package/{chunk-XMYVEF74.js → chunk-HCYE7VHY.js} +1 -1
- package/chunk-KVEOD4IE.js +13 -0
- package/chunk-LALOXUNJ.js +2 -0
- package/{chunk-2KJNXU43.js → chunk-MMLFNU6G.js} +1 -1
- package/{chunk-J6J7I3SW.js → chunk-MNSD5X74.js} +1 -1
- package/{chunk-BG6MNCDK.js → chunk-MWSODQ6X.js} +1 -1
- package/{chunk-7ZOGXD6Z.js → chunk-NTNPNLFT.js} +1 -1
- package/{chunk-447SWJD2.js → chunk-PFRELWAV.js} +1 -1
- package/{chunk-TXOYHDVN.js → chunk-RFCFKIUM.js} +1 -1
- package/{chunk-AOHSD4YE.js → chunk-RU3S5WM7.js} +2 -2
- package/{chunk-UJMFCXYS.js → chunk-SJ45VMIG.js} +1 -1
- package/{chunk-ZVY2YW2G.js → chunk-SZKZ3DG3.js} +1 -1
- package/{chunk-QE2MK6NF.js → chunk-TH6YKCXO.js} +1 -1
- package/chunk-TYMRWTZD.js +1 -0
- package/{chunk-ABOXMXUZ.js → chunk-WCKADONS.js} +1 -1
- package/chunk-WD2ZEHH2.js +1 -0
- package/{chunk-25GEE4UD.js → chunk-WDA4SVMN.js} +1 -1
- package/{chunk-IXZIBE27.js → chunk-XA2U66CN.js} +1 -1
- package/chunk-XK65RTYQ.js +1 -0
- package/package.json +1 -1
- package/types.d.ts +22 -22
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +2 -2
- package/velt-comment.js +8 -8
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +2 -2
- package/velt-huddle.js +3 -3
- package/velt-live-state-sync.js +2 -2
- package/velt-notification.js +1 -1
- package/velt-presence.js +1 -1
- package/velt-reaction.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt-rewriter.js +2 -2
- package/velt-selection.js +1 -1
- package/velt-tag.js +1 -1
- package/velt-user-invite.js +1 -1
- package/velt-user-request.js +1 -1
- package/velt-video-player.js +1 -1
- package/velt-views.js +3 -3
- package/velt.d.ts +2 -3
- package/velt.js +264 -22
- package/chunk-5B5CQEDX.js +0 -1
- package/chunk-APIRNTKO.js +0 -1
- package/chunk-AVMLJMVU.js +0 -1
- package/chunk-BLIJMW4Z.js +0 -13
- package/chunk-BY627CV6.js +0 -1
- package/chunk-DX4SZFHQ.js +0 -1
- package/chunk-JWLHBAMV.js +0 -167
package/velt-area.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ht,d as gt}from"./chunk-TXOYHDVN.js";import{t as Ft}from"./chunk-XQZVQUQK.js";import"./chunk-XMYVEF74.js";import"./chunk-7W553TUZ.js";import{a as zt}from"./chunk-AVMLJMVU.js";import"./chunk-7ZOGXD6Z.js";import"./chunk-2HGBJS2C.js";import"./chunk-447SWJD2.js";import{b as Bt}from"./chunk-ZVY2YW2G.js";import"./chunk-UJMFCXYS.js";import{a as kt}from"./chunk-6SOP2T3L.js";import{a as fe}from"./chunk-N4SGYLNB.js";import{a as vt}from"./chunk-J6J7I3SW.js";import{I as At,Y as Et,r as pt,t as ut,v as ft}from"./chunk-AOHSD4YE.js";import{$ as ge,$f as bt,Ab as nt,Bb as it,Be as De,Bg as Re,Bi as H,C as $e,Ci as Lt,Db as ot,Dd as St,De as M,E as j,Eb as rt,Ee as Ct,Fa as D,Fb as at,Gc as pe,Gd as Pt,Hi as ue,Ib as st,J as he,Jb as U,Kb as ee,Kc as lt,Kg as Dt,Kh as Rt,L as ae,Lc as mt,M as je,Ma as Je,Pa as E,Pc as dt,Pf as Oe,Qi as Nt,T as A,Ta as Ye,Te as h,Ua as ne,Va as Ze,We as _t,Y as Ie,Zh as te,_a as W,a as p,aa as We,ac as Te,af as It,ag as yt,b as S,bb as Qe,ca as _,db as ie,dg as Tt,g as le,ha as b,ia as y,ii as wt,ja as Xe,je as w,jh as we,kh as Me,l as re,la as Ge,lb as x,lg as $,mb as O,mh as Ot,nb as L,ng as se,ni as X,o as Ue,ob as qe,oi as G,p as me,pc as ct,pi as T,qa as Ke,qi as Mt,r as P,sb as be,tb as ye,ub as et,ui as K,v as f,vb as oe,vi as J,w as de,wb as tt,wi as Ne,xb as R,xg as xe,xh as xt,zb as v,zh as Le}from"./chunk-JWLHBAMV.js";var k=(()=>{let l=class l{constructor(e,t,n,o,s,a,r,c,d,u,I,C,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=C,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 Pt(this.afAuth).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(M.COMMENT))return P(r);{let c=r?.filter(d=>!d?.targetAnnotations?.filter(u=>u?.type===M.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,M.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 C=I.metadata?.documentId;return C&&(u[C]||(u[C]=[]),u[C].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(),C=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={};C&&z&&(Ce={top:z*n.topPercentage/100,left:C*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 It;o&&(c.annotationId=o),c.from=r,c.color=h.DEFAULT_ANNOTATION_COLOR,c.lastUpdated=this.timestamp,n&&(c.targetAnnotations=[n]),c.props=new _t;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 C=e?this.getPointsForAreaPinAnnotation(e):t;c.targetElements=[],C.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}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(M.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(w.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(M.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(w.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(M.AREA)&&this.documentPaths?.area&&e?.annotationId){this.updateNotificationsDatabase(e,De.DELETED),this.analyticsService.trackEvent(w.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(M.AREA)?(this.analyticsService.trackEvent(w.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(w.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),_(Et),_(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===M.COMMENT)?.annotationId,t=this.componentConfigSignal().areaPinAnnotation.targetAnnotations?.find(n=>n?.type===M.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 C=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(C);u=z.top,I=z.left}else{let C=this.componentConfigSignal().resizingOffset;u=C.top,I=C.left}this.componentConfigSignal.update(C=>(C=S(p({},C),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),C))}}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(w.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)(E(G),E(J),E(X),E(ue),E(K),E(k),E(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===M.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(Ct.AREA_COMMENT)}catch(e){this.loggingService.catch("Error in AreasContainerComponent setAreaInstalledInAnalytics: ",e)}}};l.\u0275fac=function(t){return new(t||l)(E(G),E(J),E(K),E(k),E(Ut),E(X),E(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(w.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)(E(G),E(J),E(k),E(fe),E(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(w.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(w.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-RFCFKIUM.js";import{t as Bt}from"./chunk-7USARX44.js";import"./chunk-HCYE7VHY.js";import"./chunk-DJYRZD7H.js";import{a as kt}from"./chunk-XK65RTYQ.js";import"./chunk-NTNPNLFT.js";import"./chunk-BYJ7FNFA.js";import"./chunk-PFRELWAV.js";import{b as Nt}from"./chunk-SZKZ3DG3.js";import"./chunk-SJ45VMIG.js";import{a as Ft}from"./chunk-2XFMMSIA.js";import{a as fe}from"./chunk-B4IA4XDT.js";import{a as vt}from"./chunk-MNSD5X74.js";import{I as At,Y as Pt,r as pt,t as ut,v as ft}from"./chunk-RU3S5WM7.js";import{$ as ge,$f as se,Ab as nt,Bb as it,Bf as Oe,C as $e,Db as ot,E as j,Eb as rt,Ed as St,Ee as h,Fa as D,Fb as at,Gc as pe,He as Ct,Ib as st,Ii as Lt,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,Nf as It,Nh as te,Of as bt,Pa as E,Pc as dt,Rf as yt,T as A,Ta as Ye,Ua as ne,Va as Ze,Xg as we,Y as Ie,Yg as Me,Yh as Rt,Zf as $,_a as W,_g as Dt,a as p,aa as We,ac as Te,b as S,bb as Qe,bi as X,ca as _,ci as G,db as ie,di as T,ei as wt,g as le,ha as b,ia as y,ja as Xe,jg as xe,jh as Ot,l as re,la as Ge,lb as x,lh as Le,li as K,mb as O,me as De,mi as J,nb as L,ng as Re,ni as Ne,o as Ue,ob as qe,oe as w,p as me,pc as ct,pe as Et,qa as Ke,r as P,sb as be,si as H,tb as ye,ti as Mt,ub as et,v as f,vb as oe,vh as M,w as de,wb as tt,wg as Tt,xb as R,yh as xt,yi as ue,zb as v}from"./chunk-FXUDI3M6.js";var k=(()=>{let l=class l{constructor(e,t,n,o,s,a,r,c,d,u,I,C,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=C,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(xt).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=yt(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(Ot))}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=>It(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 C=I.metadata?.documentId;return C&&(u[C]||(u[C]=[]),u[C].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(),C=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={};C&&z&&(Ce={top:z*n.topPercentage/100,left:C*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 $t={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=$t,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 C=e?this.getPointsForAreaPinAnnotation(e):t;c.targetElements=[],C.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}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(Nt,{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 Tt(10),t||""}else return""}catch(e){return this.loggingService.catch("Error in AreaService generateAreaAnnotationId: ",e),""}})}};l.\u0275fac=function(t){return new(t||l)(_(G),_(wt),_(ue),_(Mt),_(Lt),_(J),_(K),_(St),_(fe),_(Pt),_(T),_(kt),_(X))},l.\u0275prov=ge({token:l,factory:l.\u0275fac,providedIn:"root"});let m=l;return m})();var Ht=()=>({bottom:"calc(100% - 8px)",color:"green"});function Gt(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,Ht))("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 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.multiThreadCommentAnnotation==null?null:i.multiThreadCommentAnnotation.annotationId)),D(),U("left",8,"px"),x("ngStyle",Te(9,Ht))("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 Jt(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,Gt,2,10,"div",7)(8,Kt,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 Yt(m,l){if(m&1&&(be(0),W(1,Jt,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 C=this.domService.getElementFromXPath(a.targetElement),z=this.calculateResizingOffset(C);u=z.top,I=z.left}else{let C=this.componentConfigSignal().resizingOffset;u=C.top,I=C.left}this.componentConfigSignal.update(C=>(C=S(p({},C),{areaProperties:a,resizingOffset:{top:u,left:I},areaPinAnnotationOnResize:o}),C))}}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)(E(G),E(J),E(X),E(ue),E(K),E(k),E(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,Yt,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 Vt=(()=>{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)&&(Dt(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=bt(),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)(E(G),E(J),E(K),E(k),E(Vt),E(X),E(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"],qt=["*"];function en(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 tn(m,l){m&1&&et(0)}function nn(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)(E(G),E(J),E(k),E(fe),E(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:qt,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,en,3,2,"div",3),O(2,"div",4,0),W(4,tn,1,0,"ng-container",5),L()(),W(5,nn,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 Ft{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 Ut=(()=>{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,Bt]});let m=l;return m})();function on(m){m.get(T).log("%c[WB] Loading area feature chunk","color: blue;"),m.get(X).set(Rt,m.get(k));let t=Ye(Ut,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{on as default};
|
package/velt-arrow.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as zt,c as Gt,d as Xt}from"./chunk-TXOYHDVN.js";import{b as we}from"./chunk-ZVY2YW2G.js";import{a as ve}from"./chunk-6SOP2T3L.js";import{a as ut}from"./chunk-N4SGYLNB.js";import{a as Kt}from"./chunk-J6J7I3SW.js";import{Y as Zt,da as pt,ea as pe,ga as ue,r as Yt,t as Jt}from"./chunk-AOHSD4YE.js";import{$ as j,$f as ee,Ae as Et,Ag as bt,Ci as ge,Db as X,Dd as Qt,De as H,E as I,Eb as Y,Fa as O,Fb as J,G as Ot,Ga as at,Gc as ct,Gd as qt,Hi as de,Ii as he,J as F,Jb as K,Jh as se,Kb as N,Kc as $t,Kh as ce,L as St,Ma as Wt,Pa as p,Pc as lt,Pf as Ct,Qi as me,T as f,Te as d,Ua as k,We as gt,Ya as kt,_a as $,_b as Ut,a as w,ag as re,b as y,bb as Bt,bc as jt,bf as te,ca as v,db as B,dg as ie,g as At,ha as E,ia as C,ih as ht,ja as et,je as _,l as tt,la as Rt,lb as R,lh as ne,mb as W,mh as oe,nb as z,ng as dt,ni as mt,ob as st,oi as x,pb as rt,pi as A,qa as Mt,qb as Nt,qi as le,r as P,rb as Ht,sb as xt,tb as Vt,ua as Lt,ui as D,v as S,vb as G,vi as V,wa as ot,wb as Ft,xb as U,xg as yt,xh as ae,yb as Pt,zb as b}from"./chunk-JWLHBAMV.js";var M=(()=>{let s=class s{constructor(t,e,r,i,n,o,a,m,h,u,T,L){this.analyticsService=t,this.configService=e,this.docService=r,this.databaseService=i,this.authService=n,this.domService=o,this.afAuth=a,this.iamService=m,this.dialog=h,this.loggingService=u,this.serviceBook=T,this.commonDbService=L,this.arrowAnnotations$=new tt({}),this.arrowAnnotationsByDocumentId$=new tt({}),this.documentPaths=null,this.allowedElementIds$=new tt([]),this.addArrowMode$=new tt(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(I(g=>!!g),F(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addArrowMode$.value){let Z=!0,nt=this.domService.getBackgroundElement(g.clientX,g.clientY);nt&&(this.isElementInsideAllowedElements(nt)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==nt&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=nt,this.domService.highlightElement(this.highlightElement,d.CURSOR.ARROW_PIN),Z=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&Z&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},g=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addArrowMode$.value&&this.disableAddArrowMode()},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addArrowMode$.value){if(!bt(g.target)){let Z=this.domService.getBackgroundElement(g.clientX,g.clientY);Z&&this.isElementInsideAllowedElements(Z)&&(g.preventDefault(),g.stopPropagation(),this.addArrow(g))}this.disableAddArrowMode()}},g=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",g)}),this.addArrowMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(t,e,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let i,n;try{if(t&&(n=Ct(t)),e&&typeof e=="object"){let o=ie(e);i=Ct(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",o)}return qt(this.afAuth).pipe(I(o=>!!o),f(o=>this.isFeatureAllowed({firebaseUser:o,annotations:[],filteredAnnotations:[]})),f(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(S(a=>(o.featureAllowed=a,o))):P(o)),f(o=>o.featureAllowed?this.authService.isPlanExpired$().pipe(S(a=>(o.featureAllowed=!a,o))):P(o)),f(o=>o.featureAllowed?P(o).pipe(f(a=>this.docService.getDocumentPaths$().pipe(S(m=>(this.documentPaths=m,a.documentPaths=m,a)))),f(a=>this.getDataFromDocumentId(n).pipe(S(m=>(a.annotations=m||[],w({},a))))),f(a=>this.docService.getLocation$().pipe(S(m=>(a.location=m,a)))),f(a=>this.docService.getLocations$().pipe(S(m=>(a.customLocations=m,a)))),S(a=>{if(a.filteredAnnotations=[],n&&!i)return a.filteredAnnotations=a.annotations?.slice(),a;{let m=[];return i?m.push(i):(m.push(a?.location?.locationId),m.push(...Object.values(a?.customLocations||[]).map(h=>h.locationId))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,m),a}}),f(a=>r?P(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(S(()=>a)):P(a)),f(a=>r?P(a):a?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(S(()=>a)):P(a)),S(a=>(a?.filteredAnnotations?.forEach(m=>{this.calculateArrowAnnotationPosition(m)}),a)),f(a=>a?.filteredAnnotations?P(a?.filteredAnnotations||[]):P([]))):P([])),St(ae))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(I(e=>!!e),S(e=>y(w({},t),{config:e})),f(e=>this.authService.getUser$().pipe(S(r=>y(w({},e),{user:r})))),f(e=>ee(e.config,e.user,H.ARROW)?P(y(w({},e),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),P(y(w({},e),{featureAllowed:!1})))),St((e,r)=>e?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(I(e=>!!e),f(e=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(S(r=>({data:r?.data,operation:r?.operation})),S(({data:r,operation:i})=>{let n=[];return r&&(n=Object.values(r).filter(o=>typeof o=="object")),{data:n,operation:i}}),Ot(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),P({data:[],operation:null}))),S(({data:r,operation:i})=>{if(i?.type==="removed"){if(i?.ids?.length){let n=this.arrowAnnotationsByDocumentId$.value;i?.ids?.forEach(o=>{delete n?.[o]}),this.arrowAnnotationsByDocumentId$.next(n)}}else this.setArrowAnnotationsByDocumentId(t||this.documentPaths?.documentId,r);return r})):P([])))}setArrowAnnotationsByDocumentId(t,e){try{if(t){let r=y(w({},this.arrowAnnotationsByDocumentId$.value),{[t]:e});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(r=>e.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r&&dt(r)){let i=r.getBoundingClientRect();if(i&&i.width&&i.height){let{height:n,width:o}=ne(r);t.position={top:n*t.targetElement.topPercentage/100,left:o*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",e)}}addArrow(t){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new te;r.from=e,r.color=e?.color||d.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new gt;let i=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=i.screenWidth,r.props.screenHeight=i.screenHeight,r.props.screenScrollHeight=i.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=d.VELT_MIN_ARROW_LENGTH,(t?.clientX||0)>d.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,t&&(r.targetElement=this.domService.getTargetElementForCursorPosition(t)),r?.targetElement?.xpath){let n=this.domService.getXPath(r.targetElement.xpath);if(n){let o=n.iterateNext();o&&(dt(o)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=yt(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(e){this.loggingService.catch("Error in ArrowService addArrow: ",e)}}setLocationToArrowAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{if(t.targetElement?.xpath){let r=this.domService.getElementFromXPath(t.targetElement.xpath),i=this.docService.getAdditionLocationFromElement(r);if(i){let n=this.docService.addLocation({location:i,source:"internal"});n?.[0]&&(t.locationId=n[0].locationId,t.location=n[0].location)}}}catch{}}catch(e){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",e)}}saveArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.arrowUrl=this.generateArrowUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",e)}}updateArrow(t,e=!1,r){try{r&&this.setLocationToArrowAnnotation(t),e&&this.updateNotificationsDatabase(t,Et.UPDATED),this.updateArrowToDb(t)}catch(i){this.loggingService.catch("Error in ArrowService updateArrow: ",i)}}updateArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let r=e.iterateNext();r&&(dt(r)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",e)}}deleteArrowPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),i=[];Object.keys(e).forEach(n=>At(this,null,function*(){let o=e[n];if(o.type==="arrow"){let a=r&&!r?.isAnonymous&&!r?.isGuest;r&&o.from&&(a||o.from.userId===r.userId)&&i.push(o)}})),i?.length&&(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(n=>n.annotationId).join()}),this.dialog.open(we,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(F(1)).subscribe(n=>{n&&(i.forEach(o=>At(this,null,function*(){yield this.deleteArrowPinAnnotation(o)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(e){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",e)}}deleteArrowPinAnnotation(t){return this.authService.isFeatureAllowed(H.ARROW)&&this.documentPaths?.arrow&&t?.annotationId?(this.updateNotificationsDatabase(t,Et.DELETED),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(H.ARROW)?(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(t){try{return this.domService.isElementInsideListedElementIds(t,this.allowedElementIds$.value)}catch(e){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",e),!1}}updateNotificationsDatabase(t,e){try{let r={annotationData:t,actionType:e,notificationSource:"arrow"};this.serviceBook.get(ce)?.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(t){try{return t?.pageInfo?.arrowUrl?t.pageInfo.arrowUrl:(t?.pageInfo||(t.pageInfo=yt(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.arrowUrl=this.generateArrowUrl(t),this.updateArrow(t),t.pageInfo?.arrowUrl)}catch(e){this.loggingService.catch("Error in ArrowService getArrowUrl: ",e);return}}generateArrowUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(r){this.loggingService.catch("Error in ArrowService generateArrowUrl: ",r),e=new URL(window.location.href)}return e.searchParams.delete(d.URL_PARAMS.TAG_ID),e.searchParams.append(d.URL_PARAMS.TAG_ID,t.annotationId),e.href}};s.\u0275fac=function(e){return new(e||s)(v(x),v(le),v(de),v(ge),v(V),v(D),v(Qt),v(ut),v(Zt),v(A),v(mt),v(me))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var ye=["handle"],be=["arrowRef"],Ie=["headRef"],_e=l=>({transform:l});function De(l,s){if(l&1){let c=G();W(0,"div",8,2),U("cdkDragStarted",function(e){E(c);let r=b();return C(r.onDragStarted(e))})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onDragMoved(e))})("cdkDragReleased",function(e){E(c);let r=b();return C(r.onDragReleased(e))}),et(),W(2,"svg",9),st(3,"path",10)(4,"path",11),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing),R("cdkDragRootElement","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId))("cdkDragDisabled",!c.isEditable||c.isResizing)}}function Te(l,s){if(l&1){let c=G();W(0,"div",12,2),U("cdkDragStarted",function(){E(c);let e=b();return C(e.onResizeHandleDragStarted())})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onResizeHandleDragMoved(e))})("cdkDragReleased",function(){E(c);let e=b();return C(e.onResizeHandleDragReleased())}),et(),W(2,"svg",13),st(3,"path",14),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing)}}var fe=(()=>{let s=class s{get arrowPinAnnotation(){return this._arrowPinAnnotation}set arrowPinAnnotation(t){this._arrowPinAnnotation=t,this.updatedArrowAngle&&this.arrowPinAnnotation?.props&&(this.arrowPinAnnotation.props.arrowAngle=this.updatedArrowAngle),this.calculateArrowWidthBasedOnViewport()}get arrowPinSelected(){return this._arrowPinSelected}set arrowPinSelected(t){this._arrowPinSelected=t,this.updateHighlightOnElement()}get arrowPinHover(){return this._arrowPinHover}set arrowPinHover(t){this._arrowPinHover=t,this.updateHighlightOnElement()}constructor(t,e,r,i){this.arrowService=t,this.domService=e,this.loggingService=r,this.elementRef=i,this._arrowPinSelected=!1,this.multipleArrowPinsSelected=!1,this.dragStarted=new at,this.dragMoved=new at,this.dragReleased=new at,this._arrowPinHover=!1,this.subscriptions=[],this.veltElement=!0,this.isDragging=!1,this.isResizing=!1,this.isEditable=!1,this.centerX=0,this.centerY=0,this.newAngle=0,this.newWidth=0,this.updatedArrowAngle=0,this.MIN_ARROW_LENGTH=d.VELT_MIN_ARROW_LENGTH,this.pointerEventSubscriptions=[],this.loggingService.log("%c[WB] Creating COMPONENT ArrowPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),setTimeout(()=>{this.calculateArrowWidthBasedOnViewport()},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent AfterViewInit: ",t)}}ngOnChanges(t){try{t.arrowPinAnnotation&&this.checkIsEditable(),t.user&&this.checkIsEditable()}catch(e){this.loggingService.catch("Error in ArrowPinComponent ngOnChanges: ",e)}}checkIsEditable(){try{this.user?.userId===this.arrowPinAnnotation?.from?.userId?this.isEditable=!0:this.user&&!this.user.isAnonymous&&!this.user.isGuest?this.isEditable=!0:this.isEditable=!1}catch(t){this.loggingService.catch("Error in ArrowPinComponent checkIsEditable: ",t)}}onResizeHandleDragStarted(){try{this.isResizing||(this.updatedArrowAngle=0,this.updateCenter(),this.isResizing=!0)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragStarted: ",t)}}onResizeHandleDragMoved(t){try{let e=t.event;if(!this.isResizing||!this.isWithinViewport(e))return;let r=this.getAngleAndDistanceFromMouseEvent(e);this.newAngle=r.angle,this.newWidth=Math.min(r.distance,this.getMaxAllowedArrowLength()),e.stopPropagation()}catch(e){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragMoved: ",e)}}onResizeHandleDragReleased(){try{this.isResizing=!1,this.updateArrowPinAnnotationProps(),setTimeout(()=>{this.newAngle=0,this.newWidth=0},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragReleased: ",t)}}updateCenter(){try{let t=this.elementRef.nativeElement.getBoundingClientRect();this.centerX=t.x,this.centerY=t.y}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateCenter: ",t)}}getAngleAndDistanceFromMouseEvent(t){try{let e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,r=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,i=e-this.centerX,n=r-this.centerY,a=Math.atan2(n,i)*(180/Math.PI);a=a<0?a+360:a;let m=Math.sqrt(i*i+n*n);return{angle:a,distance:m}}catch(e){return this.loggingService.catch("Error in ArrowPinComponent getAngleAndDistanceFromMouseEvent: ",e),{angle:0,distance:0}}}isWithinViewport(t){try{return typeof TouchEvent<"u"&&t instanceof TouchEvent?t.touches[0].clientX>=0&&t.touches[0].clientX<=window?.innerWidth&&t.touches[0].clientY>=0&&t.touches[0].clientY<=window?.innerHeight:t.clientX>=0&&t.clientX<=window?.innerWidth&&t.clientY>=0&&t.clientY<=window?.innerHeight}catch(e){return this.loggingService.catch("Error in ArrowPinComponent isWithinViewport: ",e),!1}}calculateArrowWidthBasedOnViewport(){try{if(this.isDragging)return;if(this.arrowPinAnnotation?.props){let t=this.arrowPinAnnotation.props.viewportWidth||0,e=this.arrowPinAnnotation.props.viewportHeight||0,r=window.innerWidth,i=window.innerHeight;this.arrowPinAnnotation.props.arrowLength||(this.arrowPinAnnotation.props.arrowLength=0);let n=(this.arrowPinAnnotation.props.arrowAngle||0)%360;n>45&&n<135||n>225&&n<315?e>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*i/e):t>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*r/t);let o=this.arrowRef?.nativeElement?.getBoundingClientRect();if(o){n<0&&(n=360+n);let a=n,m=n>90&&n<=180,h=n>180&&n<=270,u=r-o.x;(m||h)&&(u=o.right,a=180-n);let T=ht(u-d.VELT_ARROW_VIEWPORT_PADDING,a);if(T>0&&this.arrowPinAnnotation.props.arrowLength>T)if(T<this.MIN_ARROW_LENGTH){let L=(this.arrowPinAnnotation.props.arrowAngle||0)%360;L>=90&&L<=270?this.updatedArrowAngle=45:this.updatedArrowAngle=135,this.arrowPinAnnotation.props.arrowLength=this.MIN_ARROW_LENGTH}else this.arrowPinAnnotation.props.arrowLength=T}this.arrowPinAnnotation.props.arrowLength=Math.min(this.arrowPinAnnotation.props.arrowLength,this.getMaxAllowedArrowLength())}}catch(t){this.loggingService.catch("Error in ArrowPinComponent calculateArrowWidthBasedOnViewport: ",t)}}getMaxAllowedArrowLength(){try{return Math.max(window.innerWidth,window.innerHeight)*.8}catch(t){return this.loggingService.catch("Error in ArrowPinComponent getMaxAllowedArrowLength: ",t),0}}updateHighlightOnElement(){try{this.targetElement&&(this.arrowPinSelected||this.arrowPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateHighlightOnElement: ",t)}}updateArrowPinAnnotationProps(){try{this.arrowPinAnnotation?.props||(this.arrowPinAnnotation.props=new gt),this.arrowPinAnnotation.props.viewportWidth=window.innerWidth,this.arrowPinAnnotation.props.viewportHeight=window.innerHeight,this.arrowPinAnnotation.props.arrowAngle=this.newAngle,this.arrowPinAnnotation.props.arrowLength=this.newWidth,this.arrowService.updateArrow(this.arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateArrowPinAnnotation: ",t)}}onPointerOver(t){try{t.buttons?this.arrowPinHover&&(this.arrowPinHover=!1):this.arrowPinHover||(this.arrowPinHover=!0)}catch(e){this.loggingService.catch("Error in ArrowPinComponent onPointerOver: ",e)}}onDragStarted(t){this.isDragging=!0,this.dragStarted.emit(t)}onDragMoved(t){this.dragMoved.emit(t)}onDragReleased(t){this.isDragging=!1,this.dragReleased.emit(t)}onPointerOut(){this.arrowPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowPinComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(M),p(D),p(A),p(ot))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin"]],viewQuery:function(e,r){if(e&1&&(X(ye,5),X(be,5),X(Ie,5)),e&2){let i;Y(i=J())&&(r.handle=i.first),Y(i=J())&&(r.arrowRef=i.first),Y(i=J())&&(r.headRef=i.first)}},hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},inputs:{arrowPinAnnotation:"arrowPinAnnotation",arrowPinSelected:"arrowPinSelected",multipleArrowPinsSelected:"multipleArrowPinsSelected",user:"user",targetElement:"targetElement"},outputs:{dragStarted:"dragStarted",dragMoved:"dragMoved",dragReleased:"dragReleased"},features:[Lt],decls:7,vars:15,consts:[["arrowRef",""],["headRef",""],["handle",""],[1,"s-arrow-annotation",3,"pointerover","pointerout","click","ngStyle"],["class","s-arrow-annotation-drag-handle","cdkDrag","","cdkDragHandle","",3,"s-arrow-annotation-handle-dragging","cdkDragRootElement","cdkDragDisabled","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],[1,"s-arrow-annotation-head"],[1,"s-arrow-annotation-line"],["class","s-arrow-annotation-handle","cdkDrag","",3,"s-arrow-annotation-handle-dragging","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"s-arrow-annotation-drag-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased","cdkDragRootElement","cdkDragDisabled"],["width","32","height","32","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M18.0039 5.99219H14.4039M18.0039 5.99219V9.59219M18.0039 5.99219L13.8039 10.1922M6.00391 17.9922H9.60391M6.00391 17.9922V14.3922M6.00391 17.9922L10.2039 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["d","M6 5.99219H9.6M6 5.99219V9.59219M6 5.99219L10.2 10.1922M18 17.9922H14.4M18 17.9922V14.3922M18 17.9922L13.8 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["cdkDrag","",1,"s-arrow-annotation-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased"],["width","16","height","16","viewBox","0 0 10 10","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M1 5C1 3.11438 1 2.17157 1.58579 1.58579C2.17157 1 3.11438 1 5 1C6.88562 1 7.82843 1 8.41421 1.58579C9 2.17157 9 3.11438 9 5C9 6.88562 9 7.82843 8.41421 8.41421C7.82843 9 6.88562 9 5 9C3.11438 9 2.17157 9 1.58579 8.41421C1 7.82843 1 6.88562 1 5Z","stroke","#0093FF","stroke-width","1.5"]],template:function(e,r){if(e&1){let i=G();W(0,"div",3,0),U("pointerover",function(o){return E(i),C(r.onPointerOver(o))})("pointerout",function(){return E(i),C(r.onPointerOut())})("click",function(o){return E(i),C(o.preventDefault())}),$(2,De,5,4,"div",4),st(3,"div",5,1)(5,"div",6),$(6,Te,4,2,"div",7),z()}e&2&&(K("width",r.newWidth||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowLength)||r.MIN_ARROW_LENGTH,"px"),N("s-arrow-annotation-selected",r.arrowPinSelected)("s-arrow-annotation-draggable",r.isEditable),R("ngStyle",jt(13,_e,"rotate("+(r.newAngle||r.updatedArrowAngle||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowAngle)||0)+"deg)")),O(2),R("ngIf",r.isEditable),O(),K("border-right-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(2),K("background-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(),R("ngIf",r.isEditable))},dependencies:[lt,ct,$t,Xt,Gt,zt],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}.s-arrow-annotation[_ngcontent-%COMP%]{position:absolute!important;z-index:20!important;height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;left:50%!important;top:50%!important;display:flex!important;align-items:center!important;justify-content:flex-end!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-line[_ngcontent-%COMP%]{height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;width:100%!important;background-color:#625df5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-head[_ngcontent-%COMP%]{width:0!important;height:0!important;border-top:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-bottom:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-right:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid #625DF5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%]{transform:none!important;cursor:move!important;display:flex!important;position:absolute!important;left:-20px!important;opacity:0!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{transform:none!important;display:flex!important;opacity:0!important;cursor:grab!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;height:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle.s-arrow-annotation-handle-dragging[_ngcontent-%COMP%]{cursor:grabbing!important}.s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{opacity:1!important}"],changeDetection:0});let l=s;return l})();var Oe=["arrowPinRef"];function Re(l,s){if(l&1){let c=G();W(0,"div",3),U("pointerup",function(e){return E(c),b(2).togglePinSelection(),C(e.stopPropagation())})("pointerdown",function(e){return E(c),C(e.stopPropagation())})("click",function(e){return E(c),C(e.stopPropagation())}),W(1,"snippyly-arrow-pin",4,0),U("dragStarted",function(){E(c);let e=b(2);return C(e.onPinDragStart())})("dragMoved",function(e){E(c);let r=b(2);return C(r.onPinMove(e))})("dragReleased",function(){E(c);let e=b(2);return C(e.onPinRelease())}),z()()}if(l&2){let c=b().ngIf,t=b();K("top",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.top:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.top)+c.offsetTop,"px")("left",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.left:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.left)+c.offsetLeft,"px"),N("pin-dragging",c.annotationDragging),R("id","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId)),O(),R("arrowPinAnnotation",c.arrowPinAnnotation)("arrowPinSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&!c.annotationDragging&&t.objectKeys(c.selectedAnnotationsMap).length===1)("multipleArrowPinsSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&t.objectKeys(c.selectedAnnotationsMap).length>1)("targetElement",c.targetElement)("user",c.user)}}function Me(l,s){if(l&1&&(xt(0),$(1,Re,3,12,"div",2),Vt()),l&2){let c=s.ngIf;O(),R("ngIf",c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.position)}}var Ae=(()=>{let s=class s{constructor(t,e,r,i,n){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.loggingService=n,this.multipleArrowPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.componentConfigSignal=Mt({arrowPinAnnotation:void 0,annotationDragging:!1,dragPosition:null,offsetTop:0,offsetLeft:0,selectedAnnotationsMap:{},targetElement:void 0,user:void 0}),this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{user:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getUser$ subscription: ",o)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{selectedAnnotationsMap:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getSelectedAnnotationsMap$ subscription: ",o)}))}ngOnInit(){}setArrowPinAnnotation(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{arrowPinAnnotation:t}),e)),this.id=this.componentConfigSignal().arrowPinAnnotation?.annotationId}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setArrowPinAnnotation: ",e)}}setTargetElement(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{targetElement:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setTargetElement: ",e)}}setOffsetLeft(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetLeft:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetLeft: ",e)}}setOffsetTop(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetTop:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetTop: ",e)}}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().arrowPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation);let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,t.style.opacity="0",document.body.appendChild(t)),this.componentConfigSignal.update(e=>(e=y(w({},e),{annotationDragging:!0}),e)),setTimeout(()=>{t&&(t.style.opacity="1")},50)}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let e=t.event,r=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,n=this.domService.getBackgroundElement(r,i);n&&(this.componentConfigSignal.update(o=>(o=y(w({},o),{targetElement:n}),o)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=t.event,this.componentConfigSignal.update(o=>(o=y(w({},o),{dragPosition:{top:i,left:r}}),o)))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath);if(this.pointerMoveEvent){this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent),h));let n=this.pointerMoveEvent,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,a=!1;if(o<d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;h>=90&&h<=270&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=45,u)),a=!0)}if(o>window?.innerWidth-d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;(h>=270&&h<=360||h>=0&&h<=90)&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=135,u)),a=!0)}if(!a){let h=o,u=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;u>=0&&u<=90||u>=270&&u<=360?h=window.innerWidth-o:u=180-u;let T=ht(h-d.VELT_ARROW_VIEWPORT_PADDING,u);T>0&&T<(this.componentConfigSignal().arrowPinAnnotation.props.arrowLength||0)&&this.componentConfigSignal.update(L=>(L=w({},L),L.arrowPinAnnotation.props.arrowLength=T,L))}let m=this.domService.getCurrentWindowSizeValue();this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.props.screenWidth=m.screenWidth,h.arrowPinAnnotation.props.screenHeight=m.screenHeight,h.arrowPinAnnotation.props.screenScrollHeight=m.screenScrollHeight,h.arrowPinAnnotation.props.viewportWidth=window.innerWidth,h.arrowPinAnnotation.props.viewportHeight=window.innerHeight,h))}let r=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(r);this.arrowService.updateArrow(this.componentConfigSignal().arrowPinAnnotation,!1,i),setTimeout(()=>{this.componentConfigSignal.update(n=>(n=w({},n),n.annotationDragging=!1,n.dragPosition=null,n)),this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement),this.arrowPinRef&&(this.arrowPinRef.updatedArrowAngle=0)},100),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAGGED,{annotationId:this.componentConfigSignal().arrowPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent onPinRelease: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin-portal"]],viewQuery:function(e,r){if(e&1&&X(Oe,5),e&2){let i;Y(i=J())&&(r.arrowPinRef=i.first)}},hostVars:2,hostBindings:function(e,r){e&2&&(Ft("id",r.id),B("data-velt-element",r.veltElement))},inputs:{multipleArrowPinsSelected:"multipleArrowPinsSelected",avatarErrorImage:"avatarErrorImage"},decls:1,vars:1,consts:[["arrowPinRef",""],[4,"ngIf"],["class","arrow-pin-portal",3,"id","pin-dragging","top","left","pointerup","pointerdown","click",4,"ngIf"],[1,"arrow-pin-portal",3,"pointerup","pointerdown","click","id"],[3,"dragStarted","dragMoved","dragReleased","arrowPinAnnotation","arrowPinSelected","multipleArrowPinsSelected","targetElement","user"]],template:function(e,r){e&1&&$(0,Me,2,1,"ng-container",1),e&2&&R("ngIf",r.componentConfigSignal())},dependencies:[lt,ct,fe],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}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.arrow-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;top:0;left:0}.arrow-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-arrow-z-index)!important}"],changeDetection:0});let l=s;return l})();var Se=(()=>{let s=class s{constructor(t,e,r,i,n){this.domService=t,this.componentFactoryResolver=e,this.injector=r,this.appRef=i,this.loggingService=n,this.arrowsPinById={}}setArrowPin(t){try{if(!this.arrowsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.arrowsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.arrowsPinById[t.annotationId].portalRef,r=this.arrowsPinById[t.annotationId].userTargetElement,i=this.arrowsPinById[t.annotationId].pinHostElement;if(document.body.contains(r)&&document.body.contains(i))e&&(e.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),this.updateElementOffset(t));else{let n=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;n&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),n.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),e.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setArrowPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r){let i=this.domService.getHostElement(r),n=new Yt(Ae),o=new Jt(i,this.appRef,this.injector),a=o.attach(n);a.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),a.instance.setTargetElement(r),this.arrowsPinById[t.annotationId]={pinHostDomPortalOutlet:o,pinPortal:n,portalRef:a,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:r,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(oe(i)||i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:r,pinHostElement:i}=this.arrowsPinById[t.annotationId],n=this.domService.getElementOffset(r,i);e.instance.setOffsetLeft(n.offsetLeft),e.instance.setOffsetTop(n.offsetTop)}catch(e){this.loggingService.catch("Error in ArrowPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(r=>r.annotationId);Object.keys(this.arrowsPinById).forEach(r=>{if(!e.includes(r)){let i=this.arrowsPinById[r];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.arrowsPinById[r]}})}catch(e){this.loggingService.catch("Error in ArrowPinPortalService checkPinsToRemove: ",e)}}};s.\u0275fac=function(e){return new(e||s)(v(D),v(Wt),v(Rt),v(Bt),v(A))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Dt=(()=>{let s=class s{constructor(t,e,r,i,n,o){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.arrowPinPortalService=n,this.loggingService=o,this.arrowPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.veltId=re(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: ArrowsContainerComponent","color: blue;")}catch(a){this.loggingService.catch("Error in ArrowsContainerComponent constructor: ",a)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_ARROWS),e=document.querySelector(d.TAGS.VELT_ARROWS);e?this.veltId===e?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===t?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(I(t=>!!t)).subscribe(t=>{t&&this.setArrowInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.getAllArrowsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent initComponent: ",t)}}getAllArrowsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.arrowService.getAllArrowAnnotations().pipe(I(t=>!!t),f(t=>this.domService.getSelectedAnnotationsMap$().pipe(S(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.arrowPinAnnotations=t?.annotations;let e=this.arrowPinAnnotations.filter(r=>r.targetElement);this.arrowPinPortalService.checkPinsToRemove(e),e.forEach(r=>{this.arrowPinPortalService.setArrowPin(r)})}catch(e){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent unsubscribe: ",t)}}setArrowInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(H.ARROW)}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent setArrowInstalledInAnalytics: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(Se),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-container"]],hostVars:2,hostBindings:function(e,r){e&2&&B("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},decls:0,vars:0,template:function(e,r){},encapsulation:2,changeDetection:0});let l=s;return l})();var Tt=(()=>{let s=class s extends ue{constructor(t,e,r,i,n,o,a,m,h){super(a,o,void 0,void 0,void 0,m,n),this.analyticsService=t,this.authService=e,this.arrowService=r,this.iamService=i,this.loggingService=n,this.themeService=o,this.elementRef=a,this.dynamicDataService=m,this.domService=h,this.customButtonAdded=!1,this.disabled=!1,this.addArrowMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(u=>{this.user=u},u=>{this.loggingService.catch("Error in ArrowsToolComponent getUser$ subscription: ",u)}))}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef)),this.subscriptions.push(this.arrowService.addArrowModeChange().subscribe(t=>{this.addArrowMode=t})),this.subscriptions.push(this.iamService.getFeaturesAccessLevel$().subscribe(t=>{this.disabled=!!t?.all?.disabled}))}catch(t){this.loggingService.catch("Error in ArrowsToolComponent AfterViewInit: ",t)}}onButtonSlotChange(){this.customButtonAdded=!0}addArrow(){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{if(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_TOOL_CLICKED,{toolType:this.customButtonAdded?"custom":"default"}),this.user){if(this.disabled){this.loggingService.catch("Arrows are disabled.");return}this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add arrows."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.arrowService.enableAddArrowMode():this.loggingService.catch("User does not have permission to add arrows.")}else this.loggingService.catch("Velt sdk not authenticated.")}catch(t){this.loggingService.catch("Error in ArrowsToolComponent addArrow: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsToolComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowsToolComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(M),p(ut),p(A),p(pe),p(ot),p(pt),p(D))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-tool"]],hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},features:[Ut([pt]),kt],decls:5,vars:2,consts:[["part","container",1,"snippyly-arrow-btn-container",3,"click"],["name","button",3,"slotchange"],["part","button-container","tabindex","0",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M17.5 7L7.5 17M17.5 7H10M17.5 7V14.5","stroke","currentColor","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(e,r){e&1&&(rt(0,"div",0),Pt("click",function(n){return r.addArrow(),n.stopPropagation()}),rt(1,"slot",1),Pt("slotchange",function(){return r.onButtonSlotChange()}),rt(2,"div",2),et(),rt(3,"svg",3),Ht(4,"path",4),Nt()()()()),e&2&&(O(2),N("active",r.addArrowMode))},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}*{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;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert!important}.snippyly-arrow-btn-container{display:inline-block}.action-btn{display:flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color)}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-active-icon-color)}
|
|
2
|
-
`],encapsulation:3,changeDetection:0});let l=s;return l})();var vt=class extends
|
|
1
|
+
import{b as zt,c as Gt,d as Xt}from"./chunk-RFCFKIUM.js";import{b as ue}from"./chunk-SZKZ3DG3.js";import{a as we}from"./chunk-2XFMMSIA.js";import{a as ut}from"./chunk-B4IA4XDT.js";import{a as Kt}from"./chunk-MNSD5X74.js";import{Y as qt,da as pt,ea as me,ga as pe,r as Yt,t as Jt}from"./chunk-RU3S5WM7.js";import{$ as j,$f as dt,Bf as Ct,Db as X,E as I,Eb as Y,Ed as Qt,Ee as d,Fa as O,Fb as J,G as Ot,Ga as at,Gc as ct,He as gt,Ii as he,J as F,Jb as K,Kb as N,Kc as $t,L as St,Ma as Wt,Ne as Zt,Nf as te,Of as ee,Pa as p,Pc as lt,Rf as re,T as f,Ua as k,Wg as ht,Ya as kt,Zg as ie,_a as $,_b as Ut,_g as ne,a as w,b as y,bb as Bt,bc as jt,bi as mt,ca as v,ci as x,db as B,di as A,ei as ce,g as At,ha as E,ia as C,ja as et,jg as yt,jh as oe,l as tt,la as Rt,lb as R,le as Et,li as D,mb as W,mg as bt,mi as V,nb as z,ob as st,oe as H,pb as rt,qa as Mt,qb as Nt,r as P,rb as Ht,sb as xt,tb as Vt,ti as le,ua as Lt,v as S,vb as G,vh as _,wa as ot,wb as Ft,xb as U,xh as ae,yb as Pt,yh as se,yi as ge,zb as b,zi as de}from"./chunk-FXUDI3M6.js";var M=(()=>{let s=class s{constructor(t,e,r,i,n,o,a,m,h,u,T,L){this.analyticsService=t,this.configService=e,this.docService=r,this.databaseService=i,this.authService=n,this.domService=o,this.afAuth=a,this.iamService=m,this.dialog=h,this.loggingService=u,this.serviceBook=T,this.commonDbService=L,this.arrowAnnotations$=new tt({}),this.arrowAnnotationsByDocumentId$=new tt({}),this.documentPaths=null,this.allowedElementIds$=new tt([]),this.addArrowMode$=new tt(!1),this.loggingService.log("%c[WB] Creating CLASS: ArrowService","color: blue;"),this.databaseService.getDb().pipe(I(g=>!!g),F(1)).subscribe(g=>{g&&this.getDocumentPaths()},g=>{this.loggingService.catch("Error in ArrowService getDb subscription: ",g)}),this.domService.onWindowPointerMove$().subscribe(g=>{if(this.addArrowMode$.value){let Z=!0,nt=this.domService.getBackgroundElement(g.clientX,g.clientY);nt&&(this.isElementInsideAllowedElements(nt)?bt(g.target)?this.domService.removeClassFromElement(document.body,"show-pin-cursor"):(this.domService.addClassToElement(document.body,"show-pin-cursor"),this.highlightElement&&this.highlightElement!==nt&&this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=nt,this.domService.highlightElement(this.highlightElement,d.CURSOR.ARROW_PIN),Z=!1):this.domService.removeClassFromElement(document.body,"show-pin-cursor")),this.highlightElement&&Z&&(this.domService.removeHighlightFromElement(this.highlightElement),this.highlightElement=null)}},g=>{this.loggingService.catch("Error in ArrowService onWindowPointerMove$ subscription: ",g)}),this.domService.onWindowKeyupEsc$().subscribe(g=>{this.addArrowMode$.value&&this.disableAddArrowMode()},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupEsc$ subscription: ",g)}),this.domService.onDocumentClick$().subscribe(g=>{if(g&&this.addArrowMode$.value){if(!bt(g.target)){let Z=this.domService.getBackgroundElement(g.clientX,g.clientY);Z&&this.isElementInsideAllowedElements(Z)&&(g.preventDefault(),g.stopPropagation(),this.addArrow(g))}this.disableAddArrowMode()}},g=>{this.loggingService.catch("Error in ArrowService onDocumentClick$ subscription: ",g)}),this.addArrowMode$.subscribe(g=>{this.highlightElement&&this.domService.removeHighlightFromElement(this.highlightElement),g?this.domService.addClassToElement(document.body,"snippyly-add-arrow-mode"):(this.domService.removeClassFromElement(document.body,"snippyly-add-arrow-mode"),this.domService.removeClassFromElement(document.body,"show-pin-cursor"))},g=>{this.loggingService.catch("Error in ArrowService addArrowMode$ subscription: ",g)}),this.domService.onWindowKeyupBackspace$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupBackspace")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupBackspace$ subscription: ",g)}),this.domService.onWindowKeyupDelete$().subscribe(g=>{this.deleteArrowPinAnnotations("keyupDelete")},g=>{this.loggingService.catch("Error in ArrowService onWindowKeyupDelete$ subscription: ",g)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$()}setAllowedElementIds(t){this.allowedElementIds$.next(t||[])}getAllowedElementIds(){return this.allowedElementIds$.asObservable()}getAllArrowAnnotations(t,e,r){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowAnnotations","color: green;");let i,n;try{if(t&&(n=Ct(t)),e&&typeof e=="object"){let o=re(e);i=Ct(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ArrowService getAllArrowAnnotations: ",o)}return this.authService.getAuthState$().pipe(I(o=>!!o),f(o=>this.isFeatureAllowed({firebaseUser:o,annotations:[],filteredAnnotations:[]})),f(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(S(a=>(o.featureAllowed=a,o))):P(o)),f(o=>o.featureAllowed?this.authService.isPlanExpired$().pipe(S(a=>(o.featureAllowed=!a,o))):P(o)),f(o=>o.featureAllowed?P(o).pipe(f(a=>this.docService.getDocumentPaths$().pipe(S(m=>(this.documentPaths=m,a.documentPaths=m,a)))),f(a=>this.getDataFromDocumentId(n).pipe(S(m=>(a.annotations=m||[],w({},a))))),f(a=>this.docService.getLocation$().pipe(S(m=>(a.location=m,a)))),f(a=>this.docService.getLocations$().pipe(S(m=>(a.customLocations=m,a)))),S(a=>{if(a.filteredAnnotations=[],n&&!i)return a.filteredAnnotations=a.annotations?.slice(),a;{let m=[];return i?m.push(i):(m.push(a?.location?.locationId),m.push(...Object.values(a?.customLocations||[]).map(h=>h.locationId))),a.filteredAnnotations=this.filterAnnotationsByLocationIds(a?.annotations,m),a}}),f(a=>r?P(a):a?.annotations?.length?this.domService.onWindowResize$().pipe(S(()=>a)):P(a)),f(a=>r?P(a):a?.annotations?.length?this.domService.onDomChange$("ArrowService getAllArrowAnnotations").pipe(S(()=>a)):P(a)),S(a=>(a?.filteredAnnotations?.forEach(m=>{this.calculateArrowAnnotationPosition(m)}),a)),f(a=>a?.filteredAnnotations?P(a?.filteredAnnotations||[]):P([]))):P([])),St(oe))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(I(e=>!!e),S(e=>y(w({},t),{config:e})),f(e=>this.authService.getUser$().pipe(S(r=>y(w({},e),{user:r})))),f(e=>te(e.config,e.user,H.ARROW)?P(y(w({},e),{featureAllowed:!0})):(this.loggingService.warn("Arrow feature is not allowed."),P(y(w({},e),{featureAllowed:!1})))),St((e,r)=>e?.featureAllowed===r?.featureAllowed))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(I(e=>!!e),f(e=>this.configService.getApiKey()&&this.documentPaths?.arrow&&this.documentPaths?this.commonDbService.dbListener({feature:"allArrows",properties:{documentId:t??this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,skipFirestore:!0}}).pipe(S(r=>({data:r?.data,operation:r?.operation})),S(({data:r,operation:i})=>{let n=[];return r&&(n=Object.values(r).filter(o=>typeof o=="object")),{data:n,operation:i}}),Ot(r=>(this.loggingService.catch("Error in ArrowService getDataFromDocumentId: ",r),P({data:[],operation:null}))),S(({data:r,operation:i})=>{if(i?.type==="removed"){if(i?.ids?.length){let n=this.arrowAnnotationsByDocumentId$.value;i?.ids?.forEach(o=>{delete n?.[o]}),this.arrowAnnotationsByDocumentId$.next(n)}}else this.setArrowAnnotationsByDocumentId(t||this.documentPaths?.documentId,r);return r})):P([])))}setArrowAnnotationsByDocumentId(t,e){try{if(t){let r=y(w({},this.arrowAnnotationsByDocumentId$.value),{[t]:e});this.arrowAnnotationsByDocumentId$.next(r)}}catch(r){this.loggingService.catch("Error in ArrowService setArrowAnnotationsByDocumentId:",r)}}filterAnnotationsByLocationIds(t,e){try{return t.filter(r=>e.includes(r.locationId))}catch(r){return this.loggingService.catch("Error in ArrowService filterAnnotationsByLocations:",r),[]}}calculateArrowAnnotationPosition(t){try{if(t.targetElement){let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r&&dt(r)){let i=r.getBoundingClientRect();if(i&&i.width&&i.height){let{height:n,width:o}=ie(r);t.position={top:n*t.targetElement.topPercentage/100,left:o*t.targetElement.leftPercentage/100}}else t.position=null}else t.position=null}else t.position=null}}catch(e){this.loggingService.catch("Error in ArrowService calculateArrowAnnotationPosition:",e)}}addArrow(t){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{let e=this.authService.getUser();if(e)if(e.isReadOnly||e.isAnonymous)this.loggingService.catch("Anonymous/Readonly users cannot add arrows.");else{let r=new Zt;r.from=e,r.color=e?.color||d.DEFAULT_ANNOTATION_COLOR,r.lastUpdated=this.timestamp,r.props=new gt;let i=this.domService.getCurrentWindowSizeValue();if(r.props.screenWidth=i.screenWidth,r.props.screenHeight=i.screenHeight,r.props.screenScrollHeight=i.screenScrollHeight,r.props.viewportWidth=window.innerWidth,r.props.viewportHeight=window.innerHeight,r.props.arrowLength=d.VELT_MIN_ARROW_LENGTH,(t?.clientX||0)>d.VELT_MIN_ARROW_LENGTH?r.props.arrowAngle=135:r.props.arrowAngle=45,t&&(r.targetElement=this.domService.getTargetElementForCursorPosition(t)),r?.targetElement?.xpath){let n=this.domService.getXPath(r.targetElement.xpath);if(n){let o=n.iterateNext();o&&(dt(o)||(r.targetElement=null))}}this.setLocationToArrowAnnotation(r),r.pageInfo=yt(),r.pageInfo&&(r.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth),this.saveArrowToDb(r)}}catch(e){this.loggingService.catch("Error in ArrowService addArrow: ",e)}}setLocationToArrowAnnotation(t){try{let e=this.docService.getLocation();e?(t.locationId=e.locationId,t.location=e.location):(delete t.locationId,delete t.location);try{if(t.targetElement?.xpath){let r=this.domService.getElementFromXPath(t.targetElement.xpath),i=this.docService.getAdditionLocationFromElement(r);if(i){let n=this.docService.addLocation({location:i,source:"internal"});n?.[0]&&(t.locationId=n[0].locationId,t.location=n[0].location)}}}catch{}}catch(e){this.loggingService.catch("Error in ArrowService setLocationToArrowAnnotation:",e)}}saveArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: saveArrowToDb","color: green;");try{this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow){t.annotationId=this.commonDbService.generateDocumentId(),t.pageInfo&&(t.pageInfo.arrowUrl=this.generateArrowUrl(t));let i=JSON.parse(JSON.stringify(t));return i.position=null,this.domService.toggleAnnotationSelection(i),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAFT_ADDED,{annotationId:t.annotationId}),this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService saveArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService saveArrowToDb: ",e)}}updateArrow(t,e=!1,r){try{r&&this.setLocationToArrowAnnotation(t),e&&this.updateNotificationsDatabase(t,Et.UPDATED),this.updateArrowToDb(t)}catch(i){this.loggingService.catch("Error in ArrowService updateArrow: ",i)}}updateArrowToDb(t){this.loggingService.log("%c[WB] Calling FUNCTION: updateArrowToDb","color: green;");try{if(t?.targetElement?.xpath){let e=this.domService.getXPath(t.targetElement.xpath);if(e){let r=e.iterateNext();r&&(dt(r)||(t.targetElement=null))}}this.domService.updateSelectedAnnotationInMap([t]),this.authService.getUser()&&this.authService.isFeatureAllowed(H.ARROW)&&this.docService.getDocumentPaths$().pipe(I(e=>!!e),F(1),f(e=>(this.documentPaths=e,this.loggingService.log(this.documentPaths),this.databaseService.getDb().pipe(I(r=>!!r),F(1),f(r=>{if(this.documentPaths?.arrow&&t?.annotationId){let i=JSON.parse(JSON.stringify(t));return i.position=null,this.commonDbService.setData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}else return P(null)}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in ArrowService updateArrowToDb subscription: ",e)})}catch(e){this.loggingService.catch("Error in ArrowService updateArrowToDb: ",e)}}deleteArrowPinAnnotations(t){try{let e=this.domService.getSelectedAnnotationsMap(),r=this.authService.getUser(),i=[];Object.keys(e).forEach(n=>At(this,null,function*(){let o=e[n];if(o.type==="arrow"){let a=r&&!r?.isAnonymous&&!r?.isGuest;r&&o.from&&(a||o.from.userId===r.userId)&&i.push(o)}})),i?.length&&(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETE_TRIGGERED,{triggerType:t,annotationId:i.map(n=>n.annotationId).join()}),this.dialog.open(ue,{panelClass:"velt-mat-dialog-container",data:{title:"Delete arrow?",message:"This selected arrow will be deleted.",yesButton:"Delete",noButton:"Cancel",variant:"arrow"}}).afterClosed().pipe(F(1)).subscribe(n=>{n&&(i.forEach(o=>At(this,null,function*(){yield this.deleteArrowPinAnnotation(o)})),setTimeout(()=>{document.querySelectorAll(`[${d.SNIPPYLY_HIGHLIGHT}]`).forEach(a=>{this.domService.removeHighlightFromElement(a)})},100))})),this.domService.resetSelectedAnnotationsMap(!0,"arrow")}catch(e){this.loggingService.catch("Error in ArrowService deleteArrowPinAnnotations: ",e)}}deleteArrowPinAnnotation(t){return this.authService.isFeatureAllowed(H.ARROW)&&this.documentPaths?.arrow&&t?.annotationId?(this.updateNotificationsDatabase(t,Et.DELETED),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DELETED,{annotationId:t.annotationId}),this.commonDbService.deleteData({feature:"arrow",properties:{documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??"",id:t.annotationId,skipFirestore:!0}})):Promise.resolve()}enableAddArrowMode(){this.authService.isFeatureAllowed(H.ARROW)?(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_ENABLED),this.addArrowMode$.next(!0)):this.loggingService.catch("Error in ArrowService enableAddArrowMode: ","Arrow feature is not enabled.")}disableAddArrowMode(){this.analyticsService.trackEvent(_.Events.Arrow.ARROW_ADD_MODE_DISABLED),this.addArrowMode$.next(!1)}addArrowModeChange(){return this.addArrowMode$.asObservable()}get timestamp(){return this.commonDbService.getServerTimestamp()}isElementInsideAllowedElements(t){try{return this.domService.isElementInsideListedElementIds(t,this.allowedElementIds$.value)}catch(e){return this.loggingService.catch("Error in ArrowService isElementInsideAllowedElements: ",e),!1}}updateNotificationsDatabase(t,e){try{let r={annotationData:t,actionType:e,notificationSource:"arrow"};this.serviceBook.get(se)?.updateNotificationDatabase(r)}catch(r){this.loggingService.catch("Error in ArrowService updateNotificationsDatabase: ",r)}}getArrowUrl(t){try{return t?.pageInfo?.arrowUrl?t.pageInfo.arrowUrl:(t?.pageInfo||(t.pageInfo=yt(),t.pageInfo&&(t.pageInfo.screenWidth=this.domService.getCurrentWindowSizeValue()?.screenWidth)),t.pageInfo.arrowUrl=this.generateArrowUrl(t),this.updateArrow(t),t.pageInfo?.arrowUrl)}catch(e){this.loggingService.catch("Error in ArrowService getArrowUrl: ",e);return}}generateArrowUrl(t){let e;try{e=new URL(t?.pageInfo?.url||window.location.href)}catch(r){this.loggingService.catch("Error in ArrowService generateArrowUrl: ",r),e=new URL(window.location.href)}return e.searchParams.delete(d.URL_PARAMS.TAG_ID),e.searchParams.append(d.URL_PARAMS.TAG_ID,t.annotationId),e.href}};s.\u0275fac=function(e){return new(e||s)(v(x),v(ce),v(ge),v(le),v(V),v(D),v(Qt),v(ut),v(qt),v(A),v(mt),v(he))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Ce=["handle"],ye=["arrowRef"],be=["headRef"],Ie=l=>({transform:l});function _e(l,s){if(l&1){let c=G();W(0,"div",8,2),U("cdkDragStarted",function(e){E(c);let r=b();return C(r.onDragStarted(e))})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onDragMoved(e))})("cdkDragReleased",function(e){E(c);let r=b();return C(r.onDragReleased(e))}),et(),W(2,"svg",9),st(3,"path",10)(4,"path",11),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing),R("cdkDragRootElement","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId))("cdkDragDisabled",!c.isEditable||c.isResizing)}}function De(l,s){if(l&1){let c=G();W(0,"div",12,2),U("cdkDragStarted",function(){E(c);let e=b();return C(e.onResizeHandleDragStarted())})("cdkDragMoved",function(e){E(c);let r=b();return C(r.onResizeHandleDragMoved(e))})("cdkDragReleased",function(){E(c);let e=b();return C(e.onResizeHandleDragReleased())}),et(),W(2,"svg",13),st(3,"path",14),z()()}if(l&2){let c=b();N("s-arrow-annotation-handle-dragging",c.isResizing)}}var ve=(()=>{let s=class s{get arrowPinAnnotation(){return this._arrowPinAnnotation}set arrowPinAnnotation(t){this._arrowPinAnnotation=t,this.updatedArrowAngle&&this.arrowPinAnnotation?.props&&(this.arrowPinAnnotation.props.arrowAngle=this.updatedArrowAngle),this.calculateArrowWidthBasedOnViewport()}get arrowPinSelected(){return this._arrowPinSelected}set arrowPinSelected(t){this._arrowPinSelected=t,this.updateHighlightOnElement()}get arrowPinHover(){return this._arrowPinHover}set arrowPinHover(t){this._arrowPinHover=t,this.updateHighlightOnElement()}constructor(t,e,r,i){this.arrowService=t,this.domService=e,this.loggingService=r,this.elementRef=i,this._arrowPinSelected=!1,this.multipleArrowPinsSelected=!1,this.dragStarted=new at,this.dragMoved=new at,this.dragReleased=new at,this._arrowPinHover=!1,this.subscriptions=[],this.veltElement=!0,this.isDragging=!1,this.isResizing=!1,this.isEditable=!1,this.centerX=0,this.centerY=0,this.newAngle=0,this.newWidth=0,this.updatedArrowAngle=0,this.MIN_ARROW_LENGTH=d.VELT_MIN_ARROW_LENGTH,this.pointerEventSubscriptions=[],this.loggingService.log("%c[WB] Creating COMPONENT ArrowPinComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{this.updateHighlightOnElement(),setTimeout(()=>{this.calculateArrowWidthBasedOnViewport()},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent AfterViewInit: ",t)}}ngOnChanges(t){try{t.arrowPinAnnotation&&this.checkIsEditable(),t.user&&this.checkIsEditable()}catch(e){this.loggingService.catch("Error in ArrowPinComponent ngOnChanges: ",e)}}checkIsEditable(){try{this.user?.userId===this.arrowPinAnnotation?.from?.userId?this.isEditable=!0:this.user&&!this.user.isAnonymous&&!this.user.isGuest?this.isEditable=!0:this.isEditable=!1}catch(t){this.loggingService.catch("Error in ArrowPinComponent checkIsEditable: ",t)}}onResizeHandleDragStarted(){try{this.isResizing||(this.updatedArrowAngle=0,this.updateCenter(),this.isResizing=!0)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragStarted: ",t)}}onResizeHandleDragMoved(t){try{let e=t.event;if(!this.isResizing||!this.isWithinViewport(e))return;let r=this.getAngleAndDistanceFromMouseEvent(e);this.newAngle=r.angle,this.newWidth=Math.min(r.distance,this.getMaxAllowedArrowLength()),e.stopPropagation()}catch(e){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragMoved: ",e)}}onResizeHandleDragReleased(){try{this.isResizing=!1,this.updateArrowPinAnnotationProps(),setTimeout(()=>{this.newAngle=0,this.newWidth=0},100)}catch(t){this.loggingService.catch("Error in ArrowPinComponent onResizeHandleDragReleased: ",t)}}updateCenter(){try{let t=this.elementRef.nativeElement.getBoundingClientRect();this.centerX=t.x,this.centerY=t.y}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateCenter: ",t)}}getAngleAndDistanceFromMouseEvent(t){try{let e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,r=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,i=e-this.centerX,n=r-this.centerY,a=Math.atan2(n,i)*(180/Math.PI);a=a<0?a+360:a;let m=Math.sqrt(i*i+n*n);return{angle:a,distance:m}}catch(e){return this.loggingService.catch("Error in ArrowPinComponent getAngleAndDistanceFromMouseEvent: ",e),{angle:0,distance:0}}}isWithinViewport(t){try{return typeof TouchEvent<"u"&&t instanceof TouchEvent?t.touches[0].clientX>=0&&t.touches[0].clientX<=window?.innerWidth&&t.touches[0].clientY>=0&&t.touches[0].clientY<=window?.innerHeight:t.clientX>=0&&t.clientX<=window?.innerWidth&&t.clientY>=0&&t.clientY<=window?.innerHeight}catch(e){return this.loggingService.catch("Error in ArrowPinComponent isWithinViewport: ",e),!1}}calculateArrowWidthBasedOnViewport(){try{if(this.isDragging)return;if(this.arrowPinAnnotation?.props){let t=this.arrowPinAnnotation.props.viewportWidth||0,e=this.arrowPinAnnotation.props.viewportHeight||0,r=window.innerWidth,i=window.innerHeight;this.arrowPinAnnotation.props.arrowLength||(this.arrowPinAnnotation.props.arrowLength=0);let n=(this.arrowPinAnnotation.props.arrowAngle||0)%360;n>45&&n<135||n>225&&n<315?e>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*i/e):t>0&&(this.arrowPinAnnotation.props.arrowLength=this.arrowPinAnnotation.props.arrowLength*r/t);let o=this.arrowRef?.nativeElement?.getBoundingClientRect();if(o){n<0&&(n=360+n);let a=n,m=n>90&&n<=180,h=n>180&&n<=270,u=r-o.x;(m||h)&&(u=o.right,a=180-n);let T=ht(u-d.VELT_ARROW_VIEWPORT_PADDING,a);if(T>0&&this.arrowPinAnnotation.props.arrowLength>T)if(T<this.MIN_ARROW_LENGTH){let L=(this.arrowPinAnnotation.props.arrowAngle||0)%360;L>=90&&L<=270?this.updatedArrowAngle=45:this.updatedArrowAngle=135,this.arrowPinAnnotation.props.arrowLength=this.MIN_ARROW_LENGTH}else this.arrowPinAnnotation.props.arrowLength=T}this.arrowPinAnnotation.props.arrowLength=Math.min(this.arrowPinAnnotation.props.arrowLength,this.getMaxAllowedArrowLength())}}catch(t){this.loggingService.catch("Error in ArrowPinComponent calculateArrowWidthBasedOnViewport: ",t)}}getMaxAllowedArrowLength(){try{return Math.max(window.innerWidth,window.innerHeight)*.8}catch(t){return this.loggingService.catch("Error in ArrowPinComponent getMaxAllowedArrowLength: ",t),0}}updateHighlightOnElement(){try{this.targetElement&&(this.arrowPinSelected||this.arrowPinHover?this.domService.highlightElement(this.targetElement):this.domService.removeHighlightFromElement(this.targetElement))}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateHighlightOnElement: ",t)}}updateArrowPinAnnotationProps(){try{this.arrowPinAnnotation?.props||(this.arrowPinAnnotation.props=new gt),this.arrowPinAnnotation.props.viewportWidth=window.innerWidth,this.arrowPinAnnotation.props.viewportHeight=window.innerHeight,this.arrowPinAnnotation.props.arrowAngle=this.newAngle,this.arrowPinAnnotation.props.arrowLength=this.newWidth,this.arrowService.updateArrow(this.arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinComponent updateArrowPinAnnotation: ",t)}}onPointerOver(t){try{t.buttons?this.arrowPinHover&&(this.arrowPinHover=!1):this.arrowPinHover||(this.arrowPinHover=!0)}catch(e){this.loggingService.catch("Error in ArrowPinComponent onPointerOver: ",e)}}onDragStarted(t){this.isDragging=!0,this.dragStarted.emit(t)}onDragMoved(t){this.dragMoved.emit(t)}onDragReleased(t){this.isDragging=!1,this.dragReleased.emit(t)}onPointerOut(){this.arrowPinHover=!1}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowPinComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(M),p(D),p(A),p(ot))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin"]],viewQuery:function(e,r){if(e&1&&(X(Ce,5),X(ye,5),X(be,5)),e&2){let i;Y(i=J())&&(r.handle=i.first),Y(i=J())&&(r.arrowRef=i.first),Y(i=J())&&(r.headRef=i.first)}},hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},inputs:{arrowPinAnnotation:"arrowPinAnnotation",arrowPinSelected:"arrowPinSelected",multipleArrowPinsSelected:"multipleArrowPinsSelected",user:"user",targetElement:"targetElement"},outputs:{dragStarted:"dragStarted",dragMoved:"dragMoved",dragReleased:"dragReleased"},features:[Lt],decls:7,vars:15,consts:[["arrowRef",""],["headRef",""],["handle",""],[1,"s-arrow-annotation",3,"pointerover","pointerout","click","ngStyle"],["class","s-arrow-annotation-drag-handle","cdkDrag","","cdkDragHandle","",3,"s-arrow-annotation-handle-dragging","cdkDragRootElement","cdkDragDisabled","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],[1,"s-arrow-annotation-head"],[1,"s-arrow-annotation-line"],["class","s-arrow-annotation-handle","cdkDrag","",3,"s-arrow-annotation-handle-dragging","cdkDragStarted","cdkDragMoved","cdkDragReleased",4,"ngIf"],["cdkDrag","","cdkDragHandle","",1,"s-arrow-annotation-drag-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased","cdkDragRootElement","cdkDragDisabled"],["width","32","height","32","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M18.0039 5.99219H14.4039M18.0039 5.99219V9.59219M18.0039 5.99219L13.8039 10.1922M6.00391 17.9922H9.60391M6.00391 17.9922V14.3922M6.00391 17.9922L10.2039 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["d","M6 5.99219H9.6M6 5.99219V9.59219M6 5.99219L10.2 10.1922M18 17.9922H14.4M18 17.9922V14.3922M18 17.9922L13.8 13.7922","stroke","#0093FF","stroke-width","1.2","stroke-linecap","round","stroke-linejoin","round"],["cdkDrag","",1,"s-arrow-annotation-handle",3,"cdkDragStarted","cdkDragMoved","cdkDragReleased"],["width","16","height","16","viewBox","0 0 10 10","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M1 5C1 3.11438 1 2.17157 1.58579 1.58579C2.17157 1 3.11438 1 5 1C6.88562 1 7.82843 1 8.41421 1.58579C9 2.17157 9 3.11438 9 5C9 6.88562 9 7.82843 8.41421 8.41421C7.82843 9 6.88562 9 5 9C3.11438 9 2.17157 9 1.58579 8.41421C1 7.82843 1 6.88562 1 5Z","stroke","#0093FF","stroke-width","1.5"]],template:function(e,r){if(e&1){let i=G();W(0,"div",3,0),U("pointerover",function(o){return E(i),C(r.onPointerOver(o))})("pointerout",function(){return E(i),C(r.onPointerOut())})("click",function(o){return E(i),C(o.preventDefault())}),$(2,_e,5,4,"div",4),st(3,"div",5,1)(5,"div",6),$(6,De,4,2,"div",7),z()}e&2&&(K("width",r.newWidth||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowLength)||r.MIN_ARROW_LENGTH,"px"),N("s-arrow-annotation-selected",r.arrowPinSelected)("s-arrow-annotation-draggable",r.isEditable),R("ngStyle",jt(13,Ie,"rotate("+(r.newAngle||r.updatedArrowAngle||(r.arrowPinAnnotation==null||r.arrowPinAnnotation.props==null?null:r.arrowPinAnnotation.props.arrowAngle)||0)+"deg)")),O(2),R("ngIf",r.isEditable),O(),K("border-right-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(2),K("background-color",((r.arrowPinAnnotation==null||r.arrowPinAnnotation.from==null?null:r.arrowPinAnnotation.from.color)||(r.arrowPinAnnotation==null?null:r.arrowPinAnnotation.color))+" !important"),O(),R("ngIf",r.isEditable))},dependencies:[lt,ct,$t,Xt,Gt,zt],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}.s-arrow-annotation[_ngcontent-%COMP%]{position:absolute!important;z-index:20!important;height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;left:50%!important;top:50%!important;display:flex!important;align-items:center!important;justify-content:flex-end!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-line[_ngcontent-%COMP%]{height:calc((.4rem + 0px) * var(--velt-base-rem-unit))!important;transform-origin:0 100%!important;width:100%!important;background-color:#625df5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-head[_ngcontent-%COMP%]{width:0!important;height:0!important;border-top:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-bottom:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid transparent!important;border-right:calc((1.1rem + 0px) * var(--velt-base-rem-unit)) solid #625DF5!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%]{transform:none!important;cursor:move!important;display:flex!important;position:absolute!important;left:-20px!important;opacity:0!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{transform:none!important;display:flex!important;opacity:0!important;cursor:grab!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;height:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-arrow-annotation[_ngcontent-%COMP%] .s-arrow-annotation-handle.s-arrow-annotation-handle-dragging[_ngcontent-%COMP%]{cursor:grabbing!important}.s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-drag-handle[_ngcontent-%COMP%], .s-arrow-annotation[_ngcontent-%COMP%]:hover .s-arrow-annotation-handle[_ngcontent-%COMP%], .s-arrow-annotation.s-arrow-annotation-selected[_ngcontent-%COMP%] .s-arrow-annotation-handle[_ngcontent-%COMP%]{opacity:1!important}"],changeDetection:0});let l=s;return l})();var Te=["arrowPinRef"];function Oe(l,s){if(l&1){let c=G();W(0,"div",3),U("pointerup",function(e){return E(c),b(2).togglePinSelection(),C(e.stopPropagation())})("pointerdown",function(e){return E(c),C(e.stopPropagation())})("click",function(e){return E(c),C(e.stopPropagation())}),W(1,"snippyly-arrow-pin",4,0),U("dragStarted",function(){E(c);let e=b(2);return C(e.onPinDragStart())})("dragMoved",function(e){E(c);let r=b(2);return C(r.onPinMove(e))})("dragReleased",function(){E(c);let e=b(2);return C(e.onPinRelease())}),z()()}if(l&2){let c=b().ngIf,t=b();K("top",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.top:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.top)+c.offsetTop,"px")("left",c.annotationDragging?c.dragPosition==null?null:c.dragPosition.left:(c.arrowPinAnnotation==null||c.arrowPinAnnotation.position==null?null:c.arrowPinAnnotation.position.left)+c.offsetLeft,"px"),N("pin-dragging",c.annotationDragging),R("id","arrow-pin-container-"+(c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId)),O(),R("arrowPinAnnotation",c.arrowPinAnnotation)("arrowPinSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&!c.annotationDragging&&t.objectKeys(c.selectedAnnotationsMap).length===1)("multipleArrowPinsSelected",c.selectedAnnotationsMap[c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.annotationId]&&t.objectKeys(c.selectedAnnotationsMap).length>1)("targetElement",c.targetElement)("user",c.user)}}function Re(l,s){if(l&1&&(xt(0),$(1,Oe,3,12,"div",2),Vt()),l&2){let c=s.ngIf;O(),R("ngIf",c.arrowPinAnnotation==null?null:c.arrowPinAnnotation.position)}}var fe=(()=>{let s=class s{constructor(t,e,r,i,n){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.loggingService=n,this.multipleArrowPinsSelected=!1,this.avatarErrorImage="",this.objectKeys=Object.keys,this.subscriptions=[],this.componentConfigSignal=Mt({arrowPinAnnotation:void 0,annotationDragging:!1,dragPosition:null,offsetTop:0,offsetLeft:0,selectedAnnotationsMap:{},targetElement:void 0,user:void 0}),this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{user:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getUser$ subscription: ",o)})),this.subscriptions.push(this.domService.getSelectedAnnotationsMap$().subscribe(o=>{this.componentConfigSignal.update(a=>(a=y(w({},a),{selectedAnnotationsMap:o}),a))},o=>{this.loggingService.catch("Error in ArrowPinPortalComponent getSelectedAnnotationsMap$ subscription: ",o)}))}ngOnInit(){}setArrowPinAnnotation(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{arrowPinAnnotation:t}),e)),this.id=this.componentConfigSignal().arrowPinAnnotation?.annotationId}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setArrowPinAnnotation: ",e)}}setTargetElement(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{targetElement:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setTargetElement: ",e)}}setOffsetLeft(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetLeft:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetLeft: ",e)}}setOffsetTop(t){try{this.componentConfigSignal.update(e=>(e=y(w({},e),{offsetTop:t}),e))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent setOffsetTop: ",e)}}togglePinSelection(){try{this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation)}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent togglePinSelection: ",t)}}onPinDragStart(){this.componentConfigSignal().selectedAnnotationsMap[this.componentConfigSignal().arrowPinAnnotation.annotationId]&&this.domService.toggleAnnotationSelection(this.componentConfigSignal().arrowPinAnnotation);let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&(this.parentElement=t.parentElement,t.style.opacity="0",document.body.appendChild(t)),this.componentConfigSignal.update(e=>(e=y(w({},e),{annotationDragging:!0}),e)),setTimeout(()=>{t&&(t.style.opacity="1")},50)}onPinMove(t){try{this.updateCurrentPinPosition(t)}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent onPinMove: ",e)}}updateCurrentPinPosition(t){try{this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement);let e=t.event,r=e?.touches?.length?e.touches[0]?.clientX:e.clientX,i=e?.touches?.length?e.touches[0]?.clientY:e.clientY,n=this.domService.getBackgroundElement(r,i);n&&(this.componentConfigSignal.update(o=>(o=y(w({},o),{targetElement:n}),o)),this.domService.highlightElement(this.componentConfigSignal().targetElement),this.pointerMoveEvent=t.event,this.componentConfigSignal.update(o=>(o=y(w({},o),{dragPosition:{top:i,left:r}}),o)))}catch(e){this.loggingService.catch("Error in ArrowPinPortalComponent updateCurrentPinPosition: ",e)}}onPinRelease(){try{let t=document.getElementById(this.componentConfigSignal().arrowPinAnnotation.annotationId);t&&this.parentElement&&this.parentElement.appendChild(t);let e=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath);if(this.pointerMoveEvent){this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.targetElement=this.domService.getTargetElementForCursorPosition(this.pointerMoveEvent),h));let n=this.pointerMoveEvent,o=n?.touches?.length?n.touches[0]?.clientX:n.clientX,a=!1;if(o<d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;h>=90&&h<=270&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=45,u)),a=!0)}if(o>window?.innerWidth-d.VELT_MIN_ARROW_LENGTH){let h=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;(h>=270&&h<=360||h>=0&&h<=90)&&(this.componentConfigSignal.update(u=>(u=w({},u),u.arrowPinAnnotation.props.arrowAngle=135,u)),a=!0)}if(!a){let h=o,u=this.componentConfigSignal().arrowPinAnnotation.props.arrowAngle||0;u>=0&&u<=90||u>=270&&u<=360?h=window.innerWidth-o:u=180-u;let T=ht(h-d.VELT_ARROW_VIEWPORT_PADDING,u);T>0&&T<(this.componentConfigSignal().arrowPinAnnotation.props.arrowLength||0)&&this.componentConfigSignal.update(L=>(L=w({},L),L.arrowPinAnnotation.props.arrowLength=T,L))}let m=this.domService.getCurrentWindowSizeValue();this.componentConfigSignal.update(h=>(h=w({},h),h.arrowPinAnnotation.props.screenWidth=m.screenWidth,h.arrowPinAnnotation.props.screenHeight=m.screenHeight,h.arrowPinAnnotation.props.screenScrollHeight=m.screenScrollHeight,h.arrowPinAnnotation.props.viewportWidth=window.innerWidth,h.arrowPinAnnotation.props.viewportHeight=window.innerHeight,h))}let r=this.domService.getElementFromXPath(this.componentConfigSignal().arrowPinAnnotation.targetElement?.xpath),i=this.domService.isElementInsideAdditionalLocationContainer(e)||this.domService.isElementInsideAdditionalLocationContainer(r);this.arrowService.updateArrow(this.componentConfigSignal().arrowPinAnnotation,!1,i),setTimeout(()=>{this.componentConfigSignal.update(n=>(n=w({},n),n.annotationDragging=!1,n.dragPosition=null,n)),this.domService.removeHighlightFromElement(this.componentConfigSignal().targetElement),this.arrowPinRef&&(this.arrowPinRef.updatedArrowAngle=0)},100),this.analyticsService.trackEvent(_.Events.Arrow.ARROW_DRAGGED,{annotationId:this.componentConfigSignal().arrowPinAnnotation.annotationId})}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent onPinRelease: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowPinPortalComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrow-pin-portal"]],viewQuery:function(e,r){if(e&1&&X(Te,5),e&2){let i;Y(i=J())&&(r.arrowPinRef=i.first)}},hostVars:2,hostBindings:function(e,r){e&2&&(Ft("id",r.id),B("data-velt-element",r.veltElement))},inputs:{multipleArrowPinsSelected:"multipleArrowPinsSelected",avatarErrorImage:"avatarErrorImage"},decls:1,vars:1,consts:[["arrowPinRef",""],[4,"ngIf"],["class","arrow-pin-portal",3,"id","pin-dragging","top","left","pointerup","pointerdown","click",4,"ngIf"],[1,"arrow-pin-portal",3,"pointerup","pointerdown","click","id"],[3,"dragStarted","dragMoved","dragReleased","arrowPinAnnotation","arrowPinSelected","multipleArrowPinsSelected","targetElement","user"]],template:function(e,r){e&1&&$(0,Re,2,1,"ng-container",1),e&2&&R("ngIf",r.componentConfigSignal())},dependencies:[lt,ct,ve],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}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;height:unset;width:unset;text-align:left!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:empty{display:revert!important}.arrow-pin-portal[_ngcontent-%COMP%]{position:absolute;transform:none!important;top:0;left:0}.arrow-pin-portal.pin-dragging[_ngcontent-%COMP%]{position:fixed;z-index:var(--velt-arrow-z-index)!important}"],changeDetection:0});let l=s;return l})();var Ae=(()=>{let s=class s{constructor(t,e,r,i,n){this.domService=t,this.componentFactoryResolver=e,this.injector=r,this.appRef=i,this.loggingService=n,this.arrowsPinById={}}setArrowPin(t){try{if(!this.arrowsPinById[t.annotationId])this.setPinPortal(t);else if(t.targetElement?.xpath===this.arrowsPinById[t.annotationId]?.annotation?.targetElement?.xpath){let e=this.arrowsPinById[t.annotationId].portalRef,r=this.arrowsPinById[t.annotationId].userTargetElement,i=this.arrowsPinById[t.annotationId].pinHostElement;if(document.body.contains(r)&&document.body.contains(i))e&&(e.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),this.updateElementOffset(t));else{let n=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;n&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),n.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}else{let e=this.arrowsPinById[t.annotationId].pinHostDomPortalOutlet;e&&(this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),this.arrowsPinById[t.annotationId].pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),e.detach(),delete this.arrowsPinById[t.annotationId],this.setPinPortal(t))}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setArrowPin: ",e)}}setPinPortal(t){try{let e=this.domService.getXPath(t.targetElement?.xpath);if(e){let r=e.iterateNext();if(r){let i=this.domService.getHostElement(r),n=new Yt(fe),o=new Jt(i,this.appRef,this.injector),a=o.attach(n);a.instance.setArrowPinAnnotation(JSON.parse(JSON.stringify(t))),a.instance.setTargetElement(r),this.arrowsPinById[t.annotationId]={pinHostDomPortalOutlet:o,pinPortal:n,portalRef:a,annotation:JSON.parse(JSON.stringify(t)),userTargetElement:r,pinHostElement:i},i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST,t.annotationId),window.getComputedStyle(i).position==="static"&&(ne(i)||i.setAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC,"true")),this.updateElementOffset(t)}}}catch(e){this.loggingService.catch("Error in ArrowPinPortalService setPinPortal: ",e)}}updateElementOffset(t){try{let{portalRef:e,userTargetElement:r,pinHostElement:i}=this.arrowsPinById[t.annotationId],n=this.domService.getElementOffset(r,i);e.instance.setOffsetLeft(n.offsetLeft),e.instance.setOffsetTop(n.offsetTop)}catch(e){this.loggingService.catch("Error in ArrowPinPortalService updateElementOffset: ",e)}}checkPinsToRemove(t){try{let e=t.map(r=>r.annotationId);Object.keys(this.arrowsPinById).forEach(r=>{if(!e.includes(r)){let i=this.arrowsPinById[r];i.pinHostDomPortalOutlet.detach(),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST),i.pinHostElement?.removeAttribute(d.ATTRIBUTES.VELT_ARROW_PIN_HOST_STATIC),this.domService.removeHighlightFromElement(i.pinHostElement),delete this.arrowsPinById[r]}})}catch(e){this.loggingService.catch("Error in ArrowPinPortalService checkPinsToRemove: ",e)}}};s.\u0275fac=function(e){return new(e||s)(v(D),v(Wt),v(Rt),v(Bt),v(A))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();var Dt=(()=>{let s=class s{constructor(t,e,r,i,n,o){this.analyticsService=t,this.authService=e,this.domService=r,this.arrowService=i,this.arrowPinPortalService=n,this.loggingService=o,this.arrowPinAnnotations=[],this.subscriptions=[],this.isFirstComponent=!0,this.veltId=ee(),this.veltElement=!0;try{this.loggingService.log("%c[WB] Creating CLASS: ArrowsContainerComponent","color: blue;")}catch(a){this.loggingService.catch("Error in ArrowsContainerComponent constructor: ",a)}}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;")}ngAfterViewInit(){try{let t=document.querySelector(d.TAGS.SNIPPYLY_ARROWS),e=document.querySelector(d.TAGS.VELT_ARROWS);e?this.veltId===e?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent()):this.veltId===t?.getAttribute(d.ATTRIBUTES.VELT_ID)&&(this.isFirstComponent=!0,this.initComponent())}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent AfterViewInit: ",t)}}initComponent(){try{this.subscriptions.push(this.authService.getUser$().pipe(I(t=>!!t)).subscribe(t=>{t&&this.setArrowInstalledInAnalytics()},t=>{this.loggingService.catch("Error in getUser: ",t)})),this.getAllArrowsOnCurrentDocument()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent initComponent: ",t)}}getAllArrowsOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getAllArrowsOnCurrentDocument","color: green;");try{this.subscriptions.push(this.arrowService.getAllArrowAnnotations().pipe(I(t=>!!t),f(t=>this.domService.getSelectedAnnotationsMap$().pipe(S(e=>({annotations:t,selectedAnnotationsMap:e||{}}))))).subscribe(t=>{try{this.loggingService.log(t),this.arrowPinAnnotations=t?.annotations;let e=this.arrowPinAnnotations.filter(r=>r.targetElement);this.arrowPinPortalService.checkPinsToRemove(e),e.forEach(r=>{this.arrowPinPortalService.setArrowPin(r)})}catch(e){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument inside subscription: ",e)}},t=>{this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument subscription: ",t)}))}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent getAllArrowsOnCurrentDocument: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent unsubscribe: ",t)}}setArrowInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(H.ARROW)}catch(t){this.loggingService.catch("Error in ArrowsContainerComponent setArrowInstalledInAnalytics: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(D),p(M),p(Ae),p(A))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-container"]],hostVars:2,hostBindings:function(e,r){e&2&&B("data-velt-id",r.veltId)("data-velt-element",r.veltElement)},decls:0,vars:0,template:function(e,r){},encapsulation:2,changeDetection:0});let l=s;return l})();var Tt=(()=>{let s=class s extends pe{constructor(t,e,r,i,n,o,a,m,h){super(a,o,void 0,void 0,void 0,m,n),this.analyticsService=t,this.authService=e,this.arrowService=r,this.iamService=i,this.loggingService=n,this.themeService=o,this.elementRef=a,this.dynamicDataService=m,this.domService=h,this.customButtonAdded=!1,this.disabled=!1,this.addArrowMode=!1,this.subscriptions=[],this.veltElement=!0,this.subscriptions.push(this.authService.getUser$().subscribe(u=>{this.user=u},u=>{this.loggingService.catch("Error in ArrowsToolComponent getUser$ subscription: ",u)}))}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef)),this.subscriptions.push(this.arrowService.addArrowModeChange().subscribe(t=>{this.addArrowMode=t})),this.subscriptions.push(this.iamService.getFeaturesAccessLevel$().subscribe(t=>{this.disabled=!!t?.all?.disabled}))}catch(t){this.loggingService.catch("Error in ArrowsToolComponent AfterViewInit: ",t)}}onButtonSlotChange(){this.customButtonAdded=!0}addArrow(){this.loggingService.log("%c[WB] Calling FUNCTION: addArrow","color: green;");try{if(this.analyticsService.trackEvent(_.Events.Arrow.ARROW_TOOL_CLICKED,{toolType:this.customButtonAdded?"custom":"default"}),this.user){if(this.disabled){this.loggingService.catch("Arrows are disabled.");return}this.user.isReadOnly||this.user.isAnonymous?this.loggingService.catch("Anonymous/Readonly users cannot add arrows."):!this.authService.isPlanExpired()&&this.iamService.getRole()?this.arrowService.enableAddArrowMode():this.loggingService.catch("User does not have permission to add arrows.")}else this.loggingService.catch("Velt sdk not authenticated.")}catch(t){this.loggingService.catch("Error in ArrowsToolComponent addArrow: ",t)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{super.ngOnDestroy(),this.unsubscribe()}catch(t){this.loggingService.catch("Error in ArrowsToolComponent ondestroy: ",t)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(t=>{t.unsubscribe()}),this.subscriptions=[]}catch(t){this.loggingService.catch("Error in ArrowsToolComponent unsubscribe: ",t)}}};s.\u0275fac=function(e){return new(e||s)(p(x),p(V),p(M),p(ut),p(A),p(me),p(ot),p(pt),p(D))},s.\u0275cmp=k({type:s,selectors:[["snippyly-arrows-tool"]],hostVars:1,hostBindings:function(e,r){e&2&&B("data-velt-element",r.veltElement)},features:[Ut([pt]),kt],decls:5,vars:2,consts:[["part","container",1,"snippyly-arrow-btn-container",3,"click"],["name","button",3,"slotchange"],["part","button-container","tabindex","0",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 25 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M17.5 7L7.5 17M17.5 7H10M17.5 7V14.5","stroke","currentColor","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"]],template:function(e,r){e&1&&(rt(0,"div",0),Pt("click",function(n){return r.addArrow(),n.stopPropagation()}),rt(1,"slot",1),Pt("slotchange",function(){return r.onButtonSlotChange()}),rt(2,"div",2),et(),rt(3,"svg",3),Ht(4,"path",4),Nt()()()()),e&2&&(O(2),N("active",r.addArrowMode))},styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}*{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;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert!important}.snippyly-arrow-btn-container{display:inline-block}.action-btn{display:flex;justify-content:center;align-items:center;padding:6px!important;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color)}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));color:var(--legacy-velt-tool-active-icon-color)}
|
|
2
|
+
`],encapsulation:3,changeDetection:0});let l=s;return l})();var vt=class extends we{constructor(s){super(s),this.getService(A).log("%c[WB] Creating CLASS: ArrowElement","color: blue;"),this.allowedElementIds=this._allowedElementIds}_allowedElementIds(s){this.getService(A).log("%c[WB] Calling FUNCTION: allowedElementIds","color: green;");try{this.trackEvent(_.Events.Arrow.ALLOWED_ELEMENT_IDS_TRIGGERED,{payload:{elementIds:s}}),this.getService(M).setAllowedElementIds(s)}catch(c){this.getService(A).catch("Error in allowedElementIds: ",c)}}};var Se=(()=>{let s=class s{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromArrowAnnotations(t){try{this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: getUserIdsToResolveFromArrowAnnotations","color: green;");let e=new Set;for(let r of t)r?.from?.userId&&e.add(r?.from?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in ArrowUtilsService getUserIdsToResolveFromArrowAnnotations:",e),[]}}mergeArrowWithUser(t){try{if(this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: mergeArrowWithUser","color: green;"),t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}return t}catch(e){return this.loggingService.catch("Error in ArrowUtilsService mergeArrowWithUser:",e),t}}formatArrowData(t){try{return this.loggingService.log("%c[WB] Calling ArrowUtilsService FUNCTION: formatArrowData","color: green;"),this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t}catch(e){return this.loggingService.catch("Error in ArrowUtilsService formatArrowData:",e),t}}};s.\u0275fac=function(e){return new(e||s)(v(A),v(de))},s.\u0275prov=j({token:s,factory:s.\u0275fac,providedIn:"root"});let l=s;return l})();function Le(l){return l.get(A).log("%c[WB] Loading arrow feature chunk","color: blue;"),l.get(mt).set(ae,l.get(Se)),ft(l,d.TAGS.VELT_ARROW_TOOL,Tt),ft(l,d.TAGS.VELT_ARROWS,Dt),ft(l,d.TAGS.SNIPPYLY_ARROW_TOOL,Tt),ft(l,d.TAGS.SNIPPYLY_ARROWS,Dt),new vt(l)}function ft(l,s,c){if(customElements.get(s))return;let t=Kt(c,{injector:l});customElements.define(s,t)}export{Le as default};
|