UNPKG

@inweb/viewer-visualize

Version:

JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS

1 lines 312 kB
!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,a=r.apply(n,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),a}}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._draggers=new Map}registerDragger(t,e){this._draggers.set(t,e)}registerDraggerAlias(t,e){const i=this.getDragger(t);i&&this.registerDragger(e,(t=>i(t)))}getDragger(t){return this._draggers.get(t)}getDraggers(){const t=new Map;return this._draggers.forEach(((e,i)=>t.set(i,e))),t}createDragger(t,e){const i=this.getDragger(t);if(!i)return null;const s=i(e);return s.name=t,s}}const n=new Map;function a(t=""){let e=n.get(t);return e||(e=new r,n.set(t,e)),e}class o{constructor(){this._components=new Map}registerComponent(t,e){this._components.set(t,e)}registerComponentAlias(t,e){const i=this.getComponent(t);i&&this.registerComponent(e,(t=>i(t)))}getComponent(t){return this._components.get(t)}getComponents(){const t=new Map;return this._components.forEach(((e,i)=>t.set(i,e))),t}createComponent(t,e){const i=this.getComponent(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 o,h.set(t,e)),e}function d(){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 c{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=c.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...c.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...c.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 u=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],g=u;var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var f,v={exports:{}},_={},y={},w={};function b(){return f||(f=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!==p?p:"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)}(w)),w}var x,S={};function C(){return x||(x=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=b();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,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=s,this.m[1]=r,this.m[2]=n,this.m[3]=a,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],a=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]=a,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]),a=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]=a,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,a={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);a.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=n/t,a.skewX=(e*s+i*r)/n,a.skewY=0}else if(0!=s||0!=r){const t=Math.sqrt(s*s+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-s/t):-Math.acos(s/t)),a.scaleX=n/t,a.scaleY=t,a.skewX=0,a.skewY=(e*s+i*r)/n}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=i;const s=Math.PI/180,r=180/Math.PI,n="Konva error: ",a={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]},o=/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 a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.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=a[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 a,o,h;if(0===r)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=n<.5?n*(1+r):n+r-n*r;const l=2*n-a,d=[0,0,0];for(let t=0;t<3;t++)o=s+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*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 a,o,h;const l=(t-i)*(t-i)+(e-s)*(e-s);if(0==l)a=t,o=e,h=(r-i)*(r-i)+(n-s)*(n-s);else{const d=((r-t)*(i-t)+(n-e)*(s-e))/l;d<0?(a=t,o=e,h=(t-r)*(t-r)+(e-n)*(e-n)):d>1?(a=i,o=s,h=(i-r)*(i-r)+(s-n)*(s-n)):(a=t+d*(i-t),o=e+d*(s-e),h=(a-r)*(a-r)+(o-n)*(o-n))}return[a,o,h]},_getProjectionToLine(e,i,s){const r=t.Util.cloneObject(e);let n=Number.MAX_VALUE;return i.forEach((function(a,o){if(!s&&o===i.length-1)return;const h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(a.x,a.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 a=[];return n.forEach((function(e){const i=t.Util._getProjectionToLine(e,r,s);a.push(i.x),a.push(i.y)})),a},_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,a=0,o=0;"number"==typeof s?r=n=a=o=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),o=Math.min(s[2]||0,e/2,i/2),a=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-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(S)),S}var P,k,A={},E={},M={};function T(){if(P)return M;P=1,Object.defineProperty(M,"__esModule",{value:!0}),M.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},M.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},M.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}},M.getNumberOrArrayOfNumbersValidator=function(s){if(t.Konva.isUnminified)return function(t,r){let n=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==s;return n||a||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+s+")"),t}},M.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}},M.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}},M.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}},M.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}},M.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}},M.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}},M.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=b(),e=C();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 M}function I(){return k||(k=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=C(),i=T(),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,a){var o=r+e.Util._capitalize(s);i.prototype[o]||t.Factory.overWriteSetter(i,s,n,a)},overWriteSetter(t,i,s,n){var a=r+e.Util._capitalize(i);t.prototype[a]=function(t){return s&&null!=t&&(t=s.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,a,o,h,l){const d=o.length,c=e.Util._capitalize,u=s+c(a),g=r+c(a);n.prototype[u]=function(){const t={};for(let e=0;e<d;e++){const i=o[e];t[i]=this.getAttr(a+c(i))}return t};const p=(0,i.getComponentValidator)(o);n.prototype[g]=function(t){const e=this.attrs[a];h&&(t=h.call(this,t,a)),p&&p.call(this,t,a);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(a+c(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+c(t),void 0)})),this._fireChangeEvent(a,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,a)},addOverloadedGetterSetter(t,i){var n=e.Util._capitalize(i),a=r+n,o=s+n;t.prototype[i]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,r,n,a){e.Util.error("Adding deprecated "+r);const o=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[o]=function(){e.Util.error(h);const t=this.attrs[r];return void 0===t?n:t},t.Factory.addSetter(i,r,a,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat(t,i){e.Util.each(i,(function(i,n){const a=t.prototype[n],o=s+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){a.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(E)),E}var F,D,O={},R={};function L(){if(F)return R;F=1,Object.defineProperty(R,"__esModule",{value:!0}),R.HitContext=R.SceneContext=R.Context=void 0;const t=C(),e=b();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,a,o=this.traceArr,h=o.length,l="";for(s=0;s<h;s++)r=o[s],n=r.method,n?(a=r.args,l+=n,e?l+="()":t.Util._isArray(a[0])?l+="(["+a.join(",")+"])":(i&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+a.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,a,o,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,a,o,h)}ellipse(t,e,i,s,r,n,a,o){this._context.ellipse(t,e,i,s,r,n,a,o)}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,a=this.setAttr;const o=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++)o(i[e]);r.setAttr=function(){a.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)}};R.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}})}));R.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,a=null!==(s=t.getShadowOffset())&&void 0!==s?s:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*d)}};return R.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()}}},R}function V(){if(D)return O;D=1,Object.defineProperty(O,"__esModule",{value:!0}),O.HitCanvas=O.SceneCanvas=O.Canvas=void 0;const t=C(),e=L(),i=b(),s=I(),r=T();let n;let a=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."),""}}}};O.Canvas=a,s.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,r.getNumberValidator)());O.SceneCanvas=class extends a{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 O.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},O}var z,G,N={};function U(){return z||(z=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=b(),i=C();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,a=n.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const i=n.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.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,a=n.getStage();i&&a.setPointersPositions(i);if(!a._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 o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===s.indexOf(o)&&s.push(o)})),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))}(N)),N}function W(){if(G)return A;G=1,Object.defineProperty(A,"__esModule",{value:!0}),A.Node=void 0;const t=C(),e=I(),i=V(),s=b(),r=U(),n=T(),a="absoluteOpacity",o="allEventListeners",h="absoluteTransform",l="absoluteScale",d="canvas",c="listening",u="mouseenter",g="mouseleave",p="Shape",m=" ",f="stage",v="transform",_="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);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!==v&&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===v||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(m);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),o=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,p=s.drawBorder||!1,m=s.hitCanvasPixelRatio||1;if(!n||!o)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),o+=2*g+(Math.abs(Math.round(r.y)-u)>.5?1:0),c-=g,u-=g;const f=new i.SceneCanvas({pixelRatio:h,width:n,height:o}),v=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),_=new i.HitCanvas({pixelRatio:m,width:n,height:o}),y=f.getContext(),w=_.getContext();return _.isCache=!0,f.isCache=!0,this._cache.delete(d),this._filterUpToDate=!1,!1===s.imageSmoothingEnabled&&(f.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),y.save(),w.save(),y.translate(-c,-u),w.translate(-c,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(l),this.drawScene(f,this),this.drawHit(_,this),this._isUnderCache=!1,y.restore(),w.restore(),p&&(y.save(),y.beginPath(),y.rect(0,0,n,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(d,{scene:f,filter:v,hit:_,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,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.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)})),{x:s,y:r,width:n-s,height:a-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(),a=this._getCanvasCache(),o=a.scene,h=a.filter,l=h.getContext();if(n){if(!this._filterUpToDate){const a=o.pixelRatio;h.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=n.length,l.clear(),l.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),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 o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let i,s,r,n,a,h=t.split(m),l=h.length;for(i=0;i<l;i++)s=h[i],r=s.split("."),n=r[0],a=r[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:a,handler:e});return this}off(t,e){let i,s,r,n,a,h,l=(t||"").split(m),d=l.length;if(this._cache&&this._cache.delete(o),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<d;i++)if(r=l[i],n=r.split("."),a=n[0],h=n[1],a)this.eventListeners[a]&&this._off(a,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(a),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(f),this._clearSelfAndDescendantCache(_),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(_,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 a=!e&&!s.Konva.hitOnDragEnabled&&(n||s.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}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,a=0;const o=this.getStage();return"Stage"!==n.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)s=h[i],a++,s.nodeType!==p&&(t=t.concat(s.getChildren().slice())),s._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&o(t)}(o.getChildren()),a}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(v),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,a=this.offset();return n.m=r.slice(),n.translate(a.x,a.y),n.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...s}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(v);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(v),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._s