-
Notifications
You must be signed in to change notification settings - Fork 1
/
konva.js
2 lines (2 loc) · 187 KB
/
konva.js
1
2
/*! For license information please see konva.js.LICENSE.txt */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(self,(()=>(()=>{var t={215:function(t,e,i){var n,r,a;function o(t,e,i){return(e=x(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(){return s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},s.apply(this,arguments)}function h(t){return function(t){if(Array.isArray(t))return p(t)}(t)||y(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=f(t);if(e){var r=f(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return function(t,e){if(e&&("object"===S(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}(this,i)}}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function g(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(t,e){if(t){if("string"==typeof t)return p(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function y(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function m(t){if(Array.isArray(t))return t}function _(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,x(n.key),n)}}function b(t,e,i){return e&&k(t.prototype,e),i&&k(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function x(t){var e=function(t,e){if("object"!==S(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!==S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===S(e)?e:String(e)}function S(t){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},S(t)}a=function(){"use strict";var t,e,n,r=Math.PI/180,a=void 0!==i.g?i.g:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},u={_global:a,version:"9.0.1",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:function(t){return u.angleDeg?t*r: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:function(){return u.DD.isDragging},isDragReady:function(){return!!u.DD.node},releaseCanvasOnDestroy:!0,document:a.document,_injectGlobal:function(t){a.Konva=t}},p=function(t){u[t.prototype.getClassName()]=t};u._injectGlobal(u);var k=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[1,0,0,1,0,0];_(this,t),this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}return b(t,[{key:"reset",value:function(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}},{key:"copy",value:function(){return new t(this.m)}},{key:"copyInto",value:function(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]}},{key:"point",value:function(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]}}},{key:"translate",value:function(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}},{key:"scale",value:function(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}},{key:"rotate",value:function(t){var e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=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]=n,this.m[1]=r,this.m[2]=a,this.m[3]=o,this}},{key:"getTranslation",value:function(){return{x:this.m[4],y:this.m[5]}}},{key:"skew",value:function(t,e){var i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=a,this}},{key:"multiply",value:function(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],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],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]=n,this.m[3]=r,this.m[4]=a,this.m[5]=o,this}},{key:"invert",value:function(){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,n=-this.m[2]*t,r=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]=n,this.m[3]=r,this.m[4]=a,this.m[5]=o,this}},{key:"getMatrix",value:function(){return this.m}},{key:"decompose",value:function(){var t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],r=t*n-e*i,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){var o=Math.sqrt(t*t+e*e);a.rotation=e>0?Math.acos(t/o):-Math.acos(t/o),a.scaleX=o,a.scaleY=r/o,a.skewX=(t*i+e*n)/r,a.skewY=0}else if(0!=i||0!=n){var s=Math.sqrt(i*i+n*n);a.rotation=Math.PI/2-(n>0?Math.acos(-i/s):-Math.acos(i/s)),a.scaleX=r/s,a.scaleY=s,a.skewX=0,a.skewY=(t*i+e*n)/r}return a.rotation=G._getRotation(a.rotation),a}}]),t}(),x=Math.PI/180,w=180/Math.PI,C="Konva error: ",P={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},A=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,T=[],M="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)},G={_isElement:function(t){return!(!t||1!=t.nodeType)},_isFunction:function(t){return!!(t&&t.constructor&&t.call&&t.apply)},_isPlainObject:function(t){return!!t&&t.constructor===Object},_isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},_isNumber:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t)},_isString:function(t){return"[object String]"===Object.prototype.toString.call(t)},_isBoolean:function(t){return"[object Boolean]"===Object.prototype.toString.call(t)},isObject:function(t){return t instanceof Object},isValidSelector:function(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:function(t){return 0===t||t>0?1:-1},requestAnimFrame:function(t){T.push(t),1===T.length&&M((function(){var t=T;T=[],t.forEach((function(t){t()}))}))},createCanvasElement:function(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:function(){return document.createElement("img")},_isInDocument:function(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage:function(t,e){var i=G.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:function(t,e,i){return((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},_hexToRgb:function(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor:function(){for(var t=(16777215*Math.random()<<0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB:function(t){var e;return t in P?{r:(e=P[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=A.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:function(t){return t=t||"black",G._namedColorToRBA(t)||G._hex3ColorToRGBA(t)||G._hex4ColorToRGBA(t)||G._hex6ColorToRGBA(t)||G._hex8ColorToRGBA(t)||G._rgbColorToRGBA(t)||G._rgbaColorToRGBA(t)||G._hslColorToRGBA(t)},_namedColorToRBA:function(t){var e=P[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA:function(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:function(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((function(t,e){return"%"===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:function(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:function(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:function(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:function(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:function(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){var e,i,n,r=m(d=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t))||y(d)||v(d)||g(),a=(r[0],r.slice(1)),o=Number(a[0])/360,s=Number(a[1])/100,h=Number(a[2])/100;if(0===s)return n=255*h,{r:Math.round(n),g:Math.round(n),b:Math.round(n),a:1};for(var l=2*h-(e=h<.5?h*(1+s):h+s-h*s),u=[0,0,0],c=0;c<3;c++)(i=o+1/3*-(c-1))<0&&i++,i>1&&i--,n=6*i<1?l+6*(e-l)*i:2*i<1?e:3*i<2?l+(e-l)*(2/3-i)*6:l,u[c]=255*n;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}var d},haveIntersection:function(t,e){return!(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:function(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:function(t){return t.slice(0)},degToRad:function(t){return t*x},radToDeg:function(t){return t*w},_degToRad:function(t){return G.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),G.degToRad(t)},_radToDeg:function(t){return G.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),G.radToDeg(t)},_getRotation:function(t){return u.angleDeg?G.radToDeg(t):t},_capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},throw:function(t){throw new Error(C+t)},error:function(t){console.error(C+t)},warn:function(t){u.showWarnings&&console.warn("Konva warning: "+t)},each:function(t,e){for(var i in t)e(i,t[i])},_inRange:function(t,e,i){return e<=t&&t<i},_getProjectionToSegment:function(t,e,i,n,r,a){var o,s,h,l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)o=t,s=e,h=(r-i)*(r-i)+(a-n)*(a-n);else{var u=((r-t)*(i-t)+(a-e)*(n-e))/l;u<0?(o=t,s=e,h=(t-r)*(t-r)+(e-a)*(e-a)):u>1?(o=i,s=n,h=(i-r)*(i-r)+(n-a)*(n-a)):h=((o=t+u*(i-t))-r)*(o-r)+((s=e+u*(n-e))-a)*(s-a)}return[o,s,h]},_getProjectionToLine:function(t,e,i){var n=G.cloneObject(t),r=Number.MAX_VALUE;return e.forEach((function(a,o){if(i||o!==e.length-1){var s=e[(o+1)%e.length],h=G._getProjectionToSegment(a.x,a.y,s.x,s.y,t.x,t.y),l=h[0],u=h[1],c=h[2];c<r&&(n.x=l,n.y=u,r=c)}})),n},_prepareArrayForTween:function(t,e,i){var n,r=[],a=[];if(t.length>e.length){var o=e;e=t,t=o}for(n=0;n<t.length;n+=2)r.push({x:t[n],y:t[n+1]});for(n=0;n<e.length;n+=2)a.push({x:e[n],y:e[n+1]});var s=[];return a.forEach((function(t){var e=G._getProjectionToLine(t,r,i);s.push(e.x),s.push(e.y)})),s},_prepareToStringify:function(t){var e;for(var i in t.visitedByCircularReferenceRemoval=!0,t)if(t.hasOwnProperty(i)&&t[i]&&"object"==S(t[i]))if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||G._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===G._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign:function(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:function(t){return t.touches?t.changedTouches[0].identifier:t.pointerId||999},releaseCanvas:function(){if(u.releaseCanvasOnDestroy){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];e.forEach((function(t){t.width=0,t.height=0}))}},drawRoundedRectPath:function(t,e,i,n){var r=0,a=0,o=0,s=0;"number"==typeof n?r=a=o=s=Math.min(n,e/2,i/2):(r=Math.min(n[0]||0,e/2,i/2),a=Math.min(n[1]||0,e/2,i/2),s=Math.min(n[2]||0,e/2,i/2),o=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1),t.lineTo(e,i-s),t.arc(e-s,i-s,s,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}};function R(t){return G._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||G._isBoolean(t)?t:Object.prototype.toString.call(t)}function E(t){return t>255?255:t<0?0:Math.round(t)}function D(){if(u.isUnminified)return function(t,e){return G._isNumber(t)||G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function O(t){if(u.isUnminified)return function(e,i){var n=G._isNumber(e),r=G._isArray(e)&&e.length==t;return n||r||G.warn(R(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function L(){if(u.isUnminified)return function(t,e){return G._isNumber(t)||"auto"===t||G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function I(){if(u.isUnminified)return function(t,e){return G._isString(t)||G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function F(){if(u.isUnminified)return function(t,e){var i=G._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function N(){if(u.isUnminified)return function(t,e){return!0===t||!1===t||G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}var B="get",H="set",W={addGetterSetter:function(t,e,i,n,r){W.addGetter(t,e,i),W.addSetter(t,e,n,r),W.addOverloadedGetterSetter(t,e)},addGetter:function(t,e,i){var n=B+G._capitalize(e);t.prototype[n]=t.prototype[n]||function(){var t=this.attrs[e];return void 0===t?i:t}},addSetter:function(t,e,i,n){var r=H+G._capitalize(e);t.prototype[r]||W.overWriteSetter(t,e,i,n)},overWriteSetter:function(t,e,i,n){var r=H+G._capitalize(e);t.prototype[r]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter:function(t,e,i,n,r){var a,o,s=i.length,h=G._capitalize,l=B+h(e),c=H+h(e);t.prototype[l]=function(){var t={};for(a=0;a<s;a++)t[o=i[a]]=this.getAttr(e+h(o));return t};var d=function(t){if(u.isUnminified)return function(e,i){return null==e||G.isObject(e)||G.warn(R(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[c]=function(t){var a,o=this,s=this.attrs[e];for(a in n&&(t=n.call(this,t)),d&&d.call(this,t,e),t)t.hasOwnProperty(a)&&this._setAttr(e+h(a),t[a]);return t||i.forEach((function(t){o._setAttr(e+h(t),void 0)})),this._fireChangeEvent(e,s,t),r&&r.call(this),this},W.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter:function(t,e){var i=G._capitalize(e),n=H+i,r=B+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter:function(t,e,i,n){G.error("Adding deprecated "+e);var r=B+G._capitalize(e),a=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[r]=function(){G.error(a);var t=this.attrs[e];return void 0===t?i:t},W.addSetter(t,e,n,(function(){G.error(a)})),W.addOverloadedGetterSetter(t,e)},backCompat:function(t,e){G.each(e,(function(e,i){var n=t.prototype[i],r=B+G._capitalize(e),a=H+G._capitalize(e);function o(){n.apply(this,arguments),G.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=o,t.prototype[r]=o,t.prototype[a]=o}))},afterSetFilter:function(){this._filterUpToDate=!1}},z=["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"],j=function(){function t(e){_(this,t),this.canvas=e,u.enableTrace&&(this.traceArr=[],this._enableTrace())}return b(t,[{key:"fillShape",value:function(t){t.fillEnabled()&&this._fill(t)}},{key:"_fill",value:function(t){}},{key:"strokeShape",value:function(t){t.hasStroke()&&this._stroke(t)}},{key:"_stroke",value:function(t){}},{key:"fillStrokeShape",value:function(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}},{key:"getTrace",value:function(t,e){var i,n,r,a,o=this.traceArr,s=o.length,h="";for(i=0;i<s;i++)(r=(n=o[i]).method)?(a=n.args,h+=r,t?h+="()":G._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((function(t){return"number"==typeof t?Math.floor(t):t}))),h+="("+a.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}},{key:"clearTrace",value:function(){this.traceArr=[]}},{key:"_trace",value:function(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}},{key:"reset",value:function(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}},{key:"getCanvas",value:function(){return this.canvas}},{key:"clear",value:function(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)}},{key:"_applyLineCap",value:function(t){var e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}},{key:"_applyOpacity",value:function(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}},{key:"_applyLineJoin",value:function(t){var e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}},{key:"setAttr",value:function(t,e){this._context[t]=e}},{key:"arc",value:function(t,e,i,n,r,a){this._context.arc(t,e,i,n,r,a)}},{key:"arcTo",value:function(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}},{key:"beginPath",value:function(){this._context.beginPath()}},{key:"bezierCurveTo",value:function(t,e,i,n,r,a){this._context.bezierCurveTo(t,e,i,n,r,a)}},{key:"clearRect",value:function(t,e,i,n){this._context.clearRect(t,e,i,n)}},{key:"clip",value:function(){this._context.clip()}},{key:"closePath",value:function(){this._context.closePath()}},{key:"createImageData",value:function(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}},{key:"createLinearGradient",value:function(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}},{key:"createPattern",value:function(t,e){return this._context.createPattern(t,e)}},{key:"createRadialGradient",value:function(t,e,i,n,r,a){return this._context.createRadialGradient(t,e,i,n,r,a)}},{key:"drawImage",value:function(t,e,i,n,r,a,o,s,h){var l=arguments,u=this._context;3===l.length?u.drawImage(t,e,i):5===l.length?u.drawImage(t,e,i,n,r):9===l.length&&u.drawImage(t,e,i,n,r,a,o,s,h)}},{key:"ellipse",value:function(t,e,i,n,r,a,o,s){this._context.ellipse(t,e,i,n,r,a,o,s)}},{key:"isPointInPath",value:function(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}},{key:"fill",value:function(t){t?this._context.fill(t):this._context.fill()}},{key:"fillRect",value:function(t,e,i,n){this._context.fillRect(t,e,i,n)}},{key:"strokeRect",value:function(t,e,i,n){this._context.strokeRect(t,e,i,n)}},{key:"fillText",value:function(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}},{key:"measureText",value:function(t){return this._context.measureText(t)}},{key:"getImageData",value:function(t,e,i,n){return this._context.getImageData(t,e,i,n)}},{key:"lineTo",value:function(t,e){this._context.lineTo(t,e)}},{key:"moveTo",value:function(t,e){this._context.moveTo(t,e)}},{key:"rect",value:function(t,e,i,n){this._context.rect(t,e,i,n)}},{key:"putImageData",value:function(t,e,i){this._context.putImageData(t,e,i)}},{key:"quadraticCurveTo",value:function(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}},{key:"restore",value:function(){this._context.restore()}},{key:"rotate",value:function(t){this._context.rotate(t)}},{key:"save",value:function(){this._context.save()}},{key:"scale",value:function(t,e){this._context.scale(t,e)}},{key:"setLineDash",value:function(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}},{key:"getLineDash",value:function(){return this._context.getLineDash()}},{key:"setTransform",value:function(t,e,i,n,r,a){this._context.setTransform(t,e,i,n,r,a)}},{key:"stroke",value:function(t){t?this._context.stroke(t):this._context.stroke()}},{key:"strokeText",value:function(t,e,i,n){this._context.strokeText(t,e,i,n)}},{key:"transform",value:function(t,e,i,n,r,a){this._context.transform(t,e,i,n,r,a)}},{key:"translate",value:function(t,e){this._context.translate(t,e)}},{key:"_enableTrace",value:function(){var t,e,i=this,n=z.length,r=this.setAttr,a=function(t){var n,r=i[t];i[t]=function(){return e=function(t){var e,i,n=[],r=t.length,a=G;for(e=0;e<r;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),n.push(i);return n}(Array.prototype.slice.call(arguments,0)),n=r.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)a(z[t]);i.setAttr=function(){r.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})}}},{key:"_applyGlobalCompositeOperation",value:function(t){var e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}]),t}();["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(j.prototype,t,{get:function(){return this._context[t]},set:function(e){this._context[t]=e}})}));var Y,X=function(t){l(i,t);var e=c(i);function i(t){var n,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).willReadFrequently,a=void 0!==r&&r;return _(this,i),(n=e.call(this,t))._context=t._canvas.getContext("2d",{willReadFrequently:a}),n}return b(i,[{key:"_fillColor",value:function(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}},{key:"_fillPattern",value:function(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}},{key:"_fillLinearGradient",value:function(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}},{key:"_fillRadialGradient",value:function(t){var e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}},{key:"_fill",value:function(t){var e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)this._fillColor(t);else{var n=t.getFillPatternImage();if(n&&"pattern"===i)this._fillPattern(t);else{var r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)this._fillLinearGradient(t);else{var a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}}}}},{key:"_strokeLinearGradient",value:function(t){var e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(var a=0;a<n.length;a+=2)r.addColorStop(n[a],n[a+1]);this.setAttr("strokeStyle",r)}}},{key:"_stroke",value:function(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,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()}}},{key:"_applyShadow",value:function(t){var e,i,n,r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},s=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=s.x*h,u=s.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",a*Math.min(Math.abs(l),Math.abs(u))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*u)}}]),i}(j),q=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t))._context=t._canvas.getContext("2d",{willReadFrequently:!0}),n}return b(i,[{key:"_fill",value:function(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}},{key:"strokeShape",value:function(t){t.hasHitStroke()&&this._stroke(t)}},{key:"_stroke",value:function(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 n=t.hitStrokeWidth(),r="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}]),i}(j),U=function(){function t(e){_(this,t),this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var i=(e||{}).pixelRatio||u.pixelRatio||function(){if(Y)return Y;var t=G.createCanvasElement(),e=t.getContext("2d");return Y=(u._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),G.releaseCanvas(t),Y}();this.pixelRatio=i,this._canvas=G.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"}return b(t,[{key:"getContext",value:function(){return this.context}},{key:"getPixelRatio",value:function(){return this.pixelRatio}},{key:"setPixelRatio",value:function(t){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}},{key:"setWidth",value:function(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)}},{key:"setHeight",value:function(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)}},{key:"getWidth",value:function(){return this.width}},{key:"getHeight",value:function(){return this.height}},{key:"setSize",value:function(t,e){this.setWidth(t||0),this.setHeight(e||0)}},{key:"toDataURL",value:function(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return G.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}]),t}();W.addGetterSetter(U,"pixelRatio",void 0,D());var V=function(t){l(i,t);var e=c(i);function i(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{width:0,height:0,willReadFrequently:!1};return _(this,i),(t=e.call(this,n)).context=new X(d(t),{willReadFrequently:n.willReadFrequently}),t.setSize(n.width,n.height),t}return b(i)}(U),K=function(t){l(i,t);var e=c(i);function i(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{width:0,height:0};return _(this,i),(t=e.call(this,n)).hitCanvas=!0,t.context=new q(d(t)),t.setSize(n.width,n.height),t}return b(i)}(U),Q={get isDragging(){var t=!1;return Q._dragElements.forEach((function(e){"dragging"===e.dragStatus&&(t=!0)})),t},justDragged:!1,get node(){var t;return Q._dragElements.forEach((function(e){t=e.node})),t},_dragElements:new Map,_drag:function(t){var e=[];Q._dragElements.forEach((function(i,n){var r=i.node,a=r.getStage();a.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=G._getFirstPointerId(t));var o=a._changedPointerPositions.find((function(t){return t.id===i.pointerId}));if(o){if("dragging"!==i.dragStatus){var s=r.dragDistance();if(Math.max(Math.abs(o.x-i.startPointerPos.x),Math.abs(o.y-i.startPointerPos.y))<s)return;if(r.startDrag({evt:t}),!r.isDragging())return}r._setDragPosition(t,i),e.push(r)}})),e.forEach((function(e){e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)}))},_endDragBefore:function(t){var e=[];Q._dragElements.forEach((function(i){var n=i.node.getStage();if(t&&n.setPointersPositions(t),n._changedPointerPositions.find((function(t){return t.id===i.pointerId}))){"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(Q.justDragged=!0,u._mouseListenClick=!1,u._touchListenClick=!1,u._pointerListenClick=!1,i.dragStatus="stopped");var r=i.node.getLayer()||i.node instanceof u.Stage&&i.node;r&&-1===e.indexOf(r)&&e.push(r)}})),e.forEach((function(t){t.draw()}))},_endDragAfter:function(t){Q._dragElements.forEach((function(e,i){"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&Q._dragElements.delete(i)}))}};u.isBrowser&&(window.addEventListener("mouseup",Q._endDragBefore,!0),window.addEventListener("touchend",Q._endDragBefore,!0),window.addEventListener("mousemove",Q._drag),window.addEventListener("touchmove",Q._drag),window.addEventListener("mouseup",Q._endDragAfter,!1),window.addEventListener("touchend",Q._endDragAfter,!1));var J="absoluteOpacity",Z="allEventListeners",$="absoluteTransform",tt="absoluteScale",et="canvas",it="listening",nt="mouseenter",rt="mouseleave",at="Shape",ot=" ",st="stage",ht="transform",lt="visible",ut=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(ot),ct=1,dt=function(){function t(e){_(this,t),this._id=ct++,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(e),this._shouldFireChangeEvents=!0}return b(t,[{key:"hasChildren",value:function(){return!1}},{key:"_clearCache",value:function(t){t!==ht&&t!==$||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}},{key:"_getCache",value:function(t,e){var i=this._cache.get(t);return(void 0===i||(t===ht||t===$)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}},{key:"_calculate",value:function(t,e,i){var n=this;if(!this._attachedDepsListeners.get(t)){var r=e.map((function(t){return t+"Change.konva"})).join(ot);this.on(r,(function(){n._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}},{key:"_getCanvasCache",value:function(){return this._cache.get(et)}},{key:"_clearSelfAndDescendantCache",value:function(t){this._clearCache(t),t===$&&this.fire("absoluteTransformChange")}},{key:"clearCache",value:function(){if(this._cache.has(et)){var t=this._cache.get(et),e=t.scene,i=t.filter,n=t.hit;G.releaseCanvas(e,i,n),this._cache.delete(et)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}},{key:"cache",value:function(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 n=Math.ceil(e.width||i.width),r=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,l=e.drawBorder||!1,u=e.hitCanvasPixelRatio||1;if(n&&r){o-=h,s-=h;var c=new V({pixelRatio:a,width:n+=2*h+1,height:r+=2*h+1}),d=new V({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),f=new K({pixelRatio:u,width:n,height:r}),g=c.getContext(),v=f.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete(et),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,d.getContext()._context.imageSmoothingEnabled=!1),g.save(),v.save(),g.translate(-o,-s),v.translate(-o,-s),this._isUnderCache=!0,this._clearSelfAndDescendantCache(J),this._clearSelfAndDescendantCache(tt),this.drawScene(c,this),this.drawHit(f,this),this._isUnderCache=!1,g.restore(),v.restore(),l&&(g.save(),g.beginPath(),g.rect(0,0,n,r),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(et,{scene:c,filter:d,hit:f,x:o,y:s}),this._requestDraw(),this}G.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}},{key:"isCached",value:function(){return this._cache.has(et)}},{key:"getClientRect",value:function(t){throw new Error('abstract "getClientRect" method call')}},{key:"_transformedRect",value:function(t,e){var i,n,r,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=r=e.x,n=a=e.y),i=Math.min(i,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)})),{x:i,y:n,width:r-i,height:a-n}}},{key:"_drawCachedSceneCanvas",value:function(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);var e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}},{key:"_drawCachedHitCanvas",value:function(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()}},{key:"_getCachedSceneCanvas",value:function(){var t,e,i,n,r=this.filters(),a=this._getCanvasCache(),o=a.scene,s=a.filter,h=s.getContext();if(r){if(!this._filterUpToDate){var l=o.pixelRatio;s.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(t=r.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/l,o.getHeight()/l),e=h.getImageData(0,0,s.getWidth(),s.getHeight()),i=0;i<t;i++)"function"==typeof(n=r[i])?(n.call(this,e),h.putImageData(e,0,0)):G.error("Filter should be type of function, but got "+S(n)+" instead. Please check correct filters")}catch(t){G.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}},{key:"on",value:function(t,e){if(this._cache&&this._cache.delete(Z),3===arguments.length)return this._delegate.apply(this,arguments);var i,n,r,a,o=t.split(ot),s=o.length;for(i=0;i<s;i++)r=(n=o[i].split("."))[0],a=n[1]||"",this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:a,handler:e});return this}},{key:"off",value:function(t,e){var i,n,r,a,o,s=(t||"").split(ot),h=s.length;if(this._cache&&this._cache.delete(Z),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<h;i++)if(a=(r=s[i].split("."))[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}},{key:"dispatchEvent",value:function(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}},{key:"addEventListener",value:function(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}},{key:"removeEventListener",value:function(t){return this.off(t),this}},{key:"_delegate",value:function(t,e,i){var n=this;this.on(t,(function(t){for(var r=t.target.findAncestors(e,!0,n),a=0;a<r.length;a++)(t=G.cloneObject(t)).currentTarget=r[a],i.call(r[a],t)}))}},{key:"remove",value:function(){return this.isDragging()&&this.stopDrag(),Q._dragElements.delete(this._id),this._remove(),this}},{key:"_clearCaches",value:function(){this._clearSelfAndDescendantCache($),this._clearSelfAndDescendantCache(J),this._clearSelfAndDescendantCache(tt),this._clearSelfAndDescendantCache(st),this._clearSelfAndDescendantCache(lt),this._clearSelfAndDescendantCache(it)}},{key:"_remove",value:function(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}},{key:"destroy",value:function(){return this.remove(),this.clearCache(),this}},{key:"getAttr",value:function(t){var e="get"+G._capitalize(t);return G._isFunction(this[e])?this[e]():this.attrs[t]}},{key:"getAncestors",value:function(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}},{key:"getAttrs",value:function(){return this.attrs||{}}},{key:"setAttrs",value:function(t){var e=this;return this._batchTransformChanges((function(){var i,n;if(!t)return e;for(i in t)"children"!==i&&(n="set"+G._capitalize(i),G._isFunction(e[n])?e[n](t[i]):e._setAttr(i,t[i]))})),this}},{key:"isListening",value:function(){return this._getCache(it,this._isListening)}},{key:"_isListening",value:function(t){if(!this.listening())return!1;var e=this.getParent();return!e||e===t||this===t||e._isListening(t)}},{key:"isVisible",value:function(){return this._getCache(lt,this._isVisible)}},{key:"_isVisible",value:function(t){if(!this.visible())return!1;var e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}},{key:"shouldDrawHit",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),n=!1;Q._dragElements.forEach((function(t){"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));var r=!e&&!u.hitOnDragEnabled&&n;return this.isListening()&&this.isVisible()&&!r}},{key:"show",value:function(){return this.visible(!0),this}},{key:"hide",value:function(){return this.visible(!1),this}},{key:"getZIndex",value:function(){return this.index||0}},{key:"getAbsoluteZIndex",value:function(){var t,e,i,n,r=this.getDepth(),a=this,o=0;return"Stage"!==a.nodeType&&function s(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],o++,n.nodeType!==at&&(t=t.concat(n.getChildren().slice())),n._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&s(t)}(a.getStage().getChildren()),o}},{key:"getDepth",value:function(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}},{key:"_batchTransformChanges",value:function(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(ht),this._clearSelfAndDescendantCache($)),this._needClearTransformCache=!1}},{key:"setPosition",value:function(t){var e=this;return this._batchTransformChanges((function(){e.x(t.x),e.y(t.y)})),this}},{key:"getPosition",value:function(){return{x:this.x(),y:this.y()}}},{key:"getRelativePointerPosition",value:function(){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)}},{key:"getAbsolutePosition",value:function(t){for(var e=!1,i=this.parent;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var n=this.getAbsoluteTransform(t).getMatrix(),r=new k,a=this.offset();return r.m=n.slice(),r.translate(a.x,a.y),r.getTranslation()}},{key:"setAbsolutePosition",value:function(t){var e=this._clearTransform();this.attrs.x=e.x,this.attrs.y=e.y,delete e.x,delete e.y,this._clearCache(ht);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(ht),this._clearSelfAndDescendantCache($),this}},{key:"_setTransform",value:function(t){var e;for(e in t)this.attrs[e]=t[e]}},{key:"_clearTransform",value:function(){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}},{key:"move",value:function(t){var e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}},{key:"_eachAncestorReverse",value:function(t,e){var i,n,r=[],a=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);a&&(!e||a._id!==e._id);)r.unshift(a),a=a.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}},{key:"rotate",value:function(t){return this.rotation(this.rotation()+t),this}},{key:"moveToTop",value:function(){if(!this.parent)return G.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)}},{key:"moveUp",value:function(){if(!this.parent)return G.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)}},{key:"moveDown",value:function(){if(!this.parent)return G.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)}},{key:"moveToBottom",value:function(){if(!this.parent)return G.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)}},{key:"setZIndex",value:function(t){if(!this.parent)return G.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&G.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}},{key:"getAbsoluteOpacity",value:function(){return this._getCache(J,this._getAbsoluteOpacity)}},{key:"_getAbsoluteOpacity",value:function(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}},{key:"moveTo",value:function(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}},{key:"toObject",value:function(){var t,e,i,n,r={},a=this.getAttrs();for(t in r.attrs={},a)e=a[t],G.isObject(e)&&!G._isPlainObject(e)&&!G._isArray(e)||(i="function"==typeof this[t]&&this[t],delete a[t],n=i?i.call(this):null,a[t]=e,n!==e&&(r.attrs[t]=e));return r.className=this.getClassName(),G._prepareToStringify(r)}},{key:"toJSON",value:function(){return JSON.stringify(this.toObject())}},{key:"getParent",value:function(){return this.parent}},{key:"findAncestors",value:function(t,e,i){var n=[];e&&this._isMatch(t)&&n.push(this);for(var r=this.parent;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}},{key:"isAncestorOf",value:function(t){return!1}},{key:"findAncestor",value:function(t,e,i){return this.findAncestors(t,e,i)[0]}},{key:"_isMatch",value:function(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,n=t.replace(/ /g,"").split(","),r=n.length;for(e=0;e<r;e++)if(i=n[e],G.isValidSelector(i)||(G.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),G.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),G.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}},{key:"getLayer",value:function(){var t=this.getParent();return t?t.getLayer():null}},{key:"getStage",value:function(){return this._getCache(st,this._getStage)}},{key:"_getStage",value:function(){var t=this.getParent();return t?t.getStage():void 0}},{key:"fire",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}},{key:"getAbsoluteTransform",value:function(t){return t?this._getAbsoluteTransform(t):this._getCache($,this._getAbsoluteTransform)}},{key:"_getAbsoluteTransform",value:function(t){var e;if(t)return e=new k,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($)||new k,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){var n=this.attrs.x||0,r=this.attrs.y||0,a=this.attrs.offsetX||0,o=this.attrs.offsetY||0;e.translate(n-a,r-o)}return e.dirty=!1,e}},{key:"getAbsoluteScale",value:function(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();var i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}},{key:"getAbsoluteRotation",value:function(){return this.getAbsoluteTransform().decompose().rotation}},{key:"getTransform",value:function(){return this._getCache(ht,this._getTransform)}},{key:"_getTransform",value:function(){var t,e,i=this._cache.get(ht)||new k;i.reset();var n=this.x(),r=this.y(),a=u.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,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===r||i.translate(n,r),0!==a&&i.rotate(a),0===h&&0===l||i.skew(h,l),1===o&&1===s||i.scale(o,s),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}},{key:"clone",value:function(t){var e,i,n,r,a,o=G.cloneObject(this.attrs);for(e in t)o[e]=t[e];var s=new this.constructor(o);for(e in this.eventListeners)for(n=(i=this.eventListeners[e]).length,r=0;r<n;r++)(a=i[r]).name.indexOf("konva")<0&&(s.eventListeners[e]||(s.eventListeners[e]=[]),s.eventListeners[e].push(a));return s}},{key:"_toKonvaCanvas",value:function(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),r=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new V({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(),(n||r)&&s.translate(-1*n,-1*r),this.drawScene(o),s.restore(),o}},{key:"toCanvas",value:function(t){return this._toKonvaCanvas(t)._canvas}},{key:"toDataURL",value:function(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}},{key:"toImage",value:function(t){var e=this;return new Promise((function(i,n){try{var r=null==t?void 0:t.callback;r&&delete t.callback,G._urlToImage(e.toDataURL(t),(function(t){i(t),null==r||r(t)}))}catch(t){n(t)}}))}},{key:"toBlob",value:function(t){var e=this;return new Promise((function(i,n){try{var r=null==t?void 0:t.callback;r&&delete t.callback,e.toCanvas(t).toBlob((function(t){i(t),null==r||r(t)}))}catch(t){n(t)}}))}},{key:"setSize",value:function(t){return this.width(t.width),this.height(t.height),this}},{key:"getSize",value:function(){return{width:this.width(),height:this.height()}}},{key:"getClassName",value:function(){return this.className||this.nodeType}},{key:"getType",value:function(){return this.nodeType}},{key:"getDragDistance",value:function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():u.dragDistance}},{key:"_off",value:function(t,e,i){var n,r,a,o=this.eventListeners[t];for(n=0;n<o.length;n++)if(r=o[n].name,a=o[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==a)){if(o.splice(n,1),0===o.length){delete this.eventListeners[t];break}n--}}},{key:"_fireChangeEvent",value:function(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}},{key:"addName",value:function(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}},{key:"hasName",value:function(t){if(!t)return!1;var e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}},{key:"removeName",value:function(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}},{key:"setAttr",value:function(t,e){var i=this["set"+G._capitalize(t)];return G._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}},{key:"_requestDraw",value:function(){if(u.autoDrawEnabled){var t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}},{key:"_setAttr",value:function(t,e){var i=this.attrs[t];(i!==e||G.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}},{key:"_setComponentAttr",value:function(t,e,i){var n;void 0!==i&&((n=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}},{key:"_fireAndBubble",value:function(t,e,i){if(e&&this.nodeType===at&&(e.target=this),t!==nt&&t!==rt||!(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i)){this._fire(t,e);var n=(t===nt||t===rt)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}},{key:"_getProtoListeners",value:function(t){var e,i,n,r=null!==(e=this._cache.get(Z))&&void 0!==e?e:{},a=null==r?void 0:r[t];if(void 0===a){a=[];for(var o=Object.getPrototypeOf(this);o;){var s,l=null!==(n=null===(i=o.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];(s=a).push.apply(s,h(l)),o=Object.getPrototypeOf(o)}r[t]=a,this._cache.set(Z,r)}return a}},{key:"_fire",value:function(t,e){(e=e||{}).currentTarget=this,e.type=t;var i=this._getProtoListeners(t);if(i)for(var n=0;n<i.length;n++)i[n].handler.call(this,e);var r=this.eventListeners[t];if(r)for(n=0;n<r.length;n++)r[n].handler.call(this,e)}},{key:"draw",value:function(){return this.drawScene(),this.drawHit(),this}},{key:"_createDragElement",value:function(t){var e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition(),r=i._getPointerById(e)||i._changedPointerPositions[0]||n;Q._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-n.x,y:r.y-n.y},dragStatus:"ready",pointerId:e})}},{key:"startDrag",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Q._dragElements.has(this._id)||this._createDragElement(t),Q._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}},{key:"_setDragPosition",value:function(t,e){var i=this.getStage()._getPointerById(e.pointerId);if(i){var n={x:i.x-e.offset.x,y:i.y-e.offset.y},r=this.dragBoundFunc();if(void 0!==r){var a=r.call(this,n,t);a?n=a:G.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}},{key:"stopDrag",value:function(t){var e=Q._dragElements.get(this._id);e&&(e.dragStatus="stopped"),Q._endDragBefore(t),Q._endDragAfter(t)}},{key:"setDraggable",value:function(t){this._setAttr("draggable",t),this._dragChange()}},{key:"isDragging",value:function(){var t=Q._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}},{key:"_listenDrag",value:function(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){var e=this;if((void 0===t.evt.button||u.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var i=!1;Q._dragElements.forEach((function(t){e.isAncestorOf(t.node)&&(i=!0)})),i||this._createDragElement(t)}}))}},{key:"_dragChange",value:function(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;var t=Q._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&Q._dragElements.delete(this._id)}}},{key:"_dragCleanup",value:function(){this.off("mousedown.konva"),this.off("touchstart.konva")}},{key:"isClientRectOnScreen",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0},e=this.getStage();if(!e)return!1;var i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return G.haveIntersection(i,this.getClientRect())}}],[{key:"create",value:function(t,e){return G._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}},{key:"_createNode",value:function(e,i){var n,r,a,o=t.prototype.getClassName.call(e),s=e.children;if(i&&(e.attrs.container=i),u[o]||(G.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new(0,u[o])(e.attrs),s)for(r=s.length,a=0;a<r;a++)n.add(t._createNode(s[a]));return n}}]),t}();dt.prototype.nodeType="Node",dt.prototype._attrsAffectingSize=[],dt.prototype.eventListeners={},dt.prototype.on.call(dt.prototype,ut,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(ht),this._clearSelfAndDescendantCache($))})),dt.prototype.on.call(dt.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(lt)})),dt.prototype.on.call(dt.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(it)})),dt.prototype.on.call(dt.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(J)}));var ft=W.addGetterSetter;ft(dt,"zIndex"),ft(dt,"absolutePosition"),ft(dt,"position"),ft(dt,"x",0,D()),ft(dt,"y",0,D()),ft(dt,"globalCompositeOperation","source-over",I()),ft(dt,"opacity",1,D()),ft(dt,"name","",I()),ft(dt,"id","",I()),ft(dt,"rotation",0,D()),W.addComponentsGetterSetter(dt,"scale",["x","y"]),ft(dt,"scaleX",1,D()),ft(dt,"scaleY",1,D()),W.addComponentsGetterSetter(dt,"skew",["x","y"]),ft(dt,"skewX",0,D()),ft(dt,"skewY",0,D()),W.addComponentsGetterSetter(dt,"offset",["x","y"]),ft(dt,"offsetX",0,D()),ft(dt,"offsetY",0,D()),ft(dt,"dragDistance",null,D()),ft(dt,"width",0,D()),ft(dt,"height",0,D()),ft(dt,"listening",!0,N()),ft(dt,"preventDefault",!0,N()),ft(dt,"filters",null,(function(t){return this._filterUpToDate=!1,t})),ft(dt,"visible",!0,N()),ft(dt,"transformsEnabled","all",I()),ft(dt,"size"),ft(dt,"dragBoundFunc"),ft(dt,"draggable",!1,N()),W.backCompat(dt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var gt=function(t){l(i,t);var e=c(i);function i(){var t;return _(this,i),(t=e.apply(this,arguments)).children=[],t}return b(i,[{key:"getChildren",value:function(t){if(!t)return this.children||[];var e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}},{key:"hasChildren",value:function(){return this.getChildren().length>0}},{key:"removeChildren",value:function(){return this.getChildren().forEach((function(t){t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}},{key:"destroyChildren",value:function(){return this.getChildren().forEach((function(t){t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}},{key:"add",value:function(){if(0===arguments.length)return this;if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(t<0||arguments.length<=t?void 0:arguments[t]);return this}var e=arguments.length<=0?void 0:arguments[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}},{key:"destroy",value:function(){return this.hasChildren()&&this.destroyChildren(),s(f(i.prototype),"destroy",this).call(this),this}},{key:"find",value:function(t){return this._generalFind(t,!1)}},{key:"findOne",value:function(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}},{key:"_generalFind",value:function(t,e){var i=[];return this._descendants((function(n){var r=n._isMatch(t);return r&&i.push(n),!(!r||!e)})),i}},{key:"_descendants",value:function(t){var e,i=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=v(t))){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}(this.getChildren());try{for(i.s();!(e=i.n()).done;){var n=e.value;if(t(n))return!0;if(n.hasChildren()&&n._descendants(t))return!0}}catch(t){i.e(t)}finally{i.f()}return!1}},{key:"toObject",value:function(){var t=dt.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((function(e){t.children.push(e.toObject())})),t}},{key:"isAncestorOf",value:function(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}},{key:"clone",value:function(t){var e=dt.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}},{key:"getAllIntersections",value:function(t){var e=[];return this.find("Shape").forEach((function(i){i.isVisible()&&i.intersects(t)&&e.push(i)})),e}},{key:"_clearSelfAndDescendantCache",value:function(t){var e;s(f(i.prototype),"_clearSelfAndDescendantCache",this).call(this,t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}},{key:"_setChildrenIndices",value:function(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}},{key:"drawScene",value:function(t,e){var i=this.getLayer(),n=t||i&&i.getCanvas(),r=n&&n.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=n&&n.isCache;if(!this.isVisible()&&!s)return this;if(o){r.save();var h=this.getAbsoluteTransform(e).getMatrix();r.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",n,e);return this}},{key:"drawHit",value:function(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),a=this._getCanvasCache();if(a&&a.hit){r.save();var o=this.getAbsoluteTransform(e).getMatrix();r.transform(o[0],o[1],o[2],o[3],o[4],o[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}},{key:"_drawChildren",value:function(t,e,i){var n,r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),s=this.clipFunc(),h=a&&o||s,l=i===this;if(h){r.save();var u=this.getAbsoluteTransform(i),c=u.getMatrix();if(r.transform(c[0],c[1],c[2],c[3],c[4],c[5]),r.beginPath(),s)s.call(this,r,this);else{var d=this.clipX(),f=this.clipY();r.rect(d,f,a,o)}r.clip(),c=u.copy().invert().getMatrix(),r.transform(c[0],c[1],c[2],c[3],c[4],c[5])}var g=!l&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;g&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(n=this.children)||void 0===n||n.forEach((function(n){n[t](e,i)})),g&&r.restore(),h&&r.restore()}},{key:"getClientRect",value:function(t){var e,i,n,r,a,o,s=(t=t||{}).skipTransform,h=t.relativeTo,l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var o=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===o.width&&0===o.height||(void 0===i?(i=o.x,n=o.y,r=o.x+o.width,a=o.y+o.height):(i=Math.min(i,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),a=Math.max(a,o.y+o.height)))}}));for(var u=this.find("Shape"),c=!1,d=0;d<u.length;d++)if(u[d]._isVisible(this)){c=!0;break}return o=c&&void 0!==i?{x:i,y:n,width:r-i,height:a-n}:{x:0,y:0,width:0,height:0},s?o:this._transformedRect(o,h)}}]),i}(dt);W.addComponentsGetterSetter(gt,"clip",["x","y","width","height"]),W.addGetterSetter(gt,"clipX",void 0,D()),W.addGetterSetter(gt,"clipY",void 0,D()),W.addGetterSetter(gt,"clipWidth",void 0,D()),W.addGetterSetter(gt,"clipHeight",void 0,D()),W.addGetterSetter(gt,"clipFunc");var vt=new Map,pt=void 0!==u._global.PointerEvent;function yt(t){return vt.get(t)}function mt(t){return{evt:t,pointerId:t.pointerId}}function _t(t,e){return vt.get(t)===e}function kt(t,e){bt(t),e.getStage()&&(vt.set(t,e),pt&&e._fire("gotpointercapture",mt(new PointerEvent("gotpointercapture"))))}function bt(t,e){var i=vt.get(t);if(i){var n=i.getStage();n&&n.content,vt.delete(t),pt&&i._fire("lostpointercapture",mt(new PointerEvent("lostpointercapture")))}}var xt="mouseleave",St="mouseover",wt="mouseenter",Ct="mousemove",Pt="mousedown",At="mouseup",Tt="pointermove",Mt="pointerdown",Gt="pointerup",Rt="pointercancel",Et="pointerout",Dt="pointerleave",Ot="pointerover",Lt="pointerenter",It="contextmenu",Ft="touchstart",Nt="touchend",Bt="touchmove",Ht="touchcancel",Wt="wheel",zt=[[wt,"_pointerenter"],[Pt,"_pointerdown"],[Ct,"_pointermove"],[At,"_pointerup"],[xt,"_pointerleave"],[Ft,"_pointerdown"],[Bt,"_pointermove"],[Nt,"_pointerup"],[Ht,"_pointercancel"],[St,"_pointerover"],[Wt,"_wheel"],[It,"_contextmenu"],[Mt,"_pointerdown"],[Tt,"_pointermove"],[Gt,"_pointerup"],[Rt,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],jt={mouse:(t={},o(t,Et,"mouseout"),o(t,Dt,xt),o(t,Ot,St),o(t,Lt,wt),o(t,Tt,Ct),o(t,Mt,Pt),o(t,Gt,At),o(t,Rt,"mousecancel"),o(t,"pointerclick","click"),o(t,"pointerdblclick","dblclick"),t),touch:(e={},o(e,Et,"touchout"),o(e,Dt,"touchleave"),o(e,Ot,"touchover"),o(e,Lt,"touchenter"),o(e,Tt,Bt),o(e,Mt,Ft),o(e,Gt,Nt),o(e,Rt,Ht),o(e,"pointerclick","tap"),o(e,"pointerdblclick","dbltap"),e),pointer:(n={},o(n,Et,Et),o(n,Dt,Dt),o(n,Ot,Ot),o(n,Lt,Lt),o(n,Tt,Tt),o(n,Mt,Mt),o(n,Gt,Gt),o(n,Rt,Rt),o(n,"pointerclick","pointerclick"),o(n,"pointerdblclick","pointerdblclick"),n)},Yt=function(t){return t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse"},Xt=function(t){var e=Yt(t);return"pointer"===e?u.pointerEventsEnabled&&jt.pointer:"touch"===e?jt.touch:"mouse"===e?jt.mouse:void 0};function qt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(t.clipFunc||t.clipWidth||t.clipHeight)&&G.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}var Ut=[],Vt=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,qt(t)))._pointerPositions=[],n._changedPointerPositions=[],n._buildDOM(),n._bindContentEvents(),Ut.push(d(n)),n.on("widthChange.konva heightChange.konva",n._resizeDOM),n.on("visibleChange.konva",n._checkVisibility),n.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(function(){qt(n.attrs)})),n._checkVisibility(),n}return b(i,[{key:"_validateAdd",value:function(t){var e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||G.throw("You may only add layers to the stage.")}},{key:"_checkVisibility",value:function(){if(this.content){var t=this.visible()?"":"none";this.content.style.display=t}}},{key:"setContainer",value:function(t){if("string"===S(t)){if("."===t.charAt(0)){var e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var i;i="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(i)}if(!t)throw"Can not find container in document with id "+i}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}},{key:"shouldDrawHit",value:function(){return!0}},{key:"clear",value:function(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}},{key:"clone",value:function(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),gt.prototype.clone.call(this,t)}},{key:"destroy",value:function(){s(f(i.prototype),"destroy",this).call(this);var t=this.content;t&&G._isInDocument(t)&&this.container().removeChild(t);var e=Ut.indexOf(this);return e>-1&&Ut.splice(e,1),G.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}},{key:"getPointerPosition",value:function(){var t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(G.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}},{key:"_getPointerById",value:function(t){return this._pointerPositions.find((function(e){return e.id===t}))}},{key:"getPointersPositions",value:function(){return this._pointerPositions}},{key:"getStage",value:function(){return this}},{key:"getContent",value:function(){return this.content}},{key:"_toKonvaCanvas",value:function(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new V({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(e.isVisible()){var n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}})),e}},{key:"getIntersection",value:function(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){var n=i[e].getIntersection(t);if(n)return n}return null}},{key:"_resizeDOM",value:function(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((function(i){i.setSize({width:t,height:e}),i.draw()}))}},{key:"add",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(arguments.length>1){for(var a=0;a<arguments.length;a++)this.add(arguments[a]);return this}s(f(i.prototype),"add",this).call(this,t);var o=this.children.length;return o>5&&G.warn("The stage has "+o+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),u.isBrowser&&this.content.appendChild(t.canvas._canvas),this}},{key:"getParent",value:function(){return null}},{key:"getLayer",value:function(){return null}},{key:"hasPointerCapture",value:function(t){return _t(t,this)}},{key:"setPointerCapture",value:function(t){kt(t,this)}},{key:"releaseCapture",value:function(t){bt(t)}},{key:"getLayers",value:function(){return this.children}},{key:"_bindContentEvents",value:function(){var t=this;u.isBrowser&&zt.forEach((function(e){var i,n,r=(n=2,m(i=e)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,r,a,o,s=[],h=!0,l=!1;try{if(a=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;h=!1}else for(;!(h=(n=a.call(i)).done)&&(s.push(n.value),s.length!==e);h=!0);}catch(t){l=!0,r=t}finally{try{if(!h&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(i,n)||v(i,n)||g()),a=r[0],o=r[1];t.content.addEventListener(a,(function(e){t[o](e)}),{passive:!1})}))}},{key:"_pointerenter",value:function(t){this.setPointersPositions(t);var e=Xt(t.type);this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}},{key:"_pointerover",value:function(t){this.setPointersPositions(t);var e=Xt(t.type);this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}},{key:"_getTargetShape",value:function(t){var e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}},{key:"_pointerleave",value:function(t){var e=Xt(t.type),i=Yt(t.type);if(e){this.setPointersPositions(t);var n=this._getTargetShape(i),r=!Q.isDragging||u.hitOnDragEnabled;n&&r?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}},{key:"_pointerdown",value:function(t){var e=this,i=Xt(t.type),n=Yt(t.type);if(i){this.setPointersPositions(t);var r=!1;this._changedPointerPositions.forEach((function(a){var o=e.getIntersection(a);if(Q.justDragged=!1,u["_"+n+"ListenClick"]=!0,o&&o.isListening()){u.capturePointerEventsEnabled&&o.setPointerCapture(a.id),e[n+"ClickStartShape"]=o,o._fireAndBubble(i.pointerdown,{evt:t,pointerId:a.id}),r=!0;var s=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&s&&t.preventDefault()}})),r||this._fire(i.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}},{key:"_pointermove",value:function(t){var e=this,i=Xt(t.type),n=Yt(t.type);if(i&&(Q.isDragging&&Q.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!Q.isDragging||u.hitOnDragEnabled)){var r={},a=!1,o=this._getTargetShape(n);this._changedPointerPositions.forEach((function(s){var h=yt(s.id)||e.getIntersection(s),l=s.id,u={evt:t,pointerId:l},c=o!==h;if(c&&o&&(o._fireAndBubble(i.pointerout,Object.assign({},u),h),o._fireAndBubble(i.pointerleave,Object.assign({},u),h)),h){if(r[h._id])return;r[h._id]=!0}h&&h.isListening()?(a=!0,c&&(h._fireAndBubble(i.pointerover,Object.assign({},u),o),h._fireAndBubble(i.pointerenter,Object.assign({},u),o),e[n+"targetShape"]=h),h._fireAndBubble(i.pointermove,Object.assign({},u))):o&&(e._fire(i.pointerover,{evt:t,target:e,currentTarget:e,pointerId:l}),e[n+"targetShape"]=null)})),a||this._fire(i.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}}},{key:"_pointerup",value:function(t){var e=this,i=Xt(t.type),n=Yt(t.type);if(i){this.setPointersPositions(t);var r=this[n+"ClickStartShape"],a=this[n+"ClickEndShape"],o={},s=!1;this._changedPointerPositions.forEach((function(h){var l=yt(h.id)||e.getIntersection(h);if(l){if(l.releaseCapture(h.id),o[l._id])return;o[l._id]=!0}var c=h.id,d={evt:t,pointerId:c},f=!1;u["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(e[n+"DblTimeout"])):Q.justDragged||(u["_"+n+"InDblClickWindow"]=!0,clearTimeout(e[n+"DblTimeout"])),e[n+"DblTimeout"]=setTimeout((function(){u["_"+n+"InDblClickWindow"]=!1}),u.dblClickWindow),l&&l.isListening()?(s=!0,e[n+"ClickEndShape"]=l,l._fireAndBubble(i.pointerup,Object.assign({},d)),u["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(i.pointerclick,Object.assign({},d)),f&&a&&a===l&&l._fireAndBubble(i.pointerdblclick,Object.assign({},d)))):(e[n+"ClickEndShape"]=null,u["_"+n+"ListenClick"]&&e._fire(i.pointerclick,{evt:t,target:e,currentTarget:e,pointerId:c}),f&&e._fire(i.pointerdblclick,{evt:t,target:e,currentTarget:e,pointerId:c}))})),s||this._fire(i.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),u["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&t.preventDefault()}}},{key:"_contextmenu",value:function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(It,{evt:t}):this._fire(It,{evt:t,target:this,currentTarget:this})}},{key:"_wheel",value:function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Wt,{evt:t}):this._fire(Wt,{evt:t,target:this,currentTarget:this})}},{key:"_pointercancel",value:function(t){this.setPointersPositions(t);var e=yt(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(Gt,mt(t)),bt(t.pointerId)}},{key:"_lostpointercapture",value:function(t){bt(t.pointerId)}},{key:"setPointersPositions",value:function(t){var e=this,i=this._getContentPosition(),n=null,r=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(function(t){e._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(function(t){e._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(n=(t.clientX-i.left)/i.scaleX,r=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:G._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:r,id:G._getFirstPointerId(t)}])}},{key:"_setPointerPosition",value:function(t){G.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}},{key:"_getContentPosition",value:function(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}},{key:"_buildDOM",value:function(){if(this.bufferCanvas=new V({width:this.width(),height:this.height()}),this.bufferHitCanvas=new K({pixelRatio:1,width:this.width(),height:this.height()}),u.isBrowser){var t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}}},{key:"cache",value:function(){return G.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}},{key:"clearCache",value:function(){return this}},{key:"batchDraw",value:function(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}]),i}(gt);Vt.prototype.nodeType="Stage",p(Vt),W.addGetterSetter(Vt,"container");var Kt,Qt="hasShadow",Jt="shadowRGBA",Zt="patternImage",$t="linearGradient",te="radialGradient";function ee(){return Kt||(Kt=G.createCanvasElement().getContext("2d"))}var ie={},ne=function(t){l(i,t);var e=c(i);function i(t){var n,r;for(_(this,i),n=e.call(this,t);!(r=G.getRandomColor())||r in ie;);return n.colorKey=r,ie[r]=d(n),n}return b(i,[{key:"getContext",value:function(){return G.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}},{key:"getCanvas",value:function(){return G.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}},{key:"getSceneFunc",value:function(){return this.attrs.sceneFunc||this._sceneFunc}},{key:"getHitFunc",value:function(){return this.attrs.hitFunc||this._hitFunc}},{key:"hasShadow",value:function(){return this._getCache(Qt,this._hasShadow)}},{key:"_hasShadow",value:function(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}},{key:"_getFillPattern",value:function(){return this._getCache(Zt,this.__getFillPattern)}},{key:"__getFillPattern",value:function(){if(this.fillPatternImage()){var t=ee().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){var e=new k;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(u.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());var i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}},{key:"_getLinearGradient",value:function(){return this._getCache($t,this.__getLinearGradient)}},{key:"__getLinearGradient",value:function(){var t=this.fillLinearGradientColorStops();if(t){for(var e=ee(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}},{key:"_getRadialGradient",value:function(){return this._getCache(te,this.__getRadialGradient)}},{key:"__getRadialGradient",value:function(){var t=this.fillRadialGradientColorStops();if(t){for(var e=ee(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius()),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}},{key:"getShadowRGBA",value:function(){return this._getCache(Jt,this._getShadowRGBA)}},{key:"_getShadowRGBA",value:function(){if(this.hasShadow()){var t=G.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}},{key:"hasFill",value:function(){var t=this;return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(function(){return t.fillEnabled()&&!!(t.fill()||t.fillPatternImage()||t.fillLinearGradientColorStops()||t.fillRadialGradientColorStops())}))}},{key:"hasStroke",value:function(){var t=this;return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(function(){return t.strokeEnabled()&&t.strokeWidth()&&!(!t.stroke()&&!t.strokeLinearGradientColorStops())}))}},{key:"hasHitStroke",value:function(){var t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}},{key:"intersects",value:function(t){var e=this.getStage().bufferHitCanvas;return e.getContext().clear(),this.drawHit(e,null,!0),e.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}},{key:"destroy",value:function(){return dt.prototype.destroy.call(this),delete ie[this.colorKey],delete this.colorKey,this}},{key:"_useBufferCanvas",value:function(t){var e;if(!this.getStage())return!1;if(null!==(e=this.attrs.perfectDrawEnabled)&&void 0!==e&&!e)return!1;var i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;var a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&n&&a&&o)}},{key:"setStrokeHitEnabled",value:function(t){G.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}},{key:"getStrokeHitEnabled",value:function(){return 0!==this.hitStrokeWidth()}},{key:"getSelfRect",value:function(){var t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}},{key:"getClientRect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.skipTransform,i=t.relativeTo,n=this.getSelfRect(),r=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+r,o=n.height+r,s=!t.skipShadow&&this.hasShadow(),h=s?this.shadowOffsetX():0,l=s?this.shadowOffsetY():0,u=a+Math.abs(h),c=o+Math.abs(l),d=s&&this.shadowBlur()||0,f={width:u+2*d,height:c+2*d,x:-(r/2+d)+Math.min(h,0)+n.x,y:-(r/2+d)+Math.min(l,0)+n.y};return e?f:this._transformedRect(f,i)}},{key:"drawScene",value:function(t,e){var i,n,r=this.getLayer(),a=t||r.getCanvas(),o=a.getContext(),s=this._getCanvasCache(),h=this.getSceneFunc(),l=this.hasShadow(),u=a.isCache,c=e===this;if(!this.isVisible()&&!c)return this;if(s){o.save();var d=this.getAbsoluteTransform(e).getMatrix();return o.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!h)return this;if(o.save(),this._useBufferCanvas()&&!u){(n=(i=this.getStage().bufferCanvas).getContext()).clear(),n.save(),n._applyLineJoin(this);var f=this.getAbsoluteTransform(e).getMatrix();n.transform(f[0],f[1],f[2],f[3],f[4],f[5]),h.call(this,n,this),n.restore();var g=i.pixelRatio;l&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(i._canvas,0,0,i.width/g,i.height/g)}else o._applyLineJoin(this),c||(f=this.getAbsoluteTransform(e).getMatrix(),o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),l&&o._applyShadow(this),h.call(this,o,this);return o.restore(),this}},{key:"drawHit",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.shouldDrawHit(e,i))return this;var n=this.getLayer(),r=t||n.hitCanvas,a=r&&r.getContext(),o=this.hitFunc()||this.sceneFunc(),s=this._getCanvasCache(),h=s&&s.hit;if(this.colorKey||G.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){a.save();var l=this.getAbsoluteTransform(e).getMatrix();return a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),this!==e){var u=this.getAbsoluteTransform(e).getMatrix();a.transform(u[0],u[1],u[2],u[3],u[4],u[5])}return o.call(this,a,this),a.restore(),this}},{key:"drawHitFromCache",value:function(){var t,e,i,n,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=this._getCanvasCache(),s=this._getCachedSceneCanvas(),h=o.hit,l=h.getContext(),u=h.getWidth(),c=h.getHeight();l.clear(),l.drawImage(s._canvas,0,0,u,c);try{for(i=(e=(t=l.getImageData(0,0,u,c)).data).length,n=G._hexToRgb(this.colorKey),r=0;r<i;r+=4)e[r+3]>a?(e[r]=n.r,e[r+1]=n.g,e[r+2]=n.b,e[r+3]=255):e[r+3]=0;l.putImageData(t,0,0)}catch(t){G.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}},{key:"hasPointerCapture",value:function(t){return _t(t,this)}},{key:"setPointerCapture",value:function(t){kt(t,this)}},{key:"releaseCapture",value:function(t){bt(t)}}]),i}(dt);ne.prototype._fillFunc=function(t){t.fill()},ne.prototype._strokeFunc=function(t){t.stroke()},ne.prototype._fillFuncHit=function(t){t.fill()},ne.prototype._strokeFuncHit=function(t){t.stroke()},ne.prototype._centroid=!1,ne.prototype.nodeType="Shape",p(ne),ne.prototype.eventListeners={},ne.prototype.on.call(ne.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Qt)})),ne.prototype.on.call(ne.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Jt)})),ne.prototype.on.call(ne.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(Zt)})),ne.prototype.on.call(ne.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache($t)})),ne.prototype.on.call(ne.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(te)})),W.addGetterSetter(ne,"stroke",void 0,F()),W.addGetterSetter(ne,"strokeWidth",2,D()),W.addGetterSetter(ne,"fillAfterStrokeEnabled",!1),W.addGetterSetter(ne,"hitStrokeWidth","auto",L()),W.addGetterSetter(ne,"strokeHitEnabled",!0,N()),W.addGetterSetter(ne,"perfectDrawEnabled",!0,N()),W.addGetterSetter(ne,"shadowForStrokeEnabled",!0,N()),W.addGetterSetter(ne,"lineJoin"),W.addGetterSetter(ne,"lineCap"),W.addGetterSetter(ne,"sceneFunc"),W.addGetterSetter(ne,"hitFunc"),W.addGetterSetter(ne,"dash"),W.addGetterSetter(ne,"dashOffset",0,D()),W.addGetterSetter(ne,"shadowColor",void 0,I()),W.addGetterSetter(ne,"shadowBlur",0,D()),W.addGetterSetter(ne,"shadowOpacity",1,D()),W.addComponentsGetterSetter(ne,"shadowOffset",["x","y"]),W.addGetterSetter(ne,"shadowOffsetX",0,D()),W.addGetterSetter(ne,"shadowOffsetY",0,D()),W.addGetterSetter(ne,"fillPatternImage"),W.addGetterSetter(ne,"fill",void 0,F()),W.addGetterSetter(ne,"fillPatternX",0,D()),W.addGetterSetter(ne,"fillPatternY",0,D()),W.addGetterSetter(ne,"fillLinearGradientColorStops"),W.addGetterSetter(ne,"strokeLinearGradientColorStops"),W.addGetterSetter(ne,"fillRadialGradientStartRadius",0),W.addGetterSetter(ne,"fillRadialGradientEndRadius",0),W.addGetterSetter(ne,"fillRadialGradientColorStops"),W.addGetterSetter(ne,"fillPatternRepeat","repeat"),W.addGetterSetter(ne,"fillEnabled",!0),W.addGetterSetter(ne,"strokeEnabled",!0),W.addGetterSetter(ne,"shadowEnabled",!0),W.addGetterSetter(ne,"dashEnabled",!0),W.addGetterSetter(ne,"strokeScaleEnabled",!0),W.addGetterSetter(ne,"fillPriority","color"),W.addComponentsGetterSetter(ne,"fillPatternOffset",["x","y"]),W.addGetterSetter(ne,"fillPatternOffsetX",0,D()),W.addGetterSetter(ne,"fillPatternOffsetY",0,D()),W.addComponentsGetterSetter(ne,"fillPatternScale",["x","y"]),W.addGetterSetter(ne,"fillPatternScaleX",1,D()),W.addGetterSetter(ne,"fillPatternScaleY",1,D()),W.addComponentsGetterSetter(ne,"fillLinearGradientStartPoint",["x","y"]),W.addComponentsGetterSetter(ne,"strokeLinearGradientStartPoint",["x","y"]),W.addGetterSetter(ne,"fillLinearGradientStartPointX",0),W.addGetterSetter(ne,"strokeLinearGradientStartPointX",0),W.addGetterSetter(ne,"fillLinearGradientStartPointY",0),W.addGetterSetter(ne,"strokeLinearGradientStartPointY",0),W.addComponentsGetterSetter(ne,"fillLinearGradientEndPoint",["x","y"]),W.addComponentsGetterSetter(ne,"strokeLinearGradientEndPoint",["x","y"]),W.addGetterSetter(ne,"fillLinearGradientEndPointX",0),W.addGetterSetter(ne,"strokeLinearGradientEndPointX",0),W.addGetterSetter(ne,"fillLinearGradientEndPointY",0),W.addGetterSetter(ne,"strokeLinearGradientEndPointY",0),W.addComponentsGetterSetter(ne,"fillRadialGradientStartPoint",["x","y"]),W.addGetterSetter(ne,"fillRadialGradientStartPointX",0),W.addGetterSetter(ne,"fillRadialGradientStartPointY",0),W.addComponentsGetterSetter(ne,"fillRadialGradientEndPoint",["x","y"]),W.addGetterSetter(ne,"fillRadialGradientEndPointX",0),W.addGetterSetter(ne,"fillRadialGradientEndPointY",0),W.addGetterSetter(ne,"fillPatternRotation",0),W.backCompat(ne,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var re=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],ae=re.length,oe=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).canvas=new V,n.hitCanvas=new K({pixelRatio:1}),n._waitingForDraw=!1,n.on("visibleChange.konva",n._checkVisibility),n._checkVisibility(),n.on("imageSmoothingEnabledChange.konva",n._setSmoothEnabled),n._setSmoothEnabled(),n}return b(i,[{key:"createPNGStream",value:function(){return this.canvas._canvas.createPNGStream()}},{key:"getCanvas",value:function(){return this.canvas}},{key:"getNativeCanvasElement",value:function(){return this.canvas._canvas}},{key:"getHitCanvas",value:function(){return this.hitCanvas}},{key:"getContext",value:function(){return this.getCanvas().getContext()}},{key:"clear",value:function(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}},{key:"setZIndex",value:function(t){s(f(i.prototype),"setZIndex",this).call(this,t);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}},{key:"moveToTop",value:function(){dt.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}},{key:"moveUp",value:function(){if(!dt.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content||(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),0))}},{key:"moveDown",value:function(){if(dt.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}},{key:"moveToBottom",value:function(){if(dt.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}},{key:"getLayer",value:function(){return this}},{key:"remove",value:function(){var t=this.getNativeCanvasElement();return dt.prototype.remove.call(this),t&&t.parentNode&&G._isInDocument(t)&&t.parentNode.removeChild(t),this}},{key:"getStage",value:function(){return this.parent}},{key:"setSize",value:function(t){var e=t.width,i=t.height;return this.canvas.setSize(e,i),this.hitCanvas.setSize(e,i),this._setSmoothEnabled(),this}},{key:"_validateAdd",value:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&G.throw("You may only add groups and shapes to a layer.")}},{key:"_toKonvaCanvas",value:function(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),dt.prototype._toKonvaCanvas.call(this,t)}},{key:"_checkVisibility",value:function(){var t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}},{key:"_setSmoothEnabled",value:function(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}},{key:"getWidth",value:function(){if(this.parent)return this.parent.width()}},{key:"setWidth",value:function(){G.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}},{key:"getHeight",value:function(){if(this.parent)return this.parent.height()}},{key:"setHeight",value:function(){G.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}},{key:"batchDraw",value:function(){var t=this;return this._waitingForDraw||(this._waitingForDraw=!0,G.requestAnimFrame((function(){t.draw(),t._waitingForDraw=!1}))),this}},{key:"getIntersection",value:function(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(var n=0;n<ae;n++){var r=re[n],a=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),o=a.shape;if(o)return o;if(i=!!a.antialiased,!a.antialiased)break}if(!i)return null;e+=1}}},{key:"_getIntersection",value:function(t){var e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){var r=G._rgbToHex(i[0],i[1],i[2]),a=ie["#"+r];return a?{shape:a}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}},{key:"drawScene",value:function(t,e){var i=this.getLayer(),n=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),gt.prototype.drawScene.call(this,n,e),this._fire("draw",{node:this}),this}},{key:"drawHit",value:function(t,e){var i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),gt.prototype.drawHit.call(this,n,e),this}},{key:"enableHitGraph",value:function(){return this.hitGraphEnabled(!0),this}},{key:"disableHitGraph",value:function(){return this.hitGraphEnabled(!1),this}},{key:"setHitGraphEnabled",value:function(t){G.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}},{key:"getHitGraphEnabled",value:function(t){return G.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}},{key:"toggleHitCanvas",value:function(){if(this.parent&&this.parent.content){var t=this.parent;this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}},{key:"destroy",value:function(){return G.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),s(f(i.prototype),"destroy",this).call(this)}}]),i}(gt);oe.prototype.nodeType="Layer",p(oe),W.addGetterSetter(oe,"imageSmoothingEnabled",!0),W.addGetterSetter(oe,"clearBeforeDraw",!0),W.addGetterSetter(oe,"hitGraphEnabled",!0,N());var se=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).listening(!1),G.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.'),n}return b(i)}(oe);se.prototype.nodeType="FastLayer",p(se);var he=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_validateAdd",value:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&G.throw("You may only add groups and shapes to groups.")}}]),i}(gt);he.prototype.nodeType="Group",p(he);var le=a.performance&&a.performance.now?function(){return a.performance.now()}:function(){return(new Date).getTime()},ue=function(){function t(e,i){_(this,t),this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:le(),frameRate:0},this.func=e,this.setLayers(i)}return b(t,[{key:"setLayers",value:function(t){var e;return e=t?t.length>0?t:[t]:[],this.layers=e,this}},{key:"getLayers",value:function(){return this.layers}},{key:"addLayer",value:function(t){var e,i=this.layers,n=i.length;for(e=0;e<n;e++)if(i[e]._id===t._id)return!1;return this.layers.push(t),!0}},{key:"isRunning",value:function(){var e,i=t.animations,n=i.length;for(e=0;e<n;e++)if(i[e].id===this.id)return!0;return!1}},{key:"start",value:function(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=le(),t._addAnimation(this),this}},{key:"stop",value:function(){return t._removeAnimation(this),this}},{key:"_updateFrameObject",value:function(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}}],[{key:"_addAnimation",value:function(t){this.animations.push(t),this._handleAnimation()}},{key:"_removeAnimation",value:function(t){var e,i=t.id,n=this.animations,r=n.length;for(e=0;e<r;e++)if(n[e].id===i){this.animations.splice(e,1);break}}},{key:"_runFrames",value:function(){var t,e,i,n,r,a,o,s,h={},l=this.animations;for(n=0;n<l.length;n++)if(e=(t=l[n]).layers,i=t.func,t._updateFrameObject(le()),a=e.length,!i||!1!==i.call(t,t.frame))for(r=0;r<a;r++)void 0!==(o=e[r])._id&&(h[o._id]=o);for(s in h)h.hasOwnProperty(s)&&h[s].batchDraw()}},{key:"_animationLoop",value:function(){var e=t;e.animations.length?(e._runFrames(),G.requestAnimFrame(e._animationLoop)):e.animRunning=!1}},{key:"_handleAnimation",value:function(){this.animRunning||(this.animRunning=!0,G.requestAnimFrame(this._animationLoop))}}]),t}();ue.animations=[],ue.animIdCounter=0,ue.animRunning=!1;var ce={node:1,duration:1,easing:1,onFinish:1,yoyo:1},de=0,fe=["fill","stroke","shadowColor"],ge=function(){function t(e,i,n,r,a,o,s){_(this,t),this.prop=e,this.propFunc=i,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=a-this.begin,this.pause()}return b(t,[{key:"fire",value:function(t){var e=this[t];e&&e()}},{key:"setTime",value:function(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}},{key:"getTime",value:function(){return this._time}},{key:"setPosition",value:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}},{key:"getPosition",value:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}},{key:"play",value:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}},{key:"reverse",value:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}},{key:"seek",value:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}},{key:"reset",value:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")}},{key:"finish",value:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}},{key:"update",value:function(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}},{key:"onEnterFrame",value:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}},{key:"pause",value:function(){this.state=1,this.fire("onPause")}},{key:"getTimer",value:function(){return(new Date).getTime()}}]),t}(),ve=function(){function t(e){_(this,t);var i,n,r=this,a=e.node,o=a._id,s=e.easing||pe.Linear,h=!!e.yoyo;i=void 0===e.duration?.3:0===e.duration?.001:e.duration,this.node=a,this._id=de++;var l=a.getLayer()||(a instanceof u.Stage?a.getLayers():null);for(n in l||G.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new ue((function(){r.tween.onEnterFrame()}),l),this.tween=new ge(n,(function(t){r._tweenFunc(t)}),s,0,1,1e3*i,h),this._addListeners(),t.attrs[o]||(t.attrs[o]={}),t.attrs[o][this._id]||(t.attrs[o][this._id]={}),t.tweens[o]||(t.tweens[o]={}),e)void 0===ce[n]&&this._addAttr(n,e[n]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}return b(t,[{key:"_addAttr",value:function(e,i){var n,r,a,o,s,h,l,u,c=this.node,d=c._id;if((a=t.tweens[d][e])&&delete t.attrs[d][a][e],n=c.getAttr(e),G._isArray(i))if(r=[],s=Math.max(i.length,n.length),"points"===e&&i.length!==n.length&&(i.length>n.length?(l=n,n=G._prepareArrayForTween(n,i,c.closed())):(h=i,i=G._prepareArrayForTween(i,n,c.closed()))),0===e.indexOf("fill"))for(o=0;o<s;o++)if(o%2==0)r.push(i[o]-n[o]);else{var f=G.colorToRGBA(n[o]);u=G.colorToRGBA(i[o]),n[o]=f,r.push({r:u.r-f.r,g:u.g-f.g,b:u.b-f.b,a:u.a-f.a})}else for(o=0;o<s;o++)r.push(i[o]-n[o]);else-1!==fe.indexOf(e)?(n=G.colorToRGBA(n),r={r:(u=G.colorToRGBA(i)).r-n.r,g:u.g-n.g,b:u.b-n.b,a:u.a-n.a}):r=i-n;t.attrs[d][this._id][e]={start:n,diff:r,end:i,trueEnd:h,trueStart:l},t.tweens[d][e]=this._id}},{key:"_tweenFunc",value:function(e){var i,n,r,a,o,s,h,l,u=this.node,c=t.attrs[u._id][this._id];for(i in c){if(r=(n=c[i]).start,a=n.diff,l=n.end,G._isArray(r))if(o=[],h=Math.max(r.length,l.length),0===i.indexOf("fill"))for(s=0;s<h;s++)s%2==0?o.push((r[s]||0)+a[s]*e):o.push("rgba("+Math.round(r[s].r+a[s].r*e)+","+Math.round(r[s].g+a[s].g*e)+","+Math.round(r[s].b+a[s].b*e)+","+(r[s].a+a[s].a*e)+")");else for(s=0;s<h;s++)o.push((r[s]||0)+a[s]*e);else o=-1!==fe.indexOf(i)?"rgba("+Math.round(r.r+a.r*e)+","+Math.round(r.g+a.g*e)+","+Math.round(r.b+a.b*e)+","+(r.a+a.a*e)+")":r+a*e;u.setAttr(i,o)}}},{key:"_addListeners",value:function(){var e=this;this.tween.onPlay=function(){e.anim.start()},this.tween.onReverse=function(){e.anim.start()},this.tween.onPause=function(){e.anim.stop()},this.tween.onFinish=function(){var i=e.node,n=t.attrs[i._id][e._id];n.points&&n.points.trueEnd&&i.setAttr("points",n.points.trueEnd),e.onFinish&&e.onFinish.call(e)},this.tween.onReset=function(){var i=e.node,n=t.attrs[i._id][e._id];n.points&&n.points.trueStart&&i.points(n.points.trueStart),e.onReset&&e.onReset()},this.tween.onUpdate=function(){e.onUpdate&&e.onUpdate.call(e)}}},{key:"play",value:function(){return this.tween.play(),this}},{key:"reverse",value:function(){return this.tween.reverse(),this}},{key:"reset",value:function(){return this.tween.reset(),this}},{key:"seek",value:function(t){return this.tween.seek(1e3*t),this}},{key:"pause",value:function(){return this.tween.pause(),this}},{key:"finish",value:function(){return this.tween.finish(),this}},{key:"destroy",value:function(){var e,i=this.node._id,n=this._id,r=t.tweens[i];for(e in this.pause(),r)delete t.tweens[i][e];delete t.attrs[i][n]}}]),t}();ve.attrs={},ve.tweens={},dt.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new ve(t).play()};var pe={BackEaseIn:function(t,e,i,n){var r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut:function(t,e,i,n){var r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut:function(t,e,i,n){var r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn:function(t,e,i,n,r,a){var o=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)+e)},ElasticEaseOut:function(t,e,i,n,r,a){var o=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-o)*(2*Math.PI)/a)+i+e)},ElasticEaseInOut:function(t,e,i,n,r,a){var o=0;return 0===t?e:2==(t/=n/2)?e+i:(a||(a=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)*.5+i+e)},BounceEaseOut:function(t,e,i,n){return(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},BounceEaseIn:function(t,e,i,n){return i-pe.BounceEaseOut(n-t,0,i,n)+e},BounceEaseInOut:function(t,e,i,n){return t<n/2?.5*pe.BounceEaseIn(2*t,0,i,n)+e:.5*pe.BounceEaseOut(2*t-n,0,i,n)+.5*i+e},EaseIn:function(t,e,i,n){return i*(t/=n)*t+e},EaseOut:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},EaseInOut:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},StrongEaseIn:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},StrongEaseOut:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},StrongEaseInOut:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},Linear:function(t,e,i,n){return i*t/n+e}},ye=G._assign(u,{Util:G,Transform:k,Node:dt,Container:gt,Stage:Vt,stages:Ut,Layer:oe,FastLayer:se,Group:he,DD:Q,Shape:ne,shapes:ie,Animation:ue,Tween:ve,Easings:pe,Context:j,Canvas:U}),me=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=u.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.outerRadius()}},{key:"getHeight",value:function(){return 2*this.outerRadius()}},{key:"setWidth",value:function(t){this.outerRadius(t/2)}},{key:"setHeight",value:function(t){this.outerRadius(t/2)}},{key:"getSelfRect",value:function(){var t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=u.getAngle(i?360-this.angle():this.angle()),r=Math.cos(Math.min(n,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),o=Math.sin(Math.min(n,Math.PI/2)),s=r*(r>0?t:e),h=a*(a>0?t:e),l=o*(o>0?e:t);return{x:s,y:i?-1*l:h,width:1*e-s,height:l-h}}}]),i}(ne);function _e(t,e,i,n,r,a,o){var s=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(a-n,2)),l=o*s/(s+h),u=o*h/(s+h);return[i-l*(r-t),n-l*(a-e),i+u*(r-t),n+u*(a-e)]}function ke(t,e){var i,n,r=t.length,a=[];for(i=2;i<r-2;i+=2)n=_e(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(n[0])||(a.push(n[0]),a.push(n[1]),a.push(t[i]),a.push(t[i+1]),a.push(n[2]),a.push(n[3]));return a}me.prototype._centroid=!0,me.prototype.className="Arc",me.prototype._attrsAffectingSize=["innerRadius","outerRadius"],p(me),W.addGetterSetter(me,"innerRadius",0,D()),W.addGetterSetter(me,"outerRadius",0,D()),W.addGetterSetter(me,"angle",0,D()),W.addGetterSetter(me,"clockwise",!1,N());var be=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")})),n}return b(i,[{key:"_sceneFunc",value:function(t){var e,i,n,r=this.points(),a=r.length,o=this.tension(),s=this.closed(),h=this.bezier();if(a){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==o&&a>4){for(i=(e=this.getTensionPoints()).length,n=s?0:4,s||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);n<i-2;)t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);s||t.quadraticCurveTo(e[i-2],e[i-1],r[a-2],r[a-1])}else if(h)for(n=2;n<a;)t.bezierCurveTo(r[n++],r[n++],r[n++],r[n++],r[n++],r[n++]);else for(n=2;n<a;n+=2)t.lineTo(r[n],r[n+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}},{key:"getTensionPoints",value:function(){return this._getCache("tensionPoints",this._getTensionPoints)}},{key:"_getTensionPoints",value:function(){return this.closed()?this._getTensionPointsClosed():ke(this.points(),this.tension())}},{key:"_getTensionPointsClosed",value:function(){var t=this.points(),e=t.length,i=this.tension(),n=_e(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),r=_e(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=ke(t,i);return[n[2],n[3]].concat(a).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],n[0],n[1],t[0],t[1]])}},{key:"getWidth",value:function(){return this.getSelfRect().width}},{key:"getHeight",value:function(){return this.getSelfRect().height}},{key:"getSelfRect",value:function(){var t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};for(var e,i,n=(t=0!==this.tension()?[t[0],t[1]].concat(h(this._getTensionPoints()),[t[t.length-2],t[t.length-1]]):this.points())[0],r=t[0],a=t[1],o=t[1],s=0;s<t.length/2;s++)e=t[2*s],i=t[2*s+1],n=Math.min(n,e),r=Math.max(r,e),a=Math.min(a,i),o=Math.max(o,i);return{x:n,y:a,width:r-n,height:o-a}}}]),i}(ne);be.prototype.className="Line",be.prototype._attrsAffectingSize=["points","bezier","tension"],p(be),W.addGetterSetter(be,"closed",!1),W.addGetterSetter(be,"bezier",!1),W.addGetterSetter(be,"tension",0,D()),W.addGetterSetter(be,"points",[],function(){if(u.isUnminified)return function(t,e){var i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(G._isArray(t)?t.forEach((function(t){G._isNumber(t)||G.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):G.warn(R(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());var xe=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Se=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],we=[[1],[1,1],[1,2,1],[1,3,3,1]],Ce=function(t,e,i){var n,r,a;n=i/2,r=0;for(var o=0;o<20;o++)a=n*xe[20][o]+n,r+=Se[20][o]*Ae(t,e,a);return n*r},Pe=function(t,e,i){void 0===i&&(i=1);var n=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],a=2*t[1]-2*t[0],o=2*e[1]-2*e[0],s=4*(n*n+r*r),h=4*(n*a+r*o),l=a*a+o*o;if(0===s)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));var u=h/(2*s),c=i+u,d=l/s-u*u,f=c*c+d>0?Math.sqrt(c*c+d):0,g=u*u+d>0?Math.sqrt(u*u+d):0,v=u+Math.sqrt(u*u+d)!==0?d*Math.log(Math.abs((c+f)/(u+g))):0;return Math.sqrt(s)/2*(c*f-u*g+v)};function Ae(t,e,i){var n=Te(1,i,t),r=Te(1,i,e),a=n*n+r*r;return Math.sqrt(a)}var Te=function t(e,i,n){var r,a,o=n.length-1;if(0===o)return 0;if(0===e){a=0;for(var s=0;s<=o;s++)a+=we[o][s]*Math.pow(1-i,o-s)*Math.pow(i,s)*n[s];return a}r=new Array(o);for(var h=0;h<o;h++)r[h]=o*(n[h+1]-n[h]);return t(e-1,i,r)},Me=function(t,e,i){for(var n=1,r=t/e,a=(t-i(r))/e,o=0;n>.001;){var s=i(r+a),h=Math.abs(t-s)/e;if(h<n)n=h,r+=a;else{var l=i(r-a),u=Math.abs(t-l)/e;u<n?(n=u,r-=a):a/=2}if(++o>500)break}return r},Ge=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).dataArray=[],n.pathLength=0,n._readDataAttribute(),n.on("dataChange.konva",(function(){this._readDataAttribute()})),n}return b(i,[{key:"_readDataAttribute",value:function(){this.dataArray=i.parsePathData(this.data()),this.pathLength=i.getPathLength(this.dataArray)}},{key:"_sceneFunc",value:function(t){var e=this.dataArray;t.beginPath();for(var i=!1,n=0;n<e.length;n++){var r=e[n].command,a=e[n].points;switch(r){case"L":t.lineTo(a[0],a[1]);break;case"M":t.moveTo(a[0],a[1]);break;case"C":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":t.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var o=a[0],s=a[1],h=a[2],l=a[3],u=a[4],c=a[5],d=a[6],f=a[7],g=h>l?h:l,v=h>l?1:h/l,p=h>l?l/h:1;t.translate(o,s),t.rotate(d),t.scale(v,p),t.arc(0,0,g,u,u+c,1-f),t.scale(1/v,1/p),t.rotate(-d),t.translate(-o,-s);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}},{key:"getSelfRect",value:function(){var t=[];this.dataArray.forEach((function(e){if("A"===e.command){var n=e.points[4],r=e.points[5],a=e.points[4]+r,o=Math.PI/180;if(Math.abs(n-a)<o&&(o=Math.abs(n-a)),r<0)for(var s=n-o;s>a;s-=o){var h=i.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],s,0);t.push(h.x,h.y)}else for(var l=n+o;l<a;l+=o){var u=i.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],l,0);t.push(u.x,u.y)}}else if("C"===e.command)for(var c=0;c<=1;c+=.01){var d=i.getPointOnCubicBezier(c,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(d.x,d.y)}else t=t.concat(e.points)}));for(var e,n,r=t[0],a=t[0],o=t[1],s=t[1],h=0;h<t.length/2;h++)e=t[2*h],n=t[2*h+1],isNaN(e)||(r=Math.min(r,e),a=Math.max(a,e)),isNaN(n)||(o=Math.min(o,n),s=Math.max(s,n));return{x:r,y:o,width:a-r,height:s-o}}},{key:"getLength",value:function(){return this.pathLength}},{key:"getPointAtLength",value:function(t){return i.getPointAtLengthOfDataArray(t,this.dataArray)}}],[{key:"getLineLength",value:function(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}},{key:"getPathLength",value:function(t){for(var e=0,i=0;i<t.length;++i)e+=t[i].pathLength;return e}},{key:"getPointAtLengthOfDataArray",value:function(t,e){var n,r=0,a=e.length;if(!a)return null;for(;r<a&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===a)return{x:(n=e[r-1].points.slice(-2))[0],y:n[1]};if(t<.01)return{x:(n=e[r].points.slice(0,2))[0],y:n[1]};var o=e[r],s=o.points;switch(o.command){case"L":return i.getPointOnLine(t,o.start.x,o.start.y,s[0],s[1]);case"C":return i.getPointOnCubicBezier(Me(t,i.getPathLength(e),(function(t){return Ce([o.start.x,s[0],s[2],s[4]],[o.start.y,s[1],s[3],s[5]],t)})),o.start.x,o.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case"Q":return i.getPointOnQuadraticBezier(Me(t,i.getPathLength(e),(function(t){return Pe([o.start.x,s[0],s[2]],[o.start.y,s[1],s[3]],t)})),o.start.x,o.start.y,s[0],s[1],s[2],s[3]);case"A":var h=s[0],l=s[1],u=s[2],c=s[3],d=s[4],f=s[5],g=s[6];return d+=f*t/o.pathLength,i.getPointOnEllipticalArc(h,l,u,c,d,g)}return null}},{key:"getPointOnLine",value:function(t,e,i,n,r,a,o){void 0===a&&(a=e),void 0===o&&(o=i);var s=(r-i)/(n-e+1e-8),h=Math.sqrt(t*t/(1+s*s));n<e&&(h*=-1);var l,u=s*h;if(n===e)l={x:a,y:o+u};else if((o-i)/(a-e+1e-8)===s)l={x:a+h,y:o+u};else{var c,d,f=this.getLineLength(e,i,n,r),g=(a-e)*(n-e)+(o-i)*(r-i);c=e+(g/=f*f)*(n-e),d=i+g*(r-i);var v=this.getLineLength(a,o,c,d),p=Math.sqrt(t*t-v*v);h=Math.sqrt(p*p/(1+s*s)),n<e&&(h*=-1),l={x:c+h,y:d+(u=s*h)}}return l}},{key:"getPointOnCubicBezier",value:function(t,e,i,n,r,a,o,s,h){function l(t){return t*t*t}function u(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*l(t)+a*u(t)+n*c(t)+e*d(t),y:h*l(t)+o*u(t)+r*c(t)+i*d(t)}}},{key:"getPointOnQuadraticBezier",value:function(t,e,i,n,r,a,o){function s(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:a*s(t)+n*h(t)+e*l(t),y:o*s(t)+r*h(t)+i*l(t)}}},{key:"getPointOnEllipticalArc",value:function(t,e,i,n,r,a){var o=Math.cos(a),s=Math.sin(a),h=i*Math.cos(r),l=n*Math.sin(r);return{x:t+(h*o-l*s),y:e+(h*s+l*o)}}},{key:"parsePathData",value:function(t){if(!t)return[];var e=t,i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var n=0;n<i.length;n++)e=e.replace(new RegExp(i[n],"g"),"|"+i[n]);var r,a=e.split("|"),o=[],s=[],h=0,l=0,u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(n=1;n<a.length;n++){var c=a[n],d=c.charAt(0);for(c=c.slice(1),s.length=0;r=u.exec(c);)s.push(r[0]);for(var f=[],g=0,v=s.length;g<v;g++)if("00"!==s[g]){var p=parseFloat(s[g]);isNaN(p)?f.push(0):f.push(p)}else f.push(0,0);for(;f.length>0&&!isNaN(f[0]);){var y,m,_,k,b,x,S,w,C,P,A=null,T=[],M=h,G=l;switch(d){case"l":h+=f.shift(),l+=f.shift(),A="L",T.push(h,l);break;case"L":h=f.shift(),l=f.shift(),T.push(h,l);break;case"m":var R=f.shift(),E=f.shift();if(h+=R,l+=E,A="M",o.length>2&&"z"===o[o.length-1].command)for(var D=o.length-2;D>=0;D--)if("M"===o[D].command){h=o[D].points[0]+R,l=o[D].points[1]+E;break}T.push(h,l),d="l";break;case"M":h=f.shift(),l=f.shift(),A="M",T.push(h,l),d="L";break;case"h":h+=f.shift(),A="L",T.push(h,l);break;case"H":h=f.shift(),A="L",T.push(h,l);break;case"v":l+=f.shift(),A="L",T.push(h,l);break;case"V":l=f.shift(),A="L",T.push(h,l);break;case"C":T.push(f.shift(),f.shift(),f.shift(),f.shift()),h=f.shift(),l=f.shift(),T.push(h,l);break;case"c":T.push(h+f.shift(),l+f.shift(),h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),A="C",T.push(h,l);break;case"S":m=h,_=l,"C"===(y=o[o.length-1]).command&&(m=h+(h-y.points[2]),_=l+(l-y.points[3])),T.push(m,_,f.shift(),f.shift()),h=f.shift(),l=f.shift(),A="C",T.push(h,l);break;case"s":m=h,_=l,"C"===(y=o[o.length-1]).command&&(m=h+(h-y.points[2]),_=l+(l-y.points[3])),T.push(m,_,h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),A="C",T.push(h,l);break;case"Q":T.push(f.shift(),f.shift()),h=f.shift(),l=f.shift(),T.push(h,l);break;case"q":T.push(h+f.shift(),l+f.shift()),h+=f.shift(),l+=f.shift(),A="Q",T.push(h,l);break;case"T":m=h,_=l,"Q"===(y=o[o.length-1]).command&&(m=h+(h-y.points[0]),_=l+(l-y.points[1])),h=f.shift(),l=f.shift(),A="Q",T.push(m,_,h,l);break;case"t":m=h,_=l,"Q"===(y=o[o.length-1]).command&&(m=h+(h-y.points[0]),_=l+(l-y.points[1])),h+=f.shift(),l+=f.shift(),A="Q",T.push(m,_,h,l);break;case"A":k=f.shift(),b=f.shift(),x=f.shift(),S=f.shift(),w=f.shift(),C=h,P=l,h=f.shift(),l=f.shift(),A="A",T=this.convertEndpointToCenterParameterization(C,P,h,l,S,w,k,b,x);break;case"a":k=f.shift(),b=f.shift(),x=f.shift(),S=f.shift(),w=f.shift(),C=h,P=l,h+=f.shift(),l+=f.shift(),A="A",T=this.convertEndpointToCenterParameterization(C,P,h,l,S,w,k,b,x)}o.push({command:A||d,points:T,start:{x:M,y:G},pathLength:this.calcLength(M,G,A||d,T)})}"z"!==d&&"Z"!==d||o.push({command:"z",points:[],start:void 0,pathLength:0})}return o}},{key:"calcLength",value:function(t,e,n,r){var a,o,s,h,l=i;switch(n){case"L":return l.getLineLength(t,e,r[0],r[1]);case"C":return Ce([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return Pe([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":a=0;var u=r[4],c=r[5],d=r[4]+c,f=Math.PI/180;if(Math.abs(u-d)<f&&(f=Math.abs(u-d)),o=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],u,0),c<0)for(h=u-f;h>d;h-=f)s=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],h,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;else for(h=u+f;h<d;h+=f)s=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],h,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;return s=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],d,0),a+l.getLineLength(o.x,o.y,s.x,s.y)}return 0}},{key:"convertEndpointToCenterParameterization",value:function(t,e,i,n,r,a,o,s,h){var l=h*(Math.PI/180),u=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,d=u*u/(o*o)+c*c/(s*s);d>1&&(o*=Math.sqrt(d),s*=Math.sqrt(d));var f=Math.sqrt((o*o*(s*s)-o*o*(c*c)-s*s*(u*u))/(o*o*(c*c)+s*s*(u*u)));r===a&&(f*=-1),isNaN(f)&&(f=0);var g=f*o*c/s,v=f*-s*u/o,p=(t+i)/2+Math.cos(l)*g-Math.sin(l)*v,y=(e+n)/2+Math.sin(l)*g+Math.cos(l)*v,m=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(m(t)*m(e))},k=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},b=k([1,0],[(u-g)/o,(c-v)/s]),x=[(u-g)/o,(c-v)/s],S=[(-1*u-g)/o,(-1*c-v)/s],w=k(x,S);return _(x,S)<=-1&&(w=Math.PI),_(x,S)>=1&&(w=0),0===a&&w>0&&(w-=2*Math.PI),1===a&&w<0&&(w+=2*Math.PI),[p,y,o,s,b,w,l,a]}}]),i}(ne);Ge.prototype.className="Path",Ge.prototype._attrsAffectingSize=["data"],p(Ge),W.addGetterSetter(Ge,"data");var Re=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){s(f(i.prototype),"_sceneFunc",this).call(this,t);var e=2*Math.PI,n=this.points(),r=n,a=0!==this.tension()&&n.length>4;a&&(r=this.getTensionPoints());var o,h,l=this.pointerLength(),u=n.length;if(a){var c=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[u-2],n[u-1]],d=Ge.calcLength(r[r.length-4],r[r.length-3],"C",c),g=Ge.getPointOnQuadraticBezier(Math.min(1,1-l/d),c[0],c[1],c[2],c[3],c[4],c[5]);o=n[u-2]-g.x,h=n[u-1]-g.y}else o=n[u-2]-n[u-4],h=n[u-1]-n[u-3];var v=(Math.atan2(h,o)+e)%e,p=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[u-2],n[u-1]),t.rotate(v),t.moveTo(0,0),t.lineTo(-l,p/2),t.lineTo(-l,-p/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),a?(o=(r[0]+r[2])/2-n[0],h=(r[1]+r[3])/2-n[1]):(o=n[2]-n[0],h=n[3]-n[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-l,p/2),t.lineTo(-l,-p/2),t.closePath(),t.restore(),this.__fillStroke(t))}},{key:"__fillStroke",value:function(t){var e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}},{key:"getSelfRect",value:function(){var t=s(f(i.prototype),"getSelfRect",this).call(this),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}}]),i}(be);Re.prototype.className="Arrow",p(Re),W.addGetterSetter(Re,"pointerLength",10,D()),W.addGetterSetter(Re,"pointerWidth",10,D()),W.addGetterSetter(Re,"pointerAtBeginning",!1),W.addGetterSetter(Re,"pointerAtEnding",!0);var Ee=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.radius()}},{key:"getHeight",value:function(){return 2*this.radius()}},{key:"setWidth",value:function(t){this.radius()!==t/2&&this.radius(t/2)}},{key:"setHeight",value:function(t){this.radius()!==t/2&&this.radius(t/2)}}]),i}(ne);Ee.prototype._centroid=!0,Ee.prototype.className="Circle",Ee.prototype._attrsAffectingSize=["radius"],p(Ee),W.addGetterSetter(Ee,"radius",0,D());var De=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.radiusX()}},{key:"getHeight",value:function(){return 2*this.radiusY()}},{key:"setWidth",value:function(t){this.radiusX(t/2)}},{key:"setHeight",value:function(t){this.radiusY(t/2)}}]),i}(ne);De.prototype.className="Ellipse",De.prototype._centroid=!0,De.prototype._attrsAffectingSize=["radiusX","radiusY"],p(De),W.addComponentsGetterSetter(De,"radius",["x","y"]),W.addGetterSetter(De,"radiusX",0,D()),W.addGetterSetter(De,"radiusY",0,D());var Oe=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).on("imageChange.konva",(function(){n._setImageLoad()})),n._setImageLoad(),n}return b(i,[{key:"_setImageLoad",value:function(){var t=this,e=this.image();e&&e.complete||e&&4===e.readyState||e&&e.addEventListener&&e.addEventListener("load",(function(){t._requestDraw()}))}},{key:"_useBufferCanvas",value:function(){return s(f(i.prototype),"_useBufferCanvas",this).call(this,!0)}},{key:"_sceneFunc",value:function(t){var e,i=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),a=this.attrs.image;if(a){var o=this.attrs.cropWidth,s=this.attrs.cropHeight;e=o&&s?[a,this.cropX(),this.cropY(),o,s,0,0,i,n]:[a,0,0,i,n]}(this.hasFill()||this.hasStroke()||r)&&(t.beginPath(),r?G.drawRoundedRectPath(t,i,n,r):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)),a&&(r&&t.clip(),t.drawImage.apply(t,e))}},{key:"_hitFunc",value:function(t){var e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?G.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}},{key:"getHeight",value:function(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}}],[{key:"fromURL",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=G.createImageElement();r.onload=function(){var t=new i({image:r});e(t)},r.onerror=n,r.crossOrigin="Anonymous",r.src=t}}]),i}(ne);Oe.prototype.className="Image",p(Oe),W.addGetterSetter(Oe,"cornerRadius",0,O(4)),W.addGetterSetter(Oe,"image"),W.addComponentsGetterSetter(Oe,"crop",["x","y","width","height"]),W.addGetterSetter(Oe,"cropX",0,D()),W.addGetterSetter(Oe,"cropY",0,D()),W.addGetterSetter(Oe,"cropWidth",0,D()),W.addGetterSetter(Oe,"cropHeight",0,D());var Le=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Ie="up",Fe="right",Ne="down",Be="left",He=Le.length,We=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).on("add.konva",(function(t){this._addListeners(t.child),this._sync()})),n}return b(i,[{key:"getText",value:function(){return this.find("Text")[0]}},{key:"getTag",value:function(){return this.find("Tag")[0]}},{key:"_addListeners",value:function(t){var e,i=this,n=function(){i._sync()};for(e=0;e<He;e++)t.on(Le[e]+"Change.konva",n)}},{key:"getWidth",value:function(){return this.getText().width()}},{key:"getHeight",value:function(){return this.getText().height()}},{key:"_sync",value:function(){var t,e,i,n,r,a,o,s=this.getText(),h=this.getTag();if(s&&h){switch(t=s.width(),e=s.height(),i=h.pointerDirection(),n=h.pointerWidth(),o=h.pointerHeight(),r=0,a=0,i){case Ie:r=t/2,a=-1*o;break;case Fe:r=t+n,a=e/2;break;case Ne:r=t/2,a=e+o;break;case Be:r=-1*n,a=e/2}h.setAttrs({x:-1*r,y:-1*a,width:t,height:e}),s.setAttrs({x:-1*r,y:-1*a})}}}]),i}(he);We.prototype.className="Label",p(We);var ze=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.width(),i=this.height(),n=this.pointerDirection(),r=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),s=0,h=0,l=0,u=0;"number"==typeof o?s=h=l=u=Math.min(o,e/2,i/2):(s=Math.min(o[0]||0,e/2,i/2),h=Math.min(o[1]||0,e/2,i/2),u=Math.min(o[2]||0,e/2,i/2),l=Math.min(o[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(s,0),n===Ie&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*a),t.lineTo((e+r)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===Fe&&(t.lineTo(e,(i-a)/2),t.lineTo(e+r,i/2),t.lineTo(e,(i+a)/2)),t.lineTo(e,i-u),t.arc(e-u,i-u,u,0,Math.PI/2,!1),n===Ne&&(t.lineTo((e+r)/2,i),t.lineTo(e/2,i+a),t.lineTo((e-r)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===Be&&(t.lineTo(0,(i+a)/2),t.lineTo(-1*r,i/2),t.lineTo(0,(i-a)/2)),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}},{key:"getSelfRect",value:function(){var t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),r=this.pointerDirection(),a=this.width(),o=this.height();return r===Ie?(e-=n,o+=n):r===Ne?o+=n:r===Be?(t-=1.5*i,a+=i):r===Fe&&(a+=1.5*i),{x:t,y:e,width:a,height:o}}}]),i}(ne);ze.prototype.className="Tag",p(ze),W.addGetterSetter(ze,"pointerDirection","none"),W.addGetterSetter(ze,"pointerWidth",0,D()),W.addGetterSetter(ze,"pointerHeight",0,D()),W.addGetterSetter(ze,"cornerRadius",0,O(4));var je=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?G.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}]),i}(ne);je.prototype.className="Rect",p(je),W.addGetterSetter(je,"cornerRadius",0,O(4));var Ye=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}},{key:"_getPoints",value:function(){for(var t=this.attrs.sides,e=this.attrs.radius||0,i=[],n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}},{key:"getSelfRect",value:function(){var t=this._getPoints(),e=t[0].x,i=t[0].y,n=t[0].x,r=t[0].y;return t.forEach((function(t){e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),{x:e,y:n,width:i-e,height:r-n}}},{key:"getWidth",value:function(){return 2*this.radius()}},{key:"getHeight",value:function(){return 2*this.radius()}},{key:"setWidth",value:function(t){this.radius(t/2)}},{key:"setHeight",value:function(t){this.radius(t/2)}}]),i}(ne);Ye.prototype.className="RegularPolygon",Ye.prototype._centroid=!0,Ye.prototype._attrsAffectingSize=["radius"],p(Ye),W.addGetterSetter(Ye,"radius",0,D()),W.addGetterSetter(Ye,"sides",0,D());var Xe=2*Math.PI,qe=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,Xe,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),Xe,0,!0),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.outerRadius()}},{key:"getHeight",value:function(){return 2*this.outerRadius()}},{key:"setWidth",value:function(t){this.outerRadius(t/2)}},{key:"setHeight",value:function(t){this.outerRadius(t/2)}}]),i}(ne);qe.prototype.className="Ring",qe.prototype._centroid=!0,qe.prototype._attrsAffectingSize=["innerRadius","outerRadius"],p(qe),W.addGetterSetter(qe,"innerRadius",0,D()),W.addGetterSetter(qe,"outerRadius",0,D());var Ue=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t))._updated=!0,n.anim=new ue((function(){var t=n._updated;return n._updated=!1,t})),n.on("animationChange.konva",(function(){this.frameIndex(0)})),n.on("frameIndexChange.konva",(function(){this._updated=!0})),n.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})),n}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],a=this.frameOffsets(),o=r[n+0],s=r[n+1],h=r[n+2],l=r[n+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),u)if(a){var c=a[e],d=2*i;t.drawImage(u,o,s,h,l,c[d+0],c[d+1],h,l)}else t.drawImage(u,o,s,h,l,0,0,h,l)}},{key:"_hitFunc",value:function(t){var e=this.animation(),i=this.frameIndex(),n=4*i,r=this.animations()[e],a=this.frameOffsets(),o=r[n+2],s=r[n+3];if(t.beginPath(),a){var h=a[e],l=2*i;t.rect(h[l+0],h[l+1],o,s)}else t.rect(0,0,o,s);t.closePath(),t.fillShape(this)}},{key:"_useBufferCanvas",value:function(){return s(f(i.prototype),"_useBufferCanvas",this).call(this,!0)}},{key:"_setInterval",value:function(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}},{key:"start",value:function(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}}},{key:"stop",value:function(){this.anim.stop(),clearInterval(this.interval)}},{key:"isRunning",value:function(){return this.anim.isRunning()}},{key:"_updateIndex",value:function(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}]),i}(ne);Ue.prototype.className="Sprite",p(Ue),W.addGetterSetter(Ue,"animation"),W.addGetterSetter(Ue,"animations"),W.addGetterSetter(Ue,"frameOffsets"),W.addGetterSetter(Ue,"image"),W.addGetterSetter(Ue,"frameIndex",0,D()),W.addGetterSetter(Ue,"frameRate",17,D()),W.backCompat(Ue,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Ve=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var r=1;r<2*n;r++){var a=r%2==0?i:e,o=a*Math.sin(r*Math.PI/n),s=-1*a*Math.cos(r*Math.PI/n);t.lineTo(o,s)}t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.outerRadius()}},{key:"getHeight",value:function(){return 2*this.outerRadius()}},{key:"setWidth",value:function(t){this.outerRadius(t/2)}},{key:"setHeight",value:function(t){this.outerRadius(t/2)}}]),i}(ne);function Ke(t){return Array.from(t)}Ve.prototype.className="Star",Ve.prototype._centroid=!0,Ve.prototype._attrsAffectingSize=["innerRadius","outerRadius"],p(Ve),W.addGetterSetter(Ve,"numPoints",5,D()),W.addGetterSetter(Ve,"innerRadius",0,D()),W.addGetterSetter(Ve,"outerRadius",0,D());var Qe,Je="auto",Ze="justify",$e="left",ti="middle",ei="normal",ii=" ",ni="none",ri=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],ai=ri.length;function oi(){return Qe||(Qe=G.createCanvasElement().getContext("2d"))}var si=function(t){l(i,t);var e=c(i);function i(t){var n;_(this,i),n=e.call(this,function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),n._partialTextX=0,n._partialTextY=0;for(var r=0;r<ai;r++)n.on(ri[r]+"Change.konva",n._setTextData);return n._setTextData(),n}return b(i,[{key:"_sceneFunc",value:function(t){var e=this.textArr,i=e.length;if(this.text()){var n,r=this.padding(),a=this.fontSize(),o=this.lineHeight()*a,s=this.verticalAlign(),h=0,l=this.align(),u=this.getWidth(),c=this.letterSpacing(),d=this.fill(),f=this.textDecoration(),g=-1!==f.indexOf("underline"),v=-1!==f.indexOf("line-through"),p=0,y=(p=o/2,0),m=0;for(t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",ti),t.setAttr("textAlign",$e),s===ti?h=(this.getHeight()-i*o-2*r)/2:"bottom"===s&&(h=this.getHeight()-i*o-2*r),t.translate(r,h+r),n=0;n<i;n++){y=0,m=0;var _,k,b,x=e[n],S=x.text,w=x.width,C=x.lastInParagraph;if(t.save(),"right"===l?y+=u-w-2*r:"center"===l&&(y+=(u-w-2*r)/2),g){t.save(),t.beginPath(),t.moveTo(y,p+m+Math.round(a/2)),k=0==(_=S.split(" ").length-1),b=l!==Ze||C?w:u-2*r,t.lineTo(y+Math.round(b),p+m+Math.round(a/2)),t.lineWidth=a/15;var P=this._getLinearGradient();t.strokeStyle=P||d,t.stroke(),t.restore()}if(v){t.save(),t.beginPath(),t.moveTo(y,p+m),k=0==(_=S.split(" ").length-1),b=l===Ze&&C&&!k?u-2*r:w,t.lineTo(y+Math.round(b),p+m),t.lineWidth=a/15;var A=this._getLinearGradient();t.strokeStyle=A||d,t.stroke(),t.restore()}if(0!==c||l===Ze){_=S.split(" ").length-1;for(var T=Ke(S),M=0;M<T.length;M++){var G=T[M];" "!==G||C||l!==Ze||(y+=(u-2*r-w)/_),this._partialTextX=y,this._partialTextY=p+m,this._partialText=G,t.fillStrokeShape(this),y+=this.measureSize(G).width+c}}else this._partialTextX=y,this._partialTextY=p+m,this._partialText=S,t.fillStrokeShape(this);t.restore(),i>1&&(p+=o)}}}},{key:"_hitFunc",value:function(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}},{key:"setText",value:function(t){var e=G._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}},{key:"getWidth",value:function(){return this.attrs.width===Je||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}},{key:"getHeight",value:function(){return this.attrs.height===Je||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}},{key:"getTextWidth",value:function(){return this.textWidth}},{key:"getTextHeight",value:function(){return G.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}},{key:"measureSize",value:function(t){var e,i=oi(),n=this.fontSize();return i.save(),i.font=this._getContextFont(),e=i.measureText(t),i.restore(),{width:e.width,height:n}}},{key:"_getContextFont",value:function(){return this.fontStyle()+ii+this.fontVariant()+ii+(this.fontSize()+"px ")+this.fontFamily().split(",").map((function(t){var e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t='"'.concat(t,'"')),t})).join(", ")}},{key:"_addTextLine",value:function(t){this.align()===Ze&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}},{key:"_getTextWidth",value:function(t){var e=this.letterSpacing(),i=t.length;return oi().measureText(t).width+(i?e*(i-1):0)}},{key:"_setTextData",value:function(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,a=this.attrs.height,o=r!==Je&&void 0!==r,s=a!==Je&&void 0!==a,h=this.padding(),l=r-2*h,u=a-2*h,c=0,d=this.wrap(),f="char"!==d&&d!==ni,g=this.ellipsis();this.textArr=[],oi().font=this._getContextFont();for(var v=g?this._getTextWidth("…"):0,p=0,y=t.length;p<y;++p){var m=t[p],_=this._getTextWidth(m);if(o&&_>l)for(;m.length>0;){for(var k=0,b=m.length,x="",S=0;k<b;){var w=k+b>>>1,C=m.slice(0,w+1),P=this._getTextWidth(C)+v;P<=l?(k=w+1,x=C,S=P):b=w}if(!x)break;if(f){var A,T=m[x.length];(A=(T===ii||"-"===T)&&S<=l?x.length:Math.max(x.lastIndexOf(ii),x.lastIndexOf("-"))+1)>0&&(k=A,x=x.slice(0,k),S=this._getTextWidth(x))}if(x=x.trimRight(),this._addTextLine(x),i=Math.max(i,S),c+=n,this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if((m=(m=m.slice(k)).trimLeft()).length>0&&(_=this._getTextWidth(m))<=l){this._addTextLine(m),c+=n,i=Math.max(i,_);break}}else this._addTextLine(m),c+=n,i=Math.max(i,_),this._shouldHandleEllipsis(c)&&p<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&c+n>u)break}this.textHeight=e,this.textWidth=i}},{key:"_shouldHandleEllipsis",value:function(t){var e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==Je&&void 0!==n,a=n-2*this.padding();return!(this.wrap()!==ni)||r&&t+i>a}},{key:"_tryToAddEllipsisToLastLine",value:function(){var t=this.attrs.width,e=t!==Je&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];r&&n&&(e&&(this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…"))}},{key:"getStrokeScaleEnabled",value:function(){return!0}}]),i}(ne);si.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},si.prototype._strokeFunc=function(t){t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},si.prototype.className="Text",si.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],p(si),W.overWriteSetter(si,"width",L()),W.overWriteSetter(si,"height",L()),W.addGetterSetter(si,"fontFamily","Arial"),W.addGetterSetter(si,"fontSize",12,D()),W.addGetterSetter(si,"fontStyle",ei),W.addGetterSetter(si,"fontVariant",ei),W.addGetterSetter(si,"padding",0,D()),W.addGetterSetter(si,"align",$e),W.addGetterSetter(si,"verticalAlign","top"),W.addGetterSetter(si,"lineHeight",1,D()),W.addGetterSetter(si,"wrap","word"),W.addGetterSetter(si,"ellipsis",!1,N()),W.addGetterSetter(si,"letterSpacing",0,D()),W.addGetterSetter(si,"text","",I()),W.addGetterSetter(si,"textDecoration","");var hi="normal";function li(t){t.fillText(this.partialText,0,0)}function ui(t){t.strokeText(this.partialText,0,0)}var ci=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t)).dummyCanvas=G.createCanvasElement(),n.dataArray=[],n._readDataAttribute(),n.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),n.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",n._setTextData),n._setTextData(),n}return b(i,[{key:"_getTextPathLength",value:function(){return Ge.getPathLength(this.dataArray)}},{key:"_getPointAtLength",value:function(t){return this.attrs.data?t-1>this.pathLength?null:Ge.getPointAtLengthOfDataArray(t,this.dataArray):null}},{key:"_readDataAttribute",value:function(){this.dataArray=Ge.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}},{key:"_sceneFunc",value:function(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),i=this.fill(),n=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(var a=0;a<r.length;a++){t.save();var o=r[a].p0;t.translate(o.x,o.y),t.rotate(r[a].rotation),this.partialText=r[a].text,t.fillStrokeShape(this),"underline"===e&&(0===a&&t.moveTo(0,n/2+1),t.lineTo(n,n/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),t.restore()}},{key:"_hitFunc",value:function(t){t.beginPath();var e=this.glyphInfo;if(e.length>=1){var i=e[0].p0;t.moveTo(i.x,i.y)}for(var n=0;n<e.length;n++){var r=e[n].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}},{key:"getTextWidth",value:function(){return this.textWidth}},{key:"getTextHeight",value:function(){return G.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}},{key:"setText",value:function(t){return si.prototype.setText.call(this,t)}},{key:"_getContextFont",value:function(){return si.prototype._getContextFont.call(this)}},{key:"_getTextSize",value:function(t){var e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();var i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt("".concat(this.fontSize()),10)}}},{key:"_setTextData",value:function(){var t=this._getTextSize(this.attrs.text),e=t.width,i=t.height;if(this.textWidth=e,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;var n=this.letterSpacing(),r=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0),s=0;"center"===r&&(s=Math.max(0,this.pathLength/2-o/2)),"right"===r&&(s=Math.max(0,this.pathLength-o));for(var h=Ke(this.text()),l=s,u=0;u<h.length;u++){var c=this._getPointAtLength(l);if(!c)return;var d=this._getTextSize(h[u]).width+n;if(" "===h[u]&&"justify"===r){var f=this.text().split(" ").length-1;d+=(this.pathLength-o)/f}var g=this._getPointAtLength(l+d);if(!g)return;var v=Ge.getLineLength(c.x,c.y,g.x,g.y),p=0;if(a)try{p=a(h[u-1],h[u])*this.fontSize()}catch(t){p=0}c.x+=p,g.x+=p,this.textWidth+=p;var y=Ge.getPointOnLine(p+v/2,c.x,c.y,g.x,g.y),m=Math.atan2(g.y-c.y,g.x-c.x);this.glyphInfo.push({transposeX:y.x,transposeY:y.y,text:h[u],rotation:m,p0:c,p1:g}),l+=d}}},{key:"getSelfRect",value:function(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));for(var e,i,n=t[0]||0,r=t[0]||0,a=t[1]||0,o=t[1]||0,s=0;s<t.length/2;s++)e=t[2*s],i=t[2*s+1],n=Math.min(n,e),r=Math.max(r,e),a=Math.min(a,i),o=Math.max(o,i);var h=this.fontSize();return{x:n-h/2,y:a-h/2,width:r-n+h,height:o-a+h}}},{key:"destroy",value:function(){return G.releaseCanvas(this.dummyCanvas),s(f(i.prototype),"destroy",this).call(this)}}]),i}(ne);ci.prototype._fillFunc=li,ci.prototype._strokeFunc=ui,ci.prototype._fillFuncHit=li,ci.prototype._strokeFuncHit=ui,ci.prototype.className="TextPath",ci.prototype._attrsAffectingSize=["text","fontSize","data"],p(ci),W.addGetterSetter(ci,"data"),W.addGetterSetter(ci,"fontFamily","Arial"),W.addGetterSetter(ci,"fontSize",12,D()),W.addGetterSetter(ci,"fontStyle",hi),W.addGetterSetter(ci,"align","left"),W.addGetterSetter(ci,"letterSpacing",0,D()),W.addGetterSetter(ci,"textBaseline","middle"),W.addGetterSetter(ci,"fontVariant",hi),W.addGetterSetter(ci,"text",""),W.addGetterSetter(ci,"textDecoration",null),W.addGetterSetter(ci,"kerningFunc",null);var di="tr-konva",fi=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((function(t){return t+".".concat(di)})).join(" "),gi="nodesRect",vi=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],pi={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},yi="ontouchstart"in u._global,mi=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function _i(t,e,i){var n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),r=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return Object.assign(Object.assign({},t),{rotation:t.rotation+e,x:n,y:r})}var ki=function(t){l(i,t);var e=c(i);function i(t){var n;return _(this,i),(n=e.call(this,t))._transforming=!1,n._createElements(),n._handleMouseMove=n._handleMouseMove.bind(d(n)),n._handleMouseUp=n._handleMouseUp.bind(d(n)),n.update=n.update.bind(d(n)),n.on(fi,n.update),n.getNode()&&n.update(),n}return b(i,[{key:"attachTo",value:function(t){return this.setNode(t),this}},{key:"setNode",value:function(t){return G.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}},{key:"getNode",value:function(){return this._nodes&&this._nodes[0]}},{key:"_getEventNamespace",value:function(){return di+this._id}},{key:"setNodes",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this._nodes&&this._nodes.length&&this.detach();var i=e.filter((function(e){return!e.isAncestorOf(t)||(G.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)}));return this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((function(e){var i=function(){1===t.nodes().length&&t.useSingleNodeRotation()&&t.rotation(t.nodes()[0].getAbsoluteRotation()),t._resetTransformCache(),t._transforming||t.isDragging()||t.update()},n=e._attrsAffectingSize.map((function(e){return e+"Change."+t._getEventNamespace()})).join(" ");e.on(n,i),e.on(vi.map((function(e){return e+".".concat(t._getEventNamespace())})).join(" "),i),e.on("absoluteTransformChange.".concat(t._getEventNamespace()),i),t._proxyDrag(e)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}},{key:"_proxyDrag",value:function(t){var e,i=this;t.on("dragstart.".concat(this._getEventNamespace()),(function(n){e=t.getAbsolutePosition(),i.isDragging()||t===i.findOne(".back")||i.startDrag(n,!1)})),t.on("dragmove.".concat(this._getEventNamespace()),(function(n){if(e){var r=t.getAbsolutePosition(),a=r.x-e.x,o=r.y-e.y;i.nodes().forEach((function(e){if(e!==t&&!e.isDragging()){var i=e.getAbsolutePosition();e.setAbsolutePosition({x:i.x+a,y:i.y+o}),e.startDrag(n)}})),e=null}}))}},{key:"getNodes",value:function(){return this._nodes||[]}},{key:"getActiveAnchor",value:function(){return this._movingAnchorName}},{key:"detach",value:function(){var t=this;this._nodes&&this._nodes.forEach((function(e){e.off("."+t._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}},{key:"_resetTransformCache",value:function(){this._clearCache(gi),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}},{key:"_getNodeRect",value:function(){return this._getCache(gi,this.__getNodeRect)}},{key:"__getNodeShape",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.rotation(),i=arguments.length>2?arguments[2]:void 0,n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(i),a=t.getAbsolutePosition(i),o=n.x*r.x-t.offsetX()*r.x,s=n.y*r.y-t.offsetY()*r.y,h=(u.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return _i({x:a.x+o*Math.cos(h)+s*Math.sin(-h),y:a.y+s*Math.cos(h)+o*Math.sin(h),width:n.width*r.x,height:n.height*r.y,rotation:h},-u.getAngle(e),{x:0,y:0})}},{key:"__getNodeRect",value:function(){var t=this;if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};var e=[];this.nodes().map((function(i){var n=i.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:t.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],a=i.getAbsoluteTransform();r.forEach((function(t){var i=a.point(t);e.push(i)}))}));var i,n,r,a,o=new k;o.rotate(-u.getAngle(this.rotation())),e.forEach((function(t){var e=o.point(t);void 0===i&&(i=r=e.x,n=a=e.y),i=Math.min(i,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)})),o.invert();var s=o.point({x:i,y:n});return{x:s.x,y:s.y,width:r-i,height:a-n,rotation:u.getAngle(this.rotation())}}},{key:"getX",value:function(){return this._getNodeRect().x}},{key:"getY",value:function(){return this._getNodeRect().y}},{key:"getWidth",value:function(){return this._getNodeRect().width}},{key:"getHeight",value:function(){return this._getNodeRect().height}},{key:"_createElements",value:function(){this._createBack(),mi.forEach(function(t){this._createAnchor(t)}.bind(this)),this._createAnchor("rotater")}},{key:"_createAnchor",value:function(t){var e=this,i=new je({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:yi?10:"auto"}),n=this;i.on("mousedown touchstart",(function(t){n._handleMouseDown(t)})),i.on("dragstart",(function(t){i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(function(t){t.cancelBubble=!0})),i.on("mouseenter",(function(){var n=u.getAngle(e.rotation()),r=function(t,e){if("rotater"===t)return"crosshair";e+=G.degToRad(pi[t]||0);var i=(G.radToDeg(e)%360+360)%360;return G._inRange(i,337.5,360)||G._inRange(i,0,22.5)?"ns-resize":G._inRange(i,22.5,67.5)?"nesw-resize":G._inRange(i,67.5,112.5)?"ew-resize":G._inRange(i,112.5,157.5)?"nwse-resize":G._inRange(i,157.5,202.5)?"ns-resize":G._inRange(i,202.5,247.5)?"nesw-resize":G._inRange(i,247.5,292.5)?"ew-resize":G._inRange(i,292.5,337.5)?"nwse-resize":(G.error("Transformer has unknown angle for cursor detection: "+i),"pointer")}(t,n);i.getStage().content&&(i.getStage().content.style.cursor=r),e._cursorChange=!0})),i.on("mouseout",(function(){i.getStage().content&&(i.getStage().content.style.cursor=""),e._cursorChange=!1})),this.add(i)}},{key:"_createBack",value:function(){var t=this,e=new ne({name:"back",width:0,height:0,draggable:!0,sceneFunc:function(t){var e=this.getParent(),i=e.padding();t.beginPath(),t.rect(-i,-i,this.width()+2*i,this.height()+2*i),t.moveTo(this.width()/2,-i),e.rotateEnabled()&&t.lineTo(this.width()/2,-e.rotateAnchorOffset()*G._sign(this.height())-i),t.fillStrokeShape(this)},hitFunc:function(e,i){if(t.shouldOverdrawWholeArea()){var n=t.padding();e.beginPath(),e.rect(-n,-n,i.width()+2*n,i.height()+2*n),e.fillStrokeShape(i)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",(function(t){t.cancelBubble=!0})),e.on("dragmove",(function(t){t.cancelBubble=!0})),e.on("dragend",(function(t){t.cancelBubble=!0})),this.on("dragmove",(function(e){t.update()}))}},{key:"_handleMouseDown",value:function(t){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,n=e.height,r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/r),this.cos=Math.abs(i/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((function(e){e._fire("transformstart",{evt:t.evt,target:e})}))}},{key:"_handleMouseMove",value:function(t){var e,i,n,r=this.findOne("."+this._movingAnchorName),a=r.getStage();a.setPointersPositions(t);var o=a.getPointerPosition(),s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(h,s,t)),r.setAbsolutePosition(s);var l=r.getAbsolutePosition();if(h.x!==l.x||h.y!==l.y)if("rotater"!==this._movingAnchorName){var c,d=this.shiftBehavior();c="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var f=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(c){var g=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(g.x-r.x(),2)+Math.pow(g.y-r.y(),2));var v=this.findOne(".top-left").x()>g.x?-1:1,p=this.findOne(".top-left").y()>g.y?-1:1;e=n*this.cos*v,i=n*this.sin*p,this.findOne(".top-left").x(g.x-e),this.findOne(".top-left").y(g.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){c&&(g=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()},n=Math.sqrt(Math.pow(r.x()-g.x,2)+Math.pow(g.y-r.y(),2)),v=this.findOne(".top-right").x()<g.x?-1:1,p=this.findOne(".top-right").y()>g.y?-1:1,e=n*this.cos*v,i=n*this.sin*p,this.findOne(".top-right").x(g.x+e),this.findOne(".top-right").y(g.y-i));var y=r.position();this.findOne(".top-left").y(y.y),this.findOne(".bottom-right").x(y.x)}else"middle-left"===this._movingAnchorName?this.findOne(".top-left").x(r.x()):"middle-right"===this._movingAnchorName?this.findOne(".bottom-right").x(r.x()):"bottom-left"===this._movingAnchorName?(c&&(g=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()},n=Math.sqrt(Math.pow(g.x-r.x(),2)+Math.pow(r.y()-g.y,2)),v=g.x<r.x()?-1:1,p=r.y()<g.y?-1:1,e=n*this.cos*v,i=n*this.sin*p,r.x(g.x-e),r.y(g.y+i)),y=r.position(),this.findOne(".top-left").x(y.x),this.findOne(".bottom-right").y(y.y)):"bottom-center"===this._movingAnchorName?this.findOne(".bottom-right").y(r.y()):"bottom-right"===this._movingAnchorName?c&&(g=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()},n=Math.sqrt(Math.pow(r.x()-g.x,2)+Math.pow(r.y()-g.y,2)),v=this.findOne(".bottom-right").x()<g.x?-1:1,p=this.findOne(".bottom-right").y()<g.y?-1:1,e=n*this.cos*v,i=n*this.sin*p,this.findOne(".bottom-right").x(g.x+e),this.findOne(".bottom-right").y(g.y+i)):console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||t.altKey){var m=this.findOne(".top-left"),_=this.findOne(".bottom-right"),k=m.x(),b=m.y(),x=this.getWidth()-_.x(),S=this.getHeight()-_.y();_.move({x:-k,y:-b}),m.move({x,y:S})}var w=this.findOne(".top-left").getAbsolutePosition();e=w.x,i=w.y;var C=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),P=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:C,height:P,rotation:u.getAngle(this.rotation())},t)}else{var A=this._getNodeRect();e=r.x()-A.width/2,i=-r.y()+A.height/2;var T=Math.atan2(-i,e)+Math.PI/2;A.height<0&&(T-=Math.PI);var M=u.getAngle(this.rotation())+T,G=u.getAngle(this.rotationSnapTolerance()),R=function(t,e,i){for(var n=e,r=0;r<t.length;r++){var a=u.getAngle(t[r]),o=Math.abs(a-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<i&&(n=a)}return n}(this.rotationSnaps(),M,G),E=function(t,e){var i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return _i(t,e,i)}(A,R-A.rotation);this._fitNodesInto(E,t)}}},{key:"_handleMouseUp",value:function(t){this._removeEvents(t)}},{key:"getAbsoluteTransform",value:function(){return this.getTransform()}},{key:"_removeEvents",value:function(t){if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var e=this.getNode();this._fire("transformend",{evt:t,target:e}),e&&this._nodes.forEach((function(e){e._fire("transformend",{evt:t,target:e})})),this._movingAnchorName=null}}},{key:"_fitNodesInto",value:function(t,e){var i=this,n=this._getNodeRect();if(G._inRange(t.width,2*-this.padding()-1,1))this.update();else if(G._inRange(t.height,2*-this.padding()-1,1))this.update();else{var r=this.flipEnabled(),a=new k;if(a.rotate(u.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){var o=a.point({x:2*-this.padding(),y:0});if(t.x+=o.x,t.y+=o.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=o.x,this._anchorDragOffset.y-=o.y,!r)return void this.update()}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){var s=a.point({x:2*this.padding(),y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=s.x,this._anchorDragOffset.y-=s.y,t.width+=2*this.padding(),!r)return void this.update()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){var h=a.point({x:0,y:2*-this.padding()});if(t.x+=h.x,t.y+=h.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=h.x,this._anchorDragOffset.y-=h.y,t.height+=2*this.padding(),!r)return void this.update()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){var l=a.point({x:0,y:2*this.padding()});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=l.x,this._anchorDragOffset.y-=l.y,t.height+=2*this.padding(),!r)return void this.update()}if(this.boundBoxFunc()){var c=this.boundBoxFunc()(n,t);c?t=c:G.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}var d=1e7,f=new k;f.translate(n.x,n.y),f.rotate(n.rotation),f.scale(n.width/d,n.height/d);var g=new k;g.translate(t.x,t.y),g.rotate(t.rotation),g.scale(t.width/d,t.height/d);var v=g.multiply(f.invert());this._nodes.forEach((function(t){var n,r=t.getParent().getAbsoluteTransform(),a=t.getTransform().copy();a.translate(t.offsetX(),t.offsetY());var o=new k;o.multiply(r.copy().invert()).multiply(v).multiply(r).multiply(a);var s=o.decompose();t.setAttrs(s),i._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t}),null===(n=t.getLayer())||void 0===n||n.batchDraw()})),this.rotation(G._getRotation(t.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}}},{key:"forceUpdate",value:function(){this._resetTransformCache(),this.update()}},{key:"_batchChangeChild",value:function(t,e){this.findOne(t).setAttrs(e)}},{key:"update",value:function(){var t,e=this,i=this._getNodeRect();this.rotation(G._getRotation(i.rotation));var n=i.width,r=i.height,a=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),h=this.anchorSize();this.find("._anchor").forEach((function(t){t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:e.anchorStroke(),strokeWidth:e.anchorStrokeWidth(),fill:e.anchorFill(),cornerRadius:e.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+s,offsetY:h/2+s,visible:o&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:h/2+s,visible:o&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:h/2-s,offsetY:h/2+s,visible:o&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+s,visible:o&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:h/2-s,visible:o&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+s,offsetY:h/2-s,visible:o&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:h/2-s,visible:o&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:h/2-s,offsetY:h/2-s,visible:o&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*G._sign(r)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}},{key:"isTransforming",value:function(){return this._transforming}},{key:"stopTransform",value:function(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}},{key:"destroy",value:function(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),he.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}},{key:"toObject",value:function(){return dt.prototype.toObject.call(this)}},{key:"clone",value:function(t){return dt.prototype.clone.call(this,t)}},{key:"getClientRect",value:function(){return this.nodes().length>0?s(f(i.prototype),"getClientRect",this).call(this):{x:0,y:0,width:0,height:0}}}]),i}(he);ki.prototype.className="Transformer",p(ki),W.addGetterSetter(ki,"enabledAnchors",mi,(function(t){return t instanceof Array||G.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===mi.indexOf(t)&&G.warn("Unknown anchor name: "+t+". Available names are: "+mi.join(", "))})),t||[]})),W.addGetterSetter(ki,"flipEnabled",!0,N()),W.addGetterSetter(ki,"resizeEnabled",!0),W.addGetterSetter(ki,"anchorSize",10,D()),W.addGetterSetter(ki,"rotateEnabled",!0),W.addGetterSetter(ki,"rotationSnaps",[]),W.addGetterSetter(ki,"rotateAnchorOffset",50,D()),W.addGetterSetter(ki,"rotationSnapTolerance",5,D()),W.addGetterSetter(ki,"borderEnabled",!0),W.addGetterSetter(ki,"anchorStroke","rgb(0, 161, 255)"),W.addGetterSetter(ki,"anchorStrokeWidth",1,D()),W.addGetterSetter(ki,"anchorFill","white"),W.addGetterSetter(ki,"anchorCornerRadius",0,D()),W.addGetterSetter(ki,"borderStroke","rgb(0, 161, 255)"),W.addGetterSetter(ki,"borderStrokeWidth",1,D()),W.addGetterSetter(ki,"borderDash"),W.addGetterSetter(ki,"keepRatio",!0),W.addGetterSetter(ki,"shiftBehavior","default"),W.addGetterSetter(ki,"centeredScaling",!1),W.addGetterSetter(ki,"ignoreStroke",!1),W.addGetterSetter(ki,"padding",0,D()),W.addGetterSetter(ki,"node"),W.addGetterSetter(ki,"nodes"),W.addGetterSetter(ki,"boundBoxFunc"),W.addGetterSetter(ki,"anchorDragBoundFunc"),W.addGetterSetter(ki,"shouldOverdrawWholeArea",!1),W.addGetterSetter(ki,"useSingleNodeRotation",!0),W.backCompat(ki,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var bi=function(t){l(i,t);var e=c(i);function i(){return _(this,i),e.apply(this,arguments)}return b(i,[{key:"_sceneFunc",value:function(t){t.beginPath(),t.arc(0,0,this.radius(),0,u.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}},{key:"getWidth",value:function(){return 2*this.radius()}},{key:"getHeight",value:function(){return 2*this.radius()}},{key:"setWidth",value:function(t){this.radius(t/2)}},{key:"setHeight",value:function(t){this.radius(t/2)}}]),i}(ne);function xi(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}bi.prototype.className="Wedge",bi.prototype._centroid=!0,bi.prototype._attrsAffectingSize=["radius"],p(bi),W.addGetterSetter(bi,"radius",0,D()),W.addGetterSetter(bi,"angle",0,D()),W.addGetterSetter(bi,"clockwise",!1),W.backCompat(bi,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Si=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],wi=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Ci(t,e,i,n,r){var a=i-e,o=r-n;return 0===a?n+o/2:0===o?n:o*((t-e)/a)+n}function Pi(t,e,i){var n=4*(i*t.width+e),r=[];return r.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),r}function Ai(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return W.addGetterSetter(dt,"blurRadius",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"brightness",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"contrast",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"embossStrength",.5,D(),W.afterSetFilter),W.addGetterSetter(dt,"embossWhiteLevel",.5,D(),W.afterSetFilter),W.addGetterSetter(dt,"embossDirection","top-left",null,W.afterSetFilter),W.addGetterSetter(dt,"embossBlend",!1,null,W.afterSetFilter),W.addGetterSetter(dt,"enhance",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"hue",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"saturation",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"luminance",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"hue",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"saturation",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"value",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"kaleidoscopePower",2,D(),W.afterSetFilter),W.addGetterSetter(dt,"kaleidoscopeAngle",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"threshold",0,D(),W.afterSetFilter),W.addGetterSetter(dt,"noise",.2,D(),W.afterSetFilter),W.addGetterSetter(dt,"pixelSize",8,D(),W.afterSetFilter),W.addGetterSetter(dt,"levels",.5,D(),W.afterSetFilter),W.addGetterSetter(dt,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),W.addGetterSetter(dt,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),W.addGetterSetter(dt,"blue",0,E,W.afterSetFilter),W.addGetterSetter(dt,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),W.addGetterSetter(dt,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),W.addGetterSetter(dt,"blue",0,E,W.afterSetFilter),W.addGetterSetter(dt,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),W.addGetterSetter(dt,"threshold",.5,D(),W.afterSetFilter),ye.Util._assign(ye,{Arc:me,Arrow:Re,Circle:Ee,Ellipse:De,Image:Oe,Label:We,Tag:ze,Line:be,Path:Ge,Rect:je,RegularPolygon:Ye,Ring:qe,Sprite:Ue,Star:Ve,Text:si,TextPath:ci,Transformer:ki,Wedge:bi,Filters:{Blur:function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,n,r,a,o,s,h,l,u,c,d,f,g,v,p,y,m,_,k,b,x,S,w,C,P=t.data,A=t.width,T=t.height,M=e+e+1,G=A-1,R=T-1,E=e+1,D=E*(E+1)/2,O=new xi,L=null,I=O,F=null,N=null,B=Si[e],H=wi[e];for(r=1;r<M;r++)I=I.next=new xi,r===E&&(L=I);for(I.next=O,h=s=0,n=0;n<T;n++){for(y=m=_=k=l=u=c=d=0,f=E*(b=P[s]),g=E*(x=P[s+1]),v=E*(S=P[s+2]),p=E*(w=P[s+3]),l+=D*b,u+=D*x,c+=D*S,d+=D*w,I=O,r=0;r<E;r++)I.r=b,I.g=x,I.b=S,I.a=w,I=I.next;for(r=1;r<E;r++)a=s+((G<r?G:r)<<2),l+=(I.r=b=P[a])*(C=E-r),u+=(I.g=x=P[a+1])*C,c+=(I.b=S=P[a+2])*C,d+=(I.a=w=P[a+3])*C,y+=b,m+=x,_+=S,k+=w,I=I.next;for(F=O,N=L,i=0;i<A;i++)P[s+3]=w=d*B>>H,0!==w?(w=255/w,P[s]=(l*B>>H)*w,P[s+1]=(u*B>>H)*w,P[s+2]=(c*B>>H)*w):P[s]=P[s+1]=P[s+2]=0,l-=f,u-=g,c-=v,d-=p,f-=F.r,g-=F.g,v-=F.b,p-=F.a,a=h+((a=i+e+1)<G?a:G)<<2,l+=y+=F.r=P[a],u+=m+=F.g=P[a+1],c+=_+=F.b=P[a+2],d+=k+=F.a=P[a+3],F=F.next,f+=b=N.r,g+=x=N.g,v+=S=N.b,p+=w=N.a,y-=b,m-=x,_-=S,k-=w,N=N.next,s+=4;h+=A}for(i=0;i<A;i++){for(m=_=k=y=u=c=d=l=0,f=E*(b=P[s=i<<2]),g=E*(x=P[s+1]),v=E*(S=P[s+2]),p=E*(w=P[s+3]),l+=D*b,u+=D*x,c+=D*S,d+=D*w,I=O,r=0;r<E;r++)I.r=b,I.g=x,I.b=S,I.a=w,I=I.next;for(o=A,r=1;r<=e;r++)s=o+i<<2,l+=(I.r=b=P[s])*(C=E-r),u+=(I.g=x=P[s+1])*C,c+=(I.b=S=P[s+2])*C,d+=(I.a=w=P[s+3])*C,y+=b,m+=x,_+=S,k+=w,I=I.next,r<R&&(o+=A);for(s=i,F=O,N=L,n=0;n<T;n++)P[3+(a=s<<2)]=w=d*B>>H,w>0?(w=255/w,P[a]=(l*B>>H)*w,P[a+1]=(u*B>>H)*w,P[a+2]=(c*B>>H)*w):P[a]=P[a+1]=P[a+2]=0,l-=f,u-=g,c-=v,d-=p,f-=F.r,g-=F.g,v-=F.b,p-=F.a,a=i+((a=n+E)<R?a:R)*A<<2,l+=y+=F.r=P[a],u+=m+=F.g=P[a+1],c+=_+=F.b=P[a+2],d+=k+=F.a=P[a+3],F=F.next,f+=b=N.r,g+=x=N.g,v+=S=N.b,p+=w=N.a,y-=b,m-=x,_-=S,k-=w,N=N.next,s+=A}}(t,e)},Brighten:function(t){var e,i=255*this.brightness(),n=t.data,r=n.length;for(e=0;e<r;e+=4)n[e]+=i,n[e+1]+=i,n[e+2]+=i},Contrast:function(t){var e,i=Math.pow((this.contrast()+100)/100,2),n=t.data,r=n.length,a=150,o=150,s=150;for(e=0;e<r;e+=4)a=n[e],o=n[e+1],s=n[e+2],a/=255,a-=.5,a*=i,a+=.5,o/=255,o-=.5,o*=i,o+=.5,s/=255,s-=.5,s*=i,s+=.5,a=(a*=255)<0?0:a>255?255:a,o=(o*=255)<0?0:o>255?255:o,s=(s*=255)<0?0:s>255?255:s,n[e]=a,n[e+1]=o,n[e+2]=s},Emboss:function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),n=this.embossDirection(),r=this.embossBlend(),a=0,o=0,s=t.data,h=t.width,l=t.height,u=4*h,c=l;switch(n){case"top-left":a=-1,o=-1;break;case"top":a=-1,o=0;break;case"top-right":a=-1,o=1;break;case"right":a=0,o=1;break;case"bottom-right":a=1,o=1;break;case"bottom":a=1,o=0;break;case"bottom-left":a=1,o=-1;break;case"left":a=0,o=-1;break;default:G.error("Unknown emboss direction: "+n)}do{var d=(c-1)*u,f=a;c+f<1&&(f=0),c+f>l&&(f=0);var g=(c-1+f)*h*4,v=h;do{var p=d+4*(v-1),y=o;v+y<1&&(y=0),v+y>h&&(y=0);var m=g+4*(v-1+y),_=s[p]-s[m],k=s[p+1]-s[m+1],b=s[p+2]-s[m+2],x=_,S=x>0?x:-x;if((k>0?k:-k)>S&&(x=k),(b>0?b:-b)>S&&(x=b),x*=e,r){var w=s[p]+x,C=s[p+1]+x,P=s[p+2]+x;s[p]=w>255?255:w<0?0:w,s[p+1]=C>255?255:C<0?0:C,s[p+2]=P>255?255:P<0?0:P}else{var A=i-x;A<0?A=0:A>255&&(A=255),s[p]=s[p+1]=s[p+2]=A}}while(--v)}while(--c)},Enhance:function(t){var e,i,n,r,a=t.data,o=a.length,s=a[0],h=s,l=a[1],u=l,c=a[2],d=c,f=this.enhance();if(0!==f){for(r=0;r<o;r+=4)(e=a[r+0])<s?s=e:e>h&&(h=e),(i=a[r+1])<l?l=i:i>u&&(u=i),(n=a[r+2])<c?c=n:n>d&&(d=n);var g,v,p,y,m,_,k,b,x;for(h===s&&(h=255,s=0),u===l&&(u=255,l=0),d===c&&(d=255,c=0),f>0?(v=h+f*(255-h),p=s-f*(s-0),m=u+f*(255-u),_=l-f*(l-0),b=d+f*(255-d),x=c-f*(c-0)):(v=h+f*(h-(g=.5*(h+s))),p=s+f*(s-g),m=u+f*(u-(y=.5*(u+l))),_=l+f*(l-y),b=d+f*(d-(k=.5*(d+c))),x=c+f*(c-k)),r=0;r<o;r+=4)a[r+0]=Ci(a[r+0],s,h,p,v),a[r+1]=Ci(a[r+1],l,u,_,m),a[r+2]=Ci(a[r+2],c,d,x,b)}},Grayscale:function(t){var e,i,n=t.data,r=n.length;for(e=0;e<r;e+=4)i=.34*n[e]+.5*n[e+1]+.16*n[e+2],n[e]=i,n[e+1]=i,n[e+2]=i},HSL:function(t){var e,i,n,r,a,o=t.data,s=o.length,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,u=127*this.luminance(),c=1*h*Math.cos(l*Math.PI/180),d=1*h*Math.sin(l*Math.PI/180),f=.299+.701*c+.167*d,g=.587-.587*c+.33*d,v=.114-.114*c-.497*d,p=.299-.299*c-.328*d,y=.587+.413*c+.035*d,m=.114-.114*c+.293*d,_=.299-.3*c+1.25*d,k=.587-.586*c-1.05*d,b=.114+.886*c-.2*d;for(e=0;e<s;e+=4)i=o[e+0],n=o[e+1],r=o[e+2],a=o[e+3],o[e+0]=f*i+g*n+v*r+u,o[e+1]=p*i+y*n+m*r+u,o[e+2]=_*i+k*n+b*r+u,o[e+3]=a},HSV:function(t){var e,i,n,r,a,o=t.data,s=o.length,h=Math.pow(2,this.value()),l=Math.pow(2,this.saturation()),u=Math.abs(this.hue()+360)%360,c=h*l*Math.cos(u*Math.PI/180),d=h*l*Math.sin(u*Math.PI/180),f=.299*h+.701*c+.167*d,g=.587*h-.587*c+.33*d,v=.114*h-.114*c-.497*d,p=.299*h-.299*c-.328*d,y=.587*h+.413*c+.035*d,m=.114*h-.114*c+.293*d,_=.299*h-.3*c+1.25*d,k=.587*h-.586*c-1.05*d,b=.114*h+.886*c-.2*d;for(e=0;e<s;e+=4)i=o[e+0],n=o[e+1],r=o[e+2],a=o[e+3],o[e+0]=f*i+g*n+v*r,o[e+1]=p*i+y*n+m*r,o[e+2]=_*i+k*n+b*r,o[e+3]=a},Invert:function(t){var e,i=t.data,n=i.length;for(e=0;e<n;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]},Kaleidoscope:function(t){var e,i,n,r,a,o,s,h,l,u=t.width,c=t.height,d=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(u*(f%360)/360);if(!(d<1)){var v=G.createCanvasElement();v.width=u,v.height=c;var p=v.getContext("2d").getImageData(0,0,u,c);G.releaseCanvas(v),function(t,e,i){var n,r,a,o,s=t.data,h=e.data,l=t.width,u=t.height,c=i.polarCenterX||l/2,d=i.polarCenterY||u/2,f=0,g=0,v=0,p=0,y=Math.sqrt(c*c+d*d);r=l-c,a=u-d,y=(o=Math.sqrt(r*r+a*a))>y?o:y;var m,_,k,b,x=u,S=l,w=360/S*Math.PI/180;for(_=0;_<S;_+=1)for(k=Math.sin(_*w),b=Math.cos(_*w),m=0;m<x;m+=1)r=Math.floor(c+y*m/x*b),f=s[0+(n=4*((a=Math.floor(d+y*m/x*k))*l+r))],g=s[n+1],v=s[n+2],p=s[n+3],h[0+(n=4*(_+m*l))]=f,h[n+1]=g,h[n+2]=v,h[n+3]=p}(t,p,{polarCenterX:u/2,polarCenterY:c/2});for(var y=u/Math.pow(2,d);y<=8;)y*=2,d-=1;var m=y=Math.ceil(y),_=0,k=m,b=1;for(g+y>u&&(_=m,k=0,b=-1),i=0;i<c;i+=1)for(e=_;e!==k;e+=b)h=4*(u*i+Math.round(e+g)%u),r=p.data[h+0],a=p.data[h+1],o=p.data[h+2],s=p.data[h+3],l=4*(u*i+e),p.data[l+0]=r,p.data[l+1]=a,p.data[l+2]=o,p.data[l+3]=s;for(i=0;i<c;i+=1)for(m=Math.floor(y),n=0;n<d;n+=1){for(e=0;e<m+1;e+=1)h=4*(u*i+e),r=p.data[h+0],a=p.data[h+1],o=p.data[h+2],s=p.data[h+3],l=4*(u*i+2*m-e-1),p.data[l+0]=r,p.data[l+1]=a,p.data[l+2]=o,p.data[l+3]=s;m*=2}!function(t,e,i){var n,r,a,o,s,h,l=t.data,u=e.data,c=t.width,d=t.height,f=i.polarCenterX||c/2,g=i.polarCenterY||d/2,v=0,p=0,y=0,m=0,_=Math.sqrt(f*f+g*g);r=c-f,a=d-g,_=(h=Math.sqrt(r*r+a*a))>_?h:_;var k,b,x,S=d,w=c,C=i.polarRotation||0;for(r=0;r<c;r+=1)for(a=0;a<d;a+=1)o=r-f,s=a-g,k=Math.sqrt(o*o+s*s)*S/_,b=(b=(180*Math.atan2(s,o)/Math.PI+360+C)%360)*w/360,x=Math.floor(b),v=l[0+(n=4*(Math.floor(k)*c+x))],p=l[n+1],y=l[n+2],m=l[n+3],u[0+(n=4*(a*c+r))]=v,u[n+1]=p,u[n+2]=y,u[n+3]=m}(p,t,{polarRotation:0})}},Mask:function(t){var e=function(t,e){var i=Pi(t,0,0),n=Pi(t,t.width-1,0),r=Pi(t,0,t.height-1),a=Pi(t,t.width-1,t.height-1),o=e||10;if(Ai(i,n)<o&&Ai(n,a)<o&&Ai(a,r)<o&&Ai(r,i)<o){for(var s=function(t){for(var e=[0,0,0],i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,a,r]),h=[],l=0;l<t.width*t.height;l++){var u=Ai(s,[t.data[4*l],t.data[4*l+1],t.data[4*l+2]]);h[l]=u<o?0:255}return h}}(t,this.threshold());return e&&function(t,e){for(var i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e=function(t,e,i){for(var n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),o=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var l=s*e+h,u=0,c=0;c<r;c++)for(var d=0;d<r;d++){var f=s+c-a,g=h+d-a;if(f>=0&&f<i&&g>=0&&g<e){var v=n[c*r+d];u+=t[f*e+g]*v}}o[l]=u}return o}(e=function(t,e,i){for(var n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),o=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var l=s*e+h,u=0,c=0;c<r;c++)for(var d=0;d<r;d++){var f=s+c-a,g=h+d-a;if(f>=0&&f<i&&g>=0&&g<e){var v=n[c*r+d];u+=t[f*e+g]*v}}o[l]=u>=1020?255:0}return o}(e=function(t,e,i){for(var n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),a=Math.floor(r/2),o=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var l=s*e+h,u=0,c=0;c<r;c++)for(var d=0;d<r;d++){var f=s+c-a,g=h+d-a;if(f>=0&&f<i&&g>=0&&g<e){var v=n[c*r+d];u+=t[f*e+g]*v}}o[l]=2040===u?255:0}return o}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},Noise:function(t){var e,i=255*this.noise(),n=t.data,r=n.length,a=i/2;for(e=0;e<r;e+=4)n[e+0]+=a-2*a*Math.random(),n[e+1]+=a-2*a*Math.random(),n[e+2]+=a-2*a*Math.random()},Pixelate:function(t){var e,i,n,r,a,o,s,h,l,u,c,d,f,g,v=Math.ceil(this.pixelSize()),p=t.width,y=t.height,m=Math.ceil(p/v),_=Math.ceil(y/v),k=t.data;if(v<=0)G.error("pixelSize value can not be <= 0");else for(d=0;d<m;d+=1)for(f=0;f<_;f+=1){for(r=0,a=0,o=0,s=0,l=(h=d*v)+v,c=(u=f*v)+v,g=0,e=h;e<l;e+=1)if(!(e>=p))for(i=u;i<c;i+=1)i>=y||(r+=k[0+(n=4*(p*i+e))],a+=k[n+1],o+=k[n+2],s+=k[n+3],g+=1);for(r/=g,a/=g,o/=g,s/=g,e=h;e<l;e+=1)if(!(e>=p))for(i=u;i<c;i+=1)i>=y||(k[0+(n=4*(p*i+e))]=r,k[n+1]=a,k[n+2]=o,k[n+3]=s)}},Posterize:function(t){var e,i=Math.round(254*this.levels())+1,n=t.data,r=n.length,a=255/i;for(e=0;e<r;e+=1)n[e]=Math.floor(n[e]/a)*a},RGB:function(t){var e,i,n=t.data,r=n.length,a=this.red(),o=this.green(),s=this.blue();for(e=0;e<r;e+=4)i=(.34*n[e]+.5*n[e+1]+.16*n[e+2])/255,n[e]=i*a,n[e+1]=i*o,n[e+2]=i*s,n[e+3]=n[e+3]},RGBA:function(t){var e,i,n=t.data,r=n.length,a=this.red(),o=this.green(),s=this.blue(),h=this.alpha();for(e=0;e<r;e+=4)i=1-h,n[e]=a*h+n[e]*i,n[e+1]=o*h+n[e+1]*i,n[e+2]=s*h+n[e+2]*i},Sepia:function(t){var e,i,n,r,a=t.data,o=a.length;for(e=0;e<o;e+=4)i=a[e+0],n=a[e+1],r=a[e+2],a[e+0]=Math.min(255,.393*i+.769*n+.189*r),a[e+1]=Math.min(255,.349*i+.686*n+.168*r),a[e+2]=Math.min(255,.272*i+.534*n+.131*r)},Solarize:function(t){var e=t.data,i=t.width,n=4*i,r=t.height;do{var a=(r-1)*n,o=i;do{var s=a+4*(o-1),h=e[s],l=e[s+1],u=e[s+2];h>127&&(h=255-h),l>127&&(l=255-l),u>127&&(u=255-u),e[s]=h,e[s+1]=l,e[s+2]=u}while(--o)}while(--r)},Threshold:function(t){var e,i=255*this.threshold(),n=t.data,r=n.length;for(e=0;e<r;e+=1)n[e]=n[e]<i?0:255}}})},"object"===S(e)?t.exports=a():void 0===(r="function"==typeof(n=a)?n.call(e,i,e,t):n)||(t.exports=r)}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,i),a.exports}return i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i(215)})()));