@inweb/viewer-visualize 26.9.1 → 26.9.2

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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Visualize=t.ODA.Visualize||{}))}(this,(function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,s){this._commands.set(t,{id:t,handler:e,thisArg:s,description:i})}registerCommandAlias(t,e){this.registerCommand(e,((e,...i)=>this.executeCommand(t,e,...i)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,i)=>t.set(i,e))),t}executeCommand(t,e,...i){const s=this._commands.get(t);if(!s){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:n}=s,o=r.apply(n,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),o}}const i=new Map;function s(t=""){let s=i.get(t);return s||(s=new e,i.set(t,s)),s}class r{constructor(){this._providers=new Map}registerDragger(t,e){this._providers.set(t,e)}registerDraggerAlias(t,e){const i=this._providers.get(t);i&&this.registerDragger(e,(t=>i(t)))}getDraggers(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createDragger(t,e){const i=this._providers.get(t);if(!i)return null;const s=i(e);return s.name=t,s}}const n=new Map;function o(t=""){let e=n.get(t);return e||(e=new r,n.set(t,e)),e}class a{constructor(){this._providers=new Map}registerComponent(t,e){this._providers.set(t,e)}registerComponentAlias(t,e){const i=this._providers.get(t);i&&this.registerComponent(e,(t=>i(t)))}getComponents(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createComponent(t,e){const i=this._providers.get(t);if(!i)return null;const s=i(e);return s.name=t,s}}const h=new Map;function l(t=""){let e=h.get(t);return e||(e=new a,h.set(t,e)),e}class d{constructor(){this.name="",this.abortController=new AbortController}dispose(){this.abortController.abort(),this.abortController=void 0}isSupport(t,e){return!1}load(t,e,i){return Promise.resolve(this)}cancel(){this.abortController.abort()}}class c{constructor(){this._providers=new Map}registerLoader(t,e){this._providers.set(t,e)}getLoader(t){return this._providers.get(t)}getLoaders(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createLoader(t,e,i){let s=null;return this._providers.forEach(((r,n)=>{const o=r(t);o.isSupport(e,i)&&(s=o,s.name=n)})),s}}const u=new Map;function g(t=""){let e=u.get(t);return e||(e=new c,u.set(t,e)),e}function f(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}class p{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=p.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...p.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...p.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}}const m=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],_=m;class v{constructor(t){this.setViewParams=t=>{var e;const i=this.m_module.getViewer().getActiveTvExtendedView();i.setView(t.position,t.target,t.upVector,t.viewFieldWidth,t.viewFieldHeight,t.perspective),null===(e=i.delete)||void 0===e||e.call(i)},this.getViewParams=()=>{var t;const e=this.m_module.getViewer().activeView,i={position:e.viewPosition,target:e.viewTarget,upVector:e.upVector,viewFieldWidth:e.viewFieldWidth,viewFieldHeight:e.viewFieldHeight,perspective:e.perspective};return null===(t=e.delete)||void 0===t||t.call(e),i},this.m_module=t}getViewer(){return this.m_module.getViewer()}getModel(){return this.getViewer().getMarkupModel()}copyPoint(t){const e=new this.m_module.Point3d;return e.set(t.x,t.y,t.z),e}createVector3d(){return new this.m_module.Vector3d}createPoint3d(){return new this.m_module.Point3d}createMatrix3d(){return new this.m_module.Matrix3d}createPlane(){return new this.m_module.OdTvPlane}toVector(t){return this.m_module.Vector3d.createFromArray(t)}toGeVector(t){return[t.x,t.y,t.z]}toGePoint(t){return[t.x,t.y,t.z]}toPoint(t){return this.m_module.Point3d.createFromArray(t)}screenToWorld(t,e){return this.toPoint(this.m_module.getViewer().screenToWorld(t,e))}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}correctCameraTarget(){const t=this.getViewParams(),e=this.m_module.getViewer().getActiveExtents(),{min:i,max:s}=e,r=this.toPoint(t.target);r.x>=i.x&&r.y>=i.y&&r.z>=i.z&&r.x<=s.x&&r.y<=s.y&&r.z<=s.z||(t.target=e.center(),this.setViewParams(t))}}class y extends v{constructor(t){super(t.visualizeJs),this.beginInteractivity=()=>{const t=this.getViewer().activeView;t.beginInteractivity&&(t.beginInteractivity(24),this.subject.update()),t.delete()},this.endInteractivity=()=>{const t=this.getViewer().activeView;if(t.endInteractivity){t.endInteractivity();const e=this.getViewer().getActiveDevice(),i=this.m_module.canvas;e.invalidate([0,0,i.width,i.height]),e.delete(),this.subject.update()}t.delete()},this.subject=t,this.needInputText=!1,this.mouseDownPosition={x:0,y:0},this.autoSelect=!1,this.onmessage=t=>this.subject.emitEvent(t),this.canvasEvents=_}initialize(){this.canvasEvents=this.canvasEvents.filter((t=>"function"==typeof this[t])),this.canvasEvents.forEach((t=>this[t]=this[t].bind(this))),this.canvasEvents.forEach((t=>this.subject.on(t,this[t]))),this.getViewer().setEnableAutoSelect(!!this.autoSelect)}dispose(){this.canvasEvents.forEach((t=>this.subject.off(t,this[t])))}relativeCoords(t){return{x:t.offsetX*window.devicePixelRatio,y:t.offsetY*window.devicePixelRatio}}pointerdown(t){if(!t.isPrimary||y.isGestureActive)return;t.target.setPointerCapture(t.pointerId);const e=this.relativeCoords(t);this.isDragging=!0,this.mouseDownPosition={x:e.x,y:e.y},this.start(e.x,e.y,t.clientX,t.clientY),this.subject.update()}pointerup(t){if(y.needSkipPointerUp)return;if(!t.isPrimary)return;t.target.releasePointerCapture(t.pointerId);const e=this.relativeCoords(t);this.end(e.x,e.y,t.clientX,t.clientY),this.isDragging=!1,this.subject.update()}pointercancel(t){t.isPrimary&&this.m_module.canvas.dispatchEvent(new PointerEvent("pointerup",t))}pointermove(t){if(!t.isPrimary||y.isGestureActive)return;const e=this.relativeCoords(t);this.drag(e.x,e.y,t.clientX,t.clientY),this.isDragging&&this.subject.update()}click(t){const e=this.getViewer(),i=this.relativeCoords(t),s=i.x,r=i.y,n=Math.abs(s-this.mouseDownPosition.x)<5&&Math.abs(r-this.mouseDownPosition.y)<5;if(e&&e.getEnableAutoSelect()&&n){e.unselect(),e.select(s,r,s,r),this.subject.update();const t=e.getSelected(),i=this.subject.getSelected();this.onmessage({type:"select",data:t,handles:i})}}dblclick(t){const e=this.getViewer(),i=this.relativeCoords(t),s=i.x,r=i.y,n=e.getActiveDevice(),o=n.viewAt([s,r]);if(o&&!o.active)e.activeView=o,o.delete(),this.subject.update();else if(e&&e.getEnableAutoSelect()){const t=e.getSelected();if(!t.isNull()&&0!==t.numItems()){const i=t.getIterator(),s=i.getEntity();e.zoomToEntity(s),this.onmessage({type:"zoomtoentity",data:s}),this.subject.update(),this.deleteAll([i,s])}}n.delete()}start(t,e,i=0,s=0){}drag(t,e,i=0,s=0){}end(t,e,i=0,s=0){}getActiveMarkupEntity(t){return this.subject.addMarkupEntity(t)}syncOverlayView(){return this.subject.syncOverlay()}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}updatePreview(){}static set isGestureActive(t){y._isGestureActive!==t&&(y._isGestureActive=t,y._isGestureActive&&(y.needSkipPointerUp=!0))}static get isGestureActive(){return y._isGestureActive}static get needSkipPointerUp(){return!!y._needSkipPointerUp&&(y.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){y._needSkipPointerUp=t}}function w(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function x(t,e){return t&&e.removeChild(t),null}function b(t,e,i){const s=e.Point3d.createFromArray(t),r=i.activeView,n=r.worldToDeviceMatrix,o=s.transformBy(n),a={x:o.x/window.devicePixelRatio,y:o.y/window.devicePixelRatio};return n.delete(),s.delete(),o.delete(),r.delete(),a}function S(t){return t<0?Math.ceil(t):Math.floor(t)}y._isGestureActive=!1,y._needSkipPointerUp=!1;function C(t,e,i,s,r){const n=((t,e,i,s)=>{const r=e.x-t.x,n=e.y-t.y,o=s.x-i.x,a=s.y-i.y,h=(-n*(t.x-i.x)+r*(t.y-i.y))/(-o*n+r*a),l=(+o*(t.y-i.y)-a*(t.x-i.x))/(-o*n+r*a);return h>=0&&h<=1&&l>=0&&l<=1&&{x:S(t.x+l*r),y:S(t.y+l*n)}})(t,e,i,s);n&&r.push(n)}function P(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function A(t,e){t&&(t.onclick=e?()=>e():()=>{})}function T(t,e){t.style.pointerEvents=e?"auto":"none"}class k{constructor(t,e,i){this.htmlElemStartPoint=null,this.htmlElemEndPoint=null,this.htmlElemLine=null,this.htmlElemTitle=null,this.startPoint=null,this.endPoint=null,this.unit="",this.scale=1,this.size=10,this.lineThickness=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",color:"white",boxShadow:"0 0 10px rgba(0,0,0,0.5)"},this.htmlElemStartPoint=w(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=w(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=w(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=w(this.htmlElemTitle,t,"ruler-value"),this.viewer=e,this.moduleInstance=i,this.targetElement=t,this.isFinishDraw=!1}drawMeasureLine(){const t=this.size,e=this.moduleInstance.canvas.getBoundingClientRect();if(this.startPoint){this.htmlElemStartPoint=w(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=b(this.startPoint,this.moduleInstance,this.viewer);P(i,e.width,e.height)?(this.htmlElemStartPoint.style.display="block",this.htmlElemStartPoint.style.cursor="pointer",this.htmlElemStartPoint.style.position="absolute",this.htmlElemStartPoint.style.top=i.y-t/2+"px",this.htmlElemStartPoint.style.left=i.x-t/2+"px",this.htmlElemStartPoint.style.borderRadius=`${t}px`,this.htmlElemStartPoint.style.border=this.style.border,this.htmlElemStartPoint.style.background=this.style.background,this.htmlElemStartPoint.style.zIndex="2",this.htmlElemStartPoint.style.width=`${t}px`,this.htmlElemStartPoint.style.height=`${t}px`,this.htmlElemStartPoint.style.boxShadow=this.style.boxShadow):this.htmlElemStartPoint.style.display="none"}if(this.endPoint&&this.isFinishDraw){this.htmlElemEndPoint=w(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=b(this.endPoint,this.moduleInstance,this.viewer);P(i,e.width,e.height)?(this.htmlElemEndPoint.style.display="block",this.htmlElemEndPoint.style.cursor="pointer",this.htmlElemEndPoint.style.position="absolute",this.htmlElemEndPoint.style.top=i.y-t/2+"px",this.htmlElemEndPoint.style.left=i.x-t/2+"px",this.htmlElemEndPoint.style.borderRadius=`${t}px`,this.htmlElemEndPoint.style.border=this.style.border,this.htmlElemEndPoint.style.background=this.style.background,this.htmlElemEndPoint.style.zIndex="2",this.htmlElemEndPoint.style.width=`${t}px`,this.htmlElemEndPoint.style.height=`${t}px`,this.htmlElemEndPoint.style.boxShadow=this.style.boxShadow):this.htmlElemEndPoint.style.display="none"}if(this.endPoint&&this.startPoint){const t=b(this.startPoint,this.moduleInstance,this.viewer),i=b(this.endPoint,this.moduleInstance,this.viewer),{p1:s,p2:r,angle:n,width:o}=function(t,e,i,s){const r={x:0,y:0},n={x:i,y:0},o={x:0,y:s},a={x:i,y:s},h=[];C(t,e,r,n,h),C(t,e,r,o,h),C(t,e,o,a,h),C(t,e,a,n,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?P(t,i,s)?(l=t,d=h[0]):(l=h[0],d=e):(l=h[0],d=h[1]);const c=d.x-l.x,u=d.y-l.y;let g=180*Math.atan(u/c)/Math.PI;return c<0&&(g-=180),{angle:g,width:Math.sqrt(Math.pow(c,2)+Math.pow(u,2)),p1:l,p2:d}}(t,i,e.width,e.height),a=r.x-s.x,h=r.y-s.y,l=this.lineThickness;if(P(s,e.width,e.height)&&P(r,e.width,e.height)){this.htmlElemLine=w(this.htmlElemLine,this.targetElement,"ruler-line"),this.htmlElemLine.style.display="block",this.htmlElemLine.style.cursor="pointer",this.htmlElemLine.style.position="absolute",this.htmlElemLine.style.top=`${s.y}px`,this.htmlElemLine.style.left=`${s.x}px`,this.htmlElemLine.style.width=`${o}px`,this.htmlElemLine.style.transform=`rotate(${n}deg)`,this.htmlElemLine.style.transformOrigin=`0px ${l/2}px`,this.htmlElemLine.style.boxShadow=this.style.boxShadow,this.htmlElemLine.style.border="none",this.htmlElemLine.style.background=this.style.background,this.htmlElemLine.style.zIndex="1",this.htmlElemLine.style.height=`${l}px`;const t=`${this.getDistance()} ${this.unit}`,e=s.x+a/2,i=s.y+h/2,r=10*t.length;this.htmlElemTitle=w(this.htmlElemTitle,this.targetElement,"ruler-value"),this.htmlElemTitle.style.display="block",this.htmlElemTitle.style.cursor="pointer",this.htmlElemTitle.style.font="10px",this.htmlElemTitle.style.color="white",this.htmlElemTitle.style.position="Absolute",this.htmlElemTitle.style.top=`${i}px`,this.htmlElemTitle.style.left=e-r/2+"px",this.htmlElemTitle.style.width=`${r}px`,this.htmlElemTitle.style.transformOrigin="0px 0px",this.htmlElemTitle.style.borderRadius="5px",this.htmlElemTitle.style.boxShadow=this.style.boxShadow,this.htmlElemTitle.style.border="none",this.htmlElemTitle.style.background=this.style.background,this.htmlElemTitle.style.zIndex="3",this.htmlElemTitle.style.padding="2px",this.htmlElemTitle.style.textAlign="center",this.htmlElemTitle.innerHTML=`${t}`}else this.htmlElemLine.style.display="none",this.htmlElemTitle.style.display="none"}}getDistance(){let t=function(t,e,i){const s=i.Point3d.createFromArray(t),r=i.Point3d.createFromArray(e),n=s.distanceTo(r).toFixed(2);return s.delete(),r.delete(),n}(this.startPoint,this.endPoint,this.moduleInstance);return Math.abs(this.scale-1)>1e-4&&(t=(t/this.scale).toFixed(2)),t}setStartPoint(t){this.startPoint=t,this.drawMeasureLine()}setEndPoint(t,e){this.isFinishDraw=void 0===e||e,this.endPoint=t,this.drawMeasureLine()}update(){this.drawMeasureLine()}setSize(t){this.size=t,this.drawMeasureLine()}clear(){this.endPoint=null,this.startPoint=null,this.htmlElemStartPoint=x(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=x(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=x(this.htmlElemLine,this.targetElement),this.htmlElemTitle=x(this.htmlElemTitle,this.targetElement)}setUnit(t){this.unit=t,this.drawMeasureLine()}setConversionFactor(t){this.scale=t,this.drawMeasureLine()}setStyle(t){this.style=t,this.drawMeasureLine()}setSelectionReactor(t){A(this.htmlElemStartPoint,t?t.onStartPoint:null),A(this.htmlElemEndPoint,t?t.onEndPoint:null),A(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){T(this.htmlElemStartPoint,t),T(this.htmlElemEndPoint,t),T(this.htmlElemLine,t),T(this.htmlElemTitle,t)}}function E(t,e){return t[e]||e}class M extends y{constructor(t){var e;super(t),this.lineThickness=2,this.press=!1,this.gripingRadius=5,this.firstPoint=null,this.secondPoint=null,this.renameUnitTable={Millimeters:"mm",Centimeters:"cm",Meters:"m",Feet:"ft",Inches:"in",Yards:"yd",Kilometers:"km",Miles:"mi",Micrometers:"µm",MicroInches:"µin",Default:"unit"},this.items=[],this.canvasEvents.push("resize"),this.oldRulerUnit=null!==(e=t.options.rulerUnit)&&void 0!==e?e:"Default",this.optionsChange=this.optionsChange.bind(this)}initialize(){super.initialize(),this.m_overlayElement=document.createElement("div"),this.m_overlayElement.style.background="rgba(0,0,0,0)",this.m_overlayElement.style.position="fixed",this.m_overlayElement.style.zIndex="1",this.m_overlayElement.style.pointerEvents="none",document.body.appendChild(this.m_overlayElement),this.subject.addEventListener("optionschange",this.optionsChange),this.resize()}dispose(){super.dispose(),this.m_overlayElement.remove(),this.subject.removeEventListener("optionschange",this.optionsChange)}updatePreview(){this.items.forEach((t=>t.update()))}resize(){const t=this.m_module.canvas.getBoundingClientRect();this.m_overlayElement.style.top=`${t.top}px`,this.m_overlayElement.style.left=`${t.left}px`,this.m_overlayElement.style.width=`${t.width}px`,this.m_overlayElement.style.height=`${t.height}px`}getSnapPointRadius(){const t=this.getViewer().activeView.viewDcCorners(),e=t.lowerLeft,i=t.upperRight;return i[0]-=e[0],i[1]-=e[1],Math.min(i[0],i[1])/120}start(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);i&&(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint))}drag(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);this.isDragging?i?this.firstPoint?(this.secondPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.secondPoint,!0)):(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint)):(this.secondPoint=null,this.previewMeasureLine.clear(),this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.getViewer().screenToWorld(t,e),!1)):i?this.previewMeasureLine.setStartPoint(i):this.previewMeasureLine.clear()}end(){if(this.firstPoint&&this.secondPoint){const t=this.createMeasureLine();t.setStartPoint(this.firstPoint),t.setEndPoint(this.secondPoint,!0)}this.firstPoint=null,this.secondPoint=null,this.previewMeasureLine.clear()}createNewMeasureIfNeed(){this.previewMeasureLine||(this.previewMeasureLine=this.createMeasureLine())}createMeasureLine(){const t=this.m_module.getViewer(),e=new k(this.m_overlayElement,t,this.m_module);e.lineThickness=this.lineThickness||e.lineThickness;const i=!this.subject.options.rulerUnit||"Default"===this.subject.options.rulerUnit;if(e.setUnit(E(this.renameUnitTable,i?t.getUnit():this.subject.options.rulerUnit)),i)e.setConversionFactor(1);else{const i=this.getKUnitByName(t.getUnit()),s=this.getKUnitByName(this.subject.options.rulerUnit),r=t.getUnitsConversionCoef(i,s);this.conversionFactor=1/r,e.setConversionFactor(this.conversionFactor)}return this.items.push(e),e}optionsChange(t){var e;const i=null!==(e=t.data.rulerUnit)&&void 0!==e?e:"Default";if(this.oldRulerUnit===i)return;this.oldRulerUnit=i;const s=this.m_module.getViewer().getUnit(),r=this.getKUnitByName(i),n=this.getKUnitByName(s);this.items.forEach((t=>{if("Default"===i)t.setUnit(E(this.renameUnitTable,s)),t.setConversionFactor(1);else{t.setUnit(E(this.renameUnitTable,i));const e=this.m_module.getViewer().getUnitsConversionCoef(n,r);this.conversionFactor=1/e,t.setConversionFactor(this.conversionFactor)}}))}getKUnitByName(t){let e=this.m_module.Units.kUserDefined;switch(t){case"Millimeters":e=this.m_module.Units.kMillimeters;break;case"Centimeters":e=this.m_module.Units.kCentimeters;break;case"Meters":e=this.m_module.Units.kMeters;break;case"Feet":e=this.m_module.Units.kFeet;break;case"Inches":e=this.m_module.Units.kInches;break;case"Yards":e=this.m_module.Units.kYards;break;case"Kilometers":e=this.m_module.Units.kKilometers;break;case"Miles":e=this.m_module.Units.kMiles;break;case"Micrometers":e=this.m_module.Units.kMicrometers;break;case"MicroInches":e=this.m_module.Units.kMicroInches}return e}}class F extends y{constructor(t){super(t),this.viewer=void 0,this.multiplier=5,this.speed=1,this.keyPressMap=new Set,this.keydown=this.keydown.bind(this),this.keyup=this.keyup.bind(this),this.lastFrameTS=0,this.animationId=void 0,this.processMovement=this.processMovement.bind(this),this.deltaAngle=Math.PI/3600,this.autoSelect=!0}initialize(){super.initialize(),this.viewer=this.getViewer(),window.addEventListener("keydown",this.keydown,!1),window.addEventListener("keyup",this.keyup,!1),this.oldWCSEnableValue=this.viewer.getEnableWCS(),this.viewer.setEnableWCS(!1);const t=this.viewer.activeView,e=this.getMaxDimension(t);this.speed=e/3e4,this.subject.emitEvent({type:"walkstart"}),this.viewParams=this.getViewParams(),this.setViewParams(this.viewParams);const i=this.viewer.getActiveModel();this.cameraId=i.appendCamera("Camera0"),this.setupCamera(t),i.delete(),this.cameraWalker=new this.m_module.OdTvCameraWalker,this.cameraWalker.setCamera(this.cameraId),this.subject.update(),this.enableZoomWheelPreviousValue=this.subject.options.enableZoomWheel,this.subject.options.enableZoomWheel=!1}dispose(){var t;if(this.oldWCSEnableValue=void 0!==this.oldWCSEnableValue?this.oldWCSEnableValue:this.subject.options.showWCS,this.viewer.setEnableWCS(this.oldWCSEnableValue),super.dispose(),this.keyPressMap.clear(),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0),this.cameraId){const e=this.viewer.getActiveModel();e.removeEntity(this.cameraId),e.delete(),null===(t=this.cameraWalker)||void 0===t||t.delete()}if(this.viewParams){this.setViewParams(this.viewParams);this.viewer.activeView.delete()}this.subject.update(!0),this.subject.options.enableZoomWheel=this.enableZoomWheelPreviousValue}keydown(t){switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"KeyW":case"KeyA":case"KeyS":case"KeyD":case"KeyQ":case"KeyE":this.keyPressMap.add(t.code),this.animationId||this.processMovement(0)}}keyup(t){this.keyPressMap.delete(t.code),this.keyPressMap.size<1&&this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0,this.lastFrameTS=0)}processMovement(t){if(this.animationId=requestAnimationFrame(this.processMovement),0!==this.lastFrameTS){const e=t-this.lastFrameTS,i=this.multiplier*e*this.speed;for(const t of this.keyPressMap)switch(t){case"KeyW":this.cameraWalker.moveForward(i);break;case"KeyS":this.cameraWalker.moveBackward(i);break;case"KeyA":this.cameraWalker.moveLeft(i);break;case"KeyD":this.cameraWalker.moveRight(i);break;case"KeyQ":this.cameraWalker.moveUp(i);break;case"KeyE":this.cameraWalker.moveDown(i)}this.subject.update()}this.lastFrameTS=t}start(t,e){this.dragPosition={x:t,y:e}}drag(t,e){if(this.cameraId&&this.isDragging){const i=t-this.dragPosition.x,s=e-this.dragPosition.y;this.dragPosition={x:t,y:e},0!==i&&this.turnLeft(-i*this.deltaAngle),0!==s&&this.cameraWalker.turnDown(s*this.deltaAngle),this.subject.update()}}turnLeft(t){const e=this.cameraWalker.camera().openObjectAsCamera(),i=this.toVector(e.direction()),s=this.toVector(e.upVector()),r=e.position(),n=this.createMatrix3d();n.setToRotation(t,[0,0,1],r),i.transformBy(n),s.transformBy(n),e.setupCameraByDirection(r,i.toArray(),s.toArray()),e.delete()}setupCamera(t){const e=this.cameraId.openObjectAsCamera(),i=t.viewTarget;e.setDisplayGlyph(!1),e.setDisplayTarget(!1),e.setAutoAdjust(!0),e.setupCamera(t.viewPosition,i,t.upVector),e.setNearClip(!1,1),e.setFarClip(!1,0),e.setViewParameters(t.viewFieldWidth,t.viewFieldHeight,!0);const s=(r=t.lensLength,n=t.viewFieldWidth,o=t.viewFieldHeight,r/42*Math.sqrt(n*n+o*o));var r,n,o;const a=this.toPoint(t.viewTarget),h=this.toPoint(t.viewPosition),l=h.sub(a),d=l.asVector(),c=d.normalize(),u=this.toGeVector(c),g=[u[0]*s,u[1]*s,u[2]*s],f=this.toPoint(t.viewTarget),p=this.toPoint(g),m=f.add(p);e.setupCamera(this.toGePoint(m),t.viewTarget,t.upVector),this.deleteAll([a,h,l,d,c,f,p,m]),e.assignView(t),e.delete()}getMaxDimension(t){const[e,i,s]=t.sceneExtents.max(),[r,n,o]=t.sceneExtents.min(),a=[e-r,i-n,s-o];return Math.max(...a)}}class I extends y{constructor(t){super(t),this.press=!1;const e=this.getViewer().getActiveExtents(),i=e.min(),s=e.max();this.m_size_x=Math.abs(s[0]-i[0])/2,this.m_size_y=Math.abs(s[1]-i[1])/2,this.m_size_z=Math.abs(s[2]-i[2])/2,this.m_center=this.toPoint(e.center()),this.m_normal=this.createNormal();const r=this.getViewer().activeView,n=this.createPlane();n.set(this.toGePoint(this.m_center),this.m_normal),r.addCuttingPlane(n),this.index=r.numCuttingPlanes()-1;const{red:o,green:a,blue:h}=this.subject.options.cuttingPlaneFillColor;r.setEnableCuttingPlaneFill(!0,o,a,h),r.setCuttingPlaneFillPatternEnabled(!0,this.m_module.CuttingPlaneFillStyle.kHorizontalBars,0,0,0),this.m_model=this.getModel(),this.createPreview(),this.deleteAll([e,r,n])}dispose(){super.dispose(),this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.deleteAll([this.m_model,this.m_entity,this.planePreview,this.m_center]),this.m_entity=null,this.planePreview=null,this.subject.update())}createNormal(){return[0,0,0]}handleDelta(t){return t}getPlanePreviewCoordinate(){return[]}start(t,e){this.press=!0,this.m_last=this.screenToWorld(t,e),this.m_click={x:t,y:e}}drag(t,e){if(this.press){const i=this.screenToWorld(t,e),s=this.handleDelta(i.sub(this.m_last)),r=this.m_center;this.m_center=r.add(s);const n=this.m_last;this.m_last=i;const o=this.getViewer().activeView,a=this.createPlane(),h=a.set(this.toGePoint(this.m_center),this.m_normal),l=o.updateCuttingPlane(this.index,a);this.drawPreview(),this.deleteAll([o,a,r,s,n,h,l]);const d=this.getViewer().getActiveDevice();d.invalidate(d.getSize())}}end(t,e){if(this.press=!1,t===this.m_click.x&&e===this.m_click.y){this.m_normal=[-1*this.m_normal[0],-1*this.m_normal[1],-1*this.m_normal[2]];const t=this.getViewer().activeView,e=this.createPlane();e.set(this.toGePoint(this.m_center),this.m_normal),t.updateCuttingPlane(this.index,e),this.deleteAll([t,e,this.m_last]);const i=this.getViewer().getActiveDevice();i.invalidate(i.getSize())}}createPreview(){this.m_entity=this.m_model.appendEntity("&CuttingPlanePreview");const t=this.m_module.GeometryTypes,e=new this.m_module.OdTvTransparencyDef,i=new this.m_module.OdTvColorDef(112,112,112);e.setValue(.9);const s=this.m_entity.openObject();s.setColor(i,t.kFaces.value),i.setColor(112,112,112),s.setColor(i,t.kEdges.value),s.setLineWeight(5),s.setTransparency(e,t.kFaces),e.setValue(1),s.setTransparency(e,t.kEdges),this.planePreview=s.appendPolygon(this.getPlanePreviewCoordinate());const r=this.planePreview.openAsPolygon();r.setFilled(!0),this.deleteAll([e,i,s,r,t]),this.subject.syncOverlay()}drawPreview(){const t=this.planePreview.openAsPolygon();t.setPoints(this.getPlanePreviewCoordinate()),this.deleteAll([t]),this.subject.syncOverlay()}}class R extends I{createNormal(){return[1,0,0]}handleDelta(t){return t.y=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z+this.m_size_z,this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z+this.m_size_z]}}class O extends I{createNormal(){return[0,1,0]}handleDelta(t){return t.x=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z,this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z]}}class D extends I{createNormal(){return[0,0,1]}handleDelta(t){return t.x=0,t.y=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z,this.m_center.x-this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z]}}class L{constructor(t,e,i,s){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=s}beginAction(t,e){this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};this.getViewer().activeView.delete(),this._beginInteractivity()}action(t,e){var i,s;const r=this.getViewer().activeView,n=r.vportRect,o=Math.max(Math.abs(n[2]-n[0]),Math.abs(n[3]-n[1])),a=(this.m_startPoint.x-t)*Math.PI/o,h=(this.m_startPoint.y-e)*Math.PI/o;this.m_startPoint.x=t,this.m_startPoint.y=e;const l=h,d=a,c={position:r.viewPosition,target:r.viewTarget,upVector:r.upVector,viewFieldWidth:r.viewFieldWidth,viewFieldHeight:r.viewFieldHeight,perspective:r.perspective};r.delete();const u=this.getSideVector(c);0!==l&&this.calculateXOrbit(c,-l,u),0!==d&&this.calculateYOrbit(c,d,u),u.delete();const g=this.getViewer().getActiveTvExtendedView();g.setView(c.position,c.target,c.upVector,c.viewFieldWidth,c.viewFieldHeight,c.perspective),g.delete(),null===(s=null===(i=this._subject.activeDragger())||void 0===i?void 0:i.updatePreview)||void 0===s||s.call(i)}endAction(){this._endInteractivity()}getSideVector(t){const e=this.toVector(t.upVector),i=this.toPoint(t.target),s=this.toPoint(t.position),r=i.sub(s),n=r.asVector(),o=e.crossProduct(n),a=o.normalize();return this.deleteAll([r,e,i,s,n,o]),a}calculateXOrbit(t,e,i){{const s=this.toPoint(t.position),r=this.toPoint(this.m_viewCenter),n=s.rotateByBasePoint(e,i,r);t.position=n.toArray(),this.deleteAll([s,r,n])}{const s=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),n=s.rotateByBasePoint(e,i,r);t.target=n.toArray(),this.deleteAll([s,r,n])}{const e=this.toPoint(t.position),s=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),n=s.sub(e),o=n.asVector(),a=o.crossProduct(i),h=a.normalize();t.upVector=h.toArray(),this.deleteAll([e,s,r,n,o,a,h])}}calculateYOrbit(t,e,i){{const i=this.toPoint(t.position),s=this.toPoint(this.m_viewCenter),r=this.toVector(this._m_module.Vector3d.kZAxis),n=i.rotateByBasePoint(e,r,s);t.position=n.toArray(),this.deleteAll([r,i,s,n])}{const i=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),r=this.toVector(this._m_module.Vector3d.kZAxis),n=i.rotateByBasePoint(e,r,s);t.target=n.toArray(),this.deleteAll([r,i,s,n])}{const s=this.toVector(this._m_module.Vector3d.kZAxis),r=this.toPoint(t.target),n=this.toPoint(t.position),o=i.rotateBy(e,s),a=r.sub(n),h=a.asVector(),l=h.crossProduct(o),d=l.normalize();t.upVector=d.toArray(),this.deleteAll([s,r,n,o,a,h,l,d])}}getCenter(){const t=this.getViewer();let e;const i=t.getSelected();if(i.isNull()||0===i.numItems())e=t.getActiveExtents().center();else{const t=i.getIterator();let s,r,n;for(;!t.done();t.step())r=t.getEntity(),s=r.getWCSExtents(),n?n.addExt(s):n=s;e=n.center(),n.delete(),t.delete()}return e}getViewer(){return this._m_module.getViewer()}toVector(t){return this._m_module.Vector3d.createFromArray(t)}toPoint(t){return this._m_module.Point3d.createFromArray(t)}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}}class V extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new L(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity)}start(t,e){this.press=!0,this._orbitAction.beginAction(t,e)}setDefaultViewParams(){const t=this.getViewer().getActiveTvExtendedView();t.setView(this.startCameraParams.position,this.startCameraParams.target,this.startCameraParams.upVector,this.startCameraParams.viewFieldWidth,this.startCameraParams.viewFieldHeight,this.startCameraParams.perspective),t.delete()}drag(t,e){this.press&&this._orbitAction.action(t,e)}end(){this.press=!1,this._orbitAction.endAction()}}class z{constructor(t,e,i,s,r,n){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=s,this._getViewParams=r,this._setViewParams=n}beginAction(t,e,i,s){this._m_start=this.screenToWorld(t,e),this._deltaScreenPosition={x:i,y:s},this._beginInteractivity()}action(t,e,i,s){var r,n;const{Vector3d:o}=this._m_module,a=this._getViewParams(),h=this.screenToWorld(t,e),l=this._m_start.sub(h).asVector(),d=o.createFromArray(a.target),c=d.add(l);a.target=c.toArray();const u=o.createFromArray(a.position),g=u.add(l);a.position=g.toArray(),this._setViewParams(a),d.delete(),c.delete(),u.delete(),g.delete(),null===(n=null===(r=this._subject.activeDragger())||void 0===r?void 0:r.updatePreview)||void 0===n||n.call(r),this._subject.emitEvent({type:"pan",x:i,y:s,dX:i-this._deltaScreenPosition.x,dY:s-this._deltaScreenPosition.y}),this._deltaScreenPosition={x:i,y:s}}endAction(){this._endInteractivity()}screenToWorld(t,e){return this._m_module.Point3d.createFromArray(this._m_module.getViewer().screenToWorld(t,e))}}class G extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new z(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams)}start(t,e,i,s){this.press=!0,this._panAction.beginAction(t,e,i,s)}drag(t,e,i,s){this.press&&this._panAction.action(t,e,i,s)}end(t,e){this.press=!1,this._panAction.endAction()}}class N{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i,s,r){var n,o;this._m_module.getViewer().zoomAt(i,t,e),this._subject.deviceAutoRegeneration(),null===(o=null===(n=this._subject.activeDragger())||void 0===n?void 0:n.updatePreview)||void 0===o||o.call(n),this._subject.emitEvent({type:"zoomat",data:i,x:s,y:r})}}class W extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new N(this.m_module,this.subject)}start(t,e,i=0,s=0){this.press=!0,this.pressX=t,this.pressY=e,this.absoluteX=i,this.absoluteY=s,this.prevY=e,this.beginInteractivity()}drag(t,e){const i=e-this.prevY;if(this.prevY=e,this.press&&Math.abs(i)>=1e-5){const t=.975,e=i>0?1/t:t;this._zoomAction.action(this.pressX,this.pressY,e,this.absoluteX,this.absoluteY)}}end(){this.press=!1,this.endInteractivity()}}class U extends y{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new N(this.m_module,this.subject),this._endInteractivityTimeOutId=void 0,this._isEnableInteractivityMode=!1}wheel(t){if(!this.subject.options.enableZoomWheel)return;(t=t||window.event).preventDefault();const e=this.subject.options.reverseZoomWheel?.925:1/.925,i=this.subject.options.reverseZoomWheel?1/.925:.925;if(this.getViewer()){const s=t.deltaY>0?e:i;this._zoomAction.action(t.offsetX*window.devicePixelRatio,t.offsetY*window.devicePixelRatio,s,t.offsetX,t.offsetY),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this.subject.update(!0),this._endInteractivityTimeOutId=setTimeout((()=>{this._endInteractivityTimeOutId=void 0,this.endInteractivity(),this._isEnableInteractivityMode=!1}),100)}}dispose(){this._endInteractivityTimeOutId&&(clearTimeout(this._endInteractivityTimeOutId),this.endInteractivity(),this._isEnableInteractivityMode=!1)}}class B{constructor(){this.m_start=[0,0,0],this.m_end=[0,0,0],this.m_model=null}createPoint3d(){return new this.m_module.Point3d}init(t,e){this.m_module=t,this.m_model=e}getViewer(){return this.m_module.getViewer()}setValue(t){this.m_end=t,this.draw()}setStartPoint(t){this.m_start=t,this.m_end=t,this.draw()}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}draw(){const t=this.getViewer().activeView,e=t.viewingMatrix,i=[];i.push(this.m_start),i.push(this.createPoint3d()),i.push(this.m_end),i.push(this.createPoint3d());const s=this.createPoint3d();s.set(this.m_start[0],this.m_start[1],this.m_start[2]);const r=this.createPoint3d();r.set(this.m_end[0],this.m_end[1],this.m_end[2]),s.transformBy(e),r.transformBy(e),i[1].x=s.x,i[3].x=r.x,i[1].y=r.y,i[3].y=s.y,i[1].z=i[3].z=r.z;const n=t.eyeToWorldMatrix;if(i[1].transformBy(n),i[3].transformBy(n),this.m_entity)this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(i));else{this.m_entity=this.m_model.appendEntity("");const t=this.m_entity.openObject();t.setColor(112,112,112),t.setLineWeight(2),this.m_frame=t.appendPolygon(this.toDoubleArray(i)),t.delete()}}clear(){this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.m_entity=null)}}class j extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new B,this.m_frame.init(this.m_module,this.getModel())}start(t,e){this.press=!0,this.m_minX=t,this.m_minY=e;const i=this.screenToWorld(t,e);this.m_frame.setStartPoint(i)}drag(t,e){if(this.press){this.m_maxX=t,this.m_maxY=e;const i=this.screenToWorld(t,e);this.m_frame.setValue(i)}}end(t,e){this.press=!1,this.m_maxX=t,this.m_maxY=e,this.m_minX!==this.m_maxX&&this.m_minY!==this.m_maxY&&(this.m_frame.clear(),this.getViewer().zoomWindow(this.m_minX,this.m_minY,this.m_maxX,this.m_maxY))}}class H extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.maxPolarAngle=Math.PI/2,this.minPolarAngle=0}start(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};const i=this.getViewer().activeView;this.startCameraParams=this.getViewParams();const s=i.vportRect;this.m_delta=Math.max(s[1]-s[0],s[2]-s[3]),this.beginInteractivity()}setDefaultViewParams(){this.setViewParams(this.startCameraParams)}drag(t,e){if(this.press){let i=t-this.m_startPoint.x,s=e-this.m_startPoint.y;i*=Math.PI/this.m_delta,s*=Math.PI/this.m_delta,this.setDefaultViewParams();const{Vector3d:r,Matrix3d:n}=this.m_module,o=r.createFromArray(this.startCameraParams.target),a=r.createFromArray(this.startCameraParams.position).sub(o),h=a.normalize(),l=new n;l.setToIdentity();const d=new n;d.setToIdentity();const c=r.createFromArray([h.x,h.y,h.z]),u=r.createFromArray(this.startCameraParams.upVector),g=c.crossProduct(u);let f=r.createFromArray([c.x,c.y,0]);f.length()<=1e-5?f.set(-g.y,g.x,0):f=f.normalize();i-=Math.sign(f.dotProduct(r.createFromArray([-1,0,0])))*f.angleTo(r.createFromArray([0,1,0]));let p=r.createFromArray([h.x,h.y,0]),m=0;p.length()<=1e-5?m=-h.z*Math.PI/2:(p=p.normalize(),m=-p.angleTo(h)),s-=m,l.setToRotation(-i,[0,0,1],[0,0,0]);const _=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,s));d.setToRotation(_,[1,0,0],[0,0,0]);const v=l.postMultBy(d);let y=r.createFromArray([0,1,0]).transformBy(v);const w=r.createFromArray([0,0,1]).transformBy(v);y.setLength(a.length()),y=o.add(y);const x=this.getViewParams();x.position=y.toArray(),x.upVector=w.toArray(),this.setViewParams(x)}}end(){this.press=!1,this.endInteractivity()}getCenter(){const t=this.getViewer();let e=t.getActiveExtents();const i=t.getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator(),s=t.getEntity();if(1===s.getType()){const t=s.openObject();e.delete(),e=t.getExtents(),t.delete()}else if(2===s.getType()){const t=s.openObjectAsInsert(),i=t.getExtents();e.delete(),e=i.ext,i.delete(),t.delete()}t.delete()}const s=e.center();return e.delete(),s}}const Y=o("visualizejs");Y.registerDragger("Pan",(t=>new G(t))),Y.registerDragger("Orbit",(t=>new V(t))),Y.registerDragger("Zoom",(t=>new W(t))),Y.registerDragger("ZoomWindow",(t=>new j(t))),Y.registerDragger("ZoomWheel",(t=>new U(t))),Y.registerDragger("OrbitAroundBuilding",(t=>new H(t))),Y.registerDragger("MeasureLine",(t=>new M(t))),Y.registerDragger("CuttingPlaneXAxis",(t=>new R(t))),Y.registerDragger("CuttingPlaneYAxis",(t=>new O(t))),Y.registerDragger("CuttingPlaneZAxis",(t=>new D(t))),Y.registerDragger("Walk",(t=>new F(t)));const X=(t,e,i)=>{const{translate:s,scale:r,rotation:n}=t,o=new i.Matrix3d;o.setTranslation([s.x,s.y,s.z]);const a=new i.Matrix3d;a.setToRotation(n.angle,[n.x,n.y,n.z],e);const h=new i.Matrix3d;return h.setToScaling(r,e),a.postMultBy(o).postMultBy(h)};function K(t,e=0){if(!t.visualizeJs)return;t.visViewer().explode(e),t.update(),t.emitEvent({type:"explode",data:e})}function q(t,e=""){if(!t.visualizeJs)return;const i=t.visLib(),s=t.visViewer(),r=i.DefaultViewPosition;s.setDefaultViewPositionWithAnimation(r[e]),t.update(),t.emit({type:"viewposition",data:e})}function J(t){return"$"===t.getName()[0]}const Z=s("visualizejs");Z.registerCommand("applyModelTransform",(function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const s=t.visLib(),r=s.getViewer(),n=r.getModelIterator();for(;!n.done();n.step()){const t=n.getModel(),i=e.getModelTransformMatrix(t.getDatabaseHandle());if(i){const e=t.getExtents();e.transformBy(t.getUnitsMatrix());const r=X(i,e.center(),s);t.setModelingMatrix(r,!0)}}n.delete(),null===(i=r.clearViewExtentsCache)||void 0===i||i.call(r),t.update()})),Z.registerCommand("clearMarkup",(function(t){t.clearOverlay()})),Z.registerCommand("clearSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().unselect(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),Z.registerCommand("clearSlices",(function(t){t.clearSlices()})),Z.registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){var s;return t.visualizeJs&&(null===(s=t.canvas)||void 0===s?void 0:s.toDataURL(e,i))||""})),Z.registerCommand("explode",K),Z.registerCommand("collect",(function(t){K(t,0)})),Z.registerCommand("getDefaultViewPositions",(function(t){if(!t.visualizeJs)return[];const e=t.visLib().DefaultViewPosition;return Object.keys(e).filter((t=>"values"!==t))})),Z.registerCommand("getModels",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getModelIterator();for(;!i.done();i.step()){const t=i.getModel();"$"!==t.getName()[0]&&e.push(t.getDatabaseHandle())}return i.delete(),e})),Z.registerCommand("getSelected",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator();for(;!t.done();t.step()){const i=t.getEntity(),s=1===i.getType()?i.openObject():2===i.getType()?i.openObjectAsInsert():null;if(s){const t=s.getNativeDatabaseHandle();"-1"!==t&&e.push(t),s.delete()}}t.delete()}return e})),Z.registerCommand("hideSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().hideSelectedObjects(!1),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),Z.registerCommand("isolateSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().isolateSelectedObjects(!1),t.update(),t.emitEvent({type:"isolate"})})),Z.registerCommand("regenerateAll",(function(t){if(!t.visualizeJs)return;t.visViewer().regenAll(),t.update(),t.emit({type:"regenerateall"})})),Z.registerCommand("resetView",(function(t){t.visualizeJs&&(t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"}))})),Z.registerCommand("selectModel",(function(t,e){if(!t.visualizeJs)return;const i=t.visViewer(),s=i.activeView,r=i.getModelIterator();for(;!r.done();r.step()){const n=r.getModel();if(n.getDatabaseHandle()===e){const e=s.selectCrossing([0,9999,9999,0],n);i.setSelected(e);const r=t.getSelected();t.update(),t.emitEvent({type:"select",data:e,handles:r}),e.delete();break}}r.delete()})),Z.registerCommand("setActiveDragger",(function(t,e=""){t.setActiveDragger(e)})),Z.registerCommand("setDefaultViewPosition",q),Z.registerCommand("setMarkupColor",(function(t,e=255,i=0,s=0){t.markup.setMarkupColor(e,i,s)})),Z.registerCommand("setSelected",(function(t,e=[]){if(!t.visualizeJs)return;const i=t.visLib(),s=i.getViewer(),r=new i.OdTvSelectionSet;null==e||e.forEach((t=>{const e=s.getEntityByOriginalHandle(t+"");e.isNull()||r.appendEntity(e)})),s.setSelected(r),t.update(),t.emitEvent({type:"select",data:r,handles:e}),r.delete()})),Z.registerCommand("showAll",(function(t){if(!t.visualizeJs)return;t.visViewer().unisolateSelectedObjects(!1),t.update(),t.emitEvent({type:"showall"})})),Z.registerCommand("zoomToExtents",(function(t,e=!1,i=t.options.cameraAnimation){if(!t.visualizeJs)return;const s=t.visViewer(),r=s.getEnableAnimation();s.setEnableAnimation(i),s.zoomExtents(e),s.update(),s.setEnableAnimation(r),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),Z.registerCommand("zoomToObjects",(function(t,e=[]){var i;if(!t.visualizeJs)return;const s=t.visLib(),r=t.visViewer(),n=new s.OdTvSelectionSet;e.forEach((t=>{const e=r.getEntityByOriginalHandle(t+"");e.isNull()||n.appendEntity(e)})),null===(i=r.zoomToObjects)||void 0===i||i.call(r,n),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"}),n.delete()})),Z.registerCommand("zoomToSelected",(function(t){var e;if(!t.visualizeJs)return;const i=t.visViewer(),s=i.getSelected();null===(e=i.zoomToObjects)||void 0===e||e.call(i,s),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),Z.registerCommand("autoTransformAllModelsToCentralPoint",(async function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const s=t.visLib(),r=s.getViewer(),n=r.getActiveExtents().center(),o=r.getModelIterator();for(;!o.done();o.step()){const t=o.getModel();if(!J(t)){const i=t.getExtents(),r=t.getUnitsMatrix();i.transformBy(t.getUnitsMatrix());const o=t.getUnitsMatrix().invert(),a=i.center(),h=1,l=new s.Matrix3d,d=new s.Matrix3d;d.setTranslation([n[0]-a[0],n[1]-a[1],n[2]-a[2]]),l.setToScaling(h,n);const c=o.postMultBy(l).postMultBy(d).postMultBy(r),u=c.scale(),g={translate:{x:c.get(0,3)-(1-u)*a[0],y:c.get(1,3)-(1-u)*a[1],z:c.get(2,3)-(1-u)*a[2]},rotation:{x:0,y:0,z:1,angle:0},scale:u},f=X(g,a,s);t.setModelingMatrix(f,!0),n[0]+=Math.abs(i.max()[0]-i.min()[0])*u,await e.setModelTransformMatrix(t.getDatabaseHandle(),g)}t.delete()}o.delete(),null===(i=r.clearViewExtentsCache)||void 0===i||i.call(r),t.update()})),Z.registerCommand("k3DViewTop",(t=>q(t,"k3DViewTop"))),Z.registerCommand("k3DViewBottom",(t=>q(t,"k3DViewBottom"))),Z.registerCommand("k3DViewLeft",(t=>q(t,"k3DViewLeft"))),Z.registerCommand("k3DViewRight",(t=>q(t,"k3DViewRight"))),Z.registerCommand("k3DViewFront",(t=>q(t,"k3DViewFront"))),Z.registerCommand("k3DViewBack",(t=>q(t,"k3DViewBack"))),Z.registerCommand("k3DViewSE",(t=>q(t,"k3DViewSE"))),Z.registerCommand("k3DViewSW",(t=>q(t,"k3DViewSW"))),Z.registerCommand("k3DViewNE",(t=>q(t,"k3DViewNE"))),Z.registerCommand("k3DViewNW",(t=>q(t,"k3DViewNW"))),Z.registerCommandAlias("clearMarkup","clearOverlay"),Z.registerCommandAlias("clearSelected","unselect"),Z.registerCommandAlias("zoomToExtents","zoomExtents");class ${constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Q{constructor(t){this.resizeViewer=()=>{this.viewer.resize()},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class tt{constructor(t){this.viewer=t,this.zoomWheelDragger=new U(t),this.zoomWheelDragger.name="ZoomWheel",this.zoomWheelDragger.initialize()}dispose(){this.zoomWheelDragger.dispose(),this.zoomWheelDragger=void 0}}var et;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(et||(et={}));class it extends y{get isSingleTouchEnabled(){return this._isSingleTouchEnabled}set isSingleTouchEnabled(t){this._isSingleTouchEnabled=t}constructor(t){super(t),this._previousEvents=new Map,this._currentEvents=new Map,this._lastGestureAction=et.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new L(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new z(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new N(this.m_module,this.subject)}getMiddlePoint(t){if(2!==t.size)return;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),s=this.relativeCoords(t.get(e[1]));return{x:Math.floor((i.x+s.x)/2),y:Math.floor((i.y+s.y)/2)}}getFirstPoint(t){if(t.size<1)return;const e=this.getKeys(t);return this.relativeCoords(t.get(e[0]))}getDistance(t){if(2!==t.size)return-1;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),s=this.relativeCoords(t.get(e[1]));return Math.hypot(i.x-s.x,i.y-s.y)}updateEvent(t){const e=!this._currentEvents.get(t.pointerId);if(e&&2===this._currentEvents.size)return;const i=this._currentEvents.get(t.pointerId);i&&this._previousEvents.set(i.pointerId,i),this._currentEvents.set(t.pointerId,t),e&&(this._initialDistance=this.getDistance(this._currentEvents))}removeEvent(t){this._currentEvents.delete(t.pointerId),this._previousEvents.delete(t.pointerId),this._currentEvents.size<2&&(this._initialDistance=-1)}getKeys(t){return Array.from(t.keys())}analyzeGesture(){if(2===this._currentEvents.size){const t=this.getDistance(this._currentEvents),e=this.getDistance(this._previousEvents);Math.abs(this._initialDistance-t)<=this._maxInitialDistanceDifference?this.executePanAction(this.getMiddlePoint(this._currentEvents)):-1!==e&&t!==e&&this.executeZoomAction(t,e)}else 1===this._currentEvents.size&&this.isSingleTouchEnabled&&this.executeOrbitAction(this.getFirstPoint(this._currentEvents))}executeZoomAction(t,e){this._lastGestureAction!==et.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Zoom,y.isGestureActive=!0);const i=1+(t-e)/700,s=this.getMiddlePoint(this._currentEvents);this._zoomAction.action(s.x,s.y,i,s.x,s.y),this.subject.update()}executePanAction(t){this._lastGestureAction!==et.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Pan,y.isGestureActive=!0,this._panAction.beginAction(t.x,t.y,t.x,t.y)),this._panAction.action(t.x,t.y,t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==et.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Orbit,y.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===et.Orbit&&this._orbitAction.endAction(),t===et.Pan&&this._panAction.endAction(),y.isGestureActive=!1}needIgnoreEvent(t){return!this.subject.options.enableZoomWheel||!this.subject.options.enableGestures||!this.eventIsTouchEvent(t)}eventIsTouchEvent(t){return"touch"===t.pointerType||""===t.pointerType}pointerdown(t){this.needIgnoreEvent(t)||this.updateEvent(t)}pointermove(t){this.needIgnoreEvent(t)||(this.updateEvent(t),this.analyzeGesture())}pointerup(t){this.needIgnoreEvent(t)||(this.removeEvent(t),this._currentEvents.size<2&&(this.executeEndAction(this._lastGestureAction),y.isGestureActive=!1),this._lastGestureAction=et.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}class st{constructor(t){this.viewer=t,this.gestureManager=new it(t),this.gestureManager.initialize()}dispose(){this.gestureManager.dispose(),this.gestureManager=void 0}}const rt=l("visualizejs");rt.registerComponent("ResizeCanvasComponent",(t=>new Q(t))),rt.registerComponent("RenderLoopComponent",(t=>new $(t))),rt.registerComponent("ZoomWheelComponent",(t=>new tt(t))),rt.registerComponent("GestureManagerComponent",(t=>new st(t)));class nt{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}load(t,e){if("string"==typeof t){const i=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal});return fetch(i).then((t=>{if(!t.ok)throw new Error(`Failed to fetch "${t.url}", status ${t.status}`);const i=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),s=parseInt(i||"",10)||0,r=s>0,n=new ReadableStream({async start(i){const n=t.body.getReader();let o=0;try{for(;;){const{done:t,value:a}=await n.read();if(t)break;e&&(o+=a.byteLength,e(new ProgressEvent("progress",{lengthComputable:r,loaded:o,total:s}))),i.enqueue(a)}i.close()}catch(t){i.error(t)}}});return new Response(n)})).then((t=>t.arrayBuffer()))}if(t instanceof globalThis.File)return new Promise(((i,s)=>{const r=new FileReader;r.onload=()=>i(r.result),r.onerror=()=>s(r.error),r.onprogress=e,r.readAsArrayBuffer(new Blob([t]))}));if(e){const i=t.byteLength;e(new ProgressEvent("progress",{lengthComputable:i>0,loaded:i,total:i}))}return Promise.resolve(t)}}class ot extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/vsf$/i.test(e)}async load(t,e,i){if(!this.viewer.visualizeJs)return this;const s=new nt;s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.setAbortSignal(this.abortController.signal);const r=await s.load(t,(e=>{const{lengthComputable:i,loaded:s,total:r}=e,n=i?s/r:1;this.viewer.emitEvent({type:"geometryprogress",data:n,file:t})})),n=new Uint8Array(r);return this.viewer.visLib().getViewer().parseFile(n),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t}),this}}class at extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.data$/i.test(t.database)}async load(t,e){if(!this.viewer.visualizeJs)return this;const i=this.viewer.visLib().getViewer(),s=[t.database,...t.geometry];console.time("File load time");for(let e=0;e<s.length;e++){const r=s[e],n=i=>{const r=(e+i)/s.length;this.viewer.emitEvent({type:"geometryprogress",data:r,file:t.file,model:t})},o=await t.downloadResource(r,n,this.abortController.signal);if(!this.viewer.visualizeJs)return this;const a=new Uint8Array(o);i.parseStream(a),0===e?(this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:a,file:t.file,model:t})):(this.viewer.update(),this.viewer.emitEvent({type:"geometrychunk",data:a,file:t.file,model:t}))}return console.timeEnd("File load time"),this}}class ht extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/vsfx$/i.test(e)}async load(t,e,i){if(!this.viewer.visualizeJs)return this;const s=new nt;s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.setAbortSignal(this.abortController.signal);const r=await s.load(t,(e=>{const{lengthComputable:i,loaded:s,total:r}=e,n=i?s/r:1;this.viewer.emitEvent({type:"geometryprogress",data:n,file:t})})),n=new Uint8Array(r);return this.viewer.visLib().getViewer().parseVsfx(n),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t}),this}}class lt extends d{constructor(t){super(),this.viewer=t}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.vsfx$/i.test(t.database)&&!1===this.viewer.options.enableStreamingMode}async load(t,e,i={}){if(!this.viewer.visualizeJs)return Promise.resolve(this);const s=this.viewer.visLib().getViewer();console.time("File load time");const r=await t.downloadResource(t.database,(e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t})}),this.abortController.signal);if(!this.viewer.visualizeJs)return this;const n=new Uint8Array(r);try{s.parseVsfx(n)}catch(t){throw console.error("VSFX parse error.",t),t}return this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t}),console.timeEnd("File load time"),this}}var dt;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(dt||(dt={}));class ct{constructor(){this.lastUpdate=0,this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==dt.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===dt.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class ut extends d{constructor(t){super(),this.viewer=t}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.vsfx$/i.test(t.database)&&!0===this.viewer.options.enableStreamingMode&&!1===this.viewer.options.enablePartialMode&&!/.rcs$/i.test(t.name)}async load(t){if(!this.viewer.visualizeJs)return this;const e=this.viewer.visLib(),i=e.getViewer(),s=new ct;s.initialize(this.viewer);let r=!1;return console.time("File load time"),await t.downloadResource(t.database,((n,o)=>{if(!this.viewer.visualizeJs)return;let a;try{a=i.parseVsfx(o)}catch(t){throw console.error("VSFX parse error.",t),t}s.update(dt.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:n,file:t.file,model:t});let h=!1;(a===e.DatabaseStreamStatus.ReadyServiceData||a===e.DatabaseStreamStatus.Complete&&!r)&&(r=!0,h=!0),h?(s.update(dt.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:o,file:t.file,model:t})):this.viewer.emitEvent({type:"geometrychunk",data:o,file:t.file,model:t})}),this.abortController.signal),s.update(dt.kNormal),console.timeEnd("File load time"),Promise.resolve(this)}}class gt extends d{constructor(t){super(),this.viewer=t,this.abortControllerForRequestMap=new Map}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.vsfx$/i.test(t.database)&&(!0===this.viewer.options.enablePartialMode||/.rcs$/i.test(t.name))}async load(t,e){if(!this.viewer.visualizeJs)return this;const i=this.viewer.visLib().getViewer();let s=!1;const r=new Map;let n=0;const o=()=>clearTimeout(n),a=new AbortController;this.abortControllerForRequestMap.set(0,a);const h=new ct;h.initialize(this.viewer),i.memoryLimit=this.viewer.options.memoryLimit;const l=(e,s,r=0)=>{if(!this.viewer.visualizeJs)return;let n;try{n=i.parseVsfxInPartialMode(r,s)}catch(t){throw console.error("VSFX parse error.",t),t}h.update(dt.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t}),n?(h.update(dt.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:s,file:t.file,model:t})):this.viewer.emitEvent({type:"geometrychunk",data:s,file:t.file,model:t})},d=async(e,s,r)=>{const n=new AbortController;this.abortControllerForRequestMap.set(s,n);try{await t.downloadResourceRange(e,s,r,l,n.signal)}catch(e){this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}finally{r.forEach((t=>i.onRequestResponseComplete(t.requestId))),this.abortControllerForRequestMap.delete(s),h.update(dt.kNormal)}},c=(t,e)=>{const i=[];for(let s=0;s<e.size();s++){const r=e.get(s);i.push({requestId:t,begin:Number(r.begin),end:Number(r.end)-1}),r.delete()}return i},u={onServicePartReceived:t=>{t&&(s=!0,this.abortController.abort())},onRequest:(e,i)=>{const s=c(e,i);d(t.database,e,s)},onFullLoaded:()=>{h.update(dt.kNormal)},onRequestResponseParsed:t=>{this.abortControllerForRequestMap.delete(t),h.update(dt.kNormal)},onRequestAborted:t=>{const e=this.abortControllerForRequestMap.get(t);e&&e.abort()},onRequestResourceFile:(e,i,s)=>{const h=`${t.fileId}${t.file.type}`,l=c(e,s);let u=[],g=0;const f=r.get(h);return f&&(u=f.ranges,g=f.number),g<=5?(r.set(h,{ranges:[],number:g+1}),void d(h,e,l)):(u=u.concat(l),u.length>=50?(n&&(window.clearTimeout(n),n=0),r.set(h,{ranges:[],number:g+1}),void d(h,e,u)):(r.set(h,{ranges:u,number:g+1}),void(0===n&&(n=window.setTimeout((()=>{a.signal.removeEventListener("abort",o),n=0,r.forEach(((t,i)=>{t.ranges.length>0&&(r.set(i,{ranges:[],number:t.number+1}),d(i,e,t.ranges))}))}),250),a.signal.addEventListener("abort",o,{once:!0})))))}};i.attachPartialResolver(u);try{await t.downloadResource(t.database,l,this.abortController.signal)}catch(t){if(window.clearTimeout(n),!s)throw t}return this}cancel(){super.cancel(),this.abortControllerForRequestMap.forEach((t=>t.abort()))}}const ft=g("visualizejs");ft.registerLoader("vsf-file",(t=>new ot(t))),ft.registerLoader("vsf-cloud",(t=>new at(t))),ft.registerLoader("vsfx-file",(t=>new ht(t))),ft.registerLoader("vsfx-cloud",(t=>new lt(t))),ft.registerLoader("vsfx-cloud-streaming",(t=>new ut(t))),ft.registerLoader("vsfx-cloud-partial",(t=>new gt(t)));class pt{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}function mt(t,e){if(window.getVisualizeLibInst){const e=window.getVisualizeLibInst.script;if(e){if(e.src===t)return Promise.resolve(e);e.remove()}delete window.getVisualizeLibInst}return function(t,e={}){return new Promise(((i,s)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.crossOrigin=e.crossOrigin,r.onload=()=>i(r),r.onerror=()=>{r.remove(),s(new Error(`GET ${t} failed to load script`))},document.body.appendChild(r)}))}(t,e)}var _t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function vt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yt,wt={exports:{}},xt={},bt={},St={};function Ct(){return yt||(yt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==_t?_t:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.18",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(St)),St}var Pt,At={};function Tt(){return Pt||(Pt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Ct();class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,n=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=s,this.m[1]=r,this.m[2]=n,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,s=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,n=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=s,this.m[2]=r,this.m[3]=n,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],s=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],n=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=s,this.m[3]=r,this.m[4]=n,this.m[5]=o,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,s=-this.m[2]*t,r=this.m[0]*t,n=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=s,this.m[3]=r,this.m[4]=n,this.m[5]=o,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],s=this.m[2],r=this.m[3],n=e*r-i*s,o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),o.scaleX=t,o.scaleY=n/t,o.skewX=(e*s+i*r)/n,o.skewY=0}else if(0!=s||0!=r){const t=Math.sqrt(s*s+r*r);o.rotation=Math.PI/2-(r>0?Math.acos(-s/t):-Math.acos(s/t)),o.scaleX=n/t,o.scaleY=t,o.skewX=0,o.skewY=(e*s+i*r)/n}return o.rotation=t.Util._getRotation(o.rotation),o}}t.Transform=i;const s=Math.PI/180,r=180/Math.PI,n="Konva error: ",o={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},a=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const s=t.Util.createImageElement();s.onload=function(){i(s)},s.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in o?(e=o[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=a.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=o[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),s=Number(i[0])/360,r=Number(i[1])/100,n=Number(i[2])/100;let o,a,h;if(0===r)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=n<.5?n*(1+r):n+r-n*r;const l=2*n-o,d=[0,0,0];for(let t=0;t<3;t++)a=s+1/3*-(t-1),a<0&&a++,a>1&&a--,h=6*a<1?l+6*(o-l)*a:2*a<1?o:3*a<2?l+(o-l)*(2/3-a)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*s,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(n+t)},error(t){console.error(n+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,s,r,n){let o,a,h;const l=(t-i)*(t-i)+(e-s)*(e-s);if(0==l)o=t,a=e,h=(r-i)*(r-i)+(n-s)*(n-s);else{const d=((r-t)*(i-t)+(n-e)*(s-e))/l;d<0?(o=t,a=e,h=(t-r)*(t-r)+(e-n)*(e-n)):d>1?(o=i,a=s,h=(i-r)*(i-r)+(s-n)*(s-n)):(o=t+d*(i-t),a=e+d*(s-e),h=(o-r)*(o-r)+(a-n)*(a-n))}return[o,a,h]},_getProjectionToLine(e,i,s){const r=t.Util.cloneObject(e);let n=Number.MAX_VALUE;return i.forEach((function(o,a){if(!s&&a===i.length-1)return;const h=i[(a+1)%i.length],l=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<n&&(r.x=d,r.y=c,n=u)})),r},_prepareArrayForTween(e,i,s){const r=[],n=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)n.push({x:i[t],y:i[t+1]});const o=[];return n.forEach((function(e){const i=t.Util._getProjectionToLine(e,r,s);o.push(i.x),o.push(i.y)})),o},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const s in e)if(e.hasOwnProperty(s)&&e[s]&&"object"==typeof e[s])if(i=Object.getOwnPropertyDescriptor(e,s),e[s].visitedByCircularReferenceRemoval||t.Util._isElement(e[s])){if(!i.configurable)return null;delete e[s]}else if(null===t.Util._prepareToStringify(e[s])){if(!i.configurable)return null;delete e[s]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,s){let r=0,n=0,o=0,a=0;"number"==typeof s?r=n=o=a=Math.min(s,e/2,i/2):(r=Math.min(s[0]||0,e/2,i/2),n=Math.min(s[1]||0,e/2,i/2),a=Math.min(s[2]||0,e/2,i/2),o=Math.min(s[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-n,0),t.arc(e-n,n,n,3*Math.PI/2,0,!1),t.lineTo(e,i-a),t.arc(e-a,i-a,a,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(At)),At}var kt,Et,Mt={},Ft={},It={};function Rt(){if(kt)return It;kt=1,Object.defineProperty(It,"__esModule",{value:!0}),It.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},It.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},It.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number.'),t}},It.getNumberOrArrayOfNumbersValidator=function(s){if(t.Konva.isUnminified)return function(t,r){let n=e.Util._isNumber(t),o=e.Util._isArray(t)&&t.length==s;return n||o||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+s+")"),t}},It.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number or "auto".'),t}},It.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a string.'),t}},It.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,s){const r=e.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||n||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a string or a native gradient.'),t}},It.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a function.'),t}},It.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,s){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+s+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a array of numbers.')),t}},It.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,s){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a boolean.'),t}},It.getComponentValidator=function(s){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+s),t}};const t=Ct(),e=Tt();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return It}function Ot(){return Et||(Et=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=Tt(),i=Rt(),s="get",r="set";t.Factory={addGetterSetter(e,i,s,r,n){t.Factory.addGetter(e,i,s),t.Factory.addSetter(e,i,r,n),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,r){var n=s+e.Util._capitalize(i);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[i];return void 0===t?r:t}},addSetter(i,s,n,o){var a=r+e.Util._capitalize(s);i.prototype[a]||t.Factory.overWriteSetter(i,s,n,o)},overWriteSetter(t,i,s,n){var o=r+e.Util._capitalize(i);t.prototype[o]=function(t){return s&&null!=t&&(t=s.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,o,a,h,l){const d=a.length,c=e.Util._capitalize,u=s+c(o),g=r+c(o);n.prototype[u]=function(){const t={};for(let e=0;e<d;e++){const i=a[e];t[i]=this.getAttr(o+c(i))}return t};const f=(0,i.getComponentValidator)(a);n.prototype[g]=function(t){const e=this.attrs[o];h&&(t=h.call(this,t,o)),f&&f.call(this,t,o);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(o+c(e),t[e]);return t||a.forEach((t=>{this._setAttr(o+c(t),void 0)})),this._fireChangeEvent(o,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,o)},addOverloadedGetterSetter(t,i){var n=e.Util._capitalize(i),o=r+n,a=s+n;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(i,r,n,o){e.Util.error("Adding deprecated "+r);const a=s+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[a]=function(){e.Util.error(h);const t=this.attrs[r];return void 0===t?n:t},t.Factory.addSetter(i,r,o,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,n){const o=t.prototype[n],a=s+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[a]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(Ft)),Ft}var Dt,Lt,Vt={},zt={};function Gt(){if(Dt)return zt;Dt=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.HitContext=zt.SceneContext=zt.Context=void 0;const t=Tt(),e=Ct();const i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let s=class{constructor(t){this.canvas=t,e.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(e,i){let s,r,n,o,a=this.traceArr,h=a.length,l="";for(s=0;s<h;s++)r=a[s],n=r.method,n?(o=r.args,l+=n,e?l+="()":t.Util._isArray(o[0])?l+="(["+o.join(",")+"])":(i&&(o=o.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+o.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,s,r,n){this._context.arc(t,e,i,s,r,n)}arcTo(t,e,i,s,r){this._context.arcTo(t,e,i,s,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,s,r,n){this._context.bezierCurveTo(t,e,i,s,r,n)}clearRect(t,e,i,s){this._context.clearRect(t,e,i,s)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,s){return this._context.createLinearGradient(t,e,i,s)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,s,r,n){return this._context.createRadialGradient(t,e,i,s,r,n)}drawImage(t,e,i,s,r,n,o,a,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,s,r):9===l.length&&d.drawImage(t,e,i,s,r,n,o,a,h)}ellipse(t,e,i,s,r,n,o,a){this._context.ellipse(t,e,i,s,r,n,o,a)}isPointInPath(t,e,i,s){return i?this._context.isPointInPath(i,t,e,s):this._context.isPointInPath(t,e,s)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,s){this._context.fillRect(t,e,i,s)}strokeRect(t,e,i,s){this._context.strokeRect(t,e,i,s)}fillText(t,e,i,s){s?this._context.fillText(t,e,i,s):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,s){return this._context.getImageData(t,e,i,s)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,s){this._context.rect(t,e,i,s)}roundRect(t,e,i,s,r){this._context.roundRect(t,e,i,s,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,s){this._context.quadraticCurveTo(t,e,i,s)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,s,r,n){this._context.setTransform(t,e,i,s,r,n)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,s){this._context.strokeText(t,e,i,s)}transform(t,e,i,s,r,n){this._context.transform(t,e,i,s,r,n)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,s,r=this,n=i.length,o=this.setAttr;const a=function(e){let i,n=r[e];r[e]=function(){return s=function(e){const i=[],s=e.length,r=t.Util;for(let t=0;t<s;t++){let s=e[t];r._isNumber(s)?s=Math.round(1e3*s)/1e3:r._isString(s)||(s+=""),i.push(s)}return i}(Array.prototype.slice.call(arguments,0)),i=n.apply(r,arguments),r._trace({method:e,args:s}),i}};for(e=0;e<n;e++)a(i[e]);r.setAttr=function(){o.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};zt.Context=s,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(s.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));zt.SceneContext=class extends s{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const s=t.getFillPatternImage();if(s&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const n=t.getFillRadialGradientColorStops();n&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):s?this._fillPattern(t):r?this._fillLinearGradient(t):n&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),s=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(s){for(let t=0;t<s.length;t+=2)r.addColorStop(s[t],s[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,s;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(s=t.getShadowOffset())&&void 0!==s?s:{x:0,y:0},a=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=a.x*h,d=a.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*d)}};return zt.HitContext=class extends s{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),s="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",s),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},zt}function Nt(){if(Lt)return Vt;Lt=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.HitCanvas=Vt.SceneCanvas=Vt.Canvas=void 0;const t=Tt(),e=Gt(),i=Ct(),s=Ot(),r=Rt();let n;let o=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const s=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(n)return n;const e=t.Util.createCanvasElement(),s=e.getContext("2d");return n=(i.Konva._global.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t.Util.releaseCanvas(e),n}();this.pixelRatio=s,this._canvas=t.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Vt.Canvas=o,s.Factory.addGetterSetter(o,"pixelRatio",void 0,(0,r.getNumberValidator)());Vt.SceneCanvas=class extends o{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return Vt.HitCanvas=class extends o{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},Vt}var Wt,Ut,Bt={};function jt(){return Wt||(Wt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Ct(),i=Tt();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const s=[];t.DD._dragElements.forEach(((t,r)=>{const{node:n}=t,o=n.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const a=o._changedPointerPositions.find((e=>e.id===t.pointerId));if(a){if("dragging"!==t.dragStatus){const i=n.dragDistance();if(Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y))<i)return;if(n.startDrag({evt:e}),!n.isDragging())return}n._setDragPosition(e,t),s.push(n)}})),s.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const s=[];t.DD._dragElements.forEach((r=>{const{node:n}=r,o=n.getStage();i&&o.setPointersPositions(i);if(!o._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const a=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;a&&-1===s.indexOf(a)&&s.push(a)})),s.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,s)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(s)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(Bt)),Bt}function Ht(){if(Ut)return Mt;Ut=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.Node=void 0;const t=Tt(),e=Ot(),i=Nt(),s=Ct(),r=jt(),n=Rt(),o="absoluteOpacity",a="allEventListeners",h="absoluteTransform",l="absoluteScale",d="canvas",c="listening",u="mouseenter",g="mouseleave",f="Shape",p=" ",m="stage",_="transform",v="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(p);let w=1,x=class e{constructor(t){this._id=w++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==_&&t!==h||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===_||t===h)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(p);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(d)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(d)){const{scene:e,filter:i,hit:s}=this._cache.get(d);t.Util.releaseCanvas(e,i,s),this._cache.delete(d)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const s=e||{};let r={};void 0!==s.x&&void 0!==s.y&&void 0!==s.width&&void 0!==s.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(s.width||r.width),a=Math.ceil(s.height||r.height),h=s.pixelRatio,c=void 0===s.x?Math.floor(r.x):s.x,u=void 0===s.y?Math.floor(r.y):s.y,g=s.offset||0,f=s.drawBorder||!1,p=s.hitCanvasPixelRatio||1;if(!n||!a)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*g+(Math.abs(Math.round(r.x)-c)>.5?1:0),a+=2*g+(Math.abs(Math.round(r.y)-u)>.5?1:0),c-=g,u-=g;const m=new i.SceneCanvas({pixelRatio:h,width:n,height:a}),_=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),v=new i.HitCanvas({pixelRatio:p,width:n,height:a}),y=m.getContext(),w=v.getContext();return v.isCache=!0,m.isCache=!0,this._cache.delete(d),this._filterUpToDate=!1,!1===s.imageSmoothingEnabled&&(m.getContext()._context.imageSmoothingEnabled=!1,_.getContext()._context.imageSmoothingEnabled=!1),y.save(),w.save(),y.translate(-c,-u),w.translate(-c,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(l),this.drawScene(m,this),this.drawHit(v,this),this._isUnderCache=!1,y.restore(),w.restore(),f&&(y.save(),y.beginPath(),y.rect(0,0,n,a),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(d,{scene:m,filter:_,hit:v,x:c,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(d)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let s=1/0,r=1/0,n=-1/0,o=-1/0;const a=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=a.point(t);void 0===s&&(s=n=e.x,r=o=e.y),s=Math.min(s,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)})),{x:s,y:r,width:n-s,height:o-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),s=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/s,i.height/s),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,i,s,r,n=this.filters(),o=this._getCanvasCache(),a=o.scene,h=o.filter,l=h.getContext();if(n){if(!this._filterUpToDate){const o=a.pixelRatio;h.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(e=n.length,l.clear(),l.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),s=0;s<e;s++)r=n[s],"function"==typeof r?(r.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return a}on(t,e){if(this._cache&&this._cache.delete(a),3===arguments.length)return this._delegate.apply(this,arguments);let i,s,r,n,o,h=t.split(p),l=h.length;for(i=0;i<l;i++)s=h[i],r=s.split("."),n=r[0],o=r[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:o,handler:e});return this}off(t,e){let i,s,r,n,o,h,l=(t||"").split(p),d=l.length;if(this._cache&&this._cache.delete(a),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<d;i++)if(r=l[i],n=r.split("."),o=n[0],h=n[1],o)this.eventListeners[o]&&this._off(o,h,e);else for(s in this.eventListeners)this._off(s,h,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(e,i,s){const r=this;this.on(e,(function(e){const n=e.target.findAncestors(i,!0,r);for(let i=0;i<n.length;i++)(e=t.Util.cloneObject(e)).currentTarget=n[i],s.call(n[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(v),this._clearSelfAndDescendantCache(c)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,s;if(!e)return this;for(i in e)"children"!==i&&(s="set"+t.Util._capitalize(i),t.Util._isFunction(this[s])?this[s](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(c,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(v,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));const o=!e&&!s.Konva.hitOnDragEnabled&&(n||s.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,s,r=this.getDepth(),n=this,o=0;const a=this.getStage();return"Stage"!==n.nodeType&&a&&function a(h){for(t=[],e=h.length,i=0;i<e;i++)s=h[i],o++,s.nodeType!==f&&(t=t.concat(s.getChildren().slice())),s._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&a(t)}(a.getChildren()),o}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(_),this._clearSelfAndDescendantCache(h)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(e){let i=!1,s=this.parent;for(;s;){if(s.isCached()){i=!0;break}s=s.parent}i&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),n=new t.Transform,o=this.offset();return n.m=r.slice(),n.translate(o.x,o.y),n.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...s}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(_);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(s),this.setPosition({x:t.x,y:t.y}),this._clearCache(_),this._clearSelfAndDescendantCache(h),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,s=this.x(),r=this.y();return void 0!==e&&(s+=e),void 0!==i&&(r+=i),this.setPosition({x:s,y:r}),this}_eachAncestorReverse(t,e){let i,s,r=[],n=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);n&&(!e||n._id!==e._id);)r.unshift(n),n=n.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(o,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let e,i,s,r,n,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(e in o)i=o[e],n=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),n||(s="function"==typeof this[e]&&this[e],delete o[e],r=s?s.call(this):null,o[e]=i,r!==i&&(a.attrs[e]=i));return t.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const s=[];e&&this._isMatch(t)&&s.push(this);let r=this.parent;for(;r;){if(r===i)return s;r._isMatch(t)&&s.push(r),r=r.parent}return s}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,s,r=e.replace(/ /g,"").split(","),n=r.length;for(i=0;i<n;i++)if(s=r[i],t.Util.isValidSelector(s)||(t.Util.warn('Selector "'+s+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===s.charAt(0)){if(this.id()===s.slice(1))return!0}else if("."===s.charAt(0)){if(this.hasName(s.slice(1)))return!0}else if(this.className===s||this.nodeType===s)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(m,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(h,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(h)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,s=this.attrs.offsetX||0,r=this.attrs.offsetY||0;i.translate(t-s,e-r)}return i.dirty=!1,i}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(_,this._getTransform)}_getTransform(){var e,i;const r=this._cache.get(_)||new t.Transform;r.reset();const n=this.x(),o=this.y(),a=s.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,d=this.attrs.skewX||0,c=this.attrs.skewY||0,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;return 0===n&&0===o||r.translate(n,o),0!==a&&r.rotate(a),0===d&&0===c||r.skew(d,c),1===h&&1===l||r.scale(h,l),0===u&&0===g||r.translate(-1*u,-1*g),r.dirty=!1,r}clone(e){let i,s,r,n,o,a=t.Util.cloneObject(this.attrs);for(i in e)a[i]=e[i];const h=new this.constructor(a);for(i in this.eventListeners)for(s=this.eventListeners[i],r=s.length,n=0;n<r;n++)o=s[n],o.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(o));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),s=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),n=void 0!==t.y?t.y:Math.floor(e.y),o=t.pixelRatio||1,a=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(s?s.width():0),height:t.height||Math.ceil(e.height)||(s?s.height():0),pixelRatio:o}),h=a.getContext(),l=new i.SceneCanvas({width:a.width/a.pixelRatio+Math.abs(r),height:a.height/a.pixelRatio+Math.abs(n),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(r||n)&&h.translate(-1*r,-1*n),this.drawScene(a,void 0,l),h.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,s=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(s),s}toImage(e){return new Promise(((i,s)=>{try{const s=null==e?void 0:e.callback;s&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==s||s(t)}))}catch(t){s(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():s.Konva.dragDistance}_off(t,e,i){let s,r,n,o=this.eventListeners[t];for(s=0;s<o.length;s++)if(r=o[s].name,n=o[s].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==n)){if(o.splice(s,1),0===o.length){delete this.eventListeners[t];break}s--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(e,i){const s=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(s)?s.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(s.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const s=this.attrs[e];(s!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,s,i),this._requestDraw())}_setComponentAttr(t,e,i){let s;void 0!==i&&(s=this.attrs[t],s||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,s,i))}_fireAndBubble(t,e,i){e&&this.nodeType===f&&(e.target=this);if(!((t===u||t===g)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=(t===u||t===g)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,s;const r=null!==(e=this._cache.get(a))&&void 0!==e?e:{};let n=null==r?void 0:r[t];if(void 0===n){n=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(s=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==s?s:[];n.push(...r),e=Object.getPrototypeOf(e)}r[t]=n,this._cache.set(a,r)}return n}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var s=0;s<i.length;s++)i[s].handler.call(this,e);const r=this.eventListeners[t];if(r)for(s=0;s<r.length;s++)r[s].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),s=this.getAbsolutePosition();if(!i)return;const n=i._getPointerById(e)||i._changedPointerPositions[0]||s;r.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,i){const s=this.getStage()._getPointerById(i.pointerId);if(!s)return;let r={x:s.x-i.offset.x,y:s.y-i.offset.y};const n=this.dragBoundFunc();if(void 0!==n){const i=n.call(this,r,e);i?r=i:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if(!(!(void 0!==t.evt.button)||s.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const i=this.getStage();if(!i)return!1;const s={x:-e.x,y:-e.y,width:i.width()+2*e.x,height:i.height()+2*e.y};return t.Util.haveIntersection(s,this.getClientRect())}static create(e,i){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,i)}static _createNode(i,r){let n,o,a,h=e.prototype.getClassName.call(i),l=i.children;r&&(i.attrs.container=r),s.Konva[h]||(t.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(n=new(0,s.Konva[h])(i.attrs),l)for(o=l.length,a=0;a<o;a++)n.add(e._createNode(l[a]));return n}};Mt.Node=x,x.prototype.nodeType="Node",x.prototype._attrsAffectingSize=[],x.prototype.eventListeners={},x.prototype.on.call(x.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(_),this._clearSelfAndDescendantCache(h))})),x.prototype.on.call(x.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(v)})),x.prototype.on.call(x.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(c)})),x.prototype.on.call(x.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(o)}));const b=e.Factory.addGetterSetter;return b(x,"zIndex"),b(x,"absolutePosition"),b(x,"position"),b(x,"x",0,(0,n.getNumberValidator)()),b(x,"y",0,(0,n.getNumberValidator)()),b(x,"globalCompositeOperation","source-over",(0,n.getStringValidator)()),b(x,"opacity",1,(0,n.getNumberValidator)()),b(x,"name","",(0,n.getStringValidator)()),b(x,"id","",(0,n.getStringValidator)()),b(x,"rotation",0,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"scale",["x","y"]),b(x,"scaleX",1,(0,n.getNumberValidator)()),b(x,"scaleY",1,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"skew",["x","y"]),b(x,"skewX",0,(0,n.getNumberValidator)()),b(x,"skewY",0,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"offset",["x","y"]),b(x,"offsetX",0,(0,n.getNumberValidator)()),b(x,"offsetY",0,(0,n.getNumberValidator)()),b(x,"dragDistance",void 0,(0,n.getNumberValidator)()),b(x,"width",0,(0,n.getNumberValidator)()),b(x,"height",0,(0,n.getNumberValidator)()),b(x,"listening",!0,(0,n.getBooleanValidator)()),b(x,"preventDefault",!0,(0,n.getBooleanValidator)()),b(x,"filters",void 0,(function(t){return this._filterUpToDate=!1,t})),b(x,"visible",!0,(0,n.getBooleanValidator)()),b(x,"transformsEnabled","all",(0,n.getStringValidator)()),b(x,"size"),b(x,"dragBoundFunc"),b(x,"draggable",!1,(0,n.getBooleanValidator)()),e.Factory.backCompat(x,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Mt}var Yt,Xt={};function Kt(){if(Yt)return Xt;Yt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Container=void 0;const t=Ot(),e=Ht(),i=Rt();let s=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((s=>{const r=s._isMatch(t);return r&&i.push(s),!(!r||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const s of i){if(e=t(s),e)return!0;if(s.hasChildren()&&(e=s._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){i.add(t.clone())})),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const s=this.getLayer(),r=t||s&&s.getCanvas(),n=r&&r.getContext(),o=this._getCanvasCache(),a=o&&o.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(a){n.save();const t=this.getAbsoluteTransform(e).getMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),s=t||i&&i.hitCanvas,r=s&&s.getContext(),n=this._getCanvasCache();if(n&&n.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",s,e);return this}_drawChildren(t,e,i,s){var r;const n=e&&e.getContext(),o=this.clipWidth(),a=this.clipHeight(),h=this.clipFunc(),l="number"==typeof o&&"number"==typeof a||h,d=i===this;if(l){n.save();const t=this.getAbsoluteTransform(i);let e,s=t.getMatrix();if(n.transform(s[0],s[1],s[2],s[3],s[4],s[5]),n.beginPath(),h)e=h.call(this,n,this);else{const t=this.clipX(),e=this.clipY();n.rect(t||0,e||0,o,a)}n.clip.apply(n,e),s=t.copy().invert().getMatrix(),n.transform(s[0],s[1],s[2],s[3],s[4],s[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(n.save(),n._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,i,s)})),c&&n.restore(),l&&n.restore()}getClientRect(t={}){var e;const i=t.skipTransform,s=t.relativeTo;let r,n,o,a,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,n=i.y,o=i.x+i.width,a=i.y+i.height):(r=Math.min(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),a=Math.max(a,i.y+i.height)))}));const d=this.find("Shape");let c=!1;for(let t=0;t<d.length;t++){if(d[t]._isVisible(this)){c=!0;break}}return h=c&&void 0!==r?{x:r,y:n,width:o-r,height:a-n}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,s)}};return Xt.Container=s,t.Factory.addComponentsGetterSetter(s,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(s,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipFunc"),Xt}var qt,Jt,Zt={},$t={};function Qt(){if(qt)return $t;qt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.getCapturedShape=function(t){return e.get(t)},$t.createEvent=s,$t.hasPointerCapture=function(t,i){return e.get(t)===i},$t.setPointerCapture=function(t,n){r(t);if(!n.getStage())return;e.set(t,n),i&&n._fire("gotpointercapture",s(new PointerEvent("gotpointercapture")))},$t.releaseCapture=r;const t=Ct(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function s(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const n=e.get(t);if(!n)return;const o=n.getStage();o&&o.content,e.delete(t),i&&n._fire("lostpointercapture",s(new PointerEvent("lostpointercapture")))}return $t}var te,ee,ie={},se={};function re(){return te||(te=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Ct(),i=Tt(),s=Ot(),r=Ht(),n=Rt(),o=Ct(),a=Qt(),h="hasShadow",l="shadowRGBA",d="patternImage",c="linearGradient",u="radialGradient";let g;function f(){return g||(g=i.Util.createCanvasElement().getContext("2d"),g)}t.shapes={};class p extends r.Node{constructor(e){let s;for(super(e);s=i.Util.getRandomColor(),!s||s in t.shapes;);this.colorKey=s,t.shapes[s]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const s=new i.Transform;s.translate(this.fillPatternX(),this.fillPatternY()),s.rotate(e.Konva.getAngle(this.fillPatternRotation())),s.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),s.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=s.getMatrix(),n="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(c,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=f(),i=this.fillLinearGradientStartPoint(),s=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,s.x,s.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=f(),i=this.fillRadialGradientStartPoint(),s=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),s.x,s.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),s=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&s&&r)return!0;const n=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&s&&n&&o)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const s=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,n=this.getSelfRect(),o=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+o,h=n.height+o,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=a+Math.abs(d),g=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(o/2+f)+Math.min(d,0)+n.x,y:-(o/2+f)+Math.min(c,0)+n.y};return s?p:this._transformedRect(p,r)}drawScene(t,e,i){const s=this.getLayer();let r,n,o=t||s.getCanvas(),a=o.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow();const c=o.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!l)return this;if(a.save(),this._useBufferCanvas()&&!c){r=this.getStage();const t=i||r.bufferCanvas;n=t.getContext(),n.clear(),n.save(),n._applyLineJoin(this);var g=this.getAbsoluteTransform(e).getMatrix();n.transform(g[0],g[1],g[2],g[3],g[4],g[5]),l.call(this,n,this),n.restore();const s=t.pixelRatio;d&&a._applyShadow(this),a._applyOpacity(this),a._applyGlobalCompositeOperation(this),a.drawImage(t._canvas,0,0,t.width/s,t.height/s)}else{if(a._applyLineJoin(this),!u){g=this.getAbsoluteTransform(e).getMatrix();a.transform(g[0],g[1],g[2],g[3],g[4],g[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}d&&a._applyShadow(this),l.call(this,a,this)}return a.restore(),this}drawHit(t,e,s=!1){if(!this.shouldDrawHit(e,s))return this;const r=this.getLayer(),n=t||r.hitCanvas,o=n&&n.getContext(),a=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!a)return this;o.save(),o._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,o,this),o.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),s=this._getCachedSceneCanvas(),r=e.hit,n=r.getContext(),o=r.getWidth(),a=r.getHeight();n.clear(),n.drawImage(s._canvas,0,0,o,a);try{const e=n.getImageData(0,0,o,a),s=e.data,r=s.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4){s[e+3]>t?(s[e]=h.r,s[e+1]=h.g,s[e+2]=h.b,s[e+3]=255):s[e+3]=0}n.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return a.hasPointerCapture(t,this)}setPointerCapture(t){a.setPointerCapture(t,this)}releaseCapture(t){a.releaseCapture(t,this)}}t.Shape=p,p.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},p.prototype._strokeFunc=function(t){t.stroke()},p.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},p.prototype._strokeFuncHit=function(t){t.stroke()},p.prototype._centroid=!1,p.prototype.nodeType="Shape",(0,o._registerNode)(p),p.prototype.eventListeners={},p.prototype.on.call(p.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),p.prototype.on.call(p.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(d)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(c)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),s.Factory.addGetterSetter(p,"stroke",void 0,(0,n.getStringOrGradientValidator)()),s.Factory.addGetterSetter(p,"strokeWidth",2,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillAfterStrokeEnabled",!1),s.Factory.addGetterSetter(p,"hitStrokeWidth","auto",(0,n.getNumberOrAutoValidator)()),s.Factory.addGetterSetter(p,"strokeHitEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"perfectDrawEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"shadowForStrokeEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"lineJoin"),s.Factory.addGetterSetter(p,"lineCap"),s.Factory.addGetterSetter(p,"sceneFunc"),s.Factory.addGetterSetter(p,"hitFunc"),s.Factory.addGetterSetter(p,"dash"),s.Factory.addGetterSetter(p,"dashOffset",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowColor",void 0,(0,n.getStringValidator)()),s.Factory.addGetterSetter(p,"shadowBlur",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowOpacity",1,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"shadowOffset",["x","y"]),s.Factory.addGetterSetter(p,"shadowOffsetX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowOffsetY",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternImage"),s.Factory.addGetterSetter(p,"fill",void 0,(0,n.getStringOrGradientValidator)()),s.Factory.addGetterSetter(p,"fillPatternX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternY",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillLinearGradientColorStops"),s.Factory.addGetterSetter(p,"strokeLinearGradientColorStops"),s.Factory.addGetterSetter(p,"fillRadialGradientStartRadius",0),s.Factory.addGetterSetter(p,"fillRadialGradientEndRadius",0),s.Factory.addGetterSetter(p,"fillRadialGradientColorStops"),s.Factory.addGetterSetter(p,"fillPatternRepeat","repeat"),s.Factory.addGetterSetter(p,"fillEnabled",!0),s.Factory.addGetterSetter(p,"strokeEnabled",!0),s.Factory.addGetterSetter(p,"shadowEnabled",!0),s.Factory.addGetterSetter(p,"dashEnabled",!0),s.Factory.addGetterSetter(p,"strokeScaleEnabled",!0),s.Factory.addGetterSetter(p,"fillPriority","color"),s.Factory.addComponentsGetterSetter(p,"fillPatternOffset",["x","y"]),s.Factory.addGetterSetter(p,"fillPatternOffsetX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternOffsetY",0,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"fillPatternScale",["x","y"]),s.Factory.addGetterSetter(p,"fillPatternScaleX",1,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternScaleY",1,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"fillLinearGradientStartPoint",["x","y"]),s.Factory.addComponentsGetterSetter(p,"strokeLinearGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillLinearGradientStartPointX",0),s.Factory.addGetterSetter(p,"strokeLinearGradientStartPointX",0),s.Factory.addGetterSetter(p,"fillLinearGradientStartPointY",0),s.Factory.addGetterSetter(p,"strokeLinearGradientStartPointY",0),s.Factory.addComponentsGetterSetter(p,"fillLinearGradientEndPoint",["x","y"]),s.Factory.addComponentsGetterSetter(p,"strokeLinearGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillLinearGradientEndPointX",0),s.Factory.addGetterSetter(p,"strokeLinearGradientEndPointX",0),s.Factory.addGetterSetter(p,"fillLinearGradientEndPointY",0),s.Factory.addGetterSetter(p,"strokeLinearGradientEndPointY",0),s.Factory.addComponentsGetterSetter(p,"fillRadialGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillRadialGradientStartPointX",0),s.Factory.addGetterSetter(p,"fillRadialGradientStartPointY",0),s.Factory.addComponentsGetterSetter(p,"fillRadialGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillRadialGradientEndPointX",0),s.Factory.addGetterSetter(p,"fillRadialGradientEndPointY",0),s.Factory.addGetterSetter(p,"fillPatternRotation",0),s.Factory.addGetterSetter(p,"fillRule",void 0,(0,n.getStringValidator)()),s.Factory.backCompat(p,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(se)),se}function ne(){if(ee)return ie;ee=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.Layer=void 0;const t=Tt(),e=Kt(),i=Ht(),s=Ot(),r=Nt(),n=Rt(),o=re(),a=Ct(),h=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],l=h.length;let d=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){i.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!i.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(i.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(i.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),i.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let s=0;s<l;s++){const r=h[s],n=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),o=n.shape;if(o)return o;if(i=!!n.antialiased,!n.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,s=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,r=s[3];if(255===r){const e=t.Util._rgbToHex(s[0],s[1],s[2]),i=o.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,i){const s=this.getLayer(),r=t||s&&s.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,i),this._fire("draw",{node:this}),this}drawHit(t,i){const s=this.getLayer(),r=t||s&&s.hitCanvas;return s&&s.clearBeforeDraw()&&s.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return ie.Layer=d,d.prototype.nodeType="Layer",(0,a._registerNode)(d),s.Factory.addGetterSetter(d,"imageSmoothingEnabled",!0),s.Factory.addGetterSetter(d,"clearBeforeDraw",!0),s.Factory.addGetterSetter(d,"hitGraphEnabled",!0,(0,n.getBooleanValidator)()),ie}var oe,ae={};var he,le={};function de(){if(he)return le;he=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Group=void 0;const t=Tt(),e=Kt(),i=Ct();let s=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return le.Group=s,s.prototype.nodeType="Group",(0,i._registerNode)(s),le}var ce,ue={};function ge(){if(ce)return ue;ce=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Animation=void 0;const t=Ct(),e=Tt(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let s=class t{constructor(e,s){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(s)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let s=0;s<i;s++)if(e[s]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,s=i.length;for(let t=0;t<s;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let s=0;s<e.length;s++){const r=e[s],n=r.layers,o=r.func;r._updateFrameObject(i());const a=n.length;let h;if(h=!o||!1!==o.call(r,r.frame),h)for(let e=0;e<a;e++){const i=n[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return ue.Animation=s,s.animations=[],s.animIdCounter=0,s.animRunning=!1,ue}var fe,pe,me={};function _e(){return pe||(pe=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Ct(),i=Tt(),s=Ht(),r=Kt(),n=(Jt||(Jt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=Tt(),i=Ot(),s=Kt(),r=Ct(),n=Nt(),o=jt(),a=Ct(),h=Qt(),l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",f="mouseup",p="pointermove",m="pointerdown",_="pointerup",v="pointercancel",y="pointerout",w="pointerleave",x="pointerover",b="pointerenter",S="contextmenu",C="touchstart",P="touchend",A="touchmove",T="touchcancel",k="wheel",E=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[f,"_pointerup"],[l,"_pointerleave"],[C,"_pointerdown"],[A,"_pointermove"],[P,"_pointerup"],[T,"_pointercancel"],[d,"_pointerover"],[k,"_wheel"],[S,"_contextmenu"],[m,"_pointerdown"],[p,"_pointermove"],[_,"_pointerup"],[v,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],M={mouse:{[y]:"mouseout",[w]:l,[x]:d,[b]:c,[p]:u,[m]:g,[_]:f,[v]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[w]:"touchleave",[x]:"touchover",[b]:"touchenter",[p]:A,[m]:C,[_]:P,[v]:T,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[w]:w,[x]:x,[b]:b,[p]:p,[m]:m,[_]:_,[v]:v,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},F=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=F(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&M.pointer:"touch"===e?M.touch:"mouse"===e?M.mouse:void 0};function R(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class O extends s.Container{constructor(e){super(R(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{R(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),s="FastLayer"===t.getType();i||s||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e)}if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),s.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const s=t.stages.indexOf(this);return s>-1&&t.stages.splice(s,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new n.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,s=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),s.forEach((function(e){if(!e.isVisible())return;const s=e._toKonvaCanvas(t);i.drawImage(s._canvas,t.x,t.y,s.getWidth()/s.getPixelRatio(),s.getHeight()/s.getPixelRatio())})),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const s=e[i].getIntersection(t);if(s)return s}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const s=this.children.length;return s>5&&e.Util.warn("The stage has "+s+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&E.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const s=this._getTargetShape(i),n=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;s&&n?(s._fireAndBubble(e.pointerout,{evt:t}),s._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):n&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);let s=!1;this._changedPointerPositions.forEach((n=>{const a=this.getIntersection(n);if(o.DD.justDragged=!1,r.Konva["_"+i+"ListenClick"]=!0,!a||!a.isListening())return void(this[i+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[i+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:n.id}),s=!0;const h=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),s||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),i=F(t.type);if(!e)return;if(r.Konva.isDragging()&&o.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const s={};let n=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach((r=>{const o=h.getCapturedShape(r.id)||this.getIntersection(r),l=r.id,d={evt:t,pointerId:l},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...d},o),a._fireAndBubble(e.pointerleave,{...d},o)),o){if(s[o._id])return;s[o._id]=!0}o&&o.isListening()?(n=!0,c&&(o._fireAndBubble(e.pointerover,{...d},a),o._fireAndBubble(e.pointerenter,{...d},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...d})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),n||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const s=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"],a={};let l=!1;this._changedPointerPositions.forEach((d=>{const c=h.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),a[c._id])return;a[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let f=!1;r.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):o.DD.justDragged||(r.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){r.Konva["_"+i+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),c&&c.isListening()?(l=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),r.Konva["_"+i+"ListenClick"]&&s&&s===c&&(c._fireAndBubble(e.pointerclick,{...g}),f&&n&&n===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,r.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(k,{evt:t}):this._fire(k,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let s=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(s=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:s,y:r},this._pointerPositions=[{x:s,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:s,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new n.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new n.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=O,O.prototype.nodeType="Stage",(0,a._registerNode)(O),i.Factory.addGetterSetter(O,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(Zt)),Zt),o=ne(),a=function(){if(oe)return ae;oe=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.FastLayer=void 0;const t=Tt(),e=ne(),i=Ct();let s=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return ae.FastLayer=s,s.prototype.nodeType="FastLayer",(0,i._registerNode)(s),ae}(),h=de(),l=jt(),d=re(),c=ge(),u=(fe||(fe=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=Tt(),i=ge(),s=Ht(),r=Ct(),n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o=["fill","stroke","shadowColor"];let a=0;class h{constructor(t,e,i,s,r,n,o){this.prop=t,this.propFunc=e,this.begin=s,this._pos=s,this.duration=n,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(s){const o=this,d=s.node,c=d._id,u=s.easing||t.Easings.Linear,g=!!s.yoyo;let f,p;f=void 0===s.duration?.3:0===s.duration?.001:s.duration,this.node=d,this._id=a++;const m=d.getLayer()||(d instanceof r.Konva.Stage?d.getLayers():null);for(p in m||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){o.tween.onEnterFrame()}),m),this.tween=new h(p,(function(t){o._tweenFunc(t)}),u,0,1,1e3*f,g),this._addListeners(),l.attrs[c]||(l.attrs[c]={}),l.attrs[c][this._id]||(l.attrs[c][this._id]={}),l.tweens[c]||(l.tweens[c]={}),s)void 0===n[p]&&this._addAttr(p,s[p]);this.reset(),this.onFinish=s.onFinish,this.onReset=s.onReset,this.onUpdate=s.onUpdate}_addAttr(t,i){const s=this.node,r=s._id;let n,a,h,d,c;const u=l.tweens[r][t];u&&delete l.attrs[r][u][t];let g=s.getAttr(t);if(e.Util._isArray(i))if(n=[],a=Math.max(i.length,g.length),"points"===t&&i.length!==g.length&&(i.length>g.length?(d=g,g=e.Util._prepareArrayForTween(g,i,s.closed())):(h=i,i=e.Util._prepareArrayForTween(i,g,s.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)n.push(i[t]-g[t]);else{const s=e.Util.colorToRGBA(g[t]);c=e.Util.colorToRGBA(i[t]),g[t]=s,n.push({r:c.r-s.r,g:c.g-s.g,b:c.b-s.b,a:c.a-s.a})}else for(let t=0;t<a;t++)n.push(i[t]-g[t]);else-1!==o.indexOf(t)?(g=e.Util.colorToRGBA(g),c=e.Util.colorToRGBA(i),n={r:c.r-g.r,g:c.g-g.g,b:c.b-g.b,a:c.a-g.a}):n=i-g;l.attrs[r][this._id][t]={start:g,diff:n,end:i,trueEnd:h,trueStart:d},l.tweens[r][t]=this._id}_tweenFunc(t){const i=this.node,s=l.attrs[i._id][this._id];let r,n,a,h,d,c,u,g;for(r in s){if(n=s[r],a=n.start,h=n.diff,g=n.end,e.Util._isArray(a))if(d=[],u=Math.max(a.length,g.length),0===r.indexOf("fill"))for(c=0;c<u;c++)c%2==0?d.push((a[c]||0)+h[c]*t):d.push("rgba("+Math.round(a[c].r+h[c].r*t)+","+Math.round(a[c].g+h[c].g*t)+","+Math.round(a[c].b+h[c].b*t)+","+(a[c].a+h[c].a*t)+")");else for(c=0;c<u;c++)d.push((a[c]||0)+h[c]*t);else d=-1!==o.indexOf(r)?"rgba("+Math.round(a.r+h.r*t)+","+Math.round(a.g+h.g*t)+","+Math.round(a.b+h.b*t)+","+(a.a+h.a*t)+")":a+h*t;i.setAttr(r,d)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=l.tweens[t];this.pause();for(const e in i)delete l.tweens[t][e];delete l.attrs[t][e]}}t.Tween=l,l.attrs={},l.tweens={},s.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,s){const r=1.70158;return i*(t/=s)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,s){const r=1.70158;return i*((t=t/s-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,s){let r=1.70158;return(t/=s/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,s,r,n){let o=0;return 0===t?e:1==(t/=s)?e+i:(n||(n=.3*s),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)+e)},ElasticEaseOut(t,e,i,s,r,n){let o=0;return 0===t?e:1==(t/=s)?e+i:(n||(n=.3*s),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/n)+i+e)},ElasticEaseInOut(t,e,i,s,r,n){let o=0;return 0===t?e:2==(t/=s/2)?e+i:(n||(n=s*(.3*1.5)),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)*.5+i+e)},BounceEaseOut:(t,e,i,s)=>(t/=s)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,s,r)=>s-t.Easings.BounceEaseOut(r-e,0,s,r)+i,BounceEaseInOut:(e,i,s,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,s,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,s,r)+.5*s+i,EaseIn:(t,e,i,s)=>i*(t/=s)*t+e,EaseOut:(t,e,i,s)=>-i*(t/=s)*(t-2)+e,EaseInOut:(t,e,i,s)=>(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,s)=>i*(t/=s)*t*t*t*t+e,StrongEaseOut:(t,e,i,s)=>i*((t=t/s-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,s)=>(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,s)=>i*t/s+e}}(me)),me),g=Gt(),f=Nt();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:s.Node,Container:r.Container,Stage:n.Stage,stages:n.stages,Layer:o.Layer,FastLayer:a.FastLayer,Group:h.Group,DD:l.DD,Shape:d.Shape,shapes:d.shapes,Animation:c.Animation,Tween:u.Tween,Easings:u.Easings,Context:g.Context,Canvas:f.Canvas}),t.default=t.Konva}(bt)),bt}var ve,ye={};var we,xe={},be={};function Se(){if(we)return be;we=1,Object.defineProperty(be,"__esModule",{value:!0}),be.Line=void 0;const t=Ot(),e=Ct(),i=re(),s=Rt();function r(t,e,i,s,r,n,o){const a=Math.sqrt(Math.pow(i-t,2)+Math.pow(s-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(n-s,2)),l=o*a/(a+h),d=o*h/(a+h);return[i-l*(r-t),s-l*(n-e),i+d*(r-t),s+d*(n-e)]}function n(t,e){const i=t.length,s=[];for(let n=2;n<i-2;n+=2){const i=r(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e);isNaN(i[0])||(s.push(i[0]),s.push(i[1]),s.push(t[n]),s.push(t[n+1]),s.push(i[2]),s.push(i[3]))}return s}let o=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,i,s,r=this.points(),n=r.length,o=this.tension(),a=this.closed(),h=this.bezier();if(n){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==o&&n>4){for(e=this.getTensionPoints(),i=e.length,s=a?0:4,a||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);s<i-2;)t.bezierCurveTo(e[s++],e[s++],e[s++],e[s++],e[s++],e[s++]);a||t.quadraticCurveTo(e[i-2],e[i-1],r[n-2],r[n-1])}else if(h)for(s=2;s<n;)t.bezierCurveTo(r[s++],r[s++],r[s++],r[s++],r[s++],r[s++]);else for(s=2;s<n;s+=2)t.lineTo(r[s],r[s+1]);a?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():n(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),s=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),o=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=n(t,i);return[s[2],s[3]].concat(a).concat([o[0],o[1],t[e-2],t[e-1],o[2],o[3],s[0],s[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,s=t[0],r=t[0],n=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],s=Math.min(s,e),r=Math.max(r,e),n=Math.min(n,i),o=Math.max(o,i);return{x:s,y:n,width:r-s,height:o-n}}};return be.Line=o,o.prototype.className="Line",o.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(o),t.Factory.addGetterSetter(o,"closed",!1),t.Factory.addGetterSetter(o,"bezier",!1),t.Factory.addGetterSetter(o,"tension",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(o,"points",[],(0,s.getNumberArrayValidator)()),be}var Ce,Pe,Ae,Te={},ke={};function Ee(){if(Pe)return Te;Pe=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Path=void 0;const t=Ot(),e=re(),i=Ct(),s=(Ce||(Ce=1,function(t){function e(t,e,s){const r=i(1,s,t),n=i(1,s,e),o=r*r+n*n;return Math.sqrt(o)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,s,r)=>{let n,o;const a=r/2;n=0;for(let r=0;r<20;r++)o=a*t.tValues[20][r]+a,n+=t.cValues[20][r]*e(i,s,o);return a*n},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const s=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],n=2*t[1]-2*t[0],o=2*e[1]-2*e[0],a=4*(s*s+r*r),h=4*(s*n+r*o),l=n*n+o*o;if(0===a)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*a),c=i+d,u=l/a-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,f=d*d+u>0?Math.sqrt(d*d+u):0,p=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+f))):0;return Math.sqrt(a)/2*(c*g-d*f+p)};const i=(e,s,r)=>{const n=r.length-1;let o,a;if(0===n)return 0;if(0===e){a=0;for(let e=0;e<=n;e++)a+=t.binomialCoefficients[n][e]*Math.pow(1-s,n-e)*Math.pow(s,e)*r[e];return a}o=new Array(n);for(let t=0;t<n;t++)o[t]=n*(r[t+1]-r[t]);return i(e-1,s,o)};t.t2length=(t,e,i)=>{let s=1,r=t/e,n=(t-i(r))/e,o=0;for(;s>.001;){const a=i(r+n),h=Math.abs(t-a)/e;if(h<s)s=h,r+=n;else{const o=i(r-n),a=Math.abs(t-o)/e;a<s?(s=a,r-=n):n/=2}if(o++,o>500)break}return r}}(ke)),ke);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let f=0;f<e.length;f++){const p=e[f].command,m=e[f].points;switch(p){case"L":t.lineTo(m[0],m[1]);break;case"M":t.moveTo(m[0],m[1]);break;case"C":t.bezierCurveTo(m[0],m[1],m[2],m[3],m[4],m[5]);break;case"Q":t.quadraticCurveTo(m[0],m[1],m[2],m[3]);break;case"A":var s=m[0],r=m[1],n=m[2],o=m[3],a=m[4],h=m[5],l=m[6],d=m[7],c=n>o?n:o,u=n>o?1:n/o,g=n>o?o/n:1;t.translate(s,r),t.rotate(l),t.scale(u,g),t.arc(0,0,c,a,a+h,1-d),t.scale(1/u,1/g),t.rotate(-l),t.translate(-s,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(i){if("A"===i.command){const s=i.points[4],r=i.points[5],n=i.points[4]+r;let o=Math.PI/180;if(Math.abs(s-n)<o&&(o=Math.abs(s-n)),r<0)for(let r=s-o;r>n;r-=o){const s=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(s.x,s.y)}else for(let r=s+o;r<n;r+=o){const s=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(s.x,s.y)}}else if("C"===i.command)for(let s=0;s<=1;s+=.01){const r=t.getPointOnCubicBezier(s,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(r.x,r.y)}else e=e.concat(i.points)}));let i,s,r=e[0],n=e[0],o=e[1],a=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],s=e[2*t+1],isNaN(i)||(r=Math.min(r,i),n=Math.max(n,i)),isNaN(s)||(o=Math.min(o,s),a=Math.max(a,s));return{x:r,y:o,width:n-r,height:a-o}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,s){return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let r,n=0,o=i.length;if(!o)return null;for(;n<o&&e>i[n].pathLength;)e-=i[n].pathLength,++n;if(n===o)return r=i[n-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=i[n].points.slice(0,2),{x:r[0],y:r[1]};const a=i[n],h=a.points;switch(a.command){case"L":return t.getPointOnLine(e,a.start.x,a.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,s.t2length)(e,t.getPathLength(i),(t=>(0,s.getCubicArcLength)([a.start.x,h[0],h[2],h[4]],[a.start.y,h[1],h[3],h[5]],t))),a.start.x,a.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,s.t2length)(e,t.getPathLength(i),(t=>(0,s.getQuadraticArcLength)([a.start.x,h[0],h[2]],[a.start.y,h[1],h[3]],t))),a.start.x,a.start.y,h[0],h[1],h[2],h[3]);case"A":var l=h[0],d=h[1],c=h[2],u=h[3],g=h[4],f=h[5],p=h[6];return g+=f*e/a.pathLength,t.getPointOnEllipticalArc(l,d,c,u,g,p)}return null}static getPointOnLine(t,e,i,s,r,n,o){n=null!=n?n:e,o=null!=o?o:i;const a=this.getLineLength(e,i,s,r);if(a<1e-10)return{x:e,y:i};if(s===e)return{x:n,y:o+(r>i?t:-t)};const h=(r-i)/(s-e),l=Math.sqrt(t*t/(1+h*h))*(s<e?-1:1),d=h*l;if(Math.abs(o-i-h*(n-e))<1e-10)return{x:n+l,y:o+d};const c=((n-e)*(s-e)+(o-i)*(r-i))/(a*a),u=e+c*(s-e),g=i+c*(r-i),f=this.getLineLength(n,o,u,g),p=Math.sqrt(t*t-f*f),m=Math.sqrt(p*p/(1+h*h))*(s<e?-1:1);return{x:u+m,y:g+h*m}}static getPointOnCubicBezier(t,e,i,s,r,n,o,a,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:a*l(t)+n*d(t)+s*c(t)+e*u(t),y:h*l(t)+o*d(t)+r*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,s,r,n,o){function a(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:n*a(t)+s*h(t)+e*l(t),y:o*a(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,s,r,n){const o=Math.cos(n),a=Math.sin(n),h=i*Math.cos(r),l=s*Math.sin(r);return{x:t+(h*o-l*a),y:e+(h*a+l*o)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var s=0;s<i.length;s++)e=e.replace(new RegExp(i[s],"g"),"|"+i[s]);const r=e.split("|"),n=[],o=[];let a=0,h=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let d;for(s=1;s<r.length;s++){let t=r[s],e=t.charAt(0);for(t=t.slice(1),o.length=0;d=l.exec(t);)o.push(d[0]);const i=[];for(let t=0,e=o.length;t<e;t++){if("00"===o[t]){i.push(0,0);continue}const e=parseFloat(o[t]);isNaN(e)?i.push(0):i.push(e)}for(;i.length>0&&!isNaN(i[0]);){let t="",s=[];const r=a,o=h;var c,u,g,f,p,m,_,v,y,w;switch(e){case"l":a+=i.shift(),h+=i.shift(),t="L",s.push(a,h);break;case"L":a=i.shift(),h=i.shift(),s.push(a,h);break;case"m":var x=i.shift(),b=i.shift();if(a+=x,h+=b,t="M",n.length>2&&"z"===n[n.length-1].command)for(let t=n.length-2;t>=0;t--)if("M"===n[t].command){a=n[t].points[0]+x,h=n[t].points[1]+b;break}s.push(a,h),e="l";break;case"M":a=i.shift(),h=i.shift(),t="M",s.push(a,h),e="L";break;case"h":a+=i.shift(),t="L",s.push(a,h);break;case"H":a=i.shift(),t="L",s.push(a,h);break;case"v":h+=i.shift(),t="L",s.push(a,h);break;case"V":h=i.shift(),t="L",s.push(a,h);break;case"C":s.push(i.shift(),i.shift(),i.shift(),i.shift()),a=i.shift(),h=i.shift(),s.push(a,h);break;case"c":s.push(a+i.shift(),h+i.shift(),a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="C",s.push(a,h);break;case"S":u=a,g=h,"C"===(c=n[n.length-1]).command&&(u=a+(a-c.points[2]),g=h+(h-c.points[3])),s.push(u,g,i.shift(),i.shift()),a=i.shift(),h=i.shift(),t="C",s.push(a,h);break;case"s":u=a,g=h,"C"===(c=n[n.length-1]).command&&(u=a+(a-c.points[2]),g=h+(h-c.points[3])),s.push(u,g,a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="C",s.push(a,h);break;case"Q":s.push(i.shift(),i.shift()),a=i.shift(),h=i.shift(),s.push(a,h);break;case"q":s.push(a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="Q",s.push(a,h);break;case"T":u=a,g=h,"Q"===(c=n[n.length-1]).command&&(u=a+(a-c.points[0]),g=h+(h-c.points[1])),a=i.shift(),h=i.shift(),t="Q",s.push(u,g,a,h);break;case"t":u=a,g=h,"Q"===(c=n[n.length-1]).command&&(u=a+(a-c.points[0]),g=h+(h-c.points[1])),a+=i.shift(),h+=i.shift(),t="Q",s.push(u,g,a,h);break;case"A":f=i.shift(),p=i.shift(),m=i.shift(),_=i.shift(),v=i.shift(),y=a,w=h,a=i.shift(),h=i.shift(),t="A",s=this.convertEndpointToCenterParameterization(y,w,a,h,_,v,f,p,m);break;case"a":f=i.shift(),p=i.shift(),m=i.shift(),_=i.shift(),v=i.shift(),y=a,w=h,a+=i.shift(),h+=i.shift(),t="A",s=this.convertEndpointToCenterParameterization(y,w,a,h,_,v,f,p,m)}n.push({command:t||e,points:s,start:{x:r,y:o},pathLength:this.calcLength(r,o,t||e,s)})}"z"!==e&&"Z"!==e||n.push({command:"z",points:[],start:void 0,pathLength:0})}return n}static calcLength(e,i,r,n){let o,a,h,l;const d=t;switch(r){case"L":return d.getLineLength(e,i,n[0],n[1]);case"C":return(0,s.getCubicArcLength)([e,n[0],n[2],n[4]],[i,n[1],n[3],n[5]],1);case"Q":return(0,s.getQuadraticArcLength)([e,n[0],n[2]],[i,n[1],n[3]],1);case"A":o=0;var c=n[4],u=n[5],g=n[4]+u,f=Math.PI/180;if(Math.abs(c-g)<f&&(f=Math.abs(c-g)),a=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),u<0)for(l=c-f;l>g;l-=f)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;else for(l=c+f;l<g;l+=f)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;return h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],g,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(t,e,i,s,r,n,o,a,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-s)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-s)/2,u=d*d/(o*o)+c*c/(a*a);u>1&&(o*=Math.sqrt(u),a*=Math.sqrt(u));let g=Math.sqrt((o*o*(a*a)-o*o*(c*c)-a*a*(d*d))/(o*o*(c*c)+a*a*(d*d)));r===n&&(g*=-1),isNaN(g)&&(g=0);const f=g*o*c/a,p=g*-a*d/o,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+s)/2+Math.sin(l)*f+Math.cos(l)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},x=w([1,0],[(d-f)/o,(c-p)/a]),b=[(d-f)/o,(c-p)/a],S=[(-1*d-f)/o,(-1*c-p)/a];let C=w(b,S);return y(b,S)<=-1&&(C=Math.PI),y(b,S)>=1&&(C=0),0===n&&C>0&&(C-=2*Math.PI),1===n&&C<0&&(C+=2*Math.PI),[m,_,o,a,x,C,l,n]}};return Te.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"data"),Te}var Me,Fe={};var Ie,Re={};var Oe,De={};var Le,Ve={};var ze,Ge={};function Ne(){if(ze)return Ge;ze=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.Rect=void 0;const t=Ot(),e=re(),i=Ct(),s=Tt(),r=Rt();let n=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?s.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}};return Ge.Rect=n,n.prototype.className="Rect",(0,i._registerNode)(n),t.Factory.addGetterSetter(n,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),Ge}var We,Ue={};var Be,je={};var He,Ye={};var Xe,Ke={};var qe,Je={};function Ze(){if(qe)return Je;qe=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.Text=void 0,Je.stringToArray=o;const t=Tt(),e=Ot(),i=re(),s=Ct(),r=Rt(),n=Ct();function o(t){return[...t].reduce(((t,e,i,s)=>{if(/\p{Emoji}/u.test(e)){const r=s[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),s[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(s[i+1]||""))?t.push(e+s[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t}),[])}const a="auto",h="inherit",l="justify",d="left",c="middle",u="normal",g=" ",f="none",p=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],m=p.length;let _;function v(){return _||(_=t.Util.createCanvasElement().getContext("2d"),_)}let y=class extends i.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<m;t++)this.on(p[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let r,n=this.padding(),a=this.fontSize(),u=this.lineHeight()*a,g=this.verticalAlign(),f=this.direction(),p=0,m=this.align(),_=this.getWidth(),v=this.letterSpacing(),y=this.fill(),w=this.textDecoration(),x=-1!==w.indexOf("underline"),b=-1!==w.indexOf("line-through");f=f===h?t.direction:f;let S=u/2,C=c;if(s.Konva._fixTextRendering){const t=this.measureSize("M");C="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var P=0,A=0;for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",C),t.setAttr("textAlign",d),g===c?p=(this.getHeight()-i*u-2*n)/2:"bottom"===g&&(p=this.getHeight()-i*u-2*n),t.translate(n,p+n),r=0;r<i;r++){P=0,A=0;var T,k,E=e[r],M=E.text,F=E.width,I=E.lastInParagraph;if(t.save(),"right"===m?P+=_-F-2*n:"center"===m&&(P+=(_-F-2*n)/2),x){t.save(),t.beginPath();const e=P,i=S+A+(s.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i),T=M.split(" ").length-1,k=m!==l||I?F:_-2*n,t.lineTo(e+Math.round(k),i),t.lineWidth=a/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=s.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(P,S+A+e),T=M.split(" ").length-1,k=m!==l||I?F:_-2*n,t.lineTo(P+Math.round(k),S+A+e),t.lineWidth=a/15;const i=this._getLinearGradient();t.strokeStyle=i||y,t.stroke(),t.restore()}if("rtl"===f||0===v&&m!==l)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=P,this._partialTextY=S+A,this._partialText=M,t.fillStrokeShape(this);else{T=M.split(" ").length-1;const e=o(M);for(let i=0;i<e.length;i++){const s=e[i];" "!==s||I||m!==l||(P+=(_-2*n-F)/T),this._partialTextX=P,this._partialTextY=S+A,this._partialText=s,t.fillStrokeShape(this),P+=this.measureSize(s).width+v}}t.restore(),i>1&&(S+=u)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===a||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===a||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,s,r,n,o,a,h,l,d,c;let u,g=v(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(s=u.actualBoundingBoxLeft)&&void 0!==s?s:-7.421875*p,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*p,alphabeticBaseline:null!==(n=u.alphabeticBaseline)&&void 0!==n?n:0,emHeightAscent:null!==(o=u.emHeightAscent)&&void 0!==o?o:100*p,emHeightDescent:null!==(a=u.emHeightDescent)&&void 0!==a?a:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+g+this.fontVariant()+g+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===l&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return v().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,s=this.lineHeight()*e,r=this.attrs.width,n=this.attrs.height,h=r!==a&&void 0!==r,l=n!==a&&void 0!==n,d=this.padding(),c=r-2*d,u=n-2*d,p=0,m=this.wrap(),_="char"!==m&&m!==f,y=this.ellipsis();this.textArr=[],v().font=this._getContextFont();const w=y?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let n=t[e],a=this._getTextWidth(n);if(h&&a>c)for(;n.length>0;){let t=0,e=o(n).length,r="",h=0;for(;t<e;){const i=t+e>>>1,s=o(n).slice(0,i+1).join(""),a=this._getTextWidth(s)+w;a<=c?(t=i+1,r=s,h=a):e=i}if(!r)break;if(_){const e=o(n),i=o(r),s=e[i.length];let a;if((s===g||"-"===s)&&h<=c)a=i.length;else{const t=i.lastIndexOf(g),e=i.lastIndexOf("-");a=Math.max(t,e)+1}a>0&&(t=a,r=e.slice(0,t).join(""),h=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,h),p+=s;if(this._shouldHandleEllipsis(p)){this._tryToAddEllipsisToLastLine();break}if(n=o(n).slice(t).join("").trimLeft(),n.length>0&&(a=this._getTextWidth(n),a<=c)){this._addTextLine(n),p+=s,i=Math.max(i,a);break}}else this._addTextLine(n),p+=s,i=Math.max(i,a),this._shouldHandleEllipsis(p)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&p+s>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,s=this.attrs.height,r=s!==a&&void 0!==s,n=s-2*this.padding();return!(this.wrap()!==f)||r&&t+i>n}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==a&&void 0!==t,i=t-2*this.padding(),s=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&s){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}};return Je.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,n._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",h),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",d),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),Je}var $e,Qe={};var ti,ei={};function ii(){if(ti)return ei;ti=1,Object.defineProperty(ei,"__esModule",{value:!0}),ei.Transformer=void 0;const t=Tt(),e=Ot(),i=Ht(),s=re(),r=Ne(),n=de(),o=Ct(),a=Rt(),h=Ct(),l="tr-konva",d=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${l}`)).join(" "),c="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],g={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},f="ontouchstart"in o.Konva._global;const p=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function m(t,e,i){const s=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:s,y:r}}function _(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return m(t,e,i)}let v=0,y=class extends n.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(d,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return l+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(u.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const s=t.getAbsolutePosition(),r=s.x-e.x,n=s.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const s=e.getAbsolutePosition();e.setAbsolutePosition({x:s.x+r,y:s.y+n}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(c),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(c,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const s=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),n=t.getAbsolutePosition(i),a=s.x*r.x-t.offsetX()*r.x,h=s.y*r.y-t.offsetY()*r.y,l=(o.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return m({x:n.x+a*Math.cos(l)+h*Math.sin(-l),y:n.y+h*Math.cos(l)+a*Math.sin(l),width:s.width*r.x,height:s.height*r.y,rotation:l},-o.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=t.getAbsoluteTransform();s.forEach((function(t){const i=r.point(t);e.push(i)}))}));const i=new t.Transform;i.rotate(-o.Konva.getAngle(this.rotation()));let s=1/0,r=1/0,n=-1/0,a=-1/0;e.forEach((function(t){const e=i.point(t);void 0===s&&(s=n=e.x,r=a=e.y),s=Math.min(s,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y)})),i.invert();const h=i.point({x:s,y:r});return{x:h.x,y:h.y,width:n-s,height:a-r,rotation:o.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),p.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const i=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:f?10:"auto"}),s=this;i.on("mousedown touchstart",(function(t){s._handleMouseDown(t)})),i.on("dragstart",(t=>{i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(t=>{t.cancelBubble=!0})),i.on("mouseenter",(()=>{const s=o.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),n=function(e,i,s){if("rotater"===e)return s;i+=t.Util.degToRad(g[e]||0);const r=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,s,r);i.getStage().content&&(i.getStage().content.style.cursor=n),this._cursorChange=!0})),i.on("mouseout",(()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(i)}_createBack(){const e=new s.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const s=i.getParent(),r=s.padding();e.beginPath(),e.rect(-r,-r,i.width()+2*r,i.height()+2*r),e.moveTo(i.width()/2,-r),s.rotateEnabled()&&s.rotateLineVisible()&&e.lineTo(i.width()/2,-s.rotateAnchorOffset()*t.Util._sign(i.height())-r),e.fillStrokeShape(i)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,s=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(s,2));this.sin=Math.abs(s/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const n=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-n.x,y:o.y-n.y},v++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,i,s;const r=this.findOne("."+this._movingAnchorName),n=r.getStage();n.setPointersPositions(t);const a=n.getPointerPosition();let h={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const d=r.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const s=this._getNodeRect();e=r.x()-s.width/2,i=-r.y()+s.height/2;let n=Math.atan2(-i,e)+Math.PI/2;s.height<0&&(n-=Math.PI);const a=o.Konva.getAngle(this.rotation())+n,h=o.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let s=e;for(let r=0;r<t.length;r++){const n=o.Konva.getAngle(t[r]),a=Math.abs(n-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(s=n)}return s}(this.rotationSnaps(),a,h),d=_(s,l-s.rotation);return void this._fitNodesInto(d,t)}const c=this.shiftBehavior();let u;u="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};s=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(f.y-r.y(),2));var p=this.findOne(".top-left").x()>f.x?-1:1,m=this.findOne(".top-left").y()>f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".top-left").x(f.x-e),this.findOne(".top-left").y(f.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(f.y-r.y(),2));p=this.findOne(".top-right").x()<f.x?-1:1,m=this.findOne(".top-right").y()>f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".top-right").x(f.x+e),this.findOne(".top-right").y(f.y-i)}var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(r.y()-f.y,2));p=f.x<r.x()?-1:1,m=r.y()<f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,r.x(f.x-e),r.y(f.y+i)}v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};s=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(r.y()-f.y,2));p=this.findOne(".bottom-right").x()<f.x?-1:1,m=this.findOne(".bottom-right").y()<f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".bottom-right").x(f.x+e),this.findOne(".bottom-right").y(f.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),s=t.y(),r=this.getWidth()-e.x(),n=this.getHeight()-e.y();e.move({x:-i,y:-s}),t.move({x:r,y:n})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,i=y.y;const w=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),x=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:w,height:x,rotation:o.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();v--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,i){const s=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(o.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(s,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const n=1e7,a=new t.Transform;a.translate(s.x,s.y),a.rotate(s.rotation),a.scale(s.width/n,s.height/n);const h=new t.Transform,l=e.width/n,d=e.height/n;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,d));const c=h.multiply(a.invert());this._nodes.forEach((e=>{var i;const s=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const n=new t.Transform;n.multiply(s.copy().invert()).multiply(c).multiply(s).multiply(r);const o=n.decompose();e.setAttrs(o),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const s=i.width,r=i.height,n=this.enabledAnchors(),o=this.resizeEnabled(),a=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach((t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+a,offsetY:h/2+a,visible:o&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:s/2,y:0,offsetY:h/2+a,visible:o&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:s,y:0,offsetX:h/2-a,offsetY:h/2+a,visible:o&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+a,visible:o&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:s,y:r/2,offsetX:h/2-a,visible:o&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:s/2,y:r,offsetY:h/2-a,visible:o&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:s,y:r,offsetX:h/2-a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:s/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:s,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const d=this.anchorStyleFunc();d&&l.forEach((t=>{d(t)})),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),n.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return ei.Transformer=y,y.isTransforming=()=>v>0,y.prototype.className="Transformer",(0,h._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",p,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===p.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+p.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,a.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),ei}var si,ri={};var ni,oi={};function ai(){if(ni)return oi;ni=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.Blur=void 0;const t=Ot(),e=Ht(),i=Rt();function s(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],n=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];return oi.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,o=t.width,a=t.height;let h,l,d,c,u,g,f,p,m,_,v,y,w,x,b,S,C,P,A,T,k,E,M,F;const I=e+e+1,R=o-1,O=a-1,D=e+1,L=D*(D+1)/2,V=new s,z=r[e],G=n[e];let N=null,W=V,U=null,B=null;for(d=1;d<I;d++)W=W.next=new s,d===D&&(N=W);for(W.next=V,f=g=0,l=0;l<a;l++){for(S=C=P=A=p=m=_=v=0,y=D*(T=i[g]),w=D*(k=i[g+1]),x=D*(E=i[g+2]),b=D*(M=i[g+3]),p+=L*T,m+=L*k,_+=L*E,v+=L*M,W=V,d=0;d<D;d++)W.r=T,W.g=k,W.b=E,W.a=M,W=W.next;for(d=1;d<D;d++)c=g+((R<d?R:d)<<2),p+=(W.r=T=i[c])*(F=D-d),m+=(W.g=k=i[c+1])*F,_+=(W.b=E=i[c+2])*F,v+=(W.a=M=i[c+3])*F,S+=T,C+=k,P+=E,A+=M,W=W.next;for(U=V,B=N,h=0;h<o;h++)i[g+3]=M=v*z>>G,0!==M?(M=255/M,i[g]=(p*z>>G)*M,i[g+1]=(m*z>>G)*M,i[g+2]=(_*z>>G)*M):i[g]=i[g+1]=i[g+2]=0,p-=y,m-=w,_-=x,v-=b,y-=U.r,w-=U.g,x-=U.b,b-=U.a,c=f+((c=h+e+1)<R?c:R)<<2,S+=U.r=i[c],C+=U.g=i[c+1],P+=U.b=i[c+2],A+=U.a=i[c+3],p+=S,m+=C,_+=P,v+=A,U=U.next,y+=T=B.r,w+=k=B.g,x+=E=B.b,b+=M=B.a,S-=T,C-=k,P-=E,A-=M,B=B.next,g+=4;f+=o}for(h=0;h<o;h++){for(C=P=A=S=m=_=v=p=0,g=h<<2,y=D*(T=i[g]),w=D*(k=i[g+1]),x=D*(E=i[g+2]),b=D*(M=i[g+3]),p+=L*T,m+=L*k,_+=L*E,v+=L*M,W=V,d=0;d<D;d++)W.r=T,W.g=k,W.b=E,W.a=M,W=W.next;for(u=o,d=1;d<=e;d++)g=u+h<<2,p+=(W.r=T=i[g])*(F=D-d),m+=(W.g=k=i[g+1])*F,_+=(W.b=E=i[g+2])*F,v+=(W.a=M=i[g+3])*F,S+=T,C+=k,P+=E,A+=M,W=W.next,d<O&&(u+=o);for(g=h,U=V,B=N,l=0;l<a;l++)c=g<<2,i[c+3]=M=v*z>>G,M>0?(M=255/M,i[c]=(p*z>>G)*M,i[c+1]=(m*z>>G)*M,i[c+2]=(_*z>>G)*M):i[c]=i[c+1]=i[c+2]=0,p-=y,m-=w,_-=x,v-=b,y-=U.r,w-=U.g,x-=U.b,b-=U.a,c=h+((c=l+D)<O?c:O)*o<<2,p+=S+=U.r=i[c],m+=C+=U.g=i[c+1],_+=P+=U.b=i[c+2],v+=A+=U.a=i[c+3],U=U.next,y+=T=B.r,w+=k=B.g,x+=E=B.b,b+=M=B.a,S-=T,C-=k,P-=E,A-=M,B=B.next,g+=o}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),oi}var hi,li={};var di,ci={};var ui,gi={};var fi,pi={};var mi,_i={};var vi,yi={};var wi,xi={};var bi,Si={};var Ci,Pi={};function Ai(){if(Ci)return Pi;Ci=1,Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.Kaleidoscope=void 0;const t=Ot(),e=Ht(),i=Tt(),s=Rt();return Pi.Kaleidoscope=function(t){const e=t.width,s=t.height;let r,n,o,a,h,l,d,c,u,g,f=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(p%360)/360);if(f<1)return;const _=i.Util.createCanvasElement();_.width=e,_.height=s;const v=_.getContext("2d").getImageData(0,0,e,s);i.Util.releaseCanvas(_),function(t,e,i){const s=t.data,r=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n,p=360/f*Math.PI/180;for(let t=0;t<f;t+=1){const e=Math.sin(t*p),i=Math.cos(t*p);for(let o=0;o<g;o+=1){d=Math.floor(a+l*o/g*i),c=Math.floor(h+l*o/g*e);let u=4*(c*n+d);const f=s[u+0],p=s[u+1],m=s[u+2],_=s[u+3];u=4*(t+o*n),r[u+0]=f,r[u+1]=p,r[u+2]=m,r[u+3]=_}}}(t,v,{polarCenterX:e/2,polarCenterY:s/2});let y=e/Math.pow(2,f);for(;y<=8;)y*=2,f-=1;y=Math.ceil(y);let w=y,x=0,b=w,S=1;for(m+y>e&&(x=w,b=0,S=-1),n=0;n<s;n+=1)for(r=x;r!==b;r+=S)o=Math.round(r+m)%e,u=4*(e*n+o),h=v.data[u+0],l=v.data[u+1],d=v.data[u+2],c=v.data[u+3],g=4*(e*n+r),v.data[g+0]=h,v.data[g+1]=l,v.data[g+2]=d,v.data[g+3]=c;for(n=0;n<s;n+=1)for(w=Math.floor(y),a=0;a<f;a+=1){for(r=0;r<w+1;r+=1)u=4*(e*n+r),h=v.data[u+0],l=v.data[u+1],d=v.data[u+2],c=v.data[u+3],g=4*(e*n+2*w-r-1),v.data[g+0]=h,v.data[g+1]=l,v.data[g+2]=d,v.data[g+3]=c;w*=2}!function(t,e,i){const s=t.data,r=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n;let p,m;for(d=0;d<n;d+=1)for(c=0;c<o;c+=1){const t=d-a,e=c-h,i=Math.sqrt(t*t+e*e)*g/l;let o=(180*Math.atan2(e,t)/Math.PI+360+0)%360;o=o*f/360,p=Math.floor(o),m=Math.floor(i);let u=4*(m*n+p);const _=s[u+0],v=s[u+1],y=s[u+2],w=s[u+3];u=4*(c*n+d),r[u+0]=_,r[u+1]=v,r[u+2]=y,r[u+3]=w}}(v,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),Pi}var Ti,ki={};function Ei(){if(Ti)return ki;Ti=1,Object.defineProperty(ki,"__esModule",{value:!0}),ki.Mask=void 0;const t=Ot(),e=Ht(),i=Rt();function s(t,e,i){let s=4*(i*t.width+e);const r=[];return r.push(t.data[s++],t.data[s++],t.data[s++],t.data[s++]),r}function r(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return ki.Mask=function(t){let e=function(t,e){const i=s(t,0,0),n=s(t,t.width-1,0),o=s(t,0,t.height-1),a=s(t,t.width-1,t.height-1),h=e||10;if(r(i,n)<h&&r(n,a)<h&&r(a,o)<h&&r(o,i)<h){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,a,o]),s=[];for(let i=0;i<t.width*t.height;i++){const n=r(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);s[i]=n<h?0:255}return s}}(t,this.threshold());return e&&(e=function(t,e,i){const s=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=2040===d?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const s=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=d>=1020?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const s=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=d}return o}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ki}var Mi,Fi={};var Ii,Ri={};var Oi,Di={};var Li,Vi={};var zi,Gi={};var Ni,Wi={};var Ui,Bi={};var ji,Hi,Yi={};function Xi(){if(Hi)return xt;Hi=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.Konva=void 0;const t=_e(),e=function(){if(ve)return ye;ve=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.Arc=void 0;const t=Ot(),e=re(),i=Ct(),s=Rt(),r=Ct();let n=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),s=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,s),t.arc(0,0,this.innerRadius(),e,0,!s),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),s=this.clockwise(),r=i.Konva.getAngle(s?360-this.angle():this.angle()),n=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),h=n*(n>0?t:e),l=o*(o>0?t:e),d=a*(a>0?e:t);return{x:h,y:s?-1*d:l,width:1*e-h,height:d-l}}};return ye.Arc=n,n.prototype._centroid=!0,n.prototype.className="Arc",n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1,(0,s.getBooleanValidator)()),ye}(),i=function(){if(Ae)return xe;Ae=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.Arrow=void 0;const t=Ot(),e=Se(),i=Rt(),s=Ct(),r=Ee();let n=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let s=i;const n=0!==this.tension()&&i.length>4;n&&(s=this.getTensionPoints());const o=this.pointerLength(),a=i.length;let h,l;if(n){const t=[s[s.length-4],s[s.length-3],s[s.length-2],s[s.length-1],i[a-2],i[a-1]],e=r.Path.calcLength(s[s.length-4],s[s.length-3],"C",t),n=r.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[a-2]-n.x,l=i[a-1]-n.y}else h=i[a-2]-i[a-4],l=i[a-1]-i[a-3];const d=(Math.atan2(l,h)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(d),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),n?(h=(s[0]+s[2])/2-i[0],l=(s[1]+s[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}};return xe.Arrow=n,n.prototype.className="Arrow",(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerAtBeginning",!1),t.Factory.addGetterSetter(n,"pointerAtEnding",!0),xe}(),s=function(){if(Me)return Fe;Me=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.Circle=void 0;const t=Ot(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}};return Fe.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),Fe}(),r=function(){if(Ie)return Re;Ie=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.Ellipse=void 0;const t=Ot(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}};return Re.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,s._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,i.getNumberValidator)()),Re}(),n=function(){if(Oe)return De;Oe=1,Object.defineProperty(De,"__esModule",{value:!0}),De.Image=void 0;const t=Tt(),e=Ot(),i=re(),s=Ct(),r=Rt();class n extends i.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const i=this.getWidth(),s=this.getHeight(),r=this.cornerRadius(),n=this.attrs.image;let o;if(n){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;o=t&&e?[n,this.cropX(),this.cropY(),t,e,0,0,i,s]:[n,0,0,i,s]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,s,r):e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)),n&&(r&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){const i=this.width(),s=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,s,r):e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,s=null){const r=t.Util.createImageElement();r.onload=function(){const t=new n({image:r});i(t)},r.onerror=s,r.crossOrigin="Anonymous",r.src=e}}return De.Image=n,n.prototype.className="Image",(0,s._registerNode)(n),e.Factory.addGetterSetter(n,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(n,"image"),e.Factory.addComponentsGetterSetter(n,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(n,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropHeight",0,(0,r.getNumberValidator)()),De}(),o=function(){if(Le)return Ve;Le=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Tag=Ve.Label=void 0;const t=Ot(),e=re(),i=de(),s=Rt(),r=Ct(),n=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],o="up",a="right",h="down",l="left",d=n.length;let c=class extends i.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const s=function(){i._sync()};for(e=0;e<d;e++)t.on(n[e]+"Change.konva",s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,s,r,n,d,c=this.getText(),u=this.getTag();if(c&&u){switch(t=c.width(),e=c.height(),i=u.pointerDirection(),s=u.pointerWidth(),d=u.pointerHeight(),r=0,n=0,i){case o:r=t/2,n=-1*d;break;case a:r=t+s,n=e/2;break;case h:r=t/2,n=e+d;break;case l:r=-1*s,n=e/2}u.setAttrs({x:-1*r,y:-1*n,width:t,height:e}),c.setAttrs({x:-1*r,y:-1*n})}}};Ve.Label=c,c.prototype.className="Label",(0,r._registerNode)(c);class u extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),s=this.pointerDirection(),r=this.pointerWidth(),n=this.pointerHeight(),d=this.cornerRadius();let c=0,u=0,g=0,f=0;"number"==typeof d?c=u=g=f=Math.min(d,e/2,i/2):(c=Math.min(d[0]||0,e/2,i/2),u=Math.min(d[1]||0,e/2,i/2),f=Math.min(d[2]||0,e/2,i/2),g=Math.min(d[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(c,0),s===o&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*n),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),s===a&&(t.lineTo(e,(i-n)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+n)/2)),t.lineTo(e,i-f),t.arc(e-f,i-f,f,0,Math.PI/2,!1),s===h&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+n),t.lineTo((e-r)/2,i)),t.lineTo(g,i),t.arc(g,i-g,g,Math.PI/2,Math.PI,!1),s===l&&(t.lineTo(0,(i+n)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-n)/2)),t.lineTo(0,c),t.arc(c,c,c,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),s=this.pointerHeight(),r=this.pointerDirection(),n=this.width(),d=this.height();return r===o?(e-=s,d+=s):r===h?d+=s:r===l?(t-=1.5*i,n+=i):r===a&&(n+=1.5*i),{x:t,y:e,width:n,height:d}}}return Ve.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),Ve}(),a=Se(),h=Ee(),l=Ne(),d=function(){if(We)return Ue;We=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.RegularPolygon=void 0;const t=Ot(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let s=0;s<t;s++)i.push({x:e*Math.sin(2*s*Math.PI/t),y:-1*e*Math.cos(2*s*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,s=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),s=Math.min(s,t.y),r=Math.max(r,t.y)})),{x:e,y:s,width:i-e,height:r-s}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Ue.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,i.getNumberValidator)()),Ue}(),c=function(){if(Be)return je;Be=1,Object.defineProperty(je,"__esModule",{value:!0}),je.Ring=void 0;const t=Ot(),e=re(),i=Rt(),s=Ct(),r=2*Math.PI;let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return je.Ring=n,n.prototype.className="Ring",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,i.getNumberValidator)()),je}(),u=function(){if(He)return Ye;He=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Sprite=void 0;const t=Ot(),e=re(),i=ge(),s=Rt(),r=Ct();let n=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),s=4*i,r=this.animations()[e],n=this.frameOffsets(),o=r[s+0],a=r[s+1],h=r[s+2],l=r[s+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(n){const s=n[e],r=2*i;t.drawImage(d,o,a,h,l,s[r+0],s[r+1],h,l)}else t.drawImage(d,o,a,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),s=4*i,r=this.animations()[e],n=this.frameOffsets(),o=r[s+2],a=r[s+3];if(t.beginPath(),n){const s=n[e],r=2*i;t.rect(s[r+0],s[r+1],o,a)}else t.rect(0,0,o,a);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}};return Ye.Sprite=n,n.prototype.className="Sprite",(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"animation"),t.Factory.addGetterSetter(n,"animations"),t.Factory.addGetterSetter(n,"frameOffsets"),t.Factory.addGetterSetter(n,"image"),t.Factory.addGetterSetter(n,"frameIndex",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"frameRate",17,(0,s.getNumberValidator)()),t.Factory.backCompat(n,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Ye}(),g=function(){if(Xe)return Ke;Xe=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.Star=void 0;const t=Ot(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),s=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*s;r++){const n=r%2==0?i:e,o=n*Math.sin(r*Math.PI/s),a=-1*n*Math.cos(r*Math.PI/s);t.lineTo(o,a)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return Ke.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,i.getNumberValidator)()),Ke}(),f=Ze(),p=function(){if($e)return Qe;$e=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.TextPath=void 0;const t=Tt(),e=Ot(),i=re(),s=Ee(),r=Ze(),n=Rt(),o=Ct(),a="normal";function h(t){t.fillText(this.partialText,0,0)}function l(t){t.strokeText(this.partialText,0,0)}let d=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return s.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:s.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=s.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),s=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<r.length;i++){t.save();const n=r[i].p0;t.translate(n.x,n.y),t.rotate(r[i].rotation),this.partialText=r[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,s/2+1),t.lineTo(s,s/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=s/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const s=e[i].p1;t.lineTo(s.x,s.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),n=this.align(),o=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===n&&(h=Math.max(0,this.pathLength/2-a/2)),"right"===n&&(h=Math.max(0,this.pathLength-a));const l=(0,r.stringToArray)(this.text());let d=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(d);if(!e)return;let r=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===n){const t=this.text().split(" ").length-1;r+=(this.pathLength-a)/t}const h=this._getPointAtLength(d+r);if(!h)return;const c=s.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(o)try{u=o(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const g=s.Path.getPointOnLine(u+c/2,e.x,e.y,h.x,h.y),f=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:l[t],rotation:f,p0:e,p1:h}),d+=r}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));let e,i,s=t[0]||0,r=t[0]||0,n=t[1]||0,o=t[1]||0;for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],s=Math.min(s,e),r=Math.max(r,e),n=Math.min(n,i),o=Math.max(o,i);const a=this.fontSize();return{x:s-a/2,y:n-a/2,width:r-s+a,height:o-n+a}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Qe.TextPath=d,d.prototype._fillFunc=h,d.prototype._strokeFunc=l,d.prototype._fillFuncHit=h,d.prototype._strokeFuncHit=l,d.prototype.className="TextPath",d.prototype._attrsAffectingSize=["text","fontSize","data"],(0,o._registerNode)(d),e.Factory.addGetterSetter(d,"data"),e.Factory.addGetterSetter(d,"fontFamily","Arial"),e.Factory.addGetterSetter(d,"fontSize",12,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(d,"fontStyle",a),e.Factory.addGetterSetter(d,"align","left"),e.Factory.addGetterSetter(d,"letterSpacing",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(d,"textBaseline","middle"),e.Factory.addGetterSetter(d,"fontVariant",a),e.Factory.addGetterSetter(d,"text",""),e.Factory.addGetterSetter(d,"textDecoration",""),e.Factory.addGetterSetter(d,"kerningFunc",void 0),Qe}(),m=ii(),_=function(){if(si)return ri;si=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.Wedge=void 0;const t=Ot(),e=re(),i=Ct(),s=Rt(),r=Ct();let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return ri.Wedge=n,n.prototype.className="Wedge",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1),t.Factory.backCompat(n,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),ri}(),v=ai(),y=function(){if(hi)return li;hi=1,Object.defineProperty(li,"__esModule",{value:!0}),li.Brighten=void 0;const t=Ot(),e=Ht(),i=Rt();return li.Brighten=function(t){const e=255*this.brightness(),i=t.data,s=i.length;for(let t=0;t<s;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),li}(),w=function(){if(di)return ci;di=1,Object.defineProperty(ci,"__esModule",{value:!0}),ci.Contrast=void 0;const t=Ot(),e=Ht(),i=Rt();return ci.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,s=i.length;let r=150,n=150,o=150;for(let t=0;t<s;t+=4)r=i[t],n=i[t+1],o=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,r=r<0?0:r>255?255:r,n=n<0?0:n>255?255:n,o=o<0?0:o>255?255:o,i[t]=r,i[t+1]=n,i[t+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ci}(),x=function(){if(ui)return gi;ui=1,Object.defineProperty(gi,"__esModule",{value:!0}),gi.Emboss=void 0;const t=Ot(),e=Ht(),i=Tt(),s=Rt();return gi.Emboss=function(t){const e=10*this.embossStrength(),s=255*this.embossWhiteLevel(),r=this.embossDirection(),n=this.embossBlend(),o=t.data,a=t.width,h=t.height,l=4*a;let d=0,c=0,u=h;switch(r){case"top-left":d=-1,c=-1;break;case"top":d=-1,c=0;break;case"top-right":d=-1,c=1;break;case"right":d=0,c=1;break;case"bottom-right":d=1,c=1;break;case"bottom":d=1,c=0;break;case"bottom-left":d=1,c=-1;break;case"left":d=0,c=-1;break;default:i.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*l;let i=d;u+i<1&&(i=0),u+i>h&&(i=0);const r=(u-1+i)*a*4;let g=a;do{const i=t+4*(g-1);let h=c;g+h<1&&(h=0),g+h>a&&(h=0);const l=r+4*(g-1+h),d=o[i]-o[l],u=o[i+1]-o[l+1],f=o[i+2]-o[l+2];let p=d;const m=p>0?p:-p;if((u>0?u:-u)>m&&(p=u),(f>0?f:-f)>m&&(p=f),p*=e,n){const t=o[i]+p,e=o[i+1]+p,s=o[i+2]+p;o[i]=t>255?255:t<0?0:t,o[i+1]=e>255?255:e<0?0:e,o[i+2]=s>255?255:s<0?0:s}else{let t=s-p;t<0?t=0:t>255&&(t=255),o[i]=o[i+1]=o[i+2]=t}}while(--g)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),gi}(),b=function(){if(fi)return pi;fi=1,Object.defineProperty(pi,"__esModule",{value:!0}),pi.Enhance=void 0;const t=Ot(),e=Ht(),i=Rt();function s(t,e,i,s,r){const n=i-e,o=r-s;if(0===n)return s+o/2;if(0===o)return s;let a=(t-e)/n;return a=o*a+s,a}return pi.Enhance=function(t){const e=t.data,i=e.length;let r,n,o,a=e[0],h=a,l=e[1],d=l,c=e[2],u=c;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)r=e[t+0],r<a?a=r:r>h&&(h=r),n=e[t+1],n<l?l=n:n>d&&(d=n),o=e[t+2],o<c?c=o:o>u&&(u=o);let f,p,m,_,v,y,w,x,b;h===a&&(h=255,a=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0?(p=h+g*(255-h),m=a-g*(a-0),v=d+g*(255-d),y=l-g*(l-0),x=u+g*(255-u),b=c-g*(c-0)):(f=.5*(h+a),p=h+g*(h-f),m=a+g*(a-f),_=.5*(d+l),v=d+g*(d-_),y=l+g*(l-_),w=.5*(u+c),x=u+g*(u-w),b=c+g*(c-w));for(let t=0;t<i;t+=4)e[t+0]=s(e[t+0],a,h,m,p),e[t+1]=s(e[t+1],l,d,y,v),e[t+2]=s(e[t+2],c,u,b,x)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),pi}(),S=(mi||(mi=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.Grayscale=void 0,_i.Grayscale=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}}),_i),C=function(){if(vi)return yi;vi=1,Object.defineProperty(yi,"__esModule",{value:!0}),yi.HSL=void 0;const t=Ot(),e=Ht(),i=Rt();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),yi.HSL=function(t){const e=t.data,i=e.length,s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,n=127*this.luminance(),o=1*s*Math.cos(r*Math.PI/180),a=1*s*Math.sin(r*Math.PI/180),h=.299+.701*o+.167*a,l=.587-.587*o+.33*a,d=.114-.114*o-.497*a,c=.299-.299*o-.328*a,u=.587+.413*o+.035*a,g=.114-.114*o+.293*a,f=.299-.3*o+1.25*a,p=.587-.586*o-1.05*a,m=.114+.886*o-.2*a;let _,v,y,w;for(let t=0;t<i;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],w=e[t+3],e[t+0]=h*_+l*v+d*y+n,e[t+1]=c*_+u*v+g*y+n,e[t+2]=f*_+p*v+m*y+n,e[t+3]=w},yi}(),P=function(){if(wi)return xi;wi=1,Object.defineProperty(xi,"__esModule",{value:!0}),xi.HSV=void 0;const t=Ot(),e=Ht(),i=Rt();return xi.HSV=function(t){const e=t.data,i=e.length,s=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,o=s*r*Math.cos(n*Math.PI/180),a=s*r*Math.sin(n*Math.PI/180),h=.299*s+.701*o+.167*a,l=.587*s-.587*o+.33*a,d=.114*s-.114*o-.497*a,c=.299*s-.299*o-.328*a,u=.587*s+.413*o+.035*a,g=.114*s-.114*o+.293*a,f=.299*s-.3*o+1.25*a,p=.587*s-.586*o-1.05*a,m=.114*s+.886*o-.2*a;let _,v,y,w;for(let t=0;t<i;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],w=e[t+3],e[t+0]=h*_+l*v+d*y,e[t+1]=c*_+u*v+g*y,e[t+2]=f*_+p*v+m*y,e[t+3]=w},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),xi}(),A=(bi||(bi=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.Invert=void 0,Si.Invert=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}),Si),T=Ai(),k=Ei(),E=function(){if(Mi)return Fi;Mi=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.Noise=void 0;const t=Ot(),e=Ht(),i=Rt();return Fi.Noise=function(t){const e=255*this.noise(),i=t.data,s=i.length,r=e/2;for(let t=0;t<s;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Fi}(),M=function(){if(Ii)return Ri;Ii=1,Object.defineProperty(Ri,"__esModule",{value:!0}),Ri.Pixelate=void 0;const t=Ot(),e=Tt(),i=Ht(),s=Rt();return Ri.Pixelate=function(t){let i,s,r,n,o,a,h,l,d,c,u,g,f,p,m=Math.ceil(this.pixelSize()),_=t.width,v=t.height,y=Math.ceil(_/m),w=Math.ceil(v/m),x=t.data;if(m<=0)e.Util.error("pixelSize value can not be <= 0");else for(g=0;g<y;g+=1)for(f=0;f<w;f+=1){for(n=0,o=0,a=0,h=0,l=g*m,d=l+m,c=f*m,u=c+m,p=0,i=l;i<d;i+=1)if(!(i>=_))for(s=c;s<u;s+=1)s>=v||(r=4*(_*s+i),n+=x[r+0],o+=x[r+1],a+=x[r+2],h+=x[r+3],p+=1);for(n/=p,o/=p,a/=p,h/=p,i=l;i<d;i+=1)if(!(i>=_))for(s=c;s<u;s+=1)s>=v||(r=4*(_*s+i),x[r+0]=n,x[r+1]=o,x[r+2]=a,x[r+3]=h)}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),Ri}(),F=function(){if(Oi)return Di;Oi=1,Object.defineProperty(Di,"__esModule",{value:!0}),Di.Posterize=void 0;const t=Ot(),e=Ht(),i=Rt();return Di.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,s=i.length,r=255/e;for(let t=0;t<s;t+=1)i[t]=Math.floor(i[t]/r)*r},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Di}(),I=function(){if(Li)return Vi;Li=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.RGB=void 0;const t=Ot(),e=Ht(),i=Rt();return Vi.RGB=function(t){const e=t.data,i=e.length,s=this.red(),r=this.green(),n=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*s,e[t+1]=i*r,e[t+2]=i*n,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),Vi}(),R=function(){if(zi)return Gi;zi=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.RGBA=void 0;const t=Ot(),e=Ht(),i=Rt();return Gi.RGBA=function(t){const e=t.data,i=e.length,s=this.red(),r=this.green(),n=this.blue(),o=this.alpha();for(let t=0;t<i;t+=4){const i=1-o;e[t]=s*o+e[t]*i,e[t+1]=r*o+e[t+1]*i,e[t+2]=n*o+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),Gi}(),O=(Ni||(Ni=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.Sepia=void 0,Wi.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],s=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*s+.189*r),e[t+1]=Math.min(255,.349*i+.686*s+.168*r),e[t+2]=Math.min(255,.272*i+.534*s+.131*r)}}),Wi),D=(Ui||(Ui=1,Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.Solarize=void 0,Bi.Solarize=function(t){const e=t.data,i=t.width,s=4*i;let r=t.height;do{const t=(r-1)*s;let n=i;do{const i=t+4*(n-1);let s=e[i],r=e[i+1],o=e[i+2];s>127&&(s=255-s),r>127&&(r=255-r),o>127&&(o=255-o),e[i]=s,e[i+1]=r,e[i+2]=o}while(--n)}while(--r)}),Bi),L=function(){if(ji)return Yi;ji=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.Threshold=void 0;const t=Ot(),e=Ht(),i=Rt();return Yi.Threshold=function(t){const e=255*this.threshold(),i=t.data,s=i.length;for(let t=0;t<s;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Yi}();return xt.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:s.Circle,Ellipse:r.Ellipse,Image:n.Image,Label:o.Label,Tag:o.Tag,Line:a.Line,Path:h.Path,Rect:l.Rect,RegularPolygon:d.RegularPolygon,Ring:c.Ring,Sprite:u.Sprite,Star:g.Star,Text:f.Text,TextPath:p.TextPath,Transformer:m.Transformer,Wedge:_.Wedge,Filters:{Blur:v.Blur,Brighten:y.Brighten,Contrast:w.Contrast,Emboss:x.Emboss,Enhance:b.Enhance,Grayscale:S.Grayscale,HSL:C.HSL,HSV:P.HSV,Invert:A.Invert,Kaleidoscope:T.Kaleidoscope,Mask:k.Mask,Noise:E.Noise,Pixelate:M.Pixelate,Posterize:F.Posterize,RGB:I.RGB,RGBA:R.RGBA,Sepia:O.Sepia,Solarize:D.Solarize,Threshold:L.Threshold}}),xt}var Ki,qi=wt.exports;var Ji=vt(function(){if(Ki)return wt.exports;Ki=1,Object.defineProperty(qi,"__esModule",{value:!0});const t=Xi();return wt.exports=t.Konva,wt.exports}());class Zi{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class $i{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const s=t=>{const e=t.toString(16);return"0"===e?"00":e};return s(t)+s(e)+s(i)}}const Qi=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class ts{constructor(t,e=null,i=new Zi){var s,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let s=0;s<e.length;s+=2)i=this._worldTransformer.screenToWorld({x:e[s],y:e[s+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const n=[],o=[];t.points.forEach((t=>{n.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});o.push({x:e.x,y:e.y,z:e.z})})),this._ref=new Ji.Line({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:n,draggable:!0,strokeScaleEnabled:!1,dash:Qi.get(t.type)||[]}),this._ref.setAttr("wcsPoints",o),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.on("transformend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let s;for(let r=0;r<i.length;r+=2){const n=t.point({x:i[r],y:i[r+1]});s=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:s.x,y:s.y,z:s.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.on("dragend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let s;for(let r=0;r<i.length;r+=2){const n=t.point({x:i[r],y:i[r+1]});s=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:s.x,y:s.y,z:s.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Qi.get("dot"):t="dot";break;case Qi.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Qi.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach((t=>{e=e.concat([t.x,t.y]);const s=this._worldTransformer.screenToWorld(t);i.push(s)})),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach((t=>{let s=this._worldTransformer.worldToScreen(t);s=i.point({x:s.x,y:s.y}),e.push(s.x),e.push(s.y)})),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class es{constructor(t,e=null,i=new Zi){var s,r,n;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()}))}else t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Ji.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(s=t.fontSize)&&void 0!==s?s:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(n=t.rotation)&&void 0!==n?n:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY);r<50&&(r=50),n<Math.round(this.getFontSize())&&(n=Math.round(this.getFontSize())),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class is{constructor(t,e=null,i=new Zi){var s,r,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Ji.Rect({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(o=t.height)&&void 0!==o?o:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY);r<50&&(r=50),n<50&&(n=50),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}function ss(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class rs{constructor(t,e=null,i=new Zi){var s,r,n;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),s=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(s||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(s=t.radius)&&void 0!==s||(t.radius={x:0,y:0}),t.radius.x=ss(t.position,t.position2),t.position3?t.radius.y=ss(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Ji.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let n=this._ref.radiusY();s&&(n*=e.scaleY);r<25&&(r=25),n<25&&(n=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:n,y:n}):this._ref.radius({x:r,y:n}),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const s=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(s))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const s=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(s))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let s=this._ref.getStage().getAbsoluteTransform().copy();s=s.invert();const r=s.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(s.point(e).x-r.x),y:Math.abs(s.point(i).y-r.y)})}}class ns{constructor(t,e=null,i=new Zi){var s,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Ji.Arrow({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),s=this._ref.getAbsoluteTransform(),r=s.point({x:i[0],y:i[1]}),n=s.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(n))})),this._ref.on("dragend",(t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),s=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const s=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([s.x,s.y,r.x,r.y])}}class os{constructor(t,e=null,i=new Zi){var s,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ji.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(s=t.width)&&void 0!==s?s:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(n/this._ratio),this._ref.height(n)):(i&&this._ref.width(r),s&&this._ref.height(n)),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}class as{constructor(t,e=null,i=new Zi){var s,r,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Ji.Shape({x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(o=t.lineWidth)&&void 0!==o?o:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),s=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+s},{x:0,y:0+s},{x:0,y:0}];function n(n,o){const a={x:(h={x:0,y:0}).x+i/2,y:h.y+s/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=o;const s=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(s*s+h*h),d=Math.floor(l/i);i=o+d/(l%i);let c=r[e].x+s/d/2,u=r[e].y+h/d/2;const g=r[e+1].x,f=r[e+1].y,p=Math.atan((f-u)/(g-c)),m=p+Math.PI,_=c>a.x&&u>a.y;for(let e=0;e<d;e++)_?t.arc(c,u,n,p,m):t.arc(c,u,n,m,p),c+=s/d,u+=h/d}t.closePath(),t.fillStrokeShape(e)}i>=49||s>=49?n(8,15):i>=25||s>=25?n(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY),r<50&&(r=50),n<50&&(n=50),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}const hs={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new ts(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new es(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new is(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new rs(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new ns(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new os(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new as(e,t,...i)}};class ls{constructor(){this._markupIsActive=!1,this._markupColor=new $i(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.pan=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.zoomAt=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,s){if(!Ji)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=s?s:new Zi,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...s)=>{i&&clearTimeout(i),i=setTimeout((()=>{i=null,t(...s)}),e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const s=new $i(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,s)}))}colorizeSelectedMarkups(t,e,i){const s=new $i(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,s)}))}setViewpoint(t){var e,i,s,r,n,o,a,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(s=t.texts)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(n=t.ellipses)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,s=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,s,t.radius,t.line_width,t.color,t.id)})),null===(o=t.arrows)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(a=t.clouds)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&hs[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=hs[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const s=i.initializer(null,e,this._worldTransformer);return this.addObject(s),s}getObjects(){const t=[];return Object.keys(hs).forEach((e=>{const i=hs[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e,null,this._worldTransformer))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(hs).find((t=>t.name===e));return i?i.initializer(t,null,this._worldTransformer):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=hs[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Ji.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ji.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ji.Group,e.add(this._groupImages),this._groupGeometry=new Ji.Group,e.add(this._groupGeometry),this._groupTexts=new Ji.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Ji.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let s,r,n,o=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const n=this.getRelativePointerPosition(t);r=n,o=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(s=this.addLine([n.x,n.y,n.x,n.y]))})),t.on("mouseup touchend",(()=>{if(this._markupIsActive){if(o){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,s=i?r.x:Math.min(r.x,e.x),n=i?r.y:Math.min(r.y,e.y),o=i?200:Math.abs(r.x-e.x),a=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:s,y:n},null,o,a):"Ellipse"===this._markupMode?this.addEllipse({x:s,y:n},null,null,{x:o/2,y:a/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?n:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:s,y:n},null,Math.max(100,o),Math.max(100,a)))}n=void 0,o=!1}})),t.on("mousemove touchmove",(()=>{if(!this._markupIsActive)return;if(!o)return;const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,a=i?r.x:Math.min(r.x,e.x),h=i?r.y:Math.min(r.y,e.y),l=i?200:Math.abs(r.x-e.x),d=i?200:Math.abs(r.y-e.y);"Line"===this._markupMode?s.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?n?n.setEndPoint(e.x,e.y):n=this.addArrow({x:r.x,y:r.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?n?(n.setPosition(a,h),n.setWidth(l),n.setHeight(d)):n=this.addRectangle({x:a,y:h},null,l,d):"Ellipse"===this._markupMode?n?(n.setPosition(a,h),n.setRadiusX(l),n.setRadiusY(d)):n=this.addEllipse({x:a,y:h},null,null,{x:l,y:d}):"Cloud"===this._markupMode&&(n?(n.setPosition(a,h),n.setWidth(Math.max(100,l)),n.setHeight(Math.max(100,d))):n=this.addCloud({x:a,y:h},null,l,d))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const s=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(s||r){if(s&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(s&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.getAttr("wcsPoints");if(!i)return;const s=new ts(null,e,this._worldTransformer),r={id:s.id(),points:i,color:s.getColor()||"#ff0000",type:s.getLineType()||this.lineType,width:s.getLineWidth()||this.lineWidth};t.push(r)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),s=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),n=new es(null,e,this._worldTransformer),o={id:n.id(),position:s,text:n.getText(),text_size:.02*i.y,angle:n.getRotation(),color:n.getColor(),font_size:n.getFontSize()*r.getMatrix()[0]};t.push(o)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(s),o=new is(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.getAttr("wcsPosition"),s=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),n=this._konvaStage.getAbsoluteTransform().getMatrix()[0],o=new rs(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,position3:r,radius:{x:e.getRadiusX()*n,y:e.getRadiusY()*n},line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=new ns(null,e,this._worldTransformer),n={id:r.id(),start:i,end:s,color:r.getColor()};t.push(n)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],n=new os(null,e,this._worldTransformer),o={id:n.id(),position:i,position2:s,src:n.getSrc(),width:n.getWidth()*r,height:n.getHeight()*r};t.push(o)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(s),o=new as(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,s,r){if(!t||0===t.length)return;const n=[];for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});const o=new ts({points:n,type:i||this.lineType,width:s||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(o),o}createTextInput(t,e,i,s,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=s,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{e(s.result)},s.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],s=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,s.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,s,r,n,o){var a;if(!t)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!n||n<h)){const t=.02;n=r/(this._worldTransformer.getScale().y/t)/34}const l=new es({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:n||this.fontSize,color:s||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,s,r,n,o){if(!t)return;const a=new is({position:t,position2:e,width:i,height:s,lineWidth:r||this.lineWidth,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addEllipse(t,e,i,s,r,n,o){if(!t)return;const a=new rs({position:t,position2:e,position3:i,radius:s,lineWidth:r,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addArrow(t,e,i,s){if(!t||!e)return;const r=new ns({start:t,end:e,color:i||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,s,r,n,o){if(!t||!i||!s)return;const a=new as({position:t,position2:e,width:i,height:s,color:n||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:o},null,this._worldTransformer);return this.addObject(a),a}addImage(t,e,i,s,r,n){var o;if(!t||!i)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeImageInput();const a=new os({position:t,position2:e,src:i,width:s,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:n},null,this._worldTransformer);return this.addObject(a),a}}const ds="$MarkupTempEntity_Line";class cs extends y{constructor(t){super(t),this.press=!1}dispose(){super.dispose(),this.end(),this.points=null,this.drawPoints=null}start(t,e){const i=this.getViewer().screenToWorld(t,e);this.drawPoints=[i[0],i[1],i[2]]}drag(t,e){if(this.isDragging){const i=this.getViewer().screenToWorld(t,e);this.drawPoints.push(i[0],i[1],i[2]),this._updateFrame()}}end(){this.entity&&(this.entity.delete(),this.drawPoints=null,this.entity=null)}_updateFrame(){if(this.entity){const t=this.getViewer().getMarkupModel();t.removeEntity(this.entity),t.delete(),this.entity.delete()}this.entity=this.getActiveMarkupEntity(ds);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const us="$MarkupTempEntity_Text";class gs extends y{constructor(t){super(t),this.TEXT_HEIGHT_ALIGN=24,this.press=!1}dispose(){var t;super.dispose(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}_finishInput(){var t;this.textRef&&this.textRef.value.trimLeft()&&this._updateFrame(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}start(t,e,i,s){this.textRef?this._finishInput():(this.textRef=document.createElement("textarea"),this.textRef.style.zIndex="9999",this.textRef.style.position="absolute",this.textRef.style.display="block",this.textRef.style.top=s+"px",this.textRef.style.left=i+"px",this.textRef.onkeypress=t=>{"Enter"===t.key&&(t.preventDefault(),this._finishInput())},document.body.appendChild(this.textRef),this.press=!0,this.m_center=this.screenToWorld(t,e+this.TEXT_HEIGHT_ALIGN),this.needInputText=!0)}_updateFrame(){this.entity=this.getActiveMarkupEntity(us);const t=this.entity.openObject(),e=this.getViewer().activeView,i=this.toPoint(e.viewPosition),s=this.toPoint(e.viewTarget),r=e.eyeToWorldMatrix,n=i.sub(s).asVector(),o=this.toVector([1,0,0]).transformBy(r),a=this.createMatrix3d();a.setToWorldToPlane(this.toGeVector(n)),o.transformBy(a);const h=-Math.atan2(-o.y,o.x);let l=1;const d=e.projectionMatrix.get(1,1);d<1e-6&&d>-1e-6||(l=1/d);const c=t.appendText(this.toGePoint(this.m_center),this.textRef.value.trimLeft()),u=c.openAsText();u.setNormal(this.toGeVector(n)),u.setRotation(h),u.setTextSize(.02*l),u.delete(),c.delete(),t.delete()}}class fs{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=4,this.fontSize=34}initialize(t,e,i,s){this._viewer=i,this._viewer.registerDragger("Line",cs),this._viewer.registerDragger("Text",gs)}dispose(){}syncOverlay(){}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete()}getMarkupColor(){return this._markupColor}setMarkupColor(t,e,i){const s={r:t,g:e,b:i};this._markupColor=s,this._viewer.emitEvent({type:"changemarkupcolor",data:s})}colorizeAllMarkup(t=255,e=0,i=0){if(!this._viewer.visualizeJs)return;const s=this._viewer.visViewer().getMarkupModel().getEntitiesIterator();for(;!s.done();s.step()){const r=s.getEntity().openObject(),n=r.getName();n!==ds&&n!==us||r.setColor(t,e,i),r.delete()}s.delete(),this._viewer.update()}colorizeSelectedMarkups(t=255,e=0,i=0){throw new Error("Not implemented yet")}setViewpoint(t){function e(t){return[t.x,t.y,t.z]}function i(t,e){return t.Point3d.createFromArray(e)}if(!this._viewer.visualizeJs)return;const s=this._viewer.visLib(),r=s.getViewer().activeView;this._viewer.syncOverlay();const n=t.custom_fields.markup_color||{r:255,g:0,b:0};if(this.setMarkupColor(n.r,n.g,n.b),t.lines)for(const e of t.lines){const t=this._viewer.addMarkupEntity(ds).openObject(),i=[];for(const t of e.points)i.push(t.x,t.y,t.z);t.appendPolyline(i).delete(),t.delete()}if(t.texts){const n=i(s,r.viewPosition),o=i(s,r.viewTarget),a=n.sub(o).asVector();for(const i of t.texts){const t=this._viewer.addMarkupEntity(us).openObject(),s=t.appendText(e(i.position),i.text),r=s.openAsText();r.setNormal(e(a)),r.setRotation(i.angle),r.setTextSize(i.text_size),r.delete(),s.delete(),t.delete()}}this._viewer.update()}getViewpoint(t){if(!this._viewer.visualizeJs)return{};function e(t){return{x:t[0],y:t[1],z:t[2]}}const i=this._viewer.visLib(),s=i.getViewer();t||(t={}),t.lines=[],t.texts=[];const r=s.getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const i=r.getEntity().openObject(),s=i.getName(),n=i.getGeometryDataIterator();if(n.done()){i.delete();continue}const o=n.getGeometryData();if(s===ds){const i=o.openAsPolyline(),s=i.getPoints(),r={points:[]};for(const t of s)r.points.push(e(t));t.lines.push(r),i.delete()}else if(s===us){const i=o.openAsText(),s={position:e(i.getPosition()),text:i.getString(),angle:i.getRotation(),text_size:i.getTextSize()};t.texts.push(s),i.delete()}i.delete()}return r.delete(),t.snapshot={data:i.canvas.toDataURL("image/jpeg",.25)},t.custom_fields={markup_color:this.getMarkupColor()},t}enableEditMode(t){return this}createObject(t,e){}getObjects(){return[]}getSelectedObjects(){return[]}selectObjects(t){}clearSelected(){}}class ps{static createMarkup(t="Konva"){let e;switch(t){case"Konva":e=new ls;break;case"Visualize":e=new fs;break;default:throw new Error("Error during Markup initialization. Unknown Markup type.")}return e}}const ms="$OVERLAY_VIEW_NAME",_s=t=>null!=t;t.CANVAS_EVENTS=_,t.CanvasEvents=m,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.FileLoader=nt,t.Loader=d,t.Markup=ls,t.OdBaseDragger=y,t.Options=p,t.Viewer=class extends pt{constructor(t,e={}){var i;super(),this._visualizeJsUrl="",this.configure(e),this._options=new p(this),this.client=t,this.loaders=[],this._activeDragger=null,this._components=[],this._renderTime=0,this.canvasEvents=_.slice(),this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(i=e.enableAutoUpdate)||void 0===i||i,this._isNeedRender=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=ps.createMarkup(e.markupType)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}get markup(){return this._markup}configure(t){return this._visualizeJsUrl=t.visualizeJsUrl||"https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js",this._crossOrigin=t.crossOrigin,this}async initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),""===t.style.width&&""===t.style.height&&(t.style.width="100%",t.style.height="100%"),t.parentElement.style.touchAction="none",t.style.touchAction="none",t.width=t.clientWidth*window.devicePixelRatio,t.height=t.clientHeight*window.devicePixelRatio,this._visualizeTimestamp=Date.now();const i=this._visualizeTimestamp,s=await(async(t,e,i={})=>{const s=await mt(t,i);return await new Promise(((i,r)=>{const n={urlMemFile:t+".wasm",TOTAL_MEMORY:134217728,onprogress:e},o=window.getVisualizeLibInst(n);o.loadWasmError=r,o.postRun.push((()=>{window.getVisualizeLibInst.script=s,i(o)}))}))})(this.visualizeJsUrl,(t=>{const{loaded:i,total:s}=t;e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:i,total:s})),this.emitEvent({type:"initializeprogress",data:i/s,loaded:i,total:s})}),{crossOrigin:this._crossOrigin});if(i!==this._visualizeTimestamp)throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");this._visualizeJs=s,this.visualizeJs.canvas=t,this.visualizeJs.Viewer.create(),this.visualizeJs.getViewer().resize(0,t.width,t.height,0),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of rt.getComponents().keys())this._components.push(rt.createComponent(t,this));return this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),this.render(this._renderTime),this.emitEvent({type:"initialize"}),this}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach((t=>t.dispose())),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this._visualizeJs&&this._visualizeJs.getViewer().clear(),this._visualizeJs=void 0,this._visualizeTimestamp=void 0,this}isInitialized(){return!!this.visualizeJs}render(t){var e,i;if(!this.visualizeJs)return;if(this._isRunAsyncUpdate)return;const s=this.visualizeJs.getViewer();if(s.isRunningAnimation()||this._isNeedRender){s.update(),null===(i=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===i||i.call(e),this._isNeedRender=!s.getActiveDevice().isValid();const r=(t-this._renderTime)/1e3;this._renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}}resize(){if(!this.visualizeJs)return this;const{clientWidth:t,clientHeight:e}=this.canvas;if(!t||!e)return this;this.canvas.width=t*window.devicePixelRatio,this.canvas.height=e*window.devicePixelRatio;return this.visualizeJs.getViewer().resize(0,this.canvas.width,this.canvas.height,0),this.update(!0),this.emitEvent({type:"resize",width:t,height:e}),this}update(t=!1){var e,i,s;this._enableAutoUpdate&&(t?(null===(e=this.visViewer())||void 0===e||e.update(),null===(s=null===(i=this._activeDragger)||void 0===i?void 0:i.updatePreview)||void 0===s||s.call(i)):this._isNeedRender=!0),this.emitEvent({type:"update",data:t})}scheduleUpdateAsync(t=50){return new Promise(((e,i)=>{setTimeout((()=>{var s,r,n;try{this._enableAutoUpdate&&(null===(s=this.visViewer())||void 0===s||s.update(t),null===(n=null===(r=this._activeDragger)||void 0===r?void 0:r.updatePreview)||void 0===n||n.call(r)),this.emitEvent({type:"update",data:!1}),e()}catch(t){console.error(t),i()}}),0)}))}async updateAsync(t=50,e=50){this._isRunAsyncUpdate=!0;const i=this.visViewer().getActiveDevice();try{for(let s=0;!i.isValid()&&s<e;s++)await this.scheduleUpdateAsync(t);await this.scheduleUpdateAsync(t)}catch(t){console.error(t)}finally{this._isRunAsyncUpdate=!1}}get visualizeJs(){return this._visualizeJs}visLib(){return this.visualizeJs}visViewer(){var t;return null===(t=this.visualizeJs)||void 0===t?void 0:t.getViewer()}syncOpenCloudVisualStyle(t){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),s=i.getActiveDevice();if(s.isNull())return this;const r=s.getActiveView();let n;r.enableDefaultLighting(!0,e.DefaultLightingType.kTwoLights),r.setDefaultLightingIntensity(1.25);try{n=i.findVisualStyle("OpenCloud")}catch{n=void 0}if(!n||n.isNull()){n=i.createVisualStyle("OpenCloud");const t=new e.OdTvColorDef(66,66,66),s=i.findVisualStyle("Realistic"),r=n.openObject();r.copyFrom(s),r.setOptionInt32(e.VisualStyleOptions.kFaceModifiers,0,e.VisualStyleOperations.kSet),r.setOptionInt32(e.VisualStyleOptions.kEdgeModel,2,e.VisualStyleOperations.kSet),r.setOptionDouble(e.VisualStyleOptions.kEdgeCreaseAngle,60,e.VisualStyleOperations.kSet),r.setOptionInt32(e.VisualStyleOptions.kEdgeStyles,0,e.VisualStyleOperations.kSet),r.setOptionInt32(e.VisualStyleOptions.kEdgeModifiers,8,e.VisualStyleOperations.kSet),r.setOptionColor(e.VisualStyleOptions.kEdgeColorValue,t,e.VisualStyleOperations.kSet),r.delete()}return r.visualStyle=n,r.delete(),s.delete(),this}syncOptions(t=this.options){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),s=i.getActiveDevice();if(s.isNull())return this;t.showWCS!==i.getEnableWCS()&&i.setEnableWCS(t.showWCS),t.cameraAnimation!==i.getEnableAnimation()&&i.setEnableAnimation(t.cameraAnimation);const r=!0===t.antialiasing||"fxaa"===t.antialiasing;if(r!==i.fxaaAntiAliasing3d&&(i.fxaaAntiAliasing3d=r,i.fxaaQuality=5),t.shadows!==i.shadows){i.shadows=t.shadows;const r=e.canvas;s.invalidate([0,r.clientWidth,r.clientHeight,0])}if(t.groundShadow!==i.groundShadow&&(i.groundShadow=t.groundShadow),t.ambientOcclusion!==s.getOptionBool(e.DeviceOptions.kSSAOEnable)){s.setOptionBool(e.DeviceOptions.kSSAOEnable,t.ambientOcclusion),s.setOptionBool(e.DeviceOptions.kSSAODynamicRadius,!0),s.setOptionDouble(e.DeviceOptions.kSSAORadius,1),s.setOptionInt32(e.DeviceOptions.kSSAOLoops,32),s.setOptionDouble(e.DeviceOptions.kSSAOPower,2),s.setOptionInt32(e.DeviceOptions.kSSAOBlurRadius,2);const r=i.activeView;r.setSSAOEnabled(t.ambientOcclusion),r.delete()}if(_s(t.edgeModel)){const r=s.getActiveView(),n=i.findVisualStyle("OpenCloud"),o=n.openObject();o.setOptionInt32(e.VisualStyleOptions.kEdgeModel,t.edgeModel?2:0,e.VisualStyleOperations.kSet),r.visualStyle=n,o.delete(),n.delete(),r.delete()}return s.delete(),this.syncHighlightingOptions(t),this.update(),this}syncHighlightingOptions(t=this.options){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:p.defaults(),i=this.visLib(),s=i.getViewer(),{Entry:r,OdTvRGBColorDef:n}=i,o=s.findHighlightStyle("Web_Default").openObject();if(_s(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(r.k3D.value|r.k3DTop.value,t),t.delete()}if(_s(e.facesOverlap)&&o.setFacesVisibility(r.k3DTop.value,e.facesOverlap),_s(e.facesTransparancy)&&o.setFacesTransparency(r.k3D.value|r.k3DTop.value,e.facesTransparancy),_s(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(r.k3DTop.value|r.k3D.value|r.k2D.value|r.k2DTop.value,t),t.delete()}if(_s(e.edgesVisibility)&&o.setEdgesVisibility(r.k2D.value|r.k2DTop.value|r.k3DTop.value|r.k3D.value,e.edgesVisibility),_s(e.edgesOverlap)){const t=!_s(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(r.k2DTop.value|r.k3DTop.value,e.edgesOverlap&&t)}const a=s.getActiveDevice();if(!a.isNull()){const t=i.canvas;a.invalidate([0,t.clientWidth,t.clientHeight,0]),a.delete()}return this}get draggers(){return[...Y.getDraggers().keys()]}get components(){return[...rt.getComponents().keys()]}registerDragger(t,e){console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead."),Y.registerDragger(t,(t=>new e(t)))}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const s=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.visualizeJs&&(r=Y.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const n=this.canvas;n&&(s&&n.classList.remove(`oda-cursor-${s.name.toLowerCase()}`),r&&n.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find((e=>e.name===t))}clearSlices(){if(!this.visualizeJs)return;const t=this.visViewer().activeView;t.removeCuttingPlanes(),t.delete(),this.update()}clearOverlay(){this.visualizeJs&&(this._markup.clearOverlay(),this.update())}syncOverlay(){if(!this.visualizeJs)return;const t=this.visViewer(),e=t.activeView;let i=t.getViewByName(ms);if(!i){const s=t.getMarkupModel(),r=t.getActiveDevice();i=r.createView(ms,!1),i.addModel(s),e.addSibling(i),r.addView(i)}i.viewPosition=e.viewPosition,i.viewTarget=e.viewTarget,i.upVector=e.upVector,i.viewFieldWidth=e.viewFieldWidth,i.viewFieldHeight=e.viewFieldHeight;const s=i.getViewport();i.setViewport(s.lowerLeft,s.upperRight),i.vportRect=e.vportRect,this._markup.syncOverlay(),this.update()}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}screenToWorld(t){if(!this.visualizeJs)return{x:t.x,y:t.y,z:0};const e=this.visViewer().activeView,i=e.transformScreenToWorld(t.x*window.devicePixelRatio,t.y*window.devicePixelRatio),s={x:i[0],y:i[1],z:i[2]};return e.delete(),s}worldToScreen(t){if(!this.visualizeJs)return{x:t.x,y:t.y};const e=this.visViewer().activeView,i=e.transformWorldToScreen(t.x,t.y,t.z),s={x:i[0]/window.devicePixelRatio,y:i[1]/window.devicePixelRatio};return e.delete(),s}getScale(){const t={x:1,y:1,z:1},e=this.visViewer().activeView.projectionMatrix,i=1e-6,s=e.get(0,0);(s>i||s<-1e-6)&&(t.x=1/s);const r=e.get(1,1);(r>i||r<-1e-6)&&(t.y=1/r);const n=e.get(2,2);return(n>i||n<-1e-6)&&(t.z=1/n),t}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}async loadReferences(t){var e;if(!this.visualizeJs)return this;if(!this.client)return this;if(!t.getReferences)return this;const i=new AbortController;null===(e=this._abortControllerForReferences)||void 0===e||e.abort(),this._abortControllerForReferences=i;let s=[];await t.getReferences(i.signal).then((t=>s=t.references)).catch((t=>console.error("Cannot load model references.",t)));for(const t of s)await this.client.downloadFile(t.id,void 0,i.signal).then((e=>{var i;return null===(i=this.visualizeJs)||void 0===i?void 0:i.getViewer().addEmbeddedFile(t.name,new Uint8Array(e))})).catch((e=>console.error(`Cannot load reference file ${t.name}.`,e)));return this}applyModelTransformMatrix(t){this.executeCommand("applyModelTransform",t)}applySceneGraphSettings(t=this.options){if(!this.visualizeJs)return;const e=this.visLib(),i=e.getViewer().getActiveDevice();_s(t.sceneGraph)&&i.setOptionBool(e.DeviceOptions.kDelaySceneGraphProc,!t.sceneGraph),i.delete(),this.update()}async open(t,e={}){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});let i=t;if(i&&"function"==typeof i.getModels){const e=await i.getModels();i=e.find((t=>t.default))||e[0]||t}if(!i)throw new Error("Format not supported");let s=e.format;s||"string"!=typeof i.type||(s=i.type.split(".").pop()),s||"string"!=typeof t||(s=t.split(".").pop()),!s&&t instanceof globalThis.File&&(s=t.name.split(".").pop());const r=ft.createLoader(this,i,s);if(!r)throw new Error("Format not supported");this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:i});try{await this.loadReferences(i),await r.load(i,s,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:i}),e}return this.emitEvent({type:"geometryend",file:t,model:i}),this.visualizeJs&&(this.applyModelTransformMatrix(i),this.applySceneGraphSettings()),this}openVsfFile(t){if(console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});const e=this.visLib().getViewer();this.emitEvent({type:"geometrystart",file:t});try{const i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseFile(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.syncOverlay(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,file:t}),this.emitEvent({type:"databasechunk",data:i,file:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t}),e}return this.emitEvent({type:"geometryend",file:t}),this}openVsfxFile(t){if(console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});const e=this.visLib().getViewer();this.emitEvent({type:"geometrystart",file:t});try{const i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseVsfx(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.syncOverlay(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,file:t}),this.emitEvent({type:"databasechunk",data:i,file:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t}),e}return this.emitEvent({type:"geometryend",file:t}),this}cancel(){var t;return null===(t=this._abortControllerForReferences)||void 0===t||t.abort(),this._abortControllerForReferences=void 0,this.loaders.forEach((t=>t.cancel())),this.emitEvent({type:"cancel"}),this}clear(){if(!this.visualizeJs)return this;const t=this.visLib().getViewer();return this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),t.clear(),t.createLocalDatabase(),this.loaders.forEach((t=>t.dispose())),this.loaders=[],this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this.syncOverlay(),this.resize(),this.emitEvent({type:"clear"}),this}getMarkupColor(){return console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead."),this._markup.getMarkupColor()}setMarkupColor(t=255,e=0,i=0){console.warn("Viewer.setMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.setMarkupColor() instead."),this._markup.setMarkupColor(t,e,i)}colorizeAllMarkup(t=255,e=0,i=0){console.warn("Viewer.colorizeAllMarkup() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.colorizeAllMarkup() instead."),this._markup.colorizeAllMarkup(t,e,i)}colorizeSelectedMarkups(t=255,e=0,i=0){this._markup.colorizeSelectedMarkups(t,e,i)}addMarkupEntity(t){if(!this.visualizeJs)return null;this.syncOverlay();const e=this.visViewer().getMarkupModel().appendEntity(t),i=e.openObject(),s=this.getMarkupColor();return i.setColor(s.r,s.g,s.b),i.setLineWeight(2),i.delete(),this.update(),e}drawViewpoint(t){var e;if(!this.visualizeJs)return;const i=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),this.setOrthogonalCameraSettings(t.orthogonal_camera),this.setClippingPlanes(t.clipping_planes),this.setSelection(t.selection),this._markup.setViewpoint(t),this.setActiveDragger(i),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.visualizeJs)return{};const t={};return t.orthogonal_camera=this.getOrthogonalCameraSettings(),t.clipping_planes=this.getClippingPlanes(),t.selection=this.getSelection(),t.description=(new Date).toDateString(),this._markup.getViewpoint(t),this.emitEvent({type:"createviewpoint",data:t}),t}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}getLogicalPoint3dAsArray(t){return[t.x,t.y,t.z]}getOrthogonalCameraSettings(){const t=this.visViewer().activeView;return{view_point:this.getPoint3dFromArray(t.viewPosition),direction:this.getPoint3dFromArray(t.viewTarget),up_vector:this.getPoint3dFromArray(t.upVector),field_width:t.viewFieldWidth,field_height:t.viewFieldHeight,view_to_world_scale:1}}setOrthogonalCameraSettings(t){const e=this.visViewer().activeView;t&&(e.setView(this.getLogicalPoint3dAsArray(t.view_point),this.getLogicalPoint3dAsArray(t.direction),this.getLogicalPoint3dAsArray(t.up_vector),t.field_width,t.field_height,!0),this.syncOverlay())}getClippingPlanes(){const t=this.visViewer().activeView,e=[];for(let i=0;i<t.numCuttingPlanes();i++){const s=t.getCuttingPlane(i),r={location:this.getPoint3dFromArray(s.getOrigin()),direction:this.getPoint3dFromArray(s.normal())};e.push(r)}return e}setClippingPlanes(t){if(t){const e=this.visViewer().activeView;for(const i of t){const t=new(this.visLib().OdTvPlane);t.set(this.getLogicalPoint3dAsArray(i.location),this.getLogicalPoint3dAsArray(i.direction)),e.addCuttingPlane(t),e.setEnableCuttingPlaneFill(!0,102,102,102)}}}getSelection(){return this.getSelected().map((t=>({handle:t})))}setSelection(t){this.setSelected(null==t?void 0:t.map((t=>t.handle)))}executeCommand(t,...e){return Z.executeCommand(t,this,...e)}deviceAutoRegeneration(){const t=this.visViewer();t.getActiveDevice().getOptionDouble(this.visLib().DeviceOptions.kRegenCoef)>1&&(t.regenAll(),this.update())}},t.commands=Z,t.commandsRegistry=s,t.components=rt,t.componentsRegistry=l,t.defaultOptions=f,t.draggers=Y,t.draggersRegistry=o,t.loaders=ft,t.loadersRegistry=g}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Visualize=t.ODA.Visualize||{}))}(this,(function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,s){this._commands.set(t,{id:t,handler:e,thisArg:s,description:i})}registerCommandAlias(t,e){this.registerCommand(e,((e,...i)=>this.executeCommand(t,e,...i)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,i)=>t.set(i,e))),t}executeCommand(t,e,...i){const s=this._commands.get(t);if(!s){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:n}=s,o=r.apply(n,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),o}}const i=new Map;function s(t=""){let s=i.get(t);return s||(s=new e,i.set(t,s)),s}class r{constructor(){this._providers=new Map}registerDragger(t,e){this._providers.set(t,e)}registerDraggerAlias(t,e){const i=this._providers.get(t);i&&this.registerDragger(e,(t=>i(t)))}getDraggers(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createDragger(t,e){const i=this._providers.get(t);if(!i)return null;const s=i(e);return s.name=t,s}}const n=new Map;function o(t=""){let e=n.get(t);return e||(e=new r,n.set(t,e)),e}class a{constructor(){this._providers=new Map}registerComponent(t,e){this._providers.set(t,e)}registerComponentAlias(t,e){const i=this._providers.get(t);i&&this.registerComponent(e,(t=>i(t)))}getComponents(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createComponent(t,e){const i=this._providers.get(t);if(!i)return null;const s=i(e);return s.name=t,s}}const h=new Map;function l(t=""){let e=h.get(t);return e||(e=new a,h.set(t,e)),e}class d{constructor(){this.name="",this.abortController=new AbortController}dispose(){this.abortController.abort(),this.abortController=void 0}isSupport(t,e){return!1}load(t,e,i){return Promise.resolve(this)}cancel(){this.abortController.abort()}}class c{constructor(){this._providers=new Map}registerLoader(t,e){this._providers.set(t,e)}getLoader(t){return this._providers.get(t)}getLoaders(){const t=new Map;return this._providers.forEach(((e,i)=>t.set(i,e))),t}createLoader(t,e,i){let s=null;return this._providers.forEach(((r,n)=>{const o=r(t);o.isSupport(e,i)&&(s=o,s.name=n)})),s}}const u=new Map;function g(t=""){let e=u.get(t);return e||(e=new c,u.set(t,e)),e}function f(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}class p{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=p.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...p.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...p.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}}const m=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],_=m;class v{constructor(t){this.setViewParams=t=>{var e;const i=this.m_module.getViewer().getActiveTvExtendedView();i.setView(t.position,t.target,t.upVector,t.viewFieldWidth,t.viewFieldHeight,t.perspective),null===(e=i.delete)||void 0===e||e.call(i)},this.getViewParams=()=>{var t;const e=this.m_module.getViewer().activeView,i={position:e.viewPosition,target:e.viewTarget,upVector:e.upVector,viewFieldWidth:e.viewFieldWidth,viewFieldHeight:e.viewFieldHeight,perspective:e.perspective};return null===(t=e.delete)||void 0===t||t.call(e),i},this.m_module=t}getViewer(){return this.m_module.getViewer()}getModel(){return this.getViewer().getMarkupModel()}copyPoint(t){const e=new this.m_module.Point3d;return e.set(t.x,t.y,t.z),e}createVector3d(){return new this.m_module.Vector3d}createPoint3d(){return new this.m_module.Point3d}createMatrix3d(){return new this.m_module.Matrix3d}createPlane(){return new this.m_module.OdTvPlane}toVector(t){return this.m_module.Vector3d.createFromArray(t)}toGeVector(t){return[t.x,t.y,t.z]}toGePoint(t){return[t.x,t.y,t.z]}toPoint(t){return this.m_module.Point3d.createFromArray(t)}screenToWorld(t,e){return this.toPoint(this.m_module.getViewer().screenToWorld(t,e))}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}correctCameraTarget(){const t=this.getViewParams(),e=this.m_module.getViewer().getActiveExtents(),{min:i,max:s}=e,r=this.toPoint(t.target);r.x>=i.x&&r.y>=i.y&&r.z>=i.z&&r.x<=s.x&&r.y<=s.y&&r.z<=s.z||(t.target=e.center(),this.setViewParams(t))}}class y extends v{constructor(t){super(t.visualizeJs),this.beginInteractivity=()=>{const t=this.getViewer().activeView;t.beginInteractivity&&(t.beginInteractivity(24),this.subject.update()),t.delete()},this.endInteractivity=()=>{const t=this.getViewer().activeView;if(t.endInteractivity){t.endInteractivity();const e=this.getViewer().getActiveDevice(),i=this.m_module.canvas;e.invalidate([0,0,i.width,i.height]),e.delete(),this.subject.update()}t.delete()},this.subject=t,this.needInputText=!1,this.mouseDownPosition={x:0,y:0},this.autoSelect=!1,this.onmessage=t=>this.subject.emitEvent(t),this.canvasEvents=_}initialize(){this.canvasEvents=this.canvasEvents.filter((t=>"function"==typeof this[t])),this.canvasEvents.forEach((t=>this[t]=this[t].bind(this))),this.canvasEvents.forEach((t=>this.subject.on(t,this[t]))),this.getViewer().setEnableAutoSelect(!!this.autoSelect)}dispose(){this.canvasEvents.forEach((t=>this.subject.off(t,this[t])))}relativeCoords(t){return{x:t.offsetX*window.devicePixelRatio,y:t.offsetY*window.devicePixelRatio}}pointerdown(t){if(!t.isPrimary||y.isGestureActive)return;t.target.setPointerCapture(t.pointerId);const e=this.relativeCoords(t);this.isDragging=!0,this.mouseDownPosition={x:e.x,y:e.y},this.start(e.x,e.y,t.clientX,t.clientY),this.subject.update()}pointerup(t){if(y.needSkipPointerUp)return;if(!t.isPrimary)return;t.target.releasePointerCapture(t.pointerId);const e=this.relativeCoords(t);this.end(e.x,e.y,t.clientX,t.clientY),this.isDragging=!1,this.subject.update()}pointercancel(t){t.isPrimary&&this.m_module.canvas.dispatchEvent(new PointerEvent("pointerup",t))}pointermove(t){if(!t.isPrimary||y.isGestureActive)return;const e=this.relativeCoords(t);this.drag(e.x,e.y,t.clientX,t.clientY),this.isDragging&&this.subject.update()}click(t){const e=this.getViewer(),i=this.relativeCoords(t),s=i.x,r=i.y,n=Math.abs(s-this.mouseDownPosition.x)<5&&Math.abs(r-this.mouseDownPosition.y)<5;if(e&&e.getEnableAutoSelect()&&n){e.unselect(),e.select(s,r,s,r),this.subject.update();const t=e.getSelected(),i=this.subject.getSelected();this.onmessage({type:"select",data:t,handles:i})}}dblclick(t){const e=this.getViewer(),i=this.relativeCoords(t),s=i.x,r=i.y,n=e.getActiveDevice(),o=n.viewAt([s,r]);if(o&&!o.active)e.activeView=o,o.delete(),this.subject.update();else if(e&&e.getEnableAutoSelect()){const t=e.getSelected();if(!t.isNull()&&0!==t.numItems()){const i=t.getIterator(),s=i.getEntity();e.zoomToEntity(s),this.onmessage({type:"zoomtoentity",data:s}),this.subject.update(),this.deleteAll([i,s])}}n.delete()}start(t,e,i=0,s=0){}drag(t,e,i=0,s=0){}end(t,e,i=0,s=0){}getActiveMarkupEntity(t){return this.subject.addMarkupEntity(t)}syncOverlayView(){return this.subject.syncOverlay()}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}updatePreview(){}static set isGestureActive(t){y._isGestureActive!==t&&(y._isGestureActive=t,y._isGestureActive&&(y.needSkipPointerUp=!0))}static get isGestureActive(){return y._isGestureActive}static get needSkipPointerUp(){return!!y._needSkipPointerUp&&(y.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){y._needSkipPointerUp=t}}function w(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function x(t,e){return t&&e.removeChild(t),null}function b(t,e,i){const s=e.Point3d.createFromArray(t),r=i.activeView,n=r.worldToDeviceMatrix,o=s.transformBy(n),a={x:o.x/window.devicePixelRatio,y:o.y/window.devicePixelRatio};return n.delete(),s.delete(),o.delete(),r.delete(),a}function S(t){return t<0?Math.ceil(t):Math.floor(t)}y._isGestureActive=!1,y._needSkipPointerUp=!1;function C(t,e,i,s,r){const n=((t,e,i,s)=>{const r=e.x-t.x,n=e.y-t.y,o=s.x-i.x,a=s.y-i.y,h=(-n*(t.x-i.x)+r*(t.y-i.y))/(-o*n+r*a),l=(+o*(t.y-i.y)-a*(t.x-i.x))/(-o*n+r*a);return h>=0&&h<=1&&l>=0&&l<=1&&{x:S(t.x+l*r),y:S(t.y+l*n)}})(t,e,i,s);n&&r.push(n)}function P(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function A(t,e){t&&(t.onclick=e?()=>e():()=>{})}function T(t,e){t.style.pointerEvents=e?"auto":"none"}class E{constructor(t,e,i){this.htmlElemStartPoint=null,this.htmlElemEndPoint=null,this.htmlElemLine=null,this.htmlElemTitle=null,this.startPoint=null,this.endPoint=null,this.unit="",this.scale=1,this.size=10,this.lineThickness=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",color:"white",boxShadow:"0 0 10px rgba(0,0,0,0.5)"},this.htmlElemStartPoint=w(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=w(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=w(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=w(this.htmlElemTitle,t,"ruler-value"),this.viewer=e,this.moduleInstance=i,this.targetElement=t,this.isFinishDraw=!1}drawMeasureLine(){const t=this.size,e=this.moduleInstance.canvas.getBoundingClientRect();if(this.startPoint){this.htmlElemStartPoint=w(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=b(this.startPoint,this.moduleInstance,this.viewer);P(i,e.width,e.height)?(this.htmlElemStartPoint.style.display="block",this.htmlElemStartPoint.style.cursor="pointer",this.htmlElemStartPoint.style.position="absolute",this.htmlElemStartPoint.style.top=i.y-t/2+"px",this.htmlElemStartPoint.style.left=i.x-t/2+"px",this.htmlElemStartPoint.style.borderRadius=`${t}px`,this.htmlElemStartPoint.style.border=this.style.border,this.htmlElemStartPoint.style.background=this.style.background,this.htmlElemStartPoint.style.zIndex="2",this.htmlElemStartPoint.style.width=`${t}px`,this.htmlElemStartPoint.style.height=`${t}px`,this.htmlElemStartPoint.style.boxShadow=this.style.boxShadow):this.htmlElemStartPoint.style.display="none"}if(this.endPoint&&this.isFinishDraw){this.htmlElemEndPoint=w(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=b(this.endPoint,this.moduleInstance,this.viewer);P(i,e.width,e.height)?(this.htmlElemEndPoint.style.display="block",this.htmlElemEndPoint.style.cursor="pointer",this.htmlElemEndPoint.style.position="absolute",this.htmlElemEndPoint.style.top=i.y-t/2+"px",this.htmlElemEndPoint.style.left=i.x-t/2+"px",this.htmlElemEndPoint.style.borderRadius=`${t}px`,this.htmlElemEndPoint.style.border=this.style.border,this.htmlElemEndPoint.style.background=this.style.background,this.htmlElemEndPoint.style.zIndex="2",this.htmlElemEndPoint.style.width=`${t}px`,this.htmlElemEndPoint.style.height=`${t}px`,this.htmlElemEndPoint.style.boxShadow=this.style.boxShadow):this.htmlElemEndPoint.style.display="none"}if(this.endPoint&&this.startPoint){const t=b(this.startPoint,this.moduleInstance,this.viewer),i=b(this.endPoint,this.moduleInstance,this.viewer),{p1:s,p2:r,angle:n,width:o}=function(t,e,i,s){const r={x:0,y:0},n={x:i,y:0},o={x:0,y:s},a={x:i,y:s},h=[];C(t,e,r,n,h),C(t,e,r,o,h),C(t,e,o,a,h),C(t,e,a,n,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?P(t,i,s)?(l=t,d=h[0]):(l=h[0],d=e):(l=h[0],d=h[1]);const c=d.x-l.x,u=d.y-l.y;let g=180*Math.atan(u/c)/Math.PI;return c<0&&(g-=180),{angle:g,width:Math.sqrt(Math.pow(c,2)+Math.pow(u,2)),p1:l,p2:d}}(t,i,e.width,e.height),a=r.x-s.x,h=r.y-s.y,l=this.lineThickness;if(P(s,e.width,e.height)&&P(r,e.width,e.height)){this.htmlElemLine=w(this.htmlElemLine,this.targetElement,"ruler-line"),this.htmlElemLine.style.display="block",this.htmlElemLine.style.cursor="pointer",this.htmlElemLine.style.position="absolute",this.htmlElemLine.style.top=`${s.y}px`,this.htmlElemLine.style.left=`${s.x}px`,this.htmlElemLine.style.width=`${o}px`,this.htmlElemLine.style.transform=`rotate(${n}deg)`,this.htmlElemLine.style.transformOrigin=`0px ${l/2}px`,this.htmlElemLine.style.boxShadow=this.style.boxShadow,this.htmlElemLine.style.border="none",this.htmlElemLine.style.background=this.style.background,this.htmlElemLine.style.zIndex="1",this.htmlElemLine.style.height=`${l}px`;const t=`${this.getDistance()} ${this.unit}`,e=s.x+a/2,i=s.y+h/2,r=10*t.length;this.htmlElemTitle=w(this.htmlElemTitle,this.targetElement,"ruler-value"),this.htmlElemTitle.style.display="block",this.htmlElemTitle.style.cursor="pointer",this.htmlElemTitle.style.font="10px",this.htmlElemTitle.style.color="white",this.htmlElemTitle.style.position="Absolute",this.htmlElemTitle.style.top=`${i}px`,this.htmlElemTitle.style.left=e-r/2+"px",this.htmlElemTitle.style.width=`${r}px`,this.htmlElemTitle.style.transformOrigin="0px 0px",this.htmlElemTitle.style.borderRadius="5px",this.htmlElemTitle.style.boxShadow=this.style.boxShadow,this.htmlElemTitle.style.border="none",this.htmlElemTitle.style.background=this.style.background,this.htmlElemTitle.style.zIndex="3",this.htmlElemTitle.style.padding="2px",this.htmlElemTitle.style.textAlign="center",this.htmlElemTitle.innerHTML=`${t}`}else this.htmlElemLine.style.display="none",this.htmlElemTitle.style.display="none"}}getDistance(){let t=function(t,e,i){const s=i.Point3d.createFromArray(t),r=i.Point3d.createFromArray(e),n=s.distanceTo(r).toFixed(2);return s.delete(),r.delete(),n}(this.startPoint,this.endPoint,this.moduleInstance);return Math.abs(this.scale-1)>1e-4&&(t=(t/this.scale).toFixed(2)),t}setStartPoint(t){this.startPoint=t,this.drawMeasureLine()}setEndPoint(t,e){this.isFinishDraw=void 0===e||e,this.endPoint=t,this.drawMeasureLine()}update(){this.drawMeasureLine()}setSize(t){this.size=t,this.drawMeasureLine()}clear(){this.endPoint=null,this.startPoint=null,this.htmlElemStartPoint=x(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=x(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=x(this.htmlElemLine,this.targetElement),this.htmlElemTitle=x(this.htmlElemTitle,this.targetElement)}setUnit(t){this.unit=t,this.drawMeasureLine()}setConversionFactor(t){this.scale=t,this.drawMeasureLine()}setStyle(t){this.style=t,this.drawMeasureLine()}setSelectionReactor(t){A(this.htmlElemStartPoint,t?t.onStartPoint:null),A(this.htmlElemEndPoint,t?t.onEndPoint:null),A(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){T(this.htmlElemStartPoint,t),T(this.htmlElemEndPoint,t),T(this.htmlElemLine,t),T(this.htmlElemTitle,t)}}function k(t,e){return t[e]||e}class M extends y{constructor(t){var e;super(t),this.lineThickness=2,this.press=!1,this.gripingRadius=5,this.firstPoint=null,this.secondPoint=null,this.renameUnitTable={Millimeters:"mm",Centimeters:"cm",Meters:"m",Feet:"ft",Inches:"in",Yards:"yd",Kilometers:"km",Miles:"mi",Micrometers:"µm",MicroInches:"µin",Default:"unit"},this.items=[],this.canvasEvents.push("resize"),this.oldRulerUnit=null!==(e=t.options.rulerUnit)&&void 0!==e?e:"Default",this.optionsChange=this.optionsChange.bind(this)}initialize(){super.initialize(),this.m_overlayElement=document.createElement("div"),this.m_overlayElement.style.background="rgba(0,0,0,0)",this.m_overlayElement.style.position="fixed",this.m_overlayElement.style.zIndex="1",this.m_overlayElement.style.pointerEvents="none",document.body.appendChild(this.m_overlayElement),this.subject.addEventListener("optionschange",this.optionsChange),this.resize()}dispose(){super.dispose(),this.m_overlayElement.remove(),this.subject.removeEventListener("optionschange",this.optionsChange)}updatePreview(){this.items.forEach((t=>t.update()))}resize(){const t=this.m_module.canvas.getBoundingClientRect();this.m_overlayElement.style.top=`${t.top}px`,this.m_overlayElement.style.left=`${t.left}px`,this.m_overlayElement.style.width=`${t.width}px`,this.m_overlayElement.style.height=`${t.height}px`}getSnapPointRadius(){const t=this.getViewer().activeView.viewDcCorners(),e=t.lowerLeft,i=t.upperRight;return i[0]-=e[0],i[1]-=e[1],Math.min(i[0],i[1])/120}start(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);i&&(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint))}drag(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);this.isDragging?i?this.firstPoint?(this.secondPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.secondPoint,!0)):(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint)):(this.secondPoint=null,this.previewMeasureLine.clear(),this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.getViewer().screenToWorld(t,e),!1)):i?this.previewMeasureLine.setStartPoint(i):this.previewMeasureLine.clear()}end(){if(this.firstPoint&&this.secondPoint){const t=this.createMeasureLine();t.setStartPoint(this.firstPoint),t.setEndPoint(this.secondPoint,!0)}this.firstPoint=null,this.secondPoint=null,this.previewMeasureLine.clear()}createNewMeasureIfNeed(){this.previewMeasureLine||(this.previewMeasureLine=this.createMeasureLine())}createMeasureLine(){const t=this.m_module.getViewer(),e=new E(this.m_overlayElement,t,this.m_module);e.lineThickness=this.lineThickness||e.lineThickness;const i=!this.subject.options.rulerUnit||"Default"===this.subject.options.rulerUnit;if(e.setUnit(k(this.renameUnitTable,i?t.getUnit():this.subject.options.rulerUnit)),i)e.setConversionFactor(1);else{const i=this.getKUnitByName(t.getUnit()),s=this.getKUnitByName(this.subject.options.rulerUnit),r=t.getUnitsConversionCoef(i,s);this.conversionFactor=1/r,e.setConversionFactor(this.conversionFactor)}return this.items.push(e),e}optionsChange(t){var e;const i=null!==(e=t.data.rulerUnit)&&void 0!==e?e:"Default";if(this.oldRulerUnit===i)return;this.oldRulerUnit=i;const s=this.m_module.getViewer().getUnit(),r=this.getKUnitByName(i),n=this.getKUnitByName(s);this.items.forEach((t=>{if("Default"===i)t.setUnit(k(this.renameUnitTable,s)),t.setConversionFactor(1);else{t.setUnit(k(this.renameUnitTable,i));const e=this.m_module.getViewer().getUnitsConversionCoef(n,r);this.conversionFactor=1/e,t.setConversionFactor(this.conversionFactor)}}))}getKUnitByName(t){let e=this.m_module.Units.kUserDefined;switch(t){case"Millimeters":e=this.m_module.Units.kMillimeters;break;case"Centimeters":e=this.m_module.Units.kCentimeters;break;case"Meters":e=this.m_module.Units.kMeters;break;case"Feet":e=this.m_module.Units.kFeet;break;case"Inches":e=this.m_module.Units.kInches;break;case"Yards":e=this.m_module.Units.kYards;break;case"Kilometers":e=this.m_module.Units.kKilometers;break;case"Miles":e=this.m_module.Units.kMiles;break;case"Micrometers":e=this.m_module.Units.kMicrometers;break;case"MicroInches":e=this.m_module.Units.kMicroInches}return e}}class F extends y{constructor(t){super(t),this.viewer=void 0,this.multiplier=5,this.speed=1,this.keyPressMap=new Set,this.keydown=this.keydown.bind(this),this.keyup=this.keyup.bind(this),this.lastFrameTS=0,this.animationId=void 0,this.processMovement=this.processMovement.bind(this),this.deltaAngle=Math.PI/3600,this.autoSelect=!0}initialize(){super.initialize(),this.viewer=this.getViewer(),window.addEventListener("keydown",this.keydown,!1),window.addEventListener("keyup",this.keyup,!1),this.oldWCSEnableValue=this.viewer.getEnableWCS(),this.viewer.setEnableWCS(!1);const t=this.viewer.activeView,e=this.getMaxDimension(t);this.speed=e/3e4,this.subject.emitEvent({type:"walkstart"}),this.viewParams=this.getViewParams(),this.setViewParams(this.viewParams);const i=this.viewer.getActiveModel();this.cameraId=i.appendCamera("Camera0"),this.setupCamera(t),i.delete(),this.cameraWalker=new this.m_module.OdTvCameraWalker,this.cameraWalker.setCamera(this.cameraId),this.subject.update(),this.enableZoomWheelPreviousValue=this.subject.options.enableZoomWheel,this.subject.options.enableZoomWheel=!1}dispose(){var t;if(this.oldWCSEnableValue=void 0!==this.oldWCSEnableValue?this.oldWCSEnableValue:this.subject.options.showWCS,this.viewer.setEnableWCS(this.oldWCSEnableValue),super.dispose(),this.keyPressMap.clear(),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0),this.cameraId){const e=this.viewer.getActiveModel();e.removeEntity(this.cameraId),e.delete(),null===(t=this.cameraWalker)||void 0===t||t.delete()}if(this.viewParams){this.setViewParams(this.viewParams);this.viewer.activeView.delete()}this.subject.update(!0),this.subject.options.enableZoomWheel=this.enableZoomWheelPreviousValue}keydown(t){switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"KeyW":case"KeyA":case"KeyS":case"KeyD":case"KeyQ":case"KeyE":this.keyPressMap.add(t.code),this.animationId||this.processMovement(0)}}keyup(t){this.keyPressMap.delete(t.code),this.keyPressMap.size<1&&this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0,this.lastFrameTS=0)}processMovement(t){if(this.animationId=requestAnimationFrame(this.processMovement),0!==this.lastFrameTS){const e=t-this.lastFrameTS,i=this.multiplier*e*this.speed;for(const t of this.keyPressMap)switch(t){case"KeyW":this.cameraWalker.moveForward(i);break;case"KeyS":this.cameraWalker.moveBackward(i);break;case"KeyA":this.cameraWalker.moveLeft(i);break;case"KeyD":this.cameraWalker.moveRight(i);break;case"KeyQ":this.cameraWalker.moveUp(i);break;case"KeyE":this.cameraWalker.moveDown(i)}this.subject.update(),this.subject.emitEvent({type:"changecamera"})}this.lastFrameTS=t}start(t,e){this.dragPosition={x:t,y:e}}drag(t,e){if(this.cameraId&&this.isDragging){const i=t-this.dragPosition.x,s=e-this.dragPosition.y;this.dragPosition={x:t,y:e},0!==i&&this.turnLeft(-i*this.deltaAngle),0!==s&&this.cameraWalker.turnDown(s*this.deltaAngle),this.subject.update(),this.subject.emitEvent({type:"changecamera"})}}turnLeft(t){const e=this.cameraWalker.camera().openObjectAsCamera(),i=this.toVector(e.direction()),s=this.toVector(e.upVector()),r=e.position(),n=this.createMatrix3d();n.setToRotation(t,[0,0,1],r),i.transformBy(n),s.transformBy(n),e.setupCameraByDirection(r,i.toArray(),s.toArray()),e.delete()}setupCamera(t){const e=this.cameraId.openObjectAsCamera(),i=t.viewTarget;e.setDisplayGlyph(!1),e.setDisplayTarget(!1),e.setAutoAdjust(!0),e.setupCamera(t.viewPosition,i,t.upVector),e.setNearClip(!1,1),e.setFarClip(!1,0),e.setViewParameters(t.viewFieldWidth,t.viewFieldHeight,!0);const s=(r=t.lensLength,n=t.viewFieldWidth,o=t.viewFieldHeight,r/42*Math.sqrt(n*n+o*o));var r,n,o;const a=this.toPoint(t.viewTarget),h=this.toPoint(t.viewPosition),l=h.sub(a),d=l.asVector(),c=d.normalize(),u=this.toGeVector(c),g=[u[0]*s,u[1]*s,u[2]*s],f=this.toPoint(t.viewTarget),p=this.toPoint(g),m=f.add(p);e.setupCamera(this.toGePoint(m),t.viewTarget,t.upVector),this.deleteAll([a,h,l,d,c,f,p,m]),e.assignView(t),e.delete()}getMaxDimension(t){const[e,i,s]=t.sceneExtents.max(),[r,n,o]=t.sceneExtents.min(),a=[e-r,i-n,s-o];return Math.max(...a)}}class I extends y{constructor(t){super(t),this.press=!1;const e=this.getViewer().getActiveExtents(),i=e.min(),s=e.max();this.m_size_x=Math.abs(s[0]-i[0])/2,this.m_size_y=Math.abs(s[1]-i[1])/2,this.m_size_z=Math.abs(s[2]-i[2])/2,this.m_center=this.toPoint(e.center()),this.m_normal=this.createNormal();const r=this.getViewer().activeView,n=this.createPlane();n.set(this.toGePoint(this.m_center),this.m_normal),r.addCuttingPlane(n),this.index=r.numCuttingPlanes()-1;const{red:o,green:a,blue:h}=this.subject.options.cuttingPlaneFillColor;r.setEnableCuttingPlaneFill(!0,o,a,h),r.setCuttingPlaneFillPatternEnabled(!0,this.m_module.CuttingPlaneFillStyle.kHorizontalBars,0,0,0),this.m_model=this.getModel(),this.createPreview(),this.deleteAll([e,r,n])}dispose(){super.dispose(),this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.deleteAll([this.m_model,this.m_entity,this.planePreview,this.m_center]),this.m_entity=null,this.planePreview=null,this.subject.update())}createNormal(){return[0,0,0]}handleDelta(t){return t}getPlanePreviewCoordinate(){return[]}start(t,e){this.press=!0,this.m_last=this.screenToWorld(t,e),this.m_click={x:t,y:e}}drag(t,e){if(this.press){const i=this.screenToWorld(t,e),s=this.handleDelta(i.sub(this.m_last)),r=this.m_center;this.m_center=r.add(s);const n=this.m_last;this.m_last=i;const o=this.getViewer().activeView,a=this.createPlane(),h=a.set(this.toGePoint(this.m_center),this.m_normal),l=o.updateCuttingPlane(this.index,a);this.drawPreview(),this.deleteAll([o,a,r,s,n,h,l]);const d=this.getViewer().getActiveDevice();d.invalidate(d.getSize())}}end(t,e){if(this.press=!1,t===this.m_click.x&&e===this.m_click.y){this.m_normal=[-1*this.m_normal[0],-1*this.m_normal[1],-1*this.m_normal[2]];const t=this.getViewer().activeView,e=this.createPlane();e.set(this.toGePoint(this.m_center),this.m_normal),t.updateCuttingPlane(this.index,e),this.deleteAll([t,e,this.m_last]);const i=this.getViewer().getActiveDevice();i.invalidate(i.getSize())}}createPreview(){this.m_entity=this.m_model.appendEntity("&CuttingPlanePreview");const t=this.m_module.GeometryTypes,e=new this.m_module.OdTvTransparencyDef,i=new this.m_module.OdTvColorDef(112,112,112);e.setValue(.9);const s=this.m_entity.openObject();s.setColor(i,t.kFaces.value),i.setColor(112,112,112),s.setColor(i,t.kEdges.value),s.setLineWeight(5),s.setTransparency(e,t.kFaces),e.setValue(1),s.setTransparency(e,t.kEdges),this.planePreview=s.appendPolygon(this.getPlanePreviewCoordinate());const r=this.planePreview.openAsPolygon();r.setFilled(!0),this.deleteAll([e,i,s,r,t]),this.subject.syncOverlay()}drawPreview(){const t=this.planePreview.openAsPolygon();t.setPoints(this.getPlanePreviewCoordinate()),this.deleteAll([t]),this.subject.syncOverlay()}}class R extends I{createNormal(){return[1,0,0]}handleDelta(t){return t.y=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z+this.m_size_z,this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z+this.m_size_z]}}class D extends I{createNormal(){return[0,1,0]}handleDelta(t){return t.x=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z,this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z]}}class O extends I{createNormal(){return[0,0,1]}handleDelta(t){return t.x=0,t.y=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z,this.m_center.x-this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z]}}class L{constructor(t,e,i,s){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=s}beginAction(t,e){this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};this.getViewer().activeView.delete(),this._beginInteractivity()}action(t,e){var i,s;const r=this.getViewer().activeView,n=r.vportRect,o=Math.max(Math.abs(n[2]-n[0]),Math.abs(n[3]-n[1])),a=(this.m_startPoint.x-t)*Math.PI/o,h=(this.m_startPoint.y-e)*Math.PI/o;this.m_startPoint.x=t,this.m_startPoint.y=e;const l=h,d=a,c={position:r.viewPosition,target:r.viewTarget,upVector:r.upVector,viewFieldWidth:r.viewFieldWidth,viewFieldHeight:r.viewFieldHeight,perspective:r.perspective};r.delete();const u=this.getSideVector(c);0!==l&&this.calculateXOrbit(c,-l,u),0!==d&&this.calculateYOrbit(c,d,u),u.delete();const g=this.getViewer().getActiveTvExtendedView();g.setView(c.position,c.target,c.upVector,c.viewFieldWidth,c.viewFieldHeight,c.perspective),g.delete(),null===(s=null===(i=this._subject.activeDragger())||void 0===i?void 0:i.updatePreview)||void 0===s||s.call(i),this._subject.emitEvent({type:"orbit"}),this._subject.emitEvent({type:"changecamera"})}endAction(){this._endInteractivity()}getSideVector(t){const e=this.toVector(t.upVector),i=this.toPoint(t.target),s=this.toPoint(t.position),r=i.sub(s),n=r.asVector(),o=e.crossProduct(n),a=o.normalize();return this.deleteAll([r,e,i,s,n,o]),a}calculateXOrbit(t,e,i){{const s=this.toPoint(t.position),r=this.toPoint(this.m_viewCenter),n=s.rotateByBasePoint(e,i,r);t.position=n.toArray(),this.deleteAll([s,r,n])}{const s=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),n=s.rotateByBasePoint(e,i,r);t.target=n.toArray(),this.deleteAll([s,r,n])}{const e=this.toPoint(t.position),s=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),n=s.sub(e),o=n.asVector(),a=o.crossProduct(i),h=a.normalize();t.upVector=h.toArray(),this.deleteAll([e,s,r,n,o,a,h])}}calculateYOrbit(t,e,i){{const i=this.toPoint(t.position),s=this.toPoint(this.m_viewCenter),r=this.toVector(this._m_module.Vector3d.kZAxis),n=i.rotateByBasePoint(e,r,s);t.position=n.toArray(),this.deleteAll([r,i,s,n])}{const i=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),r=this.toVector(this._m_module.Vector3d.kZAxis),n=i.rotateByBasePoint(e,r,s);t.target=n.toArray(),this.deleteAll([r,i,s,n])}{const s=this.toVector(this._m_module.Vector3d.kZAxis),r=this.toPoint(t.target),n=this.toPoint(t.position),o=i.rotateBy(e,s),a=r.sub(n),h=a.asVector(),l=h.crossProduct(o),d=l.normalize();t.upVector=d.toArray(),this.deleteAll([s,r,n,o,a,h,l,d])}}getCenter(){const t=this.getViewer();let e;const i=t.getSelected();if(i.isNull()||0===i.numItems())e=t.getActiveExtents().center();else{const t=i.getIterator();let s,r,n;for(;!t.done();t.step())r=t.getEntity(),s=r.getWCSExtents(),n?n.addExt(s):n=s;e=n.center(),n.delete(),t.delete()}return e}getViewer(){return this._m_module.getViewer()}toVector(t){return this._m_module.Vector3d.createFromArray(t)}toPoint(t){return this._m_module.Point3d.createFromArray(t)}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}}class V extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new L(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity)}start(t,e){this.press=!0,this._orbitAction.beginAction(t,e)}setDefaultViewParams(){const t=this.getViewer().getActiveTvExtendedView();t.setView(this.startCameraParams.position,this.startCameraParams.target,this.startCameraParams.upVector,this.startCameraParams.viewFieldWidth,this.startCameraParams.viewFieldHeight,this.startCameraParams.perspective),t.delete()}drag(t,e){this.press&&this._orbitAction.action(t,e)}end(){this.press=!1,this._orbitAction.endAction()}}class z{constructor(t,e,i,s,r,n){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=s,this._getViewParams=r,this._setViewParams=n}beginAction(t,e,i,s){this._m_start=this.screenToWorld(t,e),this._deltaScreenPosition={x:i,y:s},this._beginInteractivity()}action(t,e,i,s){var r,n;const{Vector3d:o}=this._m_module,a=this._getViewParams(),h=this.screenToWorld(t,e),l=this._m_start.sub(h).asVector(),d=o.createFromArray(a.target),c=d.add(l);a.target=c.toArray();const u=o.createFromArray(a.position),g=u.add(l);a.position=g.toArray(),this._setViewParams(a),d.delete(),c.delete(),u.delete(),g.delete(),null===(n=null===(r=this._subject.activeDragger())||void 0===r?void 0:r.updatePreview)||void 0===n||n.call(r),this._subject.emitEvent({type:"pan",x:i,y:s,dX:i-this._deltaScreenPosition.x,dY:s-this._deltaScreenPosition.y}),this._subject.emitEvent({type:"changecamera"}),this._deltaScreenPosition={x:i,y:s}}endAction(){this._endInteractivity()}screenToWorld(t,e){return this._m_module.Point3d.createFromArray(this._m_module.getViewer().screenToWorld(t,e))}}class G extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new z(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams)}start(t,e,i,s){this.press=!0,this._panAction.beginAction(t,e,i,s)}drag(t,e,i,s){this.press&&this._panAction.action(t,e,i,s)}end(t,e){this.press=!1,this._panAction.endAction()}}class N{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i,s,r){var n,o;this._m_module.getViewer().zoomAt(i,t,e),this._subject.deviceAutoRegeneration(),null===(o=null===(n=this._subject.activeDragger())||void 0===n?void 0:n.updatePreview)||void 0===o||o.call(n),this._subject.emitEvent({type:"zoomat",data:i,x:s,y:r}),this._subject.emitEvent({type:"changecamera"})}}class W extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new N(this.m_module,this.subject)}start(t,e,i=0,s=0){this.press=!0,this.pressX=t,this.pressY=e,this.absoluteX=i,this.absoluteY=s,this.prevY=e,this.beginInteractivity()}drag(t,e){const i=e-this.prevY;if(this.prevY=e,this.press&&Math.abs(i)>=1e-5){const t=.975,e=i>0?1/t:t;this._zoomAction.action(this.pressX,this.pressY,e,this.absoluteX,this.absoluteY)}}end(){this.press=!1,this.endInteractivity()}}class U extends y{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new N(this.m_module,this.subject),this._endInteractivityTimeOutId=void 0,this._isEnableInteractivityMode=!1}wheel(t){if(!this.subject.options.enableZoomWheel)return;(t=t||window.event).preventDefault();const e=this.subject.options.reverseZoomWheel?.925:1/.925,i=this.subject.options.reverseZoomWheel?1/.925:.925;if(this.getViewer()){const s=t.deltaY>0?e:i;this._zoomAction.action(t.offsetX*window.devicePixelRatio,t.offsetY*window.devicePixelRatio,s,t.offsetX,t.offsetY),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this.subject.update(!0),this._endInteractivityTimeOutId=setTimeout((()=>{this._endInteractivityTimeOutId=void 0,this.endInteractivity(),this._isEnableInteractivityMode=!1}),100)}}dispose(){this._endInteractivityTimeOutId&&(clearTimeout(this._endInteractivityTimeOutId),this.endInteractivity(),this._isEnableInteractivityMode=!1)}}class B{constructor(){this.m_start=[0,0,0],this.m_end=[0,0,0],this.m_model=null}createPoint3d(){return new this.m_module.Point3d}init(t,e){this.m_module=t,this.m_model=e}getViewer(){return this.m_module.getViewer()}setValue(t){this.m_end=t,this.draw()}setStartPoint(t){this.m_start=t,this.m_end=t,this.draw()}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}draw(){const t=this.getViewer().activeView,e=t.viewingMatrix,i=[];i.push(this.m_start),i.push(this.createPoint3d()),i.push(this.m_end),i.push(this.createPoint3d());const s=this.createPoint3d();s.set(this.m_start[0],this.m_start[1],this.m_start[2]);const r=this.createPoint3d();r.set(this.m_end[0],this.m_end[1],this.m_end[2]),s.transformBy(e),r.transformBy(e),i[1].x=s.x,i[3].x=r.x,i[1].y=r.y,i[3].y=s.y,i[1].z=i[3].z=r.z;const n=t.eyeToWorldMatrix;if(i[1].transformBy(n),i[3].transformBy(n),this.m_entity)this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(i));else{this.m_entity=this.m_model.appendEntity("");const t=this.m_entity.openObject();t.setColor(112,112,112),t.setLineWeight(2),this.m_frame=t.appendPolygon(this.toDoubleArray(i)),t.delete()}}clear(){this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.m_entity=null)}}class j extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new B,this.m_frame.init(this.m_module,this.getModel())}start(t,e){this.press=!0,this.m_minX=t,this.m_minY=e;const i=this.screenToWorld(t,e);this.m_frame.setStartPoint(i)}drag(t,e){if(this.press){this.m_maxX=t,this.m_maxY=e;const i=this.screenToWorld(t,e);this.m_frame.setValue(i)}}end(t,e){this.press=!1,this.m_maxX=t,this.m_maxY=e,this.m_minX!==this.m_maxX&&this.m_minY!==this.m_maxY&&(this.m_frame.clear(),this.getViewer().zoomWindow(this.m_minX,this.m_minY,this.m_maxX,this.m_maxY))}}class H extends y{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.maxPolarAngle=Math.PI/2,this.minPolarAngle=0}start(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};const i=this.getViewer().activeView;this.startCameraParams=this.getViewParams();const s=i.vportRect;this.m_delta=Math.max(s[1]-s[0],s[2]-s[3]),this.beginInteractivity()}setDefaultViewParams(){this.setViewParams(this.startCameraParams)}drag(t,e){if(this.press){let i=t-this.m_startPoint.x,s=e-this.m_startPoint.y;i*=Math.PI/this.m_delta,s*=Math.PI/this.m_delta,this.setDefaultViewParams();const{Vector3d:r,Matrix3d:n}=this.m_module,o=r.createFromArray(this.startCameraParams.target),a=r.createFromArray(this.startCameraParams.position).sub(o),h=a.normalize(),l=new n;l.setToIdentity();const d=new n;d.setToIdentity();const c=r.createFromArray([h.x,h.y,h.z]),u=r.createFromArray(this.startCameraParams.upVector),g=c.crossProduct(u);let f=r.createFromArray([c.x,c.y,0]);f.length()<=1e-5?f.set(-g.y,g.x,0):f=f.normalize();i-=Math.sign(f.dotProduct(r.createFromArray([-1,0,0])))*f.angleTo(r.createFromArray([0,1,0]));let p=r.createFromArray([h.x,h.y,0]),m=0;p.length()<=1e-5?m=-h.z*Math.PI/2:(p=p.normalize(),m=-p.angleTo(h)),s-=m,l.setToRotation(-i,[0,0,1],[0,0,0]);const _=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,s));d.setToRotation(_,[1,0,0],[0,0,0]);const v=l.postMultBy(d);let y=r.createFromArray([0,1,0]).transformBy(v);const w=r.createFromArray([0,0,1]).transformBy(v);y.setLength(a.length()),y=o.add(y);const x=this.getViewParams();x.position=y.toArray(),x.upVector=w.toArray(),this.setViewParams(x)}}end(){this.press=!1,this.endInteractivity()}getCenter(){const t=this.getViewer();let e=t.getActiveExtents();const i=t.getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator(),s=t.getEntity();if(1===s.getType()){const t=s.openObject();e.delete(),e=t.getExtents(),t.delete()}else if(2===s.getType()){const t=s.openObjectAsInsert(),i=t.getExtents();e.delete(),e=i.ext,i.delete(),t.delete()}t.delete()}const s=e.center();return e.delete(),s}}const Y=o("visualizejs");Y.registerDragger("Pan",(t=>new G(t))),Y.registerDragger("Orbit",(t=>new V(t))),Y.registerDragger("Zoom",(t=>new W(t))),Y.registerDragger("ZoomWindow",(t=>new j(t))),Y.registerDragger("ZoomWheel",(t=>new U(t))),Y.registerDragger("OrbitAroundBuilding",(t=>new H(t))),Y.registerDragger("MeasureLine",(t=>new M(t))),Y.registerDragger("CuttingPlaneXAxis",(t=>new R(t))),Y.registerDragger("CuttingPlaneYAxis",(t=>new D(t))),Y.registerDragger("CuttingPlaneZAxis",(t=>new O(t))),Y.registerDragger("Walk",(t=>new F(t)));const X=(t,e,i)=>{const{translate:s,scale:r,rotation:n}=t,o=new i.Matrix3d;o.setTranslation([s.x,s.y,s.z]);const a=new i.Matrix3d;a.setToRotation(n.angle,[n.x,n.y,n.z],e);const h=new i.Matrix3d;return h.setToScaling(r,e),a.postMultBy(o).postMultBy(h)};function K(t,e=0){if(!t.visualizeJs)return;t.visViewer().explode(e),t.update(),t.emitEvent({type:"explode",data:e})}function q(t,e=""){if(!t.visualizeJs)return;const i=t.visLib(),s=t.visViewer(),r=i.DefaultViewPosition;s.setDefaultViewPositionWithAnimation(r[e]),t.update(),t.emit({type:"viewposition",data:e})}function J(t){return"$"===t.getName()[0]}const Z=s("visualizejs");Z.registerCommand("applyModelTransform",(function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const s=t.visLib(),r=t.visViewer(),n=r.getModelIterator();for(;!n.done();n.step()){const t=n.getModel(),i=e.getModelTransformMatrix(t.getDatabaseHandle());if(i){const e=t.getExtents();e.transformBy(t.getUnitsMatrix());const r=X(i,e.center(),s);t.setModelingMatrix(r,!0)}}n.delete(),null===(i=r.clearViewExtentsCache)||void 0===i||i.call(r),t.update()})),Z.registerCommand("clearMarkup",(function(t){t.clearOverlay()})),Z.registerCommand("clearSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().unselect(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),Z.registerCommand("clearSlices",(function(t){t.clearSlices()})),Z.registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){var s;return t.visualizeJs&&(null===(s=t.canvas)||void 0===s?void 0:s.toDataURL(e,i))||""})),Z.registerCommand("explode",K),Z.registerCommand("collect",(function(t){K(t,0)})),Z.registerCommand("getDefaultViewPositions",(function(t){if(!t.visualizeJs)return[];const e=t.visLib().DefaultViewPosition;return Object.keys(e).filter((t=>"values"!==t))})),Z.registerCommand("getModels",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getModelIterator();for(;!i.done();i.step()){const t=i.getModel();"$"!==t.getName()[0]&&e.push(t.getDatabaseHandle())}return i.delete(),e})),Z.registerCommand("getSelected",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator();for(;!t.done();t.step()){const i=t.getEntity(),s=1===i.getType()?i.openObject():2===i.getType()?i.openObjectAsInsert():null;if(s){const t=s.getNativeDatabaseHandle();"-1"!==t&&e.push(t),s.delete()}}t.delete()}return e})),Z.registerCommand("hideSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().hideSelectedObjects(!1),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),Z.registerCommand("isolateSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().isolateSelectedObjects(!1),t.update(),t.emitEvent({type:"isolate"})})),Z.registerCommand("regenerateAll",(function(t){if(!t.visualizeJs)return;t.visViewer().regenAll(),t.update(),t.emit({type:"regenerateall"})})),Z.registerCommand("resetView",(function(t){t.visualizeJs&&(t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"}))})),Z.registerCommand("selectModel",(function(t,e){if(!t.visualizeJs)return;const i=t.visViewer(),s=i.activeView,r=i.getModelIterator();for(;!r.done();r.step()){const n=r.getModel();if(n.getDatabaseHandle()===e){const e=s.selectCrossing([0,9999,9999,0],n);i.setSelected(e);const r=t.getSelected();t.update(),t.emitEvent({type:"select",data:e,handles:r}),e.delete();break}}r.delete()})),Z.registerCommand("setActiveDragger",(function(t,e=""){t.setActiveDragger(e)})),Z.registerCommand("setDefaultViewPosition",q),Z.registerCommand("setMarkupColor",(function(t,e=255,i=0,s=0){t.markup.setMarkupColor(e,i,s)})),Z.registerCommand("setSelected",(function(t,e=[]){if(!t.visualizeJs)return;const i=t.visLib(),s=t.visViewer(),r=new i.OdTvSelectionSet;null==e||e.forEach((t=>{const e=s.getEntityByOriginalHandle(t+"");e.isNull()||r.appendEntity(e)})),s.setSelected(r),t.update(),t.emitEvent({type:"select",data:r,handles:e}),r.delete()})),Z.registerCommand("showAll",(function(t){if(!t.visualizeJs)return;t.visViewer().unisolateSelectedObjects(!1),t.update(),t.emitEvent({type:"showall"})})),Z.registerCommand("zoomToExtents",(function(t,e=!1,i=t.options.cameraAnimation){if(!t.visualizeJs)return;const s=t.visViewer(),r=s.getEnableAnimation();s.setEnableAnimation(i),s.zoomExtents(e),s.update(),s.setEnableAnimation(r),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),Z.registerCommand("zoomToObjects",(function(t,e=[]){var i;if(!t.visualizeJs)return;const s=t.visLib(),r=t.visViewer(),n=new s.OdTvSelectionSet;e.forEach((t=>{const e=r.getEntityByOriginalHandle(t+"");e.isNull()||n.appendEntity(e)})),null===(i=r.zoomToObjects)||void 0===i||i.call(r,n),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"}),n.delete()})),Z.registerCommand("zoomToSelected",(function(t){var e;if(!t.visualizeJs)return;const i=t.visViewer(),s=i.getSelected();null===(e=i.zoomToObjects)||void 0===e||e.call(i,s),t.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),Z.registerCommand("autoTransformAllModelsToCentralPoint",(async function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const s=t.visLib(),r=t.visViewer(),n=r.getActiveExtents().center(),o=r.getModelIterator();for(;!o.done();o.step()){const t=o.getModel();if(!J(t)){const i=t.getExtents(),r=t.getUnitsMatrix();i.transformBy(t.getUnitsMatrix());const o=t.getUnitsMatrix().invert(),a=i.center(),h=1,l=new s.Matrix3d,d=new s.Matrix3d;d.setTranslation([n[0]-a[0],n[1]-a[1],n[2]-a[2]]),l.setToScaling(h,n);const c=o.postMultBy(l).postMultBy(d).postMultBy(r),u=c.scale(),g={translate:{x:c.get(0,3)-(1-u)*a[0],y:c.get(1,3)-(1-u)*a[1],z:c.get(2,3)-(1-u)*a[2]},rotation:{x:0,y:0,z:1,angle:0},scale:u},f=X(g,a,s);t.setModelingMatrix(f,!0),n[0]+=Math.abs(i.max()[0]-i.min()[0])*u,await e.setModelTransformMatrix(t.getDatabaseHandle(),g)}t.delete()}o.delete(),null===(i=r.clearViewExtentsCache)||void 0===i||i.call(r),t.update()})),Z.registerCommand("k3DViewTop",(t=>q(t,"k3DViewTop"))),Z.registerCommand("k3DViewBottom",(t=>q(t,"k3DViewBottom"))),Z.registerCommand("k3DViewLeft",(t=>q(t,"k3DViewLeft"))),Z.registerCommand("k3DViewRight",(t=>q(t,"k3DViewRight"))),Z.registerCommand("k3DViewFront",(t=>q(t,"k3DViewFront"))),Z.registerCommand("k3DViewBack",(t=>q(t,"k3DViewBack"))),Z.registerCommand("k3DViewSE",(t=>q(t,"k3DViewSE"))),Z.registerCommand("k3DViewSW",(t=>q(t,"k3DViewSW"))),Z.registerCommand("k3DViewNE",(t=>q(t,"k3DViewNE"))),Z.registerCommand("k3DViewNW",(t=>q(t,"k3DViewNW"))),Z.registerCommandAlias("clearMarkup","clearOverlay"),Z.registerCommandAlias("clearSelected","unselect"),Z.registerCommandAlias("zoomToExtents","zoomExtents");class ${constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Q{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this.viewer.setSize(e,i)},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class tt{constructor(t){this.viewer=t,this.zoomWheelDragger=new U(t),this.zoomWheelDragger.name="ZoomWheel",this.zoomWheelDragger.initialize()}dispose(){this.zoomWheelDragger.dispose(),this.zoomWheelDragger=void 0}}var et;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(et||(et={}));class it extends y{get isSingleTouchEnabled(){return this._isSingleTouchEnabled}set isSingleTouchEnabled(t){this._isSingleTouchEnabled=t}constructor(t){super(t),this._previousEvents=new Map,this._currentEvents=new Map,this._lastGestureAction=et.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new L(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new z(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new N(this.m_module,this.subject)}getMiddlePoint(t){if(2!==t.size)return;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),s=this.relativeCoords(t.get(e[1]));return{x:Math.floor((i.x+s.x)/2),y:Math.floor((i.y+s.y)/2)}}getFirstPoint(t){if(t.size<1)return;const e=this.getKeys(t);return this.relativeCoords(t.get(e[0]))}getDistance(t){if(2!==t.size)return-1;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),s=this.relativeCoords(t.get(e[1]));return Math.hypot(i.x-s.x,i.y-s.y)}updateEvent(t){const e=!this._currentEvents.get(t.pointerId);if(e&&2===this._currentEvents.size)return;const i=this._currentEvents.get(t.pointerId);i&&this._previousEvents.set(i.pointerId,i),this._currentEvents.set(t.pointerId,t),e&&(this._initialDistance=this.getDistance(this._currentEvents))}removeEvent(t){this._currentEvents.delete(t.pointerId),this._previousEvents.delete(t.pointerId),this._currentEvents.size<2&&(this._initialDistance=-1)}getKeys(t){return Array.from(t.keys())}analyzeGesture(){if(2===this._currentEvents.size){const t=this.getDistance(this._currentEvents),e=this.getDistance(this._previousEvents);Math.abs(this._initialDistance-t)<=this._maxInitialDistanceDifference?this.executePanAction(this.getMiddlePoint(this._currentEvents)):-1!==e&&t!==e&&this.executeZoomAction(t,e)}else 1===this._currentEvents.size&&this.isSingleTouchEnabled&&this.executeOrbitAction(this.getFirstPoint(this._currentEvents))}executeZoomAction(t,e){this._lastGestureAction!==et.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Zoom,y.isGestureActive=!0);const i=1+(t-e)/700,s=this.getMiddlePoint(this._currentEvents);this._zoomAction.action(s.x,s.y,i,s.x,s.y),this.subject.update()}executePanAction(t){this._lastGestureAction!==et.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Pan,y.isGestureActive=!0,this._panAction.beginAction(t.x,t.y,t.x,t.y)),this._panAction.action(t.x,t.y,t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==et.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=et.Orbit,y.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===et.Orbit&&this._orbitAction.endAction(),t===et.Pan&&this._panAction.endAction(),y.isGestureActive=!1}needIgnoreEvent(t){return!this.subject.options.enableZoomWheel||!this.subject.options.enableGestures||!this.eventIsTouchEvent(t)}eventIsTouchEvent(t){return"touch"===t.pointerType||""===t.pointerType}pointerdown(t){this.needIgnoreEvent(t)||this.updateEvent(t)}pointermove(t){this.needIgnoreEvent(t)||(this.updateEvent(t),this.analyzeGesture())}pointerup(t){this.needIgnoreEvent(t)||(this.removeEvent(t),this._currentEvents.size<2&&(this.executeEndAction(this._lastGestureAction),y.isGestureActive=!1),this._lastGestureAction=et.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}class st{constructor(t){this.viewer=t,this.gestureManager=new it(t),this.gestureManager.initialize()}dispose(){this.gestureManager.dispose(),this.gestureManager=void 0}}const rt=l("visualizejs");rt.registerComponent("ResizeCanvasComponent",(t=>new Q(t))),rt.registerComponent("RenderLoopComponent",(t=>new $(t))),rt.registerComponent("ZoomWheelComponent",(t=>new tt(t))),rt.registerComponent("GestureManagerComponent",(t=>new st(t)));class nt{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}load(t,e){if("string"==typeof t){const i=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal});return fetch(i).then((t=>{if(!t.ok)throw new Error(`Failed to fetch "${t.url}", status ${t.status}`);const i=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),s=parseInt(i||"",10)||0,r=s>0,n=new ReadableStream({async start(i){const n=t.body.getReader();let o=0;try{for(;;){const{done:t,value:a}=await n.read();if(t)break;e&&(o+=a.byteLength,e(new ProgressEvent("progress",{lengthComputable:r,loaded:o,total:s}))),i.enqueue(a)}i.close()}catch(t){i.error(t)}}});return new Response(n)})).then((t=>t.arrayBuffer()))}if(t instanceof globalThis.File)return new Promise(((i,s)=>{const r=new FileReader;r.onload=()=>i(r.result),r.onerror=()=>s(r.error),r.onprogress=e,r.readAsArrayBuffer(new Blob([t]))}));if(e){const i=t.byteLength;e(new ProgressEvent("progress",{lengthComputable:i>0,loaded:i,total:i}))}return Promise.resolve(t)}}class ot extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/vsf$/i.test(e)}async load(t,e,i){if(!this.viewer.visualizeJs)return this;const s=this.viewer.visViewer(),r=new nt;r.setRequestHeader(i.requestHeader),r.setWithCredentials(i.withCredentials),r.setAbortSignal(this.abortController.signal);const n=await r.load(t,(e=>{const{lengthComputable:i,loaded:s,total:r}=e,n=i?s/r:1;this.viewer.emitEvent({type:"geometryprogress",data:n,file:t})})),o=new Uint8Array(n);if(!this.viewer.visualizeJs)return this;try{s.parseFile(o)}catch(t){throw console.error("VSF parse error.",t),t}return this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(!0),this.viewer.emitEvent({type:"databasechunk",data:o,file:t}),this}}class at extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.data$/i.test(t.database)}async load(t,e){if(!this.viewer.visualizeJs)return this;const i=this.viewer.visViewer(),s=[t.database,...t.geometry];console.time("File load time");for(let e=0;e<s.length;e++){const r=s[e],n=i=>{const r=(e+i)/s.length;this.viewer.emitEvent({type:"geometryprogress",data:r,file:t.file,model:t})},o=await t.downloadResource(r,n,this.abortController.signal),a=new Uint8Array(o);if(!this.viewer.visualizeJs)return this;try{i.parseStream(a)}catch(t){throw console.error("VSF parse error.",t),t}0===e?(this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(!0),this.viewer.emitEvent({type:"databasechunk",data:a,file:t.file,model:t})):(this.viewer.update(),this.viewer.emitEvent({type:"geometrychunk",data:a,file:t.file,model:t}))}return console.timeEnd("File load time"),this}}class ht extends d{constructor(t){super(),this.viewer=t}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/vsfx$/i.test(e)}async load(t,e,i){if(!this.viewer.visualizeJs)return this;const s=this.viewer.visViewer(),r=new nt;r.setRequestHeader(i.requestHeader),r.setWithCredentials(i.withCredentials),r.setAbortSignal(this.abortController.signal);const n=await r.load(t,(e=>{const{lengthComputable:i,loaded:s,total:r}=e,n=i?s/r:1;this.viewer.emitEvent({type:"geometryprogress",data:n,file:t})})),o=new Uint8Array(n);if(!this.viewer.visualizeJs)return this;try{s.parseVsfx(o)}catch(t){throw console.error("VSFX parse error.",t),t}return this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(!0),this.viewer.emitEvent({type:"databasechunk",data:o,file:t}),this}}class lt extends d{constructor(t){super(),this.viewer=t}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.vsfx$/i.test(t.database)&&!1===this.viewer.options.enableStreamingMode}async load(t,e,i={}){if(!this.viewer.visualizeJs)return Promise.resolve(this);const s=this.viewer.visViewer();console.time("File load time");const r=await t.downloadResource(t.database,(e=>{this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t})}),this.abortController.signal),n=new Uint8Array(r);if(!this.viewer.visualizeJs)return this;try{s.parseVsfx(n)}catch(t){throw console.error("VSFX parse error.",t),t}return this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(!0),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t}),console.timeEnd("File load time"),this}}var dt;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(dt||(dt={}));class ct{constructor(){this.lastUpdate=0,this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==dt.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===dt.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class ut extends d{constructor(t){super(),this.viewer=t}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&/.vsfx$/i.test(t.database)&&!0===this.viewer.options.enableStreamingMode&&!1===this.viewer.options.enablePartialMode&&!/.rcs$/i.test(t.name)}async load(t){if(!this.viewer.visualizeJs)return this;const e=this.viewer.visLib(),i=this.viewer.visViewer(),s=new ct;s.initialize(this.viewer);let r=!1;return console.time("File load time"),await t.downloadResource(t.database,((n,o)=>{if(!this.viewer.visualizeJs)return;let a;try{a=i.parseVsfx(o)}catch(t){throw console.error("VSFX parse error.",t),t}this.viewer.emitEvent({type:"geometryprogress",data:n,file:t.file,model:t});let h=!1;(a===e.DatabaseStreamStatus.ReadyServiceData||a===e.DatabaseStreamStatus.Complete&&!r)&&(r=!0,h=!0),h?(this.viewer.syncOptions(),this.viewer.syncOverlay(),s.update(dt.kForce),this.viewer.emitEvent({type:"databasechunk",data:o,file:t.file,model:t})):(s.update(dt.kDelay),this.viewer.emitEvent({type:"geometrychunk",data:o,file:t.file,model:t}))}),this.abortController.signal),s.update(dt.kNormal),console.timeEnd("File load time"),Promise.resolve(this)}}class gt extends d{constructor(t){super(),this.viewer=t,this.abortControllerForRequestMap=new Map}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.vsfx$/i.test(t.database)&&(!0===this.viewer.options.enablePartialMode||/.rcs$/i.test(t.name))}async load(t,e){if(!this.viewer.visualizeJs)return this;const i=this.viewer.visViewer();let s=!1;const r=new Map;let n=0;const o=()=>clearTimeout(n),a=new AbortController;this.abortControllerForRequestMap.set(0,a);const h=new ct;h.initialize(this.viewer),i.memoryLimit=this.viewer.options.memoryLimit;const l=(e,s,r=0)=>{if(!this.viewer.visualizeJs)return;let n;try{n=i.parseVsfxInPartialMode(r,s)}catch(t){throw console.error("VSFX parse error.",t),t}this.viewer.emitEvent({type:"geometryprogress",data:e,file:t.file,model:t}),n?(this.viewer.syncOptions(),this.viewer.syncOverlay(),h.update(dt.kForce),this.viewer.emitEvent({type:"databasechunk",data:s,file:t.file,model:t})):(h.update(dt.kDelay),this.viewer.emitEvent({type:"geometrychunk",data:s,file:t.file,model:t}))},d=async(e,s,r)=>{const n=new AbortController;this.abortControllerForRequestMap.set(s,n);try{await t.downloadResourceRange(e,s,r,l,n.signal)}catch(e){this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}finally{r.forEach((t=>i.onRequestResponseComplete(t.requestId))),this.abortControllerForRequestMap.delete(s),h.update(dt.kNormal)}},c=(t,e)=>{const i=[];for(let s=0;s<e.size();s++){const r=e.get(s);i.push({requestId:t,begin:Number(r.begin),end:Number(r.end)-1}),r.delete()}return i},u={onServicePartReceived:t=>{t&&(s=!0,this.abortController.abort())},onRequest:(e,i)=>{const s=c(e,i);d(t.database,e,s)},onFullLoaded:()=>{h.update(dt.kNormal)},onRequestResponseParsed:t=>{this.abortControllerForRequestMap.delete(t),h.update(dt.kNormal)},onRequestAborted:t=>{const e=this.abortControllerForRequestMap.get(t);e&&e.abort()},onRequestResourceFile:(e,i,s)=>{const h=`${t.fileId}${t.file.type}`,l=c(e,s);let u=[],g=0;const f=r.get(h);return f&&(u=f.ranges,g=f.number),g<=5?(r.set(h,{ranges:[],number:g+1}),void d(h,e,l)):(u=u.concat(l),u.length>=50?(n&&(window.clearTimeout(n),n=0),r.set(h,{ranges:[],number:g+1}),void d(h,e,u)):(r.set(h,{ranges:u,number:g+1}),void(0===n&&(n=window.setTimeout((()=>{a.signal.removeEventListener("abort",o),n=0,r.forEach(((t,i)=>{t.ranges.length>0&&(r.set(i,{ranges:[],number:t.number+1}),d(i,e,t.ranges))}))}),250),a.signal.addEventListener("abort",o,{once:!0})))))}};i.attachPartialResolver(u);try{await t.downloadResource(t.database,l,this.abortController.signal)}catch(t){if(window.clearTimeout(n),!s)throw t}return this}cancel(){super.cancel(),this.abortControllerForRequestMap.forEach((t=>t.abort()))}}const ft=g("visualizejs");ft.registerLoader("vsf-file",(t=>new ot(t))),ft.registerLoader("vsf-cloud",(t=>new at(t))),ft.registerLoader("vsfx-file",(t=>new ht(t))),ft.registerLoader("vsfx-cloud",(t=>new lt(t))),ft.registerLoader("vsfx-cloud-streaming",(t=>new ut(t))),ft.registerLoader("vsfx-cloud-partial",(t=>new gt(t)));class pt{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}function mt(t,e){if(window.getVisualizeLibInst){const e=window.getVisualizeLibInst.script;if(e){if(e.src===t)return Promise.resolve(e);e.remove()}delete window.getVisualizeLibInst}return function(t,e={}){return new Promise(((i,s)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.crossOrigin=e.crossOrigin,r.onload=()=>i(r),r.onerror=()=>{r.remove(),s(new Error(`GET ${t} failed to load script`))},document.body.appendChild(r)}))}(t,e)}var _t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function vt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yt,wt={exports:{}},xt={},bt={},St={};function Ct(){return yt||(yt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==_t?_t:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.18",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(St)),St}var Pt,At={};function Tt(){return Pt||(Pt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Ct();class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,n=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=s,this.m[1]=r,this.m[2]=n,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,s=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,n=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=s,this.m[2]=r,this.m[3]=n,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],s=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],n=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=s,this.m[3]=r,this.m[4]=n,this.m[5]=o,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,s=-this.m[2]*t,r=this.m[0]*t,n=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=s,this.m[3]=r,this.m[4]=n,this.m[5]=o,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],s=this.m[2],r=this.m[3],n=e*r-i*s,o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),o.scaleX=t,o.scaleY=n/t,o.skewX=(e*s+i*r)/n,o.skewY=0}else if(0!=s||0!=r){const t=Math.sqrt(s*s+r*r);o.rotation=Math.PI/2-(r>0?Math.acos(-s/t):-Math.acos(s/t)),o.scaleX=n/t,o.scaleY=t,o.skewX=0,o.skewY=(e*s+i*r)/n}return o.rotation=t.Util._getRotation(o.rotation),o}}t.Transform=i;const s=Math.PI/180,r=180/Math.PI,n="Konva error: ",o={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},a=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const s=t.Util.createImageElement();s.onload=function(){i(s)},s.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in o?(e=o[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=a.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=o[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),s=Number(i[0])/360,r=Number(i[1])/100,n=Number(i[2])/100;let o,a,h;if(0===r)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=n<.5?n*(1+r):n+r-n*r;const l=2*n-o,d=[0,0,0];for(let t=0;t<3;t++)a=s+1/3*-(t-1),a<0&&a++,a>1&&a--,h=6*a<1?l+6*(o-l)*a:2*a<1?o:3*a<2?l+(o-l)*(2/3-a)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*s,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(n+t)},error(t){console.error(n+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,s,r,n){let o,a,h;const l=(t-i)*(t-i)+(e-s)*(e-s);if(0==l)o=t,a=e,h=(r-i)*(r-i)+(n-s)*(n-s);else{const d=((r-t)*(i-t)+(n-e)*(s-e))/l;d<0?(o=t,a=e,h=(t-r)*(t-r)+(e-n)*(e-n)):d>1?(o=i,a=s,h=(i-r)*(i-r)+(s-n)*(s-n)):(o=t+d*(i-t),a=e+d*(s-e),h=(o-r)*(o-r)+(a-n)*(a-n))}return[o,a,h]},_getProjectionToLine(e,i,s){const r=t.Util.cloneObject(e);let n=Number.MAX_VALUE;return i.forEach((function(o,a){if(!s&&a===i.length-1)return;const h=i[(a+1)%i.length],l=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<n&&(r.x=d,r.y=c,n=u)})),r},_prepareArrayForTween(e,i,s){const r=[],n=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)n.push({x:i[t],y:i[t+1]});const o=[];return n.forEach((function(e){const i=t.Util._getProjectionToLine(e,r,s);o.push(i.x),o.push(i.y)})),o},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const s in e)if(e.hasOwnProperty(s)&&e[s]&&"object"==typeof e[s])if(i=Object.getOwnPropertyDescriptor(e,s),e[s].visitedByCircularReferenceRemoval||t.Util._isElement(e[s])){if(!i.configurable)return null;delete e[s]}else if(null===t.Util._prepareToStringify(e[s])){if(!i.configurable)return null;delete e[s]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,s){let r=0,n=0,o=0,a=0;"number"==typeof s?r=n=o=a=Math.min(s,e/2,i/2):(r=Math.min(s[0]||0,e/2,i/2),n=Math.min(s[1]||0,e/2,i/2),a=Math.min(s[2]||0,e/2,i/2),o=Math.min(s[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-n,0),t.arc(e-n,n,n,3*Math.PI/2,0,!1),t.lineTo(e,i-a),t.arc(e-a,i-a,a,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(At)),At}var Et,kt,Mt={},Ft={},It={};function Rt(){if(Et)return It;Et=1,Object.defineProperty(It,"__esModule",{value:!0}),It.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},It.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},It.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number.'),t}},It.getNumberOrArrayOfNumbersValidator=function(s){if(t.Konva.isUnminified)return function(t,r){let n=e.Util._isNumber(t),o=e.Util._isArray(t)&&t.length==s;return n||o||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+s+")"),t}},It.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number or "auto".'),t}},It.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a string.'),t}},It.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,s){const r=e.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||n||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a string or a native gradient.'),t}},It.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,s){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a function.'),t}},It.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,s){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+s+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a array of numbers.')),t}},It.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,s){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a boolean.'),t}},It.getComponentValidator=function(s){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+s),t}};const t=Ct(),e=Tt();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return It}function Dt(){return kt||(kt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=Tt(),i=Rt(),s="get",r="set";t.Factory={addGetterSetter(e,i,s,r,n){t.Factory.addGetter(e,i,s),t.Factory.addSetter(e,i,r,n),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,r){var n=s+e.Util._capitalize(i);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[i];return void 0===t?r:t}},addSetter(i,s,n,o){var a=r+e.Util._capitalize(s);i.prototype[a]||t.Factory.overWriteSetter(i,s,n,o)},overWriteSetter(t,i,s,n){var o=r+e.Util._capitalize(i);t.prototype[o]=function(t){return s&&null!=t&&(t=s.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,o,a,h,l){const d=a.length,c=e.Util._capitalize,u=s+c(o),g=r+c(o);n.prototype[u]=function(){const t={};for(let e=0;e<d;e++){const i=a[e];t[i]=this.getAttr(o+c(i))}return t};const f=(0,i.getComponentValidator)(a);n.prototype[g]=function(t){const e=this.attrs[o];h&&(t=h.call(this,t,o)),f&&f.call(this,t,o);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(o+c(e),t[e]);return t||a.forEach((t=>{this._setAttr(o+c(t),void 0)})),this._fireChangeEvent(o,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,o)},addOverloadedGetterSetter(t,i){var n=e.Util._capitalize(i),o=r+n,a=s+n;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(i,r,n,o){e.Util.error("Adding deprecated "+r);const a=s+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[a]=function(){e.Util.error(h);const t=this.attrs[r];return void 0===t?n:t},t.Factory.addSetter(i,r,o,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,n){const o=t.prototype[n],a=s+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[a]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(Ft)),Ft}var Ot,Lt,Vt={},zt={};function Gt(){if(Ot)return zt;Ot=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.HitContext=zt.SceneContext=zt.Context=void 0;const t=Tt(),e=Ct();const i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let s=class{constructor(t){this.canvas=t,e.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(e,i){let s,r,n,o,a=this.traceArr,h=a.length,l="";for(s=0;s<h;s++)r=a[s],n=r.method,n?(o=r.args,l+=n,e?l+="()":t.Util._isArray(o[0])?l+="(["+o.join(",")+"])":(i&&(o=o.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+o.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,s,r,n){this._context.arc(t,e,i,s,r,n)}arcTo(t,e,i,s,r){this._context.arcTo(t,e,i,s,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,s,r,n){this._context.bezierCurveTo(t,e,i,s,r,n)}clearRect(t,e,i,s){this._context.clearRect(t,e,i,s)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,s){return this._context.createLinearGradient(t,e,i,s)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,s,r,n){return this._context.createRadialGradient(t,e,i,s,r,n)}drawImage(t,e,i,s,r,n,o,a,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,s,r):9===l.length&&d.drawImage(t,e,i,s,r,n,o,a,h)}ellipse(t,e,i,s,r,n,o,a){this._context.ellipse(t,e,i,s,r,n,o,a)}isPointInPath(t,e,i,s){return i?this._context.isPointInPath(i,t,e,s):this._context.isPointInPath(t,e,s)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,s){this._context.fillRect(t,e,i,s)}strokeRect(t,e,i,s){this._context.strokeRect(t,e,i,s)}fillText(t,e,i,s){s?this._context.fillText(t,e,i,s):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,s){return this._context.getImageData(t,e,i,s)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,s){this._context.rect(t,e,i,s)}roundRect(t,e,i,s,r){this._context.roundRect(t,e,i,s,r)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,s){this._context.quadraticCurveTo(t,e,i,s)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,s,r,n){this._context.setTransform(t,e,i,s,r,n)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,s){this._context.strokeText(t,e,i,s)}transform(t,e,i,s,r,n){this._context.transform(t,e,i,s,r,n)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,s,r=this,n=i.length,o=this.setAttr;const a=function(e){let i,n=r[e];r[e]=function(){return s=function(e){const i=[],s=e.length,r=t.Util;for(let t=0;t<s;t++){let s=e[t];r._isNumber(s)?s=Math.round(1e3*s)/1e3:r._isString(s)||(s+=""),i.push(s)}return i}(Array.prototype.slice.call(arguments,0)),i=n.apply(r,arguments),r._trace({method:e,args:s}),i}};for(e=0;e<n;e++)a(i[e]);r.setAttr=function(){o.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};zt.Context=s,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(s.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));zt.SceneContext=class extends s{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const s=t.getFillPatternImage();if(s&&"pattern"===i)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)return void this._fillLinearGradient(t);const n=t.getFillRadialGradientColorStops();n&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):s?this._fillPattern(t):r?this._fillLinearGradient(t):n&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),s=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(s){for(let t=0;t<s.length;t+=2)r.addColorStop(s[t],s[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,s;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(s=t.getShadowOffset())&&void 0!==s?s:{x:0,y:0},a=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=a.x*h,d=a.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*d)}};return zt.HitContext=class extends s{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),s="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",s),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},zt}function Nt(){if(Lt)return Vt;Lt=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.HitCanvas=Vt.SceneCanvas=Vt.Canvas=void 0;const t=Tt(),e=Gt(),i=Ct(),s=Dt(),r=Rt();let n;let o=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const s=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(n)return n;const e=t.Util.createCanvasElement(),s=e.getContext("2d");return n=(i.Konva._global.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t.Util.releaseCanvas(e),n}();this.pixelRatio=s,this._canvas=t.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Vt.Canvas=o,s.Factory.addGetterSetter(o,"pixelRatio",void 0,(0,r.getNumberValidator)());Vt.SceneCanvas=class extends o{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return Vt.HitCanvas=class extends o{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},Vt}var Wt,Ut,Bt={};function jt(){return Wt||(Wt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Ct(),i=Tt();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const s=[];t.DD._dragElements.forEach(((t,r)=>{const{node:n}=t,o=n.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const a=o._changedPointerPositions.find((e=>e.id===t.pointerId));if(a){if("dragging"!==t.dragStatus){const i=n.dragDistance();if(Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y))<i)return;if(n.startDrag({evt:e}),!n.isDragging())return}n._setDragPosition(e,t),s.push(n)}})),s.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const s=[];t.DD._dragElements.forEach((r=>{const{node:n}=r,o=n.getStage();i&&o.setPointersPositions(i);if(!o._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const a=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;a&&-1===s.indexOf(a)&&s.push(a)})),s.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,s)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(s)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(Bt)),Bt}function Ht(){if(Ut)return Mt;Ut=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.Node=void 0;const t=Tt(),e=Dt(),i=Nt(),s=Ct(),r=jt(),n=Rt(),o="absoluteOpacity",a="allEventListeners",h="absoluteTransform",l="absoluteScale",d="canvas",c="listening",u="mouseenter",g="mouseleave",f="Shape",p=" ",m="stage",_="transform",v="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(p);let w=1,x=class e{constructor(t){this._id=w++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==_&&t!==h||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===_||t===h)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(p);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(d)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(d)){const{scene:e,filter:i,hit:s}=this._cache.get(d);t.Util.releaseCanvas(e,i,s),this._cache.delete(d)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const s=e||{};let r={};void 0!==s.x&&void 0!==s.y&&void 0!==s.width&&void 0!==s.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(s.width||r.width),a=Math.ceil(s.height||r.height),h=s.pixelRatio,c=void 0===s.x?Math.floor(r.x):s.x,u=void 0===s.y?Math.floor(r.y):s.y,g=s.offset||0,f=s.drawBorder||!1,p=s.hitCanvasPixelRatio||1;if(!n||!a)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*g+(Math.abs(Math.round(r.x)-c)>.5?1:0),a+=2*g+(Math.abs(Math.round(r.y)-u)>.5?1:0),c-=g,u-=g;const m=new i.SceneCanvas({pixelRatio:h,width:n,height:a}),_=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),v=new i.HitCanvas({pixelRatio:p,width:n,height:a}),y=m.getContext(),w=v.getContext();return v.isCache=!0,m.isCache=!0,this._cache.delete(d),this._filterUpToDate=!1,!1===s.imageSmoothingEnabled&&(m.getContext()._context.imageSmoothingEnabled=!1,_.getContext()._context.imageSmoothingEnabled=!1),y.save(),w.save(),y.translate(-c,-u),w.translate(-c,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(l),this.drawScene(m,this),this.drawHit(v,this),this._isUnderCache=!1,y.restore(),w.restore(),f&&(y.save(),y.beginPath(),y.rect(0,0,n,a),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(d,{scene:m,filter:_,hit:v,x:c,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(d)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let s=1/0,r=1/0,n=-1/0,o=-1/0;const a=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=a.point(t);void 0===s&&(s=n=e.x,r=o=e.y),s=Math.min(s,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)})),{x:s,y:r,width:n-s,height:o-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),s=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/s,i.height/s),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,i,s,r,n=this.filters(),o=this._getCanvasCache(),a=o.scene,h=o.filter,l=h.getContext();if(n){if(!this._filterUpToDate){const o=a.pixelRatio;h.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(e=n.length,l.clear(),l.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),s=0;s<e;s++)r=n[s],"function"==typeof r?(r.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return a}on(t,e){if(this._cache&&this._cache.delete(a),3===arguments.length)return this._delegate.apply(this,arguments);let i,s,r,n,o,h=t.split(p),l=h.length;for(i=0;i<l;i++)s=h[i],r=s.split("."),n=r[0],o=r[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:o,handler:e});return this}off(t,e){let i,s,r,n,o,h,l=(t||"").split(p),d=l.length;if(this._cache&&this._cache.delete(a),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<d;i++)if(r=l[i],n=r.split("."),o=n[0],h=n[1],o)this.eventListeners[o]&&this._off(o,h,e);else for(s in this.eventListeners)this._off(s,h,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(e,i,s){const r=this;this.on(e,(function(e){const n=e.target.findAncestors(i,!0,r);for(let i=0;i<n.length;i++)(e=t.Util.cloneObject(e)).currentTarget=n[i],s.call(n[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(v),this._clearSelfAndDescendantCache(c)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,s;if(!e)return this;for(i in e)"children"!==i&&(s="set"+t.Util._capitalize(i),t.Util._isFunction(this[s])?this[s](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(c,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(v,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));const o=!e&&!s.Konva.hitOnDragEnabled&&(n||s.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,s,r=this.getDepth(),n=this,o=0;const a=this.getStage();return"Stage"!==n.nodeType&&a&&function a(h){for(t=[],e=h.length,i=0;i<e;i++)s=h[i],o++,s.nodeType!==f&&(t=t.concat(s.getChildren().slice())),s._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&a(t)}(a.getChildren()),o}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(_),this._clearSelfAndDescendantCache(h)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(e){let i=!1,s=this.parent;for(;s;){if(s.isCached()){i=!0;break}s=s.parent}i&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),n=new t.Transform,o=this.offset();return n.m=r.slice(),n.translate(o.x,o.y),n.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...s}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(_);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(s),this.setPosition({x:t.x,y:t.y}),this._clearCache(_),this._clearSelfAndDescendantCache(h),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,s=this.x(),r=this.y();return void 0!==e&&(s+=e),void 0!==i&&(r+=i),this.setPosition({x:s,y:r}),this}_eachAncestorReverse(t,e){let i,s,r=[],n=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);n&&(!e||n._id!==e._id);)r.unshift(n),n=n.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(o,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let e,i,s,r,n,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(e in o)i=o[e],n=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),n||(s="function"==typeof this[e]&&this[e],delete o[e],r=s?s.call(this):null,o[e]=i,r!==i&&(a.attrs[e]=i));return t.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const s=[];e&&this._isMatch(t)&&s.push(this);let r=this.parent;for(;r;){if(r===i)return s;r._isMatch(t)&&s.push(r),r=r.parent}return s}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,s,r=e.replace(/ /g,"").split(","),n=r.length;for(i=0;i<n;i++)if(s=r[i],t.Util.isValidSelector(s)||(t.Util.warn('Selector "'+s+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===s.charAt(0)){if(this.id()===s.slice(1))return!0}else if("."===s.charAt(0)){if(this.hasName(s.slice(1)))return!0}else if(this.className===s||this.nodeType===s)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(m,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(h,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(h)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,s=this.attrs.offsetX||0,r=this.attrs.offsetY||0;i.translate(t-s,e-r)}return i.dirty=!1,i}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(_,this._getTransform)}_getTransform(){var e,i;const r=this._cache.get(_)||new t.Transform;r.reset();const n=this.x(),o=this.y(),a=s.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,d=this.attrs.skewX||0,c=this.attrs.skewY||0,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;return 0===n&&0===o||r.translate(n,o),0!==a&&r.rotate(a),0===d&&0===c||r.skew(d,c),1===h&&1===l||r.scale(h,l),0===u&&0===g||r.translate(-1*u,-1*g),r.dirty=!1,r}clone(e){let i,s,r,n,o,a=t.Util.cloneObject(this.attrs);for(i in e)a[i]=e[i];const h=new this.constructor(a);for(i in this.eventListeners)for(s=this.eventListeners[i],r=s.length,n=0;n<r;n++)o=s[n],o.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(o));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),s=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),n=void 0!==t.y?t.y:Math.floor(e.y),o=t.pixelRatio||1,a=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(s?s.width():0),height:t.height||Math.ceil(e.height)||(s?s.height():0),pixelRatio:o}),h=a.getContext(),l=new i.SceneCanvas({width:a.width/a.pixelRatio+Math.abs(r),height:a.height/a.pixelRatio+Math.abs(n),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(r||n)&&h.translate(-1*r,-1*n),this.drawScene(a,void 0,l),h.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,s=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(s),s}toImage(e){return new Promise(((i,s)=>{try{const s=null==e?void 0:e.callback;s&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==s||s(t)}))}catch(t){s(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():s.Konva.dragDistance}_off(t,e,i){let s,r,n,o=this.eventListeners[t];for(s=0;s<o.length;s++)if(r=o[s].name,n=o[s].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==n)){if(o.splice(s,1),0===o.length){delete this.eventListeners[t];break}s--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(e,i){const s=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(s)?s.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(s.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const s=this.attrs[e];(s!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,s,i),this._requestDraw())}_setComponentAttr(t,e,i){let s;void 0!==i&&(s=this.attrs[t],s||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,s,i))}_fireAndBubble(t,e,i){e&&this.nodeType===f&&(e.target=this);if(!((t===u||t===g)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=(t===u||t===g)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,s;const r=null!==(e=this._cache.get(a))&&void 0!==e?e:{};let n=null==r?void 0:r[t];if(void 0===n){n=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(s=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==s?s:[];n.push(...r),e=Object.getPrototypeOf(e)}r[t]=n,this._cache.set(a,r)}return n}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var s=0;s<i.length;s++)i[s].handler.call(this,e);const r=this.eventListeners[t];if(r)for(s=0;s<r.length;s++)r[s].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),s=this.getAbsolutePosition();if(!i)return;const n=i._getPointerById(e)||i._changedPointerPositions[0]||s;r.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,i){const s=this.getStage()._getPointerById(i.pointerId);if(!s)return;let r={x:s.x-i.offset.x,y:s.y-i.offset.y};const n=this.dragBoundFunc();if(void 0!==n){const i=n.call(this,r,e);i?r=i:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if(!(!(void 0!==t.evt.button)||s.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const i=this.getStage();if(!i)return!1;const s={x:-e.x,y:-e.y,width:i.width()+2*e.x,height:i.height()+2*e.y};return t.Util.haveIntersection(s,this.getClientRect())}static create(e,i){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,i)}static _createNode(i,r){let n,o,a,h=e.prototype.getClassName.call(i),l=i.children;r&&(i.attrs.container=r),s.Konva[h]||(t.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(n=new(0,s.Konva[h])(i.attrs),l)for(o=l.length,a=0;a<o;a++)n.add(e._createNode(l[a]));return n}};Mt.Node=x,x.prototype.nodeType="Node",x.prototype._attrsAffectingSize=[],x.prototype.eventListeners={},x.prototype.on.call(x.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(_),this._clearSelfAndDescendantCache(h))})),x.prototype.on.call(x.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(v)})),x.prototype.on.call(x.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(c)})),x.prototype.on.call(x.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(o)}));const b=e.Factory.addGetterSetter;return b(x,"zIndex"),b(x,"absolutePosition"),b(x,"position"),b(x,"x",0,(0,n.getNumberValidator)()),b(x,"y",0,(0,n.getNumberValidator)()),b(x,"globalCompositeOperation","source-over",(0,n.getStringValidator)()),b(x,"opacity",1,(0,n.getNumberValidator)()),b(x,"name","",(0,n.getStringValidator)()),b(x,"id","",(0,n.getStringValidator)()),b(x,"rotation",0,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"scale",["x","y"]),b(x,"scaleX",1,(0,n.getNumberValidator)()),b(x,"scaleY",1,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"skew",["x","y"]),b(x,"skewX",0,(0,n.getNumberValidator)()),b(x,"skewY",0,(0,n.getNumberValidator)()),e.Factory.addComponentsGetterSetter(x,"offset",["x","y"]),b(x,"offsetX",0,(0,n.getNumberValidator)()),b(x,"offsetY",0,(0,n.getNumberValidator)()),b(x,"dragDistance",void 0,(0,n.getNumberValidator)()),b(x,"width",0,(0,n.getNumberValidator)()),b(x,"height",0,(0,n.getNumberValidator)()),b(x,"listening",!0,(0,n.getBooleanValidator)()),b(x,"preventDefault",!0,(0,n.getBooleanValidator)()),b(x,"filters",void 0,(function(t){return this._filterUpToDate=!1,t})),b(x,"visible",!0,(0,n.getBooleanValidator)()),b(x,"transformsEnabled","all",(0,n.getStringValidator)()),b(x,"size"),b(x,"dragBoundFunc"),b(x,"draggable",!1,(0,n.getBooleanValidator)()),e.Factory.backCompat(x,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Mt}var Yt,Xt={};function Kt(){if(Yt)return Xt;Yt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Container=void 0;const t=Dt(),e=Ht(),i=Rt();let s=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((s=>{const r=s._isMatch(t);return r&&i.push(s),!(!r||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const s of i){if(e=t(s),e)return!0;if(s.hasChildren()&&(e=s._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){i.add(t.clone())})),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const s=this.getLayer(),r=t||s&&s.getCanvas(),n=r&&r.getContext(),o=this._getCanvasCache(),a=o&&o.scene,h=r&&r.isCache;if(!this.isVisible()&&!h)return this;if(a){n.save();const t=this.getAbsoluteTransform(e).getMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",r,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),s=t||i&&i.hitCanvas,r=s&&s.getContext(),n=this._getCanvasCache();if(n&&n.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",s,e);return this}_drawChildren(t,e,i,s){var r;const n=e&&e.getContext(),o=this.clipWidth(),a=this.clipHeight(),h=this.clipFunc(),l="number"==typeof o&&"number"==typeof a||h,d=i===this;if(l){n.save();const t=this.getAbsoluteTransform(i);let e,s=t.getMatrix();if(n.transform(s[0],s[1],s[2],s[3],s[4],s[5]),n.beginPath(),h)e=h.call(this,n,this);else{const t=this.clipX(),e=this.clipY();n.rect(t||0,e||0,o,a)}n.clip.apply(n,e),s=t.copy().invert().getMatrix(),n.transform(s[0],s[1],s[2],s[3],s[4],s[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(n.save(),n._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,i,s)})),c&&n.restore(),l&&n.restore()}getClientRect(t={}){var e;const i=t.skipTransform,s=t.relativeTo;let r,n,o,a,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===r?(r=i.x,n=i.y,o=i.x+i.width,a=i.y+i.height):(r=Math.min(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),a=Math.max(a,i.y+i.height)))}));const d=this.find("Shape");let c=!1;for(let t=0;t<d.length;t++){if(d[t]._isVisible(this)){c=!0;break}}return h=c&&void 0!==r?{x:r,y:n,width:o-r,height:a-n}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,s)}};return Xt.Container=s,t.Factory.addComponentsGetterSetter(s,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(s,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clipFunc"),Xt}var qt,Jt,Zt={},$t={};function Qt(){if(qt)return $t;qt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.getCapturedShape=function(t){return e.get(t)},$t.createEvent=s,$t.hasPointerCapture=function(t,i){return e.get(t)===i},$t.setPointerCapture=function(t,n){r(t);if(!n.getStage())return;e.set(t,n),i&&n._fire("gotpointercapture",s(new PointerEvent("gotpointercapture")))},$t.releaseCapture=r;const t=Ct(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function s(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const n=e.get(t);if(!n)return;const o=n.getStage();o&&o.content,e.delete(t),i&&n._fire("lostpointercapture",s(new PointerEvent("lostpointercapture")))}return $t}var te,ee,ie={},se={};function re(){return te||(te=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Ct(),i=Tt(),s=Dt(),r=Ht(),n=Rt(),o=Ct(),a=Qt(),h="hasShadow",l="shadowRGBA",d="patternImage",c="linearGradient",u="radialGradient";let g;function f(){return g||(g=i.Util.createCanvasElement().getContext("2d"),g)}t.shapes={};class p extends r.Node{constructor(e){let s;for(super(e);s=i.Util.getRandomColor(),!s||s in t.shapes;);this.colorKey=s,t.shapes[s]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const s=new i.Transform;s.translate(this.fillPatternX(),this.fillPatternY()),s.rotate(e.Konva.getAngle(this.fillPatternRotation())),s.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),s.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=s.getMatrix(),n="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(c,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=f(),i=this.fillLinearGradientStartPoint(),s=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,s.x,s.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=f(),i=this.fillRadialGradientStartPoint(),s=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),s.x,s.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),s=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&s&&r)return!0;const n=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&s&&n&&o)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const s=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,n=this.getSelfRect(),o=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+o,h=n.height+o,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=a+Math.abs(d),g=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(o/2+f)+Math.min(d,0)+n.x,y:-(o/2+f)+Math.min(c,0)+n.y};return s?p:this._transformedRect(p,r)}drawScene(t,e,i){const s=this.getLayer();let r,n,o=t||s.getCanvas(),a=o.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow();const c=o.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!l)return this;if(a.save(),this._useBufferCanvas()&&!c){r=this.getStage();const t=i||r.bufferCanvas;n=t.getContext(),n.clear(),n.save(),n._applyLineJoin(this);var g=this.getAbsoluteTransform(e).getMatrix();n.transform(g[0],g[1],g[2],g[3],g[4],g[5]),l.call(this,n,this),n.restore();const s=t.pixelRatio;d&&a._applyShadow(this),a._applyOpacity(this),a._applyGlobalCompositeOperation(this),a.drawImage(t._canvas,0,0,t.width/s,t.height/s)}else{if(a._applyLineJoin(this),!u){g=this.getAbsoluteTransform(e).getMatrix();a.transform(g[0],g[1],g[2],g[3],g[4],g[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}d&&a._applyShadow(this),l.call(this,a,this)}return a.restore(),this}drawHit(t,e,s=!1){if(!this.shouldDrawHit(e,s))return this;const r=this.getLayer(),n=t||r.hitCanvas,o=n&&n.getContext(),a=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!a)return this;o.save(),o._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,o,this),o.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),s=this._getCachedSceneCanvas(),r=e.hit,n=r.getContext(),o=r.getWidth(),a=r.getHeight();n.clear(),n.drawImage(s._canvas,0,0,o,a);try{const e=n.getImageData(0,0,o,a),s=e.data,r=s.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4){s[e+3]>t?(s[e]=h.r,s[e+1]=h.g,s[e+2]=h.b,s[e+3]=255):s[e+3]=0}n.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return a.hasPointerCapture(t,this)}setPointerCapture(t){a.setPointerCapture(t,this)}releaseCapture(t){a.releaseCapture(t,this)}}t.Shape=p,p.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},p.prototype._strokeFunc=function(t){t.stroke()},p.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},p.prototype._strokeFuncHit=function(t){t.stroke()},p.prototype._centroid=!1,p.prototype.nodeType="Shape",(0,o._registerNode)(p),p.prototype.eventListeners={},p.prototype.on.call(p.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),p.prototype.on.call(p.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(d)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(c)})),p.prototype.on.call(p.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),s.Factory.addGetterSetter(p,"stroke",void 0,(0,n.getStringOrGradientValidator)()),s.Factory.addGetterSetter(p,"strokeWidth",2,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillAfterStrokeEnabled",!1),s.Factory.addGetterSetter(p,"hitStrokeWidth","auto",(0,n.getNumberOrAutoValidator)()),s.Factory.addGetterSetter(p,"strokeHitEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"perfectDrawEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"shadowForStrokeEnabled",!0,(0,n.getBooleanValidator)()),s.Factory.addGetterSetter(p,"lineJoin"),s.Factory.addGetterSetter(p,"lineCap"),s.Factory.addGetterSetter(p,"sceneFunc"),s.Factory.addGetterSetter(p,"hitFunc"),s.Factory.addGetterSetter(p,"dash"),s.Factory.addGetterSetter(p,"dashOffset",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowColor",void 0,(0,n.getStringValidator)()),s.Factory.addGetterSetter(p,"shadowBlur",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowOpacity",1,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"shadowOffset",["x","y"]),s.Factory.addGetterSetter(p,"shadowOffsetX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"shadowOffsetY",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternImage"),s.Factory.addGetterSetter(p,"fill",void 0,(0,n.getStringOrGradientValidator)()),s.Factory.addGetterSetter(p,"fillPatternX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternY",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillLinearGradientColorStops"),s.Factory.addGetterSetter(p,"strokeLinearGradientColorStops"),s.Factory.addGetterSetter(p,"fillRadialGradientStartRadius",0),s.Factory.addGetterSetter(p,"fillRadialGradientEndRadius",0),s.Factory.addGetterSetter(p,"fillRadialGradientColorStops"),s.Factory.addGetterSetter(p,"fillPatternRepeat","repeat"),s.Factory.addGetterSetter(p,"fillEnabled",!0),s.Factory.addGetterSetter(p,"strokeEnabled",!0),s.Factory.addGetterSetter(p,"shadowEnabled",!0),s.Factory.addGetterSetter(p,"dashEnabled",!0),s.Factory.addGetterSetter(p,"strokeScaleEnabled",!0),s.Factory.addGetterSetter(p,"fillPriority","color"),s.Factory.addComponentsGetterSetter(p,"fillPatternOffset",["x","y"]),s.Factory.addGetterSetter(p,"fillPatternOffsetX",0,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternOffsetY",0,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"fillPatternScale",["x","y"]),s.Factory.addGetterSetter(p,"fillPatternScaleX",1,(0,n.getNumberValidator)()),s.Factory.addGetterSetter(p,"fillPatternScaleY",1,(0,n.getNumberValidator)()),s.Factory.addComponentsGetterSetter(p,"fillLinearGradientStartPoint",["x","y"]),s.Factory.addComponentsGetterSetter(p,"strokeLinearGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillLinearGradientStartPointX",0),s.Factory.addGetterSetter(p,"strokeLinearGradientStartPointX",0),s.Factory.addGetterSetter(p,"fillLinearGradientStartPointY",0),s.Factory.addGetterSetter(p,"strokeLinearGradientStartPointY",0),s.Factory.addComponentsGetterSetter(p,"fillLinearGradientEndPoint",["x","y"]),s.Factory.addComponentsGetterSetter(p,"strokeLinearGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillLinearGradientEndPointX",0),s.Factory.addGetterSetter(p,"strokeLinearGradientEndPointX",0),s.Factory.addGetterSetter(p,"fillLinearGradientEndPointY",0),s.Factory.addGetterSetter(p,"strokeLinearGradientEndPointY",0),s.Factory.addComponentsGetterSetter(p,"fillRadialGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillRadialGradientStartPointX",0),s.Factory.addGetterSetter(p,"fillRadialGradientStartPointY",0),s.Factory.addComponentsGetterSetter(p,"fillRadialGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(p,"fillRadialGradientEndPointX",0),s.Factory.addGetterSetter(p,"fillRadialGradientEndPointY",0),s.Factory.addGetterSetter(p,"fillPatternRotation",0),s.Factory.addGetterSetter(p,"fillRule",void 0,(0,n.getStringValidator)()),s.Factory.backCompat(p,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(se)),se}function ne(){if(ee)return ie;ee=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.Layer=void 0;const t=Tt(),e=Kt(),i=Ht(),s=Dt(),r=Nt(),n=Rt(),o=re(),a=Ct(),h=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],l=h.length;let d=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){i.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!i.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(i.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(i.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),i.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let s=0;s<l;s++){const r=h[s],n=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),o=n.shape;if(o)return o;if(i=!!n.antialiased,!n.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,s=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,r=s[3];if(255===r){const e=t.Util._rgbToHex(s[0],s[1],s[2]),i=o.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,i){const s=this.getLayer(),r=t||s&&s.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,i),this._fire("draw",{node:this}),this}drawHit(t,i){const s=this.getLayer(),r=t||s&&s.hitCanvas;return s&&s.clearBeforeDraw()&&s.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return ie.Layer=d,d.prototype.nodeType="Layer",(0,a._registerNode)(d),s.Factory.addGetterSetter(d,"imageSmoothingEnabled",!0),s.Factory.addGetterSetter(d,"clearBeforeDraw",!0),s.Factory.addGetterSetter(d,"hitGraphEnabled",!0,(0,n.getBooleanValidator)()),ie}var oe,ae={};var he,le={};function de(){if(he)return le;he=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Group=void 0;const t=Tt(),e=Kt(),i=Ct();let s=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return le.Group=s,s.prototype.nodeType="Group",(0,i._registerNode)(s),le}var ce,ue={};function ge(){if(ce)return ue;ce=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Animation=void 0;const t=Ct(),e=Tt(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let s=class t{constructor(e,s){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(s)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let s=0;s<i;s++)if(e[s]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,s=i.length;for(let t=0;t<s;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let s=0;s<e.length;s++){const r=e[s],n=r.layers,o=r.func;r._updateFrameObject(i());const a=n.length;let h;if(h=!o||!1!==o.call(r,r.frame),h)for(let e=0;e<a;e++){const i=n[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return ue.Animation=s,s.animations=[],s.animIdCounter=0,s.animRunning=!1,ue}var fe,pe,me={};function _e(){return pe||(pe=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Ct(),i=Tt(),s=Ht(),r=Kt(),n=(Jt||(Jt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=Tt(),i=Dt(),s=Kt(),r=Ct(),n=Nt(),o=jt(),a=Ct(),h=Qt(),l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",f="mouseup",p="pointermove",m="pointerdown",_="pointerup",v="pointercancel",y="pointerout",w="pointerleave",x="pointerover",b="pointerenter",S="contextmenu",C="touchstart",P="touchend",A="touchmove",T="touchcancel",E="wheel",k=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[f,"_pointerup"],[l,"_pointerleave"],[C,"_pointerdown"],[A,"_pointermove"],[P,"_pointerup"],[T,"_pointercancel"],[d,"_pointerover"],[E,"_wheel"],[S,"_contextmenu"],[m,"_pointerdown"],[p,"_pointermove"],[_,"_pointerup"],[v,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],M={mouse:{[y]:"mouseout",[w]:l,[x]:d,[b]:c,[p]:u,[m]:g,[_]:f,[v]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[w]:"touchleave",[x]:"touchover",[b]:"touchenter",[p]:A,[m]:C,[_]:P,[v]:T,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[w]:w,[x]:x,[b]:b,[p]:p,[m]:m,[_]:_,[v]:v,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},F=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=F(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&M.pointer:"touch"===e?M.touch:"mouse"===e?M.mouse:void 0};function R(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class D extends s.Container{constructor(e){super(R(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{R(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),s="FastLayer"===t.getType();i||s||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e)}if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),s.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const s=t.stages.indexOf(this);return s>-1&&t.stages.splice(s,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new n.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,s=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),s.forEach((function(e){if(!e.isVisible())return;const s=e._toKonvaCanvas(t);i.drawImage(s._canvas,t.x,t.y,s.getWidth()/s.getPixelRatio(),s.getHeight()/s.getPixelRatio())})),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const s=e[i].getIntersection(t);if(s)return s}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const s=this.children.length;return s>5&&e.Util.warn("The stage has "+s+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&k.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const s=this._getTargetShape(i),n=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;s&&n?(s._fireAndBubble(e.pointerout,{evt:t}),s._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):n&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);let s=!1;this._changedPointerPositions.forEach((n=>{const a=this.getIntersection(n);if(o.DD.justDragged=!1,r.Konva["_"+i+"ListenClick"]=!0,!a||!a.isListening())return void(this[i+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[i+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:n.id}),s=!0;const h=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),s||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),i=F(t.type);if(!e)return;if(r.Konva.isDragging()&&o.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const s={};let n=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach((r=>{const o=h.getCapturedShape(r.id)||this.getIntersection(r),l=r.id,d={evt:t,pointerId:l},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...d},o),a._fireAndBubble(e.pointerleave,{...d},o)),o){if(s[o._id])return;s[o._id]=!0}o&&o.isListening()?(n=!0,c&&(o._fireAndBubble(e.pointerover,{...d},a),o._fireAndBubble(e.pointerenter,{...d},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...d})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),n||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const s=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"],a={};let l=!1;this._changedPointerPositions.forEach((d=>{const c=h.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),a[c._id])return;a[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let f=!1;r.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):o.DD.justDragged||(r.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){r.Konva["_"+i+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),c&&c.isListening()?(l=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),r.Konva["_"+i+"ListenClick"]&&s&&s===c&&(c._fireAndBubble(e.pointerclick,{...g}),f&&n&&n===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,r.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(E,{evt:t}):this._fire(E,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let s=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(s=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:s,y:r},this._pointerPositions=[{x:s,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:s,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new n.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new n.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=D,D.prototype.nodeType="Stage",(0,a._registerNode)(D),i.Factory.addGetterSetter(D,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(Zt)),Zt),o=ne(),a=function(){if(oe)return ae;oe=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.FastLayer=void 0;const t=Tt(),e=ne(),i=Ct();let s=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return ae.FastLayer=s,s.prototype.nodeType="FastLayer",(0,i._registerNode)(s),ae}(),h=de(),l=jt(),d=re(),c=ge(),u=(fe||(fe=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=Tt(),i=ge(),s=Ht(),r=Ct(),n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o=["fill","stroke","shadowColor"];let a=0;class h{constructor(t,e,i,s,r,n,o){this.prop=t,this.propFunc=e,this.begin=s,this._pos=s,this.duration=n,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=r-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(s){const o=this,d=s.node,c=d._id,u=s.easing||t.Easings.Linear,g=!!s.yoyo;let f,p;f=void 0===s.duration?.3:0===s.duration?.001:s.duration,this.node=d,this._id=a++;const m=d.getLayer()||(d instanceof r.Konva.Stage?d.getLayers():null);for(p in m||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){o.tween.onEnterFrame()}),m),this.tween=new h(p,(function(t){o._tweenFunc(t)}),u,0,1,1e3*f,g),this._addListeners(),l.attrs[c]||(l.attrs[c]={}),l.attrs[c][this._id]||(l.attrs[c][this._id]={}),l.tweens[c]||(l.tweens[c]={}),s)void 0===n[p]&&this._addAttr(p,s[p]);this.reset(),this.onFinish=s.onFinish,this.onReset=s.onReset,this.onUpdate=s.onUpdate}_addAttr(t,i){const s=this.node,r=s._id;let n,a,h,d,c;const u=l.tweens[r][t];u&&delete l.attrs[r][u][t];let g=s.getAttr(t);if(e.Util._isArray(i))if(n=[],a=Math.max(i.length,g.length),"points"===t&&i.length!==g.length&&(i.length>g.length?(d=g,g=e.Util._prepareArrayForTween(g,i,s.closed())):(h=i,i=e.Util._prepareArrayForTween(i,g,s.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)n.push(i[t]-g[t]);else{const s=e.Util.colorToRGBA(g[t]);c=e.Util.colorToRGBA(i[t]),g[t]=s,n.push({r:c.r-s.r,g:c.g-s.g,b:c.b-s.b,a:c.a-s.a})}else for(let t=0;t<a;t++)n.push(i[t]-g[t]);else-1!==o.indexOf(t)?(g=e.Util.colorToRGBA(g),c=e.Util.colorToRGBA(i),n={r:c.r-g.r,g:c.g-g.g,b:c.b-g.b,a:c.a-g.a}):n=i-g;l.attrs[r][this._id][t]={start:g,diff:n,end:i,trueEnd:h,trueStart:d},l.tweens[r][t]=this._id}_tweenFunc(t){const i=this.node,s=l.attrs[i._id][this._id];let r,n,a,h,d,c,u,g;for(r in s){if(n=s[r],a=n.start,h=n.diff,g=n.end,e.Util._isArray(a))if(d=[],u=Math.max(a.length,g.length),0===r.indexOf("fill"))for(c=0;c<u;c++)c%2==0?d.push((a[c]||0)+h[c]*t):d.push("rgba("+Math.round(a[c].r+h[c].r*t)+","+Math.round(a[c].g+h[c].g*t)+","+Math.round(a[c].b+h[c].b*t)+","+(a[c].a+h[c].a*t)+")");else for(c=0;c<u;c++)d.push((a[c]||0)+h[c]*t);else d=-1!==o.indexOf(r)?"rgba("+Math.round(a.r+h.r*t)+","+Math.round(a.g+h.g*t)+","+Math.round(a.b+h.b*t)+","+(a.a+h.a*t)+")":a+h*t;i.setAttr(r,d)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=l.tweens[t];this.pause();for(const e in i)delete l.tweens[t][e];delete l.attrs[t][e]}}t.Tween=l,l.attrs={},l.tweens={},s.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,s){const r=1.70158;return i*(t/=s)*t*((r+1)*t-r)+e},BackEaseOut(t,e,i,s){const r=1.70158;return i*((t=t/s-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,i,s){let r=1.70158;return(t/=s/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,i,s,r,n){let o=0;return 0===t?e:1==(t/=s)?e+i:(n||(n=.3*s),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)+e)},ElasticEaseOut(t,e,i,s,r,n){let o=0;return 0===t?e:1==(t/=s)?e+i:(n||(n=.3*s),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/n)+i+e)},ElasticEaseInOut(t,e,i,s,r,n){let o=0;return 0===t?e:2==(t/=s/2)?e+i:(n||(n=s*(.3*1.5)),!r||r<Math.abs(i)?(r=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/n)*.5+i+e)},BounceEaseOut:(t,e,i,s)=>(t/=s)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,s,r)=>s-t.Easings.BounceEaseOut(r-e,0,s,r)+i,BounceEaseInOut:(e,i,s,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,s,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,s,r)+.5*s+i,EaseIn:(t,e,i,s)=>i*(t/=s)*t+e,EaseOut:(t,e,i,s)=>-i*(t/=s)*(t-2)+e,EaseInOut:(t,e,i,s)=>(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,s)=>i*(t/=s)*t*t*t*t+e,StrongEaseOut:(t,e,i,s)=>i*((t=t/s-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,s)=>(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,s)=>i*t/s+e}}(me)),me),g=Gt(),f=Nt();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:s.Node,Container:r.Container,Stage:n.Stage,stages:n.stages,Layer:o.Layer,FastLayer:a.FastLayer,Group:h.Group,DD:l.DD,Shape:d.Shape,shapes:d.shapes,Animation:c.Animation,Tween:u.Tween,Easings:u.Easings,Context:g.Context,Canvas:f.Canvas}),t.default=t.Konva}(bt)),bt}var ve,ye={};var we,xe={},be={};function Se(){if(we)return be;we=1,Object.defineProperty(be,"__esModule",{value:!0}),be.Line=void 0;const t=Dt(),e=Ct(),i=re(),s=Rt();function r(t,e,i,s,r,n,o){const a=Math.sqrt(Math.pow(i-t,2)+Math.pow(s-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(n-s,2)),l=o*a/(a+h),d=o*h/(a+h);return[i-l*(r-t),s-l*(n-e),i+d*(r-t),s+d*(n-e)]}function n(t,e){const i=t.length,s=[];for(let n=2;n<i-2;n+=2){const i=r(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e);isNaN(i[0])||(s.push(i[0]),s.push(i[1]),s.push(t[n]),s.push(t[n+1]),s.push(i[2]),s.push(i[3]))}return s}let o=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,i,s,r=this.points(),n=r.length,o=this.tension(),a=this.closed(),h=this.bezier();if(n){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==o&&n>4){for(e=this.getTensionPoints(),i=e.length,s=a?0:4,a||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);s<i-2;)t.bezierCurveTo(e[s++],e[s++],e[s++],e[s++],e[s++],e[s++]);a||t.quadraticCurveTo(e[i-2],e[i-1],r[n-2],r[n-1])}else if(h)for(s=2;s<n;)t.bezierCurveTo(r[s++],r[s++],r[s++],r[s++],r[s++],r[s++]);else for(s=2;s<n;s+=2)t.lineTo(r[s],r[s+1]);a?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():n(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),s=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),o=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=n(t,i);return[s[2],s[3]].concat(a).concat([o[0],o[1],t[e-2],t[e-1],o[2],o[3],s[0],s[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,s=t[0],r=t[0],n=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],s=Math.min(s,e),r=Math.max(r,e),n=Math.min(n,i),o=Math.max(o,i);return{x:s,y:n,width:r-s,height:o-n}}};return be.Line=o,o.prototype.className="Line",o.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(o),t.Factory.addGetterSetter(o,"closed",!1),t.Factory.addGetterSetter(o,"bezier",!1),t.Factory.addGetterSetter(o,"tension",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(o,"points",[],(0,s.getNumberArrayValidator)()),be}var Ce,Pe,Ae,Te={},Ee={};function ke(){if(Pe)return Te;Pe=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Path=void 0;const t=Dt(),e=re(),i=Ct(),s=(Ce||(Ce=1,function(t){function e(t,e,s){const r=i(1,s,t),n=i(1,s,e),o=r*r+n*n;return Math.sqrt(o)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,s,r)=>{let n,o;const a=r/2;n=0;for(let r=0;r<20;r++)o=a*t.tValues[20][r]+a,n+=t.cValues[20][r]*e(i,s,o);return a*n},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const s=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],n=2*t[1]-2*t[0],o=2*e[1]-2*e[0],a=4*(s*s+r*r),h=4*(s*n+r*o),l=n*n+o*o;if(0===a)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*a),c=i+d,u=l/a-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,f=d*d+u>0?Math.sqrt(d*d+u):0,p=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+f))):0;return Math.sqrt(a)/2*(c*g-d*f+p)};const i=(e,s,r)=>{const n=r.length-1;let o,a;if(0===n)return 0;if(0===e){a=0;for(let e=0;e<=n;e++)a+=t.binomialCoefficients[n][e]*Math.pow(1-s,n-e)*Math.pow(s,e)*r[e];return a}o=new Array(n);for(let t=0;t<n;t++)o[t]=n*(r[t+1]-r[t]);return i(e-1,s,o)};t.t2length=(t,e,i)=>{let s=1,r=t/e,n=(t-i(r))/e,o=0;for(;s>.001;){const a=i(r+n),h=Math.abs(t-a)/e;if(h<s)s=h,r+=n;else{const o=i(r-n),a=Math.abs(t-o)/e;a<s?(s=a,r-=n):n/=2}if(o++,o>500)break}return r}}(Ee)),Ee);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let f=0;f<e.length;f++){const p=e[f].command,m=e[f].points;switch(p){case"L":t.lineTo(m[0],m[1]);break;case"M":t.moveTo(m[0],m[1]);break;case"C":t.bezierCurveTo(m[0],m[1],m[2],m[3],m[4],m[5]);break;case"Q":t.quadraticCurveTo(m[0],m[1],m[2],m[3]);break;case"A":var s=m[0],r=m[1],n=m[2],o=m[3],a=m[4],h=m[5],l=m[6],d=m[7],c=n>o?n:o,u=n>o?1:n/o,g=n>o?o/n:1;t.translate(s,r),t.rotate(l),t.scale(u,g),t.arc(0,0,c,a,a+h,1-d),t.scale(1/u,1/g),t.rotate(-l),t.translate(-s,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(i){if("A"===i.command){const s=i.points[4],r=i.points[5],n=i.points[4]+r;let o=Math.PI/180;if(Math.abs(s-n)<o&&(o=Math.abs(s-n)),r<0)for(let r=s-o;r>n;r-=o){const s=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(s.x,s.y)}else for(let r=s+o;r<n;r+=o){const s=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],r,0);e.push(s.x,s.y)}}else if("C"===i.command)for(let s=0;s<=1;s+=.01){const r=t.getPointOnCubicBezier(s,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(r.x,r.y)}else e=e.concat(i.points)}));let i,s,r=e[0],n=e[0],o=e[1],a=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],s=e[2*t+1],isNaN(i)||(r=Math.min(r,i),n=Math.max(n,i)),isNaN(s)||(o=Math.min(o,s),a=Math.max(a,s));return{x:r,y:o,width:n-r,height:a-o}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,s){return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let r,n=0,o=i.length;if(!o)return null;for(;n<o&&e>i[n].pathLength;)e-=i[n].pathLength,++n;if(n===o)return r=i[n-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=i[n].points.slice(0,2),{x:r[0],y:r[1]};const a=i[n],h=a.points;switch(a.command){case"L":return t.getPointOnLine(e,a.start.x,a.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,s.t2length)(e,t.getPathLength(i),(t=>(0,s.getCubicArcLength)([a.start.x,h[0],h[2],h[4]],[a.start.y,h[1],h[3],h[5]],t))),a.start.x,a.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,s.t2length)(e,t.getPathLength(i),(t=>(0,s.getQuadraticArcLength)([a.start.x,h[0],h[2]],[a.start.y,h[1],h[3]],t))),a.start.x,a.start.y,h[0],h[1],h[2],h[3]);case"A":var l=h[0],d=h[1],c=h[2],u=h[3],g=h[4],f=h[5],p=h[6];return g+=f*e/a.pathLength,t.getPointOnEllipticalArc(l,d,c,u,g,p)}return null}static getPointOnLine(t,e,i,s,r,n,o){n=null!=n?n:e,o=null!=o?o:i;const a=this.getLineLength(e,i,s,r);if(a<1e-10)return{x:e,y:i};if(s===e)return{x:n,y:o+(r>i?t:-t)};const h=(r-i)/(s-e),l=Math.sqrt(t*t/(1+h*h))*(s<e?-1:1),d=h*l;if(Math.abs(o-i-h*(n-e))<1e-10)return{x:n+l,y:o+d};const c=((n-e)*(s-e)+(o-i)*(r-i))/(a*a),u=e+c*(s-e),g=i+c*(r-i),f=this.getLineLength(n,o,u,g),p=Math.sqrt(t*t-f*f),m=Math.sqrt(p*p/(1+h*h))*(s<e?-1:1);return{x:u+m,y:g+h*m}}static getPointOnCubicBezier(t,e,i,s,r,n,o,a,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:a*l(t)+n*d(t)+s*c(t)+e*u(t),y:h*l(t)+o*d(t)+r*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,s,r,n,o){function a(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:n*a(t)+s*h(t)+e*l(t),y:o*a(t)+r*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,s,r,n){const o=Math.cos(n),a=Math.sin(n),h=i*Math.cos(r),l=s*Math.sin(r);return{x:t+(h*o-l*a),y:e+(h*a+l*o)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var s=0;s<i.length;s++)e=e.replace(new RegExp(i[s],"g"),"|"+i[s]);const r=e.split("|"),n=[],o=[];let a=0,h=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let d;for(s=1;s<r.length;s++){let t=r[s],e=t.charAt(0);for(t=t.slice(1),o.length=0;d=l.exec(t);)o.push(d[0]);const i=[];for(let t=0,e=o.length;t<e;t++){if("00"===o[t]){i.push(0,0);continue}const e=parseFloat(o[t]);isNaN(e)?i.push(0):i.push(e)}for(;i.length>0&&!isNaN(i[0]);){let t="",s=[];const r=a,o=h;var c,u,g,f,p,m,_,v,y,w;switch(e){case"l":a+=i.shift(),h+=i.shift(),t="L",s.push(a,h);break;case"L":a=i.shift(),h=i.shift(),s.push(a,h);break;case"m":var x=i.shift(),b=i.shift();if(a+=x,h+=b,t="M",n.length>2&&"z"===n[n.length-1].command)for(let t=n.length-2;t>=0;t--)if("M"===n[t].command){a=n[t].points[0]+x,h=n[t].points[1]+b;break}s.push(a,h),e="l";break;case"M":a=i.shift(),h=i.shift(),t="M",s.push(a,h),e="L";break;case"h":a+=i.shift(),t="L",s.push(a,h);break;case"H":a=i.shift(),t="L",s.push(a,h);break;case"v":h+=i.shift(),t="L",s.push(a,h);break;case"V":h=i.shift(),t="L",s.push(a,h);break;case"C":s.push(i.shift(),i.shift(),i.shift(),i.shift()),a=i.shift(),h=i.shift(),s.push(a,h);break;case"c":s.push(a+i.shift(),h+i.shift(),a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="C",s.push(a,h);break;case"S":u=a,g=h,"C"===(c=n[n.length-1]).command&&(u=a+(a-c.points[2]),g=h+(h-c.points[3])),s.push(u,g,i.shift(),i.shift()),a=i.shift(),h=i.shift(),t="C",s.push(a,h);break;case"s":u=a,g=h,"C"===(c=n[n.length-1]).command&&(u=a+(a-c.points[2]),g=h+(h-c.points[3])),s.push(u,g,a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="C",s.push(a,h);break;case"Q":s.push(i.shift(),i.shift()),a=i.shift(),h=i.shift(),s.push(a,h);break;case"q":s.push(a+i.shift(),h+i.shift()),a+=i.shift(),h+=i.shift(),t="Q",s.push(a,h);break;case"T":u=a,g=h,"Q"===(c=n[n.length-1]).command&&(u=a+(a-c.points[0]),g=h+(h-c.points[1])),a=i.shift(),h=i.shift(),t="Q",s.push(u,g,a,h);break;case"t":u=a,g=h,"Q"===(c=n[n.length-1]).command&&(u=a+(a-c.points[0]),g=h+(h-c.points[1])),a+=i.shift(),h+=i.shift(),t="Q",s.push(u,g,a,h);break;case"A":f=i.shift(),p=i.shift(),m=i.shift(),_=i.shift(),v=i.shift(),y=a,w=h,a=i.shift(),h=i.shift(),t="A",s=this.convertEndpointToCenterParameterization(y,w,a,h,_,v,f,p,m);break;case"a":f=i.shift(),p=i.shift(),m=i.shift(),_=i.shift(),v=i.shift(),y=a,w=h,a+=i.shift(),h+=i.shift(),t="A",s=this.convertEndpointToCenterParameterization(y,w,a,h,_,v,f,p,m)}n.push({command:t||e,points:s,start:{x:r,y:o},pathLength:this.calcLength(r,o,t||e,s)})}"z"!==e&&"Z"!==e||n.push({command:"z",points:[],start:void 0,pathLength:0})}return n}static calcLength(e,i,r,n){let o,a,h,l;const d=t;switch(r){case"L":return d.getLineLength(e,i,n[0],n[1]);case"C":return(0,s.getCubicArcLength)([e,n[0],n[2],n[4]],[i,n[1],n[3],n[5]],1);case"Q":return(0,s.getQuadraticArcLength)([e,n[0],n[2]],[i,n[1],n[3]],1);case"A":o=0;var c=n[4],u=n[5],g=n[4]+u,f=Math.PI/180;if(Math.abs(c-g)<f&&(f=Math.abs(c-g)),a=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),u<0)for(l=c-f;l>g;l-=f)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;else for(l=c+f;l<g;l+=f)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;return h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],g,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(t,e,i,s,r,n,o,a,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-s)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-s)/2,u=d*d/(o*o)+c*c/(a*a);u>1&&(o*=Math.sqrt(u),a*=Math.sqrt(u));let g=Math.sqrt((o*o*(a*a)-o*o*(c*c)-a*a*(d*d))/(o*o*(c*c)+a*a*(d*d)));r===n&&(g*=-1),isNaN(g)&&(g=0);const f=g*o*c/a,p=g*-a*d/o,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+s)/2+Math.sin(l)*f+Math.cos(l)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},x=w([1,0],[(d-f)/o,(c-p)/a]),b=[(d-f)/o,(c-p)/a],S=[(-1*d-f)/o,(-1*c-p)/a];let C=w(b,S);return y(b,S)<=-1&&(C=Math.PI),y(b,S)>=1&&(C=0),0===n&&C>0&&(C-=2*Math.PI),1===n&&C<0&&(C+=2*Math.PI),[m,_,o,a,x,C,l,n]}};return Te.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"data"),Te}var Me,Fe={};var Ie,Re={};var De,Oe={};var Le,Ve={};var ze,Ge={};function Ne(){if(ze)return Ge;ze=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.Rect=void 0;const t=Dt(),e=re(),i=Ct(),s=Tt(),r=Rt();let n=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?s.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}};return Ge.Rect=n,n.prototype.className="Rect",(0,i._registerNode)(n),t.Factory.addGetterSetter(n,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),Ge}var We,Ue={};var Be,je={};var He,Ye={};var Xe,Ke={};var qe,Je={};function Ze(){if(qe)return Je;qe=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.Text=void 0,Je.stringToArray=o;const t=Tt(),e=Dt(),i=re(),s=Ct(),r=Rt(),n=Ct();function o(t){return[...t].reduce(((t,e,i,s)=>{if(/\p{Emoji}/u.test(e)){const r=s[i+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),s[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(s[i+1]||""))?t.push(e+s[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t}),[])}const a="auto",h="inherit",l="justify",d="left",c="middle",u="normal",g=" ",f="none",p=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],m=p.length;let _;function v(){return _||(_=t.Util.createCanvasElement().getContext("2d"),_)}let y=class extends i.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<m;t++)this.on(p[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let r,n=this.padding(),a=this.fontSize(),u=this.lineHeight()*a,g=this.verticalAlign(),f=this.direction(),p=0,m=this.align(),_=this.getWidth(),v=this.letterSpacing(),y=this.fill(),w=this.textDecoration(),x=-1!==w.indexOf("underline"),b=-1!==w.indexOf("line-through");f=f===h?t.direction:f;let S=u/2,C=c;if(s.Konva._fixTextRendering){const t=this.measureSize("M");C="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var P=0,A=0;for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",C),t.setAttr("textAlign",d),g===c?p=(this.getHeight()-i*u-2*n)/2:"bottom"===g&&(p=this.getHeight()-i*u-2*n),t.translate(n,p+n),r=0;r<i;r++){P=0,A=0;var T,E,k=e[r],M=k.text,F=k.width,I=k.lastInParagraph;if(t.save(),"right"===m?P+=_-F-2*n:"center"===m&&(P+=(_-F-2*n)/2),x){t.save(),t.beginPath();const e=P,i=S+A+(s.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i),T=M.split(" ").length-1,E=m!==l||I?F:_-2*n,t.lineTo(e+Math.round(E),i),t.lineWidth=a/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=s.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(P,S+A+e),T=M.split(" ").length-1,E=m!==l||I?F:_-2*n,t.lineTo(P+Math.round(E),S+A+e),t.lineWidth=a/15;const i=this._getLinearGradient();t.strokeStyle=i||y,t.stroke(),t.restore()}if("rtl"===f||0===v&&m!==l)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=P,this._partialTextY=S+A,this._partialText=M,t.fillStrokeShape(this);else{T=M.split(" ").length-1;const e=o(M);for(let i=0;i<e.length;i++){const s=e[i];" "!==s||I||m!==l||(P+=(_-2*n-F)/T),this._partialTextX=P,this._partialTextY=S+A,this._partialText=s,t.fillStrokeShape(this),P+=this.measureSize(s).width+v}}t.restore(),i>1&&(S+=u)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===a||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===a||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,s,r,n,o,a,h,l,d,c;let u,g=v(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(s=u.actualBoundingBoxLeft)&&void 0!==s?s:-7.421875*p,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*p,alphabeticBaseline:null!==(n=u.alphabeticBaseline)&&void 0!==n?n:0,emHeightAscent:null!==(o=u.emHeightAscent)&&void 0!==o?o:100*p,emHeightDescent:null!==(a=u.emHeightDescent)&&void 0!==a?a:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+g+this.fontVariant()+g+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===l&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return v().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,s=this.lineHeight()*e,r=this.attrs.width,n=this.attrs.height,h=r!==a&&void 0!==r,l=n!==a&&void 0!==n,d=this.padding(),c=r-2*d,u=n-2*d,p=0,m=this.wrap(),_="char"!==m&&m!==f,y=this.ellipsis();this.textArr=[],v().font=this._getContextFont();const w=y?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let n=t[e],a=this._getTextWidth(n);if(h&&a>c)for(;n.length>0;){let t=0,e=o(n).length,r="",h=0;for(;t<e;){const i=t+e>>>1,s=o(n).slice(0,i+1).join(""),a=this._getTextWidth(s)+w;a<=c?(t=i+1,r=s,h=a):e=i}if(!r)break;if(_){const e=o(n),i=o(r),s=e[i.length];let a;if((s===g||"-"===s)&&h<=c)a=i.length;else{const t=i.lastIndexOf(g),e=i.lastIndexOf("-");a=Math.max(t,e)+1}a>0&&(t=a,r=e.slice(0,t).join(""),h=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),i=Math.max(i,h),p+=s;if(this._shouldHandleEllipsis(p)){this._tryToAddEllipsisToLastLine();break}if(n=o(n).slice(t).join("").trimLeft(),n.length>0&&(a=this._getTextWidth(n),a<=c)){this._addTextLine(n),p+=s,i=Math.max(i,a);break}}else this._addTextLine(n),p+=s,i=Math.max(i,a),this._shouldHandleEllipsis(p)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&p+s>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,s=this.attrs.height,r=s!==a&&void 0!==s,n=s-2*this.padding();return!(this.wrap()!==f)||r&&t+i>n}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==a&&void 0!==t,i=t-2*this.padding(),s=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&s){if(e){this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}};return Je.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,n._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",h),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",d),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),Je}var $e,Qe={};var ti,ei={};function ii(){if(ti)return ei;ti=1,Object.defineProperty(ei,"__esModule",{value:!0}),ei.Transformer=void 0;const t=Tt(),e=Dt(),i=Ht(),s=re(),r=Ne(),n=de(),o=Ct(),a=Rt(),h=Ct(),l="tr-konva",d=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${l}`)).join(" "),c="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],g={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},f="ontouchstart"in o.Konva._global;const p=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function m(t,e,i){const s=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:s,y:r}}function _(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return m(t,e,i)}let v=0,y=class extends n.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(d,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return l+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(u.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const s=t.getAbsolutePosition(),r=s.x-e.x,n=s.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const s=e.getAbsolutePosition();e.setAbsolutePosition({x:s.x+r,y:s.y+n}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(c),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(c,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const s=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),n=t.getAbsolutePosition(i),a=s.x*r.x-t.offsetX()*r.x,h=s.y*r.y-t.offsetY()*r.y,l=(o.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return m({x:n.x+a*Math.cos(l)+h*Math.sin(-l),y:n.y+h*Math.cos(l)+a*Math.sin(l),width:s.width*r.x,height:s.height*r.y,rotation:l},-o.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],r=t.getAbsoluteTransform();s.forEach((function(t){const i=r.point(t);e.push(i)}))}));const i=new t.Transform;i.rotate(-o.Konva.getAngle(this.rotation()));let s=1/0,r=1/0,n=-1/0,a=-1/0;e.forEach((function(t){const e=i.point(t);void 0===s&&(s=n=e.x,r=a=e.y),s=Math.min(s,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y)})),i.invert();const h=i.point({x:s,y:r});return{x:h.x,y:h.y,width:n-s,height:a-r,rotation:o.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),p.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const i=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:f?10:"auto"}),s=this;i.on("mousedown touchstart",(function(t){s._handleMouseDown(t)})),i.on("dragstart",(t=>{i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(t=>{t.cancelBubble=!0})),i.on("mouseenter",(()=>{const s=o.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),n=function(e,i,s){if("rotater"===e)return s;i+=t.Util.degToRad(g[e]||0);const r=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,s,r);i.getStage().content&&(i.getStage().content.style.cursor=n),this._cursorChange=!0})),i.on("mouseout",(()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(i)}_createBack(){const e=new s.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const s=i.getParent(),r=s.padding();e.beginPath(),e.rect(-r,-r,i.width()+2*r,i.height()+2*r),e.moveTo(i.width()/2,-r),s.rotateEnabled()&&s.rotateLineVisible()&&e.lineTo(i.width()/2,-s.rotateAnchorOffset()*t.Util._sign(i.height())-r),e.fillStrokeShape(i)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,s=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(s,2));this.sin=Math.abs(s/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const n=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-n.x,y:o.y-n.y},v++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,i,s;const r=this.findOne("."+this._movingAnchorName),n=r.getStage();n.setPointersPositions(t);const a=n.getPointerPosition();let h={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const d=r.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const s=this._getNodeRect();e=r.x()-s.width/2,i=-r.y()+s.height/2;let n=Math.atan2(-i,e)+Math.PI/2;s.height<0&&(n-=Math.PI);const a=o.Konva.getAngle(this.rotation())+n,h=o.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let s=e;for(let r=0;r<t.length;r++){const n=o.Konva.getAngle(t[r]),a=Math.abs(n-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(s=n)}return s}(this.rotationSnaps(),a,h),d=_(s,l-s.rotation);return void this._fitNodesInto(d,t)}const c=this.shiftBehavior();let u;u="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};s=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(f.y-r.y(),2));var p=this.findOne(".top-left").x()>f.x?-1:1,m=this.findOne(".top-left").y()>f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".top-left").x(f.x-e),this.findOne(".top-left").y(f.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(f.y-r.y(),2));p=this.findOne(".top-right").x()<f.x?-1:1,m=this.findOne(".top-right").y()>f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".top-right").x(f.x+e),this.findOne(".top-right").y(f.y-i)}var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(r.y()-f.y,2));p=f.x<r.x()?-1:1,m=r.y()<f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,r.x(f.x-e),r.y(f.y+i)}v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){f=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};s=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(r.y()-f.y,2));p=this.findOne(".bottom-right").x()<f.x?-1:1,m=this.findOne(".bottom-right").y()<f.y?-1:1;e=s*this.cos*p,i=s*this.sin*m,this.findOne(".bottom-right").x(f.x+e),this.findOne(".bottom-right").y(f.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),s=t.y(),r=this.getWidth()-e.x(),n=this.getHeight()-e.y();e.move({x:-i,y:-s}),t.move({x:r,y:n})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,i=y.y;const w=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),x=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:w,height:x,rotation:o.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();v--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,i){const s=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(o.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(s,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const n=1e7,a=new t.Transform;a.translate(s.x,s.y),a.rotate(s.rotation),a.scale(s.width/n,s.height/n);const h=new t.Transform,l=e.width/n,d=e.height/n;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,d));const c=h.multiply(a.invert());this._nodes.forEach((e=>{var i;const s=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const n=new t.Transform;n.multiply(s.copy().invert()).multiply(c).multiply(s).multiply(r);const o=n.decompose();e.setAttrs(o),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const s=i.width,r=i.height,n=this.enabledAnchors(),o=this.resizeEnabled(),a=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach((t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+a,offsetY:h/2+a,visible:o&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:s/2,y:0,offsetY:h/2+a,visible:o&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:s,y:0,offsetX:h/2-a,offsetY:h/2+a,visible:o&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+a,visible:o&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:s,y:r/2,offsetX:h/2-a,visible:o&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:s/2,y:r,offsetY:h/2-a,visible:o&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:s,y:r,offsetX:h/2-a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:s/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:s,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const d=this.anchorStyleFunc();d&&l.forEach((t=>{d(t)})),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),n.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return ei.Transformer=y,y.isTransforming=()=>v>0,y.prototype.className="Transformer",(0,h._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",p,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===p.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+p.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,a.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),ei}var si,ri={};var ni,oi={};function ai(){if(ni)return oi;ni=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.Blur=void 0;const t=Dt(),e=Ht(),i=Rt();function s(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],n=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];return oi.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,o=t.width,a=t.height;let h,l,d,c,u,g,f,p,m,_,v,y,w,x,b,S,C,P,A,T,E,k,M,F;const I=e+e+1,R=o-1,D=a-1,O=e+1,L=O*(O+1)/2,V=new s,z=r[e],G=n[e];let N=null,W=V,U=null,B=null;for(d=1;d<I;d++)W=W.next=new s,d===O&&(N=W);for(W.next=V,f=g=0,l=0;l<a;l++){for(S=C=P=A=p=m=_=v=0,y=O*(T=i[g]),w=O*(E=i[g+1]),x=O*(k=i[g+2]),b=O*(M=i[g+3]),p+=L*T,m+=L*E,_+=L*k,v+=L*M,W=V,d=0;d<O;d++)W.r=T,W.g=E,W.b=k,W.a=M,W=W.next;for(d=1;d<O;d++)c=g+((R<d?R:d)<<2),p+=(W.r=T=i[c])*(F=O-d),m+=(W.g=E=i[c+1])*F,_+=(W.b=k=i[c+2])*F,v+=(W.a=M=i[c+3])*F,S+=T,C+=E,P+=k,A+=M,W=W.next;for(U=V,B=N,h=0;h<o;h++)i[g+3]=M=v*z>>G,0!==M?(M=255/M,i[g]=(p*z>>G)*M,i[g+1]=(m*z>>G)*M,i[g+2]=(_*z>>G)*M):i[g]=i[g+1]=i[g+2]=0,p-=y,m-=w,_-=x,v-=b,y-=U.r,w-=U.g,x-=U.b,b-=U.a,c=f+((c=h+e+1)<R?c:R)<<2,S+=U.r=i[c],C+=U.g=i[c+1],P+=U.b=i[c+2],A+=U.a=i[c+3],p+=S,m+=C,_+=P,v+=A,U=U.next,y+=T=B.r,w+=E=B.g,x+=k=B.b,b+=M=B.a,S-=T,C-=E,P-=k,A-=M,B=B.next,g+=4;f+=o}for(h=0;h<o;h++){for(C=P=A=S=m=_=v=p=0,g=h<<2,y=O*(T=i[g]),w=O*(E=i[g+1]),x=O*(k=i[g+2]),b=O*(M=i[g+3]),p+=L*T,m+=L*E,_+=L*k,v+=L*M,W=V,d=0;d<O;d++)W.r=T,W.g=E,W.b=k,W.a=M,W=W.next;for(u=o,d=1;d<=e;d++)g=u+h<<2,p+=(W.r=T=i[g])*(F=O-d),m+=(W.g=E=i[g+1])*F,_+=(W.b=k=i[g+2])*F,v+=(W.a=M=i[g+3])*F,S+=T,C+=E,P+=k,A+=M,W=W.next,d<D&&(u+=o);for(g=h,U=V,B=N,l=0;l<a;l++)c=g<<2,i[c+3]=M=v*z>>G,M>0?(M=255/M,i[c]=(p*z>>G)*M,i[c+1]=(m*z>>G)*M,i[c+2]=(_*z>>G)*M):i[c]=i[c+1]=i[c+2]=0,p-=y,m-=w,_-=x,v-=b,y-=U.r,w-=U.g,x-=U.b,b-=U.a,c=h+((c=l+O)<D?c:D)*o<<2,p+=S+=U.r=i[c],m+=C+=U.g=i[c+1],_+=P+=U.b=i[c+2],v+=A+=U.a=i[c+3],U=U.next,y+=T=B.r,w+=E=B.g,x+=k=B.b,b+=M=B.a,S-=T,C-=E,P-=k,A-=M,B=B.next,g+=o}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),oi}var hi,li={};var di,ci={};var ui,gi={};var fi,pi={};var mi,_i={};var vi,yi={};var wi,xi={};var bi,Si={};var Ci,Pi={};function Ai(){if(Ci)return Pi;Ci=1,Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.Kaleidoscope=void 0;const t=Dt(),e=Ht(),i=Tt(),s=Rt();return Pi.Kaleidoscope=function(t){const e=t.width,s=t.height;let r,n,o,a,h,l,d,c,u,g,f=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(p%360)/360);if(f<1)return;const _=i.Util.createCanvasElement();_.width=e,_.height=s;const v=_.getContext("2d").getImageData(0,0,e,s);i.Util.releaseCanvas(_),function(t,e,i){const s=t.data,r=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n,p=360/f*Math.PI/180;for(let t=0;t<f;t+=1){const e=Math.sin(t*p),i=Math.cos(t*p);for(let o=0;o<g;o+=1){d=Math.floor(a+l*o/g*i),c=Math.floor(h+l*o/g*e);let u=4*(c*n+d);const f=s[u+0],p=s[u+1],m=s[u+2],_=s[u+3];u=4*(t+o*n),r[u+0]=f,r[u+1]=p,r[u+2]=m,r[u+3]=_}}}(t,v,{polarCenterX:e/2,polarCenterY:s/2});let y=e/Math.pow(2,f);for(;y<=8;)y*=2,f-=1;y=Math.ceil(y);let w=y,x=0,b=w,S=1;for(m+y>e&&(x=w,b=0,S=-1),n=0;n<s;n+=1)for(r=x;r!==b;r+=S)o=Math.round(r+m)%e,u=4*(e*n+o),h=v.data[u+0],l=v.data[u+1],d=v.data[u+2],c=v.data[u+3],g=4*(e*n+r),v.data[g+0]=h,v.data[g+1]=l,v.data[g+2]=d,v.data[g+3]=c;for(n=0;n<s;n+=1)for(w=Math.floor(y),a=0;a<f;a+=1){for(r=0;r<w+1;r+=1)u=4*(e*n+r),h=v.data[u+0],l=v.data[u+1],d=v.data[u+2],c=v.data[u+3],g=4*(e*n+2*w-r-1),v.data[g+0]=h,v.data[g+1]=l,v.data[g+2]=d,v.data[g+3]=c;w*=2}!function(t,e,i){const s=t.data,r=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n;let p,m;for(d=0;d<n;d+=1)for(c=0;c<o;c+=1){const t=d-a,e=c-h,i=Math.sqrt(t*t+e*e)*g/l;let o=(180*Math.atan2(e,t)/Math.PI+360+0)%360;o=o*f/360,p=Math.floor(o),m=Math.floor(i);let u=4*(m*n+p);const _=s[u+0],v=s[u+1],y=s[u+2],w=s[u+3];u=4*(c*n+d),r[u+0]=_,r[u+1]=v,r[u+2]=y,r[u+3]=w}}(v,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),Pi}var Ti,Ei={};function ki(){if(Ti)return Ei;Ti=1,Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.Mask=void 0;const t=Dt(),e=Ht(),i=Rt();function s(t,e,i){let s=4*(i*t.width+e);const r=[];return r.push(t.data[s++],t.data[s++],t.data[s++],t.data[s++]),r}function r(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return Ei.Mask=function(t){let e=function(t,e){const i=s(t,0,0),n=s(t,t.width-1,0),o=s(t,0,t.height-1),a=s(t,t.width-1,t.height-1),h=e||10;if(r(i,n)<h&&r(n,a)<h&&r(a,o)<h&&r(o,i)<h){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,a,o]),s=[];for(let i=0;i<t.width*t.height;i++){const n=r(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);s[i]=n<h?0:255}return s}}(t,this.threshold());return e&&(e=function(t,e,i){const s=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=2040===d?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const s=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=d>=1020?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const s=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<r;o++)for(let l=0;l<r;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=s[o*r+l];d+=t[c*e+u]*i}}o[l]=d}return o}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Ei}var Mi,Fi={};var Ii,Ri={};var Di,Oi={};var Li,Vi={};var zi,Gi={};var Ni,Wi={};var Ui,Bi={};var ji,Hi,Yi={};function Xi(){if(Hi)return xt;Hi=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.Konva=void 0;const t=_e(),e=function(){if(ve)return ye;ve=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.Arc=void 0;const t=Dt(),e=re(),i=Ct(),s=Rt(),r=Ct();let n=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),s=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,s),t.arc(0,0,this.innerRadius(),e,0,!s),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),s=this.clockwise(),r=i.Konva.getAngle(s?360-this.angle():this.angle()),n=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),h=n*(n>0?t:e),l=o*(o>0?t:e),d=a*(a>0?e:t);return{x:h,y:s?-1*d:l,width:1*e-h,height:d-l}}};return ye.Arc=n,n.prototype._centroid=!0,n.prototype.className="Arc",n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1,(0,s.getBooleanValidator)()),ye}(),i=function(){if(Ae)return xe;Ae=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.Arrow=void 0;const t=Dt(),e=Se(),i=Rt(),s=Ct(),r=ke();let n=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let s=i;const n=0!==this.tension()&&i.length>4;n&&(s=this.getTensionPoints());const o=this.pointerLength(),a=i.length;let h,l;if(n){const t=[s[s.length-4],s[s.length-3],s[s.length-2],s[s.length-1],i[a-2],i[a-1]],e=r.Path.calcLength(s[s.length-4],s[s.length-3],"C",t),n=r.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[a-2]-n.x,l=i[a-1]-n.y}else h=i[a-2]-i[a-4],l=i[a-1]-i[a-3];const d=(Math.atan2(l,h)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(d),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),n?(h=(s[0]+s[2])/2-i[0],l=(s[1]+s[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}};return xe.Arrow=n,n.prototype.className="Arrow",(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerAtBeginning",!1),t.Factory.addGetterSetter(n,"pointerAtEnding",!0),xe}(),s=function(){if(Me)return Fe;Me=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.Circle=void 0;const t=Dt(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}};return Fe.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),Fe}(),r=function(){if(Ie)return Re;Ie=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.Ellipse=void 0;const t=Dt(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}};return Re.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,s._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,i.getNumberValidator)()),Re}(),n=function(){if(De)return Oe;De=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.Image=void 0;const t=Tt(),e=Dt(),i=re(),s=Ct(),r=Rt();class n extends i.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const i=this.getWidth(),s=this.getHeight(),r=this.cornerRadius(),n=this.attrs.image;let o;if(n){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;o=t&&e?[n,this.cropX(),this.cropY(),t,e,0,0,i,s]:[n,0,0,i,s]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,s,r):e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)),n&&(r&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){const i=this.width(),s=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,i,s,r):e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,s=null){const r=t.Util.createImageElement();r.onload=function(){const t=new n({image:r});i(t)},r.onerror=s,r.crossOrigin="Anonymous",r.src=e}}return Oe.Image=n,n.prototype.className="Image",(0,s._registerNode)(n),e.Factory.addGetterSetter(n,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(n,"image"),e.Factory.addComponentsGetterSetter(n,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(n,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropHeight",0,(0,r.getNumberValidator)()),Oe}(),o=function(){if(Le)return Ve;Le=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Tag=Ve.Label=void 0;const t=Dt(),e=re(),i=de(),s=Rt(),r=Ct(),n=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],o="up",a="right",h="down",l="left",d=n.length;let c=class extends i.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const s=function(){i._sync()};for(e=0;e<d;e++)t.on(n[e]+"Change.konva",s)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,s,r,n,d,c=this.getText(),u=this.getTag();if(c&&u){switch(t=c.width(),e=c.height(),i=u.pointerDirection(),s=u.pointerWidth(),d=u.pointerHeight(),r=0,n=0,i){case o:r=t/2,n=-1*d;break;case a:r=t+s,n=e/2;break;case h:r=t/2,n=e+d;break;case l:r=-1*s,n=e/2}u.setAttrs({x:-1*r,y:-1*n,width:t,height:e}),c.setAttrs({x:-1*r,y:-1*n})}}};Ve.Label=c,c.prototype.className="Label",(0,r._registerNode)(c);class u extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),s=this.pointerDirection(),r=this.pointerWidth(),n=this.pointerHeight(),d=this.cornerRadius();let c=0,u=0,g=0,f=0;"number"==typeof d?c=u=g=f=Math.min(d,e/2,i/2):(c=Math.min(d[0]||0,e/2,i/2),u=Math.min(d[1]||0,e/2,i/2),f=Math.min(d[2]||0,e/2,i/2),g=Math.min(d[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(c,0),s===o&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*n),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),s===a&&(t.lineTo(e,(i-n)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+n)/2)),t.lineTo(e,i-f),t.arc(e-f,i-f,f,0,Math.PI/2,!1),s===h&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+n),t.lineTo((e-r)/2,i)),t.lineTo(g,i),t.arc(g,i-g,g,Math.PI/2,Math.PI,!1),s===l&&(t.lineTo(0,(i+n)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-n)/2)),t.lineTo(0,c),t.arc(c,c,c,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),s=this.pointerHeight(),r=this.pointerDirection(),n=this.width(),d=this.height();return r===o?(e-=s,d+=s):r===h?d+=s:r===l?(t-=1.5*i,n+=i):r===a&&(n+=1.5*i),{x:t,y:e,width:n,height:d}}}return Ve.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),Ve}(),a=Se(),h=ke(),l=Ne(),d=function(){if(We)return Ue;We=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.RegularPolygon=void 0;const t=Dt(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let s=0;s<t;s++)i.push({x:e*Math.sin(2*s*Math.PI/t),y:-1*e*Math.cos(2*s*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,s=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),s=Math.min(s,t.y),r=Math.max(r,t.y)})),{x:e,y:s,width:i-e,height:r-s}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Ue.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,i.getNumberValidator)()),Ue}(),c=function(){if(Be)return je;Be=1,Object.defineProperty(je,"__esModule",{value:!0}),je.Ring=void 0;const t=Dt(),e=re(),i=Rt(),s=Ct(),r=2*Math.PI;let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return je.Ring=n,n.prototype.className="Ring",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,i.getNumberValidator)()),je}(),u=function(){if(He)return Ye;He=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Sprite=void 0;const t=Dt(),e=re(),i=ge(),s=Rt(),r=Ct();let n=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),s=4*i,r=this.animations()[e],n=this.frameOffsets(),o=r[s+0],a=r[s+1],h=r[s+2],l=r[s+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(n){const s=n[e],r=2*i;t.drawImage(d,o,a,h,l,s[r+0],s[r+1],h,l)}else t.drawImage(d,o,a,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),s=4*i,r=this.animations()[e],n=this.frameOffsets(),o=r[s+2],a=r[s+3];if(t.beginPath(),n){const s=n[e],r=2*i;t.rect(s[r+0],s[r+1],o,a)}else t.rect(0,0,o,a);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}};return Ye.Sprite=n,n.prototype.className="Sprite",(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"animation"),t.Factory.addGetterSetter(n,"animations"),t.Factory.addGetterSetter(n,"frameOffsets"),t.Factory.addGetterSetter(n,"image"),t.Factory.addGetterSetter(n,"frameIndex",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"frameRate",17,(0,s.getNumberValidator)()),t.Factory.backCompat(n,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Ye}(),g=function(){if(Xe)return Ke;Xe=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.Star=void 0;const t=Dt(),e=re(),i=Rt(),s=Ct();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),s=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let r=1;r<2*s;r++){const n=r%2==0?i:e,o=n*Math.sin(r*Math.PI/s),a=-1*n*Math.cos(r*Math.PI/s);t.lineTo(o,a)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return Ke.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,s._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,i.getNumberValidator)()),Ke}(),f=Ze(),p=function(){if($e)return Qe;$e=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.TextPath=void 0;const t=Tt(),e=Dt(),i=re(),s=ke(),r=Ze(),n=Rt(),o=Ct(),a="normal";function h(t){t.fillText(this.partialText,0,0)}function l(t){t.strokeText(this.partialText,0,0)}let d=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return s.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:s.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=s.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),s=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<r.length;i++){t.save();const n=r[i].p0;t.translate(n.x,n.y),t.rotate(r[i].rotation),this.partialText=r[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,s/2+1),t.lineTo(s,s/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=s/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const s=e[i].p1;t.lineTo(s.x,s.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),n=this.align(),o=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===n&&(h=Math.max(0,this.pathLength/2-a/2)),"right"===n&&(h=Math.max(0,this.pathLength-a));const l=(0,r.stringToArray)(this.text());let d=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(d);if(!e)return;let r=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===n){const t=this.text().split(" ").length-1;r+=(this.pathLength-a)/t}const h=this._getPointAtLength(d+r);if(!h)return;const c=s.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(o)try{u=o(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const g=s.Path.getPointOnLine(u+c/2,e.x,e.y,h.x,h.y),f=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:l[t],rotation:f,p0:e,p1:h}),d+=r}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));let e,i,s=t[0]||0,r=t[0]||0,n=t[1]||0,o=t[1]||0;for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],s=Math.min(s,e),r=Math.max(r,e),n=Math.min(n,i),o=Math.max(o,i);const a=this.fontSize();return{x:s-a/2,y:n-a/2,width:r-s+a,height:o-n+a}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Qe.TextPath=d,d.prototype._fillFunc=h,d.prototype._strokeFunc=l,d.prototype._fillFuncHit=h,d.prototype._strokeFuncHit=l,d.prototype.className="TextPath",d.prototype._attrsAffectingSize=["text","fontSize","data"],(0,o._registerNode)(d),e.Factory.addGetterSetter(d,"data"),e.Factory.addGetterSetter(d,"fontFamily","Arial"),e.Factory.addGetterSetter(d,"fontSize",12,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(d,"fontStyle",a),e.Factory.addGetterSetter(d,"align","left"),e.Factory.addGetterSetter(d,"letterSpacing",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(d,"textBaseline","middle"),e.Factory.addGetterSetter(d,"fontVariant",a),e.Factory.addGetterSetter(d,"text",""),e.Factory.addGetterSetter(d,"textDecoration",""),e.Factory.addGetterSetter(d,"kerningFunc",void 0),Qe}(),m=ii(),_=function(){if(si)return ri;si=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.Wedge=void 0;const t=Dt(),e=re(),i=Ct(),s=Rt(),r=Ct();let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return ri.Wedge=n,n.prototype.className="Wedge",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,s.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1),t.Factory.backCompat(n,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),ri}(),v=ai(),y=function(){if(hi)return li;hi=1,Object.defineProperty(li,"__esModule",{value:!0}),li.Brighten=void 0;const t=Dt(),e=Ht(),i=Rt();return li.Brighten=function(t){const e=255*this.brightness(),i=t.data,s=i.length;for(let t=0;t<s;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),li}(),w=function(){if(di)return ci;di=1,Object.defineProperty(ci,"__esModule",{value:!0}),ci.Contrast=void 0;const t=Dt(),e=Ht(),i=Rt();return ci.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,s=i.length;let r=150,n=150,o=150;for(let t=0;t<s;t+=4)r=i[t],n=i[t+1],o=i[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,r=r<0?0:r>255?255:r,n=n<0?0:n>255?255:n,o=o<0?0:o>255?255:o,i[t]=r,i[t+1]=n,i[t+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ci}(),x=function(){if(ui)return gi;ui=1,Object.defineProperty(gi,"__esModule",{value:!0}),gi.Emboss=void 0;const t=Dt(),e=Ht(),i=Tt(),s=Rt();return gi.Emboss=function(t){const e=10*this.embossStrength(),s=255*this.embossWhiteLevel(),r=this.embossDirection(),n=this.embossBlend(),o=t.data,a=t.width,h=t.height,l=4*a;let d=0,c=0,u=h;switch(r){case"top-left":d=-1,c=-1;break;case"top":d=-1,c=0;break;case"top-right":d=-1,c=1;break;case"right":d=0,c=1;break;case"bottom-right":d=1,c=1;break;case"bottom":d=1,c=0;break;case"bottom-left":d=1,c=-1;break;case"left":d=0,c=-1;break;default:i.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*l;let i=d;u+i<1&&(i=0),u+i>h&&(i=0);const r=(u-1+i)*a*4;let g=a;do{const i=t+4*(g-1);let h=c;g+h<1&&(h=0),g+h>a&&(h=0);const l=r+4*(g-1+h),d=o[i]-o[l],u=o[i+1]-o[l+1],f=o[i+2]-o[l+2];let p=d;const m=p>0?p:-p;if((u>0?u:-u)>m&&(p=u),(f>0?f:-f)>m&&(p=f),p*=e,n){const t=o[i]+p,e=o[i+1]+p,s=o[i+2]+p;o[i]=t>255?255:t<0?0:t,o[i+1]=e>255?255:e<0?0:e,o[i+2]=s>255?255:s<0?0:s}else{let t=s-p;t<0?t=0:t>255&&(t=255),o[i]=o[i+1]=o[i+2]=t}}while(--g)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),gi}(),b=function(){if(fi)return pi;fi=1,Object.defineProperty(pi,"__esModule",{value:!0}),pi.Enhance=void 0;const t=Dt(),e=Ht(),i=Rt();function s(t,e,i,s,r){const n=i-e,o=r-s;if(0===n)return s+o/2;if(0===o)return s;let a=(t-e)/n;return a=o*a+s,a}return pi.Enhance=function(t){const e=t.data,i=e.length;let r,n,o,a=e[0],h=a,l=e[1],d=l,c=e[2],u=c;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)r=e[t+0],r<a?a=r:r>h&&(h=r),n=e[t+1],n<l?l=n:n>d&&(d=n),o=e[t+2],o<c?c=o:o>u&&(u=o);let f,p,m,_,v,y,w,x,b;h===a&&(h=255,a=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0?(p=h+g*(255-h),m=a-g*(a-0),v=d+g*(255-d),y=l-g*(l-0),x=u+g*(255-u),b=c-g*(c-0)):(f=.5*(h+a),p=h+g*(h-f),m=a+g*(a-f),_=.5*(d+l),v=d+g*(d-_),y=l+g*(l-_),w=.5*(u+c),x=u+g*(u-w),b=c+g*(c-w));for(let t=0;t<i;t+=4)e[t+0]=s(e[t+0],a,h,m,p),e[t+1]=s(e[t+1],l,d,y,v),e[t+2]=s(e[t+2],c,u,b,x)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),pi}(),S=(mi||(mi=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.Grayscale=void 0,_i.Grayscale=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}}),_i),C=function(){if(vi)return yi;vi=1,Object.defineProperty(yi,"__esModule",{value:!0}),yi.HSL=void 0;const t=Dt(),e=Ht(),i=Rt();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),yi.HSL=function(t){const e=t.data,i=e.length,s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,n=127*this.luminance(),o=1*s*Math.cos(r*Math.PI/180),a=1*s*Math.sin(r*Math.PI/180),h=.299+.701*o+.167*a,l=.587-.587*o+.33*a,d=.114-.114*o-.497*a,c=.299-.299*o-.328*a,u=.587+.413*o+.035*a,g=.114-.114*o+.293*a,f=.299-.3*o+1.25*a,p=.587-.586*o-1.05*a,m=.114+.886*o-.2*a;let _,v,y,w;for(let t=0;t<i;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],w=e[t+3],e[t+0]=h*_+l*v+d*y+n,e[t+1]=c*_+u*v+g*y+n,e[t+2]=f*_+p*v+m*y+n,e[t+3]=w},yi}(),P=function(){if(wi)return xi;wi=1,Object.defineProperty(xi,"__esModule",{value:!0}),xi.HSV=void 0;const t=Dt(),e=Ht(),i=Rt();return xi.HSV=function(t){const e=t.data,i=e.length,s=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,o=s*r*Math.cos(n*Math.PI/180),a=s*r*Math.sin(n*Math.PI/180),h=.299*s+.701*o+.167*a,l=.587*s-.587*o+.33*a,d=.114*s-.114*o-.497*a,c=.299*s-.299*o-.328*a,u=.587*s+.413*o+.035*a,g=.114*s-.114*o+.293*a,f=.299*s-.3*o+1.25*a,p=.587*s-.586*o-1.05*a,m=.114*s+.886*o-.2*a;let _,v,y,w;for(let t=0;t<i;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],w=e[t+3],e[t+0]=h*_+l*v+d*y,e[t+1]=c*_+u*v+g*y,e[t+2]=f*_+p*v+m*y,e[t+3]=w},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),xi}(),A=(bi||(bi=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.Invert=void 0,Si.Invert=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}),Si),T=Ai(),E=ki(),k=function(){if(Mi)return Fi;Mi=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.Noise=void 0;const t=Dt(),e=Ht(),i=Rt();return Fi.Noise=function(t){const e=255*this.noise(),i=t.data,s=i.length,r=e/2;for(let t=0;t<s;t+=4)i[t+0]+=r-2*r*Math.random(),i[t+1]+=r-2*r*Math.random(),i[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Fi}(),M=function(){if(Ii)return Ri;Ii=1,Object.defineProperty(Ri,"__esModule",{value:!0}),Ri.Pixelate=void 0;const t=Dt(),e=Tt(),i=Ht(),s=Rt();return Ri.Pixelate=function(t){let i,s,r,n,o,a,h,l,d,c,u,g,f,p,m=Math.ceil(this.pixelSize()),_=t.width,v=t.height,y=Math.ceil(_/m),w=Math.ceil(v/m),x=t.data;if(m<=0)e.Util.error("pixelSize value can not be <= 0");else for(g=0;g<y;g+=1)for(f=0;f<w;f+=1){for(n=0,o=0,a=0,h=0,l=g*m,d=l+m,c=f*m,u=c+m,p=0,i=l;i<d;i+=1)if(!(i>=_))for(s=c;s<u;s+=1)s>=v||(r=4*(_*s+i),n+=x[r+0],o+=x[r+1],a+=x[r+2],h+=x[r+3],p+=1);for(n/=p,o/=p,a/=p,h/=p,i=l;i<d;i+=1)if(!(i>=_))for(s=c;s<u;s+=1)s>=v||(r=4*(_*s+i),x[r+0]=n,x[r+1]=o,x[r+2]=a,x[r+3]=h)}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,s.getNumberValidator)(),t.Factory.afterSetFilter),Ri}(),F=function(){if(Di)return Oi;Di=1,Object.defineProperty(Oi,"__esModule",{value:!0}),Oi.Posterize=void 0;const t=Dt(),e=Ht(),i=Rt();return Oi.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,s=i.length,r=255/e;for(let t=0;t<s;t+=1)i[t]=Math.floor(i[t]/r)*r},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Oi}(),I=function(){if(Li)return Vi;Li=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.RGB=void 0;const t=Dt(),e=Ht(),i=Rt();return Vi.RGB=function(t){const e=t.data,i=e.length,s=this.red(),r=this.green(),n=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*s,e[t+1]=i*r,e[t+2]=i*n,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),Vi}(),R=function(){if(zi)return Gi;zi=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.RGBA=void 0;const t=Dt(),e=Ht(),i=Rt();return Gi.RGBA=function(t){const e=t.data,i=e.length,s=this.red(),r=this.green(),n=this.blue(),o=this.alpha();for(let t=0;t<i;t+=4){const i=1-o;e[t]=s*o+e[t]*i,e[t+1]=r*o+e[t+1]*i,e[t+2]=n*o+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),Gi}(),D=(Ni||(Ni=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.Sepia=void 0,Wi.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],s=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*i+.769*s+.189*r),e[t+1]=Math.min(255,.349*i+.686*s+.168*r),e[t+2]=Math.min(255,.272*i+.534*s+.131*r)}}),Wi),O=(Ui||(Ui=1,Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.Solarize=void 0,Bi.Solarize=function(t){const e=t.data,i=t.width,s=4*i;let r=t.height;do{const t=(r-1)*s;let n=i;do{const i=t+4*(n-1);let s=e[i],r=e[i+1],o=e[i+2];s>127&&(s=255-s),r>127&&(r=255-r),o>127&&(o=255-o),e[i]=s,e[i+1]=r,e[i+2]=o}while(--n)}while(--r)}),Bi),L=function(){if(ji)return Yi;ji=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.Threshold=void 0;const t=Dt(),e=Ht(),i=Rt();return Yi.Threshold=function(t){const e=255*this.threshold(),i=t.data,s=i.length;for(let t=0;t<s;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Yi}();return xt.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:s.Circle,Ellipse:r.Ellipse,Image:n.Image,Label:o.Label,Tag:o.Tag,Line:a.Line,Path:h.Path,Rect:l.Rect,RegularPolygon:d.RegularPolygon,Ring:c.Ring,Sprite:u.Sprite,Star:g.Star,Text:f.Text,TextPath:p.TextPath,Transformer:m.Transformer,Wedge:_.Wedge,Filters:{Blur:v.Blur,Brighten:y.Brighten,Contrast:w.Contrast,Emboss:x.Emboss,Enhance:b.Enhance,Grayscale:S.Grayscale,HSL:C.HSL,HSV:P.HSV,Invert:A.Invert,Kaleidoscope:T.Kaleidoscope,Mask:E.Mask,Noise:k.Noise,Pixelate:M.Pixelate,Posterize:F.Posterize,RGB:I.RGB,RGBA:R.RGBA,Sepia:D.Sepia,Solarize:O.Solarize,Threshold:L.Threshold}}),xt}var Ki,qi=wt.exports;var Ji=vt(function(){if(Ki)return wt.exports;Ki=1,Object.defineProperty(qi,"__esModule",{value:!0});const t=Xi();return wt.exports=t.Konva,wt.exports}());class Zi{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class $i{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const s=t=>{const e=t.toString(16);return"0"===e?"00":e};return s(t)+s(e)+s(i)}}const Qi=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class ts{constructor(t,e=null,i=new Zi){var s,r;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let s=0;s<e.length;s+=2)i=this._worldTransformer.screenToWorld({x:e[s],y:e[s+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const n=[],o=[];t.points.forEach((t=>{n.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});o.push({x:e.x,y:e.y,z:e.z})})),this._ref=new Ji.Line({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:n,draggable:!0,strokeScaleEnabled:!1,dash:Qi.get(t.type)||[]}),this._ref.setAttr("wcsPoints",o),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.on("transformend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let s;for(let r=0;r<i.length;r+=2){const n=t.point({x:i[r],y:i[r+1]});s=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:s.x,y:s.y,z:s.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.on("dragend",(()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let s;for(let r=0;r<i.length;r+=2){const n=t.point({x:i[r],y:i[r+1]});s=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:s.x,y:s.y,z:s.z})}this._ref.setAttr("wcsPoints",e)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Qi.get("dot"):t="dot";break;case Qi.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Qi.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach((t=>{e=e.concat([t.x,t.y]);const s=this._worldTransformer.screenToWorld(t);i.push(s)})),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach((t=>{let s=this._worldTransformer.worldToScreen(t);s=i.point({x:s.x,y:s.y}),e.push(s.x),e.push(s.y)})),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class es{constructor(t,e=null,i=new Zi){var s,r,n;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()}))}else t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Ji.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(s=t.fontSize)&&void 0!==s?s:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(n=t.rotation)&&void 0!==n?n:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY);r<50&&(r=50),n<Math.round(this.getFontSize())&&(n=Math.round(this.getFontSize())),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class is{constructor(t,e=null,i=new Zi){var s,r,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Ji.Rect({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(o=t.height)&&void 0!==o?o:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY);r<50&&(r=50),n<50&&(n=50),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}function ss(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class rs{constructor(t,e=null,i=new Zi){var s,r,n;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),s=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(s||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(s=t.radius)&&void 0!==s||(t.radius={x:0,y:0}),t.radius.x=ss(t.position,t.position2),t.position3?t.radius.y=ss(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Ji.Ellipse({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();i&&(r*=e.scaleX);let n=this._ref.radiusY();s&&(n*=e.scaleY);r<25&&(r=25),n<25&&(n=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:r,y:r}):this._ref.radius({x:n,y:n}):this._ref.radius({x:r,y:n}),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const s=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(s))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const s=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(s))})),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let s=this._ref.getStage().getAbsoluteTransform().copy();s=s.invert();const r=s.point({x:t.x,y:t.y});this._ref.position({x:r.x,y:r.y}),this._ref.radius({x:Math.abs(s.point(e).x-r.x),y:Math.abs(s.point(i).y-r.y)})}}class ns{constructor(t,e=null,i=new Zi){var s,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Ji.Arrow({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),s=this._ref.getAbsoluteTransform(),r=s.point({x:i[0],y:i[1]}),n=s.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(n))})),this._ref.on("dragend",(t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),s=i.point({x:e[0],y:e[1]}),r=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const s=i.point({x:t.x,y:t.y}),r=i.point({x:e.x,y:e.y});this._ref.points([s.x,s.y,r.x,r.y])}}class os{constructor(t,e=null,i=new Zi){var s,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}}else t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ji.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(s=t.width)&&void 0!==s?s:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(n/this._ratio),this._ref.height(n)):(i&&this._ref.width(r),s&&this._ref.height(n)),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}class as{constructor(t,e=null,i=new Zi){var s,r,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Ji.Shape({x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(o=t.lineWidth)&&void 0!==o?o:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),s=this._ref.height(),r=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+s},{x:0,y:0+s},{x:0,y:0}];function n(n,o){const a={x:(h={x:0,y:0}).x+i/2,y:h.y+s/2};var h;t.beginPath();for(let e=0;e<r.length-1;e++){let i=o;const s=r[e+1].x-r[e].x,h=r[e+1].y-r[e].y,l=Math.sqrt(s*s+h*h),d=Math.floor(l/i);i=o+d/(l%i);let c=r[e].x+s/d/2,u=r[e].y+h/d/2;const g=r[e+1].x,f=r[e+1].y,p=Math.atan((f-u)/(g-c)),m=p+Math.PI,_=c>a.x&&u>a.y;for(let e=0;e<d;e++)_?t.arc(c,u,n,p,m):t.arc(c,u,n,m,p),c+=s/d,u+=h/d}t.closePath(),t.fillStrokeShape(e)}i>=49||s>=49?n(8,15):i>=25||s>=25?n(4,7.5):(t.beginPath(),t.lineTo(r[1].x,r[1].y),t.lineTo(r[2].x,r[2].y),t.lineTo(r[3].x,r[3].y),t.lineTo(r[4].x,r[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",(t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,s=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();i&&(r*=e.scaleX);let n=this._ref.height();s&&(n*=e.scaleY),r<50&&(r=50),n<50&&(n=50),i&&this._ref.width(r),s&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.on("transformend",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))})),this._ref.on("dragend",(()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))})),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},s=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",s)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const s=i.point(t),r=i.point(e);this._ref.position({x:s.x,y:s.y}),this._ref.width(Math.abs(r.x-s.x)),this._ref.height(Math.abs(r.y-s.y))}}const hs={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new ts(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new es(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new is(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new rs(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new ns(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new os(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new as(e,t,...i)}};class ls{constructor(){this._markupIsActive=!1,this._markupColor=new $i(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach((t=>{t.updateScreenCoordinates()})))},this.pan=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.zoomAt=()=>{this.getObjects().forEach((t=>{t.updateScreenCoordinates()}))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,s){if(!Ji)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=s?s:new Zi,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...s)=>{i&&clearTimeout(i),i=setTimeout((()=>{i=null,t(...s)}),e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const s=new $i(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,s)}))}colorizeSelectedMarkups(t,e,i){const s=new $i(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,s)}))}setViewpoint(t){var e,i,s,r,n,o,a,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(s=t.texts)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(n=t.ellipses)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,s=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,s,t.radius,t.line_width,t.color,t.id)})),null===(o=t.arrows)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(a=t.clouds)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&hs[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=hs[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const s=i.initializer(null,e,this._worldTransformer);return this.addObject(s),s}getObjects(){const t=[];return Object.keys(hs).forEach((e=>{const i=hs[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e,null,this._worldTransformer))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(hs).find((t=>t.name===e));return i?i.initializer(t,null,this._worldTransformer):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=hs[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Ji.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ji.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ji.Group,e.add(this._groupImages),this._groupGeometry=new Ji.Group,e.add(this._groupGeometry),this._groupTexts=new Ji.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Ji.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let s,r,n,o=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const n=this.getRelativePointerPosition(t);r=n,o=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(s=this.addLine([n.x,n.y,n.x,n.y]))})),t.on("mouseup touchend",(()=>{if(this._markupIsActive){if(o){const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,s=i?r.x:Math.min(r.x,e.x),n=i?r.y:Math.min(r.y,e.y),o=i?200:Math.abs(r.x-e.x),a=i?200:Math.abs(r.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:s,y:n},null,o,a):"Ellipse"===this._markupMode?this.addEllipse({x:s,y:n},null,null,{x:o/2,y:a/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:i?r.x+200:e.x,y:i?n:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:s,y:n},null,Math.max(100,o),Math.max(100,a)))}n=void 0,o=!1}})),t.on("mousemove touchmove",(()=>{if(!this._markupIsActive)return;if(!o)return;const e=this.getRelativePointerPosition(t),i=r&&e.x===r.x&&e.y===r.y,a=i?r.x:Math.min(r.x,e.x),h=i?r.y:Math.min(r.y,e.y),l=i?200:Math.abs(r.x-e.x),d=i?200:Math.abs(r.y-e.y);"Line"===this._markupMode?s.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?n?n.setEndPoint(e.x,e.y):n=this.addArrow({x:r.x,y:r.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?n?(n.setPosition(a,h),n.setWidth(l),n.setHeight(d)):n=this.addRectangle({x:a,y:h},null,l,d):"Ellipse"===this._markupMode?n?(n.setPosition(a,h),n.setRadiusX(l),n.setRadiusY(d)):n=this.addEllipse({x:a,y:h},null,null,{x:l,y:d}):"Cloud"===this._markupMode&&(n?(n.setPosition(a,h),n.setWidth(Math.max(100,l)),n.setHeight(Math.max(100,d))):n=this.addCloud({x:a,y:h},null,l,d))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const s=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=i.nodes().indexOf(e.target)>=0;if(s||r){if(s&&r){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(s&&!r){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.getAttr("wcsPoints");if(!i)return;const s=new ts(null,e,this._worldTransformer),r={id:s.id(),points:i,color:s.getColor()||"#ff0000",type:s.getLineType()||this.lineType,width:s.getLineWidth()||this.lineWidth};t.push(r)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),s=e.getAttr("wcsStart"),r=this._konvaStage.getAbsoluteTransform(),n=new es(null,e,this._worldTransformer),o={id:n.id(),position:s,text:n.getText(),text_size:.02*i.y,angle:n.getRotation(),color:n.getColor(),font_size:n.getFontSize()*r.getMatrix()[0]};t.push(o)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(s),o=new is(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.getAttr("wcsPosition"),s=e.getAttr("wcsRadiusX"),r=e.getAttr("wcsRadiusY"),n=this._konvaStage.getAbsoluteTransform().getMatrix()[0],o=new rs(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,position3:r,radius:{x:e.getRadiusX()*n,y:e.getRadiusY()*n},line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=new ns(null,e,this._worldTransformer),n={id:r.id(),start:i,end:s,color:r.getColor()};t.push(n)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],n=new os(null,e,this._worldTransformer),o={id:n.id(),position:i,position2:s,src:n.getSrc(),width:n.getWidth()*r,height:n.getHeight()*r};t.push(o)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.getAttr("wcsStart"),s=e.getAttr("wcsEnd"),r=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(s),o=new as(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:s,width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,s,r){if(!t||0===t.length)return;const n=[];for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});const o=new ts({points:n,type:i||this.lineType,width:s||this.lineWidth,color:e||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(o),o}createTextInput(t,e,i,s,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=s,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},r&&(this._textInputRef.value=r),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{e(s.result)},s.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],s=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,s.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,s,r,n,o){var a;if(!t)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(r&&r>h&&(!n||n<h)){const t=.02;n=r/(this._worldTransformer.getScale().y/t)/34}const l=new es({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:n||this.fontSize,color:s||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,s,r,n,o){if(!t)return;const a=new is({position:t,position2:e,width:i,height:s,lineWidth:r||this.lineWidth,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addEllipse(t,e,i,s,r,n,o){if(!t)return;const a=new rs({position:t,position2:e,position3:i,radius:s,lineWidth:r,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addArrow(t,e,i,s){if(!t||!e)return;const r=new ns({start:t,end:e,color:i||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(r),r}addCloud(t,e,i,s,r,n,o){if(!t||!i||!s)return;const a=new as({position:t,position2:e,width:i,height:s,color:n||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:o},null,this._worldTransformer);return this.addObject(a),a}addImage(t,e,i,s,r,n){var o;if(!t||!i)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeImageInput();const a=new os({position:t,position2:e,src:i,width:s,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:n},null,this._worldTransformer);return this.addObject(a),a}}const ds="$MarkupTempEntity_Line";class cs extends y{constructor(t){super(t),this.press=!1}dispose(){super.dispose(),this.end(),this.points=null,this.drawPoints=null}start(t,e){const i=this.getViewer().screenToWorld(t,e);this.drawPoints=[i[0],i[1],i[2]]}drag(t,e){if(this.isDragging){const i=this.getViewer().screenToWorld(t,e);this.drawPoints.push(i[0],i[1],i[2]),this._updateFrame()}}end(){this.entity&&(this.entity.delete(),this.drawPoints=null,this.entity=null)}_updateFrame(){if(this.entity){const t=this.getViewer().getMarkupModel();t.removeEntity(this.entity),t.delete(),this.entity.delete()}this.entity=this.getActiveMarkupEntity(ds);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const us="$MarkupTempEntity_Text";class gs extends y{constructor(t){super(t),this.TEXT_HEIGHT_ALIGN=24,this.press=!1}dispose(){var t;super.dispose(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}_finishInput(){var t;this.textRef&&this.textRef.value.trimLeft()&&this._updateFrame(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}start(t,e,i,s){this.textRef?this._finishInput():(this.textRef=document.createElement("textarea"),this.textRef.style.zIndex="9999",this.textRef.style.position="absolute",this.textRef.style.display="block",this.textRef.style.top=s+"px",this.textRef.style.left=i+"px",this.textRef.onkeypress=t=>{"Enter"===t.key&&(t.preventDefault(),this._finishInput())},document.body.appendChild(this.textRef),this.press=!0,this.m_center=this.screenToWorld(t,e+this.TEXT_HEIGHT_ALIGN),this.needInputText=!0)}_updateFrame(){this.entity=this.getActiveMarkupEntity(us);const t=this.entity.openObject(),e=this.getViewer().activeView,i=this.toPoint(e.viewPosition),s=this.toPoint(e.viewTarget),r=e.eyeToWorldMatrix,n=i.sub(s).asVector(),o=this.toVector([1,0,0]).transformBy(r),a=this.createMatrix3d();a.setToWorldToPlane(this.toGeVector(n)),o.transformBy(a);const h=-Math.atan2(-o.y,o.x);let l=1;const d=e.projectionMatrix.get(1,1);d<1e-6&&d>-1e-6||(l=1/d);const c=t.appendText(this.toGePoint(this.m_center),this.textRef.value.trimLeft()),u=c.openAsText();u.setNormal(this.toGeVector(n)),u.setRotation(h),u.setTextSize(.02*l),u.delete(),c.delete(),t.delete()}}class fs{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=4,this.fontSize=34}initialize(t,e,i,s){this._viewer=i,this._viewer.registerDragger("Line",cs),this._viewer.registerDragger("Text",gs)}dispose(){}syncOverlay(){}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete()}getMarkupColor(){return this._markupColor}setMarkupColor(t,e,i){const s={r:t,g:e,b:i};this._markupColor=s,this._viewer.emitEvent({type:"changemarkupcolor",data:s})}colorizeAllMarkup(t=255,e=0,i=0){if(!this._viewer.visualizeJs)return;const s=this._viewer.visViewer().getMarkupModel().getEntitiesIterator();for(;!s.done();s.step()){const r=s.getEntity().openObject(),n=r.getName();n!==ds&&n!==us||r.setColor(t,e,i),r.delete()}s.delete(),this._viewer.update()}colorizeSelectedMarkups(t=255,e=0,i=0){throw new Error("Not implemented yet")}setViewpoint(t){function e(t){return[t.x,t.y,t.z]}function i(t,e){return t.Point3d.createFromArray(e)}if(!this._viewer.visualizeJs)return;const s=this._viewer.visLib(),r=this._viewer.visViewer().activeView;this._viewer.syncOverlay();const n=t.custom_fields.markup_color||{r:255,g:0,b:0};if(this.setMarkupColor(n.r,n.g,n.b),t.lines)for(const e of t.lines){const t=this._viewer.addMarkupEntity(ds).openObject(),i=[];for(const t of e.points)i.push(t.x,t.y,t.z);t.appendPolyline(i).delete(),t.delete()}if(t.texts){const n=i(s,r.viewPosition),o=i(s,r.viewTarget),a=n.sub(o).asVector();for(const i of t.texts){const t=this._viewer.addMarkupEntity(us).openObject(),s=t.appendText(e(i.position),i.text),r=s.openAsText();r.setNormal(e(a)),r.setRotation(i.angle),r.setTextSize(i.text_size),r.delete(),s.delete(),t.delete()}}this._viewer.update()}getViewpoint(t){if(!this._viewer.visualizeJs)return{};function e(t){return{x:t[0],y:t[1],z:t[2]}}const i=this._viewer.visLib(),s=this._viewer.visViewer();t||(t={}),t.lines=[],t.texts=[];const r=s.getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const i=r.getEntity().openObject(),s=i.getName(),n=i.getGeometryDataIterator();if(n.done()){i.delete();continue}const o=n.getGeometryData();if(s===ds){const i=o.openAsPolyline(),s=i.getPoints(),r={points:[]};for(const t of s)r.points.push(e(t));t.lines.push(r),i.delete()}else if(s===us){const i=o.openAsText(),s={position:e(i.getPosition()),text:i.getString(),angle:i.getRotation(),text_size:i.getTextSize()};t.texts.push(s),i.delete()}i.delete()}return r.delete(),t.snapshot={data:i.canvas.toDataURL("image/jpeg",.25)},t.custom_fields={markup_color:this.getMarkupColor()},t}enableEditMode(t){return this}createObject(t,e){}getObjects(){return[]}getSelectedObjects(){return[]}selectObjects(t){}clearSelected(){}}class ps{static createMarkup(t="Konva"){let e;switch(t){case"Konva":e=new ls;break;case"Visualize":e=new fs;break;default:throw new Error("Error during Markup initialization. Unknown Markup type.")}return e}}const ms="$OVERLAY_VIEW_NAME",_s=t=>null!=t;t.CANVAS_EVENTS=_,t.CanvasEvents=m,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.FileLoader=nt,t.Loader=d,t.Markup=ls,t.OdBaseDragger=y,t.Options=p,t.Viewer=class extends pt{constructor(t,e={}){var i;super(),this._visualizeJsUrl="",this.configure(e),this._options=new p(this),this.client=t,this.loaders=[],this._activeDragger=null,this._components=[],this._renderTime=0,this.canvasEvents=_.slice(),this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(i=e.enableAutoUpdate)||void 0===i||i,this._renderNeeded=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=ps.createMarkup(e.markupType)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}get markup(){return this._markup}configure(t){return this._visualizeJsUrl=t.visualizeJsUrl||"https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js",this._crossOrigin=t.crossOrigin,this}async initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data)));const i=t.parentElement.getBoundingClientRect(),s=i.width||1,r=i.height||1;t.width=Math.round(s*window.devicePixelRatio),t.height=Math.round(r*window.devicePixelRatio),t.style.width=s+"px",t.style.height=r+"px",t.parentElement.style.touchAction="none",t.style.touchAction="none",this._visualizeTimestamp=Date.now();const n=this._visualizeTimestamp,o=await(async(t,e,i={})=>{const s=await mt(t,i);return await new Promise(((i,r)=>{const n={urlMemFile:t+".wasm",TOTAL_MEMORY:134217728,onprogress:e},o=window.getVisualizeLibInst(n);o.loadWasmError=r,o.postRun.push((()=>{window.getVisualizeLibInst.script=s,i(o)}))}))})(this.visualizeJsUrl,(t=>{const{loaded:i,total:s}=t;e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:i,total:s})),this.emitEvent({type:"initializeprogress",data:i/s,loaded:i,total:s})}),{crossOrigin:this._crossOrigin});if(n!==this._visualizeTimestamp)throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");this._visualizeJs=o,this._visualizeJs.canvas=t,this._viewer=o.Viewer.create(),this._viewer.resize(0,t.width,t.height,0),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of rt.getComponents().keys())this._components.push(rt.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),this.render(this._renderTime),this.emitEvent({type:"initialize"}),this}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach((t=>t.dispose())),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this._viewer&&this._viewer.clear(),this._visualizeJs=void 0,this._visualizeTimestamp=void 0,this._viewer=void 0,this}isInitialized(){return!!this.visualizeJs}setSize(t,e,i=!0){this.visualizeJs&&(this.canvas.width=Math.round(t*window.devicePixelRatio),this.canvas.height=Math.round(e*window.devicePixelRatio),i&&(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px"),this._viewer.resize(0,this.canvas.width,this.canvas.height,0),this.update(!0),this.emitEvent({type:"resize",width:t,height:e}))}render(t){var e,i;if(!this.visualizeJs)return;if(this._isRunAsyncUpdate)return;if(!(this.visViewer().isRunningAnimation()||this._renderNeeded))return;t||(t=performance.now());const s=(t-this._renderTime)/1e3;this._renderTime=t,this._renderNeeded=!this.visViewer().getActiveDevice().isValid(),this.visViewer().update(),null===(i=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===i||i.call(e),this.emitEvent({type:"render",time:t,deltaTime:s})}resize(){if(console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead."),!this.visualizeJs)return this;if(!this.canvas.parentElement)return this;const{width:t,height:e}=this.canvas.parentElement.getBoundingClientRect();return t&&e?(this.setSize(t,e),this):this}update(t=!1){this._enableAutoUpdate&&(this._renderNeeded=!0,t&&this.render()),this.emitEvent({type:"update",data:t})}scheduleUpdateAsync(t=50){return new Promise(((e,i)=>{setTimeout((()=>{var s,r,n;try{this._enableAutoUpdate&&(null===(s=this.visViewer())||void 0===s||s.update(t),null===(n=null===(r=this._activeDragger)||void 0===r?void 0:r.updatePreview)||void 0===n||n.call(r)),this.emitEvent({type:"update",data:!1}),e()}catch(t){console.error(t),i()}}),0)}))}async updateAsync(t=50,e=50){if(this.visualizeJs){this._isRunAsyncUpdate=!0;try{const i=this.visViewer().getActiveDevice();for(let s=0;!i.isValid()&&s<e;s++)await this.scheduleUpdateAsync(t);await this.scheduleUpdateAsync(t)}catch(t){console.error(t)}finally{this._isRunAsyncUpdate=!1}}}get visualizeJs(){return this._visualizeJs}visLib(){return this._visualizeJs}visViewer(){return this._viewer}syncOpenCloudVisualStyle(){if(!this.visualizeJs)return this;const t=this.visLib(),e=this.visViewer(),i=e.getActiveDevice();if(i.isNull())return this;const s=i.getActiveView();let r;s.enableDefaultLighting(!0,t.DefaultLightingType.kTwoLights),s.setDefaultLightingIntensity(1.25);try{r=e.findVisualStyle("OpenCloud")}catch{r=void 0}if(!r||r.isNull()){r=e.createVisualStyle("OpenCloud");const i=new t.OdTvColorDef(66,66,66),s=e.findVisualStyle("Realistic"),n=r.openObject();n.copyFrom(s),n.setOptionInt32(t.VisualStyleOptions.kFaceModifiers,0,t.VisualStyleOperations.kSet),n.setOptionInt32(t.VisualStyleOptions.kEdgeModel,2,t.VisualStyleOperations.kSet),n.setOptionDouble(t.VisualStyleOptions.kEdgeCreaseAngle,60,t.VisualStyleOperations.kSet),n.setOptionInt32(t.VisualStyleOptions.kEdgeStyles,0,t.VisualStyleOperations.kSet),n.setOptionInt32(t.VisualStyleOptions.kEdgeModifiers,8,t.VisualStyleOperations.kSet),n.setOptionColor(t.VisualStyleOptions.kEdgeColorValue,i,t.VisualStyleOperations.kSet),n.delete()}return s.visualStyle=r,s.delete(),i.delete(),this}syncOptions(t=this.options){if(!this.visualizeJs)return this;this.syncOpenCloudVisualStyle();const e=this.visLib(),i=this.visViewer(),s=i.getActiveDevice();if(s.isNull())return this;t.showWCS!==i.getEnableWCS()&&i.setEnableWCS(t.showWCS),t.cameraAnimation!==i.getEnableAnimation()&&i.setEnableAnimation(t.cameraAnimation);const r=!0===t.antialiasing||"fxaa"===t.antialiasing;if(r!==i.fxaaAntiAliasing3d&&(i.fxaaAntiAliasing3d=r,i.fxaaQuality=5),t.shadows!==i.shadows){i.shadows=t.shadows;const r=e.canvas;s.invalidate([0,r.width,r.height,0])}if(t.groundShadow!==i.groundShadow&&(i.groundShadow=t.groundShadow),t.ambientOcclusion!==s.getOptionBool(e.DeviceOptions.kSSAOEnable)){s.setOptionBool(e.DeviceOptions.kSSAOEnable,t.ambientOcclusion),s.setOptionBool(e.DeviceOptions.kSSAODynamicRadius,!0),s.setOptionDouble(e.DeviceOptions.kSSAORadius,1),s.setOptionInt32(e.DeviceOptions.kSSAOLoops,32),s.setOptionDouble(e.DeviceOptions.kSSAOPower,2),s.setOptionInt32(e.DeviceOptions.kSSAOBlurRadius,2);const r=i.activeView;r.setSSAOEnabled(t.ambientOcclusion),r.delete()}if(_s(t.edgeModel)){const r=s.getActiveView(),n=i.findVisualStyle("OpenCloud"),o=n.openObject();o.setOptionInt32(e.VisualStyleOptions.kEdgeModel,t.edgeModel?2:0,e.VisualStyleOperations.kSet),r.visualStyle=n,o.delete(),n.delete(),r.delete()}return s.delete(),this.syncHighlightingOptions(t),this.update(),this}syncHighlightingOptions(t=this.options){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:p.defaults(),i=this.visLib(),s=this.visViewer(),{Entry:r,OdTvRGBColorDef:n}=i,o=s.findHighlightStyle("Web_Default").openObject();if(_s(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(r.k3D.value|r.k3DTop.value,t),t.delete()}if(_s(e.facesOverlap)&&o.setFacesVisibility(r.k3DTop.value,e.facesOverlap),_s(e.facesTransparancy)&&o.setFacesTransparency(r.k3D.value|r.k3DTop.value,e.facesTransparancy),_s(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(r.k3DTop.value|r.k3D.value|r.k2D.value|r.k2DTop.value,t),t.delete()}if(_s(e.edgesVisibility)&&o.setEdgesVisibility(r.k2D.value|r.k2DTop.value|r.k3DTop.value|r.k3D.value,e.edgesVisibility),_s(e.edgesOverlap)){const t=!_s(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(r.k2DTop.value|r.k3DTop.value,e.edgesOverlap&&t)}const a=s.getActiveDevice();if(!a.isNull()){const t=i.canvas;a.invalidate([0,t.width,t.height,0]),a.delete()}return this}get draggers(){return[...Y.getDraggers().keys()]}get components(){return[...rt.getComponents().keys()]}registerDragger(t,e){console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead."),Y.registerDragger(t,(t=>new e(t)))}activeDragger(){return this._activeDragger}setActiveDragger(t=""){var e,i;if(!this._activeDragger||this._activeDragger.name!==t){const s=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.visualizeJs&&(r=Y.createDragger(t,this),r&&(this._activeDragger=r,null===(i=(e=this._activeDragger).initialize)||void 0===i||i.call(e)));const n=this.canvas;n&&(s&&n.classList.remove(`oda-cursor-${s.name.toLowerCase()}`),r&&n.classList.add(`oda-cursor-${r.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find((e=>e.name===t))}clearSlices(){if(!this.visualizeJs)return;const t=this.visViewer().activeView;t.removeCuttingPlanes(),t.delete(),this.update()}clearOverlay(){this.visualizeJs&&(this._markup.clearOverlay(),this.update())}syncOverlay(){if(!this.visualizeJs)return;const t=this.visViewer(),e=t.activeView;let i=t.getViewByName(ms);if(!i){const s=t.getMarkupModel(),r=t.getActiveDevice();i=r.createView(ms,!1),i.addModel(s),e.addSibling(i),r.addView(i)}i.viewPosition=e.viewPosition,i.viewTarget=e.viewTarget,i.upVector=e.upVector,i.viewFieldWidth=e.viewFieldWidth,i.viewFieldHeight=e.viewFieldHeight;const s=i.getViewport();i.setViewport(s.lowerLeft,s.upperRight),i.vportRect=e.vportRect,this._markup.syncOverlay(),this.update()}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}screenToWorld(t){if(!this.visualizeJs)return{x:t.x,y:t.y,z:0};const e=this.visViewer().activeView,i=e.transformScreenToWorld(t.x*window.devicePixelRatio,t.y*window.devicePixelRatio),s={x:i[0],y:i[1],z:i[2]};return e.delete(),s}worldToScreen(t){if(!this.visualizeJs)return{x:t.x,y:t.y};const e=this.visViewer().activeView,i=e.transformWorldToScreen(t.x,t.y,t.z),s={x:i[0]/window.devicePixelRatio,y:i[1]/window.devicePixelRatio};return e.delete(),s}getScale(){const t={x:1,y:1,z:1},e=this.visViewer().activeView.projectionMatrix,i=1e-6,s=e.get(0,0);(s>i||s<-1e-6)&&(t.x=1/s);const r=e.get(1,1);(r>i||r<-1e-6)&&(t.y=1/r);const n=e.get(2,2);return(n>i||n<-1e-6)&&(t.z=1/n),t}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}async loadReferences(t){var e;if(!this.visualizeJs)return this;if(!this.client)return this;if(!t.getReferences)return this;const i=new AbortController;null===(e=this._abortControllerForReferences)||void 0===e||e.abort(),this._abortControllerForReferences=i;let s=[];await t.getReferences(i.signal).then((t=>s=t.references)).catch((t=>console.error("Cannot load model references.",t)));for(const t of s)await this.client.downloadFile(t.id,void 0,i.signal).then((e=>{var i;return null===(i=this.visualizeJs)||void 0===i?void 0:i.getViewer().addEmbeddedFile(t.name,new Uint8Array(e))})).catch((e=>console.error(`Cannot load reference file ${t.name}.`,e)));return this}applyModelTransformMatrix(t){this.executeCommand("applyModelTransform",t)}applySceneGraphSettings(t=this.options){if(!this.visualizeJs)return;const e=this.visLib(),i=this.visViewer().getActiveDevice();_s(t.sceneGraph)&&i.setOptionBool(e.DeviceOptions.kDelaySceneGraphProc,!t.sceneGraph),i.delete(),this.update()}async open(t,e={}){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});let i=t;if(i&&"function"==typeof i.getModels){const e=await i.getModels();i=e.find((t=>t.default))||e[0]||t}if(!i)throw new Error("Format not supported");let s=e.format;s||"string"!=typeof i.type||(s=i.type.split(".").pop()),s||"string"!=typeof t||(s=t.split(".").pop()),!s&&t instanceof globalThis.File&&(s=t.name.split(".").pop());const r=ft.createLoader(this,i,s);if(!r)throw new Error("Format not supported");this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:i});try{await this.loadReferences(i),await r.load(i,s,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:i}),e}return this.emitEvent({type:"geometryend",file:t,model:i}),this.visualizeJs&&(this.applyModelTransformMatrix(i),this.applySceneGraphSettings()),this}openVsfFile(t){if(console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});const e=this.visViewer();this.emitEvent({type:"geometrystart",file:t});try{const i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseFile(i),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"geometryprogress",data:1,file:t}),this.emitEvent({type:"databasechunk",data:i,file:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t}),e}return this.emitEvent({type:"geometryend",file:t}),this}openVsfxFile(t){if(console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."),!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",file:t});const e=this.visViewer();this.emitEvent({type:"geometrystart",file:t});try{const i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseVsfx(i),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"geometryprogress",data:1,file:t}),this.emitEvent({type:"databasechunk",data:i,file:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t}),e}return this.emitEvent({type:"geometryend",file:t}),this}cancel(){var t;return null===(t=this._abortControllerForReferences)||void 0===t||t.abort(),this._abortControllerForReferences=void 0,this.loaders.forEach((t=>t.cancel())),this.emitEvent({type:"cancel"}),this}clear(){if(!this.visualizeJs)return this;const t=this.visViewer();return this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach((t=>t.dispose())),this.loaders=[],t.clear(),t.createLocalDatabase(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this}getMarkupColor(){return console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead."),this._markup.getMarkupColor()}setMarkupColor(t=255,e=0,i=0){console.warn("Viewer.setMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.setMarkupColor() instead."),this._markup.setMarkupColor(t,e,i)}colorizeAllMarkup(t=255,e=0,i=0){console.warn("Viewer.colorizeAllMarkup() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.colorizeAllMarkup() instead."),this._markup.colorizeAllMarkup(t,e,i)}colorizeSelectedMarkups(t=255,e=0,i=0){this._markup.colorizeSelectedMarkups(t,e,i)}addMarkupEntity(t){if(!this.visualizeJs)return null;this.syncOverlay();const e=this.visViewer().getMarkupModel().appendEntity(t),i=e.openObject(),s=this.getMarkupColor();return i.setColor(s.r,s.g,s.b),i.setLineWeight(2),i.delete(),this.update(),e}drawViewpoint(t){var e;if(!this.visualizeJs)return;const i=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),this.setOrthogonalCameraSettings(t.orthogonal_camera),this.setClippingPlanes(t.clipping_planes),this.setSelection(t.selection),this._markup.setViewpoint(t),this.setActiveDragger(i),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.visualizeJs)return{};const t={};return t.orthogonal_camera=this.getOrthogonalCameraSettings(),t.clipping_planes=this.getClippingPlanes(),t.selection=this.getSelection(),t.description=(new Date).toDateString(),this._markup.getViewpoint(t),this.emitEvent({type:"createviewpoint",data:t}),t}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}getLogicalPoint3dAsArray(t){return[t.x,t.y,t.z]}getOrthogonalCameraSettings(){const t=this.visViewer().activeView;return{view_point:this.getPoint3dFromArray(t.viewPosition),direction:this.getPoint3dFromArray(t.viewTarget),up_vector:this.getPoint3dFromArray(t.upVector),field_width:t.viewFieldWidth,field_height:t.viewFieldHeight,view_to_world_scale:1}}setOrthogonalCameraSettings(t){const e=this.visViewer().activeView;t&&(e.setView(this.getLogicalPoint3dAsArray(t.view_point),this.getLogicalPoint3dAsArray(t.direction),this.getLogicalPoint3dAsArray(t.up_vector),t.field_width,t.field_height,!0),this.syncOverlay())}getClippingPlanes(){const t=this.visViewer().activeView,e=[];for(let i=0;i<t.numCuttingPlanes();i++){const s=t.getCuttingPlane(i),r={location:this.getPoint3dFromArray(s.getOrigin()),direction:this.getPoint3dFromArray(s.normal())};e.push(r)}return e}setClippingPlanes(t){if(t){const e=this.visViewer().activeView;for(const i of t){const t=new(this.visLib().OdTvPlane);t.set(this.getLogicalPoint3dAsArray(i.location),this.getLogicalPoint3dAsArray(i.direction)),e.addCuttingPlane(t),e.setEnableCuttingPlaneFill(!0,102,102,102)}}}getSelection(){return this.getSelected().map((t=>({handle:t})))}setSelection(t){this.setSelected(null==t?void 0:t.map((t=>t.handle)))}executeCommand(t,...e){return Z.executeCommand(t,this,...e)}deviceAutoRegeneration(){const t=this.visViewer();t.getActiveDevice().getOptionDouble(this.visLib().DeviceOptions.kRegenCoef)>1&&(t.regenAll(),this.update())}},t.commands=Z,t.commandsRegistry=s,t.components=rt,t.componentsRegistry=l,t.defaultOptions=f,t.draggers=Y,t.draggersRegistry=o,t.loaders=ft,t.loadersRegistry=g}));