UNPKG

@inweb/markup

Version:
1 lines 225 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.Markup=t.ODA.Markup||{}))}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n={exports:{}},s={},a={},o={};function h(){return r||(r=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const i=Math.PI/180;t.glob=void 0!==e?e:"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:e=>t.Konva.angleDeg?e*i:e,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)}(o)),o}var l,d={};function c(){return l||(l=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=h();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),r=this.m[0]*e+this.m[2]*i,n=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=n,this.m[2]=s,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,r=this.m[1]+this.m[3]*e,n=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=n,this.m[3]=s,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],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],n=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=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]=r,this.m[3]=n,this.m[4]=s,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,r=-this.m[2]*t,n=this.m[0]*t,s=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]=r,this.m[3]=n,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],s=e*n-i*r,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=s/t,a.skewX=(e*r+i*n)/s,a.skewY=0}else if(0!=r||0!=n){const t=Math.sqrt(r*r+n*n);a.rotation=Math.PI/2-(n>0?Math.acos(-r/t):-Math.acos(r/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*r+i*n)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=i;const r=Math.PI/180,n=180/Math.PI,s="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 l=[];const d="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){l.push(t),1===l.length&&d((function(){const t=l;l=[],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 r=t.Util.createImageElement();r.onload=function(){i(r)},r.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),r=Number(i[0])/360,n=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===n)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+n):s+n-s*n;const l=2*s-a,d=[0,0,0];for(let t=0;t<3;t++)o=r+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*r,radToDeg:t=>t*n,_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(s+t)},error(t){console.error(s+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,r,n,s){let a,o,h;const l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)a=t,o=e,h=(n-i)*(n-i)+(s-r)*(s-r);else{const d=((n-t)*(i-t)+(s-e)*(r-e))/l;d<0?(a=t,o=e,h=(t-n)*(t-n)+(e-s)*(e-s)):d>1?(a=i,o=r,h=(i-n)*(i-n)+(r-s)*(r-s)):(a=t+d*(i-t),o=e+d*(r-e),h=(a-n)*(a-n)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(e,i,r){const n=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return i.forEach((function(a,o){if(!r&&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<s&&(n.x=d,n.y=c,s=u)})),n},_prepareArrayForTween(e,i,r){const n=[],s=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)n.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)s.push({x:i[t],y:i[t+1]});const a=[];return s.forEach((function(e){const i=t.Util._getProjectionToLine(e,n,r);a.push(i.x),a.push(i.y)})),a},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const r in e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}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,r){let n=0,s=0,a=0,o=0;"number"==typeof r?n=s=a=o=Math.min(r,e/2,i/2):(n=Math.min(r[0]||0,e/2,i/2),s=Math.min(r[1]||0,e/2,i/2),o=Math.min(r[2]||0,e/2,i/2),a=Math.min(r[3]||0,e/2,i/2)),t.moveTo(n,0),t.lineTo(e-s,0),t.arc(e-s,s,s,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,n),t.arc(n,n,n,Math.PI,3*Math.PI/2,!1)}}}(d)),d}var u,g,f={},p={},_={};function m(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},_.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},_.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number.'),t}},_.getNumberOrArrayOfNumbersValidator=function(r){if(t.Konva.isUnminified)return function(t,n){let s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==r;return s||a||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+r+")"),t}},_.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or "auto".'),t}},_.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string.'),t}},_.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,r){const n=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return n||s||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string or a native gradient.'),t}},_.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a function.'),t}},_.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,r){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&t instanceof n||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+r+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a array of numbers.')),t}},_.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,r){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a boolean.'),t}},_.getComponentValidator=function(r){if(t.Konva.isUnminified)return function(t,n){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+r),t}};const t=h(),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 _}function y(){return g||(g=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=c(),i=m(),r="get",n="set";t.Factory={addGetterSetter(e,i,r,n,s){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,n,s),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,n){var s=r+e.Util._capitalize(i);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[i];return void 0===t?n:t}},addSetter(i,r,s,a){var o=n+e.Util._capitalize(r);i.prototype[o]||t.Factory.overWriteSetter(i,r,s,a)},overWriteSetter(t,i,r,s){var a=n+e.Util._capitalize(i);t.prototype[a]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,h,l){const d=o.length,c=e.Util._capitalize,u=r+c(a),g=n+c(a);s.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 f=(0,i.getComponentValidator)(o);s.prototype[g]=function(t){const e=this.attrs[a];h&&(t=h.call(this,t,a)),f&&f.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(s,a)},addOverloadedGetterSetter(t,i){var s=e.Util._capitalize(i),a=n+s,o=r+s;t.prototype[i]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,n,s,a){e.Util.error("Adding deprecated "+n);const o=r+e.Util._capitalize(n),h=n+" 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[n];return void 0===t?s:t},t.Factory.addSetter(i,n,a,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,n)},backCompat(t,i){e.Util.each(i,(function(i,s){const a=t.prototype[s],o=r+e.Util._capitalize(i),h=n+e.Util._capitalize(i);function l(){a.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(p)),p}var v,x,b={},S={};function w(){if(v)return S;v=1,Object.defineProperty(S,"__esModule",{value:!0}),S.HitContext=S.SceneContext=S.Context=void 0;const t=c(),e=h();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 r=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 r,n,s,a,o=this.traceArr,h=o.length,l="";for(r=0;r<h;r++)n=o[r],s=n.method,s?(a=n.args,l+=s,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+=n.property,e||(l+="="+n.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,r,n,s){this._context.arc(t,e,i,r,n,s)}arcTo(t,e,i,r,n){this._context.arcTo(t,e,i,r,n)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,n,s){this._context.bezierCurveTo(t,e,i,r,n,s)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}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,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,n,s){return this._context.createRadialGradient(t,e,i,r,n,s)}drawImage(t,e,i,r,n,s,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,r,n):9===l.length&&d.drawImage(t,e,i,r,n,s,a,o,h)}ellipse(t,e,i,r,n,s,a,o){this._context.ellipse(t,e,i,r,n,s,a,o)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,n){this._context.roundRect(t,e,i,r,n)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}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,r,n,s){this._context.setTransform(t,e,i,r,n,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,n,s){this._context.transform(t,e,i,r,n,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,r,n=this,s=i.length,a=this.setAttr;const o=function(e){let i,s=n[e];n[e]=function(){return r=function(e){const i=[],r=e.length,n=t.Util;for(let t=0;t<r;t++){let r=e[t];n._isNumber(r)?r=Math.round(1e3*r)/1e3:n._isString(r)||(r+=""),i.push(r)}return i}(Array.prototype.slice.call(arguments,0)),i=s.apply(n,arguments),n._trace({method:e,args:r}),i}};for(e=0;e<s;e++)o(i[e]);n.setAttr=function(){a.apply(n,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),n._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};S.Context=r,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(r.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));S.SceneContext=class extends r{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 r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const n=t.getFillLinearGradientColorStops();if(n&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):n?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(let t=0;t<r.length;t+=2)n.addColorStop(r[t],r[t+1]);this.setAttr("strokeStyle",n)}}_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,r;const n=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",n),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*d)}};return S.HitContext=class extends r{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(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},S}function C(){if(x)return b;x=1,Object.defineProperty(b,"__esModule",{value:!0}),b.HitCanvas=b.SceneCanvas=b.Canvas=void 0;const t=c(),e=w(),i=h(),r=y(),n=m();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const r=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),r=e.getContext("2d");return s=(i.Konva._global.devicePixelRatio||1)/(r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=r,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."),""}}}};b.Canvas=a,r.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,n.getNumberValidator)());b.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 b.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)}},b}var k,P,T={};function A(){return k||(k=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=h(),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 r=[];t.DD._dragElements.forEach(((t,n)=>{const{node:s}=t,a=s.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=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<i)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),r.push(s)}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const r=[];t.DD._dragElements.forEach((n=>{const{node:s}=n,a=s.getStage();i&&a.setPointersPositions(i);if(!a._changedPointerPositions.find((t=>t.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof e.Konva.Stage&&n.node;o&&-1===r.indexOf(o)&&r.push(o)})),r.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)}))}},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))}(T)),T}function M(){if(P)return f;P=1,Object.defineProperty(f,"__esModule",{value:!0}),f.Node=void 0;const t=c(),e=y(),i=C(),r=h(),n=A(),s=m(),a="absoluteOpacity",o="allEventListeners",l="absoluteTransform",d="absoluteScale",u="canvas",g="listening",p="mouseenter",_="mouseleave",v="Shape",x=" ",b="stage",S="transform",w="visible",k=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(x);let T=1,M=class e{constructor(t){this._id=T++,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!==S&&t!==l||!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===S||t===l)&&!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(x);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(u)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(u)){const{scene:e,filter:i,hit:r}=this._cache.get(u);t.Util.releaseCanvas(e,i,r),this._cache.delete(u)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const r=e||{};let n={};void 0!==r.x&&void 0!==r.y&&void 0!==r.width&&void 0!==r.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(r.width||n.width),o=Math.ceil(r.height||n.height),h=r.pixelRatio,l=void 0===r.x?Math.floor(n.x):r.x,c=void 0===r.y?Math.floor(n.y):r.y,g=r.offset||0,f=r.drawBorder||!1,p=r.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*g+(Math.abs(Math.round(n.x)-l)>.5?1:0),o+=2*g+(Math.abs(Math.round(n.y)-c)>.5?1:0),l-=g,c-=g;const _=new i.SceneCanvas({pixelRatio:h,width:s,height:o}),m=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),y=new i.HitCanvas({pixelRatio:p,width:s,height:o}),v=_.getContext(),x=y.getContext();return y.isCache=!0,_.isCache=!0,this._cache.delete(u),this._filterUpToDate=!1,!1===r.imageSmoothingEnabled&&(_.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),v.save(),x.save(),v.translate(-l,-c),x.translate(-l,-c),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(d),this.drawScene(_,this),this.drawHit(y,this),this._isUnderCache=!1,v.restore(),x.restore(),f&&(v.save(),v.beginPath(),v.rect(0,0,s,o),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.set(u,{scene:_,filter:m,hit:y,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(u)}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 r=1/0,n=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.point(t);void 0===r&&(r=s=e.x,n=a=e.y),r=Math.min(r,e.x),n=Math.min(n,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:r,y:n,width:s-r,height:a-n}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),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,r,n,s=this.filters(),a=this._getCanvasCache(),o=a.scene,h=a.filter,l=h.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;h.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,l.clear(),l.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),r=0;r<e;r++)n=s[r],"function"==typeof n?(n.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof n+" 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,r,n,s,a,h=t.split(x),l=h.length;for(i=0;i<l;i++)r=h[i],n=r.split("."),s=n[0],a=n[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let i,r,n,s,a,h,l=(t||"").split(x),d=l.length;if(this._cache&&this._cache.delete(o),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<d;i++)if(n=l[i],s=n.split("."),a=s[0],h=s[1],a)this.eventListeners[a]&&this._off(a,h,e);else for(r in this.eventListeners)this._off(r,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,r){const n=this;this.on(e,(function(e){const s=e.target.findAncestors(i,!0,n);for(let i=0;i<s.length;i++)(e=t.Util.cloneObject(e)).currentTarget=s[i],r.call(s[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),n.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(b),this._clearSelfAndDescendantCache(w),this._clearSelfAndDescendantCache(g)}_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,r;if(!e)return this;for(i in e)"children"!==i&&(r="set"+t.Util._capitalize(i),t.Util._isFunction(this[r])?this[r](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(g,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(w,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 s=!1;n.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(s=!0)}));const a=!e&&!r.Konva.hitOnDragEnabled&&(s||r.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,r,n=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],a++,r.nodeType!==v&&(t=t.concat(r.getChildren().slice())),r._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=n&&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(S),this._clearSelfAndDescendantCache(l)),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,r=this.parent;for(;r;){if(r.isCached()){i=!0;break}r=r.parent}i&&!e&&(e=!0);const n=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=n.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(S);const n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(t.x,t.y),t={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(S),this._clearSelfAndDescendantCache(l),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,r=this.x(),n=this.y();return void 0!==e&&(r+=e),void 0!==i&&(n+=i),this.setPosition({x:r,y:n}),this}_eachAncestorReverse(t,e){let i,r,n=[],s=this.getParent();if(!e||e._id!==this._id){for(n.unshift(this);s&&(!e||s._id!==e._id);)n.unshift(s),s=s.parent;for(i=n.length,r=0;r<i;r++)t(n[r])}}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(a,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,r,n,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)i=a[e],s=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),s||(r="function"==typeof this[e]&&this[e],delete a[e],n=r?r.call(this):null,a[e]=i,n!==i&&(o.attrs[e]=i));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const r=[];e&&this._isMatch(t)&&r.push(this);let n=this.parent;for(;n;){if(n===i)return r;n._isMatch(t)&&r.push(n),n=n.parent}return r}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,r,n=e.replace(/ /g,"").split(","),s=n.length;for(i=0;i<s;i++)if(r=n[i],t.Util.isValidSelector(r)||(t.Util.warn('Selector "'+r+'" 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?")),"#"===r.charAt(0)){if(this.id()===r.slice(1))return!0}else if("."===r.charAt(0)){if(this.hasName(r.slice(1)))return!0}else if(this.className===r||this.nodeType===r)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(b,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(l,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(l)||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,r=this.attrs.offsetX||0,n=this.attrs.offsetY||0;i.translate(t-r,e-n)}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(S,this._getTransform)}_getTransform(){var e,i;const n=this._cache.get(S)||new t.Transform;n.reset();const s=this.x(),a=this.y(),o=r.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===s&&0===a||n.translate(s,a),0!==o&&n.rotate(o),0===d&&0===c||n.skew(d,c),1===h&&1===l||n.scale(h,l),0===u&&0===g||n.translate(-1*u,-1*g),n.dirty=!1,n}clone(e){let i,r,n,s,a,o=t.Util.cloneObject(this.attrs);for(i in e)o[i]=e[i];const h=new this.constructor(o);for(i in this.eventListeners)for(r=this.eventListeners[i],n=r.length,s=0;s<n;s++)a=r[s],a.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(a));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),r=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(r?r.width():0),height:t.height||Math.ceil(e.height)||(r?r.height():0),pixelRatio:a}),h=o.getContext(),l=new i.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(n),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(n||s)&&h.translate(-1*n,-1*s),this.drawScene(o,void 0,l),h.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(e){return new Promise(((i,r)=>{try{const r=null==e?void 0:e.callback;r&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==r||r(t)}))}catch(t){r(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():r.Konva.dragDistance}_off(t,e,i){let r,n,s,a=this.eventListeners[t];for(r=0;r<a.length;r++)if(n=a[r].name,s=a[r].handler,!("konva"===n&&"konva"!==e||e&&n!==e||i&&i!==s)){if(a.splice(r,1),0===a.length){delete this.eventListeners[t];break}r--}}_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 r=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(r)?r.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(r.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const r=this.attrs[e];(r!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,i),this._requestDraw())}_setComponentAttr(t,e,i){let r;void 0!==i&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){e&&this.nodeType===v&&(e.target=this);if(!((t===p||t===_)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const r=(t===p||t===_)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const n=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==n?void 0:n[t];if(void 0===s){s=[];