@qaecy/cue-ui 0.0.17 → 0.0.19
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/236.js +1 -1
- package/371.js +1 -1
- package/419.js +1 -1
- package/443.js +1 -1
- package/560.js +1 -1
- package/60.js +1 -1
- package/83.js +1 -1
- package/common.js +1 -1
- package/index.js +1 -1
- package/js/worker.mjs +7 -0
- package/main.js +1 -1
- package/package.json +3 -2
- package/187.js +0 -1
package/560.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[560],{5600(W,F,_){_.d(F,{F:()=>B,g:()=>S});var r=_(7705),g=_(2271),T=_(7089),X=_(5381),A=_(5187),L=_(1696),t=_(3319),C=_(5802),h=_(5547);function Z(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-flexcontainer",3)(1,"cue-button",6),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.activeTool.set("pan"))}),h.nrm(2,"cue-button-icon",7),h.k0s(),h.j41(3,"cue-button",8),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.activeTool.set("select"))}),h.nrm(4,"cue-button-icon",9),h.k0s()()}if(2&D){const f=h.XpG();h.R7$(),h.Y8G("variant","pan"===f.activeTool()?"secondary":"tertiary"),h.R7$(2),h.Y8G("variant","select"===f.activeTool()?"secondary":"tertiary")}}function k(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-flexcontainer",3)(1,"cue-button",10),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomOut())}),h.nrm(2,"cue-button-icon",11),h.k0s(),h.j41(3,"cue-button",12),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomIn())}),h.nrm(4,"cue-button-icon",13),h.k0s(),h.j41(5,"cue-button",14),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomFit())}),h.nrm(6,"cue-button-icon",15),h.k0s()()}if(2&D){const f=h.XpG();h.AVh("border-left",f.options().displayPanSelectTools),h.R7$(),h.Y8G("disabled",f.zoom()<=f.minZoom())("cueTooltip",f.zoom()<=f.minZoom()?"Minimum zoom reached":"Zoom out")}}function G(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-button",16),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.rotate.emit())}),h.nrm(1,"cue-button-icon",17),h.k0s()}if(2&D){const f=h.XpG();h.AVh("border-left",f.options().displayZoom&&f.options().displayRotate)}}class S{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayRotate=!0;displayPanSelectTools=!1}let B=(()=>{class D{options=(0,r.hFB)(new S);activeTool=(0,r.geq)("pan");panMode=(0,r.geq)(!1);zoom=(0,r.geq)(1);pan=(0,r.geq)({x:0,y:0});minZoom=(0,r.hFB)(1);maxZoom=(0,r.hFB)(10);rotate=(0,r.CGW)();zoomIn=(0,r.CGW)();zoomOut=(0,r.CGW)();zoomFit=(0,r.CGW)();selectMenuPositions=(0,g.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this.zoomIn.emit()}handleZoomOut(){this.zoomOut.emit()}handleZoomFit(){this.zoomFit.emit()}static \u0275fac=function(z){return new(z||D)};static \u0275cmp=h.VBU({type:D,selectors:[["cue-image-toolbar"]],inputs:{options:[1,"options"],activeTool:[1,"activeTool"],panMode:[1,"panMode"],zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"]},outputs:{activeTool:"activeToolChange",panMode:"panModeChange",zoom:"zoomChange",pan:"panChange",rotate:"rotate",zoomIn:"zoomIn",zoomOut:"zoomOut",zoomFit:"zoomFit"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["align","center","gap","s",3,"border-left"],["cueTooltip","Rotate","size","xs","variant","tertiary",3,"border-left"],["size","xs","cueTooltip","Pan mode \u2014 drag to move the view",3,"click","variant"],["icon","move-grab"],["size","xs","cueTooltip","Select mode \u2014 drag to draw a selection window",3,"click","variant"],["icon","move-click"],["size","xs","variant","tertiary",3,"click","disabled","cueTooltip"],["icon","zoom-out"],["cueTooltip","Zoom in","size","xs","variant","tertiary",3,"click"],["icon","zoom-in"],["cueTooltip","Zoom fit","size","xs","variant","tertiary",3,"click"],["icon","zoom-fit"],["cueTooltip","Rotate","size","xs","variant","tertiary",3,"click"],["icon","rotate-2d"]],template:function(z,b){1&z&&(h.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),h.nVh(3,Z,5,2,"cue-flexcontainer",3),h.nVh(4,k,7,4,"cue-flexcontainer",4),h.nVh(5,G,2,2,"cue-button",5),h.k0s()()()),2&z&&(h.R7$(),h.Y8G("padded",!1),h.R7$(2),h.vxM(b.options().displayPanSelectTools?3:-1),h.R7$(),h.vxM(b.options().displayZoom?4:-1),h.R7$(),h.vxM(b.options().displayRotate?5:-1))},dependencies:[X.n,A.Card,L.$,t.a,T.d],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return D})()},8560(W,F,_){_.d(F,{ImageViewer:()=>Ue});var r=_(5802),g=_(7705),T=_(2271),X=_(345),A=_(5600),L=_(9769),t=_(5547);let C=(()=>{class s{elementRef=(0,r.WQX)(t.aKT);cdr=(0,r.WQX)(g.gRc);zoom=(0,g.geq)(1);pan=(0,g.geq)({x:0,y:0});minZoom=(0,g.hFB)(1);maxZoom=(0,g.hFB)(10);zoomStep=(0,g.hFB)(.1);panMode=(0,g.hFB)(!0,{transform:e=>{const n=""===e||"false"!==e&&!!e;return!n&&(this.isPanning||this.isWaitingForPan)&&this.onMouseUp(),n}});longPressThreshold=(0,g.hFB)(150);dragThreshold=(0,g.hFB)(3);zoomChange=(0,g.CGW)();panChange=(0,g.CGW)();stateChange=(0,g.CGW)();isPanning=!1;lastPoint={x:0,y:0};isWaitingForPan=!1;downPoint={x:0,y:0};longPressTimer=null;moveListener;upListener;leaveListener;blurListener;visibilityListener;keyListener;contextMenuListener;pointerCancelListener;listenersAttached=!1;isMiddlePanning=!1;_midLastPoint={x:0,y:0};_midMoveListener;_midUpListener;_pinchStartDist=0;_pinchStartZoom=1;_touchStartListener;_touchMoveListener;_touchEndListener;constructor(){this.moveListener=this.onMouseMove.bind(this),this.upListener=this.onMouseUp.bind(this),this.leaveListener=this.onMouseUp.bind(this),this.blurListener=this.onMouseUp.bind(this),this.visibilityListener=()=>{document.hidden&&this.onMouseUp()},this.keyListener=e=>{"Escape"===e.key&&this.onMouseUp()},this.contextMenuListener=this.onMouseUp.bind(this),this.pointerCancelListener=this.onMouseUp.bind(this),this._midMoveListener=this._onMiddlePanMove.bind(this),this._midUpListener=this._onMiddlePanUp.bind(this)}ngOnInit(){this._attachTouchListeners()}ngOnDestroy(){this.removeListeners(),this.clearLongPressTimer(),this._detachTouchListeners(),this._stopMiddlePan()}addListeners(){this.listenersAttached||(this.listenersAttached=!0,window.addEventListener("mousemove",this.moveListener),window.addEventListener("mouseup",this.upListener,!0),window.addEventListener("blur",this.blurListener),document.addEventListener("visibilitychange",this.visibilityListener),document.addEventListener("keydown",this.keyListener),document.addEventListener("contextmenu",this.contextMenuListener),document.addEventListener("pointercancel",this.pointerCancelListener))}removeListeners(){this.listenersAttached=!1,window.removeEventListener("mousemove",this.moveListener),window.removeEventListener("mouseup",this.upListener,!0),window.removeEventListener("blur",this.blurListener),document.removeEventListener("visibilitychange",this.visibilityListener),document.removeEventListener("keydown",this.keyListener),document.removeEventListener("contextmenu",this.contextMenuListener),document.removeEventListener("pointercancel",this.pointerCancelListener)}clearLongPressTimer(){null!==this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}cursorStyle(){return this.isMiddlePanning?"grabbing":this.panMode()?this.isPanning?"grabbing":"grab":null}onMouseDown(e){if(1===e.button)return e.preventDefault(),this.isMiddlePanning=!0,this._midLastPoint={x:e.clientX,y:e.clientY},this.cdr.markForCheck(),window.addEventListener("mousemove",this._midMoveListener),void window.addEventListener("mouseup",this._midUpListener);!this.panMode()||0!==e.button||(e.composedPath?e.composedPath():[]).some(i=>i.hasAttribute&&i.hasAttribute("data-no-pan"))||((this.isPanning||this.isWaitingForPan)&&(this.clearLongPressTimer(),this.isWaitingForPan=!1,this.isPanning=!1,this.removeListeners()),this.isWaitingForPan=!0,this.downPoint={x:e.clientX,y:e.clientY},this.lastPoint={x:e.clientX,y:e.clientY},this.addListeners())}startPanning(){this.clearLongPressTimer(),this.isWaitingForPan=!1,this.isPanning=!0,this.cdr.markForCheck()}onMouseMove(e){if(!this.isWaitingForPan&&!this.isPanning)return;if(this.isWaitingForPan&&!this.isPanning){const l=e.clientX-this.downPoint.x,d=e.clientY-this.downPoint.y;if(Math.sqrt(l*l+d*d)>=this.dragThreshold()){e.preventDefault(),this.startPanning();const u=this.pan(),p={x:u.x+l,y:u.y+d};this.lastPoint={x:e.clientX,y:e.clientY},this.pan.set(p),this.panChange.emit(p),this.emitStateChange()}return}e.preventDefault();const n=e.clientX-this.lastPoint.x,o=e.clientY-this.lastPoint.y;this.lastPoint={x:e.clientX,y:e.clientY};const i=this.pan(),a={x:i.x+n,y:i.y+o};this.pan.set(a),this.panChange.emit(a),this.emitStateChange()}onMouseUp(e){this.clearLongPressTimer();const n=this.isPanning;if(this.isWaitingForPan=!1,this.isPanning=!1,this.removeListeners(),n){this.cdr.markForCheck();const o=i=>{i.stopImmediatePropagation(),i.preventDefault(),window.removeEventListener("click",o,!0)};window.addEventListener("click",o,!0),setTimeout(()=>window.removeEventListener("click",o,!0),50)}}_onMiddlePanMove(e){if(!this.isMiddlePanning)return;const n=e.clientX-this._midLastPoint.x,o=e.clientY-this._midLastPoint.y;this._midLastPoint={x:e.clientX,y:e.clientY};const i=this.pan(),a={x:i.x+n,y:i.y+o};this.pan.set(a),this.panChange.emit(a),this.emitStateChange()}_onMiddlePanUp(e){1===e.button&&this._stopMiddlePan()}_stopMiddlePan(){window.removeEventListener("mousemove",this._midMoveListener),window.removeEventListener("mouseup",this._midUpListener),this.isMiddlePanning&&(this.isMiddlePanning=!1,this.cdr.markForCheck())}onWheel(e){e.preventDefault();const n=this.zoomStep(),o=e.deltaY<0?1+n:1-n,a=this.elementRef.nativeElement.getBoundingClientRect(),l={x:e.clientX-a.left,y:e.clientY-a.top};this.zoomTo(this.zoom()*o,l)}zoomTo(e,n){const o=this.zoom(),i=this.pan(),a=Math.max(this.minZoom(),Math.min(this.maxZoom(),e));if(a===o)return;const l=a/o,d={x:n.x-(n.x-i.x)*l,y:n.y-(n.y-i.y)*l};this.zoom.set(a),this.pan.set(d),this.zoomChange.emit(a),this.panChange.emit(d),this.emitStateChange()}zoomIn(){this.zoomToCenter(this.zoom()+this.zoomStep())}zoomOut(){this.zoomToCenter(this.zoom()-this.zoomStep())}zoomToCenter(e){const n=this.elementRef.nativeElement;this.zoomTo(e,{x:n.clientWidth/2,y:n.clientHeight/2})}emitStateChange(){this.stateChange.emit({zoom:this.zoom(),pan:this.pan()})}static _touchDist(e,n){const o=n.clientX-e.clientX,i=n.clientY-e.clientY;return Math.sqrt(o*o+i*i)}_attachTouchListeners(){const e=this.elementRef.nativeElement;this._touchStartListener=n=>{2===n.touches.length&&(n.preventDefault(),this._pinchStartDist=s._touchDist(n.touches[0],n.touches[1]),this._pinchStartZoom=this.zoom())},this._touchMoveListener=n=>{if(2!==n.touches.length||(n.preventDefault(),0===this._pinchStartDist))return;const o=s._touchDist(n.touches[0],n.touches[1]),i=this._pinchStartZoom*(o/this._pinchStartDist),a=e.getBoundingClientRect();this.zoomTo(i,{x:(n.touches[0].clientX+n.touches[1].clientX)/2-a.left,y:(n.touches[0].clientY+n.touches[1].clientY)/2-a.top})},this._touchEndListener=n=>{n.touches.length<2&&(this._pinchStartDist=0)},e.addEventListener("touchstart",this._touchStartListener,{passive:!1}),e.addEventListener("touchmove",this._touchMoveListener,{passive:!1}),e.addEventListener("touchend",this._touchEndListener,{passive:!1})}_detachTouchListeners(){const e=this.elementRef.nativeElement;this._touchStartListener&&e.removeEventListener("touchstart",this._touchStartListener),this._touchMoveListener&&e.removeEventListener("touchmove",this._touchMoveListener),this._touchEndListener&&e.removeEventListener("touchend",this._touchEndListener)}static \u0275fac=function(n){return new(n||s)};static \u0275dir=t.FsC({type:s,selectors:[["","cuePanZoom",""]],hostVars:2,hostBindings:function(n,o){1&n&&t.bIt("mousedown",function(a){return o.onMouseDown(a)})("wheel",function(a){return o.onWheel(a)}),2&n&&t.xc7("cursor",o.cursorStyle())},inputs:{zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"],zoomStep:[1,"zoomStep"],panMode:[1,"panMode"],longPressThreshold:[1,"longPressThreshold"],dragThreshold:[1,"dragThreshold"]},outputs:{zoom:"zoomChange",pan:"panChange",zoomChange:"zoomChange",panChange:"panChange",stateChange:"stateChange"}})}return s})();const h=["container"],Z=["*"];let k=(()=>{class s{panZoomDirective=(0,g.ebz)(C);containerRef=(0,g.ebz)("container");zoom=(0,g.geq)(1);pan=(0,g.geq)({x:0,y:0});minZoom=(0,g.hFB)(.1);maxZoom=(0,g.hFB)(10);zoomStep=(0,g.hFB)(.1);panMode=(0,g.hFB)(!0);modelChange=(0,g.CGW)();get transform(){const{x:e,y:n}=this.pan();return`translate(${e}px, ${n}px) scale(${this.zoom()})`}onZoomChange(e){this.zoom.set(e),this.emitModelChange()}onPanChange(e){this.pan.set(e),this.emitModelChange()}emitModelChange(){this.modelChange.emit({pan:{...this.pan()},zoom:this.zoom()})}zoomFit(){this.zoom.set(this.minZoom()),this.pan.set({x:0,y:0}),this.emitModelChange()}zoomIn(){this.panZoomDirective()?.zoomIn()}zoomOut(){this.panZoomDirective()?.zoomOut()}zoomTo(e,n){this.panZoomDirective()?.zoomTo(e,n)}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=t.VBU({type:s,selectors:[["cue-pan-zoom"]],viewQuery:function(n,o){1&n&&t.wEZ(o.panZoomDirective,C,5)(o.containerRef,h,5),2&n&&t.NyB(2)},hostAttrs:[2,"display","block","width","100%","height","100%"],inputs:{zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"],zoomStep:[1,"zoomStep"],panMode:[1,"panMode"]},outputs:{zoom:"zoomChange",pan:"panChange",modelChange:"modelChange"},ngContentSelectors:Z,decls:5,vars:8,consts:[["container",""],["content",""],["cuePanZoom","",1,"pan-zoom-container",2,"width","100%","height","100%","overflow","hidden","position","relative","touch-action","none",3,"zoomChange","panChange","zoom","pan","minZoom","maxZoom","zoomStep","panMode"],[2,"position","absolute","left","0","top","0","transform-origin","0 0","backface-visibility","hidden"]],template:function(n,o){1&n&&(t.NAR(),t.j41(0,"div",2,0),t.bIt("zoomChange",function(a){return o.onZoomChange(a)})("panChange",function(a){return o.onPanChange(a)}),t.j41(2,"div",3,1),t.SdG(4),t.k0s()()),2&n&&(t.Y8G("zoom",o.zoom())("pan",o.pan())("minZoom",o.minZoom())("maxZoom",o.maxZoom())("zoomStep",o.zoomStep())("panMode",o.panMode()),t.R7$(2),t.xc7("transform",o.transform))},dependencies:[L.MD,C],encapsulation:2,changeDetection:0})}return s})();var G=_(2036),S=_(7023),B=_(4015),D=_(356),R=_(6279),f=_(5187),z=_(2245);class b{constructor(c=[],e=(n,o)=>n<o?-1:n>o?1:0){if(this.data=c,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(0===this.length)return;const c=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:e,compare:n}=this,o=e[c];for(;c>0;){const i=c-1>>1,a=e[i];if(n(o,a)>=0)break;e[c]=a,c=i}e[c]=o}_down(c){const{data:e,compare:n}=this,o=this.length>>1,i=e[c];for(;c<o;){let a=1+(c<<1);const l=a+1;if(l<this.length&&n(e[l],e[a])<0&&(a=l),n(e[a],i)>=0)break;e[c]=e[a],c=a}e[c]=i}}function j(s,c,e,n){this.x=s,this.y=c,this.h=e,this.d=function H(s,c,e){let n=!1,o=1/0;for(const i of e)for(let a=0,l=i.length,d=l-1;a<l;d=a++){const m=i[a],u=i[d];m[1]>c!=u[1]>c&&s<(u[0]-m[0])*(c-m[1])/(u[1]-m[1])+m[0]&&(n=!n),o=Math.min(o,Q(s,c,m,u))}return 0===o?0:(n?1:-1)*Math.sqrt(o)}(s,c,n),this.max=this.d+this.h*Math.SQRT2}function Q(s,c,e,n){let o=e[0],i=e[1],a=n[0]-o,l=n[1]-i;if(0!==a||0!==l){const d=((s-o)*a+(c-i)*l)/(a*a+l*l);d>1?(o=n[0],i=n[1]):d>0&&(o+=a*d,i+=l*d)}return a=s-o,l=c-i,a*a+l*l}let K=(()=>{class s{extractPathD(e){const n=e.match(/d="([^"]*)"/);return n?n[1]:null}parsePathToPolygon(e){const n=[],o=e.trim().split(/\s+/);let i=0;for(;i<o.length;){const a=o[i];if("M"===a||"L"===a)i++,i+1<o.length&&(n.push([parseFloat(o[i]),parseFloat(o[i+1])]),i+=2);else{const l=parseFloat(a);!isNaN(l)&&i+1<o.length?(n.push([l,parseFloat(o[i+1])]),i+=2):i++}}return n}getLabelPosition(e){const n=this.extractPathD(e);if(!n)return null;const o=this.parsePathToPolygon(n);if(o.length<3)return null;try{const i=function Y(s,c=1,e=!1){let n=1/0,o=1/0,i=-1/0,a=-1/0;for(const[y,x]of s[0])y<n&&(n=y),x<o&&(o=x),y>i&&(i=y),x>a&&(a=x);const l=i-n,d=a-o,m=Math.max(c,Math.min(l,d));if(m===c){const y=[n,o];return y.distance=0,y}const u=new b([],(y,x)=>x.max-y.max);let p=function U(s){let c=0,e=0,n=0;const o=s[0];for(let a=0,l=o.length,d=l-1;a<l;d=a++){const m=o[a],u=o[d],p=m[0]*u[1]-u[0]*m[1];e+=(m[0]+u[0])*p,n+=(m[1]+u[1])*p,c+=3*p}const i=new j(e/c,n/c,0,s);return 0===c||i.d<0?new j(o[0][0],o[0][1],0,s):i}(s);const v=new j(n+l/2,o+d/2,0,s);v.d>p.d&&(p=v);let M=2;function P(y,x,V){const I=new j(y,x,V,s);M++,I.max>p.d+c&&u.push(I),I.d>p.d&&(p=I,e&&console.log(`found best ${Math.round(1e4*I.d)/1e4} after ${M} probes`))}let w=m/2;for(let y=n;y<i;y+=m)for(let x=o;x<a;x+=m)P(y+w,x+w,w);for(;u.length;){const{max:y,x,y:V,h:I}=u.pop();if(y-p.d<=c)break;w=I/2,P(x-w,V-w,w),P(x+w,V-w,w),P(x-w,V+w,w),P(x+w,V+w,w)}e&&console.log(`num probes: ${M}\nbest distance: ${p.d}`);const E=[p.x,p.y];return E.distance=p.d,E}([o],.01);return{x:i[0],y:i[1]}}catch{return null}}getLabelFontSize(e){const n=this.extractPathD(e);if(!n)return.3;const o=this.parsePathToPolygon(n);if(o.length<3)return.3;const i=o.map(u=>u[0]),a=o.map(u=>u[1]),l=Math.max(...i)-Math.min(...i),d=Math.max(...a)-Math.min(...a),m=Math.min(l,d);return Math.max(m/5,.05)}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac,providedIn:"root"})}return s})(),N=(()=>{class s{editingArtefact=(0,r.vPA)(null);isEditing=(0,r.vPA)(!1);editStart=(0,r.vPA)(null);editHandle=(0,r.vPA)("body");hasDragged=!1;hasEdited=!1;originalArtefact=null;drawingArtefacts;mouseToImagePercent;parseXYWH;polygonService;artefactEdited;editMoveListener=this.onEditMouseMove.bind(this);editUpListener=this.onEditMouseUp.bind(this);init(e){this.drawingArtefacts=e.drawingArtefacts,this.mouseToImagePercent=e.mouseToImagePercent,this.parseXYWH=e.parseXYWH,this.polygonService=e.polygonService,this.artefactEdited=e.artefactEdited}startEditArtefact(e,n){this.editingArtefact.set({type:e,index:n});const o=this.drawingArtefacts();let i;"bbox"===e?i=o.xywhs[n]:"circle"===e?i=o.circles[n]:"polygon"===e&&(i=o.polygons[n]),this.originalArtefact=i?{...i}:null}cancelEdit(){const e=this.editingArtefact();if(e&&this.hasEdited&&this.originalArtefact){const n=this.drawingArtefacts();let o;"bbox"===e.type?o=n.xywhs[e.index]:"circle"===e.type?o=n.circles[e.index]:"polygon"===e.type&&(o=n.polygons[e.index]),o&&this.artefactEdited.emit({type:e.type,index:e.index,before:this.originalArtefact,after:o})}this.editingArtefact.set(null),this.isEditing.set(!1),this.editStart.set(null),this.editHandle.set("body"),this.hasEdited=!1,this.originalArtefact=null,window.removeEventListener("mousemove",this.editMoveListener),window.removeEventListener("mouseup",this.editUpListener)}onEditMouseDown(e,n="body"){if(!this.editingArtefact()||0!==e.button)return;e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);o&&(this.isEditing.set(!0),this.editStart.set(o),this.editHandle.set(n),this.hasDragged=!1,window.addEventListener("mousemove",this.editMoveListener),window.addEventListener("mouseup",this.editUpListener))}onEditMouseMove(e){if(!this.isEditing())return;e.preventDefault();const n=this.mouseToImagePercent(e),o=this.editStart(),i=this.editingArtefact();if(!n||!o||!i)return;const a=this.editHandle();if("string"==typeof a&&a.startsWith("vertex:")){const m=parseInt(a.split(":")[1],10);return this.polygonService.applyVertexDrag(i.index,m,n,e.shiftKey),this.editStart.set(n),this.hasDragged=!0,void(this.hasEdited=!0)}const l=n.x-o.x,d=n.y-o.y;this.editStart.set(n),this.hasDragged=!0,this.hasEdited=!0,this.applyEditDelta(i,l,d)}onEditMouseUp(e){if(this.isEditing()){if(window.removeEventListener("mousemove",this.editMoveListener),window.removeEventListener("mouseup",this.editUpListener),"body"===this.editHandle()&&!this.hasDragged)return void this.cancelEdit();if(this.isEditing.set(!1),this.editStart.set(null),this.hasEdited){const n=this.editingArtefact();if(n&&this.originalArtefact){const o=this.drawingArtefacts();let i;"bbox"===n.type?i=o.xywhs[n.index]:"circle"===n.type?i=o.circles[n.index]:"polygon"===n.type&&(i=o.polygons[n.index]),i&&(this.artefactEdited.emit({type:n.type,index:n.index,before:this.originalArtefact,after:i}),this.originalArtefact={...i},this.hasEdited=!1)}}}}applyEditDelta(e,n,o){const i=this.editHandle();"body"===i?this.applyMoveDelta(e,n,o):"radius"===i?this.applyCircleRadiusDelta(e.index,n,o):this.applyResizeDelta(e,i,n,o)}applyMoveDelta(e,n,o){this.drawingArtefacts.update(i=>{if("bbox"===e.type){const a=[...i.xywhs],l=a[e.index];if(!l)return i;const d=this.parseXYWH(l.xywhStr);if(!d)return i;const m=Math.max(0,d.x+n),u=Math.max(0,d.y+o);return a[e.index]={...l,xywhStr:`percent:${m.toFixed(2)},${u.toFixed(2)},${d.width.toFixed(2)},${d.height.toFixed(2)}`},{...i,xywhs:a}}if("circle"===e.type){const a=[...i.circles],l=a[e.index];return l?(a[e.index]={...l,cx:l.cx+n,cy:l.cy+o},{...i,circles:a}):i}if("polygon"===e.type){const a=[...i.polygons],l=a[e.index];return l?(a[e.index]={...l,points:l.points.map(([d,m])=>[d+n,m+o])},{...i,polygons:a}):i}return i})}applyResizeDelta(e,n,o,i){"bbox"===e.type&&this.drawingArtefacts.update(a=>{const l=[...a.xywhs],d=l[e.index];if(!d)return a;const m=this.parseXYWH(d.xywhStr);if(!m)return a;let{x:u,y:p,width:v,height:M}=m;return n.includes("w")&&(u+=o,v-=o),n.includes("e")&&(v+=o),n.includes("n")&&(p+=i,M-=i),n.includes("s")&&(M+=i),v<.5&&(v=.5),M<.5&&(M=.5),l[e.index]={...d,xywhStr:`percent:${u.toFixed(2)},${p.toFixed(2)},${v.toFixed(2)},${M.toFixed(2)}`},{...a,xywhs:l}})}applyCircleRadiusDelta(e,n,o){this.drawingArtefacts.update(i=>{const a=[...i.circles],l=a[e];if(!l)return i;const d=Math.sqrt(n*n+o*o)*Math.sign(n||o);return a[e]={...l,r:Math.max(.5,l.r+d)},{...i,circles:a}})}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})(),$=(()=>{class s{isDrawing=(0,r.vPA)(!1);drawStart=(0,r.vPA)(null);drawCurrent=(0,r.vPA)(null);drawMode;drawColor;drawnArtefactDef;artefactDrawn;mouseToImagePercent;imageDimensions;drawingArtefacts;drawMoveListener=this.onDrawMouseMove.bind(this);drawUpListener=this.onDrawMouseUp.bind(this);initialized=(0,r.vPA)(!1);drawPreview=(0,T.EW)(()=>{if(!this.initialized()||"xywh"!==this.drawMode())return null;const e=this.drawStart(),n=this.drawCurrent();if(!e||!n)return null;const o=Math.min(e.x,n.x),i=Math.min(e.y,n.y),a=Math.abs(n.x-e.x),l=Math.abs(n.y-e.y);return a<.1&&l<.1?null:{x:o,y:i,width:a,height:l,color:this.drawColor()}});circleDrawPreview=(0,T.EW)(()=>{if(!this.initialized()||"circle"!==this.drawMode())return null;const e=this.drawStart(),n=this.drawCurrent();if(!e||!n)return null;const o=Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));return o<.1?null:{cx:e.x,cy:e.y,r:o,color:this.drawColor()}});init(e){this.drawMode=e.drawMode,this.drawColor=e.drawColor,this.drawnArtefactDef=e.drawnArtefactDef,this.artefactDrawn=e.artefactDrawn,this.mouseToImagePercent=e.mouseToImagePercent,this.imageDimensions=e.imageDimensions,this.drawingArtefacts=e.drawingArtefacts,this.initialized.set(!0)}onDrawMouseDown(e){const n=this.drawMode();if("xywh"!==n&&"circle"!==n||0!==e.button)return;e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);o&&(this.isDrawing.set(!0),this.drawStart.set(o),this.drawCurrent.set(o),window.addEventListener("mousemove",this.drawMoveListener),window.addEventListener("mouseup",this.drawUpListener))}onDrawMouseMove(e){if(!this.isDrawing())return;e.preventDefault();const n=this.mouseToImagePercent(e);n&&this.drawCurrent.set(n)}onDrawMouseUp(e){if(!this.isDrawing())return;e?.preventDefault(),window.removeEventListener("mousemove",this.drawMoveListener),window.removeEventListener("mouseup",this.drawUpListener);const n=this.drawStart(),o=this.drawCurrent(),i=this.drawMode();if(n&&o)if("xywh"===i){const a=Math.min(n.x,o.x),l=Math.min(n.y,o.y),d=Math.abs(o.x-n.x),m=Math.abs(o.y-n.y);if(d>.5&&m>.5){const p={...this.drawnArtefactDef(),xywhStr:`percent:${a.toFixed(2)},${l.toFixed(2)},${d.toFixed(2)},${m.toFixed(2)}`,color:this.drawColor()},v={x:a,y:l,width:d,height:m};this.artefactDrawn.emit({type:"xywh",def:p,pct:v,abs:this.pctRectToAbs(v)}),this.drawingArtefacts.update(M=>({...M,xywhs:[...M.xywhs,p]}))}}else if("circle"===i){const a=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2));if(a>.5){const d={...this.drawnArtefactDef(),cx:n.x,cy:n.y,r:a,color:this.drawColor()},m=this.imageDimensions();this.artefactDrawn.emit({type:"circle",def:d,pct:{cx:n.x,cy:n.y,r:a},abs:{cx:m?n.x/100*m.width:n.x,cy:m?n.y/100*m.height:n.y,r:m?a/100*m.width:a}}),this.drawingArtefacts.update(u=>({...u,circles:[...u.circles,d]}))}}this.isDrawing.set(!1),this.drawStart.set(null),this.drawCurrent.set(null)}pctRectToAbs(e){const n=this.imageDimensions();return n?{x:e.x/100*n.width,y:e.y/100*n.height,width:e.width/100*n.width,height:e.height/100*n.height}:e}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})(),O=(()=>{class s{polygonPoints=(0,r.vPA)([]);polygonCursor=(0,r.vPA)(null);lastPolygonClickTime=0;axisSnapLines=(0,r.vPA)({});drawColor;drawnArtefactDef;artefactDrawn;mouseToImagePercent;imageAspectRatio;zoom;imageDimensions;drawingArtefacts;polygonMoveListener=this.onPolygonMouseMove.bind(this);polygonEscListener=this.onPolygonEsc.bind(this);initialized=(0,r.vPA)(!1);polygonDrawPreview=(0,T.EW)(()=>{if(!this.initialized())return null;const e=this.polygonPoints();if(0===e.length)return null;const n=this.polygonCursor();return{points:e,cursorPoint:n?[n.x,n.y]:null,color:this.drawColor()}});init(e){this.drawColor=e.drawColor,this.drawnArtefactDef=e.drawnArtefactDef,this.artefactDrawn=e.artefactDrawn,this.mouseToImagePercent=e.mouseToImagePercent,this.imageAspectRatio=e.imageAspectRatio,this.zoom=e.zoom,this.imageDimensions=e.imageDimensions,this.drawingArtefacts=e.drawingArtefacts,this.initialized.set(!0)}onPolygonClick(e){if(0!==e.button)return;const n=Date.now();if(n-this.lastPolygonClickTime<300)return;this.lastPolygonClickTime=n,e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);if(!o)return;const i=this.polygonPoints(),a=this.applySnapping(o,i,e.shiftKey);if(i.length>=3){const l=i[0],d=a.x-l[0],m=a.y-l[1];if(Math.sqrt(d*d+m*m)<this.closeThreshold)return void this.finishPolygon()}this.polygonPoints.update(l=>[...l,[a.x,a.y]]),this.polygonCursor.set(null),0===i.length&&(window.addEventListener("mousemove",this.polygonMoveListener),window.addEventListener("keydown",this.polygonEscListener))}cancelPolygon(){window.removeEventListener("mousemove",this.polygonMoveListener),window.removeEventListener("keydown",this.polygonEscListener),this.polygonPoints.set([]),this.polygonCursor.set(null),this.axisSnapLines.set({})}applyVertexDrag(e,n,o,i){this.drawingArtefacts.update(a=>{const l=[...a.polygons],d=l[e];if(!d)return a;const m=[...d.points.map(M=>[...M])];if(n<0||n>=m.length)return a;const u=m.filter((M,P)=>P!==n);let p=null;m.length>1&&(p=n>0?m[n-1]:m[n+1]);let v=o;return i&&p&&(v=this.snapTo45({x:p[0],y:p[1]},o)),v=this.snapToAxis(v,u,null,i?"none":"both"),m[n]=[v.x,v.y],l[e]={...d,points:m},{...a,polygons:l}})}snapTo45(e,n){const o=this.imageAspectRatio(),i=n.x-e.x,a=(n.y-e.y)/o,l=Math.atan2(a,i),d=Math.round(l/(Math.PI/4))*(Math.PI/4),m=Math.sqrt(i*i+a*a);return{x:e.x+m*Math.cos(d),y:e.y+m*Math.sin(d)*o}}get closeThreshold(){return 1.5/this.zoom()}get axisSnapThresholdX(){const e=this.imageDimensions?.();return e&&0!==e.width?24/(e.width*this.zoom()/100):1.5}get axisSnapThresholdY(){const e=this.imageDimensions?.();return e&&0!==e.height?24/(e.height*this.zoom()/100):1.5}applySnapping(e,n,o){const i=n.length>0?n[n.length-1]:null,a=n.length>1?n.slice(0,-1):[];if(!o||!i)return this.snapToAxis(e,a,i,"both");const l=this.snapTo45({x:i[0],y:i[1]},e),d=Math.abs(l.x-i[0]),m=Math.abs(l.y-i[1]),u=d+m+.001;let p;return p=d/u<.01?"y":m/u<.01?"x":"none",this.snapToAxis(l,a,i,p)}snapToAxis(e,n,o,i){if("none"===i||0===n.length)return this.axisSnapLines.set({}),e;let u,p,{x:a,y:l}=e,d=this.axisSnapThresholdX,m=this.axisSnapThresholdY;const v="x"===i||"both"===i,M="y"===i||"both"===i;for(const[P,w]of n){const E=o&&Math.abs(P-o[0])<.5,y=o&&Math.abs(w-o[1])<.5;if(v&&!E){const x=Math.abs(a-P);x<d&&(d=x,a=P,u=P)}if(M&&!y){const x=Math.abs(l-w);x<m&&(m=x,l=w,p=w)}}return this.axisSnapLines.set({x:u,y:p}),{x:a,y:l}}onPolygonMouseMove(e){const n=this.mouseToImagePercent(e);if(!n)return;const o=this.polygonPoints();this.polygonCursor.set(this.applySnapping(n,o,e.shiftKey))}finishPolygon(){const e=this.polygonPoints();if(e.length<3)return;window.removeEventListener("mousemove",this.polygonMoveListener),window.removeEventListener("keydown",this.polygonEscListener);const o={...this.drawnArtefactDef(),points:[...e],color:this.drawColor()},i=this.imageDimensions();this.artefactDrawn.emit({type:"polygon",def:o,pct:{points:[...e]},abs:{points:e.map(([a,l])=>[i?a/100*i.width:a,i?l/100*i.height:l])}}),this.polygonPoints.set([]),this.polygonCursor.set(null)}onPolygonEsc(e){"Escape"===e.key&&this.cancelPolygon()}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})();const q=["imageElement"],J=["*"],ee=(s,c)=>({artefact:s,type:"bbox",index:c}),te=(s,c)=>({artefact:s,type:"circle",index:c}),ne=(s,c)=>({artefact:s,type:"polygon",index:c}),oe=(s,c)=>({artefact:s,type:"svgPath",index:c}),ie=(s,c)=>e=>{const n=r.eBV(c).$implicit;return r.Njj(!e.visible||e.visible(n))},se=(s,c)=>c.label;function ae(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG();t.xc7("transform","scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function re(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",11),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.isContextMenuOpen.set(!1))})("click",function(o){const i=r.eBV(e).$implicit,a=t.XpG();return r.Njj(a.handleBboxClick(i,o))}),t.nVh(1,ae,2,4,"cue-card",12),t.k0s()}if(2&s){const e=c.$implicit,n=t.XpG(),o=t.sdS(17);t.xc7("left",e.x,"%")("top",e.y,"%")("width",e.width,"%")("height",e.height,"%")("border-color",e.color||"rgba(255, 0, 0, 0.8)")("border-width",3/n.zoom()+"px")("background-color",!1===e.showFill?"transparent":n.getBgColor(e.color)),t.AVh("clickable",n.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit)("removable",!!e.allowRemove),t.Y8G("title",e.label||"")("cueContextMenu",o)("contextMenuData",t.l_i(23,ee,e,e.sourceIndex))("cueContextEnabled",n.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.R7$(),t.vxM(e.label?1:-1)}}function ce(s,c){if(1&s&&t.nrm(0,"div",15),2&s){const e=c,n=t.XpG();t.xc7("left",e.x,"%")("top",e.y,"%")("width",e.width,"%")("height",e.height,"%")("border-color",e.color)("border-width",3/n.zoom()+"px")("background-color",n.getBgColor(e.color))}}function le(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"ellipse",17),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default"),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(14,te,e,n))("cueContextEnabled",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.BMQ("cx",e.cx)("cy",e.cy)("rx",e.r)("ry",e.r*o.imageAspectRatio())("stroke",e.color||"rgba(255, 0, 0, 0.8)")("fill",!1===e.showFill?"none":o.getBgColor(e.color))("stroke-width",3/o.zoom())}}function de(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG(2);t.xc7("left",e.cx,"%")("top",e.cy-e.r*n.imageAspectRatio(),"%")("transform","scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function me(s,c){1&s&&t.nVh(0,de,2,8,"cue-card",18),2&s&&t.vxM(c.$implicit.label?0:-1)}function he(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.Z7z(1,le,1,17,":svg:ellipse",16,t.Vm6),t.k0s(),t.Z7z(3,me,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.R7$(),t.Dyx(e.drawingArtefacts().circles),t.R7$(2),t.Dyx(e.drawingArtefacts().circles)}}function ue(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.nrm(1,"ellipse",19),t.k0s()),2&s){const e=c,n=t.XpG();t.R7$(),t.BMQ("cx",e.cx)("cy",e.cy)("rx",e.r)("ry",e.r*n.imageAspectRatio())("stroke",e.color)("fill",n.getBgColor(e.color))("stroke-width",3/n.zoom())}}function ge(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"polygon",21),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default"),t.AVh("clickable",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(13,ne,e,n))("cueContextEnabled",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.BMQ("points",o.pointsToAttr(e.points))("stroke",e.color||"rgba(255, 0, 0, 0.8)")("fill",!1===e.showFill?"none":o.getBgColor(e.color))("stroke-width",3/o.zoom())}}function pe(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG(2);t.xc7("left",n.polygonCentroid(e.points).x,"%")("top",n.polygonCentroid(e.points).y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function _e(s,c){1&s&&t.nVh(0,pe,2,8,"cue-card",18),2&s&&t.vxM(c.$implicit.label?0:-1)}function fe(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.Z7z(1,ge,1,16,":svg:polygon",20,t.Vm6),t.k0s(),t.Z7z(3,_e,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.R7$(),t.Dyx(e.drawingArtefacts().polygons),t.R7$(2),t.Dyx(e.drawingArtefacts().polygons)}}function we(s,c){if(1&s&&(r.qSk(),t.nrm(0,"line",25)(1,"line",26)),2&s){const e=t.XpG(),n=t.XpG();t.BMQ("x1",e.points[e.points.length-1][0])("y1",e.points[e.points.length-1][1])("x2",e.cursorPoint[0])("y2",e.cursorPoint[1])("stroke",e.color)("stroke-width",2/n.zoom()),t.R7$(),t.BMQ("x1",e.cursorPoint[0])("y1",e.cursorPoint[1])("x2",e.points[0][0])("y2",e.points[0][1])("stroke",e.color)("stroke-width",1/n.zoom())}}function xe(s,c){if(1&s&&t.nrm(0,"div",27),2&s){const e=c.$implicit,n=t.XpG(),o=t.XpG();t.xc7("left",e[0],"%")("top",e[1],"%")("transform","translate(-50%, -50%) scale("+1/o.zoom()+")")("background",n.color)}}function ve(s,c){if(1&s&&t.nrm(0,"div",28),2&s){const e=t.XpG(),n=t.XpG();t.xc7("left",e.cursorPoint[0],"%")("top",e.cursorPoint[1],"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")("background",e.color)}}function Me(s,c){if(1&s&&t.nrm(0,"div",31),2&s){const e=t.XpG();t.xc7("left",e.x,"%")}}function ye(s,c){if(1&s&&t.nrm(0,"div",32),2&s){const e=t.XpG();t.xc7("top",e.y,"%")}}function be(s,c){if(1&s&&(t.nVh(0,Me,1,2,"div",29),t.nVh(1,ye,1,2,"div",30)),2&s){const e=c;t.vxM(void 0!==e.x?0:-1),t.R7$(),t.vxM(void 0!==e.y?1:-1)}}function Ce(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.nrm(1,"polyline",22),t.nVh(2,we,2,12),t.k0s(),t.Z7z(3,xe,1,8,"div",23,t.Vm6),t.nVh(5,ve,1,8,"div",24),t.nVh(6,be,2,2)),2&s){let e;const n=c,o=t.XpG();t.R7$(),t.BMQ("points",o.pointsToAttr(n.points))("stroke",n.color)("stroke-width",3/o.zoom()),t.R7$(),t.vxM(n.cursorPoint?2:-1),t.R7$(),t.Dyx(n.points),t.R7$(2),t.vxM(n.cursorPoint&&!o.isCursorOnVertex(n.cursorPoint,n.points)?5:-1),t.R7$(),t.vxM((e=o.polygonService.axisSnapLines())?6:-1,e)}}function De(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",33),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG();return r.Njj("polygon"===i.drawMode()?i.polygonService.onPolygonClick(o):i.drawingService.onDrawMouseDown(o))})("keydown.escape",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.polygonService.cancelPolygon())}),t.k0s()}}function Pe(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",35),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"nw"))}),t.k0s(),t.j41(1,"div",36),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"ne"))}),t.k0s(),t.j41(2,"div",37),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"sw"))}),t.k0s(),t.j41(3,"div",38),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"se"))}),t.k0s(),t.j41(4,"div",39),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"n"))}),t.k0s(),t.j41(5,"div",40),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"s"))}),t.k0s(),t.j41(6,"div",41),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"w"))}),t.k0s(),t.j41(7,"div",42),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"e"))}),t.k0s()}if(2&s){const e=t.XpG().$implicit,n=t.XpG(3);t.xc7("left",e.x,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width/2,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width/2,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x,"%")("top",e.y+e.height/2,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y+e.height/2,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function ze(s,c){if(1&s&&t.nVh(0,Pe,8,48),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Te(s,c){if(1&s&&t.Z7z(0,ze,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.boundingBoxes())}}function Ie(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",43),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(1,"div",43),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(2,"div",44),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(3,"div",44),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s()}if(2&s){const e=t.XpG().$implicit,n=t.XpG(3);t.xc7("left",e.cx+e.r,"%")("top",e.cy,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx-e.r,"%")("top",e.cy,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx,"%")("top",e.cy-e.r*n.imageAspectRatio(),"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx,"%")("top",e.cy+e.r*n.imageAspectRatio(),"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function Ee(s,c){if(1&s&&t.nVh(0,Ie,4,24),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Ve(s,c){if(1&s&&t.Z7z(0,Ee,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.drawingArtefacts().circles)}}function ke(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",46),t.bIt("mousedown",function(o){const i=r.eBV(e).$index,a=t.XpG(5);return r.Njj(a.editService.onEditMouseDown(o,"vertex:"+i))}),t.k0s()}if(2&s){const e=c.$implicit,n=t.XpG(5);t.xc7("left",e[0],"%")("top",e[1],"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function Ae(s,c){if(1&s&&t.Z7z(0,ke,1,6,"div",45,t.Vm6),2&s){const e=t.XpG().$implicit;t.Dyx(e.points)}}function Le(s,c){if(1&s&&t.nVh(0,Ae,2,0),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Se(s,c){if(1&s&&t.Z7z(0,Le,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.drawingArtefacts().polygons)}}function Re(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",34),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG();return r.Njj(i.editService.onEditMouseDown(o,"body"))}),t.nVh(1,Te,2,0),t.nVh(2,Ve,2,0),t.nVh(3,Se,2,0),t.k0s()}if(2&s){const e=c;t.R7$(),t.vxM("bbox"===e.type?1:-1),t.R7$(),t.vxM("circle"===e.type?2:-1),t.R7$(),t.vxM("polygon"===e.type?3:-1)}}function je(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"g",49),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))})("click",function(o){const i=r.eBV(e).$implicit,a=t.XpG(2);return r.Njj(a.handleSvgPathClick(i,o))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default")("--dxf-sw",null!=e.strokeWidth&&o.zoom()?e.strokeWidth/o.zoom():null),t.AVh("clickable",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(18,oe,e,n))("cueContextEnabled",o.contextMenuItems().length>0&&o.contextMenuItems().some(t._m7(17,ie,c))||!!e.allowRemove||!!e.allowEdit)("innerHTML",o.safeSvg(e.svg),t.npT),t.BMQ("title",e.label||"")("transform",e.transform||null)("stroke",e.color||"#ffa8a8")("fill",e.fillColor||"none")("stroke-dasharray",e.strokeDashArray||null)}}function Fe(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=c,n=t.XpG().$implicit,o=t.XpG(2);t.xc7("left",e.x,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/o.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",n.label,t.npT)}}function Xe(s,c){if(1&s&&t.nVh(0,Fe,2,8,"cue-card",18),2&s){let e;const n=c.$implicit,o=t.XpG(2);t.vxM((e=n.label&&o.getSvgLabelPositionPercent(n.svg,n.transform))?0:-1,e)}}function Ze(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",47),t.Z7z(1,je,1,21,":svg:g",48,t.Vm6),t.k0s(),t.Z7z(3,Xe,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.BMQ("viewBox",e.svgViewBox()),t.R7$(),t.Dyx(e.drawingArtefacts().svgPaths),t.R7$(2),t.Dyx(e.drawingArtefacts().svgPaths)}}function Ge(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG().$implicit,i=t.XpG(2).$implicit;return r.Njj(o.action(i.artefact))}),t.EFF(1),t.k0s()}if(2&s){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.label," ")}}function Be(s,c){if(1&s&&t.nVh(0,Ge,2,1,"cue-menu-item"),2&s){const e=c.$implicit,n=t.XpG(2).$implicit;t.vxM(!e.visible||e.visible(n.artefact)?0:-1)}}function Ne(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG(2).$implicit,i=t.XpG();return r.Njj(i.editService.startEditArtefact(o.type,"bbox"===o.type?o.artefact.sourceIndex:o.index))}),t.EFF(1),t.nI1(2,"transloco"),t.k0s()}2&s&&(t.R7$(),t.SpI(" ",t.bMT(2,1,"common.buttons.edit")," "))}function $e(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG(2).$implicit,i=t.XpG();return r.Njj("bbox"===o.type?i.removeArtefact(o.artefact):"circle"===o.type?i.removeCircleArtefact(o.index):"polygon"===o.type?i.removePolygonArtefact(o.index):i.removeSvgPathArtefact(o.index))}),t.EFF(1),t.nI1(2,"transloco"),t.k0s()}2&s&&(t.R7$(),t.SpI(" ",t.bMT(2,1,"common.buttons.delete")," "))}function Oe(s,c){if(1&s&&(t.j41(0,"cue-menu-wrap"),t.Z7z(1,Be,1,1,null,null,se),t.nVh(3,Ne,3,3,"cue-menu-item"),t.nVh(4,$e,3,3,"cue-menu-item"),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG();t.R7$(),t.Dyx(n.contextMenuItems()),t.R7$(2),t.vxM(!e.artefact.allowEdit||"bbox"!==e.type&&"circle"!==e.type&&"polygon"!==e.type?-1:3),t.R7$(),t.vxM(e.artefact.allowRemove?4:-1)}}function We(s,c){if(1&s&&t.nVh(0,Oe,5,2,"cue-menu-wrap"),2&s){const e=t.XpG();t.vxM(e.contextMenuItems().length>0?0:-1)}}function Ye(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-image-toolbar",52),t.mxI("zoomChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.zoom,o)||(i.zoom=o),r.Njj(o)})("panChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.pan,o)||(i.pan=o),r.Njj(o)})("activeToolChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.activeTool,o)||(i.activeTool=o),r.Njj(o)}),t.bIt("rotate",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleRotate())})("zoomIn",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleZoomIn())})("zoomOut",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleZoomOut())})("zoomFit",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.calculateFitZoom())}),t.k0s()}if(2&s){const e=t.XpG(),n=t.XpG();t.Aen(n.toolbarStyle()),t.Y8G("options",e),t.R50("zoom",n.zoom)("pan",n.pan)("activeTool",n.activeTool),t.Y8G("minZoom",n.minZoom())("maxZoom",n.maxZoom())}}function He(s,c){1&s&&t.nVh(0,Ye,1,8,"cue-image-toolbar",51),2&s&&t.vxM(c.hidden?-1:0)}let Ue=(()=>{class s{svgHelpers=(0,r.WQX)(K);editService=(0,r.WQX)(N);drawingService=(0,r.WQX)($);polygonService=(0,r.WQX)(O);sanitizer=(0,r.WQX)(X.up);onEscape(){this.polygonService.polygonPoints().length>0&&this.polygonService.cancelPolygon(),this.editService.editingArtefact()&&this.editService.cancelEdit()}onEnter(){this.editService.editingArtefact()&&this.editService.cancelEdit()}src=g.hFB.required();alt=(0,g.hFB)("");fitMode=(0,g.hFB)("contain");toolbarOptions=(0,g.hFB)(new A.g);drawMode=(0,g.hFB)("none");panDisabled=(0,g.hFB)(!1);zoomDisabled=(0,g.hFB)(!1);drawnArtefactDef=(0,g.hFB)({allowRemove:!0,allowEdit:!0,color:"rgba(255, 0, 0, 0.9)"});contextMenuItems=(0,g.hFB)([]);activeTool=(0,g.geq)("pan");drawingArtefacts=(0,g.geq)((0,G.x)());artefactSelected=(0,g.CGW)();artefactDrawn=(0,g.CGW)();artefactRemoved=(0,g.CGW)();artefactEdited=(0,g.CGW)();drawColor=(0,T.EW)(()=>this.drawnArtefactDef().color??"rgba(255, 0, 0, 0.9)");panModeActive=(0,T.EW)(()=>!this.panDisabled()&&"none"===this.drawMode()&&!this.editService.editingArtefact()&&!this.isContextMenuOpen()&&"select"!==this.activeTool());boundingBoxes=(0,T.EW)(()=>this.drawingArtefacts().xywhs.map((n,o)=>{const i=this.parseXYWH("string"==typeof n?n:n.xywhStr);return i&&0!==i.width&&0!==i.height?("object"==typeof n&&(i.color=n.color,i.label=n.label,i.showFill=n.showFill,i.allowRemove=n.allowRemove,i.allowEdit=n.allowEdit),i.sourceIndex=o,i):null}).filter(Boolean));panZoom=(0,g.ebz)(k);imageElement=(0,g.ebz)("imageElement");rotationAngle=(0,r.vPA)(0);pan=(0,r.vPA)({x:0,y:0});isContextMenuOpen=(0,r.vPA)(!1);isZooming=(0,r.vPA)(!1);_zoomEndTimer=null;constructor(){(0,r.QZP)(e=>{const n=this.panZoom();if(n){const o=n.containerRef()?.nativeElement;if(o){const i=new ResizeObserver(()=>{this.zoomDisabled()||this.calculateFitZoom()});i.observe(o),e(()=>i.disconnect())}}}),(0,r.QZP)(e=>{this.zoom(),this.isZooming.set(!0),this._zoomEndTimer&&clearTimeout(this._zoomEndTimer),this._zoomEndTimer=setTimeout(()=>this.isZooming.set(!1),150),e(()=>{this._zoomEndTimer&&clearTimeout(this._zoomEndTimer)})}),queueMicrotask(()=>{const e=this.mouseToImagePercent.bind(this),n=this.parseXYWH.bind(this);this.editService.init({drawingArtefacts:this.drawingArtefacts,mouseToImagePercent:e,parseXYWH:n,polygonService:this.polygonService,artefactEdited:this.artefactEdited}),this.drawingService.init({drawMode:this.drawMode,drawColor:this.drawColor,drawnArtefactDef:this.drawnArtefactDef,artefactDrawn:this.artefactDrawn,mouseToImagePercent:e,imageDimensions:this.imageDimensions,drawingArtefacts:this.drawingArtefacts}),this.polygonService.init({drawColor:this.drawColor,drawnArtefactDef:this.drawnArtefactDef,artefactDrawn:this.artefactDrawn,mouseToImagePercent:e,imageAspectRatio:this.imageAspectRatio,zoom:this.zoom,imageDimensions:this.imageDimensions,drawingArtefacts:this.drawingArtefacts})})}zoom=(0,r.vPA)(1);imageDimensions=(0,r.vPA)(null);imageAspectRatio=(0,T.EW)(()=>{const e=this.imageDimensions();return e&&0!==e.height?e.width/e.height:1});minZoom=(0,r.vPA)(1);maxZoom=(0,r.vPA)(10);toolbarStyle=(0,T.EW)(()=>{const e=this.toolbarOptions();return{position:"absolute",left:e.margin,right:e.margin,["top"===e.position?"top":"bottom"]:e.margin,"z-index":"1000",display:"flex","justify-content":"center"}});onImageLoad(){const e=this.imageElement()?.nativeElement;e&&(this.imageDimensions.set({width:e.naturalWidth,height:e.naturalHeight}),this.zoomDisabled()||this.calculateFitZoom())}calculateFitZoom(){const e=this.panZoom(),n=this.imageElement()?.nativeElement;!e||!n||requestAnimationFrame(()=>{const o=e.containerRef()?.nativeElement;if(!o)return;const i=o.getBoundingClientRect(),a=n.naturalWidth,l=n.naturalHeight;if(0===a||0===l)return;const d=i.width/a,m=i.height/l;let u=1;u="contain"===this.fitMode()?Math.min(d,m):"cover"===this.fitMode()?Math.max(d,m):1,this.minZoom.set(Math.min(u,1)),this.zoom.set(u),this.centerImage()})}centerImage(){const e=this.panZoom();e?requestAnimationFrame(()=>{const n=e.containerRef()?.nativeElement;if(!n)return;const o=n.getBoundingClientRect(),i=this.zoom(),a=this.imageDimensions()?.width||0,l=this.imageDimensions()?.height||0;this.pan.set({x:(o.width-a*i)/2,y:(o.height-l*i)/2})}):this.pan.set({x:0,y:0})}handleRotate(){this.rotationAngle.update(e=>(e-90)%360),this.pan.update(()=>({x:0,y:0}))}handleZoomIn(){this.panZoom()?.zoomIn()}handleZoomOut(){this.panZoom()?.zoomOut()}parseXYWH(e){try{const o=e.replace("percent:","").split(",").map(m=>parseFloat(m.trim()));if(4!==o.length||o.some(isNaN))return console.warn(`Invalid XYWH format: ${e}`),null;const[i,a,l,d]=o;return{x:i,y:a,width:l,height:d}}catch(n){return console.error(`Error parsing XYWH: ${e}`,n),null}}getBgColor(e){if(!e)return"rgba(255, 0, 0, 0.1)";const n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, 0.1)`;const o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const i=o[1];return`rgba(${parseInt(3===i.length?i[0]+i[0]:i.slice(0,2),16)}, ${parseInt(3===i.length?i[1]+i[1]:i.slice(2,4),16)}, ${parseInt(3===i.length?i[2]+i[2]:i.slice(4,6),16)}, 0.1)`}return e.replace(/rgba?\([^)]+\)/,"rgba(255, 0, 0, 0.1)")}mouseToImagePercent(e){const n=this.imageElement()?.nativeElement;if(!n)return null;const o=n.getBoundingClientRect(),a=(e.clientY-o.top)/o.height*100;return{x:Math.max(0,Math.min(100,(e.clientX-o.left)/o.width*100)),y:Math.max(0,Math.min(100,a))}}handleBboxClick(e,n){n.stopPropagation(),this.artefactSelected.emit(e)}removeArtefact(e){if(null==e.sourceIndex)return;const n=this.drawingArtefacts().xywhs[e.sourceIndex];this.drawingArtefacts.update(o=>({...o,xywhs:o.xywhs.filter((i,a)=>a!==e.sourceIndex)})),n&&this.artefactRemoved.emit(n)}removeCircleArtefact(e){const n=this.drawingArtefacts().circles[e];this.drawingArtefacts.update(o=>({...o,circles:o.circles.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}removePolygonArtefact(e){const n=this.drawingArtefacts().polygons[e];this.drawingArtefacts.update(o=>({...o,polygons:o.polygons.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}handleSvgPathClick(e,n){n.stopPropagation(),this.artefactSelected.emit(e)}removeSvgPathArtefact(e){const n=this.drawingArtefacts().svgPaths[e];this.drawingArtefacts.update(o=>({...o,svgPaths:o.svgPaths.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}svgViewBox=(0,T.EW)(()=>{const e=this.imageDimensions();if(e&&e.width>0&&e.height>0)return`0 0 ${e.width} ${e.height}`;const n=this.drawingArtefacts().svgPaths;if(n.length>0){const i=n[0].svg.match(/viewBox="([^"]+)"/);if(i)return i[1]}return"0 0 100 100"});getSvgLabelPositionPercent(e,n){const o=this.svgHelpers.getLabelPosition(e);if(!o)return null;const i=this.imageDimensions();if(!i||0===i.width||0===i.height)return null;let{x:a,y:l}=o;if(n){const d=n.match(/matrix\(\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*\)/);if(d){const[,m,u,p,v,M,P]=d.map(Number),E=u*a+v*l+P;a=m*a+p*l+M,l=E}}return{x:a/i.width*100,y:l/i.height*100}}pointsToAttr(e){return e.map(n=>n[0]+","+n[1]).join(" ")}polygonCentroid(e){let n=0,o=0;for(const i of e)n+=i[0],o+=i[1];return{x:n/e.length,y:o/e.length}}isCursorOnVertex(e,n){for(const o of n)if(Math.abs(e[0]-o[0])<.5&&Math.abs(e[1]-o[1])<.5)return!0;return!1}safeSvg(e){let n=e.trim();if(n.startsWith("<svg")){const i=(new DOMParser).parseFromString(n,"image/svg+xml"),a=i.querySelector("parsererror");a&&console.warn("[ImageViewer] safeSvg: SVG parse error",a.textContent),n=i.documentElement.innerHTML}return this.sanitizer.bypassSecurityTrustHtml(n)}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=t.VBU({type:s,selectors:[["cue-image-viewer"]],viewQuery:function(n,o){1&n&&t.wEZ(o.panZoom,k,5)(o.imageElement,q,5),2&n&&t.NyB(2)},hostBindings:function(n,o){1&n&&t.bIt("keydown.escape",function(){return o.onEscape()},t.EBC)("keydown.enter",function(){return o.onEnter()},t.EBC)},inputs:{src:[1,"src"],alt:[1,"alt"],fitMode:[1,"fitMode"],toolbarOptions:[1,"toolbarOptions"],drawMode:[1,"drawMode"],panDisabled:[1,"panDisabled"],zoomDisabled:[1,"zoomDisabled"],drawnArtefactDef:[1,"drawnArtefactDef"],contextMenuItems:[1,"contextMenuItems"],activeTool:[1,"activeTool"],drawingArtefacts:[1,"drawingArtefacts"]},outputs:{activeTool:"activeToolChange",drawingArtefacts:"drawingArtefactsChange",artefactSelected:"artefactSelected",artefactDrawn:"artefactDrawn",artefactRemoved:"artefactRemoved",artefactEdited:"artefactEdited"},features:[t.Jv_([N,$,O])],ngContentSelectors:J,decls:19,vars:19,consts:[["imageElement",""],["artefactContextMenu",""],[1,"container"],[2,"width","100%","height","100%",3,"zoomChange","panChange","minZoom","maxZoom","zoom","pan","zoomStep","panMode"],[1,"image-container"],["draggable","false",2,"max-width","none","height","auto","display","block","user-select","none",3,"load","src","alt"],["trigger","leftclick",1,"bounding-box-overlay",3,"clickable","removable","left","top","width","height","border-color","border-width","background-color","title","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bounding-box-overlay","draw-preview",3,"left","top","width","height","border-color","border-width","background-color"],["viewBox","0 0 100 100","preserveAspectRatio","none",1,"svg-overlay",2,"position","absolute","top","0","left","0","width","100%","height","100%","pointer-events","none","overflow","visible"],["tabindex","0",1,"draw-overlay"],[1,"draw-overlay","edit-overlay"],["trigger","leftclick",1,"bounding-box-overlay",3,"contextMenuOpen","contextMenuClose","click","title","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bbox-label",3,"transform"],[1,"bbox-label"],["size","xs","weight","medium",3,"noWrap","innerHTML"],[1,"bounding-box-overlay","draw-preview"],["vector-effect","non-scaling-stroke","trigger","leftclick",1,"clickable",3,"pointer-events","cursor","cueContextMenu","contextMenuData","cueContextEnabled"],["vector-effect","non-scaling-stroke","trigger","leftclick",1,"clickable",3,"contextMenuOpen","contextMenuClose","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bbox-label",3,"left","top","transform"],["vector-effect","non-scaling-stroke","stroke-dasharray","6 4"],["vector-effect","non-scaling-stroke","trigger","leftclick",3,"pointer-events","cursor","clickable","cueContextMenu","contextMenuData","cueContextEnabled"],["vector-effect","non-scaling-stroke","trigger","leftclick",3,"contextMenuOpen","contextMenuClose","cueContextMenu","contextMenuData","cueContextEnabled"],["fill","none","vector-effect","non-scaling-stroke","stroke-dasharray","6 4"],[1,"polygon-vertex",3,"left","top","transform","background"],[1,"polygon-vertex","cursor-preview",3,"left","top","transform","background"],["vector-effect","non-scaling-stroke","stroke-dasharray","4 4","opacity","0.6"],["vector-effect","non-scaling-stroke","stroke-dasharray","2 4","opacity","0.3"],[1,"polygon-vertex"],[1,"polygon-vertex","cursor-preview"],[1,"snap-guide","vertical",3,"left"],[1,"snap-guide","horizontal",3,"top"],[1,"snap-guide","vertical"],[1,"snap-guide","horizontal"],["tabindex","0",1,"draw-overlay",3,"mousedown","keydown.escape"],[1,"draw-overlay","edit-overlay",3,"mousedown"],[1,"resize-handle","nw",3,"mousedown"],[1,"resize-handle","ne",3,"mousedown"],[1,"resize-handle","sw",3,"mousedown"],[1,"resize-handle","se",3,"mousedown"],[1,"resize-handle","n",3,"mousedown"],[1,"resize-handle","s",3,"mousedown"],[1,"resize-handle","w",3,"mousedown"],[1,"resize-handle","e",3,"mousedown"],[1,"resize-handle","radius",3,"mousedown"],[1,"resize-handle","radius-v",3,"mousedown"],[1,"resize-handle","vertex",3,"left","top","transform"],[1,"resize-handle","vertex",3,"mousedown"],["preserveAspectRatio","none",1,"svg-overlay",2,"position","absolute","top","0","left","0","width","100%","height","100%","pointer-events","none","overflow","visible"],["trigger","leftclick",3,"clickable","pointer-events","cursor","cueContextMenu","contextMenuData","cueContextEnabled","--dxf-sw","innerHTML"],["trigger","leftclick",3,"contextMenuOpen","contextMenuClose","click","cueContextMenu","contextMenuData","cueContextEnabled","innerHTML"],[3,"click"],[3,"options","style","zoom","pan","activeTool","minZoom","maxZoom"],[3,"zoomChange","panChange","activeToolChange","rotate","zoomIn","zoomOut","zoomFit","options","zoom","pan","activeTool","minZoom","maxZoom"]],template:function(n,o){if(1&n){const i=t.RV6();t.NAR(),t.j41(0,"div",2)(1,"cue-pan-zoom",3),t.mxI("zoomChange",function(l){return r.eBV(i),t.DH7(o.zoom,l)||(o.zoom=l),r.Njj(l)})("panChange",function(l){return r.eBV(i),t.DH7(o.pan,l)||(o.pan=l),r.Njj(l)}),t.j41(2,"div",4)(3,"img",5,0),t.bIt("load",function(){return o.onImageLoad()}),t.k0s(),t.Z7z(5,re,2,26,"div",6,t.Vm6),t.nVh(7,ce,1,14,"div",7),t.nVh(8,he,5,0),t.nVh(9,ue,2,7,":svg:svg",8),t.nVh(10,fe,5,0),t.nVh(11,Ce,7,6),t.nVh(12,De,1,0,"div",9),t.nVh(13,Re,4,3,"div",10),t.nVh(14,Ze,5,1),t.SdG(15),t.DNE(16,We,1,1,"ng-template",null,1,t.C5r),t.k0s()(),t.nVh(18,He,1,1),t.k0s()}if(2&n){let i,a,l,d,m;t.R7$(),t.Y8G("minZoom",o.zoomDisabled()?o.zoom():o.minZoom())("maxZoom",o.zoomDisabled()?o.zoom():o.maxZoom()),t.R50("zoom",o.zoom)("pan",o.pan),t.Y8G("zoomStep",.1)("panMode",o.panModeActive()),t.R7$(),t.xc7("transform","rotate("+o.rotationAngle()+"deg)"),t.R7$(),t.Y8G("src",o.src(),t.B4B)("alt",o.alt()),t.R7$(2),t.Dyx(o.boundingBoxes()),t.R7$(2),t.vxM((i=o.drawingService.drawPreview())?7:-1,i),t.R7$(),t.vxM(o.drawingArtefacts().circles.length>0?8:-1),t.R7$(),t.vxM((a=o.drawingService.circleDrawPreview())?9:-1,a),t.R7$(),t.vxM(o.drawingArtefacts().polygons.length>0?10:-1),t.R7$(),t.vxM((l=o.polygonService.polygonDrawPreview())?11:-1,l),t.R7$(),t.vxM("none"!==o.drawMode()?12:-1),t.R7$(),t.vxM((d=o.editService.editingArtefact())?13:-1,d),t.R7$(),t.vxM(o.drawingArtefacts().svgPaths.length>0&&!o.isZooming()?14:-1),t.R7$(4),t.vxM((m=o.toolbarOptions())?18:-1,m)}},dependencies:[L.MD,A.F,k,S.Q,D.M,R.D,f.Card,z.o,B.Kj],styles:["[_nghost-%COMP%]{display:contents}.container[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;overflow:hidden;display:flex;flex-direction:column}.image-container[_ngcontent-%COMP%]{position:relative;height:auto}.bounding-box-overlay[_ngcontent-%COMP%]{position:absolute;border:3px solid rgba(255,0,0,.8);background-color:#ff00001a;box-sizing:border-box;pointer-events:none;z-index:5;transition:border-width .2s ease,background-color .2s ease}.bounding-box-overlay.clickable[_ngcontent-%COMP%]{pointer-events:auto;cursor:pointer}.bounding-box-overlay.clickable[_ngcontent-%COMP%]:hover{border-width:3px;background-color:#ff000040}.bbox-label[_ngcontent-%COMP%]{position:absolute;top:-12px;left:-28px;transform-origin:bottom left;pointer-events:none;z-index:6;--cue-card-padding-x: 8px;--cue-card-padding-y: 4px}cue-image-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.draw-overlay[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;cursor:crosshair;z-index:6}.edit-overlay[_ngcontent-%COMP%]{cursor:move;z-index:8}.resize-handle[_ngcontent-%COMP%]{position:absolute;width:8px;height:8px;background:#fff;border:2px solid rgba(0,120,215,.9);border-radius:2px;z-index:9;pointer-events:auto}.resize-handle.nw[_ngcontent-%COMP%]{cursor:nw-resize}.resize-handle.ne[_ngcontent-%COMP%]{cursor:ne-resize}.resize-handle.sw[_ngcontent-%COMP%]{cursor:sw-resize}.resize-handle.se[_ngcontent-%COMP%]{cursor:se-resize}.resize-handle.n[_ngcontent-%COMP%]{cursor:n-resize}.resize-handle.s[_ngcontent-%COMP%]{cursor:s-resize}.resize-handle.e[_ngcontent-%COMP%]{cursor:e-resize}.resize-handle.w[_ngcontent-%COMP%]{cursor:w-resize}.resize-handle.radius[_ngcontent-%COMP%]{cursor:ew-resize;border-radius:50%}.resize-handle.radius-v[_ngcontent-%COMP%]{cursor:ns-resize;border-radius:50%}.draw-preview[_ngcontent-%COMP%]{border-style:dashed!important;pointer-events:none;z-index:7}.bounding-box-overlay.removable[_ngcontent-%COMP%]{pointer-events:auto}.polygon-vertex[_ngcontent-%COMP%]{position:absolute;width:8px;height:8px;border-radius:50%;border:2px solid white;pointer-events:none;z-index:7}.polygon-vertex.cursor-preview[_ngcontent-%COMP%]{opacity:.6}.snap-guide[_ngcontent-%COMP%]{position:absolute;pointer-events:none;z-index:6}.snap-guide.vertical[_ngcontent-%COMP%]{top:0;bottom:0;width:0;border-left:1px dashed rgba(0,200,255,.7)}.snap-guide.horizontal[_ngcontent-%COMP%]{left:0;right:0;height:0;border-top:1px dashed rgba(0,200,255,.7)}"],changeDetection:0})}return s})()}}]);
|
|
1
|
+
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[560],{5600(W,F,_){_.d(F,{F:()=>B,g:()=>S});var r=_(7705),g=_(2271),T=_(7089),X=_(5381),A=_(5187),L=_(1696),t=_(3319),C=_(5802),h=_(5547);function Z(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-flexcontainer",3)(1,"cue-button",6),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.activeTool.set("pan"))}),h.nrm(2,"cue-button-icon",7),h.k0s(),h.j41(3,"cue-button",8),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.activeTool.set("select"))}),h.nrm(4,"cue-button-icon",9),h.k0s()()}if(2&D){const f=h.XpG();h.R7$(),h.Y8G("variant","pan"===f.activeTool()?"secondary":"tertiary"),h.R7$(2),h.Y8G("variant","select"===f.activeTool()?"secondary":"tertiary")}}function k(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-flexcontainer",3)(1,"cue-button",10),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomOut())}),h.nrm(2,"cue-button-icon",11),h.k0s(),h.j41(3,"cue-button",12),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomIn())}),h.nrm(4,"cue-button-icon",13),h.k0s(),h.j41(5,"cue-button",14),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.handleZoomFit())}),h.nrm(6,"cue-button-icon",15),h.k0s()()}if(2&D){const f=h.XpG();h.AVh("border-left",f.options().displayPanSelectTools),h.R7$(),h.Y8G("disabled",f.zoom()<=f.minZoom())("cueTooltip",f.zoom()<=f.minZoom()?"Minimum zoom reached":"Zoom out")}}function G(D,R){if(1&D){const f=h.RV6();h.j41(0,"cue-button",16),h.bIt("click",function(){C.eBV(f);const b=h.XpG();return C.Njj(b.rotate.emit())}),h.nrm(1,"cue-button-icon",17),h.k0s()}if(2&D){const f=h.XpG();h.AVh("border-left",f.options().displayZoom&&f.options().displayRotate)}}class S{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayRotate=!0;displayPanSelectTools=!1}let B=(()=>{class D{options=(0,r.hFB)(new S);activeTool=(0,r.geq)("pan");panMode=(0,r.geq)(!1);zoom=(0,r.geq)(1);pan=(0,r.geq)({x:0,y:0});minZoom=(0,r.hFB)(1);maxZoom=(0,r.hFB)(10);rotate=(0,r.CGW)();zoomIn=(0,r.CGW)();zoomOut=(0,r.CGW)();zoomFit=(0,r.CGW)();selectMenuPositions=(0,g.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this.zoomIn.emit()}handleZoomOut(){this.zoomOut.emit()}handleZoomFit(){this.zoomFit.emit()}static \u0275fac=function(z){return new(z||D)};static \u0275cmp=h.VBU({type:D,selectors:[["cue-image-toolbar"]],inputs:{options:[1,"options"],activeTool:[1,"activeTool"],panMode:[1,"panMode"],zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"]},outputs:{activeTool:"activeToolChange",panMode:"panModeChange",zoom:"zoomChange",pan:"panChange",rotate:"rotate",zoomIn:"zoomIn",zoomOut:"zoomOut",zoomFit:"zoomFit"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["align","center","gap","s",3,"border-left"],["cueTooltip","Rotate","size","xs","variant","tertiary",3,"border-left"],["size","xs","cueTooltip","Pan mode \u2014 drag to move the view",3,"click","variant"],["icon","move-grab"],["size","xs","cueTooltip","Select mode \u2014 drag to draw a selection window",3,"click","variant"],["icon","move-click"],["size","xs","variant","tertiary",3,"click","disabled","cueTooltip"],["icon","zoom-out"],["cueTooltip","Zoom in","size","xs","variant","tertiary",3,"click"],["icon","zoom-in"],["cueTooltip","Zoom fit","size","xs","variant","tertiary",3,"click"],["icon","zoom-fit"],["cueTooltip","Rotate","size","xs","variant","tertiary",3,"click"],["icon","rotate-2d"]],template:function(z,b){1&z&&(h.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),h.nVh(3,Z,5,2,"cue-flexcontainer",3),h.nVh(4,k,7,4,"cue-flexcontainer",4),h.nVh(5,G,2,2,"cue-button",5),h.k0s()()()),2&z&&(h.R7$(),h.Y8G("padded",!1),h.R7$(2),h.vxM(b.options().displayPanSelectTools?3:-1),h.R7$(),h.vxM(b.options().displayZoom?4:-1),h.R7$(),h.vxM(b.options().displayRotate?5:-1))},dependencies:[X.n,A.Z,L.$,t.a,T.d],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return D})()},8560(W,F,_){_.d(F,{ImageViewer:()=>Ue});var r=_(5802),g=_(7705),T=_(2271),X=_(345),A=_(5600),L=_(9769),t=_(5547);let C=(()=>{class s{elementRef=(0,r.WQX)(t.aKT);cdr=(0,r.WQX)(g.gRc);zoom=(0,g.geq)(1);pan=(0,g.geq)({x:0,y:0});minZoom=(0,g.hFB)(1);maxZoom=(0,g.hFB)(10);zoomStep=(0,g.hFB)(.1);panMode=(0,g.hFB)(!0,{transform:e=>{const n=""===e||"false"!==e&&!!e;return!n&&(this.isPanning||this.isWaitingForPan)&&this.onMouseUp(),n}});longPressThreshold=(0,g.hFB)(150);dragThreshold=(0,g.hFB)(3);zoomChange=(0,g.CGW)();panChange=(0,g.CGW)();stateChange=(0,g.CGW)();isPanning=!1;lastPoint={x:0,y:0};isWaitingForPan=!1;downPoint={x:0,y:0};longPressTimer=null;moveListener;upListener;leaveListener;blurListener;visibilityListener;keyListener;contextMenuListener;pointerCancelListener;listenersAttached=!1;isMiddlePanning=!1;_midLastPoint={x:0,y:0};_midMoveListener;_midUpListener;_pinchStartDist=0;_pinchStartZoom=1;_touchStartListener;_touchMoveListener;_touchEndListener;constructor(){this.moveListener=this.onMouseMove.bind(this),this.upListener=this.onMouseUp.bind(this),this.leaveListener=this.onMouseUp.bind(this),this.blurListener=this.onMouseUp.bind(this),this.visibilityListener=()=>{document.hidden&&this.onMouseUp()},this.keyListener=e=>{"Escape"===e.key&&this.onMouseUp()},this.contextMenuListener=this.onMouseUp.bind(this),this.pointerCancelListener=this.onMouseUp.bind(this),this._midMoveListener=this._onMiddlePanMove.bind(this),this._midUpListener=this._onMiddlePanUp.bind(this)}ngOnInit(){this._attachTouchListeners()}ngOnDestroy(){this.removeListeners(),this.clearLongPressTimer(),this._detachTouchListeners(),this._stopMiddlePan()}addListeners(){this.listenersAttached||(this.listenersAttached=!0,window.addEventListener("mousemove",this.moveListener),window.addEventListener("mouseup",this.upListener,!0),window.addEventListener("blur",this.blurListener),document.addEventListener("visibilitychange",this.visibilityListener),document.addEventListener("keydown",this.keyListener),document.addEventListener("contextmenu",this.contextMenuListener),document.addEventListener("pointercancel",this.pointerCancelListener))}removeListeners(){this.listenersAttached=!1,window.removeEventListener("mousemove",this.moveListener),window.removeEventListener("mouseup",this.upListener,!0),window.removeEventListener("blur",this.blurListener),document.removeEventListener("visibilitychange",this.visibilityListener),document.removeEventListener("keydown",this.keyListener),document.removeEventListener("contextmenu",this.contextMenuListener),document.removeEventListener("pointercancel",this.pointerCancelListener)}clearLongPressTimer(){null!==this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}cursorStyle(){return this.isMiddlePanning?"grabbing":this.panMode()?this.isPanning?"grabbing":"grab":null}onMouseDown(e){if(1===e.button)return e.preventDefault(),this.isMiddlePanning=!0,this._midLastPoint={x:e.clientX,y:e.clientY},this.cdr.markForCheck(),window.addEventListener("mousemove",this._midMoveListener),void window.addEventListener("mouseup",this._midUpListener);!this.panMode()||0!==e.button||(e.composedPath?e.composedPath():[]).some(i=>i.hasAttribute&&i.hasAttribute("data-no-pan"))||((this.isPanning||this.isWaitingForPan)&&(this.clearLongPressTimer(),this.isWaitingForPan=!1,this.isPanning=!1,this.removeListeners()),this.isWaitingForPan=!0,this.downPoint={x:e.clientX,y:e.clientY},this.lastPoint={x:e.clientX,y:e.clientY},this.addListeners())}startPanning(){this.clearLongPressTimer(),this.isWaitingForPan=!1,this.isPanning=!0,this.cdr.markForCheck()}onMouseMove(e){if(!this.isWaitingForPan&&!this.isPanning)return;if(this.isWaitingForPan&&!this.isPanning){const l=e.clientX-this.downPoint.x,d=e.clientY-this.downPoint.y;if(Math.sqrt(l*l+d*d)>=this.dragThreshold()){e.preventDefault(),this.startPanning();const u=this.pan(),p={x:u.x+l,y:u.y+d};this.lastPoint={x:e.clientX,y:e.clientY},this.pan.set(p),this.panChange.emit(p),this.emitStateChange()}return}e.preventDefault();const n=e.clientX-this.lastPoint.x,o=e.clientY-this.lastPoint.y;this.lastPoint={x:e.clientX,y:e.clientY};const i=this.pan(),a={x:i.x+n,y:i.y+o};this.pan.set(a),this.panChange.emit(a),this.emitStateChange()}onMouseUp(e){this.clearLongPressTimer();const n=this.isPanning;if(this.isWaitingForPan=!1,this.isPanning=!1,this.removeListeners(),n){this.cdr.markForCheck();const o=i=>{i.stopImmediatePropagation(),i.preventDefault(),window.removeEventListener("click",o,!0)};window.addEventListener("click",o,!0),setTimeout(()=>window.removeEventListener("click",o,!0),50)}}_onMiddlePanMove(e){if(!this.isMiddlePanning)return;const n=e.clientX-this._midLastPoint.x,o=e.clientY-this._midLastPoint.y;this._midLastPoint={x:e.clientX,y:e.clientY};const i=this.pan(),a={x:i.x+n,y:i.y+o};this.pan.set(a),this.panChange.emit(a),this.emitStateChange()}_onMiddlePanUp(e){1===e.button&&this._stopMiddlePan()}_stopMiddlePan(){window.removeEventListener("mousemove",this._midMoveListener),window.removeEventListener("mouseup",this._midUpListener),this.isMiddlePanning&&(this.isMiddlePanning=!1,this.cdr.markForCheck())}onWheel(e){e.preventDefault();const n=this.zoomStep(),o=e.deltaY<0?1+n:1-n,a=this.elementRef.nativeElement.getBoundingClientRect(),l={x:e.clientX-a.left,y:e.clientY-a.top};this.zoomTo(this.zoom()*o,l)}zoomTo(e,n){const o=this.zoom(),i=this.pan(),a=Math.max(this.minZoom(),Math.min(this.maxZoom(),e));if(a===o)return;const l=a/o,d={x:n.x-(n.x-i.x)*l,y:n.y-(n.y-i.y)*l};this.zoom.set(a),this.pan.set(d),this.zoomChange.emit(a),this.panChange.emit(d),this.emitStateChange()}zoomIn(){this.zoomToCenter(this.zoom()+this.zoomStep())}zoomOut(){this.zoomToCenter(this.zoom()-this.zoomStep())}zoomToCenter(e){const n=this.elementRef.nativeElement;this.zoomTo(e,{x:n.clientWidth/2,y:n.clientHeight/2})}emitStateChange(){this.stateChange.emit({zoom:this.zoom(),pan:this.pan()})}static _touchDist(e,n){const o=n.clientX-e.clientX,i=n.clientY-e.clientY;return Math.sqrt(o*o+i*i)}_attachTouchListeners(){const e=this.elementRef.nativeElement;this._touchStartListener=n=>{2===n.touches.length&&(n.preventDefault(),this._pinchStartDist=s._touchDist(n.touches[0],n.touches[1]),this._pinchStartZoom=this.zoom())},this._touchMoveListener=n=>{if(2!==n.touches.length||(n.preventDefault(),0===this._pinchStartDist))return;const o=s._touchDist(n.touches[0],n.touches[1]),i=this._pinchStartZoom*(o/this._pinchStartDist),a=e.getBoundingClientRect();this.zoomTo(i,{x:(n.touches[0].clientX+n.touches[1].clientX)/2-a.left,y:(n.touches[0].clientY+n.touches[1].clientY)/2-a.top})},this._touchEndListener=n=>{n.touches.length<2&&(this._pinchStartDist=0)},e.addEventListener("touchstart",this._touchStartListener,{passive:!1}),e.addEventListener("touchmove",this._touchMoveListener,{passive:!1}),e.addEventListener("touchend",this._touchEndListener,{passive:!1})}_detachTouchListeners(){const e=this.elementRef.nativeElement;this._touchStartListener&&e.removeEventListener("touchstart",this._touchStartListener),this._touchMoveListener&&e.removeEventListener("touchmove",this._touchMoveListener),this._touchEndListener&&e.removeEventListener("touchend",this._touchEndListener)}static \u0275fac=function(n){return new(n||s)};static \u0275dir=t.FsC({type:s,selectors:[["","cuePanZoom",""]],hostVars:2,hostBindings:function(n,o){1&n&&t.bIt("mousedown",function(a){return o.onMouseDown(a)})("wheel",function(a){return o.onWheel(a)}),2&n&&t.xc7("cursor",o.cursorStyle())},inputs:{zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"],zoomStep:[1,"zoomStep"],panMode:[1,"panMode"],longPressThreshold:[1,"longPressThreshold"],dragThreshold:[1,"dragThreshold"]},outputs:{zoom:"zoomChange",pan:"panChange",zoomChange:"zoomChange",panChange:"panChange",stateChange:"stateChange"}})}return s})();const h=["container"],Z=["*"];let k=(()=>{class s{panZoomDirective=(0,g.ebz)(C);containerRef=(0,g.ebz)("container");zoom=(0,g.geq)(1);pan=(0,g.geq)({x:0,y:0});minZoom=(0,g.hFB)(.1);maxZoom=(0,g.hFB)(10);zoomStep=(0,g.hFB)(.1);panMode=(0,g.hFB)(!0);modelChange=(0,g.CGW)();get transform(){const{x:e,y:n}=this.pan();return`translate(${e}px, ${n}px) scale(${this.zoom()})`}onZoomChange(e){this.zoom.set(e),this.emitModelChange()}onPanChange(e){this.pan.set(e),this.emitModelChange()}emitModelChange(){this.modelChange.emit({pan:{...this.pan()},zoom:this.zoom()})}zoomFit(){this.zoom.set(this.minZoom()),this.pan.set({x:0,y:0}),this.emitModelChange()}zoomIn(){this.panZoomDirective()?.zoomIn()}zoomOut(){this.panZoomDirective()?.zoomOut()}zoomTo(e,n){this.panZoomDirective()?.zoomTo(e,n)}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=t.VBU({type:s,selectors:[["cue-pan-zoom"]],viewQuery:function(n,o){1&n&&t.wEZ(o.panZoomDirective,C,5)(o.containerRef,h,5),2&n&&t.NyB(2)},hostAttrs:[2,"display","block","width","100%","height","100%"],inputs:{zoom:[1,"zoom"],pan:[1,"pan"],minZoom:[1,"minZoom"],maxZoom:[1,"maxZoom"],zoomStep:[1,"zoomStep"],panMode:[1,"panMode"]},outputs:{zoom:"zoomChange",pan:"panChange",modelChange:"modelChange"},ngContentSelectors:Z,decls:5,vars:8,consts:[["container",""],["content",""],["cuePanZoom","",1,"pan-zoom-container",2,"width","100%","height","100%","overflow","hidden","position","relative","touch-action","none",3,"zoomChange","panChange","zoom","pan","minZoom","maxZoom","zoomStep","panMode"],[2,"position","absolute","left","0","top","0","transform-origin","0 0","backface-visibility","hidden"]],template:function(n,o){1&n&&(t.NAR(),t.j41(0,"div",2,0),t.bIt("zoomChange",function(a){return o.onZoomChange(a)})("panChange",function(a){return o.onPanChange(a)}),t.j41(2,"div",3,1),t.SdG(4),t.k0s()()),2&n&&(t.Y8G("zoom",o.zoom())("pan",o.pan())("minZoom",o.minZoom())("maxZoom",o.maxZoom())("zoomStep",o.zoomStep())("panMode",o.panMode()),t.R7$(2),t.xc7("transform",o.transform))},dependencies:[L.MD,C],encapsulation:2,changeDetection:0})}return s})();var G=_(2036),S=_(7023),B=_(4015),D=_(356),R=_(6279),f=_(5187),z=_(2245);class b{constructor(c=[],e=(n,o)=>n<o?-1:n>o?1:0){if(this.data=c,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(0===this.length)return;const c=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:e,compare:n}=this,o=e[c];for(;c>0;){const i=c-1>>1,a=e[i];if(n(o,a)>=0)break;e[c]=a,c=i}e[c]=o}_down(c){const{data:e,compare:n}=this,o=this.length>>1,i=e[c];for(;c<o;){let a=1+(c<<1);const l=a+1;if(l<this.length&&n(e[l],e[a])<0&&(a=l),n(e[a],i)>=0)break;e[c]=e[a],c=a}e[c]=i}}function j(s,c,e,n){this.x=s,this.y=c,this.h=e,this.d=function H(s,c,e){let n=!1,o=1/0;for(const i of e)for(let a=0,l=i.length,d=l-1;a<l;d=a++){const m=i[a],u=i[d];m[1]>c!=u[1]>c&&s<(u[0]-m[0])*(c-m[1])/(u[1]-m[1])+m[0]&&(n=!n),o=Math.min(o,Q(s,c,m,u))}return 0===o?0:(n?1:-1)*Math.sqrt(o)}(s,c,n),this.max=this.d+this.h*Math.SQRT2}function Q(s,c,e,n){let o=e[0],i=e[1],a=n[0]-o,l=n[1]-i;if(0!==a||0!==l){const d=((s-o)*a+(c-i)*l)/(a*a+l*l);d>1?(o=n[0],i=n[1]):d>0&&(o+=a*d,i+=l*d)}return a=s-o,l=c-i,a*a+l*l}let K=(()=>{class s{extractPathD(e){const n=e.match(/d="([^"]*)"/);return n?n[1]:null}parsePathToPolygon(e){const n=[],o=e.trim().split(/\s+/);let i=0;for(;i<o.length;){const a=o[i];if("M"===a||"L"===a)i++,i+1<o.length&&(n.push([parseFloat(o[i]),parseFloat(o[i+1])]),i+=2);else{const l=parseFloat(a);!isNaN(l)&&i+1<o.length?(n.push([l,parseFloat(o[i+1])]),i+=2):i++}}return n}getLabelPosition(e){const n=this.extractPathD(e);if(!n)return null;const o=this.parsePathToPolygon(n);if(o.length<3)return null;try{const i=function Y(s,c=1,e=!1){let n=1/0,o=1/0,i=-1/0,a=-1/0;for(const[y,x]of s[0])y<n&&(n=y),x<o&&(o=x),y>i&&(i=y),x>a&&(a=x);const l=i-n,d=a-o,m=Math.max(c,Math.min(l,d));if(m===c){const y=[n,o];return y.distance=0,y}const u=new b([],(y,x)=>x.max-y.max);let p=function U(s){let c=0,e=0,n=0;const o=s[0];for(let a=0,l=o.length,d=l-1;a<l;d=a++){const m=o[a],u=o[d],p=m[0]*u[1]-u[0]*m[1];e+=(m[0]+u[0])*p,n+=(m[1]+u[1])*p,c+=3*p}const i=new j(e/c,n/c,0,s);return 0===c||i.d<0?new j(o[0][0],o[0][1],0,s):i}(s);const v=new j(n+l/2,o+d/2,0,s);v.d>p.d&&(p=v);let M=2;function P(y,x,V){const I=new j(y,x,V,s);M++,I.max>p.d+c&&u.push(I),I.d>p.d&&(p=I,e&&console.log(`found best ${Math.round(1e4*I.d)/1e4} after ${M} probes`))}let w=m/2;for(let y=n;y<i;y+=m)for(let x=o;x<a;x+=m)P(y+w,x+w,w);for(;u.length;){const{max:y,x,y:V,h:I}=u.pop();if(y-p.d<=c)break;w=I/2,P(x-w,V-w,w),P(x+w,V-w,w),P(x-w,V+w,w),P(x+w,V+w,w)}e&&console.log(`num probes: ${M}\nbest distance: ${p.d}`);const E=[p.x,p.y];return E.distance=p.d,E}([o],.01);return{x:i[0],y:i[1]}}catch{return null}}getLabelFontSize(e){const n=this.extractPathD(e);if(!n)return.3;const o=this.parsePathToPolygon(n);if(o.length<3)return.3;const i=o.map(u=>u[0]),a=o.map(u=>u[1]),l=Math.max(...i)-Math.min(...i),d=Math.max(...a)-Math.min(...a),m=Math.min(l,d);return Math.max(m/5,.05)}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac,providedIn:"root"})}return s})(),N=(()=>{class s{editingArtefact=(0,r.vPA)(null);isEditing=(0,r.vPA)(!1);editStart=(0,r.vPA)(null);editHandle=(0,r.vPA)("body");hasDragged=!1;hasEdited=!1;originalArtefact=null;drawingArtefacts;mouseToImagePercent;parseXYWH;polygonService;artefactEdited;editMoveListener=this.onEditMouseMove.bind(this);editUpListener=this.onEditMouseUp.bind(this);init(e){this.drawingArtefacts=e.drawingArtefacts,this.mouseToImagePercent=e.mouseToImagePercent,this.parseXYWH=e.parseXYWH,this.polygonService=e.polygonService,this.artefactEdited=e.artefactEdited}startEditArtefact(e,n){this.editingArtefact.set({type:e,index:n});const o=this.drawingArtefacts();let i;"bbox"===e?i=o.xywhs[n]:"circle"===e?i=o.circles[n]:"polygon"===e&&(i=o.polygons[n]),this.originalArtefact=i?{...i}:null}cancelEdit(){const e=this.editingArtefact();if(e&&this.hasEdited&&this.originalArtefact){const n=this.drawingArtefacts();let o;"bbox"===e.type?o=n.xywhs[e.index]:"circle"===e.type?o=n.circles[e.index]:"polygon"===e.type&&(o=n.polygons[e.index]),o&&this.artefactEdited.emit({type:e.type,index:e.index,before:this.originalArtefact,after:o})}this.editingArtefact.set(null),this.isEditing.set(!1),this.editStart.set(null),this.editHandle.set("body"),this.hasEdited=!1,this.originalArtefact=null,window.removeEventListener("mousemove",this.editMoveListener),window.removeEventListener("mouseup",this.editUpListener)}onEditMouseDown(e,n="body"){if(!this.editingArtefact()||0!==e.button)return;e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);o&&(this.isEditing.set(!0),this.editStart.set(o),this.editHandle.set(n),this.hasDragged=!1,window.addEventListener("mousemove",this.editMoveListener),window.addEventListener("mouseup",this.editUpListener))}onEditMouseMove(e){if(!this.isEditing())return;e.preventDefault();const n=this.mouseToImagePercent(e),o=this.editStart(),i=this.editingArtefact();if(!n||!o||!i)return;const a=this.editHandle();if("string"==typeof a&&a.startsWith("vertex:")){const m=parseInt(a.split(":")[1],10);return this.polygonService.applyVertexDrag(i.index,m,n,e.shiftKey),this.editStart.set(n),this.hasDragged=!0,void(this.hasEdited=!0)}const l=n.x-o.x,d=n.y-o.y;this.editStart.set(n),this.hasDragged=!0,this.hasEdited=!0,this.applyEditDelta(i,l,d)}onEditMouseUp(e){if(this.isEditing()){if(window.removeEventListener("mousemove",this.editMoveListener),window.removeEventListener("mouseup",this.editUpListener),"body"===this.editHandle()&&!this.hasDragged)return void this.cancelEdit();if(this.isEditing.set(!1),this.editStart.set(null),this.hasEdited){const n=this.editingArtefact();if(n&&this.originalArtefact){const o=this.drawingArtefacts();let i;"bbox"===n.type?i=o.xywhs[n.index]:"circle"===n.type?i=o.circles[n.index]:"polygon"===n.type&&(i=o.polygons[n.index]),i&&(this.artefactEdited.emit({type:n.type,index:n.index,before:this.originalArtefact,after:i}),this.originalArtefact={...i},this.hasEdited=!1)}}}}applyEditDelta(e,n,o){const i=this.editHandle();"body"===i?this.applyMoveDelta(e,n,o):"radius"===i?this.applyCircleRadiusDelta(e.index,n,o):this.applyResizeDelta(e,i,n,o)}applyMoveDelta(e,n,o){this.drawingArtefacts.update(i=>{if("bbox"===e.type){const a=[...i.xywhs],l=a[e.index];if(!l)return i;const d=this.parseXYWH(l.xywhStr);if(!d)return i;const m=Math.max(0,d.x+n),u=Math.max(0,d.y+o);return a[e.index]={...l,xywhStr:`percent:${m.toFixed(2)},${u.toFixed(2)},${d.width.toFixed(2)},${d.height.toFixed(2)}`},{...i,xywhs:a}}if("circle"===e.type){const a=[...i.circles],l=a[e.index];return l?(a[e.index]={...l,cx:l.cx+n,cy:l.cy+o},{...i,circles:a}):i}if("polygon"===e.type){const a=[...i.polygons],l=a[e.index];return l?(a[e.index]={...l,points:l.points.map(([d,m])=>[d+n,m+o])},{...i,polygons:a}):i}return i})}applyResizeDelta(e,n,o,i){"bbox"===e.type&&this.drawingArtefacts.update(a=>{const l=[...a.xywhs],d=l[e.index];if(!d)return a;const m=this.parseXYWH(d.xywhStr);if(!m)return a;let{x:u,y:p,width:v,height:M}=m;return n.includes("w")&&(u+=o,v-=o),n.includes("e")&&(v+=o),n.includes("n")&&(p+=i,M-=i),n.includes("s")&&(M+=i),v<.5&&(v=.5),M<.5&&(M=.5),l[e.index]={...d,xywhStr:`percent:${u.toFixed(2)},${p.toFixed(2)},${v.toFixed(2)},${M.toFixed(2)}`},{...a,xywhs:l}})}applyCircleRadiusDelta(e,n,o){this.drawingArtefacts.update(i=>{const a=[...i.circles],l=a[e];if(!l)return i;const d=Math.sqrt(n*n+o*o)*Math.sign(n||o);return a[e]={...l,r:Math.max(.5,l.r+d)},{...i,circles:a}})}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})(),$=(()=>{class s{isDrawing=(0,r.vPA)(!1);drawStart=(0,r.vPA)(null);drawCurrent=(0,r.vPA)(null);drawMode;drawColor;drawnArtefactDef;artefactDrawn;mouseToImagePercent;imageDimensions;drawingArtefacts;drawMoveListener=this.onDrawMouseMove.bind(this);drawUpListener=this.onDrawMouseUp.bind(this);initialized=(0,r.vPA)(!1);drawPreview=(0,T.EW)(()=>{if(!this.initialized()||"xywh"!==this.drawMode())return null;const e=this.drawStart(),n=this.drawCurrent();if(!e||!n)return null;const o=Math.min(e.x,n.x),i=Math.min(e.y,n.y),a=Math.abs(n.x-e.x),l=Math.abs(n.y-e.y);return a<.1&&l<.1?null:{x:o,y:i,width:a,height:l,color:this.drawColor()}});circleDrawPreview=(0,T.EW)(()=>{if(!this.initialized()||"circle"!==this.drawMode())return null;const e=this.drawStart(),n=this.drawCurrent();if(!e||!n)return null;const o=Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));return o<.1?null:{cx:e.x,cy:e.y,r:o,color:this.drawColor()}});init(e){this.drawMode=e.drawMode,this.drawColor=e.drawColor,this.drawnArtefactDef=e.drawnArtefactDef,this.artefactDrawn=e.artefactDrawn,this.mouseToImagePercent=e.mouseToImagePercent,this.imageDimensions=e.imageDimensions,this.drawingArtefacts=e.drawingArtefacts,this.initialized.set(!0)}onDrawMouseDown(e){const n=this.drawMode();if("xywh"!==n&&"circle"!==n||0!==e.button)return;e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);o&&(this.isDrawing.set(!0),this.drawStart.set(o),this.drawCurrent.set(o),window.addEventListener("mousemove",this.drawMoveListener),window.addEventListener("mouseup",this.drawUpListener))}onDrawMouseMove(e){if(!this.isDrawing())return;e.preventDefault();const n=this.mouseToImagePercent(e);n&&this.drawCurrent.set(n)}onDrawMouseUp(e){if(!this.isDrawing())return;e?.preventDefault(),window.removeEventListener("mousemove",this.drawMoveListener),window.removeEventListener("mouseup",this.drawUpListener);const n=this.drawStart(),o=this.drawCurrent(),i=this.drawMode();if(n&&o)if("xywh"===i){const a=Math.min(n.x,o.x),l=Math.min(n.y,o.y),d=Math.abs(o.x-n.x),m=Math.abs(o.y-n.y);if(d>.5&&m>.5){const p={...this.drawnArtefactDef(),xywhStr:`percent:${a.toFixed(2)},${l.toFixed(2)},${d.toFixed(2)},${m.toFixed(2)}`,color:this.drawColor()},v={x:a,y:l,width:d,height:m};this.artefactDrawn.emit({type:"xywh",def:p,pct:v,abs:this.pctRectToAbs(v)}),this.drawingArtefacts.update(M=>({...M,xywhs:[...M.xywhs,p]}))}}else if("circle"===i){const a=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2));if(a>.5){const d={...this.drawnArtefactDef(),cx:n.x,cy:n.y,r:a,color:this.drawColor()},m=this.imageDimensions();this.artefactDrawn.emit({type:"circle",def:d,pct:{cx:n.x,cy:n.y,r:a},abs:{cx:m?n.x/100*m.width:n.x,cy:m?n.y/100*m.height:n.y,r:m?a/100*m.width:a}}),this.drawingArtefacts.update(u=>({...u,circles:[...u.circles,d]}))}}this.isDrawing.set(!1),this.drawStart.set(null),this.drawCurrent.set(null)}pctRectToAbs(e){const n=this.imageDimensions();return n?{x:e.x/100*n.width,y:e.y/100*n.height,width:e.width/100*n.width,height:e.height/100*n.height}:e}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})(),O=(()=>{class s{polygonPoints=(0,r.vPA)([]);polygonCursor=(0,r.vPA)(null);lastPolygonClickTime=0;axisSnapLines=(0,r.vPA)({});drawColor;drawnArtefactDef;artefactDrawn;mouseToImagePercent;imageAspectRatio;zoom;imageDimensions;drawingArtefacts;polygonMoveListener=this.onPolygonMouseMove.bind(this);polygonEscListener=this.onPolygonEsc.bind(this);initialized=(0,r.vPA)(!1);polygonDrawPreview=(0,T.EW)(()=>{if(!this.initialized())return null;const e=this.polygonPoints();if(0===e.length)return null;const n=this.polygonCursor();return{points:e,cursorPoint:n?[n.x,n.y]:null,color:this.drawColor()}});init(e){this.drawColor=e.drawColor,this.drawnArtefactDef=e.drawnArtefactDef,this.artefactDrawn=e.artefactDrawn,this.mouseToImagePercent=e.mouseToImagePercent,this.imageAspectRatio=e.imageAspectRatio,this.zoom=e.zoom,this.imageDimensions=e.imageDimensions,this.drawingArtefacts=e.drawingArtefacts,this.initialized.set(!0)}onPolygonClick(e){if(0!==e.button)return;const n=Date.now();if(n-this.lastPolygonClickTime<300)return;this.lastPolygonClickTime=n,e.preventDefault(),e.stopPropagation();const o=this.mouseToImagePercent(e);if(!o)return;const i=this.polygonPoints(),a=this.applySnapping(o,i,e.shiftKey);if(i.length>=3){const l=i[0],d=a.x-l[0],m=a.y-l[1];if(Math.sqrt(d*d+m*m)<this.closeThreshold)return void this.finishPolygon()}this.polygonPoints.update(l=>[...l,[a.x,a.y]]),this.polygonCursor.set(null),0===i.length&&(window.addEventListener("mousemove",this.polygonMoveListener),window.addEventListener("keydown",this.polygonEscListener))}cancelPolygon(){window.removeEventListener("mousemove",this.polygonMoveListener),window.removeEventListener("keydown",this.polygonEscListener),this.polygonPoints.set([]),this.polygonCursor.set(null),this.axisSnapLines.set({})}applyVertexDrag(e,n,o,i){this.drawingArtefacts.update(a=>{const l=[...a.polygons],d=l[e];if(!d)return a;const m=[...d.points.map(M=>[...M])];if(n<0||n>=m.length)return a;const u=m.filter((M,P)=>P!==n);let p=null;m.length>1&&(p=n>0?m[n-1]:m[n+1]);let v=o;return i&&p&&(v=this.snapTo45({x:p[0],y:p[1]},o)),v=this.snapToAxis(v,u,null,i?"none":"both"),m[n]=[v.x,v.y],l[e]={...d,points:m},{...a,polygons:l}})}snapTo45(e,n){const o=this.imageAspectRatio(),i=n.x-e.x,a=(n.y-e.y)/o,l=Math.atan2(a,i),d=Math.round(l/(Math.PI/4))*(Math.PI/4),m=Math.sqrt(i*i+a*a);return{x:e.x+m*Math.cos(d),y:e.y+m*Math.sin(d)*o}}get closeThreshold(){return 1.5/this.zoom()}get axisSnapThresholdX(){const e=this.imageDimensions?.();return e&&0!==e.width?24/(e.width*this.zoom()/100):1.5}get axisSnapThresholdY(){const e=this.imageDimensions?.();return e&&0!==e.height?24/(e.height*this.zoom()/100):1.5}applySnapping(e,n,o){const i=n.length>0?n[n.length-1]:null,a=n.length>1?n.slice(0,-1):[];if(!o||!i)return this.snapToAxis(e,a,i,"both");const l=this.snapTo45({x:i[0],y:i[1]},e),d=Math.abs(l.x-i[0]),m=Math.abs(l.y-i[1]),u=d+m+.001;let p;return p=d/u<.01?"y":m/u<.01?"x":"none",this.snapToAxis(l,a,i,p)}snapToAxis(e,n,o,i){if("none"===i||0===n.length)return this.axisSnapLines.set({}),e;let u,p,{x:a,y:l}=e,d=this.axisSnapThresholdX,m=this.axisSnapThresholdY;const v="x"===i||"both"===i,M="y"===i||"both"===i;for(const[P,w]of n){const E=o&&Math.abs(P-o[0])<.5,y=o&&Math.abs(w-o[1])<.5;if(v&&!E){const x=Math.abs(a-P);x<d&&(d=x,a=P,u=P)}if(M&&!y){const x=Math.abs(l-w);x<m&&(m=x,l=w,p=w)}}return this.axisSnapLines.set({x:u,y:p}),{x:a,y:l}}onPolygonMouseMove(e){const n=this.mouseToImagePercent(e);if(!n)return;const o=this.polygonPoints();this.polygonCursor.set(this.applySnapping(n,o,e.shiftKey))}finishPolygon(){const e=this.polygonPoints();if(e.length<3)return;window.removeEventListener("mousemove",this.polygonMoveListener),window.removeEventListener("keydown",this.polygonEscListener);const o={...this.drawnArtefactDef(),points:[...e],color:this.drawColor()},i=this.imageDimensions();this.artefactDrawn.emit({type:"polygon",def:o,pct:{points:[...e]},abs:{points:e.map(([a,l])=>[i?a/100*i.width:a,i?l/100*i.height:l])}}),this.polygonPoints.set([]),this.polygonCursor.set(null)}onPolygonEsc(e){"Escape"===e.key&&this.cancelPolygon()}static \u0275fac=function(n){return new(n||s)};static \u0275prov=r.jDH({token:s,factory:s.\u0275fac})}return s})();const q=["imageElement"],J=["*"],ee=(s,c)=>({artefact:s,type:"bbox",index:c}),te=(s,c)=>({artefact:s,type:"circle",index:c}),ne=(s,c)=>({artefact:s,type:"polygon",index:c}),oe=(s,c)=>({artefact:s,type:"svgPath",index:c}),ie=(s,c)=>e=>{const n=r.eBV(c).$implicit;return r.Njj(!e.visible||e.visible(n))},se=(s,c)=>c.label;function ae(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG();t.xc7("transform","scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function re(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",11),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.isContextMenuOpen.set(!1))})("click",function(o){const i=r.eBV(e).$implicit,a=t.XpG();return r.Njj(a.handleBboxClick(i,o))}),t.nVh(1,ae,2,4,"cue-card",12),t.k0s()}if(2&s){const e=c.$implicit,n=t.XpG(),o=t.sdS(17);t.xc7("left",e.x,"%")("top",e.y,"%")("width",e.width,"%")("height",e.height,"%")("border-color",e.color||"rgba(255, 0, 0, 0.8)")("border-width",3/n.zoom()+"px")("background-color",!1===e.showFill?"transparent":n.getBgColor(e.color)),t.AVh("clickable",n.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit)("removable",!!e.allowRemove),t.Y8G("title",e.label||"")("cueContextMenu",o)("contextMenuData",t.l_i(23,ee,e,e.sourceIndex))("cueContextEnabled",n.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.R7$(),t.vxM(e.label?1:-1)}}function ce(s,c){if(1&s&&t.nrm(0,"div",15),2&s){const e=c,n=t.XpG();t.xc7("left",e.x,"%")("top",e.y,"%")("width",e.width,"%")("height",e.height,"%")("border-color",e.color)("border-width",3/n.zoom()+"px")("background-color",n.getBgColor(e.color))}}function le(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"ellipse",17),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default"),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(14,te,e,n))("cueContextEnabled",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.BMQ("cx",e.cx)("cy",e.cy)("rx",e.r)("ry",e.r*o.imageAspectRatio())("stroke",e.color||"rgba(255, 0, 0, 0.8)")("fill",!1===e.showFill?"none":o.getBgColor(e.color))("stroke-width",3/o.zoom())}}function de(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG(2);t.xc7("left",e.cx,"%")("top",e.cy-e.r*n.imageAspectRatio(),"%")("transform","scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function me(s,c){1&s&&t.nVh(0,de,2,8,"cue-card",18),2&s&&t.vxM(c.$implicit.label?0:-1)}function he(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.Z7z(1,le,1,17,":svg:ellipse",16,t.Vm6),t.k0s(),t.Z7z(3,me,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.R7$(),t.Dyx(e.drawingArtefacts().circles),t.R7$(2),t.Dyx(e.drawingArtefacts().circles)}}function ue(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.nrm(1,"ellipse",19),t.k0s()),2&s){const e=c,n=t.XpG();t.R7$(),t.BMQ("cx",e.cx)("cy",e.cy)("rx",e.r)("ry",e.r*n.imageAspectRatio())("stroke",e.color)("fill",n.getBgColor(e.color))("stroke-width",3/n.zoom())}}function ge(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"polygon",21),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default"),t.AVh("clickable",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(13,ne,e,n))("cueContextEnabled",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.BMQ("points",o.pointsToAttr(e.points))("stroke",e.color||"rgba(255, 0, 0, 0.8)")("fill",!1===e.showFill?"none":o.getBgColor(e.color))("stroke-width",3/o.zoom())}}function pe(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG(2);t.xc7("left",n.polygonCentroid(e.points).x,"%")("top",n.polygonCentroid(e.points).y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",e.label,t.npT)}}function _e(s,c){1&s&&t.nVh(0,pe,2,8,"cue-card",18),2&s&&t.vxM(c.$implicit.label?0:-1)}function fe(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.Z7z(1,ge,1,16,":svg:polygon",20,t.Vm6),t.k0s(),t.Z7z(3,_e,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.R7$(),t.Dyx(e.drawingArtefacts().polygons),t.R7$(2),t.Dyx(e.drawingArtefacts().polygons)}}function we(s,c){if(1&s&&(r.qSk(),t.nrm(0,"line",25)(1,"line",26)),2&s){const e=t.XpG(),n=t.XpG();t.BMQ("x1",e.points[e.points.length-1][0])("y1",e.points[e.points.length-1][1])("x2",e.cursorPoint[0])("y2",e.cursorPoint[1])("stroke",e.color)("stroke-width",2/n.zoom()),t.R7$(),t.BMQ("x1",e.cursorPoint[0])("y1",e.cursorPoint[1])("x2",e.points[0][0])("y2",e.points[0][1])("stroke",e.color)("stroke-width",1/n.zoom())}}function xe(s,c){if(1&s&&t.nrm(0,"div",27),2&s){const e=c.$implicit,n=t.XpG(),o=t.XpG();t.xc7("left",e[0],"%")("top",e[1],"%")("transform","translate(-50%, -50%) scale("+1/o.zoom()+")")("background",n.color)}}function ve(s,c){if(1&s&&t.nrm(0,"div",28),2&s){const e=t.XpG(),n=t.XpG();t.xc7("left",e.cursorPoint[0],"%")("top",e.cursorPoint[1],"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")("background",e.color)}}function Me(s,c){if(1&s&&t.nrm(0,"div",31),2&s){const e=t.XpG();t.xc7("left",e.x,"%")}}function ye(s,c){if(1&s&&t.nrm(0,"div",32),2&s){const e=t.XpG();t.xc7("top",e.y,"%")}}function be(s,c){if(1&s&&(t.nVh(0,Me,1,2,"div",29),t.nVh(1,ye,1,2,"div",30)),2&s){const e=c;t.vxM(void 0!==e.x?0:-1),t.R7$(),t.vxM(void 0!==e.y?1:-1)}}function Ce(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",8),t.nrm(1,"polyline",22),t.nVh(2,we,2,12),t.k0s(),t.Z7z(3,xe,1,8,"div",23,t.Vm6),t.nVh(5,ve,1,8,"div",24),t.nVh(6,be,2,2)),2&s){let e;const n=c,o=t.XpG();t.R7$(),t.BMQ("points",o.pointsToAttr(n.points))("stroke",n.color)("stroke-width",3/o.zoom()),t.R7$(),t.vxM(n.cursorPoint?2:-1),t.R7$(),t.Dyx(n.points),t.R7$(2),t.vxM(n.cursorPoint&&!o.isCursorOnVertex(n.cursorPoint,n.points)?5:-1),t.R7$(),t.vxM((e=o.polygonService.axisSnapLines())?6:-1,e)}}function De(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",33),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG();return r.Njj("polygon"===i.drawMode()?i.polygonService.onPolygonClick(o):i.drawingService.onDrawMouseDown(o))})("keydown.escape",function(){r.eBV(e);const o=t.XpG();return r.Njj(o.polygonService.cancelPolygon())}),t.k0s()}}function Pe(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",35),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"nw"))}),t.k0s(),t.j41(1,"div",36),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"ne"))}),t.k0s(),t.j41(2,"div",37),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"sw"))}),t.k0s(),t.j41(3,"div",38),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"se"))}),t.k0s(),t.j41(4,"div",39),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"n"))}),t.k0s(),t.j41(5,"div",40),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"s"))}),t.k0s(),t.j41(6,"div",41),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"w"))}),t.k0s(),t.j41(7,"div",42),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"e"))}),t.k0s()}if(2&s){const e=t.XpG().$implicit,n=t.XpG(3);t.xc7("left",e.x,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width/2,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width/2,"%")("top",e.y+e.height,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x,"%")("top",e.y+e.height/2,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.x+e.width,"%")("top",e.y+e.height/2,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function ze(s,c){if(1&s&&t.nVh(0,Pe,8,48),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Te(s,c){if(1&s&&t.Z7z(0,ze,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.boundingBoxes())}}function Ie(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",43),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(1,"div",43),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(2,"div",44),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s(),t.j41(3,"div",44),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG(4);return r.Njj(i.editService.onEditMouseDown(o,"radius"))}),t.k0s()}if(2&s){const e=t.XpG().$implicit,n=t.XpG(3);t.xc7("left",e.cx+e.r,"%")("top",e.cy,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx-e.r,"%")("top",e.cy,"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx,"%")("top",e.cy-e.r*n.imageAspectRatio(),"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")"),t.R7$(),t.xc7("left",e.cx,"%")("top",e.cy+e.r*n.imageAspectRatio(),"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function Ee(s,c){if(1&s&&t.nVh(0,Ie,4,24),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Ve(s,c){if(1&s&&t.Z7z(0,Ee,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.drawingArtefacts().circles)}}function ke(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",46),t.bIt("mousedown",function(o){const i=r.eBV(e).$index,a=t.XpG(5);return r.Njj(a.editService.onEditMouseDown(o,"vertex:"+i))}),t.k0s()}if(2&s){const e=c.$implicit,n=t.XpG(5);t.xc7("left",e[0],"%")("top",e[1],"%")("transform","translate(-50%, -50%) scale("+1/n.zoom()+")")}}function Ae(s,c){if(1&s&&t.Z7z(0,ke,1,6,"div",45,t.Vm6),2&s){const e=t.XpG().$implicit;t.Dyx(e.points)}}function Le(s,c){if(1&s&&t.nVh(0,Ae,2,0),2&s){const e=c.$index,n=t.XpG(2);t.vxM(e===n.index?0:-1)}}function Se(s,c){if(1&s&&t.Z7z(0,Le,1,1,null,null,t.Vm6),2&s){const e=t.XpG(2);t.Dyx(e.drawingArtefacts().polygons)}}function Re(s,c){if(1&s){const e=t.RV6();t.j41(0,"div",34),t.bIt("mousedown",function(o){r.eBV(e);const i=t.XpG();return r.Njj(i.editService.onEditMouseDown(o,"body"))}),t.nVh(1,Te,2,0),t.nVh(2,Ve,2,0),t.nVh(3,Se,2,0),t.k0s()}if(2&s){const e=c;t.R7$(),t.vxM("bbox"===e.type?1:-1),t.R7$(),t.vxM("circle"===e.type?2:-1),t.R7$(),t.vxM("polygon"===e.type?3:-1)}}function je(s,c){if(1&s){const e=t.RV6();r.qSk(),t.j41(0,"g",49),t.bIt("contextMenuOpen",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!0))})("contextMenuClose",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.isContextMenuOpen.set(!1))})("click",function(o){const i=r.eBV(e).$implicit,a=t.XpG(2);return r.Njj(a.handleSvgPathClick(i,o))}),t.k0s()}if(2&s){const e=c.$implicit,n=c.$index,o=t.XpG(2),i=t.sdS(17);t.xc7("pointer-events",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"all":"none")("cursor",o.contextMenuItems().length>0||e.allowRemove||e.allowEdit?"pointer":"default")("--dxf-sw",null!=e.strokeWidth&&o.zoom()?e.strokeWidth/o.zoom():null),t.AVh("clickable",o.contextMenuItems().length>0||!!e.allowRemove||!!e.allowEdit),t.Y8G("cueContextMenu",i)("contextMenuData",t.l_i(18,oe,e,n))("cueContextEnabled",o.contextMenuItems().length>0&&o.contextMenuItems().some(t._m7(17,ie,c))||!!e.allowRemove||!!e.allowEdit)("innerHTML",o.safeSvg(e.svg),t.npT),t.BMQ("title",e.label||"")("transform",e.transform||null)("stroke",e.color||"#ffa8a8")("fill",e.fillColor||"none")("stroke-dasharray",e.strokeDashArray||null)}}function Fe(s,c){if(1&s&&(t.j41(0,"cue-card",13),t.nrm(1,"cue-typography",14),t.k0s()),2&s){const e=c,n=t.XpG().$implicit,o=t.XpG(2);t.xc7("left",e.x,"%")("top",e.y,"%")("transform","translate(-50%, -50%) scale("+1/o.zoom()+")"),t.R7$(),t.Y8G("noWrap",!0)("innerHTML",n.label,t.npT)}}function Xe(s,c){if(1&s&&t.nVh(0,Fe,2,8,"cue-card",18),2&s){let e;const n=c.$implicit,o=t.XpG(2);t.vxM((e=n.label&&o.getSvgLabelPositionPercent(n.svg,n.transform))?0:-1,e)}}function Ze(s,c){if(1&s&&(r.qSk(),t.j41(0,"svg",47),t.Z7z(1,je,1,21,":svg:g",48,t.Vm6),t.k0s(),t.Z7z(3,Xe,1,1,null,null,t.Vm6)),2&s){const e=t.XpG();t.BMQ("viewBox",e.svgViewBox()),t.R7$(),t.Dyx(e.drawingArtefacts().svgPaths),t.R7$(2),t.Dyx(e.drawingArtefacts().svgPaths)}}function Ge(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG().$implicit,i=t.XpG(2).$implicit;return r.Njj(o.action(i.artefact))}),t.EFF(1),t.k0s()}if(2&s){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.label," ")}}function Be(s,c){if(1&s&&t.nVh(0,Ge,2,1,"cue-menu-item"),2&s){const e=c.$implicit,n=t.XpG(2).$implicit;t.vxM(!e.visible||e.visible(n.artefact)?0:-1)}}function Ne(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG(2).$implicit,i=t.XpG();return r.Njj(i.editService.startEditArtefact(o.type,"bbox"===o.type?o.artefact.sourceIndex:o.index))}),t.EFF(1),t.nI1(2,"transloco"),t.k0s()}2&s&&(t.R7$(),t.SpI(" ",t.bMT(2,1,"common.buttons.edit")," "))}function $e(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-menu-item",50),t.bIt("click",function(){r.eBV(e);const o=t.XpG(2).$implicit,i=t.XpG();return r.Njj("bbox"===o.type?i.removeArtefact(o.artefact):"circle"===o.type?i.removeCircleArtefact(o.index):"polygon"===o.type?i.removePolygonArtefact(o.index):i.removeSvgPathArtefact(o.index))}),t.EFF(1),t.nI1(2,"transloco"),t.k0s()}2&s&&(t.R7$(),t.SpI(" ",t.bMT(2,1,"common.buttons.delete")," "))}function Oe(s,c){if(1&s&&(t.j41(0,"cue-menu-wrap"),t.Z7z(1,Be,1,1,null,null,se),t.nVh(3,Ne,3,3,"cue-menu-item"),t.nVh(4,$e,3,3,"cue-menu-item"),t.k0s()),2&s){const e=t.XpG().$implicit,n=t.XpG();t.R7$(),t.Dyx(n.contextMenuItems()),t.R7$(2),t.vxM(!e.artefact.allowEdit||"bbox"!==e.type&&"circle"!==e.type&&"polygon"!==e.type?-1:3),t.R7$(),t.vxM(e.artefact.allowRemove?4:-1)}}function We(s,c){if(1&s&&t.nVh(0,Oe,5,2,"cue-menu-wrap"),2&s){const e=t.XpG();t.vxM(e.contextMenuItems().length>0?0:-1)}}function Ye(s,c){if(1&s){const e=t.RV6();t.j41(0,"cue-image-toolbar",52),t.mxI("zoomChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.zoom,o)||(i.zoom=o),r.Njj(o)})("panChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.pan,o)||(i.pan=o),r.Njj(o)})("activeToolChange",function(o){r.eBV(e);const i=t.XpG(2);return t.DH7(i.activeTool,o)||(i.activeTool=o),r.Njj(o)}),t.bIt("rotate",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleRotate())})("zoomIn",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleZoomIn())})("zoomOut",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.handleZoomOut())})("zoomFit",function(){r.eBV(e);const o=t.XpG(2);return r.Njj(o.calculateFitZoom())}),t.k0s()}if(2&s){const e=t.XpG(),n=t.XpG();t.Aen(n.toolbarStyle()),t.Y8G("options",e),t.R50("zoom",n.zoom)("pan",n.pan)("activeTool",n.activeTool),t.Y8G("minZoom",n.minZoom())("maxZoom",n.maxZoom())}}function He(s,c){1&s&&t.nVh(0,Ye,1,8,"cue-image-toolbar",51),2&s&&t.vxM(c.hidden?-1:0)}let Ue=(()=>{class s{svgHelpers=(0,r.WQX)(K);editService=(0,r.WQX)(N);drawingService=(0,r.WQX)($);polygonService=(0,r.WQX)(O);sanitizer=(0,r.WQX)(X.up);onEscape(){this.polygonService.polygonPoints().length>0&&this.polygonService.cancelPolygon(),this.editService.editingArtefact()&&this.editService.cancelEdit()}onEnter(){this.editService.editingArtefact()&&this.editService.cancelEdit()}src=g.hFB.required();alt=(0,g.hFB)("");fitMode=(0,g.hFB)("contain");toolbarOptions=(0,g.hFB)(new A.g);drawMode=(0,g.hFB)("none");panDisabled=(0,g.hFB)(!1);zoomDisabled=(0,g.hFB)(!1);drawnArtefactDef=(0,g.hFB)({allowRemove:!0,allowEdit:!0,color:"rgba(255, 0, 0, 0.9)"});contextMenuItems=(0,g.hFB)([]);activeTool=(0,g.geq)("pan");drawingArtefacts=(0,g.geq)((0,G.x)());artefactSelected=(0,g.CGW)();artefactDrawn=(0,g.CGW)();artefactRemoved=(0,g.CGW)();artefactEdited=(0,g.CGW)();drawColor=(0,T.EW)(()=>this.drawnArtefactDef().color??"rgba(255, 0, 0, 0.9)");panModeActive=(0,T.EW)(()=>!this.panDisabled()&&"none"===this.drawMode()&&!this.editService.editingArtefact()&&!this.isContextMenuOpen()&&"select"!==this.activeTool());boundingBoxes=(0,T.EW)(()=>this.drawingArtefacts().xywhs.map((n,o)=>{const i=this.parseXYWH("string"==typeof n?n:n.xywhStr);return i&&0!==i.width&&0!==i.height?("object"==typeof n&&(i.color=n.color,i.label=n.label,i.showFill=n.showFill,i.allowRemove=n.allowRemove,i.allowEdit=n.allowEdit),i.sourceIndex=o,i):null}).filter(Boolean));panZoom=(0,g.ebz)(k);imageElement=(0,g.ebz)("imageElement");rotationAngle=(0,r.vPA)(0);pan=(0,r.vPA)({x:0,y:0});isContextMenuOpen=(0,r.vPA)(!1);isZooming=(0,r.vPA)(!1);_zoomEndTimer=null;constructor(){(0,r.QZP)(e=>{const n=this.panZoom();if(n){const o=n.containerRef()?.nativeElement;if(o){const i=new ResizeObserver(()=>{this.zoomDisabled()||this.calculateFitZoom()});i.observe(o),e(()=>i.disconnect())}}}),(0,r.QZP)(e=>{this.zoom(),this.isZooming.set(!0),this._zoomEndTimer&&clearTimeout(this._zoomEndTimer),this._zoomEndTimer=setTimeout(()=>this.isZooming.set(!1),150),e(()=>{this._zoomEndTimer&&clearTimeout(this._zoomEndTimer)})}),queueMicrotask(()=>{const e=this.mouseToImagePercent.bind(this),n=this.parseXYWH.bind(this);this.editService.init({drawingArtefacts:this.drawingArtefacts,mouseToImagePercent:e,parseXYWH:n,polygonService:this.polygonService,artefactEdited:this.artefactEdited}),this.drawingService.init({drawMode:this.drawMode,drawColor:this.drawColor,drawnArtefactDef:this.drawnArtefactDef,artefactDrawn:this.artefactDrawn,mouseToImagePercent:e,imageDimensions:this.imageDimensions,drawingArtefacts:this.drawingArtefacts}),this.polygonService.init({drawColor:this.drawColor,drawnArtefactDef:this.drawnArtefactDef,artefactDrawn:this.artefactDrawn,mouseToImagePercent:e,imageAspectRatio:this.imageAspectRatio,zoom:this.zoom,imageDimensions:this.imageDimensions,drawingArtefacts:this.drawingArtefacts})})}zoom=(0,r.vPA)(1);imageDimensions=(0,r.vPA)(null);imageAspectRatio=(0,T.EW)(()=>{const e=this.imageDimensions();return e&&0!==e.height?e.width/e.height:1});minZoom=(0,r.vPA)(1);maxZoom=(0,r.vPA)(10);toolbarStyle=(0,T.EW)(()=>{const e=this.toolbarOptions();return{position:"absolute",left:e.margin,right:e.margin,["top"===e.position?"top":"bottom"]:e.margin,"z-index":"1000",display:"flex","justify-content":"center"}});onImageLoad(){const e=this.imageElement()?.nativeElement;e&&(this.imageDimensions.set({width:e.naturalWidth,height:e.naturalHeight}),this.zoomDisabled()||this.calculateFitZoom())}calculateFitZoom(){const e=this.panZoom(),n=this.imageElement()?.nativeElement;!e||!n||requestAnimationFrame(()=>{const o=e.containerRef()?.nativeElement;if(!o)return;const i=o.getBoundingClientRect(),a=n.naturalWidth,l=n.naturalHeight;if(0===a||0===l)return;const d=i.width/a,m=i.height/l;let u=1;u="contain"===this.fitMode()?Math.min(d,m):"cover"===this.fitMode()?Math.max(d,m):1,this.minZoom.set(Math.min(u,1)),this.zoom.set(u),this.centerImage()})}centerImage(){const e=this.panZoom();e?requestAnimationFrame(()=>{const n=e.containerRef()?.nativeElement;if(!n)return;const o=n.getBoundingClientRect(),i=this.zoom(),a=this.imageDimensions()?.width||0,l=this.imageDimensions()?.height||0;this.pan.set({x:(o.width-a*i)/2,y:(o.height-l*i)/2})}):this.pan.set({x:0,y:0})}handleRotate(){this.rotationAngle.update(e=>(e-90)%360),this.pan.update(()=>({x:0,y:0}))}handleZoomIn(){this.panZoom()?.zoomIn()}handleZoomOut(){this.panZoom()?.zoomOut()}parseXYWH(e){try{const o=e.replace("percent:","").split(",").map(m=>parseFloat(m.trim()));if(4!==o.length||o.some(isNaN))return console.warn(`Invalid XYWH format: ${e}`),null;const[i,a,l,d]=o;return{x:i,y:a,width:l,height:d}}catch(n){return console.error(`Error parsing XYWH: ${e}`,n),null}}getBgColor(e){if(!e)return"rgba(255, 0, 0, 0.1)";const n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, 0.1)`;const o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const i=o[1];return`rgba(${parseInt(3===i.length?i[0]+i[0]:i.slice(0,2),16)}, ${parseInt(3===i.length?i[1]+i[1]:i.slice(2,4),16)}, ${parseInt(3===i.length?i[2]+i[2]:i.slice(4,6),16)}, 0.1)`}return e.replace(/rgba?\([^)]+\)/,"rgba(255, 0, 0, 0.1)")}mouseToImagePercent(e){const n=this.imageElement()?.nativeElement;if(!n)return null;const o=n.getBoundingClientRect(),a=(e.clientY-o.top)/o.height*100;return{x:Math.max(0,Math.min(100,(e.clientX-o.left)/o.width*100)),y:Math.max(0,Math.min(100,a))}}handleBboxClick(e,n){n.stopPropagation(),this.artefactSelected.emit(e)}removeArtefact(e){if(null==e.sourceIndex)return;const n=this.drawingArtefacts().xywhs[e.sourceIndex];this.drawingArtefacts.update(o=>({...o,xywhs:o.xywhs.filter((i,a)=>a!==e.sourceIndex)})),n&&this.artefactRemoved.emit(n)}removeCircleArtefact(e){const n=this.drawingArtefacts().circles[e];this.drawingArtefacts.update(o=>({...o,circles:o.circles.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}removePolygonArtefact(e){const n=this.drawingArtefacts().polygons[e];this.drawingArtefacts.update(o=>({...o,polygons:o.polygons.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}handleSvgPathClick(e,n){n.stopPropagation(),this.artefactSelected.emit(e)}removeSvgPathArtefact(e){const n=this.drawingArtefacts().svgPaths[e];this.drawingArtefacts.update(o=>({...o,svgPaths:o.svgPaths.filter((i,a)=>a!==e)})),n&&this.artefactRemoved.emit(n)}svgViewBox=(0,T.EW)(()=>{const e=this.imageDimensions();if(e&&e.width>0&&e.height>0)return`0 0 ${e.width} ${e.height}`;const n=this.drawingArtefacts().svgPaths;if(n.length>0){const i=n[0].svg.match(/viewBox="([^"]+)"/);if(i)return i[1]}return"0 0 100 100"});getSvgLabelPositionPercent(e,n){const o=this.svgHelpers.getLabelPosition(e);if(!o)return null;const i=this.imageDimensions();if(!i||0===i.width||0===i.height)return null;let{x:a,y:l}=o;if(n){const d=n.match(/matrix\(\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*,\s*([-\d.e]+)\s*\)/);if(d){const[,m,u,p,v,M,P]=d.map(Number),E=u*a+v*l+P;a=m*a+p*l+M,l=E}}return{x:a/i.width*100,y:l/i.height*100}}pointsToAttr(e){return e.map(n=>n[0]+","+n[1]).join(" ")}polygonCentroid(e){let n=0,o=0;for(const i of e)n+=i[0],o+=i[1];return{x:n/e.length,y:o/e.length}}isCursorOnVertex(e,n){for(const o of n)if(Math.abs(e[0]-o[0])<.5&&Math.abs(e[1]-o[1])<.5)return!0;return!1}safeSvg(e){let n=e.trim();if(n.startsWith("<svg")){const i=(new DOMParser).parseFromString(n,"image/svg+xml"),a=i.querySelector("parsererror");a&&console.warn("[ImageViewer] safeSvg: SVG parse error",a.textContent),n=i.documentElement.innerHTML}return this.sanitizer.bypassSecurityTrustHtml(n)}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=t.VBU({type:s,selectors:[["cue-image-viewer"]],viewQuery:function(n,o){1&n&&t.wEZ(o.panZoom,k,5)(o.imageElement,q,5),2&n&&t.NyB(2)},hostBindings:function(n,o){1&n&&t.bIt("keydown.escape",function(){return o.onEscape()},t.EBC)("keydown.enter",function(){return o.onEnter()},t.EBC)},inputs:{src:[1,"src"],alt:[1,"alt"],fitMode:[1,"fitMode"],toolbarOptions:[1,"toolbarOptions"],drawMode:[1,"drawMode"],panDisabled:[1,"panDisabled"],zoomDisabled:[1,"zoomDisabled"],drawnArtefactDef:[1,"drawnArtefactDef"],contextMenuItems:[1,"contextMenuItems"],activeTool:[1,"activeTool"],drawingArtefacts:[1,"drawingArtefacts"]},outputs:{activeTool:"activeToolChange",drawingArtefacts:"drawingArtefactsChange",artefactSelected:"artefactSelected",artefactDrawn:"artefactDrawn",artefactRemoved:"artefactRemoved",artefactEdited:"artefactEdited"},features:[t.Jv_([N,$,O])],ngContentSelectors:J,decls:19,vars:19,consts:[["imageElement",""],["artefactContextMenu",""],[1,"container"],[2,"width","100%","height","100%",3,"zoomChange","panChange","minZoom","maxZoom","zoom","pan","zoomStep","panMode"],[1,"image-container"],["draggable","false",2,"max-width","none","height","auto","display","block","user-select","none",3,"load","src","alt"],["trigger","leftclick",1,"bounding-box-overlay",3,"clickable","removable","left","top","width","height","border-color","border-width","background-color","title","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bounding-box-overlay","draw-preview",3,"left","top","width","height","border-color","border-width","background-color"],["viewBox","0 0 100 100","preserveAspectRatio","none",1,"svg-overlay",2,"position","absolute","top","0","left","0","width","100%","height","100%","pointer-events","none","overflow","visible"],["tabindex","0",1,"draw-overlay"],[1,"draw-overlay","edit-overlay"],["trigger","leftclick",1,"bounding-box-overlay",3,"contextMenuOpen","contextMenuClose","click","title","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bbox-label",3,"transform"],[1,"bbox-label"],["size","xs","weight","medium",3,"noWrap","innerHTML"],[1,"bounding-box-overlay","draw-preview"],["vector-effect","non-scaling-stroke","trigger","leftclick",1,"clickable",3,"pointer-events","cursor","cueContextMenu","contextMenuData","cueContextEnabled"],["vector-effect","non-scaling-stroke","trigger","leftclick",1,"clickable",3,"contextMenuOpen","contextMenuClose","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"bbox-label",3,"left","top","transform"],["vector-effect","non-scaling-stroke","stroke-dasharray","6 4"],["vector-effect","non-scaling-stroke","trigger","leftclick",3,"pointer-events","cursor","clickable","cueContextMenu","contextMenuData","cueContextEnabled"],["vector-effect","non-scaling-stroke","trigger","leftclick",3,"contextMenuOpen","contextMenuClose","cueContextMenu","contextMenuData","cueContextEnabled"],["fill","none","vector-effect","non-scaling-stroke","stroke-dasharray","6 4"],[1,"polygon-vertex",3,"left","top","transform","background"],[1,"polygon-vertex","cursor-preview",3,"left","top","transform","background"],["vector-effect","non-scaling-stroke","stroke-dasharray","4 4","opacity","0.6"],["vector-effect","non-scaling-stroke","stroke-dasharray","2 4","opacity","0.3"],[1,"polygon-vertex"],[1,"polygon-vertex","cursor-preview"],[1,"snap-guide","vertical",3,"left"],[1,"snap-guide","horizontal",3,"top"],[1,"snap-guide","vertical"],[1,"snap-guide","horizontal"],["tabindex","0",1,"draw-overlay",3,"mousedown","keydown.escape"],[1,"draw-overlay","edit-overlay",3,"mousedown"],[1,"resize-handle","nw",3,"mousedown"],[1,"resize-handle","ne",3,"mousedown"],[1,"resize-handle","sw",3,"mousedown"],[1,"resize-handle","se",3,"mousedown"],[1,"resize-handle","n",3,"mousedown"],[1,"resize-handle","s",3,"mousedown"],[1,"resize-handle","w",3,"mousedown"],[1,"resize-handle","e",3,"mousedown"],[1,"resize-handle","radius",3,"mousedown"],[1,"resize-handle","radius-v",3,"mousedown"],[1,"resize-handle","vertex",3,"left","top","transform"],[1,"resize-handle","vertex",3,"mousedown"],["preserveAspectRatio","none",1,"svg-overlay",2,"position","absolute","top","0","left","0","width","100%","height","100%","pointer-events","none","overflow","visible"],["trigger","leftclick",3,"clickable","pointer-events","cursor","cueContextMenu","contextMenuData","cueContextEnabled","--dxf-sw","innerHTML"],["trigger","leftclick",3,"contextMenuOpen","contextMenuClose","click","cueContextMenu","contextMenuData","cueContextEnabled","innerHTML"],[3,"click"],[3,"options","style","zoom","pan","activeTool","minZoom","maxZoom"],[3,"zoomChange","panChange","activeToolChange","rotate","zoomIn","zoomOut","zoomFit","options","zoom","pan","activeTool","minZoom","maxZoom"]],template:function(n,o){if(1&n){const i=t.RV6();t.NAR(),t.j41(0,"div",2)(1,"cue-pan-zoom",3),t.mxI("zoomChange",function(l){return r.eBV(i),t.DH7(o.zoom,l)||(o.zoom=l),r.Njj(l)})("panChange",function(l){return r.eBV(i),t.DH7(o.pan,l)||(o.pan=l),r.Njj(l)}),t.j41(2,"div",4)(3,"img",5,0),t.bIt("load",function(){return o.onImageLoad()}),t.k0s(),t.Z7z(5,re,2,26,"div",6,t.Vm6),t.nVh(7,ce,1,14,"div",7),t.nVh(8,he,5,0),t.nVh(9,ue,2,7,":svg:svg",8),t.nVh(10,fe,5,0),t.nVh(11,Ce,7,6),t.nVh(12,De,1,0,"div",9),t.nVh(13,Re,4,3,"div",10),t.nVh(14,Ze,5,1),t.SdG(15),t.DNE(16,We,1,1,"ng-template",null,1,t.C5r),t.k0s()(),t.nVh(18,He,1,1),t.k0s()}if(2&n){let i,a,l,d,m;t.R7$(),t.Y8G("minZoom",o.zoomDisabled()?o.zoom():o.minZoom())("maxZoom",o.zoomDisabled()?o.zoom():o.maxZoom()),t.R50("zoom",o.zoom)("pan",o.pan),t.Y8G("zoomStep",.1)("panMode",o.panModeActive()),t.R7$(),t.xc7("transform","rotate("+o.rotationAngle()+"deg)"),t.R7$(),t.Y8G("src",o.src(),t.B4B)("alt",o.alt()),t.R7$(2),t.Dyx(o.boundingBoxes()),t.R7$(2),t.vxM((i=o.drawingService.drawPreview())?7:-1,i),t.R7$(),t.vxM(o.drawingArtefacts().circles.length>0?8:-1),t.R7$(),t.vxM((a=o.drawingService.circleDrawPreview())?9:-1,a),t.R7$(),t.vxM(o.drawingArtefacts().polygons.length>0?10:-1),t.R7$(),t.vxM((l=o.polygonService.polygonDrawPreview())?11:-1,l),t.R7$(),t.vxM("none"!==o.drawMode()?12:-1),t.R7$(),t.vxM((d=o.editService.editingArtefact())?13:-1,d),t.R7$(),t.vxM(o.drawingArtefacts().svgPaths.length>0&&!o.isZooming()?14:-1),t.R7$(4),t.vxM((m=o.toolbarOptions())?18:-1,m)}},dependencies:[L.MD,A.F,k,S.Q,D.M,R.D,f.Z,z.o,B.Kj],styles:["[_nghost-%COMP%]{display:contents}.container[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;overflow:hidden;display:flex;flex-direction:column}.image-container[_ngcontent-%COMP%]{position:relative;height:auto}.bounding-box-overlay[_ngcontent-%COMP%]{position:absolute;border:3px solid rgba(255,0,0,.8);background-color:#ff00001a;box-sizing:border-box;pointer-events:none;z-index:5;transition:border-width .2s ease,background-color .2s ease}.bounding-box-overlay.clickable[_ngcontent-%COMP%]{pointer-events:auto;cursor:pointer}.bounding-box-overlay.clickable[_ngcontent-%COMP%]:hover{border-width:3px;background-color:#ff000040}.bbox-label[_ngcontent-%COMP%]{position:absolute;top:-12px;left:-28px;transform-origin:bottom left;pointer-events:none;z-index:6;--cue-card-padding-x: 8px;--cue-card-padding-y: 4px}cue-image-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.draw-overlay[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;cursor:crosshair;z-index:6}.edit-overlay[_ngcontent-%COMP%]{cursor:move;z-index:8}.resize-handle[_ngcontent-%COMP%]{position:absolute;width:8px;height:8px;background:#fff;border:2px solid rgba(0,120,215,.9);border-radius:2px;z-index:9;pointer-events:auto}.resize-handle.nw[_ngcontent-%COMP%]{cursor:nw-resize}.resize-handle.ne[_ngcontent-%COMP%]{cursor:ne-resize}.resize-handle.sw[_ngcontent-%COMP%]{cursor:sw-resize}.resize-handle.se[_ngcontent-%COMP%]{cursor:se-resize}.resize-handle.n[_ngcontent-%COMP%]{cursor:n-resize}.resize-handle.s[_ngcontent-%COMP%]{cursor:s-resize}.resize-handle.e[_ngcontent-%COMP%]{cursor:e-resize}.resize-handle.w[_ngcontent-%COMP%]{cursor:w-resize}.resize-handle.radius[_ngcontent-%COMP%]{cursor:ew-resize;border-radius:50%}.resize-handle.radius-v[_ngcontent-%COMP%]{cursor:ns-resize;border-radius:50%}.draw-preview[_ngcontent-%COMP%]{border-style:dashed!important;pointer-events:none;z-index:7}.bounding-box-overlay.removable[_ngcontent-%COMP%]{pointer-events:auto}.polygon-vertex[_ngcontent-%COMP%]{position:absolute;width:8px;height:8px;border-radius:50%;border:2px solid white;pointer-events:none;z-index:7}.polygon-vertex.cursor-preview[_ngcontent-%COMP%]{opacity:.6}.snap-guide[_ngcontent-%COMP%]{position:absolute;pointer-events:none;z-index:6}.snap-guide.vertical[_ngcontent-%COMP%]{top:0;bottom:0;width:0;border-left:1px dashed rgba(0,200,255,.7)}.snap-guide.horizontal[_ngcontent-%COMP%]{left:0;right:0;height:0;border-top:1px dashed rgba(0,200,255,.7)}"],changeDetection:0})}return s})()}}]);
|