pikaso-react-hook
Version:
Pikaso React Hook
7 lines (4 loc) • 254 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var react = require('react');
var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){var e=t.default;if("function"==typeof e){var i=function(){return e.apply(this,arguments)};i.prototype=e.prototype;}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:function(){return t[e]}});})),i}var i={},r={},n={},a={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._registerNode=e.Konva=e.glob=void 0;var i=Math.PI/180;e.glob=void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},e.Konva={_global:e.glob,version:"8.3.9",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>e.Konva.angleDeg?t*i:t,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,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>e.Konva.DD.isDragging,isDragReady:()=>!!e.Konva.DD.node,document:e.glob.document,_injectGlobal(t){e.glob.Konva=t;}};e._registerNode=t=>{e.Konva[t.prototype.getClassName()]=t;},e.Konva._injectGlobal(e.Konva);}(a);var o={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=a;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){var 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){var 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,a=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=n,this.m[2]=a,this.m[3]=o,this}getTranslation(){return {x:this.m[4],y:this.m[5]}}skew(t,e){var i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,n=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=n,this.m[3]=a,this}multiply(t){var 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],a=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}invert(){var 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,a=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){var e=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],a=e*n-i*r;let o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var s=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/s):-Math.acos(e/s),o.scaleX=s,o.scaleY=a/s,o.skewX=(e*r+i*n)/a,o.skewY=0;}else if(0!=r||0!=n){var h=Math.sqrt(r*r+n*n);o.rotation=Math.PI/2-(n>0?Math.acos(-r/h):-Math.acos(r/h)),o.scaleX=a/h,o.scaleY=h,o.skewX=0,o.skewY=(e*r+i*n)/a;}return o.rotation=t.Util._getRotation(o.rotation),o}}t.Transform=i;var r=Math.PI/180,n=180/Math.PI,o="Konva error: ",s={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]},h=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,d=[];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;var e=t[0];return "#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){d.push(t),1===d.length&&l((function(){const t=d;d=[],t.forEach((function(t){t();}));}));},createCanvasElement(){var 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){var 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("#","");var e=parseInt(t,16);return {r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){for(var t=(16777215*Math.random()<<0).toString(16);t.length<6;)t="0"+t;return "#"+t},getRGB(t){var e;return t in s?{r:(e=s[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=h.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._hex6ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){var e=s[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){var 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(")){var 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]}}},_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}},_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,a=Number(i[2])/100;let o,s,h;if(0===n)return h=255*a,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=a<.5?a*(1+n):a+n-a*n;const d=2*a-o,l=[0,0,0];for(let t=0;t<3;t++)s=r+1/3*-(t-1),s<0&&s++,s>1&&s--,h=6*s<1?d+6*(o-d)*s:2*s<1?o:3*s<2?d+(o-d)*(2/3-s)*6:d,l[t]=255*h;return {r:Math.round(l[0]),g:Math.round(l[1]),b:Math.round(l[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){var e={};for(var 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(o+t)},error(t){console.error(o+t);},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t);},each(t,e){for(var i in t)e(i,t[i]);},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,r,n,a){var o,s,h,d=(t-i)*(t-i)+(e-r)*(e-r);if(0==d)o=t,s=e,h=(n-i)*(n-i)+(a-r)*(a-r);else {var l=((n-t)*(i-t)+(a-e)*(r-e))/d;l<0?(o=t,s=e,h=(t-n)*(t-n)+(e-a)*(e-a)):l>1?(o=i,s=r,h=(i-n)*(i-n)+(r-a)*(r-a)):h=((o=t+l*(i-t))-n)*(o-n)+((s=e+l*(r-e))-a)*(s-a);}return [o,s,h]},_getProjectionToLine(e,i,r){var n=t.Util.cloneObject(e),a=Number.MAX_VALUE;return i.forEach((function(o,s){if(r||s!==i.length-1){var h=i[(s+1)%i.length],d=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),l=d[0],c=d[1],u=d[2];u<a&&(n.x=l,n.y=c,a=u);}})),n},_prepareArrayForTween(e,i,r){var n,a=[],o=[];if(e.length>i.length){var s=i;i=e,e=s;}for(n=0;n<e.length;n+=2)a.push({x:e[n],y:e[n+1]});for(n=0;n<i.length;n+=2)o.push({x:i[n],y:i[n+1]});var h=[];return o.forEach((function(e){var i=t.Util._getProjectionToLine(e,a,r);h.push(i.x),h.push(i.y);})),h},_prepareToStringify(e){var i;for(var r in e.visitedByCircularReferenceRemoval=!0,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(var i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999};}(o);var s={},h={},d={};Object.defineProperty(d,"__esModule",{value:!0}),d.getComponentValidator=d.getBooleanValidator=d.getNumberArrayValidator=d.getFunctionValidator=d.getStringOrGradientValidator=d.getStringValidator=d.getNumberOrAutoValidator=d.getNumberOrArrayOfNumbersValidator=d.getNumberValidator=d.alphaComponent=d.RGBComponent=void 0;const l=a,c=o;function u(t){return c.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||c.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}d.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},d.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},d.getNumberValidator=function(){if(l.Konva.isUnminified)return function(t,e){return c.Util._isNumber(t)||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},d.getNumberOrArrayOfNumbersValidator=function(t){if(l.Konva.isUnminified)return function(e,i){let r=c.Util._isNumber(e),n=c.Util._isArray(e)&&e.length==t;return r||n||c.Util.warn(u(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},d.getNumberOrAutoValidator=function(){if(l.Konva.isUnminified)return function(t,e){return c.Util._isNumber(t)||"auto"===t||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},d.getStringValidator=function(){if(l.Konva.isUnminified)return function(t,e){return c.Util._isString(t)||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},d.getStringOrGradientValidator=function(){if(l.Konva.isUnminified)return function(t,e){const i=c.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},d.getFunctionValidator=function(){if(l.Konva.isUnminified)return function(t,e){return c.Util._isFunction(t)||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},d.getNumberArrayValidator=function(){if(l.Konva.isUnminified)return function(t,e){return c.Util._isArray(t)?t.forEach((function(t){c.Util._isNumber(t)||c.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.");})):c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.'),t}},d.getBooleanValidator=function(){if(l.Konva.isUnminified)return function(t,e){return !0===t||!1===t||c.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},d.getComponentValidator=function(t){if(l.Konva.isUnminified)return function(e,i){return c.Util.isObject(e)||c.Util.warn(u(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=o,i=d;var r="get",n="set";t.Factory={addGetterSetter(e,i,r,n,a){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,n,a),t.Factory.addOverloadedGetterSetter(e,i);},addGetter(t,i,n){var a=r+e.Util._capitalize(i);t.prototype[a]=t.prototype[a]||function(){var t=this.attrs[i];return void 0===t?n:t};},addSetter(i,r,a,o){var s=n+e.Util._capitalize(r);i.prototype[s]||t.Factory.overWriteSetter(i,r,a,o);},overWriteSetter(t,i,r,a){var o=n+e.Util._capitalize(i);t.prototype[o]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),a&&a.call(this),this};},addComponentsGetterSetter(a,o,s,h,d){var l,c,u=s.length,g=e.Util._capitalize,p=r+g(o),f=n+g(o);a.prototype[p]=function(){var t={};for(l=0;l<u;l++)t[c=s[l]]=this.getAttr(o+g(c));return t};var v=(0, i.getComponentValidator)(s);a.prototype[f]=function(t){var e,i=this.attrs[o];for(e in h&&(t=h.call(this,t)),v&&v.call(this,t,o),t)t.hasOwnProperty(e)&&this._setAttr(o+g(e),t[e]);return this._fireChangeEvent(o,i,t),d&&d.call(this),this},t.Factory.addOverloadedGetterSetter(a,o);},addOverloadedGetterSetter(t,i){var a=e.Util._capitalize(i),o=n+a,s=r+a;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[s]()};},addDeprecatedGetterSetter(i,n,a,o){e.Util.error("Adding deprecated "+n);var s=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[s]=function(){e.Util.error(h);var t=this.attrs[n];return void 0===t?a:t},t.Factory.addSetter(i,n,o,(function(){e.Util.error(h);})),t.Factory.addOverloadedGetterSetter(i,n);},backCompat(t,i){e.Util.each(i,(function(i,a){var o=t.prototype[a],s=r+e.Util._capitalize(i),h=n+e.Util._capitalize(i);function d(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+a+'" instead.');}t.prototype[i]=d,t.prototype[s]=d,t.prototype[h]=d;}));},afterSetFilter(){this._filterUpToDate=!1;}};}(h);var g={},p={};Object.defineProperty(p,"__esModule",{value:!0}),p.HitContext=p.SceneContext=p.Context=void 0;const f=o,v=a;function y(t){var e,i,r=[],n=t.length,a=f.Util;for(e=0;e<n;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),r.push(i);return r}var m=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class b{constructor(t){this.canvas=t,this._context=t._canvas.getContext("2d"),v.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(t,e){var i,r,n,a,o=this.traceArr,s=o.length,h="";for(i=0;i<s;i++)(n=(r=o[i]).method)?(a=r.args,h+=n,t?h+="()":f.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=r.property,t||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[];}_trace(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift();}reset(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0);}getCanvas(){return this.canvas}clear(t){var 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){var e=t.getLineCap();e&&this.setAttr("lineCap",e);}_applyOpacity(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e);}_applyLineJoin(t){var e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e);}setAttr(t,e){this._context[t]=e;}arc(t,e,i,r,n,a){this._context.arc(t,e,i,r,n,a);}arcTo(t,e,i,r,n){this._context.arcTo(t,e,i,r,n);}beginPath(){this._context.beginPath();}bezierCurveTo(t,e,i,r,n,a){this._context.bezierCurveTo(t,e,i,r,n,a);}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r);}clip(){this._context.clip();}closePath(){this._context.closePath();}createImageData(t,e){var 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,a){return this._context.createRadialGradient(t,e,i,r,n,a)}drawImage(t,e,i,r,n,a,o,s,h){var d=arguments,l=this._context;3===d.length?l.drawImage(t,e,i):5===d.length?l.drawImage(t,e,i,r,n):9===d.length&&l.drawImage(t,e,i,r,n,a,o,s,h);}ellipse(t,e,i,r,n,a,o,s){this._context.ellipse(t,e,i,r,n,a,o,s);}isPointInPath(t,e){return this._context.isPointInPath(t,e)}fill(t){t?this._context.fill(t):this._context.fill();}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);}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,a){this._context.setTransform(t,e,i,r,n,a);}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,a){this._context.transform(t,e,i,r,n,a);}translate(t,e){this._context.translate(t,e);}_enableTrace(){var t,e,i=this,r=m.length,n=this.setAttr,a=function(t){var r,n=i[t];i[t]=function(){return e=y(Array.prototype.slice.call(arguments,0)),r=n.apply(i,arguments),i._trace({method:t,args:e}),r};};for(t=0;t<r;t++)a(m[t]);i.setAttr=function(){n.apply(i,arguments);var t=arguments[0],e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e});};}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e);}}p.Context=b,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(b.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e;}});}));p.SceneContext=class extends b{_fillColor(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this);}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this);}_fillLinearGradient(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this));}_fillRadialGradient(t){var e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this));}_fill(t){var e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)this._fillColor(t);else {var r=t.getFillPatternImage();if(r&&"pattern"===i)this._fillPattern(t);else {var n=t.getFillLinearGradientColorStops();if(n&&"linear-gradient"===i)this._fillLinearGradient(t);else {var a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):n?this._fillLinearGradient(t):a&&this._fillRadialGradient(t);}}}}_strokeLinearGradient(t){var e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(var a=0;a<r.length;a+=2)n.addColorStop(r[a],r[a+1]);this.setAttr("strokeStyle",n);}}_stroke(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,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,n=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},s=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),d=s.x*h,l=s.y*h;this.setAttr("shadowColor",n),this.setAttr("shadowBlur",a*Math.min(Math.abs(d),Math.abs(l))),this.setAttr("shadowOffsetX",o.x*d),this.setAttr("shadowOffsetY",o.y*l);}};p.HitContext=class extends b{_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()){var e=t.getStrokeScaleEnabled();if(!e){this.save();var i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,0,0);}this._applyLineCap(t);var r=t.hitStrokeWidth(),n="auto"===r?t.strokeWidth():r;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore();}}},Object.defineProperty(g,"__esModule",{value:!0}),g.HitCanvas=g.SceneCanvas=g.Canvas=void 0;const _=o,x=p,w=a,S=h,C=d;var P;class k{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||w.Konva.pixelRatio||function(){if(P)return P;var t=_.Util.createCanvasElement().getContext("2d");return P=(w.Konva._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}();this.pixelRatio=e,this._canvas=_.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){var 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";var 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";var 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(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return _.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}g.Canvas=k,S.Factory.addGetterSetter(k,"pixelRatio",void 0,(0, C.getNumberValidator)());g.SceneCanvas=class extends k{constructor(t={width:0,height:0}){super(t),this.context=new x.SceneContext(this),this.setSize(t.width,t.height);}};g.HitCanvas=class extends k{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new x.HitContext(this),this.setSize(t.width,t.height);}};var A={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=a,i=o;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0);})),e},justDragged:!1,get node(){var 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:a}=t,o=a.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const s=o._changedPointerPositions.find((e=>e.id===t.pointerId));if(s){if("dragging"!==t.dragStatus){var h=a.dragDistance();if(Math.max(Math.abs(s.x-t.startPointerPos.x),Math.abs(s.y-t.startPointerPos.y))<h)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,t),r.push(a);}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0);}));},_endDragBefore(i){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&&o.batchDraw();}));},_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("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1));}(A),Object.defineProperty(s,"__esModule",{value:!0}),s.Node=void 0;const T=o,D=h,F=g,M=a,O=A,E=d;var G=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(" ");let N=1;class R{constructor(t){this._id=N++,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){"transform"!==t&&"absoluteTransform"!==t||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0;}_getCache(t,e){var i=this._cache.get(t);return (void 0===i||("transform"===t||"absoluteTransform"===t)&&!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(" ");this.on(i,(()=>{this._clearCache(t);})),this._attachedDepsListeners.set(t,!0);}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get("canvas")}_clearSelfAndDescendantCache(t){this._clearCache(t),"absoluteTransform"===t&&this.fire("absoluteTransformChange");}clearCache(){return this._cache.delete("canvas"),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var r=Math.ceil(e.width||i.width),n=Math.ceil(e.height||i.height),a=e.pixelRatio,o=void 0===e.x?Math.floor(i.x):e.x,s=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,d=e.drawBorder||!1,l=e.hitCanvasPixelRatio||1;if(r&&n){r+=2*h+1,n+=2*h+1,o-=h,s-=h;var c=new F.SceneCanvas({pixelRatio:a,width:r,height:n}),u=new F.SceneCanvas({pixelRatio:a,width:0,height:0}),g=new F.HitCanvas({pixelRatio:l,width:r,height:n}),p=c.getContext(),f=g.getContext();return g.isCache=!0,c.isCache=!0,this._cache.delete("canvas"),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),f.save(),p.translate(-o,-s),f.translate(-o,-s),this._isUnderCache=!0,this._clearSelfAndDescendantCache("absoluteOpacity"),this._clearSelfAndDescendantCache("absoluteScale"),this.drawScene(c,this),this.drawHit(g,this),this._isUnderCache=!1,p.restore(),f.restore(),d&&(p.save(),p.beginPath(),p.rect(0,0,r,n),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set("canvas",{scene:c,filter:u,hit:g,x:o,y:s}),this._requestDraw(),this}T.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");}isCached(){return this._cache.has("canvas")}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){var i,r,n,a,o=[{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}],s=this.getAbsoluteTransform(e);return o.forEach((function(t){var e=s.point(t);void 0===i&&(i=n=e.x,r=a=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y);})),{x:i,y:r,width:n-i,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore();}_drawCachedHitCanvas(t){var 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(){var t,e,i,r,n=this.filters(),a=this._getCanvasCache(),o=a.scene,s=a.filter,h=s.getContext();if(n){if(!this._filterUpToDate){var d=o.pixelRatio;s.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(t=n.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/d,o.getHeight()/d),e=h.getImageData(0,0,s.getWidth(),s.getHeight()),i=0;i<t;i++)"function"==typeof(r=n[i])?(r.call(this,e),h.putImageData(e,0,0)):T.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters");}catch(t){T.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");}this._filterUpToDate=!0;}return s}return o}on(t,e){if(this._cache&&this._cache.delete("allEventListeners"),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,n,a,o=t.split(" "),s=o.length;for(i=0;i<s;i++)n=(r=o[i].split("."))[0],a=r[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:a,handler:e});return this}off(t,e){var i,r,n,a,o,s=(t||"").split(" "),h=s.length;if(this._cache&&this._cache.delete("allEventListeners"),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<h;i++)if(a=(n=s[i].split("."))[0],o=n[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(r in this.eventListeners)this._off(r,o,e);return this}dispatchEvent(t){var 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(t,e,i){var r=this;this.on(t,(function(t){for(var n=t.target.findAncestors(e,!0,r),a=0;a<n.length;a++)(t=T.Util.cloneObject(t)).currentTarget=n[a],i.call(n[a],t);}));}remove(){return this.isDragging()&&this.stopDrag(),O.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache("absoluteTransform"),this._clearSelfAndDescendantCache("absoluteOpacity"),this._clearSelfAndDescendantCache("absoluteScale"),this._clearSelfAndDescendantCache("stage"),this._clearSelfAndDescendantCache("visible"),this._clearSelfAndDescendantCache("listening");}_remove(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null);}destroy(){return this.remove(),this}getAttr(t){var e="get"+T.Util._capitalize(t);return T.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges((()=>{var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+T.Util._capitalize(e),T.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]));})),this}isListening(){return this._getCache("listening",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("visible",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);var i=this.getLayer(),r=!1;O.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0);}));var n=!e&&!M.Konva.hitOnDragEnabled&&r;return this.isListening()&&this.isVisible()&&!n}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var t,e,i,r,n=this.getDepth(),a=this,o=0;return "Stage"!==a.nodeType&&function s(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],o++,"Shape"!==r.nodeType&&(t=t.concat(r.getChildren().slice())),r._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=n&&s(t);}(a.getStage().getChildren()),o}getDepth(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")),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(){if(!this.getStage())return null;var t=this.getStage().getPointerPosition();if(!t)return null;var e=this.getAbsoluteTransform().copy();return e.invert(),e.point(t)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent;}e&&!t&&(t=!0);var r=this.getAbsoluteTransform(t).getMatrix(),n=new T.Transform,a=this.offset();return n.m=r.slice(),n.translate(a.x,a.y),n.getTranslation()}setAbsolutePosition(t){var e=this._clearTransform();this.attrs.x=e.x,this.attrs.y=e.y,delete e.x,delete e.y,this._clearCache("transform");var i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(e),this.setPosition({x:t.x,y:t.y}),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform"),this}_setTransform(t){var e;for(e in t)this.attrs[e]=t[e];}_clearTransform(){var 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){var 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){var i,r,n=[],a=this.getParent();if(!e||e._id!==this._id){for(n.unshift(this);a&&(!e||a._id!==e._id);)n.unshift(a),a=a.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;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,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;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return T.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return T.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return T.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&T.Util.warn("Unexpected value "+t+" 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)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache("absoluteOpacity",this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t,e,i,r,n={},a=this.getAttrs();for(t in n.attrs={},a)e=a[t],T.Util.isObject(e)&&!T.Util._isPlainObject(e)&&!T.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete a[t],r=i?i.call(this):null,a[t]=e,r!==e&&(n.attrs[t]=e));return n.className=this.getClassName(),T.Util._prepareToStringify(n)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){var r=[];e&&this._isMatch(t)&&r.push(this);for(var n=this.parent;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(t){if(!t)return !1;if("function"==typeof t)return t(this);var e,i,r=t.replace(/ /g,"").split(","),n=r.length;for(e=0;e<n;e++)if(i=r[e],T.Util.isValidSelector(i)||(T.Util.warn('Selector "'+i+'" 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?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return !0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return !0}else if(this.className===i||this.nodeType===i)return !0;return !1}getLayer(){var t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache("stage",this._getStage)}_getStage(){var t=this.getParent();return t?t.getStage():void 0}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("absoluteTransform",this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new T.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY());}),t),e;e=this._cache.get("absoluteTransform")||new T.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){const t=this.attrs.x||0,i=this.attrs.y||0,r=this.attrs.offsetX||0,n=this.attrs.offsetY||0;e.translate(t-r,i-n);}return e.dirty=!1,e}getAbsoluteScale(t){for(var e=this;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("transform",this._getTransform)}_getTransform(){var t,e,i=this._cache.get("transform")||new T.Transform;i.reset();var r=this.x(),n=this.y(),a=M.Konva.getAngle(this.rotation()),o=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,s=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,d=this.attrs.skewY||0,l=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return 0===r&&0===n||i.translate(r,n),0!==a&&i.rotate(a),0===h&&0===d||i.skew(h,d),1===o&&1===s||i.scale(o,s),0===l&&0===c||i.translate(-1*l,-1*c),i.dirty=!1,i}clone(t){var e,i,r,n,a,o=T.Util.cloneObject(this.attrs);for(e in t)o[e]=t[e];var s=new this.constructor(o);for(e in this.eventListeners)for(r=(i=this.eventListeners[e]).length,n=0;n<r;n++)(a=i[n]).name.indexOf("konva")<0&&(s.eventListeners[e]||(s.eventListeners[e]=[]),s.eventListeners[e].push(a));return s}_toKonvaCanvas(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),n=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new F.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),s=o.getContext();return !1===t.imageSmoothingEnabled&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||n)&&s.translate(-1*r,-1*n),this.drawScene(o),s.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){if(!t||!t.callback)throw "callback required for toImage method config argument";var e=t.callback;delete t.callback,T.Util._urlToImage(this.toDataURL(t),(function(t){e(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():M.Konva.dragDistance}_off(t,e,i){var r,n,a,o=this.eventListeners[t];for(r=0;r<o.length;r++)if(n=o[r].name,a=o[r].handler,!("konva"===n&&"konva"!==e||e&&n!==e||i&&i!==a)){if(o.splice(r,1),0===o.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)){var e=this.name(),i=e?e+" "+t:t;this.name(i);}return this}hasName(t){if(!t)return !1;const e=this.name();return !!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return -1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){var i=this["set"+T.Util._capitalize(t)];return T.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(M.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw();}}_setAttr(t,e){var i=this.attrs[t];(i!==e||T.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw());}_setComponentAttr(t,e,i){var r;void 0!==i&&((r=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i));}_fireAndBubble(t,e,i){if(e&&"Shape"===this.nodeType&&(e.target=this),!(("mouseenter"===t||"mouseleave"===t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=("mouseenter"===t||"mouseleave"===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){let e=this._cache.get("allEventListeners");if(!e){e={};let t=Object.getPrototypeOf(this);for(;t;)if(t.eventListeners){for(var i in t.eventListeners){const r=t.eventListeners[i],n=e[i]||[];e[i]=r.concat(n);}t=Object.getPrototypeOf(t);}else t=Object.getPrototypeOf(t);this._cache.set("allEventListeners",e);}return e[t]}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var r=0;r<i.length;r++)i[r].handler.call(this,e);const n=this.eventListeners[t];if(n)for(r=0;r<n.length;r++)n[r].handler.call(this,e);}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){var e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition(),n=i._getPointerById(e)||i._changedPointerPositions[0]||r;O.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-r.x,y:n.y-r.y},dragStatus:"ready",pointerId:e});}startDrag(t,e=!0){O.DD._dragElements.has(this._id)||this._createDragElement(t);O.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e);}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(i){var r={x:i.x-e.offset.x,y:i.y-e.offset.y},n=this.dragBoundFunc();if(void 0!==n){const e=n.call(this,r,t);e?r=e:T.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r;}}stopDrag(t){const e=O.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),O.DD._endDragBefore(t),O.DD._endDragAfter(t);}setDraggable(t){this._setAttr("draggable",t),this._dragChange();}isDragging(){const t=O.DD._dragElements.get(this._id);return !!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if((!(void 0!==t.evt.button)||M.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;O.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0);})),e||this._createDragElement(t);}}));}_dragChange(){if(this.attrs.draggable)this._listenDrag();else {if(this._dragCleanup(),!this.getStage())return;const t=O.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&O.DD._dragElements.delete(this._id);}}_dragCleanup(){this.off("mousedown.