mumuki-puzzle-runner 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ var headbreaker=function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=34)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(3),n=i(2);e.Factory={addGetterSetter:function(t,e,i,r,n){this.addGetter(t,e,i),this.addSetter(t,e,r,n),this.addOverloadedGetterSetter(t,e)},addGetter:function(t,e,i){var n="get"+r.Util._capitalize(e);t.prototype[n]=t.prototype[n]||function(){var t=this.attrs[e];return void 0===t?i:t}},addSetter:function(t,i,n,o){var a="set"+r.Util._capitalize(i);t.prototype[a]||e.Factory.overWriteSetter(t,i,n,o)},overWriteSetter:function(t,e,i,n){var o="set"+r.Util._capitalize(e);t.prototype[o]=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,o,a){var s,h,c=i.length,l=r.Util._capitalize,u="get"+l(e),d="set"+l(e);t.prototype[u]=function(){var t={};for(s=0;s<c;s++)t[h=i[s]]=this.getAttr(e+l(h));return t};var p=n.getComponentValidator(i);t.prototype[d]=function(t){var i,r=this.attrs[e];for(i in o&&(t=o.call(this,t)),p&&p.call(this,t,e),t)t.hasOwnProperty(i)&&this._setAttr(e+l(i),t[i]);return this._fireChangeEvent(e,r,t),a&&a.call(this),this},this.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter:function(t,e){var i=r.Util._capitalize(e),n="set"+i,o="get"+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter:function(t,e,i,n){r.Util.error("Adding deprecated "+e);var o="get"+r.Util._capitalize(e),a=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[o]=function(){r.Util.error(a);var t=this.attrs[e];return void 0===t?i:t},this.addSetter(t,e,n,(function(){r.Util.error(a)})),this.addOverloadedGetterSetter(t,e)},backCompat:function(t,e){r.Util.each(e,(function(e,i){var n=t.prototype[i],o="get"+r.Util._capitalize(e),a="set"+r.Util._capitalize(e);function s(){n.apply(this,arguments),r.Util.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=s,t.prototype[o]=s,t.prototype[a]=s}))},afterSetFilter:function(){this._filterUpToDate=!1}}},function(t,e,i){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});var i=Math.PI/180;var r=function(t){var e=t.indexOf("msie ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}var r=t.indexOf("edge/");return r>0&&parseInt(t.substring(r+5,t.indexOf(".",r)),10)};e._parseUA=function(t){var e=t.toLowerCase(),i=/(chrome)[ /]([\w.]+)/.exec(e)||/(webkit)[ /]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ /]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[],n=!!t.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i),o=!!t.match(/IEMobile/i);return{browser:i[1]||"",version:i[2]||"0",isIE:r(e),mobile:n,ieMobile:o}},e.glob=void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},e.Konva={_global:e.glob,version:"6.0.0",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 e.Konva.angleDeg?t*i:t},enableTrace:!1,_pointerEventsEnabled:!1,hitOnDragEnabled:!1,captureTouchEventsEnabled:!1,listenClickTap:!1,inDblClickWindow:!1,pixelRatio:void 0,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:function(){return e.Konva.DD.isDragging},isDragReady:function(){return!!e.Konva.DD.node},UA:e._parseUA(e.glob.navigator&&e.glob.navigator.userAgent||""),document:e.glob.document,_injectGlobal:function(t){e.glob.Konva=t},_parseUA:e._parseUA},e._NODES_REGISTRY={},e._registerNode=function(t){e._NODES_REGISTRY[t.prototype.getClassName()]=t,e.Konva[t.prototype.getClassName()]=t}}).call(this,i(43))},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=i(3);function o(t){return n.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||n.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}e.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},e.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},e.getNumberValidator=function(){if(r.Konva.isUnminified)return function(t,e){return n.Util._isNumber(t)||n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},e.getNumberOrAutoValidator=function(){if(r.Konva.isUnminified)return function(t,e){return n.Util._isNumber(t)||"auto"===t||n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},e.getStringValidator=function(){if(r.Konva.isUnminified)return function(t,e){return n.Util._isString(t)||n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},e.getFunctionValidator=function(){if(r.Konva.isUnminified)return function(t,e){return n.Util._isFunction(t)||n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},e.getNumberArrayValidator=function(){if(r.Konva.isUnminified)return function(t,e){return n.Util._isArray(t)?t.forEach((function(t){n.Util._isNumber(t)||n.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.'),t}},e.getBooleanValidator=function(){if(r.Konva.isUnminified)return function(t,e){return!0===t||!1===t||n.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},e.getComponentValidator=function(t){if(r.Konva.isUnminified)return function(e,i){return n.Util.isObject(e)||n.Util.warn(o(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=function(){function t(){}return t.toCollection=function(e){var i,r=new t,n=e.length;for(i=0;i<n;i++)r.push(e[i]);return r},t._mapMethod=function(e){t.prototype[e]=function(){var t,i=this.length,r=[].slice.call(arguments);for(t=0;t<i;t++)this[t][e].apply(this[t],r);return this}},t.mapMethods=function(e){var i=e.prototype;for(var r in i)t._mapMethod(r)},t}();e.Collection=n,n.prototype=[],n.prototype.each=function(t){for(var e=0;e<this.length;e++)t(this[e],e)},n.prototype.toArray=function(){var t,e=[],i=this.length;for(t=0;t<i;t++)e.push(this[t]);return e};var o=function(){function t(t){void 0===t&&(t=[1,0,0,1,0,0]),this.m=t&&t.slice()||[1,0,0,1,0,0]}return t.prototype.copy=function(){return new t(this.m)},t.prototype.point=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]}},t.prototype.translate=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},t.prototype.scale=function(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this},t.prototype.rotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.m[0]*e+this.m[2]*i,n=this.m[1]*e+this.m[3]*i,o=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=n,this.m[2]=o,this.m[3]=a,this},t.prototype.getTranslation=function(){return{x:this.m[4],y:this.m[5]}},t.prototype.skew=function(t,e){var i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,n=this.m[2]+this.m[0]*t,o=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=n,this.m[3]=o,this},t.prototype.multiply=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],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],n=this.m[1]*t.m[2]+this.m[3]*t.m[3],o=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=o,this.m[5]=a,this},t.prototype.invert=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,r=-this.m[2]*t,n=this.m[0]*t,o=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=o,this.m[5]=a,this},t.prototype.getMatrix=function(){return this.m},t.prototype.setAbsolutePosition=function(t,e){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],a=this.m[4],s=(i*(e-this.m[5])-r*(t-a))/(i*o-r*n),h=(t-a-n*s)/i;return this.translate(h,s)},t.prototype.decompose=function(){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=t*n-i*r,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=i){var s=Math.sqrt(t*t+i*i);a.rotation=i>0?Math.acos(t/s):-Math.acos(t/s),a.scaleX=s,a.scaleY=o/s,a.skewX=(t*r+i*n)/o,a.skewY=0}else if(0!=r||0!=n){var h=Math.sqrt(r*r+n*n);a.rotation=Math.PI/2-(n>0?Math.acos(-r/h):-Math.acos(r/h)),a.scaleX=o/h,a.scaleY=h,a.skewX=0,a.skewY=(t*r+i*n)/o}return a.rotation=e.Util._getRotation(a.rotation),a},t}();e.Transform=o;var a=Math.PI/180,s=180/Math.PI,h={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]},c=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,l=[];e.Util={_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?0:t>0?1:-1},requestAnimFrame:function(t){l.push(t),1===l.length&&requestAnimationFrame((function(){var t=l;l=[],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},_simplifyArray:function(t){var i,r,n=[],o=t.length,a=e.Util;for(i=0;i<o;i++)r=t[i],a._isNumber(r)?r=Math.round(1e3*r)/1e3:a._isString(r)||(r=r.toString()),n.push(r);return n},_urlToImage:function(t,e){var i=new r.glob.Image;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},get:function(t,e){return void 0===t?e:t},getRGB:function(t){var e;return t in h?{r:(e=h[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=c.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",e.Util._namedColorToRBA(t)||e.Util._hex3ColorToRGBA(t)||e.Util._hex6ColorToRGBA(t)||e.Util._rgbColorToRGBA(t)||e.Util._rgbaColorToRGBA(t)||e.Util._hslColorToRGBA(t)},_namedColorToRBA:function(t){var e=h[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(Number);return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_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}},_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=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),i=(e[0],e.slice(1)),r=Number(i[0])/360,n=Number(i[1])/100,o=Number(i[2])/100,a=void 0,s=void 0,h=void 0;if(0===n)return h=255*o,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};for(var c=2*o-(a=o<.5?o*(1+n):o+n-o*n),l=[0,0,0],u=0;u<3;u++)(s=r+1/3*-(u-1))<0&&s++,s>1&&s--,h=6*s<1?c+6*(a-c)*s:2*s<1?a:3*s<2?c+(a-c)*(2/3-s)*6:c,l[u]=255*h;return{r:Math.round(l[0]),g:Math.round(l[1]),b:Math.round(l[2]),a:1}}},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*a},_radToDeg:function(t){return t*s},_getRotation:function(t){return r.Konva.angleDeg?e.Util._radToDeg(t):t},_capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},throw:function(t){throw new Error("Konva error: "+t)},error:function(t){console.error("Konva error: "+t)},warn:function(t){r.Konva.showWarnings&&console.warn("Konva warning: "+t)},extend:function(t,e){function i(){this.constructor=t}i.prototype=e.prototype;var r=t.prototype;for(var n in t.prototype=new i,r)r.hasOwnProperty(n)&&(t.prototype[n]=r[n]);t.__super__=e.prototype,t.super=e},_getControlPoints:function(t,e,i,r,n,o,a){var s=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(n-i,2)+Math.pow(o-r,2)),c=a*s/(s+h),l=a*h/(s+h);return[i-c*(n-t),r-c*(o-e),i+l*(n-t),r+l*(o-e)]},_expandPoints:function(t,i){var r,n,o=t.length,a=[];for(r=2;r<o-2;r+=2)n=e.Util._getControlPoints(t[r-2],t[r-1],t[r],t[r+1],t[r+2],t[r+3],i),a.push(n[0]),a.push(n[1]),a.push(t[r]),a.push(t[r+1]),a.push(n[2]),a.push(n[3]);return a},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,r,n,o){var a,s,h,c=(t-i)*(t-i)+(e-r)*(e-r);if(0==c)a=t,s=e,h=(n-i)*(n-i)+(o-r)*(o-r);else{var l=((n-t)*(i-t)+(o-e)*(r-e))/c;l<0?(a=t,s=e,h=(t-n)*(t-n)+(e-o)*(e-o)):l>1?(a=i,s=r,h=(i-n)*(i-n)+(r-o)*(r-o)):h=((a=t+l*(i-t))-n)*(a-n)+((s=e+l*(r-e))-o)*(s-o)}return[a,s,h]},_getProjectionToLine:function(t,i,r){var n=e.Util.cloneObject(t),o=Number.MAX_VALUE;return i.forEach((function(a,s){if(r||s!==i.length-1){var h=i[(s+1)%i.length],c=e.Util._getProjectionToSegment(a.x,a.y,h.x,h.y,t.x,t.y),l=c[0],u=c[1],d=c[2];d<o&&(n.x=l,n.y=u,o=d)}})),n},_prepareArrayForTween:function(t,i,r){var n,o=[],a=[];if(t.length>i.length){var s=i;i=t,t=s}for(n=0;n<t.length;n+=2)o.push({x:t[n],y:t[n+1]});for(n=0;n<i.length;n+=2)a.push({x:i[n],y:i[n+1]});var h=[];return a.forEach((function(t){var i=e.Util._getProjectionToLine(t,o,r);h.push(i.x),h.push(i.y)})),h},_prepareToStringify:function(t){var i;for(var r in t.visitedByCircularReferenceRemoval=!0,t)if(t.hasOwnProperty(r)&&t[r]&&"object"==typeof t[r])if(i=Object.getOwnPropertyDescriptor(t,r),t[r].visitedByCircularReferenceRemoval||e.Util._isElement(t[r])){if(!i.configurable)return null;delete t[r]}else if(null===e.Util._prepareToStringify(t[r])){if(!i.configurable)return null;delete t[r]}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:999}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(3),n=i(0),o=i(11),a=i(1),s=i(16),h=i(2);e.ids={},e.names={};e._removeId=function(t,i){t&&e.ids[t]===i&&delete e.ids[t]},e._addName=function(t,i){i&&(e.names[i]||(e.names[i]=[]),e.names[i].push(t))},e._removeName=function(t,i){if(t){var r=e.names[t];if(r){for(var n=0;n<r.length;n++){r[n]._id===i&&r.splice(n,1)}0===r.length&&delete e.names[t]}}};var c=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(" "),l=(["scaleXChange.konva","scaleYChange.konva"].join(" "),new r.Collection),u=1,d=function(){function t(t){var e=this;this._id=u++,this.eventListeners={},this.attrs={},this.index=0,this.parent=null,this._cache=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this.children=l,this._dragEventId=null,this.setAttrs(t),this.on(c,(function(){e._batchingTransformChange?e._needClearTransformCache=!0:(e._clearCache("transform"),e._clearSelfAndDescendantCache("absoluteTransform"))})),this.on("visibleChange.konva",(function(){e._clearSelfAndDescendantCache("visible")})),this.on("listeningChange.konva",(function(){e._clearSelfAndDescendantCache("listening")})),this.on("opacityChange.konva",(function(){e._clearSelfAndDescendantCache("absoluteOpacity")}))}return t.prototype.hasChildren=function(){return!1},t.prototype.getChildren=function(){return l},t.prototype._clearCache=function(t){t?this._cache.delete(t):this._cache.clear()},t.prototype._getCache=function(t,e){var i=this._cache.get(t);return void 0===i&&(i=e.call(this),this._cache.set(t,i)),i},t.prototype._getCanvasCache=function(){return this._cache.get("canvas")},t.prototype._clearSelfAndDescendantCache=function(t,e){this._clearCache(t),e&&"absoluteTransform"===t&&this.fire("_clearTransformCache"),this.isCached()||this.children&&this.children.each((function(e){e._clearSelfAndDescendantCache(t,!0)}))},t.prototype.clearCache=function(){return this._cache.delete("canvas"),this._clearSelfAndDescendantCache(),this},t.prototype.cache=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),a=Math.ceil(e.height||i.height),s=e.pixelRatio,h=void 0===e.x?i.x:e.x,c=void 0===e.y?i.y:e.y,l=e.offset||0,u=e.drawBorder||!1;if(n&&a){n+=2*l,a+=2*l,h-=l,c-=l;var d=new o.SceneCanvas({pixelRatio:s,width:n,height:a}),p=new o.SceneCanvas({pixelRatio:s,width:0,height:0}),f=new o.HitCanvas({pixelRatio:1,width:n,height:a}),g=d.getContext(),y=f.getContext();return f.isCache=!0,this._cache.delete("canvas"),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),g.save(),y.save(),g.translate(-h,-c),y.translate(-h,-c),this._isUnderCache=!0,this._clearSelfAndDescendantCache("absoluteOpacity"),this._clearSelfAndDescendantCache("absoluteScale"),this.drawScene(d,this,!0),this.drawHit(f,this,!0),this._isUnderCache=!1,g.restore(),y.restore(),u&&(g.save(),g.beginPath(),g.rect(0,0,n,a),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set("canvas",{scene:d,filter:p,hit:f,x:h,y:c}),this}r.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")},t.prototype.isCached=function(){return this._cache.has("canvas")},t.prototype.getClientRect=function(t){throw new Error('abstract "getClientRect" method call')},t.prototype._transformedRect=function(t,e){var i,r,n,o,a=[{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 a.forEach((function(t){var e=s.point(t);void 0===i&&(i=n=e.x,r=o=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)})),{x:i,y:r,width:n-i,height:o-r}},t.prototype._drawCachedSceneCanvas=function(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);var e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()},t.prototype._drawCachedHitCanvas=function(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0),t.restore()},t.prototype._getCachedSceneCanvas=function(){var t,e,i,n,o=this.filters(),a=this._getCanvasCache(),s=a.scene,h=a.filter,c=h.getContext();if(o){if(!this._filterUpToDate){var l=s.pixelRatio;h.setSize(s.width/s.pixelRatio,s.height/s.pixelRatio);try{for(t=o.length,c.clear(),c.drawImage(s._canvas,0,0,s.getWidth()/l,s.getHeight()/l),e=c.getImageData(0,0,h.getWidth(),h.getHeight()),i=0;i<t;i++)"function"==typeof(n=o[i])?(n.call(this,e),c.putImageData(e,0,0)):r.Util.error("Filter should be type of function, but got "+typeof n+" instead. Please check correct filters")}catch(t){r.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return s},t.prototype.on=function(t,e){if(3===arguments.length)return this._delegate.apply(this,arguments);var i,r,n,o,a=t.split(" "),s=a.length;for(i=0;i<s;i++)n=(r=a[i].split("."))[0],o=r[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:o,handler:e});return this},t.prototype.off=function(t,e){var i,r,n,o,a,s=(t||"").split(" "),h=s.length;if(!t)for(r in this.eventListeners)this._off(r);for(i=0;i<h;i++)if(o=(n=s[i].split("."))[0],a=n[1],o)this.eventListeners[o]&&this._off(o,a,e);else for(r in this.eventListeners)this._off(r,a,e);return this},t.prototype.dispatchEvent=function(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this},t.prototype.addEventListener=function(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this},t.prototype.removeEventListener=function(t){return this.off(t),this},t.prototype._delegate=function(t,e,i){var n=this;this.on(t,(function(t){for(var o=t.target.findAncestors(e,!0,n),a=0;a<o.length;a++)(t=r.Util.cloneObject(t)).currentTarget=o[a],i.call(o[a],t)}))},t.prototype.remove=function(){return this.isDragging()&&this.stopDrag(),s.DD._dragElements.delete(this._id),this._remove(),this},t.prototype._clearCaches=function(){this._clearSelfAndDescendantCache("absoluteTransform"),this._clearSelfAndDescendantCache("absoluteOpacity"),this._clearSelfAndDescendantCache("absoluteScale"),this._clearSelfAndDescendantCache("stage"),this._clearSelfAndDescendantCache("visible"),this._clearSelfAndDescendantCache("listening")},t.prototype._remove=function(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)},t.prototype.destroy=function(){e._removeId(this.id(),this);for(var t=(this.name()||"").split(/\s/g),i=0;i<t.length;i++){var r=t[i];e._removeName(r,this._id)}return this.remove(),this},t.prototype.getAttr=function(t){var e="get"+r.Util._capitalize(t);return r.Util._isFunction(this[e])?this[e]():this.attrs[t]},t.prototype.getAncestors=function(){for(var t=this.getParent(),e=new r.Collection;t;)e.push(t),t=t.getParent();return e},t.prototype.getAttrs=function(){return this.attrs||{}},t.prototype.setAttrs=function(t){var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+r.Util._capitalize(e),r.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]));return this},t.prototype.isListening=function(){return this._getCache("listening",this._isListening)},t.prototype._isListening=function(){var t=this.listening(),e=this.getParent();return"inherit"===t?!e||e.isListening():t},t.prototype.isVisible=function(){return this._getCache("visible",this._isVisible)},t.prototype._isVisible=function(t){var e=this.visible(),i=this.getParent();return"inherit"===e?!i||i===t||i._isVisible(t):t&&t!==i?e&&i._isVisible(t):e},t.prototype.shouldDrawHit=function(){var t=this.getLayer();return!t&&this.isListening()&&this.isVisible()||t&&t.hitGraphEnabled()&&this.isListening()&&this.isVisible()},t.prototype.show=function(){return this.visible(!0),this},t.prototype.hide=function(){return this.visible(!1),this},t.prototype.getZIndex=function(){return this.index||0},t.prototype.getAbsoluteZIndex=function(){var t,e,i,r,n=this.getDepth(),o=this,a=0;return"Stage"!==o.nodeType&&function s(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],a++,"Shape"!==r.nodeType&&(t=t.concat(r.getChildren().toArray())),r._id===o._id&&(i=e);t.length>0&&t[0].getDepth()<=n&&s(t)}(o.getStage().getChildren()),a},t.prototype.getDepth=function(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t},t.prototype._batchTransformChanges=function(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform",!0)),this._needClearTransformCache=!1},t.prototype.setPosition=function(t){var e=this;return this._batchTransformChanges((function(){e.x(t.x),e.y(t.y)})),this},t.prototype.getPosition=function(){return{x:this.x(),y:this.y()}},t.prototype.getAbsolutePosition=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(),o=new r.Transform,a=this.offset();return o.m=n.slice(),o.translate(a.x,a.y),o.getTranslation()},t.prototype.setAbsolutePosition=function(t){var e,i=this._clearTransform();return this.attrs.x=i.x,this.attrs.y=i.y,delete i.x,delete i.y,this._clearCache("transform"),(e=this._getAbsoluteTransform()).invert(),e.translate(t.x,t.y),t={x:this.attrs.x+e.getTranslation().x,y:this.attrs.y+e.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this},t.prototype._setTransform=function(t){var e;for(e in t)this.attrs[e]=t[e]},t.prototype._clearTransform=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},t.prototype.move=function(t){var e=t.x,i=t.y,r=this.x(),n=this.y();return void 0!==e&&(r+=e),void 0!==i&&(n+=i),this.setPosition({x:r,y:n}),this},t.prototype._eachAncestorReverse=function(t,e){var i,r,n=[],o=this.getParent();if(e&&e._id===this._id)t(this);else{for(n.unshift(this);o&&(!e||o._id!==e._id);)n.unshift(o),o=o.parent;for(i=n.length,r=0;r<i;r++)t(n[r])}},t.prototype.rotate=function(t){return this.rotation(this.rotation()+t),this},t.prototype.moveToTop=function(){if(!this.parent)return r.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0},t.prototype.moveUp=function(){if(!this.parent)return r.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)},t.prototype.moveDown=function(){if(!this.parent)return r.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)},t.prototype.moveToBottom=function(){if(!this.parent)return r.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)},t.prototype.setZIndex=function(t){if(!this.parent)return r.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&r.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this},t.prototype.getAbsoluteOpacity=function(){return this._getCache("absoluteOpacity",this._getAbsoluteOpacity)},t.prototype._getAbsoluteOpacity=function(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t},t.prototype.moveTo=function(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this},t.prototype.toObject=function(){var t,e,i,n,o={},a=this.getAttrs();for(t in o.attrs={},a)e=a[t],r.Util.isObject(e)&&!r.Util._isPlainObject(e)&&!r.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete a[t],n=i?i.call(this):null,a[t]=e,n!==e&&(o.attrs[t]=e));return o.className=this.getClassName(),r.Util._prepareToStringify(o)},t.prototype.toJSON=function(){return JSON.stringify(this.toObject())},t.prototype.getParent=function(){return this.parent},t.prototype.findAncestors=function(t,e,i){var r=[];e&&this._isMatch(t)&&r.push(this);for(var n=this.parent;n;){if(n===i)return r;n._isMatch(t)&&r.push(n),n=n.parent}return r},t.prototype.isAncestorOf=function(t){return!1},t.prototype.findAncestor=function(t,e,i){return this.findAncestors(t,e,i)[0]},t.prototype._isMatch=function(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,n=t.replace(/ /g,"").split(","),o=n.length;for(e=0;e<o;e++)if(i=n[e],r.Util.isValidSelector(i)||(r.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),r.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),r.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1},t.prototype.getLayer=function(){var t=this.getParent();return t?t.getLayer():null},t.prototype.getStage=function(){return this._getCache("stage",this._getStage)},t.prototype._getStage=function(){var t=this.getParent();return t?t.getStage():void 0},t.prototype.fire=function(t,e,i){return void 0===e&&(e={}),e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this},t.prototype.getAbsoluteTransform=function(t){return t?this._getAbsoluteTransform(t):this._getCache("absoluteTransform",this._getAbsoluteTransform)},t.prototype._getAbsoluteTransform=function(t){var e;if(t)return e=new r.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this.parent?this.parent.getAbsoluteTransform().copy():new r.Transform;var i=this.transformsEnabled();return"all"===i?e.multiply(this.getTransform()):"position"===i&&e.translate(this.x()-this.offsetX(),this.y()-this.offsetY()),e},t.prototype.getAbsoluteScale=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}},t.prototype.getAbsoluteRotation=function(){return this.getAbsoluteTransform().decompose().rotation},t.prototype.getTransform=function(){return this._getCache("transform",this._getTransform)},t.prototype._getTransform=function(){var t=new r.Transform,e=this.x(),i=this.y(),n=a.Konva.getAngle(this.rotation()),o=this.scaleX(),s=this.scaleY(),h=this.skewX(),c=this.skewY(),l=this.offsetX(),u=this.offsetY();return 0===e&&0===i||t.translate(e,i),0!==n&&t.rotate(n),0===h&&0===c||t.skew(h,c),1===o&&1===s||t.scale(o,s),0===l&&0===u||t.translate(-1*l,-1*u),t},t.prototype.clone=function(t){var e,i,n,o,a,s=r.Util.cloneObject(this.attrs);for(e in t)s[e]=t[e];var h=new this.constructor(s);for(e in this.eventListeners)for(n=(i=this.eventListeners[e]).length,o=0;o<n;o++)(a=i[o]).name.indexOf("konva")<0&&(h.eventListeners[e]||(h.eventListeners[e]=[]),h.eventListeners[e].push(a));return h},t.prototype._toKonvaCanvas=function(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:e.x,n=void 0!==t.y?t.y:e.y,a=t.pixelRatio||1,s=new o.SceneCanvas({width:t.width||e.width||(i?i.width():0),height:t.height||e.height||(i?i.height():0),pixelRatio:a}),h=s.getContext();return h.save(),(r||n)&&h.translate(-1*r,-1*n),this.drawScene(s),h.restore(),s},t.prototype.toCanvas=function(t){return this._toKonvaCanvas(t)._canvas},t.prototype.toDataURL=function(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r},t.prototype.toImage=function(t){if(!t||!t.callback)throw"callback required for toImage method config argument";var e=t.callback;delete t.callback,r.Util._urlToImage(this.toDataURL(t),(function(t){e(t)}))},t.prototype.setSize=function(t){return this.width(t.width),this.height(t.height),this},t.prototype.getSize=function(){return{width:this.width(),height:this.height()}},t.prototype.getClassName=function(){return this.className||this.nodeType},t.prototype.getType=function(){return this.nodeType},t.prototype.getDragDistance=function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():a.Konva.dragDistance},t.prototype._off=function(t,e,i){var r,n,o,a=this.eventListeners[t];for(r=0;r<a.length;r++)if(n=a[r].name,o=a[r].handler,!("konva"===n&&"konva"!==e||e&&n!==e||i&&i!==o)){if(a.splice(r,1),0===a.length){delete this.eventListeners[t];break}r--}},t.prototype._fireChangeEvent=function(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})},t.prototype.setId=function(t){var i=this.id();return e._removeId(i,this),function(t,i){i&&(e.ids[i]=t)}(this,t),this._setAttr("id",t),this},t.prototype.setName=function(t){var i,r,n=(this.name()||"").split(/\s/g),o=(t||"").split(/\s/g);for(r=0;r<n.length;r++)i=n[r],-1===o.indexOf(i)&&i&&e._removeName(i,this._id);for(r=0;r<o.length;r++)i=o[r],-1===n.indexOf(i)&&i&&e._addName(this,i);return this._setAttr("name",t),this},t.prototype.addName=function(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.setName(i)}return this},t.prototype.hasName=function(t){if(!t)return!1;var e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)},t.prototype.removeName=function(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.setName(e.join(" "))),this},t.prototype.setAttr=function(t,e){var i=this["set"+r.Util._capitalize(t)];return r.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this},t.prototype._setAttr=function(t,e){var i=this.attrs[t];(i!==e||r.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._fireChangeEvent(t,i,e))},t.prototype._setComponentAttr=function(t,e,i){var r;void 0!==i&&((r=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))},t.prototype._fireAndBubble=function(t,e,i){if(e&&"Shape"===this.nodeType&&(e.target=this),!(("mouseenter"===t||"mouseleave"===t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=("mouseenter"===t||"mouseleave"===t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}},t.prototype._fire=function(t,e){var i,r=this.eventListeners[t];if(r)for((e=e||{}).currentTarget=this,e.type=t,i=0;i<r.length;i++)r[i].handler.call(this,e)},t.prototype.draw=function(){return this.drawScene(),this.drawHit(),this},t.prototype._createDragElement=function(t){var e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition(),n=i._getPointerById(e)||i._changedPointerPositions[0]||r;s.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-r.x,y:n.y-r.y},dragStatus:"ready",pointerId:e})},t.prototype.startDrag=function(t){s.DD._dragElements.has(this._id)||this._createDragElement(t),s.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},!0)},t.prototype._setDragPosition=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},o=this.dragBoundFunc();if(void 0!==o){var a=o.call(this,n,t);a?n=a:r.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this.getLayer()?this.getLayer().batchDraw():this.getStage()&&this.getStage().batchDraw()),this._lastPos=n}},t.prototype.stopDrag=function(t){var e=s.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),s.DD._endDragBefore(t),s.DD._endDragAfter(t)},t.prototype.setDraggable=function(t){this._setAttr("draggable",t),this._dragChange()},t.prototype.isDragging=function(){var t=s.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus},t.prototype._listenDrag=function(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){var e=this;if((!(void 0!==t.evt.button)||a.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var i=!1;s.DD._dragElements.forEach((function(t){e.isAncestorOf(t.node)&&(i=!0)})),i||this._createDragElement(t)}}))},t.prototype._dragChange=function(){this.attrs.draggable?this._listenDrag():(this._dragCleanup(),this.getStage()&&s.DD._dragElements.has(this._id)&&this.stopDrag())},t.prototype._dragCleanup=function(){this.off("mousedown.konva"),this.off("touchstart.konva")},t.create=function(t,e){return r.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)},t._createNode=function(e,i){var n,o,s,h=t.prototype.getClassName.call(e),c=e.children;if(i&&(e.attrs.container=i),a._NODES_REGISTRY[h]||(r.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape"),n=new(0,a._NODES_REGISTRY[h])(e.attrs),c)for(o=c.length,s=0;s<o;s++)n.add(t._createNode(c[s]));return n},t}();e.Node=d,d.prototype.nodeType="Node",d.prototype._attrsAffectingSize=[],n.Factory.addGetterSetter(d,"zIndex"),n.Factory.addGetterSetter(d,"absolutePosition"),n.Factory.addGetterSetter(d,"position"),n.Factory.addGetterSetter(d,"x",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"y",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"globalCompositeOperation","source-over",h.getStringValidator()),n.Factory.addGetterSetter(d,"opacity",1,h.getNumberValidator()),n.Factory.addGetterSetter(d,"name","",h.getStringValidator()),n.Factory.addGetterSetter(d,"id","",h.getStringValidator()),n.Factory.addGetterSetter(d,"rotation",0,h.getNumberValidator()),n.Factory.addComponentsGetterSetter(d,"scale",["x","y"]),n.Factory.addGetterSetter(d,"scaleX",1,h.getNumberValidator()),n.Factory.addGetterSetter(d,"scaleY",1,h.getNumberValidator()),n.Factory.addComponentsGetterSetter(d,"skew",["x","y"]),n.Factory.addGetterSetter(d,"skewX",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"skewY",0,h.getNumberValidator()),n.Factory.addComponentsGetterSetter(d,"offset",["x","y"]),n.Factory.addGetterSetter(d,"offsetX",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"offsetY",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"dragDistance",null,h.getNumberValidator()),n.Factory.addGetterSetter(d,"width",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"height",0,h.getNumberValidator()),n.Factory.addGetterSetter(d,"listening","inherit",(function(t){return!0===t||!1===t||"inherit"===t||r.Util.warn(t+' is a not valid value for "listening" attribute. The value may be true, false or "inherit".'),t})),n.Factory.addGetterSetter(d,"preventDefault",!0,h.getBooleanValidator()),n.Factory.addGetterSetter(d,"filters",null,(function(t){return this._filterUpToDate=!1,t})),n.Factory.addGetterSetter(d,"visible","inherit",(function(t){return!0===t||!1===t||"inherit"===t||r.Util.warn(t+' is a not valid value for "visible" attribute. The value may be true, false or "inherit".'),t})),n.Factory.addGetterSetter(d,"transformsEnabled","all",h.getStringValidator()),n.Factory.addGetterSetter(d,"size"),n.Factory.addGetterSetter(d,"dragBoundFunc"),n.Factory.addGetterSetter(d,"draggable",!1,h.getBooleanValidator()),n.Factory.backCompat(d,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),r.Collection.mapMethods(d)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o,a=i(3),s=i(0),h=i(4),c=i(2),l=i(1),u=i(28);function d(){return o||(o=a.Util.createCanvasElement().getContext("2d"))}function p(){this._clearCache("hasShadow")}function f(){this._clearCache("shadowRGBA")}function g(){this._clearCache("patternImage")}function y(){this._clearCache("linearGradient")}function v(){this._clearCache("radialGradient")}e.shapes={};var _=function(t){function i(i){for(var r,n=t.call(this,i)||this;!(r=a.Util.getRandomColor())||r in e.shapes;);return n.colorKey=r,e.shapes[r]=n,n.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",p),n.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",f),n.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva",g),n.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",y),n.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",v),n}return n(i,t),i.prototype.getContext=function(){return this.getLayer().getContext()},i.prototype.getCanvas=function(){return this.getLayer().getCanvas()},i.prototype.getSceneFunc=function(){return this.attrs.sceneFunc||this._sceneFunc},i.prototype.getHitFunc=function(){return this.attrs.hitFunc||this._hitFunc},i.prototype.hasShadow=function(){return this._getCache("hasShadow",this._hasShadow)},i.prototype._hasShadow=function(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())},i.prototype._getFillPattern=function(){return this._getCache("patternImage",this.__getFillPattern)},i.prototype.__getFillPattern=function(){if(this.fillPatternImage())return d().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat")},i.prototype._getLinearGradient=function(){return this._getCache("linearGradient",this.__getLinearGradient)},i.prototype.__getLinearGradient=function(){var t=this.fillLinearGradientColorStops();if(t){for(var e=d(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),n=e.createLinearGradient(i.x,i.y,r.x,r.y),o=0;o<t.length;o+=2)n.addColorStop(t[o],t[o+1]);return n}},i.prototype._getRadialGradient=function(){return this._getCache("radialGradient",this.__getRadialGradient)},i.prototype.__getRadialGradient=function(){var t=this.fillRadialGradientColorStops();if(t){for(var e=d(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),n=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),o=0;o<t.length;o+=2)n.addColorStop(t[o],t[o+1]);return n}},i.prototype.getShadowRGBA=function(){return this._getCache("shadowRGBA",this._getShadowRGBA)},i.prototype._getShadowRGBA=function(){if(this.hasShadow()){var t=a.Util.colorToRGBA(this.shadowColor());return"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")"}},i.prototype.hasFill=function(){return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())},i.prototype.hasStroke=function(){return this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())},i.prototype.hasHitStroke=function(){var t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t},i.prototype.intersects=function(t){var e=this.getStage().bufferHitCanvas;return e.getContext().clear(),this.drawHit(e),e.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0},i.prototype.destroy=function(){return h.Node.prototype.destroy.call(this),delete e.shapes[this.colorKey],delete this.colorKey,this},i.prototype._useBufferCanvas=function(t){return!(t&&!this.hasShadow()||!this.perfectDrawEnabled()||1===this.getAbsoluteOpacity()||!this.hasFill()||!this.hasStroke()||!this.getStage())},i.prototype.setStrokeHitEnabled=function(t){a.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)},i.prototype.getStrokeHitEnabled=function(){return 0!==this.hitStrokeWidth()},i.prototype.getSelfRect=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}},i.prototype.getClientRect=function(t){var e=(t=t||{}).skipTransform,i=t.relativeTo,r=this.getSelfRect(),n=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+n,a=r.height+n,s=!t.skipShadow&&this.hasShadow(),h=s?this.shadowOffsetX():0,c=s?this.shadowOffsetY():0,l=o+Math.abs(h),u=a+Math.abs(c),d=s&&this.shadowBlur()||0,p=l+2*d,f=u+2*d,g=0;Math.round(n/2)!==n/2&&(g=1);var y={width:p+g,height:f+g,x:-Math.round(n/2+d)+Math.min(h,0)+r.x,y:-Math.round(n/2+d)+Math.min(c,0)+r.y};return e?y:this._transformedRect(y,i)},i.prototype.drawScene=function(t,e,i,r){var n,o,a=this.getLayer(),s=t||a.getCanvas(),h=s.getContext(),c=this._getCanvasCache(),l=this.sceneFunc(),u=this.hasShadow(),d=this.hasStroke();if(!this.isVisible()&&!i)return this;if(c)return h.save(),a._applyTransform(this,h,e),this._drawCachedSceneCanvas(h),h.restore(),this;if(!l)return this;if(h.save(),this._useBufferCanvas(i)&&!r){if((o=(n=this.getStage().bufferCanvas).getContext()).clear(),o.save(),o._applyLineJoin(this),!i)if(a)a._applyTransform(this,o,e);else{var p=this.getAbsoluteTransform(e).getMatrix();h.transform(p[0],p[1],p[2],p[3],p[4],p[5])}l.call(this,o,this),o.restore();var f=n.pixelRatio;u&&!s.hitCanvas?(h.save(),h._applyShadow(this),h._applyOpacity(this),h._applyGlobalCompositeOperation(this),h.drawImage(n._canvas,0,0,n.width/f,n.height/f),h.restore()):(h._applyOpacity(this),h._applyGlobalCompositeOperation(this),h.drawImage(n._canvas,0,0,n.width/f,n.height/f))}else{if(h._applyLineJoin(this),!i)if(a)a._applyTransform(this,h,e);else{var g=this.getAbsoluteTransform(e).getMatrix();h.transform(g[0],g[1],g[2],g[3],g[4],g[5])}u&&d&&!s.hitCanvas?(h.save(),i||(h._applyOpacity(this),h._applyGlobalCompositeOperation(this)),h._applyShadow(this),l.call(this,h,this),h.restore(),this.hasFill()&&this.shadowForStrokeEnabled()&&l.call(this,h,this)):u&&!s.hitCanvas?(h.save(),i||(h._applyOpacity(this),h._applyGlobalCompositeOperation(this)),h._applyShadow(this),l.call(this,h,this),h.restore()):(i||(h._applyOpacity(this),h._applyGlobalCompositeOperation(this)),l.call(this,h,this))}return h.restore(),this},i.prototype.drawHit=function(t,e,i){var r=this.getLayer(),n=t||r.hitCanvas,o=n&&n.getContext(),s=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),c=h&&h.hit;if(this.colorKey||(console.log(this),a.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. See the shape in logs above. If you want to reuse shape you should call remove() instead of destroy()")),!this.shouldDrawHit()&&!i)return this;if(c)return o.save(),r._applyTransform(this,o,e),this._drawCachedHitCanvas(o),o.restore(),this;if(!s)return this;if(o.save(),o._applyLineJoin(this),!i)if(r)r._applyTransform(this,o,e);else{var l=this.getAbsoluteTransform(e).getMatrix();o.transform(l[0],l[1],l[2],l[3],l[4],l[5])}return s.call(this,o,this),o.restore(),this},i.prototype.drawHitFromCache=function(t){void 0===t&&(t=0);var e,i,r,n,o,s=this._getCanvasCache(),h=this._getCachedSceneCanvas(),c=s.hit,l=c.getContext(),u=c.getWidth(),d=c.getHeight();l.clear(),l.drawImage(h._canvas,0,0,u,d);try{for(r=(i=(e=l.getImageData(0,0,u,d)).data).length,n=a.Util._hexToRgb(this.colorKey),o=0;o<r;o+=4)i[o+3]>t?(i[o]=n.r,i[o+1]=n.g,i[o+2]=n.b,i[o+3]=255):i[o+3]=0;l.putImageData(e,0,0)}catch(t){a.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this},i.prototype.hasPointerCapture=function(t){return u.hasPointerCapture(t,this)},i.prototype.setPointerCapture=function(t){u.setPointerCapture(t,this)},i.prototype.releaseCapture=function(t){u.releaseCapture(t,this)},i}(h.Node);e.Shape=_,_.prototype._fillFunc=function(t){t.fill()},_.prototype._strokeFunc=function(t){t.stroke()},_.prototype._fillFuncHit=function(t){t.fill()},_.prototype._strokeFuncHit=function(t){t.stroke()},_.prototype._centroid=!1,_.prototype.nodeType="Shape",l._registerNode(_),s.Factory.addGetterSetter(_,"stroke",void 0,c.getStringValidator()),s.Factory.addGetterSetter(_,"strokeWidth",2,c.getNumberValidator()),s.Factory.addGetterSetter(_,"hitStrokeWidth","auto",c.getNumberOrAutoValidator()),s.Factory.addGetterSetter(_,"strokeHitEnabled",!0,c.getBooleanValidator()),s.Factory.addGetterSetter(_,"perfectDrawEnabled",!0,c.getBooleanValidator()),s.Factory.addGetterSetter(_,"shadowForStrokeEnabled",!0,c.getBooleanValidator()),s.Factory.addGetterSetter(_,"lineJoin"),s.Factory.addGetterSetter(_,"lineCap"),s.Factory.addGetterSetter(_,"sceneFunc"),s.Factory.addGetterSetter(_,"hitFunc"),s.Factory.addGetterSetter(_,"dash"),s.Factory.addGetterSetter(_,"dashOffset",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"shadowColor",void 0,c.getStringValidator()),s.Factory.addGetterSetter(_,"shadowBlur",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"shadowOpacity",1,c.getNumberValidator()),s.Factory.addComponentsGetterSetter(_,"shadowOffset",["x","y"]),s.Factory.addGetterSetter(_,"shadowOffsetX",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"shadowOffsetY",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"fillPatternImage"),s.Factory.addGetterSetter(_,"fill",void 0,c.getStringValidator()),s.Factory.addGetterSetter(_,"fillPatternX",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"fillPatternY",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"fillLinearGradientColorStops"),s.Factory.addGetterSetter(_,"strokeLinearGradientColorStops"),s.Factory.addGetterSetter(_,"fillRadialGradientStartRadius",0),s.Factory.addGetterSetter(_,"fillRadialGradientEndRadius",0),s.Factory.addGetterSetter(_,"fillRadialGradientColorStops"),s.Factory.addGetterSetter(_,"fillPatternRepeat","repeat"),s.Factory.addGetterSetter(_,"fillEnabled",!0),s.Factory.addGetterSetter(_,"strokeEnabled",!0),s.Factory.addGetterSetter(_,"shadowEnabled",!0),s.Factory.addGetterSetter(_,"dashEnabled",!0),s.Factory.addGetterSetter(_,"strokeScaleEnabled",!0),s.Factory.addGetterSetter(_,"fillPriority","color"),s.Factory.addComponentsGetterSetter(_,"fillPatternOffset",["x","y"]),s.Factory.addGetterSetter(_,"fillPatternOffsetX",0,c.getNumberValidator()),s.Factory.addGetterSetter(_,"fillPatternOffsetY",0,c.getNumberValidator()),s.Factory.addComponentsGetterSetter(_,"fillPatternScale",["x","y"]),s.Factory.addGetterSetter(_,"fillPatternScaleX",1,c.getNumberValidator()),s.Factory.addGetterSetter(_,"fillPatternScaleY",1,c.getNumberValidator()),s.Factory.addComponentsGetterSetter(_,"fillLinearGradientStartPoint",["x","y"]),s.Factory.addComponentsGetterSetter(_,"strokeLinearGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillLinearGradientStartPointX",0),s.Factory.addGetterSetter(_,"strokeLinearGradientStartPointX",0),s.Factory.addGetterSetter(_,"fillLinearGradientStartPointY",0),s.Factory.addGetterSetter(_,"strokeLinearGradientStartPointY",0),s.Factory.addComponentsGetterSetter(_,"fillLinearGradientEndPoint",["x","y"]),s.Factory.addComponentsGetterSetter(_,"strokeLinearGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillLinearGradientEndPointX",0),s.Factory.addGetterSetter(_,"strokeLinearGradientEndPointX",0),s.Factory.addGetterSetter(_,"fillLinearGradientEndPointY",0),s.Factory.addGetterSetter(_,"strokeLinearGradientEndPointY",0),s.Factory.addComponentsGetterSetter(_,"fillRadialGradientStartPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillRadialGradientStartPointX",0),s.Factory.addGetterSetter(_,"fillRadialGradientStartPointY",0),s.Factory.addComponentsGetterSetter(_,"fillRadialGradientEndPoint",["x","y"]),s.Factory.addGetterSetter(_,"fillRadialGradientEndPointX",0),s.Factory.addGetterSetter(_,"fillRadialGradientEndPointY",0),s.Factory.addGetterSetter(_,"fillPatternRotation",0),s.Factory.backCompat(_,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"}),a.Collection.mapMethods(_)},function(t,e,i){const r=i(7),{anchor:n,Anchor:o}=i(10),{None:a}=i(13),s=i(36),h=i(18),{itself:c,orthogonalTransform:l}=i(17);class u{constructor({up:t=a,down:e=a,left:i=a,right:r=a}={}){this.up=t,this.down=e,this.left=i,this.right=r,this.metadata={},this.centralAnchor=null,this._initializeListeners()}_initializeListeners(){this.translateListeners=[],this.connectListeners=[],this.disconnectListeners=[]}annotate(t){Object.assign(this.metadata,t)}reannotate(t){this.metadata=t}belongTo(t){this.puzzle=t}get presentConnections(){return this.connections.filter(c)}get connections(){return[this.rightConnection,this.downConnection,this.leftConnection,this.upConnection]}get inserts(){return[this.right,this.down,this.left,this.up]}onTranslate(t){this.translateListeners.push(t)}onConnect(t){this.connectListeners.push(t)}onDisconnect(t){this.disconnectListeners.push(t)}fireTranslate(t,e){this.translateListeners.forEach(i=>i(this,t,e))}fireConnect(t){this.connectListeners.forEach(e=>e(this,t))}fireDisconnect(t){t.forEach(t=>{this.disconnectListeners.forEach(e=>e(this,t))})}connectVerticallyWith(t,e=!1){s.vertical.connectWith(this,t,this.proximity,e)}attractVertically(t,e=!1){s.vertical.attract(this,t,e)}connectHorizontallyWith(t,e=!1){s.horizontal.connectWith(this,t,this.proximity,e)}attractHorizontally(t,e=!1){s.horizontal.attract(this,t,e)}tryConnectWith(t,e=!1){this.tryConnectHorizontallyWith(t,e),this.tryConnectVerticallyWith(t,e)}tryConnectHorizontallyWith(t,e=!1){this.canConnectHorizontallyWith(t)&&this.connectHorizontallyWith(t,e)}tryConnectVerticallyWith(t,e=!1){this.canConnectVerticallyWith(t)&&this.connectVerticallyWith(t,e)}disconnect(){if(!this.connected)return;const t=this.presentConnections;this.upConnection&&(this.upConnection.downConnection=null,this.upConnection=null),this.downConnection&&(this.downConnection.upConnection=null,this.downConnection=null),this.leftConnection&&(this.leftConnection.rightConnection=null,this.leftConnection=null),this.rightConnection&&(this.rightConnection.leftConnection=null,this.rightConnection=null),this.fireDisconnect(t)}centerAround(t){if(this.centralAnchor)throw new Error("this pieces has already being centered. Use recenterAround instead");this.centralAnchor=t}locateAt(t,e){this.centerAround(n(t,e))}isAt(t,e){return this.centralAnchor.isAt(t,e)}recenterAround(t,e=!1){const[i,r]=t.diff(this.centralAnchor);this.translate(i,r,e)}relocateTo(t,e,i=!1){this.recenterAround(n(t,e),i)}translate(t,e,i=!1){r.isNull(t,e)||(this.centralAnchor.translate(t,e),i||this.fireTranslate(t,e))}push(t,e,i=!1,r=[this]){this.translate(t,e,i);const n=this.presentConnections.filter(t=>-1===r.indexOf(t));r.push(...n),n.forEach(i=>i.push(t,e,!1,r))}drag(t,e,i=!1){r.isNull(t,e)||(this.horizontallyOpenMovement(t)&&this.vericallyOpenMovement(e)?(this.disconnect(),this.translate(t,e,i)):this.push(t,e,i))}drop(){this.puzzle.autoconnectWith(this)}dragAndDrop(t,e){this.drag(t,e),this.drop()}vericallyOpenMovement(t){return s.vertical.openMovement(this,t)}horizontallyOpenMovement(t){return s.horizontal.openMovement(this,t)}canConnectHorizontallyWith(t){return s.horizontal.canConnectWith(this,t,this.proximity)}canConnectVerticallyWith(t){return s.vertical.canConnectWith(this,t,this.proximity)}verticallyCloseTo(t){return s.vertical.closeTo(this,t,this.proximity)}horizontallyCloseTo(t){return s.horizontal.closeTo(this,t,this.proximity)}verticallyMatch(t){return s.vertical.match(this,t)}horizontallyMatch(t){return s.horizontal.match(this,t)}get connected(){return!!(this.upConnection||this.downConnection||this.leftConnection||this.rightConnection)}get downAnchor(){return this.centralAnchor.translated(0,this.size)}get rightAnchor(){return this.centralAnchor.translated(this.size,0)}get upAnchor(){return this.centralAnchor.translated(0,-this.size)}get leftAnchor(){return this.centralAnchor.translated(-this.size,0)}get size(){return this.puzzle.pieceSize}get proximity(){return this.puzzle.proximity}get id(){return this.metadata.id}export({compact:t=!1}={}){const e={centralAnchor:this.centralAnchor&&this.centralAnchor.export(),structure:h.serialize(this),metadata:this.metadata};return t?e:Object.assign(e,{connections:l(this.connections,t=>({id:t.id}))})}static import(t){const e=new u(h.deserialize(t.structure));return t.centralAnchor&&e.centerAround(o.import(t.centralAnchor)),t.metadata&&e.annotate(t.metadata),e}}t.exports=u},function(t,e){function i(t,e,i,r){return t===i&&e===r}t.exports={isNull:function(t,e){return i(t,e,0,0)},diff:function(t,e,i,r){return[t-i,e-r]},equal:i}},function(t,e,i){const r=i(7);function n(t,e){return{x:t,y:e}}t.exports={position:n,copy:function({x:t,y:e}){return{x:t,y:e}},equal:function(t,e){return r.equal(t.x,t.y,e.x,e.y)},origin:function(){return n(0,0)},update:function(t,e,i){t.x=e,t.y=i},diff:function(t,e){return r.diff(t.x,t.y,e.x,e.y)}}},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(4),h=i(16),c=i(2),l=i(1),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.children=new o.Collection,e}return n(e,t),e.prototype.getChildren=function(t){if(!t)return this.children;var e=new o.Collection;return this.children.each((function(i){t(i)&&e.push(i)})),e},e.prototype.hasChildren=function(){return this.getChildren().length>0},e.prototype.removeChildren=function(){for(var t,e=0;e<this.children.length;e++)(t=this.children[e]).parent=null,t.index=0,t.remove();return this.children=new o.Collection,this},e.prototype.destroyChildren=function(){for(var t,e=0;e<this.children.length;e++)(t=this.children[e]).parent=null,t.index=0,t.destroy();return this.children=new o.Collection,this},e.prototype.add=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(arguments.length>1){for(var i=0;i<arguments.length;i++)this.add(arguments[i]);return this}var r=t[0];if(r.getParent())return r.moveTo(this),this;var n=this.children;return this._validateAdd(r),r._clearCaches(),r.index=n.length,r.parent=this,n.push(r),this._fire("add",{child:r}),this},e.prototype.destroy=function(){return this.hasChildren()&&this.destroyChildren(),t.prototype.destroy.call(this),this},e.prototype.find=function(t){return this._generalFind(t,!1)},e.prototype.get=function(t){return o.Util.warn("collection.get() method is deprecated. Please use collection.find() instead."),this.find(t)},e.prototype.findOne=function(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0},e.prototype._generalFind=function(t,e){var i=[];return this._descendants((function(r){var n=r._isMatch(t);return n&&i.push(r),!(!n||!e)})),o.Collection.toCollection(i)},e.prototype._descendants=function(t){for(var e=0;e<this.children.length;e++){var i=this.children[e];if(t(i))return!0;if(i.hasChildren()&&i._descendants(t))return!0}return!1},e.prototype.toObject=function(){var t=s.Node.prototype.toObject.call(this);t.children=[];for(var e=this.getChildren(),i=e.length,r=0;r<i;r++){var n=e[r];t.children.push(n.toObject())}return t},e.prototype.isAncestorOf=function(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1},e.prototype.clone=function(t){var e=s.Node.prototype.clone.call(this,t);return this.getChildren().each((function(t){e.add(t.clone())})),e},e.prototype.getAllIntersections=function(t){var e=[];return this.find("Shape").each((function(i){i.isVisible()&&i.intersects(t)&&e.push(i)})),e},e.prototype._setChildrenIndices=function(){this.children.each((function(t,e){t.index=e}))},e.prototype.drawScene=function(t,e,i){var r=this.getLayer(),n=t||r&&r.getCanvas(),o=n&&n.getContext(),a=this._getCanvasCache(),s=a&&a.scene;return(this.isVisible()||i)&&(!i&&s?(o.save(),r._applyTransform(this,o,e),this._drawCachedSceneCanvas(o),o.restore()):this._drawChildren(n,"drawScene",e,!1,i,i)),this},e.prototype.drawHit=function(t,e,i){var r=this.getLayer(),n=t||r&&r.hitCanvas,o=n&&n.getContext(),a=this._getCanvasCache(),s=a&&a.hit;return(this.shouldDrawHit(n)||i)&&(!i&&s?(o.save(),r._applyTransform(this,o,e),this._drawCachedHitCanvas(o),o.restore()):this._drawChildren(n,"drawHit",e,!1,i,i)),this},e.prototype._drawChildren=function(t,e,i,r,n,o){var a,s,h=this.getLayer(),c=t&&t.getContext(),l=this.clipWidth(),u=this.clipHeight(),d=this.clipFunc(),p=l&&u||d;if(p&&h){c.save();var f=this.getAbsoluteTransform(i),g=f.getMatrix();c.transform(g[0],g[1],g[2],g[3],g[4],g[5]),c.beginPath(),d?d.call(this,c,this):(a=this.clipX(),s=this.clipY(),c.rect(a,s,l,u)),c.clip(),g=f.copy().invert().getMatrix(),c.transform(g[0],g[1],g[2],g[3],g[4],g[5])}var y="source-over"!==this.globalCompositeOperation()&&!o&&"drawScene"===e;y&&h&&(c.save(),c._applyGlobalCompositeOperation(this)),this.children.each((function(o){o[e](t,i,r,n)})),y&&h&&c.restore(),p&&h&&c.restore()},e.prototype.shouldDrawHit=function(t){if(t&&t.isCache)return!0;var e=this.getLayer(),i=!1;h.DD._dragElements.forEach((function(t){"dragging"===t.dragStatus&&t.node.getLayer()===e&&(i=!0)}));var r=!l.Konva.hitOnDragEnabled&&i;return e&&e.hitGraphEnabled()&&this.isVisible()&&!r},e.prototype.getClientRect=function(t){var e,i,r,n,o=(t=t||{}).skipTransform,a=t.relativeTo,s={x:1/0,y:1/0,width:0,height:0},h=this;this.children.each((function(o){if(o.visible()){var a=o.getClientRect({relativeTo:h,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===a.width&&0===a.height||(void 0===e?(e=a.x,i=a.y,r=a.x+a.width,n=a.y+a.height):(e=Math.min(e,a.x),i=Math.min(i,a.y),r=Math.max(r,a.x+a.width),n=Math.max(n,a.y+a.height)))}}));for(var c=this.find("Shape"),l=!1,u=0;u<c.length;u++){if(c[u]._isVisible(this)){l=!0;break}}return s=l&&void 0!==e?{x:e,y:i,width:r-e,height:n-i}:{x:0,y:0,width:0,height:0},o?s:this._transformedRect(s,a)},e}(s.Node);e.Container=u,a.Factory.addComponentsGetterSetter(u,"clip",["x","y","width","height"]),a.Factory.addGetterSetter(u,"clipX",void 0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clipY",void 0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clipWidth",void 0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clipHeight",void 0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clipFunc"),o.Collection.mapMethods(u)},function(t,e,i){const r=i(35),n=i(7),{position:o}=i(8);class a{constructor(t,e){this.x=t,this.y=e}equal(t){return this.isAt(t.x,t.y)}isAt(t,e){return n.equal(this.x,this.y,t,e)}translated(t,e){return this.copy().translate(t,e)}translate(t,e){return this.x+=t,this.y+=e,this}closeTo(t,e){return r(this.x,t.x-e,t.x+e)&&r(this.y,t.y-e,t.y+e)}copy(){return new a(this.x,this.y)}diff(t){return n.diff(this.x,this.y,t.x,t.y)}asPoint(){return[this.x,this.y]}asPosition(){return o(this.x,this.y)}export(){return this.asPosition()}static atRandom(t,e){return new a(Math.random()*t,Math.random()*e)}static import(t){return s(t.x,t.y)}}function s(t,e){return new a(t,e)}t.exports={anchor:s,Anchor:a}},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o,a=i(3),s=i(27),h=i(1),c=i(0),l=i(2);var u=function(){function t(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||h.Konva.pixelRatio||function(){if(o)return o;var t=a.Util.createCanvasElement().getContext("2d");return o=(h.Konva._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}();this.pixelRatio=e,this._canvas=a.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}return t.prototype.getContext=function(){return this.context},t.prototype.getPixelRatio=function(){return this.pixelRatio},t.prototype.setPixelRatio=function(t){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)},t.prototype.setWidth=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)},t.prototype.setHeight=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)},t.prototype.getWidth=function(){return this.width},t.prototype.getHeight=function(){return this.height},t.prototype.setSize=function(t,e){this.setWidth(t||0),this.setHeight(e||0)},t.prototype.toDataURL=function(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return a.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}},t}();e.Canvas=u,c.Factory.addGetterSetter(u,"pixelRatio",void 0,l.getNumberValidator());var d=function(t){function e(e){void 0===e&&(e={width:0,height:0});var i=t.call(this,e)||this;return i.context=new s.SceneContext(i),i.setSize(e.width,e.height),i}return n(e,t),e}(u);e.SceneCanvas=d;var p=function(t){function e(e){void 0===e&&(e={width:0,height:0});var i=t.call(this,e)||this;return i.hitCanvas=!0,i.context=new s.HitContext(i),i.setSize(e.width,e.height),i}return n(e,t),e}(u);e.HitCanvas=p},function(t,e,i){const{Anchor:r}=i(10),n=i(6),{NullValidator:o}=i(14);class a{constructor({pieceSize:t=2,proximity:e=1}={}){this.pieceSize=t,this.proximity=e,this.pieces=[],this.validator=o}newPiece(t={}){const e=new n(t);return this.addPiece(e),e}addPiece(t){this.pieces.push(t),t.belongTo(this)}addPieces(t){t.forEach(t=>this.addPiece(t))}annotate(t){this.pieces.forEach((e,i)=>e.annotate(t[i]))}relocateTo(t){this.pieces.forEach((e,i)=>e.relocateTo(...t[i]))}autoconnect(){this.pieces.forEach(t=>this.autoconnectWith(t))}disconnect(){this.pieces.forEach(t=>t.disconnect())}autoconnectWith(t){this.pieces.filter(e=>e!==t).forEach(e=>{t.tryConnectWith(e),e.tryConnectWith(t,!0)})}shuffle(t,e){this.disconnect(),this.pieces.forEach(i=>i.recenterAround(r.atRandom(t,e))),this.autoconnect()}translate(t,e){this.pieces.forEach(i=>i.translate(t,e))}onTranslate(t){this.pieces.forEach(e=>e.onTranslate(t))}onConnect(t){this.pieces.forEach(e=>e.onConnect(t))}onDisconnect(t){this.pieces.forEach(e=>e.onDisconnect(t))}onValid(t){this.validator.onValid(t)}get points(){return this.pieces.map(t=>t.centralAnchor.asPoint())}get refs(){return this.points.map(([t,e])=>[t/this.pieceWidth,e/this.pieceWidth])}get metadata(){return this.pieces.map(t=>t.metadata)}get head(){return this.pieces[0]}get headAnchor(){return this.head.centralAnchor}attachValidator(t){this.validator=t}isValid(){return this.validator.isValid(this)}validate(){this.validator.validate(this)}get connected(){return this.pieces.every(t=>t.connected)}get pieceWidth(){return 2*this.pieceSize}export(t={}){return{pieceSize:this.pieceSize,proximity:this.proximity,pieces:this.pieces.map(e=>e.export(t))}}static import(t){const e=new a({pieceSize:t.pieceSize,proximity:t.proximity});return e.addPieces(t.pieces.map(t=>n.import(t))),e.autoconnect(),e}}t.exports=a},function(t,e){const i={isSlot:()=>!1,isTab:()=>!0,isNone:()=>!1,match:t=>t.isSlot(),toString:()=>"Tab",complement:()=>r,serialize:()=>"T"},r={isSlot:()=>!0,isTab:()=>!1,isNone:()=>!1,match:t=>t.isTab(),toString:()=>"Slot",complement:()=>i,serialize:()=>"S"},n={isSlot:()=>!1,isTab:()=>!1,isNone:()=>!0,match:t=>!1,toString:()=>"None",complement:()=>n,serialize:()=>"-"};t.exports={None:n,Slot:r,Tab:i}},function(t,e,i){i(12),i(6);const r=i(7);class n{constructor(){this.validListeners=[],this._valid=!1}validate(t){const e=this._valid;this._valid=this.isValid(t),this._valid&&!e&&this.fireValid(t)}fireValid(t){this.validListeners.forEach(e=>e(t))}onValid(t){this.validListeners.push(t)}get valid(){return this._valid}get isNull(){return!1}}class o extends n{constructor(t){super(),this.condition=t}isValid(t){return this.condition(t)}}o.connected=t=>t.connected,o.relativeRefs=t=>e=>{function i(i,n,o){const[a,s]=t[o];return r.diff(i,n,a*e.pieceWidth,s*e.pieceWidth)}const n=e.points,[o,a]=n[0],[s,h]=i(o,a,0);return n.every(([t,e],n)=>r.equal(s,h,...i(t,e,n)))};const a={isValid:t=>!1,validate(t){},onValid(t){},get valid(){return!1},get isNull(){return!0}};t.exports={PuzzleValidator:o,PieceValidator:class extends n{constructor(t){super(),this.condition=t}isValid(t){return t.pieces.every(t=>this.condition(t))}},NullValidator:a}},function(t,e,i){const r=i(7),n=(i(6),i(12)),o=i(24),{twoAndTwo:a}=i(19),s=i(18),h=i(37),{position:c,...l}=i(8),u=i(20),d=i(25),{PuzzleValidator:p,PieceValidator:f}=i(14);t.exports=class{constructor(t,{width:e,height:i,pieceSize:r=50,proximity:n=10,borderFill:o=0,strokeWidth:a=3,strokeColor:s="black",lineSoftness:c=0,image:l=null,painter:u=null}){this.width=e,this.height=i,this.pieceSize=r,this.borderFill=o,this.imageMetadata=h.asImageMetadata(l),this.strokeWidth=a,this.strokeColor=s,this.lineSoftness=c,this.proximity=n,this._painter=u||new window.headbreaker.painters.Konva,this._initialize(),this._painter.initialize(this,t)}_initialize(){this._puzzle=null,this.figures={},this.templates={}}sketchPiece({structure:t,metadata:e}){d.initialize(e,l.origin()),this.renderPiece(this._newPiece(t,e))}renderPiece(t){const e={label:null,group:null,shape:null};this.figures[t.metadata.id]=e,this._painter.sketch(this,t,e);const i=t.metadata.label;i&&i.text&&(i.fontSize=i.fontSize||.55*this.pieceSize,i.y=i.y||(this.pieceSize-i.fontSize)/2,this._painter.label(this,t,e)),this._bindGroupToPiece(e.group,t),this._bindPieceToGroup(t,e.group)}renderPieces(t){t.forEach(t=>{this._annotatePiecePosition(t),this.renderPiece(t)})}renderPuzzle(t){this.pieceSize=t.pieceWidth,this.proximity=2*t.proximity,this._puzzle=t,this.renderPieces(t.pieces)}autogenerate({horizontalPiecesCount:t=5,verticalPiecesCount:e=5,insertsGenerator:i=a,metadata:r=[]}={}){const n=new o;n.withDimmensions(t,e),n.withInsertsGenerator(i),n.withMetadata(r),this.autogenerateWithManufacturer(n)}autogenerateWithManufacturer(t){t.withStructure(this.settings),this._puzzle=t.build(),this.renderPieces(this.puzzle.pieces)}defineTemplate(t,e){this.templates[t]=e}sketchPieceUsingTemplate(t,e){const i=this.templates[e];if(!i)throw new Error("Unknown template "+t);const r=u.copy(i.metadata);r.id=t,this.sketchPiece({structure:i.structure,metadata:r})}shuffle(t=1){const e=this.pieceSize;this.puzzle.shuffle(t*(this.width-e),t*(this.height-e)),this.puzzle.translate(e,e),this.autoconnected=!0}solve(){this.puzzle.pieces.forEach(t=>{const{x:e,y:i}=t.metadata.targetPosition;t.relocateTo(e,i)}),this.autoconnect()}autoconnect(){this.puzzle.autoconnect(),this.autoconnected=!0}draw(){this.autoconnected||this.autoconnect(),this.autoconnected=!1,this.redraw()}redraw(){this._painter.draw(this)}clear(){this._initialize(),this._painter.reinitialize(this)}attachValidator(t){this.puzzle.attachValidator(t)}attachSolvedValidator(){this.puzzle.attachValidator(new p(d.solved))}attachRelativePositionValidator(){this.puzzle.attachValidator(new p(d.relativePosition))}attachAbsolutePositionValidator(){this.puzzle.attachValidator(new f(d.absolutePosition))}onConnect(t){this.puzzle.onConnect((e,i)=>{t(e,this.getFigure(e),i,this.getFigure(i))})}onDisconnect(t){this.puzzle.onDisconnect((e,i)=>{t(e,this.getFigure(e),i,this.getFigure(i))})}onTranslate(t){this.puzzle.onTranslate((e,i,r)=>{t(e,this.getFigure(e),i,r)})}onValid(t){this.puzzle.onValid(t)}getFigure(t){return this.getFigureById(t.metadata.id)}getFigureById(t){return this.figures[t]}_annotatePiecePosition(t){const e=t.centralAnchor.asPosition();d.initialize(t.metadata,e,l.copy(e))}_bindGroupToPiece(t,e){e.onTranslate((i,r)=>{this._painter.physicalTranslate(this,t,e),this._painter.logicalTranslate(this,e,t)})}_bindPieceToGroup(t,e){this._painter.onDrag(this,t,e,(i,n)=>{r.isNull(i,n)||(t.drag(i,n,!0),this._painter.logicalTranslate(this,t,e),this.redraw())}),this._painter.onDragEnd(this,t,e,()=>{t.drop(),this.puzzle.validate(),this.redraw()})}_imageMetadataFor(t){return this.imageMetadata?{content:this.imageMetadata.content,offset:t.metadata.targetPosition||this.imageMetadata.offset,scale:t.metadata.scale||this.imageMetadata.scale}:h.asImageMetadata(t.metadata.image)}_initializeEmptyPuzzle(){this._puzzle=new n(this.settings)}_newPiece(t,e){let i=this.puzzle.newPiece(s.asStructure(t));return i.annotate(e),i.locateAt(e.currentPosition.x,e.currentPosition.y),i}get puzzle(){return this._puzzle||this._initializeEmptyPuzzle(),this._puzzle}get settings(){return{pieceSize:this.pieceSize/2,proximity:this.proximity}}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=i(3);e.DD={get isDragging(){var t=!1;return e.DD._dragElements.forEach((function(e){"dragging"===e.dragStatus&&(t=!0)})),t},justDragged:!1,get node(){var t;return e.DD._dragElements.forEach((function(e){t=e.node})),t},_dragElements:new Map,_drag:function(t){e.DD._dragElements.forEach((function(e,i){var r=e.node,o=r.getStage();o.setPointersPositions(t),void 0===e.pointerId&&(e.pointerId=n.Util._getFirstPointerId(t));var a=o._changedPointerPositions.find((function(t){return t.id===e.pointerId}));if(a){if("dragging"!==e.dragStatus){var s=r.dragDistance();if(Math.max(Math.abs(a.x-e.startPointerPos.x),Math.abs(a.y-e.startPointerPos.y))<s)return;if(r.startDrag({evt:t}),!r.isDragging())return}r._setDragPosition(t,e),r.fire("dragmove",{type:"dragmove",target:r,evt:t},!0)}}))},_endDragBefore:function(t){e.DD._dragElements.forEach((function(i,n){var o=i.node.getStage();if(t&&o.setPointersPositions(t),o._changedPointerPositions.find((function(t){return t.id===i.pointerId}))){"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(e.DD.justDragged=!0,r.Konva.listenClickTap=!1,i.dragStatus="stopped");var a=i.node.getLayer()||i.node instanceof r.Konva.Stage&&i.node;a&&a.draw()}}))},_endDragAfter:function(t){e.DD._dragElements.forEach((function(i,r){"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:t},!0),"dragging"!==i.dragStatus&&e.DD._dragElements.delete(r)}))}},r.Konva.isBrowser&&(window.addEventListener("mouseup",e.DD._endDragBefore,!0),window.addEventListener("touchend",e.DD._endDragBefore,!0),window.addEventListener("mousemove",e.DD._drag),window.addEventListener("touchmove",e.DD._drag),window.addEventListener("mouseup",e.DD._endDragAfter,!1),window.addEventListener("touchend",e.DD._endDragAfter,!1))},function(t,e){function i(t,e,i=null){return t.map(t=>{const r=t||i;return r&&e(r)})}t.exports={pivot:function(t,e,i=!1){return i?[t,e]:[e,t]},itself:function(t){return t},orthogonalMap:i,orthogonalTransform:function(t,e,r=null){const[n,o,a,s]=i(t,e,r);return{right:n,down:o,left:a,up:s}}}},function(t,e,i){const{Slot:r,Tab:n,None:o}=i(13),{orthogonalMap:a}=i(17);function s(t){return"S"===t?r:"T"===t?n:o}function h(t){if(4!==t.length)throw new Error("structure string must be 4-chars long");return{right:s(t[0]),down:s(t[1]),left:s(t[2]),up:s(t[3])}}t.exports={serialize:function(t){return a([t.right,t.down,t.left,t.up],t=>t.serialize(),o).join("")},deserialize:h,asStructure:function(t){return"string"==typeof t?h(t):t}}},function(t,e,i){const{Tab:r,Slot:n,None:o}=i(13);t.exports={InsertSequence:class{constructor(t){this.generator=t,this.n=0,this._previous,this._current=o}previousComplement(){return this._previous.complement()}current(t){return this.n==t?o:this._current}next(){return this._previous=this._current,this._current=this.generator(this.n++),this._current}},fixed:function(t){return r},flipflop:function(t){return t%2==0?r:n},twoAndTwo:function(t){return t%4<2?r:n},random:function(t){return Math.random()<.5?r:n}}},function(t,e){t.exports={copy:function(t){return JSON.parse(JSON.stringify(t))}}},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(9),s=i(1),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._validateAdd=function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&o.Util.throw("You may only add groups and shapes to groups.")},e}(a.Container);e.Group=h,h.prototype.nodeType="Group",s._registerNode(h),o.Collection.mapMethods(h)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=r.glob.performance&&r.glob.performance.now?function(){return r.glob.performance.now()}:function(){return(new Date).getTime()},o=function(){function t(e,i){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:n(),frameRate:0},this.func=e,this.setLayers(i)}return t.prototype.setLayers=function(t){var e=[];return e=t?t.length>0?t:[t]:[],this.layers=e,this},t.prototype.getLayers=function(){return this.layers},t.prototype.addLayer=function(t){var e,i=this.layers,r=i.length;for(e=0;e<r;e++)if(i[e]._id===t._id)return!1;return this.layers.push(t),!0},t.prototype.isRunning=function(){var e,i=t.animations,r=i.length;for(e=0;e<r;e++)if(i[e].id===this.id)return!0;return!1},t.prototype.start=function(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=n(),t._addAnimation(this),this},t.prototype.stop=function(){return t._removeAnimation(this),this},t.prototype._updateFrameObject=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},t._addAnimation=function(t){this.animations.push(t),this._handleAnimation()},t._removeAnimation=function(t){var e,i=t.id,r=this.animations,n=r.length;for(e=0;e<n;e++)if(r[e].id===i){this.animations.splice(e,1);break}},t._runFrames=function(){var t,e,i,r,o,a,s,h,c={},l=this.animations;for(r=0;r<l.length;r++)if(e=(t=l[r]).layers,i=t.func,t._updateFrameObject(n()),a=e.length,!i||!1!==i.call(t,t.frame))for(o=0;o<a;o++)void 0!==(s=e[o])._id&&(c[s._id]=s);for(h in c)c.hasOwnProperty(h)&&c[h].draw()},t._animationLoop=function(){var e=t;e.animations.length?(e._runFrames(),requestAnimationFrame(e._animationLoop)):e.animRunning=!1},t._handleAnimation=function(){this.animRunning||(this.animRunning=!0,requestAnimationFrame(this._animationLoop))},t.animations=[],t.animIdCounter=0,t.animRunning=!1,t}();e.Animation=o},function(t,e,i){i(6);function r(t,e,i,r){return t.isTab()?e:t.isSlot()?i:r}t.exports={draw:function(t,e=50,i=0){const n=5*i/e;return[0-n,0-n,1,0-n,2,r(t.up,-1-n,1-n,0-n),3,0-n,4+n,0-n,4+n,1,r(t.right,5+n,3+n,4+n),2,4+n,3,4+n,4+n,3,4+n,2,r(t.down,5+n,3+n,4+n),1,4+n,0-n,4+n,0-n,3,r(t.left,-1-n,1-n,0-n),2,0-n,1].map(t=>t*e/5)}}},function(t,e,i){const r=i(12),{Anchor:n}=(i(6),i(10)),{anchor:o}=i(10),{fixed:a,InsertSequence:s}=i(19),h=i(20);class c{constructor(t,e){this.puzzle=t,this.initializeOffset(e)}initializeOffset(t){t?(this.xOffset=t.x,this.yOffset=t.y):(this.xOffset=this.pieceWidth,this.yOffset=this.pieceWidth)}get pieceWidth(){return this.puzzle.pieceWidth}naturalAnchor(t,e){return o(t*this.pieceWidth+this.xOffset,e*this.pieceWidth+this.yOffset)}}t.exports=class{constructor(){this.insertsGenerator=a,this.metadata=[],this.headAnchor=null}withMetadata(t){this.metadata=t}withInsertsGenerator(t){this.insertsGenerator=t||this.insertsGenerator}withHeadAt(t){this.headAnchor=t}withStructure(t){this.structure=t}withDimmensions(t,e){this.width=t,this.height=e}build(){const t=new r(this.structure),e=new c(t,this.headAnchor);let i,n=this._newSequence();for(let r=0;r<this.height;r++){i=this._newSequence(),n.next();for(let o=0;o<this.width;o++){i.next();this._buildPiece(t,i,n).centerAround(e.naturalAnchor(o,r))}}return this._annotateAll(t.pieces),t}_annotateAll(t){t.forEach((t,e)=>this._annotate(t,e))}_annotate(t,e){const i=this.metadata[e],r=i?h.copy(i):{};r.id=r.id||String(e+1),t.annotate(r)}_newSequence(){return new s(this.insertsGenerator)}_buildPiece(t,e,i){return t.newPiece({left:e.previousComplement(),up:i.previousComplement(),right:e.current(this.width),down:i.current(this.height)})}}},function(t,e,i){const r=i(8),n=i(7),{PuzzleValidator:o}=i(14);function a(t){return r.diff(t.metadata.targetPosition,t.centralAnchor.asPosition())}const s=t=>{const[e,i]=a(t.head);return t.pieces.every(t=>n.equal(e,i,...a(t)))};t.exports={initialize:function(t,e,i){t.targetPosition=t.targetPosition||e,t.currentPosition=t.currentPosition||i||r.copy(t.targetPosition)},solved:t=>s(t)&&o.connected(t),relativePosition:s,absolutePosition:t=>r.equal(t.centralAnchor.asPosition(),t.metadata.targetPosition)}},function(t,e,i){i(15),i(6);t.exports=class{initialize(t,e){}reinitialize(t){}draw(t){}sketch(t,e,i){}label(t,e,i){}physicalTranslate(t,e,i){}logicalTranslate(t,e,i){}onDrag(t,e,i,r){}onDragEnd(t,e,i,r){}}},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(1),s=["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"],h=function(){function t(t){this.canvas=t,this._context=t._canvas.getContext("2d"),a.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}return t.prototype.fillShape=function(t){t.fillEnabled()&&this._fill(t)},t.prototype._fill=function(t){},t.prototype.strokeShape=function(t){t.hasStroke()&&this._stroke(t)},t.prototype._stroke=function(t){},t.prototype.fillStrokeShape=function(t){this.fillShape(t),this.strokeShape(t)},t.prototype.getTrace=function(t){var e,i,r,n,a=this.traceArr,s=a.length,h="";for(e=0;e<s;e++)(r=(i=a[e]).method)?(n=i.args,h+=r,t?h+="()":o.Util._isArray(n[0])?h+="(["+n.join(",")+"])":h+="("+n.join(",")+")"):(h+=i.property,t||(h+="="+i.val)),h+=";";return h},t.prototype.clearTrace=function(){this.traceArr=[]},t.prototype._trace=function(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()},t.prototype.reset=function(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)},t.prototype.getCanvas=function(){return this.canvas},t.prototype.clear=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)},t.prototype._applyLineCap=function(t){var e=t.getLineCap();e&&this.setAttr("lineCap",e)},t.prototype._applyOpacity=function(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)},t.prototype._applyLineJoin=function(t){var e=t.getLineJoin();e&&this.setAttr("lineJoin",e)},t.prototype.setAttr=function(t,e){this._context[t]=e},t.prototype.arc=function(t,e,i,r,n,o){this._context.arc(t,e,i,r,n,o)},t.prototype.arcTo=function(t,e,i,r,n){this._context.arcTo(t,e,i,r,n)},t.prototype.beginPath=function(){this._context.beginPath()},t.prototype.bezierCurveTo=function(t,e,i,r,n,o){this._context.bezierCurveTo(t,e,i,r,n,o)},t.prototype.clearRect=function(t,e,i,r){this._context.clearRect(t,e,i,r)},t.prototype.clip=function(){this._context.clip()},t.prototype.closePath=function(){this._context.closePath()},t.prototype.createImageData=function(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0},t.prototype.createLinearGradient=function(t,e,i,r){return this._context.createLinearGradient(t,e,i,r)},t.prototype.createPattern=function(t,e){return this._context.createPattern(t,e)},t.prototype.createRadialGradient=function(t,e,i,r,n,o){return this._context.createRadialGradient(t,e,i,r,n,o)},t.prototype.drawImage=function(t,e,i,r,n,o,a,s,h){var c=arguments,l=this._context;3===c.length?l.drawImage(t,e,i):5===c.length?l.drawImage(t,e,i,r,n):9===c.length&&l.drawImage(t,e,i,r,n,o,a,s,h)},t.prototype.ellipse=function(t,e,i,r,n,o,a,s){this._context.ellipse(t,e,i,r,n,o,a,s)},t.prototype.isPointInPath=function(t,e){return this._context.isPointInPath(t,e)},t.prototype.fill=function(){this._context.fill()},t.prototype.fillRect=function(t,e,i,r){this._context.fillRect(t,e,i,r)},t.prototype.strokeRect=function(t,e,i,r){this._context.strokeRect(t,e,i,r)},t.prototype.fillText=function(t,e,i){this._context.fillText(t,e,i)},t.prototype.measureText=function(t){return this._context.measureText(t)},t.prototype.getImageData=function(t,e,i,r){return this._context.getImageData(t,e,i,r)},t.prototype.lineTo=function(t,e){this._context.lineTo(t,e)},t.prototype.moveTo=function(t,e){this._context.moveTo(t,e)},t.prototype.rect=function(t,e,i,r){this._context.rect(t,e,i,r)},t.prototype.putImageData=function(t,e,i){this._context.putImageData(t,e,i)},t.prototype.quadraticCurveTo=function(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)},t.prototype.restore=function(){this._context.restore()},t.prototype.rotate=function(t){this._context.rotate(t)},t.prototype.save=function(){this._context.save()},t.prototype.scale=function(t,e){this._context.scale(t,e)},t.prototype.setLineDash=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)},t.prototype.getLineDash=function(){return this._context.getLineDash()},t.prototype.setTransform=function(t,e,i,r,n,o){this._context.setTransform(t,e,i,r,n,o)},t.prototype.stroke=function(){this._context.stroke()},t.prototype.strokeText=function(t,e,i,r){this._context.strokeText(t,e,i,r)},t.prototype.transform=function(t,e,i,r,n,o){this._context.transform(t,e,i,r,n,o)},t.prototype.translate=function(t,e){this._context.translate(t,e)},t.prototype._enableTrace=function(){var t,e,i=this,r=s.length,n=o.Util._simplifyArray,a=this.setAttr,h=function(t){var r,o=i[t];i[t]=function(){return e=n(Array.prototype.slice.call(arguments,0)),r=o.apply(i,arguments),i._trace({method:t,args:e}),r}};for(t=0;t<r;t++)h(s[t]);i.setAttr=function(){a.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})}},t.prototype._applyGlobalCompositeOperation=function(t){var e=t.getGlobalCompositeOperation();"source-over"!==e&&this.setAttr("globalCompositeOperation",e)},t}();e.Context=h,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(h.prototype,t,{get:function(){return this._context[t]},set:function(e){this._context[t]=e}})}));var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._fillColor=function(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)},e.prototype._fillPattern=function(t){var e=t.getFillPatternX(),i=t.getFillPatternY(),r=a.Konva.getAngle(t.getFillPatternRotation()),n=t.getFillPatternOffsetX(),o=t.getFillPatternOffsetY(),s=t.getFillPatternScaleX(),h=t.getFillPatternScaleY();(e||i)&&this.translate(e||0,i||0),r&&this.rotate(r),(s||h)&&this.scale(s,h),(n||o)&&this.translate(-1*n,-1*o),this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)},e.prototype._fillLinearGradient=function(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))},e.prototype._fillRadialGradient=function(t){var e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))},e.prototype._fill=function(t){var e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)this._fillColor(t);else{var r=t.getFillPatternImage();if(r&&"pattern"===i)this._fillPattern(t);else{var n=t.getFillLinearGradientColorStops();if(n&&"linear-gradient"===i)this._fillLinearGradient(t);else{var o=t.getFillRadialGradientColorStops();o&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):n?this._fillLinearGradient(t):o&&this._fillRadialGradient(t)}}}},e.prototype._strokeLinearGradient=function(t){var e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(var o=0;o<r.length;o+=2)n.addColorStop(r[o],r[o+1]);this.setAttr("strokeStyle",n)}},e.prototype._stroke=function(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}},e.prototype._applyShadow=function(t){var e=o.Util,i=e.get(t.getShadowRGBA(),"black"),r=e.get(t.getShadowBlur(),5),n=e.get(t.getShadowOffset(),{x:0,y:0}),a=t.getAbsoluteScale(),s=this.canvas.getPixelRatio(),h=a.x*s,c=a.y*s;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",r*Math.min(Math.abs(h),Math.abs(c))),this.setAttr("shadowOffsetX",n.x*h),this.setAttr("shadowOffsetY",n.y*c)},e}(h);e.SceneContext=c;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._fill=function(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()},e.prototype.strokeShape=function(t){t.hasHitStroke()&&this._stroke(t)},e.prototype._stroke=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 r=t.hitStrokeWidth(),n="auto"===r?t.strokeWidth():r;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}},e}(h);e.HitContext=l},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=new Map,o=void 0!==r.Konva._global.PointerEvent;function a(t){return{evt:t,pointerId:t.pointerId}}function s(t,e){var i=n.get(t);if(i){var r=i.getStage();r&&r.content,n.delete(t),o&&i._fire("lostpointercapture",a(new PointerEvent("lostpointercapture")))}}e.getCapturedShape=function(t){return n.get(t)},e.createEvent=a,e.hasPointerCapture=function(t,e){return n.get(t)===e},e.setPointerCapture=function(t,e){s(t),e.getStage()&&(n.set(t,e),o&&e._fire("gotpointercapture",a(new PointerEvent("gotpointercapture"))))},e.releaseCapture=s},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(9),s=i(4),h=i(0),c=i(11),l=function(t){function e(e){var i=t.call(this,e)||this;return i.canvas=new c.SceneCanvas,i._waitingForDraw=!1,i.on("visibleChange",i._checkVisibility),i._checkVisibility(),i.on("imageSmoothingEnabledChange",i._setSmoothEnabled),i._setSmoothEnabled(),i}return n(e,t),e.prototype.createPNGStream=function(){return this.canvas._canvas.createPNGStream()},e.prototype.getCanvas=function(){return this.canvas},e.prototype.getHitCanvas=function(){return this.hitCanvas},e.prototype.getContext=function(){return this.getCanvas().getContext()},e.prototype.clear=function(t){return this.getContext().clear(t),this},e.prototype.setZIndex=function(e){t.prototype.setZIndex.call(this,e);var i=this.getStage();return i&&(i.content.removeChild(this.getCanvas()._canvas),e<i.children.length-1?i.content.insertBefore(this.getCanvas()._canvas,i.children[e+1].getCanvas()._canvas):i.content.appendChild(this.getCanvas()._canvas)),this},e.prototype.moveToTop=function(){s.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&(t.content.removeChild(this.getCanvas()._canvas),t.content.appendChild(this.getCanvas()._canvas)),!0},e.prototype.moveUp=function(){if(!s.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!!t&&(t.content.removeChild(this.getCanvas()._canvas),this.index<t.children.length-1?t.content.insertBefore(this.getCanvas()._canvas,t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getCanvas()._canvas),!0)},e.prototype.moveDown=function(){if(s.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content.removeChild(this.getCanvas()._canvas),t.content.insertBefore(this.getCanvas()._canvas,e[this.index+1].getCanvas()._canvas)}return!0}return!1},e.prototype.moveToBottom=function(){if(s.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content.removeChild(this.getCanvas()._canvas),t.content.insertBefore(this.getCanvas()._canvas,e[1].getCanvas()._canvas)}return!0}return!1},e.prototype.getLayer=function(){return this},e.prototype.hitGraphEnabled=function(){return!0},e.prototype.remove=function(){var t=this.getCanvas()._canvas;return s.Node.prototype.remove.call(this),t&&t.parentNode&&o.Util._isInDocument(t)&&t.parentNode.removeChild(t),this},e.prototype.getStage=function(){return this.parent},e.prototype.setSize=function(t){var e=t.width,i=t.height;return this.canvas.setSize(e,i),this._setSmoothEnabled(),this},e.prototype._toKonvaCanvas=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(),s.Node.prototype._toKonvaCanvas.call(this,t)},e.prototype._checkVisibility=function(){var t=this.visible();this.canvas._canvas.style.display=t?"block":"none"},e.prototype._setSmoothEnabled=function(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()},e.prototype.getWidth=function(){if(this.parent)return this.parent.width()},e.prototype.setWidth=function(){o.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')},e.prototype.getHeight=function(){if(this.parent)return this.parent.height()},e.prototype.setHeight=function(){o.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')},e.prototype.getIntersection=function(t,e){return null},e.prototype.batchDraw=function(){var t=this;return this._waitingForDraw||(this._waitingForDraw=!0,o.Util.requestAnimFrame((function(){t.draw(),t._waitingForDraw=!1}))),this},e.prototype._applyTransform=function(t,e,i){var r=t.getAbsoluteTransform(i).getMatrix();e.transform(r[0],r[1],r[2],r[3],r[4],r[5])},e}(a.Container);e.BaseLayer=l,l.prototype.nodeType="BaseLayer",h.Factory.addGetterSetter(l,"imageSmoothingEnabled",!0),h.Factory.addGetterSetter(l,"clearBeforeDraw",!0),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),o=this&&this.__spreadArrays||function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var r=Array(t),n=0;for(e=0;e<i;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,n++)r[n]=o[a];return r};Object.defineProperty(e,"__esModule",{value:!0});var a=i(3),s=i(0),h=i(5),c=i(2),l=i(1),u=function(t){function e(e){var i=t.call(this,e)||this;return i.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")})),i}return n(e,t),e.prototype._sceneFunc=function(t){var e,i,r,n=this.points(),o=n.length,a=this.tension(),s=this.closed(),h=this.bezier();if(o){if(t.beginPath(),t.moveTo(n[0],n[1]),0!==a&&o>4){for(i=(e=this.getTensionPoints()).length,r=s?0:4,s||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);r<i-2;)t.bezierCurveTo(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);s||t.quadraticCurveTo(e[i-2],e[i-1],n[o-2],n[o-1])}else if(h)for(r=2;r<o;)t.bezierCurveTo(n[r++],n[r++],n[r++],n[r++],n[r++],n[r++]);else for(r=2;r<o;r+=2)t.lineTo(n[r],n[r+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}},e.prototype.getTensionPoints=function(){return this._getCache("tensionPoints",this._getTensionPoints)},e.prototype._getTensionPoints=function(){return this.closed()?this._getTensionPointsClosed():a.Util._expandPoints(this.points(),this.tension())},e.prototype._getTensionPointsClosed=function(){var t=this.points(),e=t.length,i=this.tension(),r=a.Util._getControlPoints(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),n=a.Util._getControlPoints(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),o=a.Util._expandPoints(t,i);return[r[2],r[3]].concat(o).concat([n[0],n[1],t[e-2],t[e-1],n[2],n[3],r[0],r[1],t[0],t[1]])},e.prototype.getWidth=function(){return this.getSelfRect().width},e.prototype.getHeight=function(){return this.getSelfRect().height},e.prototype.getSelfRect=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,r=(t=0!==this.tension()?o([t[0],t[1]],this._getTensionPoints(),[t[t.length-2],t[t.length-1]]):this.points())[0],n=t[0],a=t[1],s=t[1],h=0;h<t.length/2;h++)e=t[2*h],i=t[2*h+1],r=Math.min(r,e),n=Math.max(n,e),a=Math.min(a,i),s=Math.max(s,i);return{x:r,y:a,width:n-r,height:s-a}},e}(h.Shape);e.Line=u,u.prototype.className="Line",u.prototype._attrsAffectingSize=["points","bezier","tension"],l._registerNode(u),s.Factory.addGetterSetter(u,"closed",!1),s.Factory.addGetterSetter(u,"bezier",!1),s.Factory.addGetterSetter(u,"tension",0,c.getNumberValidator()),s.Factory.addGetterSetter(u,"points",[],c.getNumberArrayValidator()),a.Collection.mapMethods(u)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(1),c=function(t){function e(i){var r=t.call(this,i)||this;r.dataArray=[],r.pathLength=0,r.dataArray=e.parsePathData(r.data()),r.pathLength=0;for(var n=0;n<r.dataArray.length;++n)r.pathLength+=r.dataArray[n].pathLength;return r.on("dataChange.konva",(function(){this.dataArray=e.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength})),r}return n(e,t),e.prototype._sceneFunc=function(t){var e=this.dataArray;t.beginPath();for(var i=!1,r=0;r<e.length;r++){var n=e[r].command,o=e[r].points;switch(n){case"L":t.lineTo(o[0],o[1]);break;case"M":t.moveTo(o[0],o[1]);break;case"C":t.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":t.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":var a=o[0],s=o[1],h=o[2],c=o[3],l=o[4],u=o[5],d=o[6],p=o[7],f=h>c?h:c,g=h>c?1:h/c,y=h>c?c/h:1;t.translate(a,s),t.rotate(d),t.scale(g,y),t.arc(0,0,f,l,l+u,1-p),t.scale(1/g,1/y),t.rotate(-d),t.translate(-a,-s);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)},e.prototype.getSelfRect=function(){var t=[];this.dataArray.forEach((function(i){if("A"===i.command){var r=i.points[4],n=i.points[5],o=i.points[4]+n,a=Math.PI/180;if(Math.abs(r-o)<a&&(a=Math.abs(r-o)),n<0)for(var s=r-a;s>o;s-=a){var h=e.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);t.push(h.x,h.y)}else for(s=r+a;s<o;s+=a){h=e.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);t.push(h.x,h.y)}}else if("C"===i.command)for(s=0;s<=1;s+=.01){h=e.getPointOnCubicBezier(s,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);t.push(h.x,h.y)}else t=t.concat(i.points)}));for(var i,r,n=t[0],o=t[0],a=t[1],s=t[1],h=0;h<t.length/2;h++)i=t[2*h],r=t[2*h+1],isNaN(i)||(n=Math.min(n,i),o=Math.max(o,i)),isNaN(r)||(a=Math.min(a,r),s=Math.max(s,r));return{x:Math.round(n),y:Math.round(a),width:Math.round(o-n),height:Math.round(s-a)}},e.prototype.getLength=function(){return this.pathLength},e.prototype.getPointAtLength=function(t){var i,r=0,n=this.dataArray.length;if(!n)return null;for(;r<n&&t>this.dataArray[r].pathLength;)t-=this.dataArray[r].pathLength,++r;if(r===n)return{x:(i=this.dataArray[r-1].points.slice(-2))[0],y:i[1]};if(t<.01)return{x:(i=this.dataArray[r].points.slice(0,2))[0],y:i[1]};var o=this.dataArray[r],a=o.points;switch(o.command){case"L":return e.getPointOnLine(t,o.start.x,o.start.y,a[0],a[1]);case"C":return e.getPointOnCubicBezier(t/o.pathLength,o.start.x,o.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return e.getPointOnQuadraticBezier(t/o.pathLength,o.start.x,o.start.y,a[0],a[1],a[2],a[3]);case"A":var s=a[0],h=a[1],c=a[2],l=a[3],u=a[4],d=a[5],p=a[6];return u+=d*t/o.pathLength,e.getPointOnEllipticalArc(s,h,c,l,u,p)}return null},e.getLineLength=function(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))},e.getPointOnLine=function(t,e,i,r,n,o,a){void 0===o&&(o=e),void 0===a&&(a=i);var s=(n-i)/(r-e+1e-8),h=Math.sqrt(t*t/(1+s*s));r<e&&(h*=-1);var c,l=s*h;if(r===e)c={x:o,y:a+l};else if((a-i)/(o-e+1e-8)===s)c={x:o+h,y:a+l};else{var u,d,p=this.getLineLength(e,i,r,n);if(p<1e-8)return;var f=(o-e)*(r-e)+(a-i)*(n-i);u=e+(f/=p*p)*(r-e),d=i+f*(n-i);var g=this.getLineLength(o,a,u,d),y=Math.sqrt(t*t-g*g);h=Math.sqrt(y*y/(1+s*s)),r<e&&(h*=-1),c={x:u+h,y:d+(l=s*h)}}return c},e.getPointOnCubicBezier=function(t,e,i,r,n,o,a,s,h){function c(t){return t*t*t}function l(t){return 3*t*t*(1-t)}function u(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*c(t)+o*l(t)+r*u(t)+e*d(t),y:h*c(t)+a*l(t)+n*u(t)+i*d(t)}},e.getPointOnQuadraticBezier=function(t,e,i,r,n,o,a){function s(t){return t*t}function h(t){return 2*t*(1-t)}function c(t){return(1-t)*(1-t)}return{x:o*s(t)+r*h(t)+e*c(t),y:a*s(t)+n*h(t)+i*c(t)}},e.getPointOnEllipticalArc=function(t,e,i,r,n,o){var a=Math.cos(o),s=Math.sin(o),h=i*Math.cos(n),c=r*Math.sin(n);return{x:t+(h*a-c*s),y:e+(h*s+c*a)}},e.parsePathData=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 r=0;r<i.length;r++)e=e.replace(new RegExp(i[r],"g"),"|"+i[r]);var n,o=e.split("|"),a=[],s=[],h=0,c=0,l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<o.length;r++){var u=o[r],d=u.charAt(0);for(u=u.slice(1),s.length=0;n=l.exec(u);)s.push(n[0]);for(var p=[],f=0,g=s.length;f<g;f++){var y=parseFloat(s[f]);isNaN(y)?p.push(0):p.push(y)}for(;p.length>0&&!isNaN(p[0]);){var v,_,m,b,x,S,w,C,P,A,T=null,k=[],M=h,F=c;switch(d){case"l":h+=p.shift(),c+=p.shift(),T="L",k.push(h,c);break;case"L":h=p.shift(),c=p.shift(),k.push(h,c);break;case"m":var O=p.shift(),G=p.shift();if(h+=O,c+=G,T="M",a.length>2&&"z"===a[a.length-1].command)for(var D=a.length-2;D>=0;D--)if("M"===a[D].command){h=a[D].points[0]+O,c=a[D].points[1]+G;break}k.push(h,c),d="l";break;case"M":h=p.shift(),c=p.shift(),T="M",k.push(h,c),d="L";break;case"h":h+=p.shift(),T="L",k.push(h,c);break;case"H":h=p.shift(),T="L",k.push(h,c);break;case"v":c+=p.shift(),T="L",k.push(h,c);break;case"V":c=p.shift(),T="L",k.push(h,c);break;case"C":k.push(p.shift(),p.shift(),p.shift(),p.shift()),h=p.shift(),c=p.shift(),k.push(h,c);break;case"c":k.push(h+p.shift(),c+p.shift(),h+p.shift(),c+p.shift()),h+=p.shift(),c+=p.shift(),T="C",k.push(h,c);break;case"S":_=h,m=c,"C"===(v=a[a.length-1]).command&&(_=h+(h-v.points[2]),m=c+(c-v.points[3])),k.push(_,m,p.shift(),p.shift()),h=p.shift(),c=p.shift(),T="C",k.push(h,c);break;case"s":_=h,m=c,"C"===(v=a[a.length-1]).command&&(_=h+(h-v.points[2]),m=c+(c-v.points[3])),k.push(_,m,h+p.shift(),c+p.shift()),h+=p.shift(),c+=p.shift(),T="C",k.push(h,c);break;case"Q":k.push(p.shift(),p.shift()),h=p.shift(),c=p.shift(),k.push(h,c);break;case"q":k.push(h+p.shift(),c+p.shift()),h+=p.shift(),c+=p.shift(),T="Q",k.push(h,c);break;case"T":_=h,m=c,"Q"===(v=a[a.length-1]).command&&(_=h+(h-v.points[0]),m=c+(c-v.points[1])),h=p.shift(),c=p.shift(),T="Q",k.push(_,m,h,c);break;case"t":_=h,m=c,"Q"===(v=a[a.length-1]).command&&(_=h+(h-v.points[0]),m=c+(c-v.points[1])),h+=p.shift(),c+=p.shift(),T="Q",k.push(_,m,h,c);break;case"A":b=p.shift(),x=p.shift(),S=p.shift(),w=p.shift(),C=p.shift(),P=h,A=c,h=p.shift(),c=p.shift(),T="A",k=this.convertEndpointToCenterParameterization(P,A,h,c,w,C,b,x,S);break;case"a":b=p.shift(),x=p.shift(),S=p.shift(),w=p.shift(),C=p.shift(),P=h,A=c,h+=p.shift(),c+=p.shift(),T="A",k=this.convertEndpointToCenterParameterization(P,A,h,c,w,C,b,x,S)}a.push({command:T||d,points:k,start:{x:M,y:F},pathLength:this.calcLength(M,F,T||d,k)})}"z"!==d&&"Z"!==d||a.push({command:"z",points:[],start:void 0,pathLength:0})}return a},e.calcLength=function(t,i,r,n){var o,a,s,h,c=e;switch(r){case"L":return c.getLineLength(t,i,n[0],n[1]);case"C":for(o=0,a=c.getPointOnCubicBezier(0,t,i,n[0],n[1],n[2],n[3],n[4],n[5]),h=.01;h<=1;h+=.01)s=c.getPointOnCubicBezier(h,t,i,n[0],n[1],n[2],n[3],n[4],n[5]),o+=c.getLineLength(a.x,a.y,s.x,s.y),a=s;return o;case"Q":for(o=0,a=c.getPointOnQuadraticBezier(0,t,i,n[0],n[1],n[2],n[3]),h=.01;h<=1;h+=.01)s=c.getPointOnQuadraticBezier(h,t,i,n[0],n[1],n[2],n[3]),o+=c.getLineLength(a.x,a.y,s.x,s.y),a=s;return o;case"A":o=0;var l=n[4],u=n[5],d=n[4]+u,p=Math.PI/180;if(Math.abs(l-d)<p&&(p=Math.abs(l-d)),a=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),u<0)for(h=l-p;h>d;h-=p)s=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),o+=c.getLineLength(a.x,a.y,s.x,s.y),a=s;else for(h=l+p;h<d;h+=p)s=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),o+=c.getLineLength(a.x,a.y,s.x,s.y),a=s;return s=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],d,0),o+=c.getLineLength(a.x,a.y,s.x,s.y)}return 0},e.convertEndpointToCenterParameterization=function(t,e,i,r,n,o,a,s,h){var c=h*(Math.PI/180),l=Math.cos(c)*(t-i)/2+Math.sin(c)*(e-r)/2,u=-1*Math.sin(c)*(t-i)/2+Math.cos(c)*(e-r)/2,d=l*l/(a*a)+u*u/(s*s);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));var p=Math.sqrt((a*a*(s*s)-a*a*(u*u)-s*s*(l*l))/(a*a*(u*u)+s*s*(l*l)));n===o&&(p*=-1),isNaN(p)&&(p=0);var f=p*a*u/s,g=p*-s*l/a,y=(t+i)/2+Math.cos(c)*f-Math.sin(c)*g,v=(e+r)/2+Math.sin(c)*f+Math.cos(c)*g,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},m=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},b=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(m(t,e))},x=b([1,0],[(l-f)/a,(u-g)/s]),S=[(l-f)/a,(u-g)/s],w=[(-1*l-f)/a,(-1*u-g)/s],C=b(S,w);return m(S,w)<=-1&&(C=Math.PI),m(S,w)>=1&&(C=0),0===o&&C>0&&(C-=2*Math.PI),1===o&&C<0&&(C+=2*Math.PI),[y,v,a,s,x,C,c,o]},e}(s.Shape);e.Path=c,c.prototype.className="Path",c.prototype._attrsAffectingSize=["data"],h._registerNode(c),a.Factory.addGetterSetter(c,"data"),o.Collection.mapMethods(c)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(1),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){var e=this.cornerRadius(),i=this.width(),r=this.height();if(t.beginPath(),e){var n=0,o=0,a=0,s=0;"number"==typeof e?n=o=a=s=Math.min(e,i/2,r/2):(n=Math.min(e[0],i/2,r/2),o=Math.min(e[1],i/2,r/2),s=Math.min(e[2],i/2,r/2),a=Math.min(e[3],i/2,r/2)),t.moveTo(n,0),t.lineTo(i-o,0),t.arc(i-o,o,o,3*Math.PI/2,0,!1),t.lineTo(i,r-s),t.arc(i-s,r-s,s,0,Math.PI/2,!1),t.lineTo(a,r),t.arc(a,r-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,n),t.arc(n,n,n,Math.PI,3*Math.PI/2,!1)}else t.rect(0,0,i,r);t.closePath(),t.fillStrokeShape(this)},e}(s.Shape);e.Rect=c,c.prototype.className="Rect",h._registerNode(c),a.Factory.addGetterSetter(c,"cornerRadius",0),o.Collection.mapMethods(c)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o,a=i(3),s=i(0),h=i(5),c=i(1),l=i(2),u=i(1),d=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],p=d.length;function f(){return o||(o=a.Util.createCanvasElement().getContext("2d"))}String.prototype.trimRight;var g=function(t){function e(e){var i=t.call(this,function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(e))||this;i._partialTextX=0,i._partialTextY=0;for(var r=0;r<p;r++)i.on(d[r]+"Change.konva",i._setTextData);return i._setTextData(),i}return n(e,t),e.prototype._sceneFunc=function(t){var e,i=this.padding(),r=this.fontSize(),n=this.lineHeight()*r,o=this.textArr,a=o.length,s=this.verticalAlign(),h=0,c=this.align(),l=this.getWidth(),u=this.letterSpacing(),d=this.fill(),p=this.textDecoration(),f=-1!==p.indexOf("underline"),g=-1!==p.indexOf("line-through"),y=0,v=(y=n/2,0),_=0;for(t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline","middle"),t.setAttr("textAlign","left"),"middle"===s?h=(this.getHeight()-a*n-2*i)/2:"bottom"===s&&(h=this.getHeight()-a*n-2*i),t.translate(i,h+i),e=0;e<a;e++){v=0,_=0;var m,b,x,S=o[e],w=S.text,C=S.width,P=e!==a-1;if(t.save(),"right"===c?v+=l-C-2*i:"center"===c&&(v+=(l-C-2*i)/2),f&&(t.save(),t.beginPath(),t.moveTo(v,y+_+Math.round(r/2)),b=0===(m=w.split(" ").length-1),x="justify"===c&&P&&!b?l-2*i:C,t.lineTo(v+Math.round(x),y+_+Math.round(r/2)),t.lineWidth=r/15,t.strokeStyle=d,t.stroke(),t.restore()),g&&(t.save(),t.beginPath(),t.moveTo(v,y+_),b=0===(m=w.split(" ").length-1),x="justify"===c&&P&&!b?l-2*i:C,t.lineTo(v+Math.round(x),y+_),t.lineWidth=r/15,t.strokeStyle=d,t.stroke(),t.restore()),0!==u||"justify"===c){m=w.split(" ").length-1;for(var A=0;A<w.length;A++){var T=w[A];" "===T&&e!==a-1&&"justify"===c&&(v+=Math.floor((l-2*i-C)/m)),this._partialTextX=v,this._partialTextY=y+_,this._partialText=T,t.fillStrokeShape(this),v+=Math.round(this.measureSize(T).width)+u}}else this._partialTextX=v,this._partialTextY=y+_,this._partialText=w,t.fillStrokeShape(this);t.restore(),a>1&&(y+=n)}},e.prototype._hitFunc=function(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)},e.prototype.setText=function(t){var e=a.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this},e.prototype.getWidth=function(){return"auto"===this.attrs.width||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width},e.prototype.getHeight=function(){return"auto"===this.attrs.height||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height},e.prototype.getTextWidth=function(){return this.textWidth},e.prototype.getTextHeight=function(){return a.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight},e.prototype.measureSize=function(t){var e,i=f(),r=this.fontSize();return i.save(),i.font=this._getContextFont(),e=i.measureText(t),i.restore(),{width:e.width,height:r}},e.prototype._getContextFont=function(){return c.Konva.UA.isIE?this.fontStyle()+" "+this.fontSize()+"px "+this.fontFamily():this.fontStyle()+" "+this.fontVariant()+" "+this.fontSize()+"px "+this.fontFamily()},e.prototype._addTextLine=function(t){"justify"===this.align()&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e})},e.prototype._getTextWidth=function(t){var e=this.letterSpacing(),i=t.length;return f().measureText(t).width+(i?e*(i-1):0)},e.prototype._setTextData=function(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,n=this.attrs.width,o=this.attrs.height,a="auto"!==n&&void 0!==n,s="auto"!==o&&void 0!==o,h=this.padding(),c=n-2*h,l=o-2*h,u=0,d=this.wrap(),p="none"!==d,g="char"!==d&&p,y=this.ellipsis()&&!p;this.textArr=[],f().font=this._getContextFont();for(var v=y?this._getTextWidth("…"):0,_=0,m=t.length;_<m;++_){var b=t[_],x=this._getTextWidth(b);if(a&&x>c)for(;b.length>0;){for(var S=0,w=b.length,C="",P=0;S<w;){var A=S+w>>>1,T=b.slice(0,A+1),k=this._getTextWidth(T)+v;k<=c?(S=A+1,C=T+(y?"…":""),P=k):w=A}if(!C)break;if(g){var M,F=b[C.length];(M=(" "===F||"-"===F)&&P<=c?C.length:Math.max(C.lastIndexOf(" "),C.lastIndexOf("-"))+1)>0&&(S=M,C=C.slice(0,S),P=this._getTextWidth(C))}if(C=C.trimRight(),this._addTextLine(C),i=Math.max(i,P),u+=r,!p||s&&u+r>l)break;if((b=(b=b.slice(S)).trimLeft()).length>0&&(x=this._getTextWidth(b))<=c){this._addTextLine(b),u+=r,i=Math.max(i,x);break}}else this._addTextLine(b),u+=r,i=Math.max(i,x);if(s&&u+r>l)break}this.textHeight=e,this.textWidth=i},e.prototype.getStrokeScaleEnabled=function(){return!0},e}(h.Shape);e.Text=g,g.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},g.prototype._strokeFunc=function(t){t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},g.prototype.className="Text",g.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight"],u._registerNode(g),s.Factory.overWriteSetter(g,"width",l.getNumberOrAutoValidator()),s.Factory.overWriteSetter(g,"height",l.getNumberOrAutoValidator()),s.Factory.addGetterSetter(g,"fontFamily","Arial"),s.Factory.addGetterSetter(g,"fontSize",12,l.getNumberValidator()),s.Factory.addGetterSetter(g,"fontStyle","normal"),s.Factory.addGetterSetter(g,"fontVariant","normal"),s.Factory.addGetterSetter(g,"padding",0,l.getNumberValidator()),s.Factory.addGetterSetter(g,"align","left"),s.Factory.addGetterSetter(g,"verticalAlign","top"),s.Factory.addGetterSetter(g,"lineHeight",1,l.getNumberValidator()),s.Factory.addGetterSetter(g,"wrap","word"),s.Factory.addGetterSetter(g,"ellipsis",!1),s.Factory.addGetterSetter(g,"letterSpacing",0,l.getNumberValidator()),s.Factory.addGetterSetter(g,"text","",l.getStringValidator()),s.Factory.addGetterSetter(g,"textDecoration",""),a.Collection.mapMethods(g)},function(t,e,i){const r=i(7),{anchor:n,Anchor:o}=i(10),a=i(12),s=i(6),{Tab:h,Slot:c,None:l}=i(13),{NullValidator:u,PieceValidator:d,PuzzleValidator:p}=i(14),f=i(18),g=i(23),y=i(15),v=i(24),{InsertSequence:_,...m}=i(19),b=i(20),x=i(25),{position:S,...w}=i(8);t.exports={anchor:n,position:S,Anchor:o,Puzzle:a,Piece:s,Canvas:y,Manufacturer:v,InsertSequence:_,PieceValidator:d,PuzzleValidator:p,NullValidator:u,Tab:h,Slot:c,None:l,Pair:r,Metadata:b,SpatialMetadata:x,Outline:g,Structure:f,Position:w,generators:m,painters:{Dummy:i(38),Konva:i(39)}}},function(t,e){t.exports=function(t,e,i){return e<=t&&t<=i}},function(t,e,i){const{pivot:r}=i(17);class n{constructor(t,e,i){this.axis=t,this.forward=e,this.backward=i,this.forwardAnchor=e+"Anchor",this.backwardAnchor=i+"Anchor",this.forwardConnection=e+"Connection",this.backwardConnection=i+"Connection"}attract(t,e,i=!1){const[n,o]=r(t,e,i);let a,s;o.centralAnchor[this.axis]>n.centralAnchor[this.axis]?[a,s]=o[this.backwardAnchor].diff(n[this.forwardAnchor]):[a,s]=o[this.forwardAnchor].diff(n[this.backwardAnchor]),n.push(a,s)}openMovement(t,e){return e>0&&!t[this.forwardConnection]||e<0&&!t[this.backwardConnection]||0==e}canConnectWith(t,e,i){return this.closeTo(t,e,i)&&this.match(t,e)}closeTo(t,e,i){return t[this.forwardAnchor].closeTo(e[this.backwardAnchor],i)}match(t,e){return t[this.forward].match(e[this.backward])}connectWith(t,e,i,r){if(!this.canConnectWith(t,e,i))throw new Error(`can not connect ${this.forward}!`);t[this.forwardConnection]!==e&&(this.attract(e,t,r),t[this.forwardConnection]=e,e[this.backwardConnection]=t,t.fireConnect(e))}}t.exports={horizontal:new n("x","right","left"),vertical:new n("y","down","up")}},function(t,e,i){const{position:r}=i(8);t.exports={asImageMetadata:function(t){return t instanceof HTMLImageElement?{content:t,offset:r(1,1),scale:1}:t}}},function(t,e,i){i(15),i(6);const r=i(26);t.exports=class extends r{initialize(t,e){t.__nullLayer__={drawn:!1,figures:0}}draw(t){t.__nullLayer__.drawn=!0}sketch(t,e,i){t.__nullLayer__.figures++}}},function(t,e,i){let r;try{r=i(40)}catch(t){r={Stage:class{constructor(t){throw new Error("Konva not loaded")}}}}i(15);const n=i(23),o=(i(6),i(7)),a=i(8),s=i(26);t.exports=class extends s{initialize(t,e){var i=new r.Stage({container:e,width:t.width,height:t.height});this._initializeLayer(i,t)}_initializeLayer(t,e){var i=new r.Layer;t.add(i),e.__konvaLayer__=i}draw(t){t.__konvaLayer__.draw()}reinitialize(t){const e=t.__konvaLayer__,i=e.getStage();e.destroy(),this._initializeLayer(i,t)}sketch(t,e,i){i.group=new r.Group({x:e.metadata.currentPosition.x,y:e.metadata.currentPosition.y});const o=t._imageMetadataFor(e);i.shape=new r.Line({points:n.draw(e,t.pieceSize,t.borderFill),fill:o?null:e.metadata.color||"black",fillPatternImage:o&&o.content,fillPatternScale:o&&{x:o.scale,y:o.scale},fillPatternOffset:o&&o.offset,tension:t.lineSoftness,stroke:e.metadata.strokeColor||t.strokeColor,strokeWidth:t.strokeWidth,closed:!0}),i.group.add(i.shape),i.group.draggable("true"),t.__konvaLayer__.add(i.group)}label(t,e,i){i.label=new r.Text({x:e.metadata.label.x||i.group.width()/2,y:e.metadata.label.y||i.group.height()/2,text:e.metadata.label.text,fontSize:e.metadata.label.fontSize,fontFamily:e.metadata.label.fontFamily||"Sans Serif",fill:e.metadata.label.color||"white"}),i.group.add(i.label)}physicalTranslate(t,e,i){e.x(i.centralAnchor.x),e.y(i.centralAnchor.y)}logicalTranslate(t,e,i){a.update(e.metadata.currentPosition,i.x(),i.y())}onDrag(t,e,i,r){i.on("mouseover",()=>{document.body.style.cursor="pointer"}),i.on("mouseout",()=>{document.body.style.cursor="default"}),i.on("dragmove",()=>{let[t,n]=function(t,e){return o.diff(e.x(),e.y(),t.metadata.currentPosition.x,t.metadata.currentPosition.y)}(e,i);r(t,n)})}onDragEnd(t,e,i,r){i.on("dragend",()=>{r()})}}},function(t,e,i){var r=i(41).Konva;r._injectGlobal(r),e.default=r,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(42),n=i(48),o=i(49),a=i(50),s=i(51),h=i(52),c=i(53),l=i(30),u=i(31),d=i(32),p=i(54),f=i(55),g=i(56),y=i(57),v=i(33),_=i(58),m=i(59),b=i(60),x=i(61),S=i(62),w=i(63),C=i(64),P=i(65),A=i(66),T=i(67),k=i(68),M=i(69),F=i(70),O=i(71),G=i(72),D=i(73),N=i(74),E=i(75),R=i(76),L=i(77),I=i(78),z=i(79);e.Konva=r.Konva.Util._assign(r.Konva,{Arc:n.Arc,Arrow:o.Arrow,Circle:a.Circle,Ellipse:s.Ellipse,Image:h.Image,Label:c.Label,Tag:c.Tag,Line:l.Line,Path:u.Path,Rect:d.Rect,RegularPolygon:p.RegularPolygon,Ring:f.Ring,Sprite:g.Sprite,Star:y.Star,Text:v.Text,TextPath:_.TextPath,Transformer:m.Transformer,Wedge:b.Wedge,Filters:{Blur:x.Blur,Brighten:S.Brighten,Contrast:w.Contrast,Emboss:C.Emboss,Enhance:P.Enhance,Grayscale:A.Grayscale,HSL:T.HSL,HSV:k.HSV,Invert:M.Invert,Kaleidoscope:F.Kaleidoscope,Mask:O.Mask,Noise:G.Noise,Pixelate:D.Pixelate,Posterize:N.Posterize,RGB:E.RGB,RGBA:R.RGBA,Sepia:L.Sepia,Solarize:I.Solarize,Threshold:z.Threshold}})},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),n=i(3),o=i(4),a=i(9),s=i(44),h=i(45),c=i(46),l=i(21),u=i(16),d=i(5),p=i(22),f=i(47),g=i(27),y=i(11);e.Konva=n.Util._assign(r.Konva,{Collection:n.Collection,Util:n.Util,Transform:n.Transform,Node:o.Node,ids:o.ids,names:o.names,Container:a.Container,Stage:s.Stage,stages:s.stages,Layer:h.Layer,FastLayer:c.FastLayer,Group:l.Group,DD:u.DD,Shape:d.Shape,shapes:d.shapes,Animation:p.Animation,Tween:f.Tween,Easings:f.Easings,Context:g.Context,Canvas:y.Canvas})},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(9),h=i(1),c=i(11),l=i(16),u=i(1),d=i(28),p=["mouseenter","mousedown","mousemove","mouseup","mouseout","touchstart","touchmove","touchend","mouseover","wheel","contextmenu","pointerdown","pointermove","pointerup","pointercancel","lostpointercapture"],f=p.length;function g(t,e){t.content.addEventListener(e,(function(i){t["_"+e](i)}),!1)}function y(t){return void 0===t&&(t={}),(t.clipFunc||t.clipWidth||t.clipHeight)&&o.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}e.stages=[];var v=function(t){function i(i){var r=t.call(this,y(i))||this;return r._pointerPositions=[],r._changedPointerPositions=[],r._buildDOM(),r._bindContentEvents(),e.stages.push(r),r.on("widthChange.konva heightChange.konva",r._resizeDOM),r.on("visibleChange.konva",r._checkVisibility),r.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(function(){y(r.attrs)})),r._checkVisibility(),r}return n(i,t),i.prototype._validateAdd=function(t){var e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||o.Util.throw("You may only add layers to the stage.")},i.prototype._checkVisibility=function(){if(this.content){var t=this.visible()?"":"none";this.content.style.display=t}},i.prototype.setContainer=function(t){if("string"==typeof 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},i.prototype.shouldDrawHit=function(){return!0},i.prototype.clear=function(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this},i.prototype.clone=function(t){return t||(t={}),t.container=document.createElement("div"),s.Container.prototype.clone.call(this,t)},i.prototype.destroy=function(){t.prototype.destroy.call(this);var i=this.content;i&&o.Util._isInDocument(i)&&this.container().removeChild(i);var r=e.stages.indexOf(this);return r>-1&&e.stages.splice(r,1),this},i.prototype.getPointerPosition=function(){var t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(o.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)},i.prototype._getPointerById=function(t){return this._pointerPositions.find((function(e){return e.id===t}))},i.prototype.getPointersPositions=function(){return this._pointerPositions},i.prototype.getStage=function(){return this},i.prototype.getContent=function(){return this.content},i.prototype._toKonvaCanvas=function(t){var e=(t=t||{}).x||0,i=t.y||0,r=new c.SceneCanvas({width:t.width||this.width(),height:t.height||this.height(),pixelRatio:t.pixelRatio||1}),n=r.getContext()._context,o=this.children;return(e||i)&&n.translate(-1*e,-1*i),o.each((function(r){if(r.isVisible()){var o=r._toKonvaCanvas(t);n.drawImage(o._canvas,e,i,o.getWidth()/o.getPixelRatio(),o.getHeight()/o.getPixelRatio())}})),r},i.prototype.getIntersection=function(t,e){if(!t)return null;var i,r,n=this.children;for(i=n.length-1;i>=0;i--)if(r=n[i].getIntersection(t,e))return r;return null},i.prototype._resizeDOM=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.each((function(i){i.setSize({width:t,height:e}),i.draw()}))},i.prototype.add=function(e){if(arguments.length>1){for(var i=0;i<arguments.length;i++)this.add(arguments[i]);return this}t.prototype.add.call(this,e);var r=this.children.length;return r>5&&o.Util.warn("The stage has "+r+" 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."),e.setSize({width:this.width(),height:this.height()}),e.draw(),h.Konva.isBrowser&&this.content.appendChild(e.canvas._canvas),this},i.prototype.getParent=function(){return null},i.prototype.getLayer=function(){return null},i.prototype.hasPointerCapture=function(t){return d.hasPointerCapture(t,this)},i.prototype.setPointerCapture=function(t){d.setPointerCapture(t,this)},i.prototype.releaseCapture=function(t){d.releaseCapture(t,this)},i.prototype.getLayers=function(){return this.getChildren()},i.prototype._bindContentEvents=function(){if(h.Konva.isBrowser)for(var t=0;t<f;t++)g(this,p[t])},i.prototype._mouseenter=function(t){this.setPointersPositions(t),this._fire("mouseenter",{evt:t,target:this,currentTarget:this})},i.prototype._mouseover=function(t){this.setPointersPositions(t),this._fire("contentMouseover",{evt:t}),this._fire("mouseover",{evt:t,target:this,currentTarget:this})},i.prototype._mouseout=function(t){var e;this.setPointersPositions(t);var i=(null===(e=this.targetShape)||void 0===e?void 0:e.getStage())?this.targetShape:null,r=!l.DD.isDragging||h.Konva.hitOnDragEnabled;i&&r?(i._fireAndBubble("mouseout",{evt:t}),i._fireAndBubble("mouseleave",{evt:t}),this._fire("mouseleave",{evt:t,target:this,currentTarget:this}),this.targetShape=null):r&&(this._fire("mouseleave",{evt:t,target:this,currentTarget:this}),this._fire("mouseout",{evt:t,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[],this._fire("contentMouseout",{evt:t})},i.prototype._mousemove=function(t){var e;if(h.Konva.UA.ieMobile)return this._touchmove(t);this.setPointersPositions(t);var i,r=o.Util._getFirstPointerId(t),n=(null===(e=this.targetShape)||void 0===e?void 0:e.getStage())?this.targetShape:null,a=!l.DD.isDragging||h.Konva.hitOnDragEnabled;if(a){if((i=this.getIntersection(this.getPointerPosition()))&&i.isListening())a&&n!==i?(n&&(n._fireAndBubble("mouseout",{evt:t,pointerId:r},i),n._fireAndBubble("mouseleave",{evt:t,pointerId:r},i)),i._fireAndBubble("mouseover",{evt:t,pointerId:r},n),i._fireAndBubble("mouseenter",{evt:t,pointerId:r},n),i._fireAndBubble("mousemove",{evt:t,pointerId:r}),this.targetShape=i):i._fireAndBubble("mousemove",{evt:t,pointerId:r});else n&&a&&(n._fireAndBubble("mouseout",{evt:t,pointerId:r}),n._fireAndBubble("mouseleave",{evt:t,pointerId:r}),this._fire("mouseover",{evt:t,target:this,currentTarget:this,pointerId:r}),this.targetShape=null),this._fire("mousemove",{evt:t,target:this,currentTarget:this,pointerId:r});this._fire("contentMousemove",{evt:t})}t.cancelable&&t.preventDefault()},i.prototype._mousedown=function(t){if(h.Konva.UA.ieMobile)return this._touchstart(t);this.setPointersPositions(t);var e=o.Util._getFirstPointerId(t),i=this.getIntersection(this.getPointerPosition());l.DD.justDragged=!1,h.Konva.listenClickTap=!0,i&&i.isListening()?(this.clickStartShape=i,i._fireAndBubble("mousedown",{evt:t,pointerId:e})):this._fire("mousedown",{evt:t,target:this,currentTarget:this,pointerId:e}),this._fire("contentMousedown",{evt:t})},i.prototype._mouseup=function(t){if(h.Konva.UA.ieMobile)return this._touchend(t);this.setPointersPositions(t);var e=o.Util._getFirstPointerId(t),i=this.getIntersection(this.getPointerPosition()),r=this.clickStartShape,n=this.clickEndShape,a=!1;h.Konva.inDblClickWindow?(a=!0,clearTimeout(this.dblTimeout)):l.DD.justDragged||(h.Konva.inDblClickWindow=!0,clearTimeout(this.dblTimeout)),this.dblTimeout=setTimeout((function(){h.Konva.inDblClickWindow=!1}),h.Konva.dblClickWindow),i&&i.isListening()?(this.clickEndShape=i,i._fireAndBubble("mouseup",{evt:t,pointerId:e}),h.Konva.listenClickTap&&r&&r._id===i._id&&(i._fireAndBubble("click",{evt:t,pointerId:e}),a&&n&&n===i&&i._fireAndBubble("dblclick",{evt:t,pointerId:e}))):(this._fire("mouseup",{evt:t,target:this,currentTarget:this,pointerId:e}),h.Konva.listenClickTap&&this._fire("click",{evt:t,target:this,currentTarget:this,pointerId:e}),a&&this._fire("dblclick",{evt:t,target:this,currentTarget:this,pointerId:e})),this._fire("contentMouseup",{evt:t}),h.Konva.listenClickTap&&(this._fire("contentClick",{evt:t}),a&&this._fire("contentDblclick",{evt:t})),h.Konva.listenClickTap=!1,t.cancelable&&t.preventDefault()},i.prototype._contextmenu=function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble("contextmenu",{evt:t}):this._fire("contextmenu",{evt:t,target:this,currentTarget:this}),this._fire("contentContextmenu",{evt:t})},i.prototype._touchstart=function(t){var e=this;this.setPointersPositions(t);var i=!1;this._changedPointerPositions.forEach((function(r){var n=e.getIntersection(r);h.Konva.listenClickTap=!0,l.DD.justDragged=!1,n&&n.isListening()&&(h.Konva.captureTouchEventsEnabled&&n.setPointerCapture(r.id),e.tapStartShape=n,n._fireAndBubble("touchstart",{evt:t,pointerId:r.id},e),i=!0,n.isListening()&&n.preventDefault()&&t.cancelable&&t.preventDefault())})),i||this._fire("touchstart",{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),this._fire("contentTouchstart",{evt:t})},i.prototype._touchmove=function(t){var e=this;if(this.setPointersPositions(t),!l.DD.isDragging||h.Konva.hitOnDragEnabled){var i=!1,r={};this._changedPointerPositions.forEach((function(n){var o=d.getCapturedShape(n.id)||e.getIntersection(n);o&&o.isListening()&&(r[o._id]||(r[o._id]=!0,o._fireAndBubble("touchmove",{evt:t,pointerId:n.id}),i=!0,o.isListening()&&o.preventDefault()&&t.cancelable&&t.preventDefault()))})),i||this._fire("touchmove",{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),this._fire("contentTouchmove",{evt:t})}l.DD.isDragging&&l.DD.node.preventDefault()&&t.cancelable&&t.preventDefault()},i.prototype._touchend=function(t){var e=this;this.setPointersPositions(t);var i=this.clickEndShape,r=!1;h.Konva.inDblClickWindow?(r=!0,clearTimeout(this.dblTimeout)):l.DD.justDragged||(h.Konva.inDblClickWindow=!0,clearTimeout(this.dblTimeout)),this.dblTimeout=setTimeout((function(){h.Konva.inDblClickWindow=!1}),h.Konva.dblClickWindow);var n=!1,o={},a=!1,s=!1;this._changedPointerPositions.forEach((function(c){var l=d.getCapturedShape(c.id)||e.getIntersection(c);l&&l.releaseCapture(c.id),l&&l.isListening()&&(o[l._id]||(o[l._id]=!0,e.clickEndShape=l,l._fireAndBubble("touchend",{evt:t,pointerId:c.id}),n=!0,h.Konva.listenClickTap&&l===e.tapStartShape&&(a=!0,l._fireAndBubble("tap",{evt:t,pointerId:c.id}),r&&i&&i===l&&(s=!0,l._fireAndBubble("dbltap",{evt:t,pointerId:c.id}))),l.isListening()&&l.preventDefault()&&t.cancelable&&t.preventDefault()))})),n||this._fire("touchend",{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),h.Konva.listenClickTap&&!a&&this._fire("tap",{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r&&!s&&this._fire("dbltap",{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),this._fire("contentTouchend",{evt:t}),h.Konva.listenClickTap&&(this._fire("contentTap",{evt:t}),r&&this._fire("contentDbltap",{evt:t})),h.Konva.listenClickTap=!1},i.prototype._wheel=function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble("wheel",{evt:t}):this._fire("wheel",{evt:t,target:this,currentTarget:this}),this._fire("contentWheel",{evt:t})},i.prototype._pointerdown=function(t){if(h.Konva._pointerEventsEnabled){this.setPointersPositions(t);var e=d.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble("pointerdown",d.createEvent(t))}},i.prototype._pointermove=function(t){if(h.Konva._pointerEventsEnabled){this.setPointersPositions(t);var e=d.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble("pointermove",d.createEvent(t))}},i.prototype._pointerup=function(t){if(h.Konva._pointerEventsEnabled){this.setPointersPositions(t);var e=d.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble("pointerup",d.createEvent(t)),d.releaseCapture(t.pointerId)}},i.prototype._pointercancel=function(t){if(h.Konva._pointerEventsEnabled){this.setPointersPositions(t);var e=d.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble("pointerup",d.createEvent(t)),d.releaseCapture(t.pointerId)}},i.prototype._lostpointercapture=function(t){d.releaseCapture(t.pointerId)},i.prototype.setPointersPositions=function(t){var e=this,i=this._getContentPosition(),r=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],o.Collection.prototype.each.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})})),o.Collection.prototype.each.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})}))):(r=(t.clientX-i.left)/i.scaleX,n=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:n},this._pointerPositions=[{x:r,y:n,id:o.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:n,id:o.Util._getFirstPointerId(t)}])},i.prototype._setPointerPosition=function(t){o.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)},i.prototype._getContentPosition=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}},i.prototype._buildDOM=function(){if(this.bufferCanvas=new c.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new c.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),h.Konva.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()}},i.prototype.cache=function(){return o.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this},i.prototype.clearCache=function(){return this},i.prototype.batchDraw=function(){return this.children.each((function(t){t.batchDraw()})),this},i}(s.Container);e.Stage=v,v.prototype.nodeType="Stage",u._registerNode(v),a.Factory.addGetterSetter(v,"container")},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(9),s=i(0),h=i(29),c=i(11),l=i(5),u=i(2),d=i(1),p=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],f=p.length,g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitCanvas=new c.HitCanvas({pixelRatio:1}),e}return n(e,t),e.prototype.setSize=function(e){var i=e.width,r=e.height;return t.prototype.setSize.call(this,{width:i,height:r}),this.hitCanvas.setSize(i,r),this},e.prototype._validateAdd=function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&o.Util.throw("You may only add groups and shapes to a layer.")},e.prototype.getIntersection=function(t,e){var i,r,n,o;if(!this.hitGraphEnabled()||!this.isVisible())return null;for(var a=1,s=!1;;){for(r=0;r<f;r++){if(n=p[r],(o=(i=this._getIntersection({x:t.x+n.x*a,y:t.y+n.y*a})).shape)&&e)return o.findAncestor(e,!0);if(o)return o;if(s=!!i.antialiased,!i.antialiased)break}if(!s)return null;a+=1}},e.prototype._getIntersection=function(t){var e,i,r=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(t.x*r),Math.round(t.y*r),1,1).data,a=n[3];return 255===a?(e=o.Util._rgbToHex(n[0],n[1],n[2]),(i=l.shapes["#"+e])?{shape:i}:{antialiased:!0}):a>0?{antialiased:!0}:{}},e.prototype.drawScene=function(t,e){var i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),a.Container.prototype.drawScene.call(this,r,e),this._fire("draw",{node:this}),this},e.prototype.drawHit=function(t,e){var i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),a.Container.prototype.drawHit.call(this,r,e),this},e.prototype.clear=function(t){return h.BaseLayer.prototype.clear.call(this,t),this.getHitCanvas().getContext().clear(t),this},e.prototype.enableHitGraph=function(){return this.hitGraphEnabled(!0),this},e.prototype.disableHitGraph=function(){return this.hitGraphEnabled(!1),this},e.prototype.toggleHitCanvas=function(){if(this.parent){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}},e}(h.BaseLayer);e.Layer=g,g.prototype.nodeType="Layer",d._registerNode(g),s.Factory.addGetterSetter(g,"hitGraphEnabled",!0,u.getBooleanValidator()),o.Collection.mapMethods(g)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(9),s=i(29),h=i(1),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._validateAdd=function(t){"Shape"!==t.getType()&&o.Util.throw("You may only add shapes to a fast layer.")},e.prototype.hitGraphEnabled=function(){return!1},e.prototype.drawScene=function(t){var e=this.getLayer(),i=t||e&&e.getCanvas();return this.clearBeforeDraw()&&i.getContext().clear(),a.Container.prototype.drawScene.call(this,i),this},e.prototype.draw=function(){return this.drawScene(),this},e}(s.BaseLayer);e.FastLayer=c,c.prototype.nodeType="FastLayer",h._registerNode(c),o.Collection.mapMethods(c)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(3),n=i(22),o=i(4),a=i(1),s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},h=0,c=["fill","stroke","shadowColor"],l=function(){function t(t,e,i,r,n,o,a){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=n-this.begin,this.pause()}return t.prototype.fire=function(t){var e=this[t];e&&e()},t.prototype.setTime=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())},t.prototype.getTime=function(){return this._time},t.prototype.setPosition=function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t},t.prototype.getPosition=function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)},t.prototype.play=function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},t.prototype.reverse=function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},t.prototype.seek=function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")},t.prototype.reset=function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},t.prototype.finish=function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},t.prototype.update=function(){this.setPosition(this.getPosition(this._time))},t.prototype.onEnterFrame=function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)},t.prototype.pause=function(){this.state=1,this.fire("onPause")},t.prototype.getTimer=function(){return(new Date).getTime()},t}(),u=function(){function t(i){var o,c,u=this,d=i.node,p=d._id,f=i.easing||e.Easings.Linear,g=!!i.yoyo;o=void 0===i.duration?.3:0===i.duration?.001:i.duration,this.node=d,this._id=h++;var y=d.getLayer()||(d instanceof a.Konva.Stage?d.getLayers():null);for(c in y||r.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new n.Animation((function(){u.tween.onEnterFrame()}),y),this.tween=new l(c,(function(t){u._tweenFunc(t)}),f,0,1,1e3*o,g),this._addListeners(),t.attrs[p]||(t.attrs[p]={}),t.attrs[p][this._id]||(t.attrs[p][this._id]={}),t.tweens[p]||(t.tweens[p]={}),i)void 0===s[c]&&this._addAttr(c,i[c]);this.reset(),this.onFinish=i.onFinish,this.onReset=i.onReset}return t.prototype._addAttr=function(e,i){var n,o,a,s,h,l,u,d,p=this.node,f=p._id;if((a=t.tweens[f][e])&&delete t.attrs[f][a][e],n=p.getAttr(e),r.Util._isArray(i))if(o=[],h=Math.max(i.length,n.length),"points"===e&&i.length!==n.length&&(i.length>n.length?(u=n,n=r.Util._prepareArrayForTween(n,i,p.closed())):(l=i,i=r.Util._prepareArrayForTween(i,n,p.closed()))),0===e.indexOf("fill"))for(s=0;s<h;s++)if(s%2==0)o.push(i[s]-n[s]);else{var g=r.Util.colorToRGBA(n[s]);d=r.Util.colorToRGBA(i[s]),n[s]=g,o.push({r:d.r-g.r,g:d.g-g.g,b:d.b-g.b,a:d.a-g.a})}else for(s=0;s<h;s++)o.push(i[s]-n[s]);else-1!==c.indexOf(e)?(n=r.Util.colorToRGBA(n),o={r:(d=r.Util.colorToRGBA(i)).r-n.r,g:d.g-n.g,b:d.b-n.b,a:d.a-n.a}):o=i-n;t.attrs[f][this._id][e]={start:n,diff:o,end:i,trueEnd:l,trueStart:u},t.tweens[f][e]=this._id},t.prototype._tweenFunc=function(e){var i,n,o,a,s,h,l,u,d=this.node,p=t.attrs[d._id][this._id];for(i in p){if(o=(n=p[i]).start,a=n.diff,u=n.end,r.Util._isArray(o))if(s=[],l=Math.max(o.length,u.length),0===i.indexOf("fill"))for(h=0;h<l;h++)h%2==0?s.push((o[h]||0)+a[h]*e):s.push("rgba("+Math.round(o[h].r+a[h].r*e)+","+Math.round(o[h].g+a[h].g*e)+","+Math.round(o[h].b+a[h].b*e)+","+(o[h].a+a[h].a*e)+")");else for(h=0;h<l;h++)s.push((o[h]||0)+a[h]*e);else s=-1!==c.indexOf(i)?"rgba("+Math.round(o.r+a.r*e)+","+Math.round(o.g+a.g*e)+","+Math.round(o.b+a.b*e)+","+(o.a+a.a*e)+")":o+a*e;d.setAttr(i,s)}},t.prototype._addListeners=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,r=t.attrs[i._id][e._id];r.points&&r.points.trueEnd&&i.setAttr("points",r.points.trueEnd),e.onFinish&&e.onFinish.call(e)},this.tween.onReset=function(){var i=e.node,r=t.attrs[i._id][e._id];r.points&&r.points.trueStart&&i.points(r.points.trueStart),e.onReset&&e.onReset()}},t.prototype.play=function(){return this.tween.play(),this},t.prototype.reverse=function(){return this.tween.reverse(),this},t.prototype.reset=function(){return this.tween.reset(),this},t.prototype.seek=function(t){return this.tween.seek(1e3*t),this},t.prototype.pause=function(){return this.tween.pause(),this},t.prototype.finish=function(){return this.tween.finish(),this},t.prototype.destroy=function(){var e,i=this.node._id,r=this._id,n=t.tweens[i];for(e in this.pause(),n)delete t.tweens[i][e];delete t.attrs[i][r]},t.attrs={},t.tweens={},t}();e.Tween=u,o.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new u(t).play()},e.Easings={BackEaseIn:function(t,e,i,r){var n=1.70158;return i*(t/=r)*t*((n+1)*t-n)+e},BackEaseOut:function(t,e,i,r){var n=1.70158;return i*((t=t/r-1)*t*((n+1)*t+n)+1)+e},BackEaseInOut:function(t,e,i,r){var n=1.70158;return(t/=r/2)<1?i/2*(t*t*((1+(n*=1.525))*t-n))+e:i/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},ElasticEaseIn:function(t,e,i,r,n,o){var a=0;return 0===t?e:1==(t/=r)?e+i:(o||(o=.3*r),!n||n<Math.abs(i)?(n=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/n),-n*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+e)},ElasticEaseOut:function(t,e,i,r,n,o){var a=0;return 0===t?e:1==(t/=r)?e+i:(o||(o=.3*r),!n||n<Math.abs(i)?(n=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/n),n*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+i+e)},ElasticEaseInOut:function(t,e,i,r,n,o){var a=0;return 0===t?e:2==(t/=r/2)?e+i:(o||(o=r*(.3*1.5)),!n||n<Math.abs(i)?(n=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/n),t<1?n*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+e:n*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+i+e)},BounceEaseOut:function(t,e,i,r){return(t/=r)<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,i,r,n){return r-e.Easings.BounceEaseOut(n-t,0,r,n)+i},BounceEaseInOut:function(t,i,r,n){return t<n/2?.5*e.Easings.BounceEaseIn(2*t,0,r,n)+i:.5*e.Easings.BounceEaseOut(2*t-n,0,r,n)+.5*r+i},EaseIn:function(t,e,i,r){return i*(t/=r)*t+e},EaseOut:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},EaseInOut:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},StrongEaseIn:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},StrongEaseOut:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},StrongEaseInOut:function(t,e,i,r){return(t/=r/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,r){return i*t/r+e}}},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(1),c=i(2),l=i(1),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){var e=h.Konva.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)},e.prototype.getWidth=function(){return 2*this.outerRadius()},e.prototype.getHeight=function(){return 2*this.outerRadius()},e.prototype.setWidth=function(t){this.outerRadius(t/2)},e.prototype.setHeight=function(t){this.outerRadius(t/2)},e}(s.Shape);e.Arc=u,u.prototype._centroid=!0,u.prototype.className="Arc",u.prototype._attrsAffectingSize=["innerRadius","outerRadius"],l._registerNode(u),a.Factory.addGetterSetter(u,"innerRadius",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"outerRadius",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"angle",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clockwise",!1,c.getBooleanValidator()),o.Collection.mapMethods(u)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(30),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(e){t.prototype._sceneFunc.call(this,e);var i=2*Math.PI,r=this.points(),n=r,o=0!==this.tension()&&r.length>4;o&&(n=this.getTensionPoints());var a,s,h=r.length;o?(a=r[h-2]-(n[n.length-2]+n[n.length-4])/2,s=r[h-1]-(n[n.length-1]+n[n.length-3])/2):(a=r[h-2]-r[h-4],s=r[h-1]-r[h-3]);var c=(Math.atan2(s,a)+i)%i,l=this.pointerLength(),u=this.pointerWidth();e.save(),e.beginPath(),e.translate(r[h-2],r[h-1]),e.rotate(c),e.moveTo(0,0),e.lineTo(-l,u/2),e.lineTo(-l,-u/2),e.closePath(),e.restore(),this.pointerAtBeginning()&&(e.save(),e.translate(r[0],r[1]),o?(a=(n[0]+n[2])/2-r[0],s=(n[1]+n[3])/2-r[1]):(a=r[2]-r[0],s=r[3]-r[1]),e.rotate((Math.atan2(-s,-a)+i)%i),e.moveTo(0,0),e.lineTo(-l,u/2),e.lineTo(-l,-u/2),e.closePath(),e.restore());var d=this.dashEnabled();d&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),d&&(this.attrs.dashEnabled=!0)},e.prototype.getSelfRect=function(){var e=t.prototype.getSelfRect.call(this),i=this.pointerWidth()/2;return{x:e.x-i,y:e.y-i,width:e.width+2*i,height:e.height+2*i}},e}(s.Line);e.Arrow=l,l.prototype.className="Arrow",c._registerNode(l),a.Factory.addGetterSetter(l,"pointerLength",10,h.getNumberValidator()),a.Factory.addGetterSetter(l,"pointerWidth",10,h.getNumberValidator()),a.Factory.addGetterSetter(l,"pointerAtBeginning",!1),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){t.beginPath(),t.arc(0,0,this.radius(),0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){return 2*this.radius()},e.prototype.getHeight=function(){return 2*this.radius()},e.prototype.setWidth=function(t){this.radius()!==t/2&&this.radius(t/2)},e.prototype.setHeight=function(t){this.radius()!==t/2&&this.radius(t/2)},e}(s.Shape);e.Circle=l,l.prototype._centroid=!0,l.prototype.className="Circle",l.prototype._attrsAffectingSize=["radius"],c._registerNode(l),a.Factory.addGetterSetter(l,"radius",0,h.getNumberValidator()),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=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)},e.prototype.getWidth=function(){return 2*this.radiusX()},e.prototype.getHeight=function(){return 2*this.radiusY()},e.prototype.setWidth=function(t){this.radiusX(t/2)},e.prototype.setHeight=function(t){this.radiusY(t/2)},e}(s.Shape);e.Ellipse=l,l.prototype.className="Ellipse",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["radiusX","radiusY"],c._registerNode(l),a.Factory.addComponentsGetterSetter(l,"radius",["x","y"]),a.Factory.addGetterSetter(l,"radiusX",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"radiusY",0,h.getNumberValidator()),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._useBufferCanvas=function(){return!(!this.hasShadow()&&1===this.getAbsoluteOpacity()||!this.hasStroke()||!this.getStage())},e.prototype._sceneFunc=function(t){var e,i,r,n=this.width(),o=this.height(),a=this.image();a&&(e=this.cropWidth(),i=this.cropHeight(),r=e&&i?[a,this.cropX(),this.cropY(),e,i,0,0,n,o]:[a,0,0,n,o]),(this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,n,o),t.closePath(),t.fillStrokeShape(this)),a&&t.drawImage.apply(t,r)},e.prototype._hitFunc=function(t){var e=this.width(),i=this.height();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){var t,e=this.image();return null!==(t=this.attrs.width)&&void 0!==t?t:e?e.width:0},e.prototype.getHeight=function(){var t,e=this.image();return null!==(t=this.attrs.height)&&void 0!==t?t:e?e.height:0},e.fromURL=function(t,i){var r=o.Util.createImageElement();r.onload=function(){var t=new e({image:r});i(t)},r.crossOrigin="Anonymous",r.src=t},e}(s.Shape);e.Image=l,l.prototype.className="Image",c._registerNode(l),a.Factory.addGetterSetter(l,"image"),a.Factory.addComponentsGetterSetter(l,"crop",["x","y","width","height"]),a.Factory.addGetterSetter(l,"cropX",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"cropY",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"cropWidth",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"cropHeight",0,h.getNumberValidator()),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(21),c=i(2),l=i(1),u=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width"],d=u.length,p=function(t){function e(e){var i=t.call(this,e)||this;return i.on("add.konva",(function(t){this._addListeners(t.child),this._sync()})),i}return n(e,t),e.prototype.getText=function(){return this.find("Text")[0]},e.prototype.getTag=function(){return this.find("Tag")[0]},e.prototype._addListeners=function(t){var e,i=this,r=function(){i._sync()};for(e=0;e<d;e++)t.on(u[e]+"Change.konva",r)},e.prototype.getWidth=function(){return this.getText().width()},e.prototype.getHeight=function(){return this.getText().height()},e.prototype._sync=function(){var t,e,i,r,n,o,a,s=this.getText(),h=this.getTag();if(s&&h){switch(t=s.width(),e=s.height(),i=h.pointerDirection(),r=h.pointerWidth(),a=h.pointerHeight(),n=0,o=0,i){case"up":n=t/2,o=-1*a;break;case"right":n=t+r,o=e/2;break;case"down":n=t/2,o=e+a;break;case"left":n=-1*r,o=e/2}h.setAttrs({x:-1*n,y:-1*o,width:t,height:e}),s.setAttrs({x:-1*n,y:-1*o})}},e}(h.Group);e.Label=p,p.prototype.className="Label",l._registerNode(p),o.Collection.mapMethods(p);var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){var e=this.width(),i=this.height(),r=this.pointerDirection(),n=this.pointerWidth(),o=this.pointerHeight(),a=Math.min(this.cornerRadius(),e/2,i/2);t.beginPath(),a?t.moveTo(a,0):t.moveTo(0,0),"up"===r&&(t.lineTo((e-n)/2,0),t.lineTo(e/2,-1*o),t.lineTo((e+n)/2,0)),a?(t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1)):t.lineTo(e,0),"right"===r&&(t.lineTo(e,(i-o)/2),t.lineTo(e+n,i/2),t.lineTo(e,(i+o)/2)),a?(t.lineTo(e,i-a),t.arc(e-a,i-a,a,0,Math.PI/2,!1)):t.lineTo(e,i),"down"===r&&(t.lineTo((e+n)/2,i),t.lineTo(e/2,i+o),t.lineTo((e-n)/2,i)),a?(t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1)):t.lineTo(0,i),"left"===r&&(t.lineTo(0,(i+o)/2),t.lineTo(-1*n,i/2),t.lineTo(0,(i-o)/2)),a&&(t.lineTo(0,a),t.arc(a,a,a,Math.PI,3*Math.PI/2,!1)),t.closePath(),t.fillStrokeShape(this)},e.prototype.getSelfRect=function(){var t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),n=this.pointerDirection(),o=this.width(),a=this.height();return"up"===n?(e-=r,a+=r):"down"===n?a+=r:"left"===n?(t-=1.5*i,o+=i):"right"===n&&(o+=1.5*i),{x:t,y:e,width:o,height:a}},e}(s.Shape);e.Tag=f,f.prototype.className="Tag",l._registerNode(f),a.Factory.addGetterSetter(f,"pointerDirection","none"),a.Factory.addGetterSetter(f,"pointerWidth",0,c.getNumberValidator()),a.Factory.addGetterSetter(f,"pointerHeight",0,c.getNumberValidator()),a.Factory.addGetterSetter(f,"cornerRadius",0,c.getNumberValidator()),o.Collection.mapMethods(f)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){var e,i,r,n=this.sides(),o=this.radius();for(t.beginPath(),t.moveTo(0,0-o),e=1;e<n;e++)i=o*Math.sin(2*e*Math.PI/n),r=-1*o*Math.cos(2*e*Math.PI/n),t.lineTo(i,r);t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){return 2*this.radius()},e.prototype.getHeight=function(){return 2*this.radius()},e.prototype.setWidth=function(t){this.radius(t/2)},e.prototype.setHeight=function(t){this.radius(t/2)},e}(s.Shape);e.RegularPolygon=l,l.prototype.className="RegularPolygon",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["radius"],c._registerNode(l),a.Factory.addGetterSetter(l,"radius",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"sides",0,h.getNumberValidator()),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=2*Math.PI,u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,l,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),l,0,!0),t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){return 2*this.outerRadius()},e.prototype.getHeight=function(){return 2*this.outerRadius()},e.prototype.setWidth=function(t){this.outerRadius(t/2)},e.prototype.setHeight=function(t){this.outerRadius(t/2)},e}(s.Shape);e.Ring=u,u.prototype.className="Ring",u.prototype._centroid=!0,u.prototype._attrsAffectingSize=["innerRadius","outerRadius"],c._registerNode(u),a.Factory.addGetterSetter(u,"innerRadius",0,h.getNumberValidator()),a.Factory.addGetterSetter(u,"outerRadius",0,h.getNumberValidator()),o.Collection.mapMethods(u)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(22),c=i(2),l=i(1),u=function(t){function e(e){var i=t.call(this,e)||this;return i._updated=!0,i.anim=new h.Animation((function(){var t=i._updated;return i._updated=!1,t})),i.on("animationChange.konva",(function(){this.frameIndex(0)})),i.on("frameIndexChange.konva",(function(){this._updated=!0})),i.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})),i}return n(e,t),e.prototype._sceneFunc=function(t){var e=this.animation(),i=this.frameIndex(),r=4*i,n=this.animations()[e],o=this.frameOffsets(),a=n[r+0],s=n[r+1],h=n[r+2],c=n[r+3],l=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,c),t.closePath(),t.fillStrokeShape(this)),l)if(o){var u=o[e],d=2*i;t.drawImage(l,a,s,h,c,u[d+0],u[d+1],h,c)}else t.drawImage(l,a,s,h,c,0,0,h,c)},e.prototype._hitFunc=function(t){var e=this.animation(),i=this.frameIndex(),r=4*i,n=this.animations()[e],o=this.frameOffsets(),a=n[r+2],s=n[r+3];if(t.beginPath(),o){var h=o[e],c=2*i;t.rect(h[c+0],h[c+1],a,s)}else t.rect(0,0,a,s);t.closePath(),t.fillShape(this)},e.prototype._useBufferCanvas=function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()},e.prototype._setInterval=function(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())},e.prototype.start=function(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}},e.prototype.stop=function(){this.anim.stop(),clearInterval(this.interval)},e.prototype.isRunning=function(){return this.anim.isRunning()},e.prototype._updateIndex=function(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)},e}(s.Shape);e.Sprite=u,u.prototype.className="Sprite",l._registerNode(u),a.Factory.addGetterSetter(u,"animation"),a.Factory.addGetterSetter(u,"animations"),a.Factory.addGetterSetter(u,"frameOffsets"),a.Factory.addGetterSetter(u,"image"),a.Factory.addGetterSetter(u,"frameIndex",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"frameRate",17,c.getNumberValidator()),a.Factory.backCompat(u,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),o.Collection.mapMethods(u)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(2),c=i(1),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){var e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var n=1;n<2*r;n++){var o=n%2==0?i:e,a=o*Math.sin(n*Math.PI/r),s=-1*o*Math.cos(n*Math.PI/r);t.lineTo(a,s)}t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){return 2*this.outerRadius()},e.prototype.getHeight=function(){return 2*this.outerRadius()},e.prototype.setWidth=function(t){this.outerRadius(t/2)},e.prototype.setHeight=function(t){this.outerRadius(t/2)},e}(s.Shape);e.Star=l,l.prototype.className="Star",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["innerRadius","outerRadius"],c._registerNode(l),a.Factory.addGetterSetter(l,"numPoints",5,h.getNumberValidator()),a.Factory.addGetterSetter(l,"innerRadius",0,h.getNumberValidator()),a.Factory.addGetterSetter(l,"outerRadius",0,h.getNumberValidator()),o.Collection.mapMethods(l)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(31),c=i(33),l=i(2),u=i(1);function d(t){t.fillText(this.partialText,0,0)}function p(t){t.strokeText(this.partialText,0,0)}var f=function(t){function e(e){var i=t.call(this,e)||this;return i.dummyCanvas=o.Util.createCanvasElement(),i.dataArray=[],i.dataArray=h.Path.parsePathData(i.attrs.data),i.on("dataChange.konva",(function(){this.dataArray=h.Path.parsePathData(this.attrs.data),this._setTextData()})),i.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva",i._setTextData),e&&e.getKerning&&(o.Util.warn('getKerning TextPath API is deprecated. Please use "kerningFunc" instead.'),i.kerningFunc(e.getKerning)),i._setTextData(),i}return n(e,t),e.prototype._sceneFunc=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(),r=this.fontSize(),n=this.glyphInfo;"underline"===e&&t.beginPath();for(var o=0;o<n.length;o++){t.save();var a=n[o].p0;t.translate(a.x,a.y),t.rotate(n[o].rotation),this.partialText=n[o].text,t.fillStrokeShape(this),"underline"===e&&(0===o&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=r/20,t.stroke()),t.restore()},e.prototype._hitFunc=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 r=0;r<e.length;r++){var n=e[r].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()},e.prototype.getTextWidth=function(){return this.textWidth},e.prototype.getTextHeight=function(){return o.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight},e.prototype.setText=function(t){return c.Text.prototype.setText.call(this,t)},e.prototype._getContextFont=function(){return c.Text.prototype._getContextFont.call(this)},e.prototype._getTextSize=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(this.attrs.fontSize,10)}},e.prototype._setTextData=function(){var t=this,e=this._getTextSize(this.attrs.text),i=this.letterSpacing(),r=this.align(),n=this.kerningFunc();this.textWidth=e.width,this.textHeight=e.height;var o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);this.glyphInfo=[];for(var a=0,s=0;s<t.dataArray.length;s++)t.dataArray[s].pathLength>0&&(a+=t.dataArray[s].pathLength);var c=0;"center"===r&&(c=Math.max(0,a/2-o/2)),"right"===r&&(c=Math.max(0,a-o));for(var l,u,d,p=this.text().split(""),f=this.text().split(" ").length-1,g=-1,y=0,v=function(){y=0;for(var e=t.dataArray,i=g+1;i<e.length;i++){if(e[i].pathLength>0)return g=i,e[i];"M"===e[i].command&&(l={x:e[i].points[0],y:e[i].points[1]})}return{}},_=function(e){var n=t._getTextSize(e).width+i;" "===e&&"justify"===r&&(n+=(a-o)/f);var s=0,c=0;for(u=void 0;Math.abs(n-s)/n>.01&&c<25;){c++;for(var p=s;void 0===d;)(d=v())&&p+d.pathLength<n&&(p+=d.pathLength,d=void 0);if(d==={}||void 0===l)return;var g=!1;switch(d.command){case"L":h.Path.getLineLength(l.x,l.y,d.points[0],d.points[1])>n?u=h.Path.getPointOnLine(n,l.x,l.y,d.points[0],d.points[1],l.x,l.y):d=void 0;break;case"A":var _=d.points[4],m=d.points[5],b=d.points[4]+m;0===y?y=_+1e-8:n>s?y+=Math.PI/180*m/Math.abs(m):y-=Math.PI/360*m/Math.abs(m),(m<0&&y<b||m>=0&&y>b)&&(y=b,g=!0),u=h.Path.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],y,d.points[6]);break;case"C":0===y?y=n>d.pathLength?1e-8:n/d.pathLength:n>s?y+=(n-s)/d.pathLength:y-=(s-n)/d.pathLength,y>1&&(y=1,g=!0),u=h.Path.getPointOnCubicBezier(y,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);break;case"Q":0===y?y=n/d.pathLength:n>s?y+=(n-s)/d.pathLength:y-=(s-n)/d.pathLength,y>1&&(y=1,g=!0),u=h.Path.getPointOnQuadraticBezier(y,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3])}void 0!==u&&(s=h.Path.getLineLength(l.x,l.y,u.x,u.y)),g&&(g=!1,d=void 0)}},m=c/(t._getTextSize("C").width+i)-1,b=0;b<m&&(_("C"),void 0!==l&&void 0!==u);b++)l=u;for(var x=0;x<p.length&&(_(p[x]),void 0!==l&&void 0!==u);x++){var S=h.Path.getLineLength(l.x,l.y,u.x,u.y),w=0;if(n)try{w=n(p[x-1],p[x])*this.fontSize()}catch(t){w=0}l.x+=w,u.x+=w,this.textWidth+=w;var C=h.Path.getPointOnLine(w+S/2,l.x,l.y,u.x,u.y),P=Math.atan2(u.y-l.y,u.x-l.x);this.glyphInfo.push({transposeX:C.x,transposeY:C.y,text:p[x],rotation:P,p0:l,p1:u}),l=u}},e.prototype.getSelfRect=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,r=t[0]||0,n=t[0]||0,o=t[1]||0,a=t[1]||0,s=0;s<t.length/2;s++)e=t[2*s],i=t[2*s+1],r=Math.min(r,e),n=Math.max(n,e),o=Math.min(o,i),a=Math.max(a,i);var h=this.fontSize();return{x:r-h/2,y:o-h/2,width:n-r+h,height:a-o+h}},e}(s.Shape);e.TextPath=f,f.prototype._fillFunc=d,f.prototype._strokeFunc=p,f.prototype._fillFuncHit=d,f.prototype._strokeFuncHit=p,f.prototype.className="TextPath",f.prototype._attrsAffectingSize=["text","fontSize","data"],u._registerNode(f),a.Factory.addGetterSetter(f,"data"),a.Factory.addGetterSetter(f,"fontFamily","Arial"),a.Factory.addGetterSetter(f,"fontSize",12,l.getNumberValidator()),a.Factory.addGetterSetter(f,"fontStyle","normal"),a.Factory.addGetterSetter(f,"align","left"),a.Factory.addGetterSetter(f,"letterSpacing",0,l.getNumberValidator()),a.Factory.addGetterSetter(f,"textBaseline","middle"),a.Factory.addGetterSetter(f,"fontVariant","normal"),a.Factory.addGetterSetter(f,"text",""),a.Factory.addGetterSetter(f,"textDecoration",null),a.Factory.addGetterSetter(f,"kerningFunc",null),o.Collection.mapMethods(f)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var a=i(3),s=i(0),h=i(4),c=i(5),l=i(32),u=i(21),d=i(1),p=i(2),f=i(1),g=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((function(t){return t+".tr-konva"})).join(" "),y=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"].map((function(t){return t+".tr-konva"})).join(" "),v={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},_="ontouchstart"in d.Konva._global;var m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function b(t,e,i){var r=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),n=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return o(o({},t),{rotation:t.rotation+e,x:r,y:n})}function x(t,e){return b(t,e,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))}var S=function(t){function e(e){var i=t.call(this,e)||this;return i._transforming=!1,i._createElements(),i._handleMouseMove=i._handleMouseMove.bind(i),i._handleMouseUp=i._handleMouseUp.bind(i),i.update=i.update.bind(i),i.on(g,i.update),i.getNode()&&i.update(),i}return n(e,t),e.prototype.attachTo=function(t){return this.setNode(t),this},e.prototype.setNode=function(t){return a.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])},e.prototype.getNode=function(){return this._nodes&&this._nodes[0]},e.prototype.setNodes=function(t){var e=this;return void 0===t&&(t=[]),this._nodes&&this._nodes.length&&this.detach(),this._nodes=t,1===t.length?this.rotation(t[0].rotation()):this.rotation(0),this._nodes.forEach((function(t){var i=t._attrsAffectingSize.map((function(t){return t+"Change.tr-konva"})).join(" "),r=function(){e._resetTransformCache(),e._transforming||e.update()};t.on(i,r),t.on(y,r),t.on("_clearTransformCache.tr-konva",r),t.on("xChange.tr-konva yChange.tr-konva",r),e._proxyDrag(t)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this},e.prototype._proxyDrag=function(t){var e,i=this;t.on("dragstart.tr-konva",(function(){e=t.getAbsolutePosition()})),t.on("dragmove.tr-konva",(function(){if(e){var r=t.getAbsolutePosition(),n=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+n,y:i.y+o}),e.startDrag()}})),e=null}}))},e.prototype.getNodes=function(){return this._nodes},e.prototype.getActiveAnchor=function(){return this._movingAnchorName},e.prototype.detach=function(){this._nodes&&this._nodes.forEach((function(t){t.off(".tr-konva")})),this._nodes=[],this._resetTransformCache()},e.prototype._resetTransformCache=function(){this._clearCache("nodesRect"),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")},e.prototype._getNodeRect=function(){return this._getCache("nodesRect",this.__getNodeRect)},e.prototype.__getNodeShape=function(t,e,i){void 0===e&&(e=this.rotation());var r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=t.getAbsoluteScale(i),o=t.getAbsolutePosition(i),a=r.x*n.x-t.offsetX()*n.x,s=r.y*n.y-t.offsetY()*n.y,h=(d.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return b({x:o.x+a*Math.cos(h)+s*Math.sin(-h),y:o.y+s*Math.cos(h)+a*Math.sin(h),width:r.width*n.x,height:r.height*n.y,rotation:h},-d.Konva.getAngle(e),{x:0,y:0})},e.prototype.__getNodeRect=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 r=i.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:t.ignoreStroke()}),n=[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}],o=i.getAbsoluteTransform();n.forEach((function(t){var i=o.point(t);e.push(i)}))}));var i,r,n,o,s=new a.Transform;s.rotate(-d.Konva.getAngle(this.rotation())),e.forEach((function(t){var e=s.point(t);void 0===i&&(i=n=e.x,r=o=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)})),s.invert();var h=s.point({x:i,y:r});return{x:h.x,y:h.y,width:n-i,height:o-r,rotation:d.Konva.getAngle(this.rotation())}},e.prototype.getX=function(){return this._getNodeRect().x},e.prototype.getY=function(){return this._getNodeRect().y},e.prototype.getWidth=function(){return this._getNodeRect().width},e.prototype.getHeight=function(){return this._getNodeRect().height},e.prototype._createElements=function(){this._createBack(),m.forEach(function(t){this._createAnchor(t)}.bind(this)),this._createAnchor("rotater")},e.prototype._createAnchor=function(t){var e=this,i=new l.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:_?10:"auto"}),r=this;i.on("mousedown touchstart",(function(t){r._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 r=d.Konva.getAngle(e.rotation()),n=function(t,e){if("rotater"===t)return"crosshair";e+=a.Util._degToRad(v[t]||0);var i=(a.Util._radToDeg(e)%360+360)%360;return a.Util._inRange(i,337.5,360)||a.Util._inRange(i,0,22.5)?"ns-resize":a.Util._inRange(i,22.5,67.5)?"nesw-resize":a.Util._inRange(i,67.5,112.5)?"ew-resize":a.Util._inRange(i,112.5,157.5)?"nwse-resize":a.Util._inRange(i,157.5,202.5)?"ns-resize":a.Util._inRange(i,202.5,247.5)?"nesw-resize":a.Util._inRange(i,247.5,292.5)?"ew-resize":a.Util._inRange(i,292.5,337.5)?"nwse-resize":(a.Util.error("Transformer has unknown angle for cursor detection: "+i),"pointer")}(t,r);i.getStage().content.style.cursor=n,e._cursorChange=!0})),i.on("mouseout",(function(){i.getStage().content.style.cursor="",e._cursorChange=!1})),this.add(i)},e.prototype._createBack=function(){var t=this,e=new c.Shape({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()*a.Util._sign(this.height())-i),t.fillStrokeShape(this)},hitFunc:function(e,i){if(t.shouldOverdrawWholeArea()){var r=t.padding();e.beginPath(),e.rect(-r,-r,i.width()+2*r,i.height()+2*r),e.fillStrokeShape(i)}}});this.add(e),this._proxyDrag(e)},e.prototype._handleMouseDown=function(t){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,r=e.height,n=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/n),this.cos=Math.abs(i/n),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 o=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-o.x,y:a.y-o.y},this._fire("transformstart",{evt:t,target:this.getNode()}),this.getNode()._fire("transformstart",{evt:t,target:this.getNode()})},e.prototype._handleMouseMove=function(t){var e,i,r,n=this.findOne("."+this._movingAnchorName),o=n.getStage();o.setPointersPositions(t);var a=o.getPointerPosition(),s={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y},h=n.getAbsolutePosition();n.setAbsolutePosition(s);var c=n.getAbsolutePosition();if(h.x!==c.x||h.y!==c.y)if("rotater"!==this._movingAnchorName){var l=this.keepRatio()||t.shiftKey,u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(l){var p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(p.x-n.x(),2)+Math.pow(p.y-n.y(),2));var f=this.findOne(".top-left").x()>p.x?-1:1,g=this.findOne(".top-left").y()>p.y?-1:1;e=r*this.cos*f,i=r*this.sin*g,this.findOne(".top-left").x(p.x-e),this.findOne(".top-left").y(p.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(n.y());else if("top-right"===this._movingAnchorName){if(l){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(n.x()-p.x,2)+Math.pow(p.y-n.y(),2));f=this.findOne(".top-right").x()<p.x?-1:1,g=this.findOne(".top-right").y()>p.y?-1:1;e=r*this.cos*f,i=r*this.sin*g,this.findOne(".top-right").x(p.x+e),this.findOne(".top-right").y(p.y-i)}var y=n.position();this.findOne(".top-left").y(y.y),this.findOne(".bottom-right").x(y.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(n.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(n.x());else if("bottom-left"===this._movingAnchorName){if(l){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(p.x-n.x(),2)+Math.pow(n.y()-p.y,2));f=p.x<n.x()?-1:1,g=n.y()<p.y?-1:1;e=r*this.cos*f,i=r*this.sin*g,n.x(p.x-e),n.y(p.y+i)}y=n.position(),this.findOne(".top-left").x(y.x),this.findOne(".bottom-right").y(y.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(n.y());else if("bottom-right"===this._movingAnchorName){if(l){p=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(n.x()-p.x,2)+Math.pow(n.y()-p.y,2));f=this.findOne(".bottom-right").x()<p.x?-1:1,g=this.findOne(".bottom-right").y()<p.y?-1:1;e=r*this.cos*f,i=r*this.sin*g,this.findOne(".bottom-right").x(p.x+e),this.findOne(".bottom-right").y(p.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey){var v=this.findOne(".top-left"),_=this.findOne(".bottom-right"),m=v.x(),b=v.y(),S=this.getWidth()-_.x(),w=this.getHeight()-_.y();_.move({x:-m,y:-b}),v.move({x:S,y:w})}var C=this.findOne(".top-left").getAbsolutePosition();e=C.x,i=C.y;var P=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),A=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:P,height:A,rotation:d.Konva.getAngle(this.rotation())},t)}else{var T=this._getNodeRect();e=n.x()-T.width/2,i=-n.y()+T.height/2;var k=Math.atan2(-i,e)+Math.PI/2;T.height<0&&(k-=Math.PI);var M=d.Konva.getAngle(this.rotation())+k,F=d.Konva.getAngle(this.rotationSnapTolerance()),O=x(T,function(t,e,i){for(var r=e,n=0;n<t.length;n++){var o=d.Konva.getAngle(t[n]),a=Math.abs(o-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(r=o)}return r}(this.rotationSnaps(),M,F)-T.rotation);this._fitNodesInto(O,t)}},e.prototype._handleMouseUp=function(t){this._removeEvents(t)},e.prototype.getAbsoluteTransform=function(){return this.getTransform()},e.prototype._removeEvents=function(t){if(this._transforming){this._transforming=!1,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&&e.fire("transformend",{evt:t,target:e}),this._movingAnchorName=null}},e.prototype._fitNodesInto=function(t,e){var i=this,r=this._getNodeRect();if(a.Util._inRange(t.width,2*-this.padding()-1,1))this.update();else if(a.Util._inRange(t.height,2*-this.padding()-1,1))this.update();else{var n=new a.Transform;if(n.rotate(d.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){var o=n.point({x:2*-this.padding(),y:0});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}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){o=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=o.x,this._anchorDragOffset.y-=o.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){o=n.point({x:0,y:2*-this.padding()});t.x+=o.x,t.y+=o.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=o.x,this._anchorDragOffset.y-=o.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){o=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=o.x,this._anchorDragOffset.y-=o.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){var s=this.boundBoxFunc()(r,t);s?t=s:a.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}var h=new a.Transform;h.translate(r.x,r.y),h.rotate(r.rotation),h.scale(r.width/1e7,r.height/1e7);var c=new a.Transform;c.translate(t.x,t.y),c.rotate(t.rotation),c.scale(t.width/1e7,t.height/1e7);var l=c.multiply(h.invert());this._nodes.forEach((function(t){var r=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());var o=new a.Transform;o.multiply(r.copy().invert()).multiply(l).multiply(r).multiply(n);var s=o.decompose();t._batchTransformChanges((function(){t.setAttrs(s)})),i._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this.rotation(a.Util._getRotation(t.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}},e.prototype.forceUpdate=function(){this._resetTransformCache(),this.update()},e.prototype._batchChangeChild=function(t,e){var i=this.findOne(t);i._batchTransformChanges((function(){i.setAttrs(e)}))},e.prototype.update=function(){var t=this,e=this._getNodeRect();this.rotation(a.Util._getRotation(e.rotation));var i=e.width,r=e.height,n=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),h=this.anchorSize();this.find("._anchor").each((function(e){e._batchTransformChanges((function(){e.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:t.anchorStroke(),strokeWidth:t.anchorStrokeWidth(),fill:t.anchorFill(),cornerRadius:t.anchorCornerRadius()})}))})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+s,offsetY:h/2+s,visible:o&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:h/2+s,visible:o&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:h/2-s,offsetY:h/2+s,visible:o&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:h/2+s,visible:o&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:h/2-s,visible:o&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:h/2+s,offsetY:h/2-s,visible:o&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:h/2-s,visible:o&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:h/2-s,offsetY:h/2-s,visible:o&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*a.Util._sign(r)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})},e.prototype.isTransforming=function(){return this._transforming},e.prototype.stopTransform=function(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}},e.prototype.destroy=function(){return this.getStage()&&this._cursorChange&&(this.getStage().content.style.cursor=""),u.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this},e.prototype.toObject=function(){return h.Node.prototype.toObject.call(this)},e}(u.Group);e.Transformer=S,S.prototype.className="Transformer",f._registerNode(S),s.Factory.addGetterSetter(S,"enabledAnchors",m,(function(t){return t instanceof Array||a.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===m.indexOf(t)&&a.Util.warn("Unknown anchor name: "+t+". Available names are: "+m.join(", "))})),t||[]})),s.Factory.addGetterSetter(S,"resizeEnabled",!0),s.Factory.addGetterSetter(S,"anchorSize",10,p.getNumberValidator()),s.Factory.addGetterSetter(S,"rotateEnabled",!0),s.Factory.addGetterSetter(S,"rotationSnaps",[]),s.Factory.addGetterSetter(S,"rotateAnchorOffset",50,p.getNumberValidator()),s.Factory.addGetterSetter(S,"rotationSnapTolerance",5,p.getNumberValidator()),s.Factory.addGetterSetter(S,"borderEnabled",!0),s.Factory.addGetterSetter(S,"anchorStroke","rgb(0, 161, 255)"),s.Factory.addGetterSetter(S,"anchorStrokeWidth",1,p.getNumberValidator()),s.Factory.addGetterSetter(S,"anchorFill","white"),s.Factory.addGetterSetter(S,"anchorCornerRadius",0,p.getNumberValidator()),s.Factory.addGetterSetter(S,"borderStroke","rgb(0, 161, 255)"),s.Factory.addGetterSetter(S,"borderStrokeWidth",1,p.getNumberValidator()),s.Factory.addGetterSetter(S,"borderDash"),s.Factory.addGetterSetter(S,"keepRatio",!0),s.Factory.addGetterSetter(S,"centeredScaling",!1),s.Factory.addGetterSetter(S,"ignoreStroke",!1),s.Factory.addGetterSetter(S,"padding",0,p.getNumberValidator()),s.Factory.addGetterSetter(S,"node"),s.Factory.addGetterSetter(S,"nodes"),s.Factory.addGetterSetter(S,"boundBoxFunc"),s.Factory.addGetterSetter(S,"shouldOverdrawWholeArea",!1),s.Factory.backCompat(S,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),a.Collection.mapMethods(S)},function(t,e,i){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var o=i(3),a=i(0),s=i(5),h=i(1),c=i(2),l=i(1),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._sceneFunc=function(t){t.beginPath(),t.arc(0,0,this.radius(),0,h.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)},e.prototype.getWidth=function(){return 2*this.radius()},e.prototype.getHeight=function(){return 2*this.radius()},e.prototype.setWidth=function(t){this.radius(t/2)},e.prototype.setHeight=function(t){this.radius(t/2)},e}(s.Shape);e.Wedge=u,u.prototype.className="Wedge",u.prototype._centroid=!0,u.prototype._attrsAffectingSize=["radius"],l._registerNode(u),a.Factory.addGetterSetter(u,"radius",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"angle",0,c.getNumberValidator()),a.Factory.addGetterSetter(u,"clockwise",!1),a.Factory.backCompat(u,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),o.Collection.mapMethods(u)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);function a(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var s=[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],h=[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];e.Blur=function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,r,n,o,c,l,u,d,p,f,g,y,v,_,m,b,x,S,w,C,P,A,T,k,M=t.data,F=t.width,O=t.height,G=e+e+1,D=F-1,N=O-1,E=e+1,R=E*(E+1)/2,L=new a,I=null,z=L,U=null,j=null,V=s[e],B=h[e];for(n=1;n<G;n++)z=z.next=new a,n===E&&(I=z);for(z.next=L,u=l=0,r=0;r<O;r++){for(b=x=S=w=d=p=f=g=0,y=E*(C=M[l]),v=E*(P=M[l+1]),_=E*(A=M[l+2]),m=E*(T=M[l+3]),d+=R*C,p+=R*P,f+=R*A,g+=R*T,z=L,n=0;n<E;n++)z.r=C,z.g=P,z.b=A,z.a=T,z=z.next;for(n=1;n<E;n++)o=l+((D<n?D:n)<<2),d+=(z.r=C=M[o])*(k=E-n),p+=(z.g=P=M[o+1])*k,f+=(z.b=A=M[o+2])*k,g+=(z.a=T=M[o+3])*k,b+=C,x+=P,S+=A,w+=T,z=z.next;for(U=L,j=I,i=0;i<F;i++)M[l+3]=T=g*V>>B,0!==T?(T=255/T,M[l]=(d*V>>B)*T,M[l+1]=(p*V>>B)*T,M[l+2]=(f*V>>B)*T):M[l]=M[l+1]=M[l+2]=0,d-=y,p-=v,f-=_,g-=m,y-=U.r,v-=U.g,_-=U.b,m-=U.a,o=u+((o=i+e+1)<D?o:D)<<2,d+=b+=U.r=M[o],p+=x+=U.g=M[o+1],f+=S+=U.b=M[o+2],g+=w+=U.a=M[o+3],U=U.next,y+=C=j.r,v+=P=j.g,_+=A=j.b,m+=T=j.a,b-=C,x-=P,S-=A,w-=T,j=j.next,l+=4;u+=F}for(i=0;i<F;i++){for(x=S=w=b=p=f=g=d=0,y=E*(C=M[l=i<<2]),v=E*(P=M[l+1]),_=E*(A=M[l+2]),m=E*(T=M[l+3]),d+=R*C,p+=R*P,f+=R*A,g+=R*T,z=L,n=0;n<E;n++)z.r=C,z.g=P,z.b=A,z.a=T,z=z.next;for(c=F,n=1;n<=e;n++)l=c+i<<2,d+=(z.r=C=M[l])*(k=E-n),p+=(z.g=P=M[l+1])*k,f+=(z.b=A=M[l+2])*k,g+=(z.a=T=M[l+3])*k,b+=C,x+=P,S+=A,w+=T,z=z.next,n<N&&(c+=F);for(l=i,U=L,j=I,r=0;r<O;r++)M[(o=l<<2)+3]=T=g*V>>B,T>0?(T=255/T,M[o]=(d*V>>B)*T,M[o+1]=(p*V>>B)*T,M[o+2]=(f*V>>B)*T):M[o]=M[o+1]=M[o+2]=0,d-=y,p-=v,f-=_,g-=m,y-=U.r,v-=U.g,_-=U.b,m-=U.a,o=i+((o=r+E)<N?o:N)*F<<2,d+=b+=U.r=M[o],p+=x+=U.g=M[o+1],f+=S+=U.b=M[o+2],g+=w+=U.a=M[o+3],U=U.next,y+=C=j.r,v+=P=j.g,_+=A=j.b,m+=T=j.a,b-=C,x-=P,S-=A,w-=T,j=j.next,l+=F}}(t,e)},r.Factory.addGetterSetter(n.Node,"blurRadius",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.Brighten=function(t){var e,i=255*this.brightness(),r=t.data,n=r.length;for(e=0;e<n;e+=4)r[e]+=i,r[e+1]+=i,r[e+2]+=i},r.Factory.addGetterSetter(n.Node,"brightness",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.Contrast=function(t){var e,i=Math.pow((this.contrast()+100)/100,2),r=t.data,n=r.length,o=150,a=150,s=150;for(e=0;e<n;e+=4)o=r[e],a=r[e+1],s=r[e+2],o/=255,o-=.5,o*=i,o+=.5,a/=255,a-=.5,a*=i,a+=.5,s/=255,s-=.5,s*=i,s+=.5,o=(o*=255)<0?0:o>255?255:o,a=(a*=255)<0?0:a>255?255:a,s=(s*=255)<0?0:s>255?255:s,r[e]=o,r[e+1]=a,r[e+2]=s},r.Factory.addGetterSetter(n.Node,"contrast",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(3),a=i(2);e.Emboss=function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),n=this.embossBlend(),a=0,s=0,h=t.data,c=t.width,l=t.height,u=4*c,d=l;switch(r){case"top-left":a=-1,s=-1;break;case"top":a=-1,s=0;break;case"top-right":a=-1,s=1;break;case"right":a=0,s=1;break;case"bottom-right":a=1,s=1;break;case"bottom":a=1,s=0;break;case"bottom-left":a=1,s=-1;break;case"left":a=0,s=-1;break;default:o.Util.error("Unknown emboss direction: "+r)}do{var p=(d-1)*u,f=a;d+f<1&&(f=0),d+f>l&&(f=0);var g=(d-1+f)*c*4,y=c;do{var v=p+4*(y-1),_=s;y+_<1&&(_=0),y+_>c&&(_=0);var m=g+4*(y-1+_),b=h[v]-h[m],x=h[v+1]-h[m+1],S=h[v+2]-h[m+2],w=b,C=w>0?w:-w;if((x>0?x:-x)>C&&(w=x),(S>0?S:-S)>C&&(w=S),w*=e,n){var P=h[v]+w,A=h[v+1]+w,T=h[v+2]+w;h[v]=P>255?255:P<0?0:P,h[v+1]=A>255?255:A<0?0:A,h[v+2]=T>255?255:T<0?0:T}else{var k=i-w;k<0?k=0:k>255&&(k=255),h[v]=h[v+1]=h[v+2]=k}}while(--y)}while(--d)},r.Factory.addGetterSetter(n.Node,"embossStrength",.5,a.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"embossWhiteLevel",.5,a.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"embossDirection","top-left",null,r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"embossBlend",!1,null,r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);function a(t,e,i,r,n){var o=i-e,a=n-r;return 0===o?r+a/2:0===a?r:a*((t-e)/o)+r}e.Enhance=function(t){var e,i,r,n,o=t.data,s=o.length,h=o[0],c=h,l=o[1],u=l,d=o[2],p=d,f=this.enhance();if(0!==f){for(n=0;n<s;n+=4)(e=o[n+0])<h?h=e:e>c&&(c=e),(i=o[n+1])<l?l=i:i>u&&(u=i),(r=o[n+2])<d?d=r:r>p&&(p=r);var g,y,v,_,m,b,x,S,w;for(c===h&&(c=255,h=0),u===l&&(u=255,l=0),p===d&&(p=255,d=0),f>0?(y=c+f*(255-c),v=h-f*(h-0),m=u+f*(255-u),b=l-f*(l-0),S=p+f*(255-p),w=d-f*(d-0)):(y=c+f*(c-(g=.5*(c+h))),v=h+f*(h-g),m=u+f*(u-(_=.5*(u+l))),b=l+f*(l-_),S=p+f*(p-(x=.5*(p+d))),w=d+f*(d-x)),n=0;n<s;n+=4)o[n+0]=a(o[n+0],h,c,v,y),o[n+1]=a(o[n+1],l,u,b,m),o[n+2]=a(o[n+2],d,p,w,S)}},r.Factory.addGetterSetter(n.Node,"enhance",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Grayscale=function(t){var e,i,r=t.data,n=r.length;for(e=0;e<n;e+=4)i=.34*r[e]+.5*r[e+1]+.16*r[e+2],r[e]=i,r[e+1]=i,r[e+2]=i}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);r.Factory.addGetterSetter(n.Node,"hue",0,o.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"saturation",0,o.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"luminance",0,o.getNumberValidator(),r.Factory.afterSetFilter),e.HSL=function(t){var e,i,r,n,o,a=t.data,s=a.length,h=Math.pow(2,this.saturation()),c=Math.abs(this.hue()+360)%360,l=127*this.luminance(),u=1*h*Math.cos(c*Math.PI/180),d=1*h*Math.sin(c*Math.PI/180),p=.299+.701*u+.167*d,f=.587-.587*u+.33*d,g=.114-.114*u-.497*d,y=.299-.299*u-.328*d,v=.587+.413*u+.035*d,_=.114-.114*u+.293*d,m=.299-.3*u+1.25*d,b=.587-.586*u-1.05*d,x=.114+.886*u-.2*d;for(e=0;e<s;e+=4)i=a[e+0],r=a[e+1],n=a[e+2],o=a[e+3],a[e+0]=p*i+f*r+g*n+l,a[e+1]=y*i+v*r+_*n+l,a[e+2]=m*i+b*r+x*n+l,a[e+3]=o}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.HSV=function(t){var e,i,r,n,o,a=t.data,s=a.length,h=Math.pow(2,this.value()),c=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,u=h*c*Math.cos(l*Math.PI/180),d=h*c*Math.sin(l*Math.PI/180),p=.299*h+.701*u+.167*d,f=.587*h-.587*u+.33*d,g=.114*h-.114*u-.497*d,y=.299*h-.299*u-.328*d,v=.587*h+.413*u+.035*d,_=.114*h-.114*u+.293*d,m=.299*h-.3*u+1.25*d,b=.587*h-.586*u-1.05*d,x=.114*h+.886*u-.2*d;for(e=0;e<s;e+=4)i=a[e+0],r=a[e+1],n=a[e+2],o=a[e+3],a[e+0]=p*i+f*r+g*n,a[e+1]=y*i+v*r+_*n,a[e+2]=m*i+b*r+x*n,a[e+3]=o},r.Factory.addGetterSetter(n.Node,"hue",0,o.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"saturation",0,o.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"value",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Invert=function(t){var e,i=t.data,r=i.length;for(e=0;e<r;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(3),a=i(2);e.Kaleidoscope=function(t){var e,i,r,n,a,s,h,c,l,u=t.width,d=t.height,p=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(u*(f%360)/360);if(!(p<1)){var y=o.Util.createCanvasElement();y.width=u,y.height=d;var v=y.getContext("2d").getImageData(0,0,u,d);!function(t,e,i){var r,n,o,a,s=t.data,h=e.data,c=t.width,l=t.height,u=i.polarCenterX||c/2,d=i.polarCenterY||l/2,p=0,f=0,g=0,y=0,v=Math.sqrt(u*u+d*d);n=c-u,o=l-d,v=(a=Math.sqrt(n*n+o*o))>v?a:v;var _,m,b,x,S=l,w=c,C=360/w*Math.PI/180;for(m=0;m<w;m+=1)for(b=Math.sin(m*C),x=Math.cos(m*C),_=0;_<S;_+=1)n=Math.floor(u+v*_/S*x),p=s[(r=4*((o=Math.floor(d+v*_/S*b))*c+n))+0],f=s[r+1],g=s[r+2],y=s[r+3],h[(r=4*(m+_*c))+0]=p,h[r+1]=f,h[r+2]=g,h[r+3]=y}(t,v,{polarCenterX:u/2,polarCenterY:d/2});for(var _=u/Math.pow(2,p);_<=8;)_*=2,p-=1;var m=_=Math.ceil(_),b=0,x=m,S=1;for(g+_>u&&(b=m,x=0,S=-1),i=0;i<d;i+=1)for(e=b;e!==x;e+=S)c=4*(u*i+Math.round(e+g)%u),n=v.data[c+0],a=v.data[c+1],s=v.data[c+2],h=v.data[c+3],l=4*(u*i+e),v.data[l+0]=n,v.data[l+1]=a,v.data[l+2]=s,v.data[l+3]=h;for(i=0;i<d;i+=1)for(m=Math.floor(_),r=0;r<p;r+=1){for(e=0;e<m+1;e+=1)c=4*(u*i+e),n=v.data[c+0],a=v.data[c+1],s=v.data[c+2],h=v.data[c+3],l=4*(u*i+2*m-e-1),v.data[l+0]=n,v.data[l+1]=a,v.data[l+2]=s,v.data[l+3]=h;m*=2}!function(t,e,i){var r,n,o,a,s,h,c=t.data,l=e.data,u=t.width,d=t.height,p=i.polarCenterX||u/2,f=i.polarCenterY||d/2,g=0,y=0,v=0,_=0,m=Math.sqrt(p*p+f*f);n=u-p,o=d-f,m=(h=Math.sqrt(n*n+o*o))>m?h:m;var b,x,S,w=d,C=u,P=i.polarRotation||0;for(n=0;n<u;n+=1)for(o=0;o<d;o+=1)a=n-p,s=o-f,b=Math.sqrt(a*a+s*s)*w/m,x=(x=(180*Math.atan2(s,a)/Math.PI+360+P)%360)*C/360,S=Math.floor(x),g=c[(r=4*(Math.floor(b)*u+S))+0],y=c[r+1],v=c[r+2],_=c[r+3],l[(r=4*(o*u+n))+0]=g,l[r+1]=y,l[r+2]=v,l[r+3]=_}(v,t,{polarRotation:0})}},r.Factory.addGetterSetter(n.Node,"kaleidoscopePower",2,a.getNumberValidator(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"kaleidoscopeAngle",0,a.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);function a(t,e,i){var r=4*(i*t.width+e),n=[];return n.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),n}function s(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))}e.Mask=function(t){var e=function(t,e){var i=a(t,0,0),r=a(t,t.width-1,0),n=a(t,0,t.height-1),o=a(t,t.width-1,t.height-1),h=e||10;if(s(i,r)<h&&s(r,o)<h&&s(o,n)<h&&s(n,i)<h){for(var c=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}([r,i,o,n]),l=[],u=0;u<t.width*t.height;u++){var d=s(c,[t.data[4*u],t.data[4*u+1],t.data[4*u+2]]);l[u]=d<h?0:255}return l}}(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 r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],n=Math.round(Math.sqrt(r.length)),o=Math.floor(n/2),a=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var c=s*e+h,l=0,u=0;u<n;u++)for(var d=0;d<n;d++){var p=s+u-o,f=h+d-o;if(p>=0&&p<i&&f>=0&&f<e){var g=r[u*n+d];l+=t[p*e+f]*g}}a[c]=l}return a}(e=function(t,e,i){for(var r=[1,1,1,1,1,1,1,1,1],n=Math.round(Math.sqrt(r.length)),o=Math.floor(n/2),a=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var c=s*e+h,l=0,u=0;u<n;u++)for(var d=0;d<n;d++){var p=s+u-o,f=h+d-o;if(p>=0&&p<i&&f>=0&&f<e){var g=r[u*n+d];l+=t[p*e+f]*g}}a[c]=l>=1020?255:0}return a}(e=function(t,e,i){for(var r=[1,1,1,1,0,1,1,1,1],n=Math.round(Math.sqrt(r.length)),o=Math.floor(n/2),a=[],s=0;s<i;s++)for(var h=0;h<e;h++){for(var c=s*e+h,l=0,u=0;u<n;u++)for(var d=0;d<n;d++){var p=s+u-o,f=h+d-o;if(p>=0&&p<i&&f>=0&&f<e){var g=r[u*n+d];l+=t[p*e+f]*g}}a[c]=2040===l?255:0}return a}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},r.Factory.addGetterSetter(n.Node,"threshold",0,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.Noise=function(t){var e,i=255*this.noise(),r=t.data,n=r.length,o=i/2;for(e=0;e<n;e+=4)r[e+0]+=o-2*o*Math.random(),r[e+1]+=o-2*o*Math.random(),r[e+2]+=o-2*o*Math.random()},r.Factory.addGetterSetter(n.Node,"noise",.2,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(3),o=i(4),a=i(2);e.Pixelate=function(t){var e,i,r,o,a,s,h,c,l,u,d,p,f,g,y=Math.ceil(this.pixelSize()),v=t.width,_=t.height,m=Math.ceil(v/y),b=Math.ceil(_/y),x=t.data;if(y<=0)n.Util.error("pixelSize value can not be <= 0");else for(p=0;p<m;p+=1)for(f=0;f<b;f+=1){for(o=0,a=0,s=0,h=0,l=(c=p*y)+y,d=(u=f*y)+y,g=0,e=c;e<l;e+=1)if(!(e>=v))for(i=u;i<d;i+=1)i>=_||(o+=x[(r=4*(v*i+e))+0],a+=x[r+1],s+=x[r+2],h+=x[r+3],g+=1);for(o/=g,a/=g,s/=g,h/=g,e=c;e<l;e+=1)if(!(e>=v))for(i=u;i<d;i+=1)i>=_||(x[(r=4*(v*i+e))+0]=o,x[r+1]=a,x[r+2]=s,x[r+3]=h)}},r.Factory.addGetterSetter(o.Node,"pixelSize",8,a.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.Posterize=function(t){var e,i=Math.round(254*this.levels())+1,r=t.data,n=r.length,o=255/i;for(e=0;e<n;e+=1)r[e]=Math.floor(r[e]/o)*o},r.Factory.addGetterSetter(n.Node,"levels",.5,o.getNumberValidator(),r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.RGB=function(t){var e,i,r=t.data,n=r.length,o=this.red(),a=this.green(),s=this.blue();for(e=0;e<n;e+=4)i=(.34*r[e]+.5*r[e+1]+.16*r[e+2])/255,r[e]=i*o,r[e+1]=i*a,r[e+2]=i*s,r[e+3]=r[e+3]},r.Factory.addGetterSetter(n.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),r.Factory.addGetterSetter(n.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),r.Factory.addGetterSetter(n.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.RGBA=function(t){var e,i,r=t.data,n=r.length,o=this.red(),a=this.green(),s=this.blue(),h=this.alpha();for(e=0;e<n;e+=4)i=1-h,r[e]=o*h+r[e]*i,r[e+1]=a*h+r[e+1]*i,r[e+2]=s*h+r[e+2]*i},r.Factory.addGetterSetter(n.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),r.Factory.addGetterSetter(n.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),r.Factory.addGetterSetter(n.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter),r.Factory.addGetterSetter(n.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}))},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sepia=function(t){var e,i,r,n,o=t.data,a=o.length;for(e=0;e<a;e+=4)i=o[e+0],r=o[e+1],n=o[e+2],o[e+0]=Math.min(255,.393*i+.769*r+.189*n),o[e+1]=Math.min(255,.349*i+.686*r+.168*n),o[e+2]=Math.min(255,.272*i+.534*r+.131*n)}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Solarize=function(t){var e=t.data,i=t.width,r=4*i,n=t.height;do{var o=(n-1)*r,a=i;do{var s=o+4*(a-1),h=e[s],c=e[s+1],l=e[s+2];h>127&&(h=255-h),c>127&&(c=255-c),l>127&&(l=255-l),e[s]=h,e[s+1]=c,e[s+2]=l}while(--a)}while(--n)}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),n=i(4),o=i(2);e.Threshold=function(t){var e,i=255*this.threshold(),r=t.data,n=r.length;for(e=0;e<n;e+=1)r[e]=r[e]<i?0:255},r.Factory.addGetterSetter(n.Node,"threshold",.5,o.getNumberValidator(),r.Factory.afterSetFilter)}]);
2
+ //# sourceMappingURL=headbreaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack://headbreaker/webpack/bootstrap","webpack://headbreaker/../node_modules/konva/lib/Factory.js","webpack://headbreaker/../node_modules/konva/lib/Global.js","webpack://headbreaker/../node_modules/konva/lib/Validators.js","webpack://headbreaker/../node_modules/konva/lib/Util.js","webpack://headbreaker/../node_modules/konva/lib/Node.js","webpack://headbreaker/../node_modules/konva/lib/Shape.js","webpack://headbreaker/./piece.js","webpack://headbreaker/./pair.js","webpack://headbreaker/./position.js","webpack://headbreaker/../node_modules/konva/lib/Container.js","webpack://headbreaker/./anchor.js","webpack://headbreaker/../node_modules/konva/lib/Canvas.js","webpack://headbreaker/./puzzle.js","webpack://headbreaker/./insert.js","webpack://headbreaker/./validator.js","webpack://headbreaker/./canvas.js","webpack://headbreaker/../node_modules/konva/lib/DragAndDrop.js","webpack://headbreaker/./prelude.js","webpack://headbreaker/./structure.js","webpack://headbreaker/./sequence.js","webpack://headbreaker/./metadata.js","webpack://headbreaker/../node_modules/konva/lib/Group.js","webpack://headbreaker/../node_modules/konva/lib/Animation.js","webpack://headbreaker/./outline.js","webpack://headbreaker/./manufacturer.js","webpack://headbreaker/./spatial-metadata.js","webpack://headbreaker/./painter.js","webpack://headbreaker/../node_modules/konva/lib/Context.js","webpack://headbreaker/../node_modules/konva/lib/PointerEvents.js","webpack://headbreaker/../node_modules/konva/lib/BaseLayer.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Line.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Path.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Rect.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Text.js","webpack://headbreaker/./index.js","webpack://headbreaker/./between.js","webpack://headbreaker/./connector.js","webpack://headbreaker/./image-metadata.js","webpack://headbreaker/./dummy-painter.js","webpack://headbreaker/./konva-painter.js","webpack://headbreaker/../node_modules/konva/lib/index.js","webpack://headbreaker/../node_modules/konva/lib/_FullInternals.js","webpack://headbreaker/../node_modules/konva/lib/_CoreInternals.js","webpack://headbreaker/../node_modules/webpack/buildin/global.js","webpack://headbreaker/../node_modules/konva/lib/Stage.js","webpack://headbreaker/../node_modules/konva/lib/Layer.js","webpack://headbreaker/../node_modules/konva/lib/FastLayer.js","webpack://headbreaker/../node_modules/konva/lib/Tween.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Arc.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Arrow.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Circle.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Ellipse.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Image.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Label.js","webpack://headbreaker/../node_modules/konva/lib/shapes/RegularPolygon.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Ring.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Sprite.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Star.js","webpack://headbreaker/../node_modules/konva/lib/shapes/TextPath.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Transformer.js","webpack://headbreaker/../node_modules/konva/lib/shapes/Wedge.js","webpack://headbreaker/../node_modules/konva/lib/filters/Blur.js","webpack://headbreaker/../node_modules/konva/lib/filters/Brighten.js","webpack://headbreaker/../node_modules/konva/lib/filters/Contrast.js","webpack://headbreaker/../node_modules/konva/lib/filters/Emboss.js","webpack://headbreaker/../node_modules/konva/lib/filters/Enhance.js","webpack://headbreaker/../node_modules/konva/lib/filters/Grayscale.js","webpack://headbreaker/../node_modules/konva/lib/filters/HSL.js","webpack://headbreaker/../node_modules/konva/lib/filters/HSV.js","webpack://headbreaker/../node_modules/konva/lib/filters/Invert.js","webpack://headbreaker/../node_modules/konva/lib/filters/Kaleidoscope.js","webpack://headbreaker/../node_modules/konva/lib/filters/Mask.js","webpack://headbreaker/../node_modules/konva/lib/filters/Noise.js","webpack://headbreaker/../node_modules/konva/lib/filters/Pixelate.js","webpack://headbreaker/../node_modules/konva/lib/filters/Posterize.js","webpack://headbreaker/../node_modules/konva/lib/filters/RGB.js","webpack://headbreaker/../node_modules/konva/lib/filters/RGBA.js","webpack://headbreaker/../node_modules/konva/lib/filters/Sepia.js","webpack://headbreaker/../node_modules/konva/lib/filters/Solarize.js","webpack://headbreaker/../node_modules/konva/lib/filters/Threshold.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","Util_1","Validators_1","Factory","addGetterSetter","constructor","attr","def","validator","after","this","addGetter","addSetter","addOverloadedGetterSetter","method","Util","_capitalize","val","attrs","undefined","overWriteSetter","_setAttr","addComponentsGetterSetter","components","component","len","length","capitalize","setter","ret","getAttr","basicValidator","getComponentValidator","oldVal","_fireChangeEvent","capitalizedAttr","arguments","addDeprecatedGetterSetter","error","message","backCompat","methods","each","oldMethodName","newMethodName","oldGetter","oldSetter","deprecated","apply","afterSetFilter","_filterUpToDate","PI_OVER_180","Math","PI","_detectIE","ua","msie","indexOf","parseInt","substring","rv","edge","_parseUA","userAgent","toLowerCase","match","exec","mobile","ieMobile","browser","version","isIE","glob","global","window","WorkerGlobalScope","self","Konva","_global","isBrowser","toString","isUnminified","test","param","dblClickWindow","getAngle","angle","angleDeg","enableTrace","_pointerEventsEnabled","hitOnDragEnabled","captureTouchEventsEnabled","listenClickTap","inDblClickWindow","pixelRatio","dragDistance","showWarnings","dragButtons","isDragging","isDragReady","node","UA","navigator","document","_injectGlobal","_NODES_REGISTRY","_registerNode","NodeClass","getClassName","Global_1","_formatValue","_isString","_isBoolean","RGBComponent","round","alphaComponent","getNumberValidator","_isNumber","warn","getNumberOrAutoValidator","getStringValidator","getFunctionValidator","_isFunction","getNumberArrayValidator","_isArray","forEach","item","getBooleanValidator","isObject","Collection","toCollection","arr","collection","push","_mapMethod","methodName","args","slice","mapMethods","prot","func","toArray","Transform","copy","point","x","y","translate","scale","sx","sy","rotate","rad","cos","sin","m11","m12","m21","m22","getTranslation","skew","multiply","matrix","dx","dy","invert","m0","m1","m2","m3","m4","m5","getMatrix","setAbsolutePosition","yt","xt","decompose","a","b","delta","result","rotation","scaleX","scaleY","skewX","skewY","sqrt","acos","_getRotation","PI_OVER_DEG180","DEG180_OVER_PI","COLORS","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","transparent","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","RGB_REGEX","animQueue","_isElement","obj","nodeType","_isPlainObject","isNaN","isFinite","isValidSelector","selector","firstChar","toUpperCase","_sign","number","requestAnimFrame","callback","requestAnimationFrame","queue","cb","createCanvasElement","canvas","createElement","style","e","createImageElement","_isInDocument","el","parentNode","_simplifyArray","retArr","util","_urlToImage","url","imageObj","Image","onload","src","_rgbToHex","g","_hexToRgb","hex","replace","bigint","getRandomColor","randColor","random","getRGB","color","rgb","substr","colorToRGBA","str","_namedColorToRBA","_hex3ColorToRGBA","_hex6ColorToRGBA","_rgbColorToRGBA","_rgbaColorToRGBA","_hslColorToRGBA","parts","split","map","Number","_a","hsl","h","t2","t3","t1","haveIntersection","r1","r2","width","height","cloneObject","retObj","cloneArray","_degToRad","deg","_radToDeg","radians","charAt","throw","Error","console","extend","child","parent","Ctor","oldProto","__super__","super","_getControlPoints","x0","y0","x1","y1","x2","y2","d01","pow","d12","fa","fb","_expandPoints","tension","cp","allPoints","_inRange","left","right","_getProjectionToSegment","x3","y3","dist","pd2","u","_getProjectionToLine","pt","line","isClosed","pc","MAX_VALUE","p1","p2","proj","px","py","pdist","_prepareArrayForTween","startArray","endArray","start","end","temp","newStart","pr","_prepareToStringify","desc","visitedByCircularReferenceRemoval","getOwnPropertyDescriptor","configurable","_assign","target","source","_getFirstPointerId","evt","touches","changedTouches","identifier","Factory_1","Canvas_1","DragAndDrop_1","ids","names","_removeId","id","_addName","_removeName","_id","nodes","splice","TRANSFORM_CHANGE_STR","join","emptyChildren","idCounter","Node","config","_this","eventListeners","index","_cache","Map","_lastPos","_batchingTransformChange","_needClearTransformCache","_isUnderCache","children","_dragEventId","setAttrs","on","_clearCache","_clearSelfAndDescendantCache","hasChildren","getChildren","delete","clear","_getCache","privateGetter","cache","set","_getCanvasCache","forceEvent","fire","isCached","clearCache","conf","rect","getClientRect","skipTransform","relativeTo","getParent","ceil","offset","drawBorder","cachedSceneCanvas","SceneCanvas","cachedFilterCanvas","cachedHitCanvas","HitCanvas","sceneContext","getContext","hitContext","isCache","imageSmoothingEnabled","_context","save","drawScene","drawHit","restore","beginPath","closePath","setAttr","stroke","scene","filter","hit","has","_transformedRect","top","minX","minY","maxX","maxY","points","trans","getAbsoluteTransform","transformed","min","max","_drawCachedSceneCanvas","context","_applyOpacity","_applyGlobalCompositeOperation","canvasCache","cacheCanvas","_getCachedSceneCanvas","ratio","drawImage","_canvas","_drawCachedHitCanvas","hitCanvas","imageData","filters","cachedCanvas","sceneCanvas","filterCanvas","filterContext","setSize","getWidth","getHeight","getImageData","putImageData","evtStr","handler","_delegate","baseEvent","events","off","_off","dispatchEvent","type","addEventListener","removeEventListener","event","stopNode","targets","findAncestors","currentTarget","remove","stopDrag","DD","_dragElements","_remove","_clearCaches","_setChildrenIndices","destroy","subname","getAncestors","ancestors","getAttrs","isListening","_isListening","listening","isVisible","_isVisible","visible","shouldDrawHit","layer","getLayer","hitGraphEnabled","show","hide","getZIndex","getAbsoluteZIndex","depth","getDepth","that","addChildren","concat","getStage","_batchTransformChanges","setPosition","pos","getPosition","getAbsolutePosition","haveCachedParent","absoluteMatrix","absoluteTransform","it","origTrans","_clearTransform","_getAbsoluteTransform","_setTransform","offsetX","offsetY","move","change","changeX","changeY","_eachAncestorReverse","family","unshift","theta","moveToTop","moveUp","moveDown","moveToBottom","setZIndex","zIndex","getAbsoluteOpacity","_getAbsoluteOpacity","absOpacity","opacity","moveTo","newContainer","add","toObject","defaultValue","className","toJSON","JSON","stringify","includeSelf","res","_isMatch","ancestor","isAncestorOf","findAncestor","sel","selectorArr","hasName","_getStage","eventType","bubble","_fireAndBubble","_fire","at","transformsEnabled","getTransform","getAbsoluteScale","getAbsoluteRotation","_getTransform","clone","allListeners","listener","_toKonvaCanvas","box","stage","toCanvas","toDataURL","mimeType","quality","toImage","img","size","getSize","getType","getDragDistance","evtName","evtListeners","newVal","setId","oldId","_addId","setName","oldNames","newNames","addName","oldName","newName","fullName","removeName","_setComponentAttr","compareShape","stopBubble","cancelBubble","draw","_createDragElement","pointerId","ap","_getPointerById","_changedPointerPositions","startPointerPos","dragStatus","startDrag","_setDragPosition","elem","newNodePos","dbf","dragBoundFunc","bounded","batchDraw","_endDragBefore","_endDragAfter","setDraggable","draggable","_dragChange","_listenDrag","_dragCleanup","hasDraggingChild","data","container","parse","_createNode","no","Class","_attrsAffectingSize","rotateDeg","setRotationDeg","getRotationDeg","extendStatics","__extends","setPrototypeOf","__proto__","Array","__","dummyContext","Node_1","PointerEvents","getDummyContext","_clearHasShadowCache","_clearGetShadowRGBACache","_clearFillPatternCache","_clearLinearGradientCache","_clearRadialGradientCache","shapes","Shape","_super","colorKey","getCanvas","getSceneFunc","sceneFunc","getHitFunc","hitFunc","hasShadow","_hasShadow","shadowEnabled","shadowOpacity","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","_getFillPattern","__getFillPattern","fillPatternImage","createPattern","fillPatternRepeat","_getLinearGradient","__getLinearGradient","colorStops","fillLinearGradientColorStops","ctx","fillLinearGradientStartPoint","fillLinearGradientEndPoint","grd","createLinearGradient","addColorStop","_getRadialGradient","__getRadialGradient","fillRadialGradientColorStops","fillRadialGradientStartPoint","fillRadialGradientEndPoint","createRadialGradient","fillRadialGradientStartRadius","fillRadialGradientEndRadius","getShadowRGBA","_getShadowRGBA","rgba","hasFill","fillEnabled","fill","hasStroke","strokeEnabled","strokeWidth","strokeLinearGradientColorStops","hasHitStroke","hitStrokeWidth","intersects","bufferHitCanvas","_useBufferCanvas","caching","perfectDrawEnabled","setStrokeHitEnabled","getStrokeHitEnabled","getSelfRect","_centroid","fillRect","skipStroke","fillAndStrokeWidth","fillAndStrokeHeight","applyShadow","skipShadow","preWidth","abs","preHeight","blurRadius","roundingOffset","can","skipBuffer","bufferCanvas","bufferContext","drawFunc","_applyTransform","_applyLineJoin","transform","_applyShadow","shadowForStrokeEnabled","log","drawHitFromCache","alphaThreshold","hitImageData","hitData","rgbColorKey","hitWidth","hitHeight","hasPointerCapture","setPointerCapture","releaseCapture","_fillFunc","_strokeFunc","_fillFuncHit","_strokeFuncHit","dashArray","getDashArray","setDashArray","getDrawFunc","setDrawFunc","drawHitFunc","getDrawHitFunc","setDrawHitFunc","Pair","anchor","Anchor","None","connector","Structure","itself","orthogonalTransform","Piece","up","down","metadata","centralAnchor","_initializeListeners","translateListeners","connectListeners","disconnectListeners","assign","puzzle","connections","rightConnection","downConnection","leftConnection","upConnection","f","other","others","back","vertical","connectWith","proximity","attract","horizontal","tryConnectHorizontallyWith","tryConnectVerticallyWith","canConnectHorizontallyWith","connectHorizontallyWith","canConnectVerticallyWith","connectVerticallyWith","connected","presentConnections","fireDisconnect","centerAround","isAt","quiet","diff","recenterAround","isNull","fireTranslate","pushedPieces","stationaries","horizontallyOpenMovement","vericallyOpenMovement","disconnect","autoconnectWith","drag","drop","openMovement","canConnectWith","closeTo","translated","pieceSize","compact","base","export","structure","serialize","dump","piece","deserialize","import","annotate","equal","position","one","origin","update","Container","filterFunc","results","removeChildren","destroyChildren","_i","_children","_validateAdd","find","_generalFind","findOne","_descendants","valid","fn","getAllIntersections","shape","_drawChildren","drawMethod","skipComposition","clipX","clipY","clipWidth","clipHeight","clipFunc","hasClip","clip","hasComposition","globalCompositeOperation","layerUnderDrag","dragSkip","selfRect","Infinity","hasVisible","between","tolerance","asPosition","_pixelRatio","Context_1","Canvas","devicePixelRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","getDevicePixelRatio","padding","margin","border","background","getPixelRatio","setPixelRatio","previousRatio","setWidth","setHeight","err","SceneContext","HitContext","NullValidator","Puzzle","pieces","options","addPiece","belongTo","relocateTo","tryConnectWith","atRandom","autoconnect","onTranslate","onConnect","onDisconnect","onValid","asPoint","pieceWidth","head","isValid","validate","every","addPieces","Tab","isSlot","isTab","isNone","complement","Slot","AbstractValidator","validListeners","_valid","wasValid","fireValid","PuzzleValidator","condition","relativeRefs","expected","PieceValidator","Manufacturer","twoAndTwo","imageLike","Position","Metadata","SpatialMetadata","borderFill","strokeColor","lineSoftness","image","painter","imageMetadata","asImageMetadata","_painter","_initialize","initialize","_puzzle","figures","templates","renderPiece","_newPiece","figure","label","group","sketch","text","fontSize","_bindGroupToPiece","_bindPieceToGroup","_annotatePiecePosition","renderPieces","horizontalPiecesCount","verticalPiecesCount","insertsGenerator","manufacturer","withDimmensions","withInsertsGenerator","withMetadata","autogenerateWithManufacturer","withStructure","settings","build","template","templateName","sketchPiece","farness","shuffle","autoconnected","targetPosition","redraw","reinitialize","attachValidator","solved","relativePosition","absolutePosition","getFigure","getFigureById","_dx","_dy","physicalTranslate","logicalTranslate","onDrag","onDragEnd","model","content","structureLike","newPiece","asStructure","locateAt","currentPosition","_initializeEmptyPuzzle","flag","justDragged","_drag","setPointersPositions","drawNode","orthogonalMap","values","mapper","replacement","pivot","arg","parseInsert","insert","string","InsertSequence","generator","_previous","_current","fixed","_n","flipflop","_","Container_1","Group","now","performance","Date","getTime","Animation","layers","animIdCounter","frame","time","timeDiff","lastTime","frameRate","setLayers","lays","getLayers","addLayer","isRunning","animations","stop","_addAnimation","_removeAnimation","_updateFrameObject","anim","_handleAnimation","_runFrames","layersLen","layerHash","_animationLoop","Anim","animRunning","select","Positioner","headAnchor","initializeOffset","xOffset","yOffset","positioner","horizontalSequence","verticalSequence","_newSequence","next","_buildPiece","naturalAnchor","_annotateAll","_annotate","baseMetadata","String","previousComplement","current","diffToTarget","CONTEXT_METHODS","Context","traceArr","_enableTrace","fillShape","_fill","strokeShape","_stroke","fillStrokeShape","getTrace","relaxed","trace","clearTrace","_trace","shift","reset","setTransform","bounds","clearRect","_applyLineCap","lineCap","getLineCap","lineJoin","getLineJoin","arc","a0","a1","a2","a3","a4","a5","arcTo","bezierCurveTo","createImageData","a6","a7","a8","ellipse","isPointInPath","strokeRect","fillText","measureText","lineTo","quadraticCurveTo","setLineDash","getLineDash","strokeText","origSetter","origMethod","prop","getGlobalCompositeOperation","_fillColor","_fillPattern","fillPatternX","getFillPatternX","fillPatternY","getFillPatternY","fillPatternRotation","getFillPatternRotation","fillPatternOffsetX","getFillPatternOffsetX","fillPatternOffsetY","getFillPatternOffsetY","fillPatternScaleX","getFillPatternScaleX","fillPatternScaleY","getFillPatternScaleY","_fillLinearGradient","_fillRadialGradient","hasColor","fillPriority","getFillPriority","hasPattern","getFillPatternImage","hasLinearGradient","getFillLinearGradientColorStops","hasRadialGradient","getFillRadialGradientColorStops","_strokeLinearGradient","getStrokeLinearGradientStartPoint","getStrokeLinearGradientEndPoint","getStrokeLinearGradientColorStops","dash","strokeScaleEnabled","getStrokeScaleEnabled","dashEnabled","dashOffset","getShadowForStrokeEnabled","blur","getShadowBlur","getShadowOffset","Captures","SUPPORT_POINTER_EVENTS","createEvent","PointerEvent","getCapturedShape","BaseLayer","_waitingForDraw","_checkVisibility","_setSmoothEnabled","createPNGStream","getHitCanvas","removeChild","insertBefore","appendChild","display","getIntersection","__spreadArrays","il","k","j","jl","Shape_1","Line","_sceneFunc","tp","closed","bezier","getTensionPoints","_getTensionPoints","_getTensionPointsClosed","firstControlPoints","lastControlPoints","middle","Path","dataArray","pathLength","parsePathData","ca","command","cx","cy","rx","ry","dTheta","psi","fs","inc","getPointOnEllipticalArc","getPointOnCubicBezier","getLength","getPointAtLength","ii","getPointOnLine","getPointOnQuadraticBezier","getLineLength","P1x","P1y","P2x","P2y","fromX","fromY","run","rise","ix","iy","pRise","pRun","pct","P3x","P3y","P4x","P4y","CB1","CB2","CB3","CB4","QB1","QB2","QB3","cosPsi","sinPsi","cs","cc","RegExp","coords","cpx","cpy","re","jlen","parsed","parseFloat","prevCmd","ctlPtx","ctlPty","cmd","startX","startY","idx","convertEndpointToCenterParameterization","calcLength","path","psiDeg","xp","yp","lambda","cxp","cyp","vMag","v","vRatio","vAngle","Rect","cornerRadius","topLeft","topRight","bottomLeft","bottomRight","Global_2","ATTR_CHANGE_LIST","attrChangeListLen","trimRight","Text","checkDefaultFill","_partialTextX","_partialTextY","_setTextData","lineHeightPx","lineHeight","textArr","textArrLen","verticalAlign","alignY","align","totalWidth","letterSpacing","textDecoration","shouldUnderline","shouldLineThrough","translateY","lineTranslateX","lineTranslateY","_getContextFont","spacesNumber","oneWord","lineWidth","lastLine","strokeStyle","li","letter","floor","_partialText","measureSize","_hitFunc","setText","getTextWidth","textWidth","getTextHeight","textHeight","metrics","font","fontStyle","fontFamily","fontVariant","_addTextLine","trim","_getTextWidth","lines","fixedWidth","fixedHeight","maxWidth","maxHeightPx","currentHeightPx","wrap","shouldWrap","wrapAtWord","shouldAddEllipsis","ellipsis","additionalWidth","low","high","matchWidth","mid","substrWidth","wrapIndex","nextChar","lastIndexOf","trimLeft","Outline","generators","painters","Dummy","Connector","axis","forward","backward","forwardAnchor","backwardAnchor","forwardConnection","backwardConnection","iron","magnet","fireConnect","HTMLImageElement","Painter","drawn","_piece","_figure","Stage","_options","_initializeLayer","Layer","_imageMetadataFor","fillPatternScale","fillPatternOffset","body","cursor","currentPositionDiff","_CoreInternals_1","Arc_1","Arrow_1","Circle_1","Ellipse_1","Image_1","Label_1","Line_1","Path_1","Rect_1","RegularPolygon_1","Ring_1","Sprite_1","Star_1","Text_1","TextPath_1","Transformer_1","Wedge_1","Blur_1","Brighten_1","Contrast_1","Emboss_1","Enhance_1","Grayscale_1","HSL_1","HSV_1","Invert_1","Kaleidoscope_1","Mask_1","Noise_1","Pixelate_1","Posterize_1","RGB_1","RGBA_1","Sepia_1","Solarize_1","Threshold_1","Arc","Arrow","Circle","Ellipse","Label","Tag","RegularPolygon","Ring","Sprite","Star","TextPath","Transformer","Wedge","Filters","Blur","Brighten","Contrast","Emboss","Enhance","Grayscale","HSL","HSV","Invert","Kaleidoscope","Mask","Noise","Pixelate","Posterize","RGB","RGBA","Sepia","Solarize","Threshold","Stage_1","Layer_1","FastLayer_1","Group_1","Animation_1","Tween_1","stages","FastLayer","Tween","Easings","Function","EVENTS","eventsLength","addEvent","eventName","checkNoClip","_pointerPositions","_buildDOM","_bindContentEvents","_resizeDOM","isLayer","isFastLayer","setContainer","getElementsByClassName","getElementById","parentElement","getPointerPosition","getPointersPositions","getContent","layerCanvas","_mouseenter","_mouseover","_mouseout","targetShape","eventsEnabled","pointerPos","_mousemove","_touchmove","cancelable","preventDefault","_mousedown","_touchstart","clickStartShape","_mouseup","_touchend","clickEndShape","fireDblClick","clearTimeout","dblTimeout","setTimeout","_contextmenu","triggeredOnShape","tapStartShape","processedShapesIds","tapTriggered","dblTapTriggered","_wheel","_pointerdown","_pointermove","_pointerup","_pointercancel","_lostpointercapture","contentPosition","_getContentPosition","touch","clientX","clientY","_setPointerPosition","getBoundingClientRect","clientWidth","clientHeight","innerHTML","userSelect","setAttribute","BaseLayer_1","INTERSECTION_OFFSETS","INTERSECTION_OFFSETS_LEN","intersectionOffset","spiralSearchDistance","continueSearch","_getIntersection","antialiased","p3","clearBeforeDraw","enableHitGraph","disableHitGraph","toggleHitCanvas","blacklist","duration","easing","onFinish","yoyo","colorAttrs","TweenEngine","propFunc","begin","finish","_pos","_change","prevPos","_time","_position","_startTime","_finish","pause","setTime","reverse","play","state","getTimer","onEnterFrame","seek","nodeId","Linear","tween","_tweenFunc","_addListeners","tweens","_addAttr","onReset","tweenId","trueEnd","trueStart","endRGBA","startRGBA","onPlay","onReverse","onPause","thisId","to","params","BackEaseIn","BackEaseOut","BackEaseInOut","ElasticEaseIn","asin","ElasticEaseOut","ElasticEaseInOut","BounceEaseOut","BounceEaseIn","BounceEaseInOut","EaseIn","EaseOut","EaseInOut","StrongEaseIn","StrongEaseOut","StrongEaseInOut","clockwise","outerRadius","innerRadius","PI2","fromTension","atan2","pointerLength","pointerWidth","pointerAtBeginning","isDashEnabled","lineRect","radius","radiusX","radiusY","cropWidth","cropHeight","cropX","cropY","fromURL","crossOrigin","_sync","getText","getTag","pointerDirection","pointerHeight","tag","direction","sides","PIx2","_updated","updated","frameIndex","clearInterval","interval","_setInterval","animation","ix4","offsets","frameOffsets","ix2","setInterval","_updateIndex","getIndex","setIndex","numPoints","partialText","dummyCanvas","kerningFunc","textBaseline","glyphInfo","p0","_getTextSize","textFullWidth","fullPathWidth","pathCmd","charArr","pIndex","currentT","getNextPathSegment","pathData","findSegmentToFitCharacter","glyphWidth","currLen","attempts","cumulativePathLength","needNewSegment","lettersInOffset","kern","midpoint","transposeX","transposeY","info","__assign","ANGLES","TOUCH_DEVICE","ANCHORS_NAMES","rotateAroundPoint","angleRad","rotateAroundCenter","deltaRad","getCenter","_transforming","_createElements","_handleMouseMove","_handleMouseUp","getNode","attachTo","setNode","setNodes","_nodes","detach","additionalEvents","onChange","_resetTransformCache","_proxyDrag","lastPos","otherNode","otherAbs","getNodes","getActiveAnchor","_movingAnchorName","_getNodeRect","__getNodeRect","__getNodeShape","rot","relative","ignoreStroke","absScale","absPos","totalPoints","tr","getX","getY","_createBack","_createAnchor","_handleMouseDown","anchorName","getCursor","_cursorChange","rotateEnabled","rotateAnchorOffset","shouldOverdrawWholeArea","hypotenuse","_anchorDragOffset","newHypotenuse","anchorNode","pp","oldAbs","newAbs","keepProportion","keepRatio","shiftKey","centeredScaling","altKey","comparePoint","reverseX","reverseY","topOffsetX","topOffsetY","bottomOffsetX","bottomOffsetY","_fitNodesInto","newRotation","tol","rotationSnapTolerance","snaps","newRotationRad","snapped","absDiff","getSnap","rotationSnaps","_removeEvents","newAttrs","oldAttrs","boundBoxFunc","oldTr","newTr","parentTransform","localTransform","newLocalTransform","forceUpdate","_batchChangeChild","enabledAnchors","resizeEnabled","anchorSize","anchorStroke","anchorStrokeWidth","anchorFill","anchorCornerRadius","borderEnabled","borderStroke","borderStrokeWidth","borderDash","isTransforming","stopTransform","lineEnabled","rotateHandlerOffset","enabledHandlers","getAngleDeg","setAngleDeg","BlurStack","mul_table","shg_table","yi","yw","r_sum","g_sum","b_sum","a_sum","r_out_sum","g_out_sum","b_out_sum","a_out_sum","r_in_sum","g_in_sum","b_in_sum","a_in_sum","pg","pb","pa","rbs","pixels","div","widthMinus1","heightMinus1","radiusPlus1","sumFactor","stackStart","stackEnd","stack","stackIn","stackOut","mul_sum","shg_sum","filterGaussBlurRGBA","brightness","adjust","contrast","nPixels","strength","embossStrength","greyLevel","embossWhiteLevel","embossDirection","blend","embossBlend","dirY","dirX","w","w4","otherY","offsetYOther","otherX","offsetOther","dR","dG","dB","dif","absDif","remap","fromValue","fromMin","fromMax","toMin","toMax","fromRange","toRange","nSubPixels","rMin","rMax","gMin","gMax","bMin","bMax","enhanceAmount","enhance","rMid","rGoalMax","rGoalMin","gMid","gGoalMax","gGoalMin","bMid","bGoalMax","bGoalMin","saturation","hue","luminance","vsu","vsw","rr","rg","rb","gr","gg","gb","br","bg","bb","srcPos","dstPos","xSize","ySize","power","kaleidoscopePower","kaleidoscopeAngle","tempCanvas","scratchData","dst","opt","srcPixels","dstPixels","xMid","polarCenterX","yMid","polarCenterY","rSize","tSize","conversion","ToPolar","minSectionSize","sectionSize","xStart","xEnd","xDelta","phaseShift","polarRotation","FromPolar","pixelAt","idata","rgbDistance","mask","threshold","rgbv_no","rgbv_ne","rgbv_so","rgbv_se","thres","mean","pTab","rgbMean","backgroundMask","applyMask","sw","sh","weights","side","halfSide","maskResult","so","scy","scx","wt","smoothEdgeMask","dilateMask","erodeMask","amount","noise","half","alpha","xBinStart","xBinEnd","yBinStart","yBinEnd","xBin","yBin","pixelsInBin","pixelSize","nBinsX","nBinsY","levels","ia","level"],"mappings":"4BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,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C,EAxBC,CAyBVrP,EAAQrhB,OACV9zB,EAAQwkD,MAAQA,EAChBA,EAAM1iD,UAAUorB,UAAY,QAC5Bs3B,EAAM1iD,UAAU21B,WAAY,EAC5B+sB,EAAM1iD,UAAU4wB,oBAAsB,CAAC,UACvCyoB,EAASxyC,cAAc67C,GACvB7jC,EAAUve,QAAQC,gBAAgBmiD,EAAO,SAAU,EAAGriD,EAAakH,sBACnEsX,EAAUve,QAAQC,gBAAgBmiD,EAAO,QAAS,EAAGriD,EAAakH,sBAClEsX,EAAUve,QAAQC,gBAAgBmiD,EAAO,aAAa,GACtD7jC,EAAUve,QAAQqC,WAAW+/C,EAAO,CAChCh9C,SAAU,QACV0yD,YAAa,WACbC,YAAa,aAEjBj4D,EAAOgI,WAAWS,WAAW65C,I,6BC3D7B5jD,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,IACtD,IAAIwf,EAAY,EAAQ,GACpB0S,EAAS,EAAQ,GACjBlxB,EAAe,EAAQ,GAC3B,SAASi4D,IACLz3D,KAAK3B,EAAI,EACT2B,KAAKiX,EAAI,EACTjX,KAAKwK,EAAI,EACTxK,KAAKuK,EAAI,EACTvK,KAAK8qC,KAAO,KAEhB,IAAI4sB,EAAY,CACZ,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAEAC,EAAY,CACZ,EACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IAwKJt6D,EAAQ0kD,KAAO,SAAcz9B,GACzB,IAAI0oC,EAAStqD,KAAK8D,MAAMxG,KAAKw1B,cACzBw3B,EAAS,GAxKjB,SAA6B1oC,EAAW0oC,GACpC,IACIzkD,EAAGC,EAAGjL,EAAG8B,EAAGq4C,EAAIkgB,EAAIC,EAAIC,EAAOC,EAAOC,EAAOC,EAAOC,EAAWC,EAAWC,EAAWC,EAAWC,EAAUC,EAAUC,EAAUC,EAAUv7C,EAAIw7C,EAAIC,EAAIC,EAAIC,EADxJC,EAASx0C,EAAUmL,KAAMvW,EAAQoL,EAAUpL,MAAOC,EAASmL,EAAUnL,OAErE4/C,EAAM/L,EAASA,EAAS,EAAGgM,EAAc9/C,EAAQ,EAAG+/C,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AAK8kE,EAAQ,EAAI,KAGxCrkD,EAAUve,QAAQC,gBAAgBgxB,EAAO1R,KAAM,YAAa,GAAKxf,EAAakH,qBAAsBsX,EAAUve,QAAQ8C","file":"headbreaker.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 34);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Validators_1 = require(\"./Validators\");\nvar GET = 'get', SET = 'set';\nexports.Factory = {\n addGetterSetter: function (constructor, attr, def, validator, after) {\n this.addGetter(constructor, attr, def);\n this.addSetter(constructor, attr, validator, after);\n this.addOverloadedGetterSetter(constructor, attr);\n },\n addGetter: function (constructor, attr, def) {\n var method = GET + Util_1.Util._capitalize(attr);\n constructor.prototype[method] =\n constructor.prototype[method] ||\n function () {\n var val = this.attrs[attr];\n return val === undefined ? def : val;\n };\n },\n addSetter: function (constructor, attr, validator, after) {\n var method = SET + Util_1.Util._capitalize(attr);\n if (!constructor.prototype[method]) {\n exports.Factory.overWriteSetter(constructor, attr, validator, after);\n }\n },\n overWriteSetter: function (constructor, attr, validator, after) {\n var method = SET + Util_1.Util._capitalize(attr);\n constructor.prototype[method] = function (val) {\n if (validator && val !== undefined && val !== null) {\n val = validator.call(this, val, attr);\n }\n this._setAttr(attr, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n },\n addComponentsGetterSetter: function (constructor, attr, components, validator, after) {\n var len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), n, component;\n constructor.prototype[getter] = function () {\n var ret = {};\n for (n = 0; n < len; n++) {\n component = components[n];\n ret[component] = this.getAttr(attr + capitalize(component));\n }\n return ret;\n };\n var basicValidator = Validators_1.getComponentValidator(components);\n constructor.prototype[setter] = function (val) {\n var oldVal = this.attrs[attr], key;\n if (validator) {\n val = validator.call(this, val);\n }\n if (basicValidator) {\n basicValidator.call(this, val, attr);\n }\n for (key in val) {\n if (!val.hasOwnProperty(key)) {\n continue;\n }\n this._setAttr(attr + capitalize(key), val[key]);\n }\n this._fireChangeEvent(attr, oldVal, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n this.addOverloadedGetterSetter(constructor, attr);\n },\n addOverloadedGetterSetter: function (constructor, attr) {\n var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;\n constructor.prototype[attr] = function () {\n if (arguments.length) {\n this[setter](arguments[0]);\n return this;\n }\n return this[getter]();\n };\n },\n addDeprecatedGetterSetter: function (constructor, attr, def, validator) {\n Util_1.Util.error('Adding deprecated ' + attr);\n var method = GET + Util_1.Util._capitalize(attr);\n var message = attr +\n ' property is deprecated and will be removed soon. Look at Konva change log for more information.';\n constructor.prototype[method] = function () {\n Util_1.Util.error(message);\n var val = this.attrs[attr];\n return val === undefined ? def : val;\n };\n this.addSetter(constructor, attr, validator, function () {\n Util_1.Util.error(message);\n });\n this.addOverloadedGetterSetter(constructor, attr);\n },\n backCompat: function (constructor, methods) {\n Util_1.Util.each(methods, function (oldMethodName, newMethodName) {\n var method = constructor.prototype[newMethodName];\n var oldGetter = GET + Util_1.Util._capitalize(oldMethodName);\n var oldSetter = SET + Util_1.Util._capitalize(oldMethodName);\n function deprecated() {\n method.apply(this, arguments);\n Util_1.Util.error('\"' +\n oldMethodName +\n '\" method is deprecated and will be removed soon. Use \"\"' +\n newMethodName +\n '\" instead.');\n }\n constructor.prototype[oldMethodName] = deprecated;\n constructor.prototype[oldGetter] = deprecated;\n constructor.prototype[oldSetter] = deprecated;\n });\n },\n afterSetFilter: function () {\n this._filterUpToDate = false;\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar PI_OVER_180 = Math.PI / 180;\nfunction detectBrowser() {\n return (typeof window !== 'undefined' &&\n ({}.toString.call(window) === '[object Window]' ||\n {}.toString.call(window) === '[object global]'));\n}\nvar _detectIE = function (ua) {\n var msie = ua.indexOf('msie ');\n if (msie > 0) {\n return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\n }\n var trident = ua.indexOf('trident/');\n if (trident > 0) {\n var rv = ua.indexOf('rv:');\n return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\n }\n var edge = ua.indexOf('edge/');\n if (edge > 0) {\n return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\n }\n return false;\n};\nexports._parseUA = function (userAgent) {\n var ua = userAgent.toLowerCase(), match = /(chrome)[ /]([\\w.]+)/.exec(ua) ||\n /(webkit)[ /]([\\w.]+)/.exec(ua) ||\n /(opera)(?:.*version|)[ /]([\\w.]+)/.exec(ua) ||\n /(msie) ([\\w.]+)/.exec(ua) ||\n (ua.indexOf('compatible') < 0 &&\n /(mozilla)(?:.*? rv:([\\w.]+)|)/.exec(ua)) ||\n [], mobile = !!userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i), ieMobile = !!userAgent.match(/IEMobile/i);\n return {\n browser: match[1] || '',\n version: match[2] || '0',\n isIE: _detectIE(ua),\n mobile: mobile,\n ieMobile: ieMobile\n };\n};\nexports.glob = typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : typeof WorkerGlobalScope !== 'undefined'\n ? self\n : {};\nexports.Konva = {\n _global: exports.glob,\n version: '6.0.0',\n isBrowser: detectBrowser(),\n isUnminified: /param/.test(function (param) { }.toString()),\n dblClickWindow: 400,\n getAngle: function (angle) {\n return exports.Konva.angleDeg ? angle * PI_OVER_180 : angle;\n },\n enableTrace: false,\n _pointerEventsEnabled: false,\n hitOnDragEnabled: false,\n captureTouchEventsEnabled: false,\n listenClickTap: false,\n inDblClickWindow: false,\n pixelRatio: undefined,\n dragDistance: 3,\n angleDeg: true,\n showWarnings: true,\n dragButtons: [0, 1],\n isDragging: function () {\n return exports.Konva['DD'].isDragging;\n },\n isDragReady: function () {\n return !!exports.Konva['DD'].node;\n },\n UA: exports._parseUA((exports.glob.navigator && exports.glob.navigator.userAgent) || ''),\n document: exports.glob.document,\n _injectGlobal: function (Konva) {\n exports.glob.Konva = Konva;\n },\n _parseUA: exports._parseUA\n};\nexports._NODES_REGISTRY = {};\nexports._registerNode = function (NodeClass) {\n exports._NODES_REGISTRY[NodeClass.prototype.getClassName()] = NodeClass;\n exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar Util_1 = require(\"./Util\");\nfunction _formatValue(val) {\n if (Util_1.Util._isString(val)) {\n return '\"' + val + '\"';\n }\n if (Object.prototype.toString.call(val) === '[object Number]') {\n return val;\n }\n if (Util_1.Util._isBoolean(val)) {\n return val;\n }\n return Object.prototype.toString.call(val);\n}\nfunction RGBComponent(val) {\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n return Math.round(val);\n}\nexports.RGBComponent = RGBComponent;\nfunction alphaComponent(val) {\n if (val > 1) {\n return 1;\n }\n else if (val < 0.0001) {\n return 0.0001;\n }\n return val;\n}\nexports.alphaComponent = alphaComponent;\nfunction getNumberValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isNumber(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number.');\n }\n return val;\n };\n }\n}\nexports.getNumberValidator = getNumberValidator;\nfunction getNumberOrAutoValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n var isNumber = Util_1.Util._isNumber(val);\n var isAuto = val === 'auto';\n if (!(isNumber || isAuto)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number or \"auto\".');\n }\n return val;\n };\n }\n}\nexports.getNumberOrAutoValidator = getNumberOrAutoValidator;\nfunction getStringValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isString(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a string.');\n }\n return val;\n };\n }\n}\nexports.getStringValidator = getStringValidator;\nfunction getFunctionValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isFunction(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a function.');\n }\n return val;\n };\n }\n}\nexports.getFunctionValidator = getFunctionValidator;\nfunction getNumberArrayValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isArray(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a array of numbers.');\n }\n else {\n val.forEach(function (item) {\n if (!Util_1.Util._isNumber(item)) {\n Util_1.Util.warn('\"' +\n attr +\n '\" attribute has non numeric element ' +\n item +\n '. Make sure that all elements are numbers.');\n }\n });\n }\n return val;\n };\n }\n}\nexports.getNumberArrayValidator = getNumberArrayValidator;\nfunction getBooleanValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n var isBool = val === true || val === false;\n if (!isBool) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a boolean.');\n }\n return val;\n };\n }\n}\nexports.getBooleanValidator = getBooleanValidator;\nfunction getComponentValidator(components) {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util.isObject(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be an object with properties ' +\n components);\n }\n return val;\n };\n }\n}\nexports.getComponentValidator = getComponentValidator;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar Collection = (function () {\n function Collection() {\n }\n Collection.toCollection = function (arr) {\n var collection = new Collection(), len = arr.length, n;\n for (n = 0; n < len; n++) {\n collection.push(arr[n]);\n }\n return collection;\n };\n Collection._mapMethod = function (methodName) {\n Collection.prototype[methodName] = function () {\n var len = this.length, i;\n var args = [].slice.call(arguments);\n for (i = 0; i < len; i++) {\n this[i][methodName].apply(this[i], args);\n }\n return this;\n };\n };\n Collection.mapMethods = function (constructor) {\n var prot = constructor.prototype;\n for (var methodName in prot) {\n Collection._mapMethod(methodName);\n }\n };\n return Collection;\n}());\nexports.Collection = Collection;\nCollection.prototype = [];\nCollection.prototype.each = function (func) {\n for (var n = 0; n < this.length; n++) {\n func(this[n], n);\n }\n};\nCollection.prototype.toArray = function () {\n var arr = [], len = this.length, n;\n for (n = 0; n < len; n++) {\n arr.push(this[n]);\n }\n return arr;\n};\nvar Transform = (function () {\n function Transform(m) {\n if (m === void 0) { m = [1, 0, 0, 1, 0, 0]; }\n this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];\n }\n Transform.prototype.copy = function () {\n return new Transform(this.m);\n };\n Transform.prototype.point = function (point) {\n var m = this.m;\n return {\n x: m[0] * point.x + m[2] * point.y + m[4],\n y: m[1] * point.x + m[3] * point.y + m[5]\n };\n };\n Transform.prototype.translate = function (x, y) {\n this.m[4] += this.m[0] * x + this.m[2] * y;\n this.m[5] += this.m[1] * x + this.m[3] * y;\n return this;\n };\n Transform.prototype.scale = function (sx, sy) {\n this.m[0] *= sx;\n this.m[1] *= sx;\n this.m[2] *= sy;\n this.m[3] *= sy;\n return this;\n };\n Transform.prototype.rotate = function (rad) {\n var c = Math.cos(rad);\n var s = Math.sin(rad);\n var m11 = this.m[0] * c + this.m[2] * s;\n var m12 = this.m[1] * c + this.m[3] * s;\n var m21 = this.m[0] * -s + this.m[2] * c;\n var m22 = this.m[1] * -s + this.m[3] * c;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n };\n Transform.prototype.getTranslation = function () {\n return {\n x: this.m[4],\n y: this.m[5]\n };\n };\n Transform.prototype.skew = function (sx, sy) {\n var m11 = this.m[0] + this.m[2] * sy;\n var m12 = this.m[1] + this.m[3] * sy;\n var m21 = this.m[2] + this.m[0] * sx;\n var m22 = this.m[3] + this.m[1] * sx;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n };\n Transform.prototype.multiply = function (matrix) {\n var m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];\n var m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];\n var m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];\n var m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];\n var dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];\n var dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n this.m[4] = dx;\n this.m[5] = dy;\n return this;\n };\n Transform.prototype.invert = function () {\n var d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);\n var m0 = this.m[3] * d;\n var m1 = -this.m[1] * d;\n var m2 = -this.m[2] * d;\n var m3 = this.m[0] * d;\n var m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);\n var m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);\n this.m[0] = m0;\n this.m[1] = m1;\n this.m[2] = m2;\n this.m[3] = m3;\n this.m[4] = m4;\n this.m[5] = m5;\n return this;\n };\n Transform.prototype.getMatrix = function () {\n return this.m;\n };\n Transform.prototype.setAbsolutePosition = function (x, y) {\n var m0 = this.m[0], m1 = this.m[1], m2 = this.m[2], m3 = this.m[3], m4 = this.m[4], m5 = this.m[5], yt = (m0 * (y - m5) - m1 * (x - m4)) / (m0 * m3 - m1 * m2), xt = (x - m4 - m2 * yt) / m0;\n return this.translate(xt, yt);\n };\n Transform.prototype.decompose = function () {\n var a = this.m[0];\n var b = this.m[1];\n var c = this.m[2];\n var d = this.m[3];\n var e = this.m[4];\n var f = this.m[5];\n var delta = a * d - b * c;\n var result = {\n x: e,\n y: f,\n rotation: 0,\n scaleX: 0,\n scaleY: 0,\n skewX: 0,\n skewY: 0\n };\n if (a != 0 || b != 0) {\n var r = Math.sqrt(a * a + b * b);\n result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);\n result.scaleX = r;\n result.scaleY = delta / r;\n result.skewX = (a * c + b * d) / delta;\n result.skewY = 0;\n }\n else if (c != 0 || d != 0) {\n var s = Math.sqrt(c * c + d * d);\n result.rotation =\n Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));\n result.scaleX = delta / s;\n result.scaleY = s;\n result.skewX = 0;\n result.skewY = (a * c + b * d) / delta;\n }\n else {\n }\n result.rotation = exports.Util._getRotation(result.rotation);\n return result;\n };\n return Transform;\n}());\nexports.Transform = Transform;\nvar OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 132, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 255, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 203],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [119, 128, 144],\n slategrey: [119, 128, 144],\n snow: [255, 255, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n transparent: [255, 255, 255, 0],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 5]\n}, RGB_REGEX = /rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)/, animQueue = [];\nexports.Util = {\n _isElement: function (obj) {\n return !!(obj && obj.nodeType == 1);\n },\n _isFunction: function (obj) {\n return !!(obj && obj.constructor && obj.call && obj.apply);\n },\n _isPlainObject: function (obj) {\n return !!obj && obj.constructor === Object;\n },\n _isArray: function (obj) {\n return Object.prototype.toString.call(obj) === OBJECT_ARRAY;\n },\n _isNumber: function (obj) {\n return (Object.prototype.toString.call(obj) === OBJECT_NUMBER &&\n !isNaN(obj) &&\n isFinite(obj));\n },\n _isString: function (obj) {\n return Object.prototype.toString.call(obj) === OBJECT_STRING;\n },\n _isBoolean: function (obj) {\n return Object.prototype.toString.call(obj) === OBJECT_BOOLEAN;\n },\n isObject: function (val) {\n return val instanceof Object;\n },\n isValidSelector: function (selector) {\n if (typeof selector !== 'string') {\n return false;\n }\n var firstChar = selector[0];\n return (firstChar === '#' ||\n firstChar === '.' ||\n firstChar === firstChar.toUpperCase());\n },\n _sign: function (number) {\n if (number === 0) {\n return 0;\n }\n if (number > 0) {\n return 1;\n }\n else {\n return -1;\n }\n },\n requestAnimFrame: function (callback) {\n animQueue.push(callback);\n if (animQueue.length === 1) {\n requestAnimationFrame(function () {\n var queue = animQueue;\n animQueue = [];\n queue.forEach(function (cb) {\n cb();\n });\n });\n }\n },\n createCanvasElement: function () {\n var canvas = document.createElement('canvas');\n try {\n canvas.style = canvas.style || {};\n }\n catch (e) { }\n return canvas;\n },\n createImageElement: function () {\n return document.createElement('img');\n },\n _isInDocument: function (el) {\n while ((el = el.parentNode)) {\n if (el == document) {\n return true;\n }\n }\n return false;\n },\n _simplifyArray: function (arr) {\n var retArr = [], len = arr.length, util = exports.Util, n, val;\n for (n = 0; n < len; n++) {\n val = arr[n];\n if (util._isNumber(val)) {\n val = Math.round(val * 1000) / 1000;\n }\n else if (!util._isString(val)) {\n val = val.toString();\n }\n retArr.push(val);\n }\n return retArr;\n },\n _urlToImage: function (url, callback) {\n var imageObj = new Global_1.glob.Image();\n imageObj.onload = function () {\n callback(imageObj);\n };\n imageObj.src = url;\n },\n _rgbToHex: function (r, g, b) {\n return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n },\n _hexToRgb: function (hex) {\n hex = hex.replace(HASH, EMPTY_STRING);\n var bigint = parseInt(hex, 16);\n return {\n r: (bigint >> 16) & 255,\n g: (bigint >> 8) & 255,\n b: bigint & 255\n };\n },\n getRandomColor: function () {\n var randColor = ((Math.random() * 0xffffff) << 0).toString(16);\n while (randColor.length < 6) {\n randColor = ZERO + randColor;\n }\n return HASH + randColor;\n },\n get: function (val, def) {\n if (val === undefined) {\n return def;\n }\n else {\n return val;\n }\n },\n getRGB: function (color) {\n var rgb;\n if (color in COLORS) {\n rgb = COLORS[color];\n return {\n r: rgb[0],\n g: rgb[1],\n b: rgb[2]\n };\n }\n else if (color[0] === HASH) {\n return this._hexToRgb(color.substring(1));\n }\n else if (color.substr(0, 4) === RGB_PAREN) {\n rgb = RGB_REGEX.exec(color.replace(/ /g, ''));\n return {\n r: parseInt(rgb[1], 10),\n g: parseInt(rgb[2], 10),\n b: parseInt(rgb[3], 10)\n };\n }\n else {\n return {\n r: 0,\n g: 0,\n b: 0\n };\n }\n },\n colorToRGBA: function (str) {\n str = str || 'black';\n return (exports.Util._namedColorToRBA(str) ||\n exports.Util._hex3ColorToRGBA(str) ||\n exports.Util._hex6ColorToRGBA(str) ||\n exports.Util._rgbColorToRGBA(str) ||\n exports.Util._rgbaColorToRGBA(str) ||\n exports.Util._hslColorToRGBA(str));\n },\n _namedColorToRBA: function (str) {\n var c = COLORS[str.toLowerCase()];\n if (!c) {\n return null;\n }\n return {\n r: c[0],\n g: c[1],\n b: c[2],\n a: 1\n };\n },\n _rgbColorToRGBA: function (str) {\n if (str.indexOf('rgb(') === 0) {\n str = str.match(/rgb\\(([^)]+)\\)/)[1];\n var parts = str.split(/ *, */).map(Number);\n return {\n r: parts[0],\n g: parts[1],\n b: parts[2],\n a: 1\n };\n }\n },\n _rgbaColorToRGBA: function (str) {\n if (str.indexOf('rgba(') === 0) {\n str = str.match(/rgba\\(([^)]+)\\)/)[1];\n var parts = str.split(/ *, */).map(Number);\n return {\n r: parts[0],\n g: parts[1],\n b: parts[2],\n a: parts[3]\n };\n }\n },\n _hex6ColorToRGBA: function (str) {\n if (str[0] === '#' && str.length === 7) {\n return {\n r: parseInt(str.slice(1, 3), 16),\n g: parseInt(str.slice(3, 5), 16),\n b: parseInt(str.slice(5, 7), 16),\n a: 1\n };\n }\n },\n _hex3ColorToRGBA: function (str) {\n if (str[0] === '#' && str.length === 4) {\n return {\n r: parseInt(str[1] + str[1], 16),\n g: parseInt(str[2] + str[2], 16),\n b: parseInt(str[3] + str[3], 16),\n a: 1\n };\n }\n },\n _hslColorToRGBA: function (str) {\n if (/hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/g.test(str)) {\n var _a = /hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/g.exec(str), _ = _a[0], hsl = _a.slice(1);\n var h = Number(hsl[0]) / 360;\n var s = Number(hsl[1]) / 100;\n var l = Number(hsl[2]) / 100;\n var t2 = void 0;\n var t3 = void 0;\n var val = void 0;\n if (s === 0) {\n val = l * 255;\n return {\n r: Math.round(val),\n g: Math.round(val),\n b: Math.round(val),\n a: 1\n };\n }\n if (l < 0.5) {\n t2 = l * (1 + s);\n }\n else {\n t2 = l + s - l * s;\n }\n var t1 = 2 * l - t2;\n var rgb = [0, 0, 0];\n for (var i = 0; i < 3; i++) {\n t3 = h + (1 / 3) * -(i - 1);\n if (t3 < 0) {\n t3++;\n }\n if (t3 > 1) {\n t3--;\n }\n if (6 * t3 < 1) {\n val = t1 + (t2 - t1) * 6 * t3;\n }\n else if (2 * t3 < 1) {\n val = t2;\n }\n else if (3 * t3 < 2) {\n val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n }\n else {\n val = t1;\n }\n rgb[i] = val * 255;\n }\n return {\n r: Math.round(rgb[0]),\n g: Math.round(rgb[1]),\n b: Math.round(rgb[2]),\n a: 1\n };\n }\n },\n haveIntersection: function (r1, r2) {\n return !(r2.x > r1.x + r1.width ||\n r2.x + r2.width < r1.x ||\n r2.y > r1.y + r1.height ||\n r2.y + r2.height < r1.y);\n },\n cloneObject: function (obj) {\n var retObj = {};\n for (var key in obj) {\n if (this._isPlainObject(obj[key])) {\n retObj[key] = this.cloneObject(obj[key]);\n }\n else if (this._isArray(obj[key])) {\n retObj[key] = this.cloneArray(obj[key]);\n }\n else {\n retObj[key] = obj[key];\n }\n }\n return retObj;\n },\n cloneArray: function (arr) {\n return arr.slice(0);\n },\n _degToRad: function (deg) {\n return deg * PI_OVER_DEG180;\n },\n _radToDeg: function (rad) {\n return rad * DEG180_OVER_PI;\n },\n _getRotation: function (radians) {\n return Global_1.Konva.angleDeg ? exports.Util._radToDeg(radians) : radians;\n },\n _capitalize: function (str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n throw: function (str) {\n throw new Error(KONVA_ERROR + str);\n },\n error: function (str) {\n console.error(KONVA_ERROR + str);\n },\n warn: function (str) {\n if (!Global_1.Konva.showWarnings) {\n return;\n }\n console.warn(KONVA_WARNING + str);\n },\n extend: function (child, parent) {\n function Ctor() {\n this.constructor = child;\n }\n Ctor.prototype = parent.prototype;\n var oldProto = child.prototype;\n child.prototype = new Ctor();\n for (var key in oldProto) {\n if (oldProto.hasOwnProperty(key)) {\n child.prototype[key] = oldProto[key];\n }\n }\n child.__super__ = parent.prototype;\n child.super = parent;\n },\n _getControlPoints: function (x0, y0, x1, y1, x2, y2, t) {\n var d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);\n return [p1x, p1y, p2x, p2y];\n },\n _expandPoints: function (p, tension) {\n var len = p.length, allPoints = [], n, cp;\n for (n = 2; n < len - 2; n += 2) {\n cp = exports.Util._getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);\n allPoints.push(cp[0]);\n allPoints.push(cp[1]);\n allPoints.push(p[n]);\n allPoints.push(p[n + 1]);\n allPoints.push(cp[2]);\n allPoints.push(cp[3]);\n }\n return allPoints;\n },\n each: function (obj, func) {\n for (var key in obj) {\n func(key, obj[key]);\n }\n },\n _inRange: function (val, left, right) {\n return left <= val && val < right;\n },\n _getProjectionToSegment: function (x1, y1, x2, y2, x3, y3) {\n var x, y, dist;\n var pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n if (pd2 == 0) {\n x = x1;\n y = y1;\n dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);\n }\n else {\n var u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;\n if (u < 0) {\n x = x1;\n y = y1;\n dist = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);\n }\n else if (u > 1.0) {\n x = x2;\n y = y2;\n dist = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);\n }\n else {\n x = x1 + u * (x2 - x1);\n y = y1 + u * (y2 - y1);\n dist = (x - x3) * (x - x3) + (y - y3) * (y - y3);\n }\n }\n return [x, y, dist];\n },\n _getProjectionToLine: function (pt, line, isClosed) {\n var pc = exports.Util.cloneObject(pt);\n var dist = Number.MAX_VALUE;\n line.forEach(function (p1, i) {\n if (!isClosed && i === line.length - 1) {\n return;\n }\n var p2 = line[(i + 1) % line.length];\n var proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);\n var px = proj[0], py = proj[1], pdist = proj[2];\n if (pdist < dist) {\n pc.x = px;\n pc.y = py;\n dist = pdist;\n }\n });\n return pc;\n },\n _prepareArrayForTween: function (startArray, endArray, isClosed) {\n var n, start = [], end = [];\n if (startArray.length > endArray.length) {\n var temp = endArray;\n endArray = startArray;\n startArray = temp;\n }\n for (n = 0; n < startArray.length; n += 2) {\n start.push({\n x: startArray[n],\n y: startArray[n + 1]\n });\n }\n for (n = 0; n < endArray.length; n += 2) {\n end.push({\n x: endArray[n],\n y: endArray[n + 1]\n });\n }\n var newStart = [];\n end.forEach(function (point) {\n var pr = exports.Util._getProjectionToLine(point, start, isClosed);\n newStart.push(pr.x);\n newStart.push(pr.y);\n });\n return newStart;\n },\n _prepareToStringify: function (obj) {\n var desc;\n obj.visitedByCircularReferenceRemoval = true;\n for (var key in obj) {\n if (!(obj.hasOwnProperty(key) && obj[key] && typeof obj[key] == 'object')) {\n continue;\n }\n desc = Object.getOwnPropertyDescriptor(obj, key);\n if (obj[key].visitedByCircularReferenceRemoval ||\n exports.Util._isElement(obj[key])) {\n if (desc.configurable) {\n delete obj[key];\n }\n else {\n return null;\n }\n }\n else if (exports.Util._prepareToStringify(obj[key]) === null) {\n if (desc.configurable) {\n delete obj[key];\n }\n else {\n return null;\n }\n }\n }\n delete obj.visitedByCircularReferenceRemoval;\n return obj;\n },\n _assign: function (target, source) {\n for (var key in source) {\n target[key] = source[key];\n }\n return target;\n },\n _getFirstPointerId: function (evt) {\n if (!evt.touches) {\n return 999;\n }\n else {\n return evt.changedTouches[0].identifier;\n }\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Factory_1 = require(\"./Factory\");\nvar Canvas_1 = require(\"./Canvas\");\nvar Global_1 = require(\"./Global\");\nvar DragAndDrop_1 = require(\"./DragAndDrop\");\nvar Validators_1 = require(\"./Validators\");\nexports.ids = {};\nexports.names = {};\nvar _addId = function (node, id) {\n if (!id) {\n return;\n }\n exports.ids[id] = node;\n};\nexports._removeId = function (id, node) {\n if (!id) {\n return;\n }\n if (exports.ids[id] !== node) {\n return;\n }\n delete exports.ids[id];\n};\nexports._addName = function (node, name) {\n if (name) {\n if (!exports.names[name]) {\n exports.names[name] = [];\n }\n exports.names[name].push(node);\n }\n};\nexports._removeName = function (name, _id) {\n if (!name) {\n return;\n }\n var nodes = exports.names[name];\n if (!nodes) {\n return;\n }\n for (var n = 0; n < nodes.length; n++) {\n var no = nodes[n];\n if (no._id === _id) {\n nodes.splice(n, 1);\n }\n }\n if (nodes.length === 0) {\n delete exports.names[name];\n }\n};\nvar ABSOLUTE_OPACITY = 'absoluteOpacity', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [\n 'xChange.konva',\n 'yChange.konva',\n 'scaleXChange.konva',\n 'scaleYChange.konva',\n 'skewXChange.konva',\n 'skewYChange.konva',\n 'rotationChange.konva',\n 'offsetXChange.konva',\n 'offsetYChange.konva',\n 'transformsEnabledChange.konva',\n].join(SPACE), SCALE_CHANGE_STR = ['scaleXChange.konva', 'scaleYChange.konva'].join(SPACE);\nvar emptyChildren = new Util_1.Collection();\nvar idCounter = 1;\nvar Node = (function () {\n function Node(config) {\n var _this = this;\n this._id = idCounter++;\n this.eventListeners = {};\n this.attrs = {};\n this.index = 0;\n this.parent = null;\n this._cache = new Map();\n this._lastPos = null;\n this._batchingTransformChange = false;\n this._needClearTransformCache = false;\n this._filterUpToDate = false;\n this._isUnderCache = false;\n this.children = emptyChildren;\n this._dragEventId = null;\n this.setAttrs(config);\n this.on(TRANSFORM_CHANGE_STR, function () {\n if (_this._batchingTransformChange) {\n _this._needClearTransformCache = true;\n return;\n }\n _this._clearCache(TRANSFORM);\n _this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n });\n this.on('visibleChange.konva', function () {\n _this._clearSelfAndDescendantCache(VISIBLE);\n });\n this.on('listeningChange.konva', function () {\n _this._clearSelfAndDescendantCache(LISTENING);\n });\n this.on('opacityChange.konva', function () {\n _this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n });\n }\n Node.prototype.hasChildren = function () {\n return false;\n };\n Node.prototype.getChildren = function () {\n return emptyChildren;\n };\n Node.prototype._clearCache = function (attr) {\n if (attr) {\n this._cache.delete(attr);\n }\n else {\n this._cache.clear();\n }\n };\n Node.prototype._getCache = function (attr, privateGetter) {\n var cache = this._cache.get(attr);\n if (cache === undefined) {\n cache = privateGetter.call(this);\n this._cache.set(attr, cache);\n }\n return cache;\n };\n Node.prototype._getCanvasCache = function () {\n return this._cache.get(CANVAS);\n };\n Node.prototype._clearSelfAndDescendantCache = function (attr, forceEvent) {\n this._clearCache(attr);\n if (forceEvent && attr === ABSOLUTE_TRANSFORM) {\n this.fire('_clearTransformCache');\n }\n if (this.isCached()) {\n return;\n }\n if (this.children) {\n this.children.each(function (node) {\n node._clearSelfAndDescendantCache(attr, true);\n });\n }\n };\n Node.prototype.clearCache = function () {\n this._cache.delete(CANVAS);\n this._clearSelfAndDescendantCache();\n return this;\n };\n Node.prototype.cache = function (config) {\n var conf = config || {};\n var rect = {};\n if (conf.x === undefined ||\n conf.y === undefined ||\n conf.width === undefined ||\n conf.height === undefined) {\n rect = this.getClientRect({\n skipTransform: true,\n relativeTo: this.getParent(),\n });\n }\n var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? rect.x : conf.x, y = conf.y === undefined ? rect.y : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false;\n if (!width || !height) {\n Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');\n return;\n }\n width += offset * 2;\n height += offset * 2;\n x -= offset;\n y -= offset;\n var cachedSceneCanvas = new Canvas_1.SceneCanvas({\n pixelRatio: pixelRatio,\n width: width,\n height: height,\n }), cachedFilterCanvas = new Canvas_1.SceneCanvas({\n pixelRatio: pixelRatio,\n width: 0,\n height: 0,\n }), cachedHitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: 1,\n width: width,\n height: height,\n }), sceneContext = cachedSceneCanvas.getContext(), hitContext = cachedHitCanvas.getContext();\n cachedHitCanvas.isCache = true;\n this._cache.delete('canvas');\n this._filterUpToDate = false;\n if (conf.imageSmoothingEnabled === false) {\n cachedSceneCanvas.getContext()._context.imageSmoothingEnabled = false;\n cachedFilterCanvas.getContext()._context.imageSmoothingEnabled = false;\n }\n sceneContext.save();\n hitContext.save();\n sceneContext.translate(-x, -y);\n hitContext.translate(-x, -y);\n this._isUnderCache = true;\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);\n this.drawScene(cachedSceneCanvas, this, true);\n this.drawHit(cachedHitCanvas, this, true);\n this._isUnderCache = false;\n sceneContext.restore();\n hitContext.restore();\n if (drawBorder) {\n sceneContext.save();\n sceneContext.beginPath();\n sceneContext.rect(0, 0, width, height);\n sceneContext.closePath();\n sceneContext.setAttr('strokeStyle', 'red');\n sceneContext.setAttr('lineWidth', 5);\n sceneContext.stroke();\n sceneContext.restore();\n }\n this._cache.set(CANVAS, {\n scene: cachedSceneCanvas,\n filter: cachedFilterCanvas,\n hit: cachedHitCanvas,\n x: x,\n y: y,\n });\n return this;\n };\n Node.prototype.isCached = function () {\n return this._cache.has('canvas');\n };\n Node.prototype.getClientRect = function (config) {\n throw new Error('abstract \"getClientRect\" method call');\n };\n Node.prototype._transformedRect = function (rect, top) {\n var points = [\n { x: rect.x, y: rect.y },\n { x: rect.x + rect.width, y: rect.y },\n { x: rect.x + rect.width, y: rect.y + rect.height },\n { x: rect.x, y: rect.y + rect.height },\n ];\n var minX, minY, maxX, maxY;\n var trans = this.getAbsoluteTransform(top);\n points.forEach(function (point) {\n var transformed = trans.point(point);\n if (minX === undefined) {\n minX = maxX = transformed.x;\n minY = maxY = transformed.y;\n }\n minX = Math.min(minX, transformed.x);\n minY = Math.min(minY, transformed.y);\n maxX = Math.max(maxX, transformed.x);\n maxY = Math.max(maxY, transformed.y);\n });\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n };\n Node.prototype._drawCachedSceneCanvas = function (context) {\n context.save();\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n var canvasCache = this._getCanvasCache();\n context.translate(canvasCache.x, canvasCache.y);\n var cacheCanvas = this._getCachedSceneCanvas();\n var ratio = cacheCanvas.pixelRatio;\n context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);\n context.restore();\n };\n Node.prototype._drawCachedHitCanvas = function (context) {\n var canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;\n context.save();\n context.translate(canvasCache.x, canvasCache.y);\n context.drawImage(hitCanvas._canvas, 0, 0);\n context.restore();\n };\n Node.prototype._getCachedSceneCanvas = function () {\n var filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;\n if (filters) {\n if (!this._filterUpToDate) {\n var ratio = sceneCanvas.pixelRatio;\n filterCanvas.setSize(sceneCanvas.width / sceneCanvas.pixelRatio, sceneCanvas.height / sceneCanvas.pixelRatio);\n try {\n len = filters.length;\n filterContext.clear();\n filterContext.drawImage(sceneCanvas._canvas, 0, 0, sceneCanvas.getWidth() / ratio, sceneCanvas.getHeight() / ratio);\n imageData = filterContext.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight());\n for (n = 0; n < len; n++) {\n filter = filters[n];\n if (typeof filter !== 'function') {\n Util_1.Util.error('Filter should be type of function, but got ' +\n typeof filter +\n ' instead. Please check correct filters');\n continue;\n }\n filter.call(this, imageData);\n filterContext.putImageData(imageData, 0, 0);\n }\n }\n catch (e) {\n Util_1.Util.error('Unable to apply filter. ' +\n e.message +\n ' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n }\n this._filterUpToDate = true;\n }\n return filterCanvas;\n }\n return sceneCanvas;\n };\n Node.prototype.on = function (evtStr, handler) {\n if (arguments.length === 3) {\n return this._delegate.apply(this, arguments);\n }\n var events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;\n for (n = 0; n < len; n++) {\n event = events[n];\n parts = event.split('.');\n baseEvent = parts[0];\n name = parts[1] || '';\n if (!this.eventListeners[baseEvent]) {\n this.eventListeners[baseEvent] = [];\n }\n this.eventListeners[baseEvent].push({\n name: name,\n handler: handler,\n });\n }\n return this;\n };\n Node.prototype.off = function (evtStr, callback) {\n var events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;\n if (!evtStr) {\n for (t in this.eventListeners) {\n this._off(t);\n }\n }\n for (n = 0; n < len; n++) {\n event = events[n];\n parts = event.split('.');\n baseEvent = parts[0];\n name = parts[1];\n if (baseEvent) {\n if (this.eventListeners[baseEvent]) {\n this._off(baseEvent, name, callback);\n }\n }\n else {\n for (t in this.eventListeners) {\n this._off(t, name, callback);\n }\n }\n }\n return this;\n };\n Node.prototype.dispatchEvent = function (evt) {\n var e = {\n target: this,\n type: evt.type,\n evt: evt,\n };\n this.fire(evt.type, e);\n return this;\n };\n Node.prototype.addEventListener = function (type, handler) {\n this.on(type, function (evt) {\n handler.call(this, evt.evt);\n });\n return this;\n };\n Node.prototype.removeEventListener = function (type) {\n this.off(type);\n return this;\n };\n Node.prototype._delegate = function (event, selector, handler) {\n var stopNode = this;\n this.on(event, function (evt) {\n var targets = evt.target.findAncestors(selector, true, stopNode);\n for (var i = 0; i < targets.length; i++) {\n evt = Util_1.Util.cloneObject(evt);\n evt.currentTarget = targets[i];\n handler.call(targets[i], evt);\n }\n });\n };\n Node.prototype.remove = function () {\n if (this.isDragging()) {\n this.stopDrag();\n }\n DragAndDrop_1.DD._dragElements.delete(this._id);\n this._remove();\n return this;\n };\n Node.prototype._clearCaches = function () {\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);\n this._clearSelfAndDescendantCache(STAGE);\n this._clearSelfAndDescendantCache(VISIBLE);\n this._clearSelfAndDescendantCache(LISTENING);\n };\n Node.prototype._remove = function () {\n this._clearCaches();\n var parent = this.getParent();\n if (parent && parent.children) {\n parent.children.splice(this.index, 1);\n parent._setChildrenIndices();\n this.parent = null;\n }\n };\n Node.prototype.destroy = function () {\n exports._removeId(this.id(), this);\n var names = (this.name() || '').split(/\\s/g);\n for (var i = 0; i < names.length; i++) {\n var subname = names[i];\n exports._removeName(subname, this._id);\n }\n this.remove();\n return this;\n };\n Node.prototype.getAttr = function (attr) {\n var method = 'get' + Util_1.Util._capitalize(attr);\n if (Util_1.Util._isFunction(this[method])) {\n return this[method]();\n }\n return this.attrs[attr];\n };\n Node.prototype.getAncestors = function () {\n var parent = this.getParent(), ancestors = new Util_1.Collection();\n while (parent) {\n ancestors.push(parent);\n parent = parent.getParent();\n }\n return ancestors;\n };\n Node.prototype.getAttrs = function () {\n return this.attrs || {};\n };\n Node.prototype.setAttrs = function (config) {\n var key, method;\n if (!config) {\n return this;\n }\n for (key in config) {\n if (key === CHILDREN) {\n continue;\n }\n method = SET + Util_1.Util._capitalize(key);\n if (Util_1.Util._isFunction(this[method])) {\n this[method](config[key]);\n }\n else {\n this._setAttr(key, config[key]);\n }\n }\n return this;\n };\n Node.prototype.isListening = function () {\n return this._getCache(LISTENING, this._isListening);\n };\n Node.prototype._isListening = function () {\n var listening = this.listening(), parent = this.getParent();\n if (listening === 'inherit') {\n if (parent) {\n return parent.isListening();\n }\n else {\n return true;\n }\n }\n else {\n return listening;\n }\n };\n Node.prototype.isVisible = function () {\n return this._getCache(VISIBLE, this._isVisible);\n };\n Node.prototype._isVisible = function (relativeTo) {\n var visible = this.visible(), parent = this.getParent();\n if (visible === 'inherit') {\n if (parent && parent !== relativeTo) {\n return parent._isVisible(relativeTo);\n }\n else {\n return true;\n }\n }\n else if (relativeTo && relativeTo !== parent) {\n return visible && parent._isVisible(relativeTo);\n }\n else {\n return visible;\n }\n };\n Node.prototype.shouldDrawHit = function () {\n var layer = this.getLayer();\n return ((!layer && this.isListening() && this.isVisible()) ||\n (layer &&\n layer.hitGraphEnabled() &&\n this.isListening() &&\n this.isVisible()));\n };\n Node.prototype.show = function () {\n this.visible(true);\n return this;\n };\n Node.prototype.hide = function () {\n this.visible(false);\n return this;\n };\n Node.prototype.getZIndex = function () {\n return this.index || 0;\n };\n Node.prototype.getAbsoluteZIndex = function () {\n var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;\n function addChildren(children) {\n nodes = [];\n len = children.length;\n for (n = 0; n < len; n++) {\n child = children[n];\n index++;\n if (child.nodeType !== SHAPE) {\n nodes = nodes.concat(child.getChildren().toArray());\n }\n if (child._id === that._id) {\n n = len;\n }\n }\n if (nodes.length > 0 && nodes[0].getDepth() <= depth) {\n addChildren(nodes);\n }\n }\n if (that.nodeType !== UPPER_STAGE) {\n addChildren(that.getStage().getChildren());\n }\n return index;\n };\n Node.prototype.getDepth = function () {\n var depth = 0, parent = this.parent;\n while (parent) {\n depth++;\n parent = parent.parent;\n }\n return depth;\n };\n Node.prototype._batchTransformChanges = function (func) {\n this._batchingTransformChange = true;\n func();\n this._batchingTransformChange = false;\n if (this._needClearTransformCache) {\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM, true);\n }\n this._needClearTransformCache = false;\n };\n Node.prototype.setPosition = function (pos) {\n var _this = this;\n this._batchTransformChanges(function () {\n _this.x(pos.x);\n _this.y(pos.y);\n });\n return this;\n };\n Node.prototype.getPosition = function () {\n return {\n x: this.x(),\n y: this.y(),\n };\n };\n Node.prototype.getAbsolutePosition = function (top) {\n var haveCachedParent = false;\n var parent = this.parent;\n while (parent) {\n if (parent.isCached()) {\n haveCachedParent = true;\n break;\n }\n parent = parent.parent;\n }\n if (haveCachedParent && !top) {\n top = true;\n }\n var absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();\n absoluteTransform.m = absoluteMatrix.slice();\n absoluteTransform.translate(offset.x, offset.y);\n return absoluteTransform.getTranslation();\n };\n Node.prototype.setAbsolutePosition = function (pos) {\n var origTrans = this._clearTransform(), it;\n this.attrs.x = origTrans.x;\n this.attrs.y = origTrans.y;\n delete origTrans.x;\n delete origTrans.y;\n this._clearCache(TRANSFORM);\n it = this._getAbsoluteTransform();\n it.invert();\n it.translate(pos.x, pos.y);\n pos = {\n x: this.attrs.x + it.getTranslation().x,\n y: this.attrs.y + it.getTranslation().y,\n };\n this._setTransform(origTrans);\n this.setPosition({ x: pos.x, y: pos.y });\n return this;\n };\n Node.prototype._setTransform = function (trans) {\n var key;\n for (key in trans) {\n this.attrs[key] = trans[key];\n }\n };\n Node.prototype._clearTransform = function () {\n var trans = {\n x: this.x(),\n y: this.y(),\n rotation: this.rotation(),\n scaleX: this.scaleX(),\n scaleY: this.scaleY(),\n offsetX: this.offsetX(),\n offsetY: this.offsetY(),\n skewX: this.skewX(),\n skewY: this.skewY(),\n };\n this.attrs.x = 0;\n this.attrs.y = 0;\n this.attrs.rotation = 0;\n this.attrs.scaleX = 1;\n this.attrs.scaleY = 1;\n this.attrs.offsetX = 0;\n this.attrs.offsetY = 0;\n this.attrs.skewX = 0;\n this.attrs.skewY = 0;\n return trans;\n };\n Node.prototype.move = function (change) {\n var changeX = change.x, changeY = change.y, x = this.x(), y = this.y();\n if (changeX !== undefined) {\n x += changeX;\n }\n if (changeY !== undefined) {\n y += changeY;\n }\n this.setPosition({ x: x, y: y });\n return this;\n };\n Node.prototype._eachAncestorReverse = function (func, top) {\n var family = [], parent = this.getParent(), len, n;\n if (top && top._id === this._id) {\n func(this);\n return;\n }\n family.unshift(this);\n while (parent && (!top || parent._id !== top._id)) {\n family.unshift(parent);\n parent = parent.parent;\n }\n len = family.length;\n for (n = 0; n < len; n++) {\n func(family[n]);\n }\n };\n Node.prototype.rotate = function (theta) {\n this.rotation(this.rotation() + theta);\n return this;\n };\n Node.prototype.moveToTop = function () {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveToTop function is ignored.');\n return false;\n }\n var index = this.index;\n this.parent.children.splice(index, 1);\n this.parent.children.push(this);\n this.parent._setChildrenIndices();\n return true;\n };\n Node.prototype.moveUp = function () {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveUp function is ignored.');\n return false;\n }\n var index = this.index, len = this.parent.getChildren().length;\n if (index < len - 1) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index + 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n };\n Node.prototype.moveDown = function () {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveDown function is ignored.');\n return false;\n }\n var index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index - 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n };\n Node.prototype.moveToBottom = function () {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveToBottom function is ignored.');\n return false;\n }\n var index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.unshift(this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n };\n Node.prototype.setZIndex = function (zIndex) {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. zIndex parameter is ignored.');\n return this;\n }\n if (zIndex < 0 || zIndex >= this.parent.children.length) {\n Util_1.Util.warn('Unexpected value ' +\n zIndex +\n ' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' +\n (this.parent.children.length - 1) +\n '.');\n }\n var index = this.index;\n this.parent.children.splice(index, 1);\n this.parent.children.splice(zIndex, 0, this);\n this.parent._setChildrenIndices();\n return this;\n };\n Node.prototype.getAbsoluteOpacity = function () {\n return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);\n };\n Node.prototype._getAbsoluteOpacity = function () {\n var absOpacity = this.opacity();\n var parent = this.getParent();\n if (parent && !parent._isUnderCache) {\n absOpacity *= parent.getAbsoluteOpacity();\n }\n return absOpacity;\n };\n Node.prototype.moveTo = function (newContainer) {\n if (this.getParent() !== newContainer) {\n this._remove();\n newContainer.add(this);\n }\n return this;\n };\n Node.prototype.toObject = function () {\n var obj = {}, attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;\n obj.attrs = {};\n for (key in attrs) {\n val = attrs[key];\n nonPlainObject =\n Util_1.Util.isObject(val) && !Util_1.Util._isPlainObject(val) && !Util_1.Util._isArray(val);\n if (nonPlainObject) {\n continue;\n }\n getter = typeof this[key] === 'function' && this[key];\n delete attrs[key];\n defaultValue = getter ? getter.call(this) : null;\n attrs[key] = val;\n if (defaultValue !== val) {\n obj.attrs[key] = val;\n }\n }\n obj.className = this.getClassName();\n return Util_1.Util._prepareToStringify(obj);\n };\n Node.prototype.toJSON = function () {\n return JSON.stringify(this.toObject());\n };\n Node.prototype.getParent = function () {\n return this.parent;\n };\n Node.prototype.findAncestors = function (selector, includeSelf, stopNode) {\n var res = [];\n if (includeSelf && this._isMatch(selector)) {\n res.push(this);\n }\n var ancestor = this.parent;\n while (ancestor) {\n if (ancestor === stopNode) {\n return res;\n }\n if (ancestor._isMatch(selector)) {\n res.push(ancestor);\n }\n ancestor = ancestor.parent;\n }\n return res;\n };\n Node.prototype.isAncestorOf = function (node) {\n return false;\n };\n Node.prototype.findAncestor = function (selector, includeSelf, stopNode) {\n return this.findAncestors(selector, includeSelf, stopNode)[0];\n };\n Node.prototype._isMatch = function (selector) {\n if (!selector) {\n return false;\n }\n if (typeof selector === 'function') {\n return selector(this);\n }\n var selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;\n for (n = 0; n < len; n++) {\n sel = selectorArr[n];\n if (!Util_1.Util.isValidSelector(sel)) {\n Util_1.Util.warn('Selector \"' +\n sel +\n '\" is invalid. Allowed selectors examples are \"#foo\", \".bar\" or \"Group\".');\n Util_1.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like \"Triangle\".');\n Util_1.Util.warn('Konva is awesome, right?');\n }\n if (sel.charAt(0) === '#') {\n if (this.id() === sel.slice(1)) {\n return true;\n }\n }\n else if (sel.charAt(0) === '.') {\n if (this.hasName(sel.slice(1))) {\n return true;\n }\n }\n else if (this.className === sel || this.nodeType === sel) {\n return true;\n }\n }\n return false;\n };\n Node.prototype.getLayer = function () {\n var parent = this.getParent();\n return parent ? parent.getLayer() : null;\n };\n Node.prototype.getStage = function () {\n return this._getCache(STAGE, this._getStage);\n };\n Node.prototype._getStage = function () {\n var parent = this.getParent();\n if (parent) {\n return parent.getStage();\n }\n else {\n return undefined;\n }\n };\n Node.prototype.fire = function (eventType, evt, bubble) {\n if (evt === void 0) { evt = {}; }\n evt.target = evt.target || this;\n if (bubble) {\n this._fireAndBubble(eventType, evt);\n }\n else {\n this._fire(eventType, evt);\n }\n return this;\n };\n Node.prototype.getAbsoluteTransform = function (top) {\n if (top) {\n return this._getAbsoluteTransform(top);\n }\n else {\n return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);\n }\n };\n Node.prototype._getAbsoluteTransform = function (top) {\n var at;\n if (top) {\n at = new Util_1.Transform();\n this._eachAncestorReverse(function (node) {\n var transformsEnabled = node.transformsEnabled();\n if (transformsEnabled === 'all') {\n at.multiply(node.getTransform());\n }\n else if (transformsEnabled === 'position') {\n at.translate(node.x() - node.offsetX(), node.y() - node.offsetY());\n }\n }, top);\n return at;\n }\n else {\n if (this.parent) {\n at = this.parent.getAbsoluteTransform().copy();\n }\n else {\n at = new Util_1.Transform();\n }\n var transformsEnabled = this.transformsEnabled();\n if (transformsEnabled === 'all') {\n at.multiply(this.getTransform());\n }\n else if (transformsEnabled === 'position') {\n at.translate(this.x() - this.offsetX(), this.y() - this.offsetY());\n }\n return at;\n }\n };\n Node.prototype.getAbsoluteScale = function (top) {\n var parent = this;\n while (parent) {\n if (parent._isUnderCache) {\n top = parent;\n }\n parent = parent.getParent();\n }\n var transform = this.getAbsoluteTransform(top);\n var attrs = transform.decompose();\n return {\n x: attrs.scaleX,\n y: attrs.scaleY,\n };\n };\n Node.prototype.getAbsoluteRotation = function () {\n return this.getAbsoluteTransform().decompose().rotation;\n };\n Node.prototype.getTransform = function () {\n return this._getCache(TRANSFORM, this._getTransform);\n };\n Node.prototype._getTransform = function () {\n var m = new Util_1.Transform(), x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = this.scaleX(), scaleY = this.scaleY(), skewX = this.skewX(), skewY = this.skewY(), offsetX = this.offsetX(), offsetY = this.offsetY();\n if (x !== 0 || y !== 0) {\n m.translate(x, y);\n }\n if (rotation !== 0) {\n m.rotate(rotation);\n }\n if (skewX !== 0 || skewY !== 0) {\n m.skew(skewX, skewY);\n }\n if (scaleX !== 1 || scaleY !== 1) {\n m.scale(scaleX, scaleY);\n }\n if (offsetX !== 0 || offsetY !== 0) {\n m.translate(-1 * offsetX, -1 * offsetY);\n }\n return m;\n };\n Node.prototype.clone = function (obj) {\n var attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;\n for (key in obj) {\n attrs[key] = obj[key];\n }\n var node = new this.constructor(attrs);\n for (key in this.eventListeners) {\n allListeners = this.eventListeners[key];\n len = allListeners.length;\n for (n = 0; n < len; n++) {\n listener = allListeners[n];\n if (listener.name.indexOf(KONVA) < 0) {\n if (!node.eventListeners[key]) {\n node.eventListeners[key] = [];\n }\n node.eventListeners[key].push(listener);\n }\n }\n }\n return node;\n };\n Node.prototype._toKonvaCanvas = function (config) {\n config = config || {};\n var box = this.getClientRect();\n var stage = this.getStage(), x = config.x !== undefined ? config.x : box.x, y = config.y !== undefined ? config.y : box.y, pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({\n width: config.width || box.width || (stage ? stage.width() : 0),\n height: config.height || box.height || (stage ? stage.height() : 0),\n pixelRatio: pixelRatio,\n }), context = canvas.getContext();\n context.save();\n if (x || y) {\n context.translate(-1 * x, -1 * y);\n }\n this.drawScene(canvas);\n context.restore();\n return canvas;\n };\n Node.prototype.toCanvas = function (config) {\n return this._toKonvaCanvas(config)._canvas;\n };\n Node.prototype.toDataURL = function (config) {\n config = config || {};\n var mimeType = config.mimeType || null, quality = config.quality || null;\n var url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);\n if (config.callback) {\n config.callback(url);\n }\n return url;\n };\n Node.prototype.toImage = function (config) {\n if (!config || !config.callback) {\n throw 'callback required for toImage method config argument';\n }\n var callback = config.callback;\n delete config.callback;\n Util_1.Util._urlToImage(this.toDataURL(config), function (img) {\n callback(img);\n });\n };\n Node.prototype.setSize = function (size) {\n this.width(size.width);\n this.height(size.height);\n return this;\n };\n Node.prototype.getSize = function () {\n return {\n width: this.width(),\n height: this.height(),\n };\n };\n Node.prototype.getClassName = function () {\n return this.className || this.nodeType;\n };\n Node.prototype.getType = function () {\n return this.nodeType;\n };\n Node.prototype.getDragDistance = function () {\n if (this.attrs.dragDistance !== undefined) {\n return this.attrs.dragDistance;\n }\n else if (this.parent) {\n return this.parent.getDragDistance();\n }\n else {\n return Global_1.Konva.dragDistance;\n }\n };\n Node.prototype._off = function (type, name, callback) {\n var evtListeners = this.eventListeners[type], i, evtName, handler;\n for (i = 0; i < evtListeners.length; i++) {\n evtName = evtListeners[i].name;\n handler = evtListeners[i].handler;\n if ((evtName !== 'konva' || name === 'konva') &&\n (!name || evtName === name) &&\n (!callback || callback === handler)) {\n evtListeners.splice(i, 1);\n if (evtListeners.length === 0) {\n delete this.eventListeners[type];\n break;\n }\n i--;\n }\n }\n };\n Node.prototype._fireChangeEvent = function (attr, oldVal, newVal) {\n this._fire(attr + CHANGE, {\n oldVal: oldVal,\n newVal: newVal,\n });\n };\n Node.prototype.setId = function (id) {\n var oldId = this.id();\n exports._removeId(oldId, this);\n _addId(this, id);\n this._setAttr('id', id);\n return this;\n };\n Node.prototype.setName = function (name) {\n var oldNames = (this.name() || '').split(/\\s/g);\n var newNames = (name || '').split(/\\s/g);\n var subname, i;\n for (i = 0; i < oldNames.length; i++) {\n subname = oldNames[i];\n if (newNames.indexOf(subname) === -1 && subname) {\n exports._removeName(subname, this._id);\n }\n }\n for (i = 0; i < newNames.length; i++) {\n subname = newNames[i];\n if (oldNames.indexOf(subname) === -1 && subname) {\n exports._addName(this, subname);\n }\n }\n this._setAttr(NAME, name);\n return this;\n };\n Node.prototype.addName = function (name) {\n if (!this.hasName(name)) {\n var oldName = this.name();\n var newName = oldName ? oldName + ' ' + name : name;\n this.setName(newName);\n }\n return this;\n };\n Node.prototype.hasName = function (name) {\n if (!name) {\n return false;\n }\n var fullName = this.name();\n if (!fullName) {\n return false;\n }\n var names = (fullName || '').split(/\\s/g);\n return names.indexOf(name) !== -1;\n };\n Node.prototype.removeName = function (name) {\n var names = (this.name() || '').split(/\\s/g);\n var index = names.indexOf(name);\n if (index !== -1) {\n names.splice(index, 1);\n this.setName(names.join(' '));\n }\n return this;\n };\n Node.prototype.setAttr = function (attr, val) {\n var func = this[SET + Util_1.Util._capitalize(attr)];\n if (Util_1.Util._isFunction(func)) {\n func.call(this, val);\n }\n else {\n this._setAttr(attr, val);\n }\n return this;\n };\n Node.prototype._setAttr = function (key, val) {\n var oldVal = this.attrs[key];\n if (oldVal === val && !Util_1.Util.isObject(val)) {\n return;\n }\n if (val === undefined || val === null) {\n delete this.attrs[key];\n }\n else {\n this.attrs[key] = val;\n }\n this._fireChangeEvent(key, oldVal, val);\n };\n Node.prototype._setComponentAttr = function (key, component, val) {\n var oldVal;\n if (val !== undefined) {\n oldVal = this.attrs[key];\n if (!oldVal) {\n this.attrs[key] = this.getAttr(key);\n }\n this.attrs[key][component] = val;\n this._fireChangeEvent(key, oldVal, val);\n }\n };\n Node.prototype._fireAndBubble = function (eventType, evt, compareShape) {\n if (evt && this.nodeType === SHAPE) {\n evt.target = this;\n }\n var shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&\n ((compareShape &&\n (this === compareShape ||\n (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||\n (this.nodeType === 'Stage' && !compareShape));\n if (!shouldStop) {\n this._fire(eventType, evt);\n var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&\n compareShape &&\n compareShape.isAncestorOf &&\n compareShape.isAncestorOf(this) &&\n !compareShape.isAncestorOf(this.parent);\n if (((evt && !evt.cancelBubble) || !evt) &&\n this.parent &&\n this.parent.isListening() &&\n !stopBubble) {\n if (compareShape && compareShape.parent) {\n this._fireAndBubble.call(this.parent, eventType, evt, compareShape);\n }\n else {\n this._fireAndBubble.call(this.parent, eventType, evt);\n }\n }\n }\n };\n Node.prototype._fire = function (eventType, evt) {\n var events = this.eventListeners[eventType], i;\n if (events) {\n evt = evt || {};\n evt.currentTarget = this;\n evt.type = eventType;\n for (i = 0; i < events.length; i++) {\n events[i].handler.call(this, evt);\n }\n }\n };\n Node.prototype.draw = function () {\n this.drawScene();\n this.drawHit();\n return this;\n };\n Node.prototype._createDragElement = function (evt) {\n var pointerId = evt ? evt.pointerId : undefined;\n var stage = this.getStage();\n var ap = this.getAbsolutePosition();\n var pos = stage._getPointerById(pointerId) ||\n stage._changedPointerPositions[0] ||\n ap;\n DragAndDrop_1.DD._dragElements.set(this._id, {\n node: this,\n startPointerPos: pos,\n offset: {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n },\n dragStatus: 'ready',\n pointerId: pointerId,\n });\n };\n Node.prototype.startDrag = function (evt) {\n if (!DragAndDrop_1.DD._dragElements.has(this._id)) {\n this._createDragElement(evt);\n }\n var elem = DragAndDrop_1.DD._dragElements.get(this._id);\n elem.dragStatus = 'dragging';\n this.fire('dragstart', {\n type: 'dragstart',\n target: this,\n evt: evt && evt.evt,\n }, true);\n };\n Node.prototype._setDragPosition = function (evt, elem) {\n var pos = this.getStage()._getPointerById(elem.pointerId);\n if (!pos) {\n return;\n }\n var newNodePos = {\n x: pos.x - elem.offset.x,\n y: pos.y - elem.offset.y,\n };\n var dbf = this.dragBoundFunc();\n if (dbf !== undefined) {\n var bounded = dbf.call(this, newNodePos, evt);\n if (!bounded) {\n Util_1.Util.warn('dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.');\n }\n else {\n newNodePos = bounded;\n }\n }\n if (!this._lastPos ||\n this._lastPos.x !== newNodePos.x ||\n this._lastPos.y !== newNodePos.y) {\n this.setAbsolutePosition(newNodePos);\n if (this.getLayer()) {\n this.getLayer().batchDraw();\n }\n else if (this.getStage()) {\n this.getStage().batchDraw();\n }\n }\n this._lastPos = newNodePos;\n };\n Node.prototype.stopDrag = function (evt) {\n var elem = DragAndDrop_1.DD._dragElements.get(this._id);\n if (elem) {\n elem.dragStatus = 'stopped';\n }\n DragAndDrop_1.DD._endDragBefore(evt);\n DragAndDrop_1.DD._endDragAfter(evt);\n };\n Node.prototype.setDraggable = function (draggable) {\n this._setAttr('draggable', draggable);\n this._dragChange();\n };\n Node.prototype.isDragging = function () {\n var elem = DragAndDrop_1.DD._dragElements.get(this._id);\n return elem ? elem.dragStatus === 'dragging' : false;\n };\n Node.prototype._listenDrag = function () {\n this._dragCleanup();\n this.on('mousedown.konva touchstart.konva', function (evt) {\n var _this = this;\n var shouldCheckButton = evt.evt['button'] !== undefined;\n var canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;\n if (!canDrag) {\n return;\n }\n if (this.isDragging()) {\n return;\n }\n var hasDraggingChild = false;\n DragAndDrop_1.DD._dragElements.forEach(function (elem) {\n if (_this.isAncestorOf(elem.node)) {\n hasDraggingChild = true;\n }\n });\n if (!hasDraggingChild) {\n this._createDragElement(evt);\n }\n });\n };\n Node.prototype._dragChange = function () {\n if (this.attrs.draggable) {\n this._listenDrag();\n }\n else {\n this._dragCleanup();\n var stage = this.getStage();\n if (stage && DragAndDrop_1.DD._dragElements.has(this._id)) {\n this.stopDrag();\n }\n }\n };\n Node.prototype._dragCleanup = function () {\n this.off('mousedown.konva');\n this.off('touchstart.konva');\n };\n Node.create = function (data, container) {\n if (Util_1.Util._isString(data)) {\n data = JSON.parse(data);\n }\n return this._createNode(data, container);\n };\n Node._createNode = function (obj, container) {\n var className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;\n if (container) {\n obj.attrs.container = container;\n }\n if (!Global_1._NODES_REGISTRY[className]) {\n Util_1.Util.warn('Can not find a node with class name \"' +\n className +\n '\". Fallback to \"Shape\".');\n className = 'Shape';\n }\n var Class = Global_1._NODES_REGISTRY[className];\n no = new Class(obj.attrs);\n if (children) {\n len = children.length;\n for (n = 0; n < len; n++) {\n no.add(Node._createNode(children[n]));\n }\n }\n return no;\n };\n return Node;\n}());\nexports.Node = Node;\nNode.prototype.nodeType = 'Node';\nNode.prototype._attrsAffectingSize = [];\nFactory_1.Factory.addGetterSetter(Node, 'zIndex');\nFactory_1.Factory.addGetterSetter(Node, 'absolutePosition');\nFactory_1.Factory.addGetterSetter(Node, 'position');\nFactory_1.Factory.addGetterSetter(Node, 'x', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'y', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'globalCompositeOperation', 'source-over', Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Node, 'opacity', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'name', '', Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Node, 'id', '', Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Node, 'rotation', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'scale', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Node, 'scaleX', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'scaleY', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'skew', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Node, 'skewX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'skewY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'offset', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Node, 'offsetX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'offsetY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'dragDistance', null, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'width', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'height', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Node, 'listening', 'inherit', function (val) {\n var isValid = val === true || val === false || val === 'inherit';\n if (!isValid) {\n Util_1.Util.warn(val +\n ' is a not valid value for \"listening\" attribute. The value may be true, false or \"inherit\".');\n }\n return val;\n});\nFactory_1.Factory.addGetterSetter(Node, 'preventDefault', true, Validators_1.getBooleanValidator());\nFactory_1.Factory.addGetterSetter(Node, 'filters', null, function (val) {\n this._filterUpToDate = false;\n return val;\n});\nFactory_1.Factory.addGetterSetter(Node, 'visible', 'inherit', function (val) {\n var isValid = val === true || val === false || val === 'inherit';\n if (!isValid) {\n Util_1.Util.warn(val +\n ' is a not valid value for \"visible\" attribute. The value may be true, false or \"inherit\".');\n }\n return val;\n});\nFactory_1.Factory.addGetterSetter(Node, 'transformsEnabled', 'all', Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Node, 'size');\nFactory_1.Factory.addGetterSetter(Node, 'dragBoundFunc');\nFactory_1.Factory.addGetterSetter(Node, 'draggable', false, Validators_1.getBooleanValidator());\nFactory_1.Factory.backCompat(Node, {\n rotateDeg: 'rotate',\n setRotationDeg: 'setRotation',\n getRotationDeg: 'getRotation',\n});\nUtil_1.Collection.mapMethods(Node);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Factory_1 = require(\"./Factory\");\nvar Node_1 = require(\"./Node\");\nvar Validators_1 = require(\"./Validators\");\nvar Global_1 = require(\"./Global\");\nvar PointerEvents = require(\"./PointerEvents\");\nvar HAS_SHADOW = 'hasShadow';\nvar SHADOW_RGBA = 'shadowRGBA';\nvar patternImage = 'patternImage';\nvar linearGradient = 'linearGradient';\nvar radialGradient = 'radialGradient';\nvar dummyContext;\nfunction getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util_1.Util.createCanvasElement().getContext('2d');\n return dummyContext;\n}\nexports.shapes = {};\nfunction _fillFunc(context) {\n context.fill();\n}\nfunction _strokeFunc(context) {\n context.stroke();\n}\nfunction _fillFuncHit(context) {\n context.fill();\n}\nfunction _strokeFuncHit(context) {\n context.stroke();\n}\nfunction _clearHasShadowCache() {\n this._clearCache(HAS_SHADOW);\n}\nfunction _clearGetShadowRGBACache() {\n this._clearCache(SHADOW_RGBA);\n}\nfunction _clearFillPatternCache() {\n this._clearCache(patternImage);\n}\nfunction _clearLinearGradientCache() {\n this._clearCache(linearGradient);\n}\nfunction _clearRadialGradientCache() {\n this._clearCache(radialGradient);\n}\nvar Shape = (function (_super) {\n __extends(Shape, _super);\n function Shape(config) {\n var _this = _super.call(this, config) || this;\n var key;\n while (true) {\n key = Util_1.Util.getRandomColor();\n if (key && !(key in exports.shapes)) {\n break;\n }\n }\n _this.colorKey = key;\n exports.shapes[key] = _this;\n _this.on('shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);\n _this.on('shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);\n _this.on('fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva', _clearFillPatternCache);\n _this.on('fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);\n _this.on('fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);\n return _this;\n }\n Shape.prototype.getContext = function () {\n return this.getLayer().getContext();\n };\n Shape.prototype.getCanvas = function () {\n return this.getLayer().getCanvas();\n };\n Shape.prototype.getSceneFunc = function () {\n return this.attrs.sceneFunc || this['_sceneFunc'];\n };\n Shape.prototype.getHitFunc = function () {\n return this.attrs.hitFunc || this['_hitFunc'];\n };\n Shape.prototype.hasShadow = function () {\n return this._getCache(HAS_SHADOW, this._hasShadow);\n };\n Shape.prototype._hasShadow = function () {\n return (this.shadowEnabled() &&\n this.shadowOpacity() !== 0 &&\n !!(this.shadowColor() ||\n this.shadowBlur() ||\n this.shadowOffsetX() ||\n this.shadowOffsetY()));\n };\n Shape.prototype._getFillPattern = function () {\n return this._getCache(patternImage, this.__getFillPattern);\n };\n Shape.prototype.__getFillPattern = function () {\n if (this.fillPatternImage()) {\n var ctx = getDummyContext();\n var pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');\n return pattern;\n }\n };\n Shape.prototype._getLinearGradient = function () {\n return this._getCache(linearGradient, this.__getLinearGradient);\n };\n Shape.prototype.__getLinearGradient = function () {\n var colorStops = this.fillLinearGradientColorStops();\n if (colorStops) {\n var ctx = getDummyContext();\n var start = this.fillLinearGradientStartPoint();\n var end = this.fillLinearGradientEndPoint();\n var grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n };\n Shape.prototype._getRadialGradient = function () {\n return this._getCache(radialGradient, this.__getRadialGradient);\n };\n Shape.prototype.__getRadialGradient = function () {\n var colorStops = this.fillRadialGradientColorStops();\n if (colorStops) {\n var ctx = getDummyContext();\n var start = this.fillRadialGradientStartPoint();\n var end = this.fillRadialGradientEndPoint();\n var grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n };\n Shape.prototype.getShadowRGBA = function () {\n return this._getCache(SHADOW_RGBA, this._getShadowRGBA);\n };\n Shape.prototype._getShadowRGBA = function () {\n if (this.hasShadow()) {\n var rgba = Util_1.Util.colorToRGBA(this.shadowColor());\n return ('rgba(' +\n rgba.r +\n ',' +\n rgba.g +\n ',' +\n rgba.b +\n ',' +\n rgba.a * (this.shadowOpacity() || 1) +\n ')');\n }\n };\n Shape.prototype.hasFill = function () {\n return (this.fillEnabled() &&\n !!(this.fill() ||\n this.fillPatternImage() ||\n this.fillLinearGradientColorStops() ||\n this.fillRadialGradientColorStops()));\n };\n Shape.prototype.hasStroke = function () {\n return (this.strokeEnabled() &&\n this.strokeWidth() &&\n !!(this.stroke() || this.strokeLinearGradientColorStops()));\n };\n Shape.prototype.hasHitStroke = function () {\n var width = this.hitStrokeWidth();\n if (width === 'auto') {\n return this.hasStroke();\n }\n return this.strokeEnabled() && !!width;\n };\n Shape.prototype.intersects = function (point) {\n var stage = this.getStage(), bufferHitCanvas = stage.bufferHitCanvas, p;\n bufferHitCanvas.getContext().clear();\n this.drawHit(bufferHitCanvas);\n p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;\n return p[3] > 0;\n };\n Shape.prototype.destroy = function () {\n Node_1.Node.prototype.destroy.call(this);\n delete exports.shapes[this.colorKey];\n delete this.colorKey;\n return this;\n };\n Shape.prototype._useBufferCanvas = function (caching) {\n return !!((!caching || this.hasShadow()) &&\n this.perfectDrawEnabled() &&\n this.getAbsoluteOpacity() !== 1 &&\n this.hasFill() &&\n this.hasStroke() &&\n this.getStage());\n };\n Shape.prototype.setStrokeHitEnabled = function (val) {\n Util_1.Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');\n if (val) {\n this.hitStrokeWidth('auto');\n }\n else {\n this.hitStrokeWidth(0);\n }\n };\n Shape.prototype.getStrokeHitEnabled = function () {\n if (this.hitStrokeWidth() === 0) {\n return false;\n }\n else {\n return true;\n }\n };\n Shape.prototype.getSelfRect = function () {\n var size = this.size();\n return {\n x: this._centroid ? -size.width / 2 : 0,\n y: this._centroid ? -size.height / 2 : 0,\n width: size.width,\n height: size.height\n };\n };\n Shape.prototype.getClientRect = function (attrs) {\n attrs = attrs || {};\n var skipTransform = attrs.skipTransform;\n var relativeTo = attrs.relativeTo;\n var fillRect = this.getSelfRect();\n var applyStroke = !attrs.skipStroke && this.hasStroke();\n var strokeWidth = (applyStroke && this.strokeWidth()) || 0;\n var fillAndStrokeWidth = fillRect.width + strokeWidth;\n var fillAndStrokeHeight = fillRect.height + strokeWidth;\n var applyShadow = !attrs.skipShadow && this.hasShadow();\n var shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;\n var shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;\n var preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);\n var preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);\n var blurRadius = (applyShadow && this.shadowBlur()) || 0;\n var width = preWidth + blurRadius * 2;\n var height = preHeight + blurRadius * 2;\n var roundingOffset = 0;\n if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {\n roundingOffset = 1;\n }\n var rect = {\n width: width + roundingOffset,\n height: height + roundingOffset,\n x: -Math.round(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetX, 0) +\n fillRect.x,\n y: -Math.round(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetY, 0) +\n fillRect.y\n };\n if (!skipTransform) {\n return this._transformedRect(rect, relativeTo);\n }\n return rect;\n };\n Shape.prototype.drawScene = function (can, top, caching, skipBuffer) {\n var layer = this.getLayer(), canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.sceneFunc(), hasShadow = this.hasShadow(), hasStroke = this.hasStroke(), stage, bufferCanvas, bufferContext;\n if (!this.isVisible() && !caching) {\n return this;\n }\n if (cachedCanvas) {\n context.save();\n layer._applyTransform(this, context, top);\n this._drawCachedSceneCanvas(context);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n if (this._useBufferCanvas(caching) && !skipBuffer) {\n stage = this.getStage();\n bufferCanvas = stage.bufferCanvas;\n bufferContext = bufferCanvas.getContext();\n bufferContext.clear();\n bufferContext.save();\n bufferContext._applyLineJoin(this);\n if (!caching) {\n if (layer) {\n layer._applyTransform(this, bufferContext, top);\n }\n else {\n var m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n }\n drawFunc.call(this, bufferContext, this);\n bufferContext.restore();\n var ratio = bufferCanvas.pixelRatio;\n if (hasShadow && !canvas.hitCanvas) {\n context.save();\n context._applyShadow(this);\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n context.drawImage(bufferCanvas._canvas, 0, 0, bufferCanvas.width / ratio, bufferCanvas.height / ratio);\n context.restore();\n }\n else {\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n context.drawImage(bufferCanvas._canvas, 0, 0, bufferCanvas.width / ratio, bufferCanvas.height / ratio);\n }\n }\n else {\n context._applyLineJoin(this);\n if (!caching) {\n if (layer) {\n layer._applyTransform(this, context, top);\n }\n else {\n var o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n }\n }\n if (hasShadow && hasStroke && !canvas.hitCanvas) {\n context.save();\n if (!caching) {\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n context._applyShadow(this);\n drawFunc.call(this, context, this);\n context.restore();\n if (this.hasFill() && this.shadowForStrokeEnabled()) {\n drawFunc.call(this, context, this);\n }\n }\n else if (hasShadow && !canvas.hitCanvas) {\n context.save();\n if (!caching) {\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n context._applyShadow(this);\n drawFunc.call(this, context, this);\n context.restore();\n }\n else {\n if (!caching) {\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n drawFunc.call(this, context, this);\n }\n }\n context.restore();\n return this;\n };\n Shape.prototype.drawHit = function (can, top, caching) {\n var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;\n if (!this.colorKey) {\n console.log(this);\n Util_1.Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. See the shape in logs above. If you want to reuse shape you should call remove() instead of destroy()');\n }\n if (!this.shouldDrawHit() && !caching) {\n return this;\n }\n if (cachedHitCanvas) {\n context.save();\n layer._applyTransform(this, context, top);\n this._drawCachedHitCanvas(context);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n context._applyLineJoin(this);\n if (!caching) {\n if (layer) {\n layer._applyTransform(this, context, top);\n }\n else {\n var o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n }\n }\n drawFunc.call(this, context, this);\n context.restore();\n return this;\n };\n Shape.prototype.drawHitFromCache = function (alphaThreshold) {\n if (alphaThreshold === void 0) { alphaThreshold = 0; }\n var cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha;\n hitContext.clear();\n hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);\n try {\n hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);\n hitData = hitImageData.data;\n len = hitData.length;\n rgbColorKey = Util_1.Util._hexToRgb(this.colorKey);\n for (i = 0; i < len; i += 4) {\n alpha = hitData[i + 3];\n if (alpha > alphaThreshold) {\n hitData[i] = rgbColorKey.r;\n hitData[i + 1] = rgbColorKey.g;\n hitData[i + 2] = rgbColorKey.b;\n hitData[i + 3] = 255;\n }\n else {\n hitData[i + 3] = 0;\n }\n }\n hitContext.putImageData(hitImageData, 0, 0);\n }\n catch (e) {\n Util_1.Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);\n }\n return this;\n };\n Shape.prototype.hasPointerCapture = function (pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n };\n Shape.prototype.setPointerCapture = function (pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n };\n Shape.prototype.releaseCapture = function (pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n };\n return Shape;\n}(Node_1.Node));\nexports.Shape = Shape;\nShape.prototype._fillFunc = _fillFunc;\nShape.prototype._strokeFunc = _strokeFunc;\nShape.prototype._fillFuncHit = _fillFuncHit;\nShape.prototype._strokeFuncHit = _strokeFuncHit;\nShape.prototype._centroid = false;\nShape.prototype.nodeType = 'Shape';\nGlobal_1._registerNode(Shape);\nFactory_1.Factory.addGetterSetter(Shape, 'stroke', undefined, Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'strokeWidth', 2, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', Validators_1.getNumberOrAutoValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, Validators_1.getBooleanValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, Validators_1.getBooleanValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, Validators_1.getBooleanValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'lineJoin');\nFactory_1.Factory.addGetterSetter(Shape, 'lineCap');\nFactory_1.Factory.addGetterSetter(Shape, 'sceneFunc');\nFactory_1.Factory.addGetterSetter(Shape, 'hitFunc');\nFactory_1.Factory.addGetterSetter(Shape, 'dash');\nFactory_1.Factory.addGetterSetter(Shape, 'dashOffset', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowColor', undefined, Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowBlur', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOpacity', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternImage');\nFactory_1.Factory.addGetterSetter(Shape, 'fill', undefined, Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');\nFactory_1.Factory.addGetterSetter(Shape, 'fillEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'shadowEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'dashEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPriority', 'color');\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [\n 'x',\n 'y'\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);\nFactory_1.Factory.backCompat(Shape, {\n dashArray: 'dash',\n getDashArray: 'getDash',\n setDashArray: 'getDash',\n drawFunc: 'sceneFunc',\n getDrawFunc: 'getSceneFunc',\n setDrawFunc: 'setSceneFunc',\n drawHitFunc: 'hitFunc',\n getDrawHitFunc: 'getHitFunc',\n setDrawHitFunc: 'setHitFunc'\n});\nUtil_1.Collection.mapMethods(Shape);\n","const Pair = require('./pair');\nconst {anchor, Anchor} = require('./anchor');\nconst {None} = require('./insert')\nconst connector = require('./connector')\nconst Structure = require('./structure');\nconst {itself, orthogonalTransform} = require('./prelude');\n\n/**\n * @callback TranslationListener\n * @param {Piece} piece\n * @param {number} dx\n * @param {number} dy\n */\n\n/**\n * @callback ConnectionListener\n * @param {Piece} piece\n * @param {Piece} target\n */\n\n/**\n * A piece primitive representation that can be easily stringified, exchanged and persisted\n *\n * @typedef {object} PieceDump\n * @property {import('./position').Position} centralAnchor\n * @property {string} structure\n * @property {import('./prelude').Orthogonal<object>} [connections]\n * @property {object} metadata\n */\n\n /**\n * A jigsaw piece\n */\n class Piece {\n\n /**\n * @param {import('./structure').Structure} [options]\n */\n constructor({up = None, down = None, left = None, right = None} = {}) {\n this.up = up;\n this.down = down;\n this.left = left;\n this.right = right;\n this.metadata = {};\n /** @type {Anchor} */\n this.centralAnchor = null;\n this._initializeListeners();\n }\n\n _initializeListeners() {\n /** @type {TranslationListener[]} */\n this.translateListeners = [];\n /** @type {ConnectionListener[]} */\n this.connectListeners = [];\n /** @type {ConnectionListener[]} */\n this.disconnectListeners = [];\n }\n\n /**\n * Adds unestructured user-defined metadata on this piece.\n *\n * @param {object} metadata\n */\n annotate(metadata) {\n Object.assign(this.metadata, metadata);\n }\n\n /**\n * Sets unestructured user-defined metadata on this piece.\n *\n * This object has no strong requirement, but it is recommended to have an\n * id property.\n *\n * @param {object} metadata\n */\n reannotate(metadata) {\n this.metadata = metadata;\n }\n\n /**\n * @param {import('./puzzle')} puzzle\n */\n belongTo(puzzle) {\n this.puzzle = puzzle;\n }\n\n /**\n * @returns {Piece[]}\n */\n get presentConnections() {\n return this.connections.filter(itself);\n }\n\n get connections() {\n return [\n this.rightConnection,\n this.downConnection,\n this.leftConnection,\n this.upConnection\n ];\n }\n\n get inserts() {\n return [\n this.right,\n this.down,\n this.left,\n this.up\n ];\n }\n\n /**\n * @param {TranslationListener} f the callback\n */\n onTranslate(f) {\n this.translateListeners.push(f);\n }\n\n /**\n * @param {ConnectionListener} f the callback\n */\n onConnect(f) {\n this.connectListeners.push(f);\n }\n\n /**\n * @param {ConnectionListener} f the callback\n */\n onDisconnect(f) {\n this.disconnectListeners.push(f);\n }\n\n /**\n * @param {number} dx\n * @param {number} dy\n */\n fireTranslate(dx, dy) {\n this.translateListeners.forEach(it => it(this, dx, dy));\n }\n\n /**\n * @param {Piece} other\n */\n fireConnect(other) {\n this.connectListeners.forEach(it => it(this, other));\n }\n\n /**\n * @param {Piece[]} others\n */\n fireDisconnect(others) {\n others.forEach(other => {\n this.disconnectListeners.forEach(it => it(this, other));\n });\n }\n\n /**\n *\n * @param {Piece} other\n * @param {boolean} [back]\n */\n connectVerticallyWith(other, back = false) {\n connector.vertical.connectWith(this, other, this.proximity, back);\n }\n\n /**\n * @param {Piece} other\n */\n attractVertically(other, back = false) {\n connector.vertical.attract(this, other, back);\n }\n\n /**\n * @param {Piece} other\n * @param {boolean} [back]\n */\n connectHorizontallyWith(other, back = false) {\n connector.horizontal.connectWith(this, other, this.proximity, back);\n }\n\n /**\n * @param {Piece} other\n */\n attractHorizontally(other, back = false) {\n connector.horizontal.attract(this, other, back);\n }\n\n /**\n * @param {Piece} other\n * @param {boolean} [back]\n */\n tryConnectWith(other, back = false) {\n this.tryConnectHorizontallyWith(other, back);\n this.tryConnectVerticallyWith(other, back);\n }\n\n /**\n *\n * @param {Piece} other\n * @param {boolean} [back]\n */\n tryConnectHorizontallyWith(other, back = false) {\n if (this.canConnectHorizontallyWith(other)) {\n this.connectHorizontallyWith(other, back);\n }\n }\n /**\n *\n * @param {Piece} other\n * @param {boolean} [back]\n */\n tryConnectVerticallyWith(other, back = false) {\n if (this.canConnectVerticallyWith(other)) {\n this.connectVerticallyWith(other, back);\n }\n }\n\n disconnect() {\n if (!this.connected) {\n return;\n }\n const connections = this.presentConnections;\n\n if (this.upConnection) {\n this.upConnection.downConnection = null;\n /** @type {Piece} */\n this.upConnection = null;\n }\n\n if (this.downConnection) {\n this.downConnection.upConnection = null;\n this.downConnection = null;\n }\n\n if (this.leftConnection) {\n this.leftConnection.rightConnection = null;\n /** @type {Piece} */\n this.leftConnection = null;\n }\n\n if (this.rightConnection) {\n this.rightConnection.leftConnection = null;\n this.rightConnection = null;\n }\n\n this.fireDisconnect(connections);\n }\n\n /**\n * Sets the centralAnchor for this piece.\n *\n * @param {Anchor} anchor\n */\n centerAround(anchor) {\n if (this.centralAnchor) {\n throw new Error(\"this pieces has already being centered. Use recenterAround instead\");\n }\n this.centralAnchor = anchor;\n }\n\n\n /**\n * Sets the initial position of this piece. This method is similar to {@link Piece#centerAround},\n * but takes a pair instead of an anchor.\n *\n * @param {number} x\n * @param {number} y\n */\n locateAt(x, y) {\n this.centerAround(anchor(x, y));\n }\n\n /**\n * Tells whether this piece central anchor is at given point\n *\n * @param {number} x\n * @param {number} y\n * @return {boolean}\n */\n isAt(x, y) {\n return this.centralAnchor.isAt(x, y);\n }\n\n /**\n * Moves this piece to the given position, firing translation events.\n * Piece must be already centered.\n *\n * @param {Anchor} anchor the new central anchor\n * @param {boolean} [quiet] indicates whether events should be suppressed\n */\n recenterAround(anchor, quiet = false) {\n const [dx, dy] = anchor.diff(this.centralAnchor);\n this.translate(dx, dy, quiet);\n }\n\n /**\n * Moves this piece to the given position, firing translation events.\n * Piece must be already centered. This method is similar to {@link Piece#recenterAround},\n * but takes a pair instead of an anchor.\n *\n * @param {number} x the final x position\n * @param {number} y the final y position\n * @param {boolean} [quiet] indicates whether events should be suppressed\n */\n relocateTo(x, y, quiet = false) {\n this.recenterAround(anchor(x, y), quiet);\n }\n\n /**\n * Move this piece a given distance, firing translation events\n *\n * @param {number} dx the x distance\n * @param {number} dy the y distance\n * @param {boolean} [quiet] indicates whether events should be suppressed\n */\n translate(dx, dy, quiet = false) {\n if (!Pair.isNull(dx, dy)) {\n this.centralAnchor.translate(dx, dy);\n if (!quiet) {\n this.fireTranslate(dx, dy);\n }\n }\n }\n\n /**\n *\n * @param {number} dx\n * @param {number} dy\n * @param {boolean} [quiet]\n * @param {Piece[]} [pushedPieces]\n */\n push(dx, dy, quiet = false, pushedPieces = [this]) {\n this.translate(dx, dy, quiet);\n\n const stationaries = this.presentConnections.filter(it => pushedPieces.indexOf(it) === -1);\n pushedPieces.push(...stationaries);\n stationaries.forEach(it => it.push(dx, dy, false, pushedPieces));\n }\n\n /**\n *\n * @param {number} dx\n * @param {number} dy\n */\n drag(dx, dy, quiet = false) {\n if (Pair.isNull(dx, dy)) return;\n\n if (this.horizontallyOpenMovement(dx) && this.vericallyOpenMovement(dy)) {\n this.disconnect();\n this.translate(dx, dy, quiet);\n } else {\n this.push(dx, dy, quiet);\n }\n }\n\n drop() {\n this.puzzle.autoconnectWith(this);\n }\n\n dragAndDrop(dx, dy) {\n this.drag(dx, dy);\n this.drop();\n }\n\n /**\n *\n * @param {number} dy\n * @returns {boolean}\n */\n vericallyOpenMovement(dy) {\n return connector.vertical.openMovement(this, dy);\n }\n\n /**\n *\n * @param {number} dx\n * @returns {boolean}\n */\n horizontallyOpenMovement(dx) {\n return connector.horizontal.openMovement(this, dx);\n }\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n canConnectHorizontallyWith(other) {\n return connector.horizontal.canConnectWith(this, other, this.proximity);\n }\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n canConnectVerticallyWith(other) {\n return connector.vertical.canConnectWith(this, other, this.proximity);\n }\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n verticallyCloseTo(other) {\n return connector.vertical.closeTo(this, other, this.proximity);\n }\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n horizontallyCloseTo(other) {\n return connector.horizontal.closeTo(this, other, this.proximity);\n }\n\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n verticallyMatch(other) {\n return connector.vertical.match(this, other);\n }\n\n /**\n *\n * @param {Piece} other\n * @returns {boolean}\n */\n horizontallyMatch(other) {\n return connector.horizontal.match(this, other);\n }\n\n get connected() {\n return !!(this.upConnection || this.downConnection || this.leftConnection || this.rightConnection);\n }\n\n /**\n * @return {Anchor}\n */\n get downAnchor() {\n return this.centralAnchor.translated(0, this.size);\n }\n\n /**\n * @return {Anchor}\n */\n get rightAnchor() {\n return this.centralAnchor.translated(this.size, 0);\n }\n\n /**\n * @return {Anchor}\n */\n get upAnchor() {\n return this.centralAnchor.translated(0, -this.size);\n }\n\n /**\n * @return {Anchor}\n */\n get leftAnchor() {\n return this.centralAnchor.translated(-this.size, 0);\n }\n\n /**\n * @return {number}\n */\n get size() {\n return this.puzzle.pieceSize;\n }\n\n /**\n * @returns {number}\n */\n get proximity() {\n return this.puzzle.proximity;\n }\n\n /**\n * This piece id. It is extracted from metadata\n *\n * @returns {string}\n */\n get id() {\n return this.metadata.id;\n }\n\n /**\n * Converts this piece into a plain, stringify-ready object.\n * Connections should have ids\n *\n * @param {object} options\n * @param {boolean} [options.compact]\n * @returns {PieceDump}\n */\n export({compact = false} = {}) {\n const base = {\n centralAnchor: this.centralAnchor && this.centralAnchor.export(),\n structure: Structure.serialize(this),\n metadata: this.metadata\n };\n return compact ? base : Object.assign(base, {\n connections: orthogonalTransform(this.connections, it => ({id: it.id}))\n })\n }\n\n /**\n * Converts this piece back from a dump. Connections are not restored. {@link Puzzle#autoconnect} method should be used\n * after importing all them\n *\n * @param {PieceDump} dump\n * @returns {Piece}\n */\n static import(dump) {\n const piece = new Piece(Structure.deserialize(dump.structure));\n\n if (dump.centralAnchor) {\n piece.centerAround(Anchor.import(dump.centralAnchor));\n }\n\n if (dump.metadata) {\n piece.annotate(dump.metadata);\n }\n return piece;\n }\n}\n\nmodule.exports = Piece;\n","/**\n * @typedef {[number, number]} Pair\n */\n\n/**\n * Utilities for handling 2D vectors, expressed a two-elements list\n *\n * @module Pair\n */\n\n/**\n * Tells whether this pair is (0, 0)\n *\n * @param {number} x\n * @param {number} y\n * @returns {boolean}\n */\nfunction isNull(x, y) {\n return equal(x, y, 0, 0);\n}\n\n/**\n * @param {number} x1\n * @param {number} y1\n * @param {number} x2\n * @param {number} y2\n * @returns {boolean}\n */\nfunction equal(x1, y1, x2, y2) {\n return x1 === x2 && y1 === y2;\n}\n\n/**\n * Calculates the difference of two vectors\n *\n * @param {number} x1\n * @param {number} y1\n * @param {number} x2\n * @param {number} y2\n * @returns {Pair}\n */\nfunction diff(x1, y1, x2, y2) {\n return [x1 - x2, y1 - y2];\n}\n\nmodule.exports = {\n isNull,\n diff,\n equal\n};\n","const Pair = require('./pair');\n\n/**\n * @typedef {object} Position\n * @property {number} x\n * @property {number} y\n */\n\n/**\n *\n * @param {number} x\n * @param {number} y\n *\n * @returns {Position}\n */\nfunction position(x, y) {\n return { x, y };\n}\n\n /**\n * This module contains functions for dealing with objects with x and y\n * coordinates that represent or include point data\n *\n * @module Position\n */\n\n/**\n * Returns a new (0, 0) position\n *\n * @returns {Position}\n */\nfunction origin() {\n return position(0, 0);\n}\n\n/**\n * Compares two points\n *\n * @param {Position} one\n * @param {Position} other\n * @returns {boolean}\n */\nfunction equal(one, other) {\n return Pair.equal(one.x, one.y, other.x, other.y);\n}\n\n/**\n * Creates a copy of the given point\n *\n * @param {Position} one\n * @returns {Position}\n */\nfunction copy({x, y}) {\n return {x, y}\n}\n\n/**\n * @param {Position} position\n * @param {any} x\n * @param {any} y\n */\nfunction update(position, x, y) {\n position.x = x;\n position.y = y;\n}\n\n/**\n * @param {Position} one\n * @param {Position} other\n * @returns {import('./pair').Pair};\n */\nfunction diff(one, other) {\n return Pair.diff(one.x, one.y, other.x, other.y);\n}\n\nmodule.exports = {\n position,\n copy,\n equal,\n origin,\n update,\n diff\n};\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Factory_1 = require(\"./Factory\");\nvar Node_1 = require(\"./Node\");\nvar DragAndDrop_1 = require(\"./DragAndDrop\");\nvar Validators_1 = require(\"./Validators\");\nvar Global_1 = require(\"./Global\");\nvar Container = (function (_super) {\n __extends(Container, _super);\n function Container() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.children = new Util_1.Collection();\n return _this;\n }\n Container.prototype.getChildren = function (filterFunc) {\n if (!filterFunc) {\n return this.children;\n }\n var results = new Util_1.Collection();\n this.children.each(function (child) {\n if (filterFunc(child)) {\n results.push(child);\n }\n });\n return results;\n };\n Container.prototype.hasChildren = function () {\n return this.getChildren().length > 0;\n };\n Container.prototype.removeChildren = function () {\n var child;\n for (var i = 0; i < this.children.length; i++) {\n child = this.children[i];\n child.parent = null;\n child.index = 0;\n child.remove();\n }\n this.children = new Util_1.Collection();\n return this;\n };\n Container.prototype.destroyChildren = function () {\n var child;\n for (var i = 0; i < this.children.length; i++) {\n child = this.children[i];\n child.parent = null;\n child.index = 0;\n child.destroy();\n }\n this.children = new Util_1.Collection();\n return this;\n };\n Container.prototype.add = function () {\n var children = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n children[_i] = arguments[_i];\n }\n if (arguments.length > 1) {\n for (var i = 0; i < arguments.length; i++) {\n this.add(arguments[i]);\n }\n return this;\n }\n var child = children[0];\n if (child.getParent()) {\n child.moveTo(this);\n return this;\n }\n var _children = this.children;\n this._validateAdd(child);\n child._clearCaches();\n child.index = _children.length;\n child.parent = this;\n _children.push(child);\n this._fire('add', {\n child: child\n });\n return this;\n };\n Container.prototype.destroy = function () {\n if (this.hasChildren()) {\n this.destroyChildren();\n }\n _super.prototype.destroy.call(this);\n return this;\n };\n Container.prototype.find = function (selector) {\n return this._generalFind(selector, false);\n };\n Container.prototype.get = function (selector) {\n Util_1.Util.warn('collection.get() method is deprecated. Please use collection.find() instead.');\n return this.find(selector);\n };\n Container.prototype.findOne = function (selector) {\n var result = this._generalFind(selector, true);\n return result.length > 0 ? result[0] : undefined;\n };\n Container.prototype._generalFind = function (selector, findOne) {\n var retArr = [];\n this._descendants(function (node) {\n var valid = node._isMatch(selector);\n if (valid) {\n retArr.push(node);\n }\n if (valid && findOne) {\n return true;\n }\n return false;\n });\n return Util_1.Collection.toCollection(retArr);\n };\n Container.prototype._descendants = function (fn) {\n var shouldStop = false;\n for (var i = 0; i < this.children.length; i++) {\n var child = this.children[i];\n shouldStop = fn(child);\n if (shouldStop) {\n return true;\n }\n if (!child.hasChildren()) {\n continue;\n }\n shouldStop = child._descendants(fn);\n if (shouldStop) {\n return true;\n }\n }\n return false;\n };\n Container.prototype.toObject = function () {\n var obj = Node_1.Node.prototype.toObject.call(this);\n obj.children = [];\n var children = this.getChildren();\n var len = children.length;\n for (var n = 0; n < len; n++) {\n var child = children[n];\n obj.children.push(child.toObject());\n }\n return obj;\n };\n Container.prototype.isAncestorOf = function (node) {\n var parent = node.getParent();\n while (parent) {\n if (parent._id === this._id) {\n return true;\n }\n parent = parent.getParent();\n }\n return false;\n };\n Container.prototype.clone = function (obj) {\n var node = Node_1.Node.prototype.clone.call(this, obj);\n this.getChildren().each(function (no) {\n node.add(no.clone());\n });\n return node;\n };\n Container.prototype.getAllIntersections = function (pos) {\n var arr = [];\n this.find('Shape').each(function (shape) {\n if (shape.isVisible() && shape.intersects(pos)) {\n arr.push(shape);\n }\n });\n return arr;\n };\n Container.prototype._setChildrenIndices = function () {\n this.children.each(function (child, n) {\n child.index = n;\n });\n };\n Container.prototype.drawScene = function (can, top, caching) {\n var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;\n if (this.isVisible() || caching) {\n if (!caching && cachedSceneCanvas) {\n context.save();\n layer._applyTransform(this, context, top);\n this._drawCachedSceneCanvas(context);\n context.restore();\n }\n else {\n this._drawChildren(canvas, 'drawScene', top, false, caching, caching);\n }\n }\n return this;\n };\n Container.prototype.drawHit = function (can, top, caching) {\n var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;\n if (this.shouldDrawHit(canvas) || caching) {\n if (!caching && cachedHitCanvas) {\n context.save();\n layer._applyTransform(this, context, top);\n this._drawCachedHitCanvas(context);\n context.restore();\n }\n else {\n this._drawChildren(canvas, 'drawHit', top, false, caching, caching);\n }\n }\n return this;\n };\n Container.prototype._drawChildren = function (canvas, drawMethod, top, caching, skipBuffer, skipComposition) {\n var layer = this.getLayer(), context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (clipWidth && clipHeight) || clipFunc, clipX, clipY;\n if (hasClip && layer) {\n context.save();\n var transform = this.getAbsoluteTransform(top);\n var m = transform.getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n context.beginPath();\n if (clipFunc) {\n clipFunc.call(this, context, this);\n }\n else {\n clipX = this.clipX();\n clipY = this.clipY();\n context.rect(clipX, clipY, clipWidth, clipHeight);\n }\n context.clip();\n m = transform\n .copy()\n .invert()\n .getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n var hasComposition = this.globalCompositeOperation() !== 'source-over' &&\n !skipComposition &&\n drawMethod === 'drawScene';\n if (hasComposition && layer) {\n context.save();\n context._applyGlobalCompositeOperation(this);\n }\n this.children.each(function (child) {\n child[drawMethod](canvas, top, caching, skipBuffer);\n });\n if (hasComposition && layer) {\n context.restore();\n }\n if (hasClip && layer) {\n context.restore();\n }\n };\n Container.prototype.shouldDrawHit = function (canvas) {\n if (canvas && canvas.isCache) {\n return true;\n }\n var layer = this.getLayer();\n var layerUnderDrag = false;\n DragAndDrop_1.DD._dragElements.forEach(function (elem) {\n if (elem.dragStatus === 'dragging' && elem.node.getLayer() === layer) {\n layerUnderDrag = true;\n }\n });\n var dragSkip = !Global_1.Konva.hitOnDragEnabled && layerUnderDrag;\n return layer && layer.hitGraphEnabled() && this.isVisible() && !dragSkip;\n };\n Container.prototype.getClientRect = function (config) {\n config = config || {};\n var skipTransform = config.skipTransform;\n var relativeTo = config.relativeTo;\n var minX, minY, maxX, maxY;\n var selfRect = {\n x: Infinity,\n y: Infinity,\n width: 0,\n height: 0\n };\n var that = this;\n this.children.each(function (child) {\n if (!child.visible()) {\n return;\n }\n var rect = child.getClientRect({\n relativeTo: that,\n skipShadow: config.skipShadow,\n skipStroke: config.skipStroke\n });\n if (rect.width === 0 && rect.height === 0) {\n return;\n }\n if (minX === undefined) {\n minX = rect.x;\n minY = rect.y;\n maxX = rect.x + rect.width;\n maxY = rect.y + rect.height;\n }\n else {\n minX = Math.min(minX, rect.x);\n minY = Math.min(minY, rect.y);\n maxX = Math.max(maxX, rect.x + rect.width);\n maxY = Math.max(maxY, rect.y + rect.height);\n }\n });\n var shapes = this.find('Shape');\n var hasVisible = false;\n for (var i = 0; i < shapes.length; i++) {\n var shape = shapes[i];\n if (shape._isVisible(this)) {\n hasVisible = true;\n break;\n }\n }\n if (hasVisible && minX !== undefined) {\n selfRect = {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY\n };\n }\n else {\n selfRect = {\n x: 0,\n y: 0,\n width: 0,\n height: 0\n };\n }\n if (!skipTransform) {\n return this._transformedRect(selfRect, relativeTo);\n }\n return selfRect;\n };\n return Container;\n}(Node_1.Node));\nexports.Container = Container;\nFactory_1.Factory.addComponentsGetterSetter(Container, 'clip', [\n 'x',\n 'y',\n 'width',\n 'height'\n]);\nFactory_1.Factory.addGetterSetter(Container, 'clipX', undefined, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Container, 'clipY', undefined, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Container, 'clipWidth', undefined, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Container, 'clipHeight', undefined, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Container, 'clipFunc');\nUtil_1.Collection.mapMethods(Container);\n","const between = require('./between');\nconst Pair = require('./pair')\nconst {position} = require('./position')\n\n/**\n * An Anchor is a mutable 2D point that\n * is used to locate pieces and pieces inserts\n */\nclass Anchor {\n /**\n *\n * @param {number} x\n * @param {number} y\n */\n constructor(x, y) {\n this.x = x;\n this.y = y;\n }\n\n /**\n * @param {Anchor} other\n * @returns {boolean}\n */\n equal(other) {\n return this.isAt(other.x, other.y);\n }\n\n /**\n * @param {number} x\n * @param {number} y\n * @returns {boolean}\n */\n isAt(x, y) {\n return Pair.equal(this.x, this.y, x, y);\n }\n\n /**\n * Creates a translated copy of this Anchor\n * according to a vector\n *\n * @param {number} dx\n * @param {number} dy\n * @returns {Anchor}\n */\n translated(dx, dy) {\n return this.copy().translate(dx, dy);\n }\n\n /**\n * Translates this anchor given to a vector\n *\n * @param {number} dx\n * @param {number} dy\n */\n translate(dx, dy) {\n this.x += dx;\n this.y += dy;\n return this;\n }\n\n /**\n * Answers whether this Anchor is near to another given a tolerance\n *\n * @param {Anchor} other\n * @param {number} tolerance the max distance within its radius is considered to be \"close\"\n * @returns {boolean}\n */\n closeTo(other, tolerance) {\n return between(this.x, other.x-tolerance, other.x + tolerance) && between(this.y, other.y-tolerance, other.y + tolerance)\n }\n\n /**\n * @returns {Anchor}\n */\n copy() {\n return new Anchor(this.x, this.y);\n }\n\n /**\n * Calculates the difference between this anchor and another\n *\n * @param {Anchor} other\n * @returns {import('./pair').Pair}\n */\n diff(other) {\n return Pair.diff(this.x, this.y, other.x, other.y)\n }\n\n /**\n * Converts this anchor into a point\n *\n * @returns {import('./pair').Pair}\n */\n asPoint() {\n return [this.x, this.y];\n }\n\n /**\n * Converts this anchor into a position\n *\n * @returns {import('./position').Position}\n */\n asPosition() {\n return position(this.x, this.y);\n }\n\n /**\n * @returns {import('./position').Position}\n */\n export() {\n return this.asPosition();\n }\n\n /**\n * @param {number} maxX\n * @param {number} maxY\n * @returns {Anchor}\n */\n static atRandom(maxX, maxY) {\n return new Anchor(Math.random() * maxX, Math.random() * maxY);\n }\n\n /**\n *\n * @param {import('./position').Position} position\n * @returns {Anchor}\n */\n static import(position) {\n return anchor(position.x, position.y);\n }\n}\n\n/**\n * Creates a new {@link Anchor}\n *\n * @param {number} x\n * @param {number} y\n * @returns {Anchor}\n */\nfunction anchor(x, y) {\n return new Anchor(x, y);\n}\n\nmodule.exports = {\n anchor,\n Anchor\n}\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Context_1 = require(\"./Context\");\nvar Global_1 = require(\"./Global\");\nvar Factory_1 = require(\"./Factory\");\nvar Validators_1 = require(\"./Validators\");\nvar _pixelRatio;\nfunction getDevicePixelRatio() {\n if (_pixelRatio) {\n return _pixelRatio;\n }\n var canvas = Util_1.Util.createCanvasElement();\n var context = canvas.getContext('2d');\n _pixelRatio = (function () {\n var devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||\n context.mozBackingStorePixelRatio ||\n context.msBackingStorePixelRatio ||\n context.oBackingStorePixelRatio ||\n context.backingStorePixelRatio ||\n 1;\n return devicePixelRatio / backingStoreRatio;\n })();\n return _pixelRatio;\n}\nvar Canvas = (function () {\n function Canvas(config) {\n this.pixelRatio = 1;\n this.width = 0;\n this.height = 0;\n this.isCache = false;\n var conf = config || {};\n var pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();\n this.pixelRatio = pixelRatio;\n this._canvas = Util_1.Util.createCanvasElement();\n this._canvas.style.padding = '0';\n this._canvas.style.margin = '0';\n this._canvas.style.border = '0';\n this._canvas.style.background = 'transparent';\n this._canvas.style.position = 'absolute';\n this._canvas.style.top = '0';\n this._canvas.style.left = '0';\n }\n Canvas.prototype.getContext = function () {\n return this.context;\n };\n Canvas.prototype.getPixelRatio = function () {\n return this.pixelRatio;\n };\n Canvas.prototype.setPixelRatio = function (pixelRatio) {\n var previousRatio = this.pixelRatio;\n this.pixelRatio = pixelRatio;\n this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);\n };\n Canvas.prototype.setWidth = function (width) {\n this.width = this._canvas.width = width * this.pixelRatio;\n this._canvas.style.width = width + 'px';\n var pixelRatio = this.pixelRatio, _context = this.getContext()._context;\n _context.scale(pixelRatio, pixelRatio);\n };\n Canvas.prototype.setHeight = function (height) {\n this.height = this._canvas.height = height * this.pixelRatio;\n this._canvas.style.height = height + 'px';\n var pixelRatio = this.pixelRatio, _context = this.getContext()._context;\n _context.scale(pixelRatio, pixelRatio);\n };\n Canvas.prototype.getWidth = function () {\n return this.width;\n };\n Canvas.prototype.getHeight = function () {\n return this.height;\n };\n Canvas.prototype.setSize = function (width, height) {\n this.setWidth(width || 0);\n this.setHeight(height || 0);\n };\n Canvas.prototype.toDataURL = function (mimeType, quality) {\n try {\n return this._canvas.toDataURL(mimeType, quality);\n }\n catch (e) {\n try {\n return this._canvas.toDataURL();\n }\n catch (err) {\n Util_1.Util.error('Unable to get data URL. ' +\n err.message +\n ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n return '';\n }\n }\n };\n return Canvas;\n}());\nexports.Canvas = Canvas;\nFactory_1.Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, Validators_1.getNumberValidator());\nvar SceneCanvas = (function (_super) {\n __extends(SceneCanvas, _super);\n function SceneCanvas(config) {\n if (config === void 0) { config = { width: 0, height: 0 }; }\n var _this = _super.call(this, config) || this;\n _this.context = new Context_1.SceneContext(_this);\n _this.setSize(config.width, config.height);\n return _this;\n }\n return SceneCanvas;\n}(Canvas));\nexports.SceneCanvas = SceneCanvas;\nvar HitCanvas = (function (_super) {\n __extends(HitCanvas, _super);\n function HitCanvas(config) {\n if (config === void 0) { config = { width: 0, height: 0 }; }\n var _this = _super.call(this, config) || this;\n _this.hitCanvas = true;\n _this.context = new Context_1.HitContext(_this);\n _this.setSize(config.width, config.height);\n return _this;\n }\n return HitCanvas;\n}(Canvas));\nexports.HitCanvas = HitCanvas;\n","const {Anchor} = require('./anchor');\nconst Piece = require('./piece');\nconst {NullValidator} = require('./validator');\n\n /**\n * A puzzle primitive representation that can be easily stringified, exchanged and persisted\n *\n * @typedef {object} PuzzleDump\n * @property {number} pieceSize\n * @property {number} proximity\n * @property {import('./piece').PieceDump[]} pieces\n */\n\n/**\n * @typedef {object} Settings\n * @property {number} [pieceSize]\n * @property {number} [proximity]\n */\n\n\n /**\n * A set of a {@link Piece}s that can be manipulated as a whole, and that can be\n * used as a pieces factory\n */\nclass Puzzle {\n\n /**\n * @param {Settings} [options]\n */\n constructor({pieceSize = 2, proximity = 1} = {}) {\n this.pieceSize = pieceSize;\n this.proximity = proximity;\n /** @type {Piece[]} */\n this.pieces = [];\n /** @type {import('./validator').Validator} */\n this.validator = NullValidator;\n }\n\n /**\n * Creates and adds to this puzzle a new piece\n *\n * @param {import('./structure').Structure} [options] the piece structure\n * @returns {Piece} the new piece\n */\n newPiece(options = {}) {\n const piece = new Piece(options);\n this.addPiece(piece);\n return piece;\n }\n\n /**\n * @param {Piece} piece\n */\n addPiece(piece) {\n this.pieces.push(piece);\n piece.belongTo(this);\n }\n\n /**\n * @param {Piece[]} pieces\n */\n addPieces(pieces) {\n pieces.forEach(it => this.addPiece(it));\n }\n\n /**\n * Annotates all the pieces with the given list of metadata\n *\n * @param {object[]} metadata\n */\n annotate(metadata) {\n this.pieces.forEach((piece, index) => piece.annotate(metadata[index]));\n }\n\n /**\n * Relocates all the pieces to the given list of points\n *\n * @param {import('./pair').Pair[]} points\n */\n relocateTo(points) {\n this.pieces.forEach((piece, index) => piece.relocateTo(...points[index]));\n }\n\n /**\n * Tries to connect pieces in their current positions\n * This method is O(n^2)\n */\n autoconnect() {\n this.pieces.forEach(it => this.autoconnectWith(it));\n }\n\n /**\n * Disconnects all pieces\n */\n disconnect() {\n this.pieces.forEach(it => it.disconnect());\n }\n\n /**\n * Tries to connect the given piece to the rest of the set\n * This method is O(n)\n * @param {Piece} piece\n */\n autoconnectWith(piece) {\n this.pieces.filter(it => it !== piece).forEach(other => {\n piece.tryConnectWith(other);\n other.tryConnectWith(piece, true);\n })\n }\n\n /**\n * @param {number} maxX\n * @param {number} maxY\n */\n shuffle(maxX, maxY) {\n this.disconnect();\n this.pieces.forEach(it => it.recenterAround(Anchor.atRandom(maxX, maxY)));\n this.autoconnect();\n }\n\n /**\n * @param {number} dx\n * @param {number} dy\n */\n translate(dx, dy) {\n this.pieces.forEach(it => it.translate(dx, dy));\n }\n /**\n * @param {import('./piece').TranslationListener} f\n */\n onTranslate(f) {\n this.pieces.forEach(it => it.onTranslate(f));\n }\n\n /**\n * @param {import('./piece').ConnectionListener} f\n */\n onConnect(f) {\n this.pieces.forEach(it => it.onConnect(f));\n }\n\n /**\n * @param {import('./piece').ConnectionListener} f\n */\n onDisconnect(f) {\n this.pieces.forEach(it => it.onDisconnect(f));\n }\n\n /**\n * @param {import('./validator').ValidationListener} f\n */\n onValid(f) {\n this.validator.onValid(f);\n }\n\n /**\n * Answers the list of points where\n * central anchors of pieces are located\n *\n * @returns {import('./pair').Pair[]}\n */\n get points() {\n return this.pieces.map(it => it.centralAnchor.asPoint());\n }\n\n /**\n * Answers a list of points whose coordinates are scaled\n * to the {@link Puzzle#pieceWidth}\n *\n * @returns {import('./pair').Pair[]}\n */\n get refs() {\n return this.points.map(([x, y]) => [x / this.pieceWidth, y / this.pieceWidth])\n }\n\n get metadata() {\n return this.pieces.map(it => it.metadata);\n }\n\n /**\n * Returns the first piece\n *\n * @returns {Piece}\n */\n get head() {\n return this.pieces[0];\n }\n\n /**\n * Returns the central anchor of the first piece\n *\n * @returns {Anchor}\n */\n get headAnchor() {\n return this.head.centralAnchor;\n }\n\n /**\n * @param {import('./validator').Validator} validator\n */\n attachValidator(validator) {\n this.validator = validator;\n }\n\n isValid() {\n return this.validator.isValid(this);\n }\n\n validate() {\n this.validator.validate(this);\n }\n\n /**\n * Wether all the pieces in this puzzle are connected\n *\n * @returns {boolean}\n */\n get connected() {\n return this.pieces.every(it => it.connected);\n }\n\n /**\n * The piece width, from edge to edge\n *\n * @returns {number} the double of the {@link Puzzle#pieceSize}\n */\n get pieceWidth() {\n return this.pieceSize * 2;\n }\n\n /**\n * Converts this piece into a plain, stringify-ready object.\n * Pieces should have ids\n *\n * @param {object} options config options for export\n * @param {boolean} [options.compact] if connection information must be omitted\n * @returns {PuzzleDump}\n */\n export(options = {}) {\n return {\n pieceSize: this.pieceSize,\n proximity: this.proximity,\n pieces: this.pieces.map(it => it.export(options))\n }\n }\n\n /**\n * @param {PuzzleDump} dump\n * @returns {Puzzle}\n */\n static import(dump) {\n const puzzle = new Puzzle({pieceSize: dump.pieceSize, proximity: dump.proximity});\n puzzle.addPieces(dump.pieces.map(it => Piece.import(it)));\n puzzle.autoconnect();\n return puzzle;\n }\n}\n\nmodule.exports = Puzzle;\n","/**\n * A connection element of a piece\n *\n * @typedef {(Tab|Slot|None)} Insert\n */\n\nconst Tab = {\n isSlot: () => false,\n isTab: () => true,\n isNone: () => false,\n match: (other) => other.isSlot(),\n toString: () => \"Tab\",\n complement: () => Slot,\n serialize: () => 'T'\n}\n\nconst Slot = {\n isSlot: () => true,\n isTab: () => false,\n isNone: () => false,\n match: (other) => other.isTab(),\n toString: () => \"Slot\",\n complement: () => Tab,\n serialize: () => 'S'\n}\n\nconst None = {\n isSlot: () => false,\n isTab: () => false,\n isNone: () => true,\n match: (other) => false,\n toString: () => \"None\",\n complement: () => None,\n serialize: () => '-'\n}\n\nmodule.exports = {\n None,\n Slot,\n Tab\n};\n\n\n","const Puzzle = require('./puzzle');\nconst Piece = require('./piece');\nconst Pair = require('./pair');\n\n/**\n * @typedef {PieceValidator | PuzzleValidator | NullValidator} Validator\n **/\n\n/**\n * @callback ValidationListener\n * @param {Puzzle} puzzle\n */\n\n\nclass AbstractValidator {\n\n constructor() {\n /** @type {ValidationListener[]} */\n this.validListeners = [];\n this._valid = false;\n }\n\n /**\n * Validates the puzzle, firing validation events\n *\n * @param {Puzzle} puzzle\n */\n validate(puzzle) {\n const wasValid = this._valid;\n // @ts-ignore\n this._valid = this.isValid(puzzle);\n if (this._valid && !wasValid) {\n this.fireValid(puzzle);\n }\n }\n\n /**\n * @param {Puzzle} puzzle\n */\n fireValid(puzzle) {\n this.validListeners.forEach(it => it(puzzle));\n }\n\n /**\n * Registers a validation listener\n *\n * @param {ValidationListener} f\n */\n onValid(f) {\n this.validListeners.push(f);\n }\n\n /**\n * Answers the current validity status of this validator. This\n * property neither alters the current status nor triggers new validity checks\n *\n * @returns {boolean}\n */\n get valid() {\n return this._valid;\n }\n\n /**\n * Answers wether this is the {@link NullValidator}\n *\n * @returns {boolean}\n */\n get isNull() {\n return false;\n }\n}\n\n/**\n * @callback PieceCondition\n * @param {Piece} puzzle\n * @returns {boolean}\n */\n\n\n/**\n * @callback PuzzleCondition\n * @param {Puzzle} puzzle\n * @returns {boolean}\n */\n\n/** A validator that evaluates each piece independently */\nclass PieceValidator extends AbstractValidator {\n\n /**\n * @param {PieceCondition} f\n */\n constructor(f) {\n super();\n this.condition = f;\n }\n\n /**\n * @param {Puzzle} puzzle\n * @returns {boolean}\n */\n isValid(puzzle) {\n return puzzle.pieces.every(it => this.condition(it));\n }\n}\n\nclass PuzzleValidator extends AbstractValidator {\n\n /**\n * @param {PuzzleCondition} f\n */\n constructor(f) {\n super();\n this.condition = f;\n }\n\n /**\n * @param {Puzzle} puzzle\n */\n isValid(puzzle) {\n return this.condition(puzzle);\n }\n}\n\n/**\n* @type {PuzzleCondition}\n*/\nPuzzleValidator.connected = (puzzle) => puzzle.connected;\n\n/**\n * @param {import('./pair').Pair[]} expected the expected relative refs\n * @returns {PuzzleCondition}\n */\nPuzzleValidator.relativeRefs = (expected) => {\n return (puzzle) => {\n function diff(x, y, index) {\n const [x2, y2] = expected[index];\n return Pair.diff(x, y, x2 * puzzle.pieceWidth, y2 * puzzle.pieceWidth);\n }\n const points = puzzle.points;\n const [x0, y0] = points[0];\n const [dx, dy] = diff(x0, y0, 0);\n return points.every(([x, y], index) => Pair.equal(dx, dy, ...diff(x, y, index)))\n };\n};\n\nconst NullValidator = {\n /**\n * @param {Puzzle} puzzle\n */\n isValid(puzzle) {\n return false;\n },\n\n /**\n * @param {Puzzle} puzzle\n */\n validate(puzzle) {},\n\n /**\n * @param {ValidationListener} f\n */\n onValid(f) {},\n\n /**\n * @returns {boolean}\n */\n get valid() {\n return false;\n },\n\n /**\n * Answers wether this is the {@link NullValidator}\n *\n * @returns {boolean}\n */\n get isNull() {\n return true;\n }\n};\n\n\nmodule.exports = {\n PuzzleValidator,\n PieceValidator,\n NullValidator\n}\n","const Pair = require('./pair');\nconst Piece = require('./piece');\nconst Puzzle = require('./puzzle');\nconst Manufacturer = require('../src/manufacturer');\nconst {twoAndTwo} = require('./sequence');\nconst Structure = require('./structure');\nconst imageLike = require('./image-metadata');\nconst {position, ...Position} = require('./position');\nconst Metadata = require('./metadata');\nconst SpatialMetadata = require('./spatial-metadata');\nconst {PuzzleValidator, PieceValidator} = require('./validator');\n\n/**\n * @typedef {object} Shape\n * @typedef {object} Group\n * @typedef {object} Label\n */\n\n/**\n * @typedef {object} Figure\n * @property {Shape} shape\n * @property {Group} group\n * @property {Label} [label]\n */\n\n/**\n * @callback CanvasConnectionListener\n * @param {Piece} piece the connecting piece\n * @param {Figure} figure the visual representation of the connecting piece\n * @param {Piece} targetPiece the target connected piece\n * @param {Figure} targetFigure the visual representation of the target connected\n */\n\n/**\n * @callback CanvasTranslationListener\n * @param {Piece} piece the translated piece\n * @param {Figure} figure the visual representation of the translated piece\n * @param {number} dx the horizontal displacement\n * @param {number} dy the vertical displacement\n*/\n\n/**\n * @typedef {object} LabelMetadata\n * @property {string} [text]\n * @property {number} [fontSize]\n * @property {number} [x]\n * @property {number} [y]\n */\n\n/**\n * @typedef {object} CanvasMetadata\n * @property {string} [id]\n * @property {import('./position').Position} [targetPosition]\n * @property {import('./position').Position} [currentPosition]\n * @property {string} [color]\n * @property {string} [strokeColor]\n * @property {import('./image-metadata').ImageLike} [image]\n * @property {LabelMetadata} [label]\n */\n\n/**\n * @typedef {object} Template\n * @property {import('./structure').StructureLike} structure\n * @property {CanvasMetadata} metadata\n */\n\n /**\n * An HTML graphical area where puzzles and pieces can be rendered. No assumption of the rendering backend is done - it may be\n * and be a plain HTML SVG or canvas element, or a higher-level library - and this task is fully delegated to {@link Painter}\n */\nclass Canvas {\n\n /**\n * @private\n * @typedef {import('./painter')} Painter\n */\n\n /**\n * @param {string} id the html id of the element where to place the canvas\n * @param {object} options\n * @param {number} options.width\n * @param {number} options.height\n * @param {number} [options.pieceSize]\n * @param {number} [options.proximity]\n * @param {number} [options.borderFill] the broder fill of the pieces, expresed in pixels. 0 means no border fill, 0.5 * pieceSize means full fill\n * @param {number} [options.strokeWidth]\n * @param {string} [options.strokeColor]\n * @param {number} [options.lineSoftness] how soft the line will be\n * @param {import('./image-metadata').ImageLike} [options.image] an optional background image for the puzzle that will be split across all pieces.\n * @param {Painter} [options.painter] the Painter object used to actually draw figures in canvas\n */\n constructor(id, {\n width,\n height,\n pieceSize = 50,\n proximity = 10,\n borderFill = 0,\n strokeWidth = 3,\n strokeColor = 'black',\n lineSoftness = 0,\n image = null,\n painter = null }) {\n this.width = width;\n this.height = height;\n this.pieceSize = pieceSize;\n this.borderFill = borderFill;\n this.imageMetadata = imageLike.asImageMetadata(image);\n this.strokeWidth = strokeWidth;\n this.strokeColor = strokeColor;\n this.lineSoftness = lineSoftness;\n this.proximity = proximity;\n /** @type {Painter} */\n this._painter = painter || new window['headbreaker']['painters']['Konva']();\n this._initialize();\n this._painter.initialize(this, id);\n }\n\n _initialize() {\n /** @type {Puzzle} */\n this._puzzle = null;\n /** @type {Object<string, Figure>} */\n this.figures = {};\n /** @type {Object<string, Template>} */\n this.templates = {};\n }\n\n /**\n * Creates and renders a piece using a template, that is ready to be rendered by calling {@link Canvas#draw}\n *\n * @param {Template} options\n */\n sketchPiece({structure, metadata}) {\n SpatialMetadata.initialize(metadata, Position.origin())\n this.renderPiece(this._newPiece(structure, metadata));\n }\n\n /**\n * Renders a previously created piece object\n *\n * @param {Piece} piece\n */\n renderPiece(piece) {\n /** @type {Figure} */\n const figure = {label: null, group: null, shape: null};\n this.figures[piece.metadata.id] = figure;\n\n this._painter.sketch(this, piece, figure);\n\n /** @type {LabelMetadata} */\n const label = piece.metadata.label;\n if (label && label.text) {\n label.fontSize = label.fontSize || this.pieceSize * 0.55;\n label.y = label.y || (this.pieceSize - label.fontSize) / 2;\n this._painter.label(this, piece, figure);\n }\n\n this._bindGroupToPiece(figure.group, piece);\n this._bindPieceToGroup(piece, figure.group);\n }\n\n /**\n * Renders many previously created piece objects\n *\n * @param {Piece[]} pieces\n */\n renderPieces(pieces) {\n pieces.forEach((it) => {\n this._annotatePiecePosition(it);\n this.renderPiece(it);\n });\n }\n\n /**\n * Renders a previously created puzzle object. This method\n * overrides this canvas' {@link Canvas#pieceSize} and {@link Canvas#proximity}\n *\n * @param {Puzzle} puzzle\n */\n renderPuzzle(puzzle) {\n this.pieceSize = puzzle.pieceWidth;\n this.proximity = puzzle.proximity * 2;\n this._puzzle = puzzle;\n this.renderPieces(puzzle.pieces);\n }\n\n /**\n * Automatically creates and renders pieces given some configuration paramters\n *\n * @param {object} options\n * @param {number} [options.horizontalPiecesCount]\n * @param {number} [options.verticalPiecesCount]\n * @param {import('./sequence').InsertsGenerator} [options.insertsGenerator]\n * @param {CanvasMetadata[]} [options.metadata] optional list of metadata that will be attached to each generated piece\n */\n autogenerate({horizontalPiecesCount = 5, verticalPiecesCount = 5, insertsGenerator = twoAndTwo, metadata = []} = {}) {\n const manufacturer = new Manufacturer();\n manufacturer.withDimmensions(horizontalPiecesCount, verticalPiecesCount);\n manufacturer.withInsertsGenerator(insertsGenerator);\n manufacturer.withMetadata(metadata);\n this.autogenerateWithManufacturer(manufacturer);\n }\n\n /**\n * @param {Manufacturer} manufacturer\n */\n autogenerateWithManufacturer(manufacturer) {\n manufacturer.withStructure(this.settings);\n this._puzzle = manufacturer.build();\n this.renderPieces(this.puzzle.pieces);\n }\n\n /**\n * Creates a name piece template, that can be later instantiated using {@link Canvas#sketchPieceUsingTemplate}\n *\n * @param {string} name\n * @param {Template} template\n */\n defineTemplate(name, template) {\n this.templates[name] = template;\n }\n\n /**\n * Creates a new Piece with given id using a named template\n * defined with {@link Canvas#defineTemplate}\n *\n * @param {string} id\n * @param {string} templateName\n */\n sketchPieceUsingTemplate(id, templateName) {\n const options = this.templates[templateName];\n if (!options) {\n throw new Error(`Unknown template ${id}`);\n }\n const metadata = Metadata.copy(options.metadata);\n metadata.id = id;\n this.sketchPiece({structure: options.structure, metadata: metadata})\n }\n\n /**\n * @param {number} farness from 0 to 1, how far pieces will be placed from x = pieceSize, y = pieceSize\n */\n shuffle(farness = 1) {\n const offset = this.pieceSize;\n this.puzzle.shuffle(farness * (this.width - offset), farness * (this.height - offset))\n this.puzzle.translate(offset, offset);\n this.autoconnected = true;\n }\n\n solve() {\n this.puzzle.pieces.forEach(it => {\n const {x, y} = it.metadata.targetPosition;\n it.relocateTo(x, y);\n });\n this.autoconnect();\n }\n\n autoconnect() {\n this.puzzle.autoconnect();\n this.autoconnected = true;\n }\n\n /**\n * Draws this canvas for the first time\n */\n draw() {\n if (!this.autoconnected) {\n this.autoconnect();\n }\n this.autoconnected = false;\n this.redraw();\n }\n\n /**\n * Re-draws this canvas. This method is useful when the canvas {@link Figure}s have\n * being modified and you need changes to become visible\n */\n redraw() {\n this._painter.draw(this);\n }\n\n /**\n * Clears the canvas, clearing the rendering backend and discarding all the created templates, figures, and pieces\n */\n clear() {\n this._initialize();\n this._painter.reinitialize(this);\n }\n\n /**\n * Sets a validator for the canvas' puzzle. Only one validator\n * can be attached, so subsequent calls of this method will override the previously\n * attached validator\n *\n * @param {import('./validator').Validator} validator\n */\n attachValidator(validator) {\n this.puzzle.attachValidator(validator);\n }\n\n /**\n * Sets a validator that will report when puzzle has been solved,\n * overriding any previously configured validator\n */\n attachSolvedValidator() {\n this.puzzle.attachValidator(new PuzzleValidator(SpatialMetadata.solved));\n }\n\n /**\n * Sets a validator that will report when puzzle pieces are in their expected relative\n * positions, overriding any previously configured validator\n */\n attachRelativePositionValidator() {\n this.puzzle.attachValidator(new PuzzleValidator(SpatialMetadata.relativePosition));\n }\n\n /**\n * Sets a validator that will report when puzzle pieces are in their expected absolute\n * positions, overriding any previously configured validator\n */\n attachAbsolutePositionValidator() {\n this.puzzle.attachValidator(new PieceValidator(SpatialMetadata.absolutePosition));\n }\n\n /**\n * Registers a listener for connect events\n *\n * @param {CanvasConnectionListener} f\n */\n onConnect(f) {\n this.puzzle.onConnect((piece, target) => {\n f(piece, this.getFigure(piece), target, this.getFigure(target));\n });\n }\n\n /**\n * Registers a listener for disconnect events\n *\n * @param {CanvasConnectionListener} f\n */\n onDisconnect(f) {\n this.puzzle.onDisconnect((piece, target) => {\n f(piece, this.getFigure(piece), target, this.getFigure(target));\n });\n }\n\n /**\n * @param {CanvasTranslationListener} f\n */\n onTranslate(f) {\n this.puzzle.onTranslate((piece, dx, dy) => {\n f(piece, this.getFigure(piece), dx, dy);\n });\n }\n\n /**\n * @param {import('./validator').ValidationListener} f\n */\n onValid(f) {\n this.puzzle.onValid(f);\n }\n\n /**\n * Answers the visual representation for the given piece.\n * This method uses piece's id.\n *\n * @param {Piece} piece\n * @returns {Figure}\n */\n getFigure(piece) {\n return this.getFigureById(piece.metadata.id);\n }\n\n /**\n * Answers the visual representation for the given piece id.\n *\n * @param {string} id\n * @returns {Figure}\n */\n getFigureById(id) {\n return this.figures[id];\n }\n\n /**\n * @param {Piece} piece\n */\n _annotatePiecePosition(piece) {\n const p = piece.centralAnchor.asPosition();\n SpatialMetadata.initialize(piece.metadata, p, Position.copy(p));\n }\n\n /**\n * Configures updates from piece into group\n * @param {Group} group\n * @param {Piece} piece\n */\n _bindGroupToPiece(group, piece) {\n piece.onTranslate((_dx, _dy) => {\n this._painter.physicalTranslate(this, group, piece);\n this._painter.logicalTranslate(this, piece, group);\n });\n }\n\n /**\n * * Configures updates from group into piece\n * @param {Piece} piece\n * @param {Group} group\n */\n _bindPieceToGroup(piece, group) {\n this._painter.onDrag(this, piece, group, (dx, dy) => {\n if (!Pair.isNull(dx, dy)) {\n piece.drag(dx, dy, true);\n this._painter.logicalTranslate(this, piece, group);\n this.redraw();\n }\n });\n this._painter.onDragEnd(this, piece, group, () => {\n piece.drop();\n this.puzzle.validate();\n this.redraw();\n })\n }\n\n /**\n * @param {Piece} model\n * @returns {import('./image-metadata').ImageMetadata}\n */\n _imageMetadataFor(model) {\n if (this.imageMetadata) {\n return {\n content: this.imageMetadata.content,\n offset: model.metadata.targetPosition || this.imageMetadata.offset,\n scale: model.metadata.scale || this.imageMetadata.scale\n };\n } else {\n return imageLike.asImageMetadata(model.metadata.image);\n }\n }\n\n _initializeEmptyPuzzle() {\n this._puzzle = new Puzzle(this.settings);\n }\n\n /**\n * @param {import('./structure').StructureLike} structureLike\n * @param {CanvasMetadata} metadata\n */\n _newPiece(structureLike, metadata) {\n let piece = this.puzzle.newPiece(Structure.asStructure(structureLike));\n piece.annotate(metadata);\n piece.locateAt(metadata.currentPosition.x, metadata.currentPosition.y);\n return piece;\n }\n\n /**\n * The puzzle rendered by this canvas\n *\n * @returns {Puzzle}\n */\n get puzzle() {\n if (!this._puzzle) {\n this._initializeEmptyPuzzle();\n }\n return this._puzzle;\n }\n\n /**\n * @returns {import('./puzzle').Settings}\n */\n get settings() {\n return {pieceSize: this.pieceSize / 2, proximity: this.proximity}\n }\n}\n\nmodule.exports = Canvas\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar Util_1 = require(\"./Util\");\nexports.DD = {\n get isDragging() {\n var flag = false;\n exports.DD._dragElements.forEach(function (elem) {\n if (elem.dragStatus === 'dragging') {\n flag = true;\n }\n });\n return flag;\n },\n justDragged: false,\n get node() {\n var node;\n exports.DD._dragElements.forEach(function (elem) {\n node = elem.node;\n });\n return node;\n },\n _dragElements: new Map(),\n _drag: function (evt) {\n exports.DD._dragElements.forEach(function (elem, key) {\n var node = elem.node;\n var stage = node.getStage();\n stage.setPointersPositions(evt);\n if (elem.pointerId === undefined) {\n elem.pointerId = Util_1.Util._getFirstPointerId(evt);\n }\n var pos = stage._changedPointerPositions.find(function (pos) { return pos.id === elem.pointerId; });\n if (!pos) {\n return;\n }\n if (elem.dragStatus !== 'dragging') {\n var dragDistance = node.dragDistance();\n var distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));\n if (distance < dragDistance) {\n return;\n }\n node.startDrag({ evt: evt });\n if (!node.isDragging()) {\n return;\n }\n }\n node._setDragPosition(evt, elem);\n node.fire('dragmove', {\n type: 'dragmove',\n target: node,\n evt: evt\n }, true);\n });\n },\n _endDragBefore: function (evt) {\n exports.DD._dragElements.forEach(function (elem, key) {\n var node = elem.node;\n var stage = node.getStage();\n if (evt) {\n stage.setPointersPositions(evt);\n }\n var pos = stage._changedPointerPositions.find(function (pos) { return pos.id === elem.pointerId; });\n if (!pos) {\n return;\n }\n if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {\n exports.DD.justDragged = true;\n Global_1.Konva.listenClickTap = false;\n elem.dragStatus = 'stopped';\n }\n var drawNode = elem.node.getLayer() ||\n (elem.node instanceof Global_1.Konva['Stage'] && elem.node);\n if (drawNode) {\n drawNode.draw();\n }\n });\n },\n _endDragAfter: function (evt) {\n exports.DD._dragElements.forEach(function (elem, key) {\n if (elem.dragStatus === 'stopped') {\n elem.node.fire('dragend', {\n type: 'dragend',\n target: elem.node,\n evt: evt\n }, true);\n }\n if (elem.dragStatus !== 'dragging') {\n exports.DD._dragElements.delete(key);\n }\n });\n }\n};\nif (Global_1.Konva.isBrowser) {\n window.addEventListener('mouseup', exports.DD._endDragBefore, true);\n window.addEventListener('touchend', exports.DD._endDragBefore, true);\n window.addEventListener('mousemove', exports.DD._drag);\n window.addEventListener('touchmove', exports.DD._drag);\n window.addEventListener('mouseup', exports.DD._endDragAfter, false);\n window.addEventListener('touchend', exports.DD._endDragAfter, false);\n}\n","/**\n * @template A\n * @typedef {Object} Orthogonal\n * @property {A} up\n * @property {A} down\n * @property {A} left\n * @property {A} right\n */\n\n/**\n * @template A\n * @template B\n *\n * @callback Mapper\n * @param {A} value\n * @returns {B}\n */\n\n/**\n * Misc generic functions\n *\n * @module Prelude\n */\n\n/**\n * @template T\n * @param {T} one\n * @param {T} other\n * @param {boolean} [back]\n * @returns {[T, T]}\n */\nfunction pivot(one, other, back = false) {\n return back ? [one, other] : [other, one];\n}\n\n/**\n * @template A\n * @template B\n *\n * @param {A[]} values\n * @param {Mapper<A, B>} mapper\n * @param {A} replacement\n * @returns {B[]}\n */\nfunction orthogonalMap(values, mapper, replacement = null) {\n return values.map(it => {\n const value = it || replacement;\n return value && mapper(value)\n });\n}\n\n/**\n * @template A\n * @template B\n * @param {A[]} values\n * @param {Mapper<A, B>} mapper\n * @param {A} replacement\n * @returns {Orthogonal<B>}\n */\nfunction orthogonalTransform(values, mapper, replacement = null) {\n const [right, down, left, up] = orthogonalMap(values, mapper, replacement)\n return {right, down, left, up};\n}\n\n/**\n * @template A\n * @param {A} arg\n * @returns {A}\n */\nfunction itself(arg) {\n return arg;\n}\n\nmodule.exports = {\n pivot,\n itself,\n orthogonalMap,\n orthogonalTransform\n};\n","const {Slot, Tab, None} = require('./insert');\nconst {orthogonalMap} = require('./prelude');\n\n/**\n * @typedef {object} Structure\n * @property {import('./insert').Insert} [up]\n * @property {import('./insert').Insert} [left]\n * @property {import('./insert').Insert} [down]\n * @property {import('./insert').Insert} [right]\n */\n\n/**\n * @module Structure\n */\n\n/**\n * @private\n * @param {string} insert\n * @returns {import('./insert').Insert}\n */\nfunction parseInsert(insert) {\n return insert === 'S' ? Slot : insert === 'T' ? Tab : None;\n}\n\n/**\n *\n * @param {Structure} structure\n * @returns {string}\n */\nfunction serialize(structure) {\n return orthogonalMap([structure.right, structure.down, structure.left, structure.up], it => it.serialize(), None).join('');\n}\n\n/**\n *\n * @param {string} string\n * @returns {Structure}\n */\nfunction deserialize(string) {\n\n if (string.length !== 4) {\n throw new Error(\"structure string must be 4-chars long\");\n }\n\n return {\n right: parseInsert(string[0]),\n down: parseInsert(string[1]),\n left: parseInsert(string[2]),\n up: parseInsert(string[3]),\n };\n}\n\n/**\n * @typedef {Structure|string} StructureLike\n */\n\n/**\n * @param {StructureLike} structureLike\n * @returns {Structure}\n */\nfunction asStructure(structureLike) {\n if (typeof(structureLike) === 'string') {\n return deserialize(structureLike);\n }\n return structureLike;\n}\n\nmodule.exports = {\n serialize,\n deserialize,\n asStructure\n};\n\n\n","const {Tab, Slot, None} = require('./insert');\n\n/**\n * A function for generating {@link Insert}s sequentially\n *\n * @callback InsertsGenerator\n * @param {number} index the position of the element to be generated in the sequence\n * @returns {import('./insert').Insert}\n */\n\n/**\n * This module exports several {@link Insert}s sequences strategies: {@link fixed}, {@link flipflop}, {@link twoAndTwo} and {@link random}\n *\n * @module sequence\n */\n\n/**\n * @type {InsertsGenerator}\n */\nfunction fixed(_n) {\n return Tab;\n}\n\n/**\n * Generates slots and tabs alternately\n *\n * @type {InsertsGenerator}\n */\nfunction flipflop(n) {\n return n % 2 === 0 ? Tab : Slot;\n}\n\n/**\n * Generates sequences of two slots and then two tabs\n *\n * @type {InsertsGenerator}\n */\nfunction twoAndTwo(n) {\n return n % 4 < 2 ? Tab : Slot;\n}\n\n/**\n * Generates tabs and slots in a psuedo-random way\n *\n * @type {InsertsGenerator}\n */\nfunction random(_) {\n return Math.random() < 0.5 ? Tab : Slot;\n}\n\n/**\n * An InsertSequence is a statefull object that\n * allows to generate {@link Insert}s sequences using an {@link InsertsGenerator} as strategy\n */\nclass InsertSequence {\n /**\n * @param {InsertsGenerator} generator the generator used by this sequence to produce inserts\n */\n constructor(generator) {\n this.generator = generator;\n this.n = 0\n this._previous;\n this._current = None;\n }\n\n /**\n * The previously generated insert\n *\n * @returns {import('./insert').Insert}\n */\n previousComplement() {\n return this._previous.complement();\n }\n\n /**\n * Answers the last Insert generated by {@link InsertSequence#next}\n *\n * @returns {import('./insert').Insert}\n */\n current(max) {\n if (this.n == max) {\n return None\n }\n return this._current;\n }\n\n /**\n * @returns {import('./insert').Insert}\n **/\n next() {\n this._previous = this._current;\n this._current = this.generator(this.n++);\n return this._current;\n }\n}\n\nmodule.exports = {\n InsertSequence,\n fixed,\n flipflop,\n twoAndTwo,\n random\n}\n","/**\n * This module exposes metadata-handling functions you can override to have better performance\n *\n * @module Metadata\n */\n\n/**\n * Copies a metadata object. The default implementation uses {@link JSON#parse}. Override it to have better performance\n *\n * @template T\n * @param {T} metadata\n * @returns {T}\n */\nfunction copy(metadata) {\n return JSON.parse(JSON.stringify(metadata));\n}\n\nmodule.exports = {\n copy\n}\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Container_1 = require(\"./Container\");\nvar Global_1 = require(\"./Global\");\nvar Group = (function (_super) {\n __extends(Group, _super);\n function Group() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Group.prototype._validateAdd = function (child) {\n var type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util_1.Util.throw('You may only add groups and shapes to groups.');\n }\n };\n return Group;\n}(Container_1.Container));\nexports.Group = Group;\nGroup.prototype.nodeType = 'Group';\nGlobal_1._registerNode(Group);\nUtil_1.Collection.mapMethods(Group);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar now = (function () {\n if (Global_1.glob.performance && Global_1.glob.performance.now) {\n return function () {\n return Global_1.glob.performance.now();\n };\n }\n return function () {\n return new Date().getTime();\n };\n})();\nvar Animation = (function () {\n function Animation(func, layers) {\n this.id = Animation.animIdCounter++;\n this.frame = {\n time: 0,\n timeDiff: 0,\n lastTime: now(),\n frameRate: 0\n };\n this.func = func;\n this.setLayers(layers);\n }\n Animation.prototype.setLayers = function (layers) {\n var lays = [];\n if (!layers) {\n lays = [];\n }\n else if (layers.length > 0) {\n lays = layers;\n }\n else {\n lays = [layers];\n }\n this.layers = lays;\n return this;\n };\n Animation.prototype.getLayers = function () {\n return this.layers;\n };\n Animation.prototype.addLayer = function (layer) {\n var layers = this.layers, len = layers.length, n;\n for (n = 0; n < len; n++) {\n if (layers[n]._id === layer._id) {\n return false;\n }\n }\n this.layers.push(layer);\n return true;\n };\n Animation.prototype.isRunning = function () {\n var a = Animation, animations = a.animations, len = animations.length, n;\n for (n = 0; n < len; n++) {\n if (animations[n].id === this.id) {\n return true;\n }\n }\n return false;\n };\n Animation.prototype.start = function () {\n this.stop();\n this.frame.timeDiff = 0;\n this.frame.lastTime = now();\n Animation._addAnimation(this);\n return this;\n };\n Animation.prototype.stop = function () {\n Animation._removeAnimation(this);\n return this;\n };\n Animation.prototype._updateFrameObject = function (time) {\n this.frame.timeDiff = time - this.frame.lastTime;\n this.frame.lastTime = time;\n this.frame.time += this.frame.timeDiff;\n this.frame.frameRate = 1000 / this.frame.timeDiff;\n };\n Animation._addAnimation = function (anim) {\n this.animations.push(anim);\n this._handleAnimation();\n };\n Animation._removeAnimation = function (anim) {\n var id = anim.id, animations = this.animations, len = animations.length, n;\n for (n = 0; n < len; n++) {\n if (animations[n].id === id) {\n this.animations.splice(n, 1);\n break;\n }\n }\n };\n Animation._runFrames = function () {\n var layerHash = {}, animations = this.animations, anim, layers, func, n, i, layersLen, layer, key, needRedraw;\n for (n = 0; n < animations.length; n++) {\n anim = animations[n];\n layers = anim.layers;\n func = anim.func;\n anim._updateFrameObject(now());\n layersLen = layers.length;\n if (func) {\n needRedraw = func.call(anim, anim.frame) !== false;\n }\n else {\n needRedraw = true;\n }\n if (!needRedraw) {\n continue;\n }\n for (i = 0; i < layersLen; i++) {\n layer = layers[i];\n if (layer._id !== undefined) {\n layerHash[layer._id] = layer;\n }\n }\n }\n for (key in layerHash) {\n if (!layerHash.hasOwnProperty(key)) {\n continue;\n }\n layerHash[key].draw();\n }\n };\n Animation._animationLoop = function () {\n var Anim = Animation;\n if (Anim.animations.length) {\n Anim._runFrames();\n requestAnimationFrame(Anim._animationLoop);\n }\n else {\n Anim.animRunning = false;\n }\n };\n Animation._handleAnimation = function () {\n if (!this.animRunning) {\n this.animRunning = true;\n requestAnimationFrame(this._animationLoop);\n }\n };\n Animation.animations = [];\n Animation.animIdCounter = 0;\n Animation.animRunning = false;\n return Animation;\n}());\nexports.Animation = Animation;\n","const Piece = require('./piece');\n\n/**\n * This module contains the draw function. Override it change pieces drawing strategy\n *\n * @module Outline\n */\n\n/**\n * @param {import('./insert').Insert} insert\n * @param {number} t\n * @param {number} s\n * @param {number} n\n */\nfunction select(insert, t, s, n) {\n return insert.isTab() ? t : insert.isSlot() ? s : n;\n}\n\n/**\n *\n * @param {Piece} piece\n * @param {number} [size]\n * @returns {number[]}\n */\nfunction draw(piece, size = 50, borderFill = 0) {\n const offset = borderFill * 5 / size;\n return [\n (0 - offset), (0 - offset),\n 1, (0 - offset),\n 2, select(piece.up, (-1 - offset), (1 - offset), (0 - offset)),\n 3, (0 - offset),\n (4 + offset), (0 - offset),\n (4 + offset), 1,\n select(piece.right, (5 + offset), (3 + offset), (4 + offset)), 2,\n (4 + offset), 3,\n (4 + offset), (4 + offset),\n 3, (4 + offset),\n 2, select(piece.down, (5 + offset), (3 + offset), (4 + offset)),\n 1, (4 + offset),\n (0 - offset), (4 + offset),\n (0 - offset), 3,\n select(piece.left, (-1 - offset), (1 - offset), (0 - offset)), 2,\n (0 - offset), 1\n ].map(it => it * size / 5)\n}\n\n\nmodule.exports = {\n draw\n}\n","const Puzzle = require('./puzzle');\nconst Piece = require('./piece');\nconst {Anchor} = require('./anchor');\nconst {anchor} = require('./anchor');\nconst {fixed, InsertSequence} = require('./sequence')\nconst Metadata = require('./metadata');\n\n/**\n * A manufacturer allows to create rectangular\n * puzzles by automatically generating inserts\n */\nclass Manufacturer {\n constructor() {\n this.insertsGenerator = fixed;\n this.metadata = [];\n /** @type {Anchor} */\n this.headAnchor = null;\n }\n\n /**\n * Attach metadata to each piece\n *\n * @param {object[]} metadata list of metadata that will be attached to each generated piece\n */\n withMetadata(metadata) {\n this.metadata = metadata;\n }\n\n /**\n * @param {import('./sequence').InsertsGenerator} generator\n */\n withInsertsGenerator(generator) {\n this.insertsGenerator = generator || this.insertsGenerator;\n }\n\n /**\n * Sets the central anchor. If not specified, puzzle will be positioned\n * at the distance of a whole piece from the origin\n *\n * @param {Anchor} anchor\n */\n withHeadAt(anchor) {\n this.headAnchor = anchor;\n }\n\n /**\n * If nothing is configured, default Puzzle structured is assumed\n *\n * @param {import('../src/puzzle').Settings} structure\n */\n withStructure(structure) {\n this.structure = structure\n }\n\n /**\n *\n * @param {number} width\n * @param {number} height\n */\n withDimmensions(width, height) {\n this.width = width;\n this.height = height;\n }\n\n /**\n * @returns {Puzzle}\n */\n build() {\n const puzzle = new Puzzle(this.structure);\n const positioner = new Positioner(puzzle, this.headAnchor);\n\n let verticalSequence = this._newSequence();\n let horizontalSequence;\n\n for (let y = 0; y < this.height; y++) {\n horizontalSequence = this._newSequence();\n verticalSequence.next();\n\n for (let x = 0; x < this.width; x++) {\n horizontalSequence.next();\n const piece = this._buildPiece(puzzle, horizontalSequence, verticalSequence);\n piece.centerAround(positioner.naturalAnchor(x, y));\n }\n }\n this._annotateAll(puzzle.pieces);\n return puzzle;\n }\n\n /**\n * @param {Piece[]} pieces\n */\n _annotateAll(pieces) {\n pieces.forEach((piece, index) => this._annotate(piece, index));\n }\n\n /**\n * @param {Piece} piece\n * @param {number} index\n */\n _annotate(piece, index) {\n const baseMetadata = this.metadata[index];\n const metadata = baseMetadata ? Metadata.copy(baseMetadata) : {};\n metadata.id = metadata.id || String(index + 1);\n piece.annotate(metadata);\n }\n\n _newSequence() {\n return new InsertSequence(this.insertsGenerator);\n }\n\n /**\n * @param {Puzzle} puzzle\n * @param {InsertSequence} horizontalSequence\n * @param {InsertSequence} verticalSequence\n */\n _buildPiece(puzzle, horizontalSequence, verticalSequence) {\n return puzzle.newPiece({\n left: horizontalSequence.previousComplement(),\n up: verticalSequence.previousComplement(),\n right: horizontalSequence.current(this.width),\n down: verticalSequence.current(this.height)\n });\n }\n}\n\nclass Positioner {\n /**\n *\n * @param {Puzzle} puzzle\n * @param {Anchor} headAnchor\n */\n constructor(puzzle, headAnchor) {\n this.puzzle = puzzle;\n this.initializeOffset(headAnchor);\n }\n\n initializeOffset(headAnchor) {\n if (headAnchor) {\n this.xOffset = headAnchor.x;\n this.yOffset = headAnchor.y;\n }\n else {\n this.xOffset = this.pieceWidth;\n this.yOffset = this.pieceWidth;\n }\n }\n\n get pieceWidth() {\n return this.puzzle.pieceWidth;\n }\n\n /**\n * @param {number} x\n * @param {number} y\n */\n naturalAnchor(x, y) {\n return anchor(\n x * this.pieceWidth + this.xOffset,\n y * this.pieceWidth + this.yOffset);\n }\n}\n\nmodule.exports = Manufacturer;\n","const Position = require('./position');\nconst Pair = require('./pair');\nconst {PuzzleValidator} = require('./validator');\n\n/**\n * @typedef {object} SpatialMetadata\n * @property {import('./position').Position} [targetPosition]\n * @property {import('./position').Position} [currentPosition]\n */\n\n/**\n * Functions for handling spatial metadata\n * and pieces and puzzles that are annotated with it\n *\n * @module SpatialMetadata\n */\n\nfunction diffToTarget(piece) {\n return Position.diff(piece.metadata.targetPosition, piece.centralAnchor.asPosition());\n}\n\n/**\n * @type {import('../src/validator').PuzzleCondition}\n */\nconst solved = (puzzle) => relativePosition(puzzle) && PuzzleValidator.connected(puzzle);\n\n/**\n * @type {import('../src/validator').PuzzleCondition}\n */\nconst relativePosition = (puzzle) => {\n const [dx, dy] = diffToTarget(puzzle.head);\n return puzzle.pieces.every(piece => {\n return Pair.equal(dx, dy, ...diffToTarget(piece))\n });\n}\n\n/**\n *@type {import('../src/validator').PieceCondition}\n */\nconst absolutePosition = (piece) => Position.equal(piece.centralAnchor.asPosition(), piece.metadata.targetPosition);\n\n\n/**\n * @param {SpatialMetadata} metadata\n * @param {import('./position').Position} target\n * @param {import('./position').Position} [current]\n */\nfunction initialize(metadata, target, current) {\n metadata.targetPosition = metadata.targetPosition || target;\n metadata.currentPosition = metadata.currentPosition || current || Position.copy(metadata.targetPosition);\n}\n\nmodule.exports = {\n initialize,\n solved,\n relativePosition,\n absolutePosition\n}\n","const Canvas = require('./canvas');\nconst Piece = require('./piece');\n\n/**\n * @callback VectorAction\n * @param {number} dx\n * @param {number} dy\n */\n\n /**\n * @callback Action\n */\n\n/**\n * An interface for a a rendering backend for a {@link Canvas}, that can be implemented in\n * order to create UI representations of a puzzle.\n *\n * @interface Painter\n */\nclass Painter {\n\n /**\n * Creates the rendering backend, initializig all its contents.\n * After this call, painter is ready to receive any other messages\n *\n * @param {Canvas} canvas\n * @param {string} id\n */\n initialize(canvas, id) { }\n\n /**\n * Recreates the rendering backend, clearing all its contents\n * After this call, painter is ready to receive any other messages\n * as it had been just initialized.\n *\n * @param {Canvas} canvas\n */\n reinitialize(canvas) { }\n\n /**\n * Draws the canvas figures in the rendering backend\n *\n * @param {Canvas} canvas\n */\n draw(canvas) { }\n\n /**\n * Adds a piece to the rendering backend, so that it is ready to be drawn\n *\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {import('./canvas').Figure} figure the rendering backend information for this piece. This method may mutate it if necessary\n */\n sketch(canvas, piece, figure) { }\n\n /**\n * Adds piece's label to the given figure in the rendering backend\n *\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {import('./canvas').Figure} figure the rendering backend information for this piece. This method may mutate it if necessary\n */\n label(canvas, piece, figure) { }\n\n /**\n * Translates th given piece\n * @param {Canvas} canvas\n * @param {import('./canvas').Group} group\n * @param {Piece} piece\n */\n physicalTranslate(canvas, group, piece) { }\n\n /**\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {import('./canvas').Group} group\n */\n logicalTranslate(canvas, piece, group) { }\n\n /**\n * Registers a drag-start callback\n *\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {import('./canvas').Group} group\n * @param {VectorAction} f\n *\n */\n onDrag(canvas, piece, group, f) { }\n\n /**\n * Registers a drag-end callback\n *\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {import('./canvas').Group} group\n * @param {Action} f\n */\n onDragEnd(canvas, piece, group, f) { }\n}\n\nmodule.exports = Painter;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Global_1 = require(\"./Global\");\nvar COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [\n 'arc',\n 'arcTo',\n 'beginPath',\n 'bezierCurveTo',\n 'clearRect',\n 'clip',\n 'closePath',\n 'createLinearGradient',\n 'createPattern',\n 'createRadialGradient',\n 'drawImage',\n 'ellipse',\n 'fill',\n 'fillText',\n 'getImageData',\n 'createImageData',\n 'lineTo',\n 'moveTo',\n 'putImageData',\n 'quadraticCurveTo',\n 'rect',\n 'restore',\n 'rotate',\n 'save',\n 'scale',\n 'setLineDash',\n 'setTransform',\n 'stroke',\n 'strokeText',\n 'transform',\n 'translate'\n];\nvar CONTEXT_PROPERTIES = [\n 'fillStyle',\n 'strokeStyle',\n 'shadowColor',\n 'shadowBlur',\n 'shadowOffsetX',\n 'shadowOffsetY',\n 'lineCap',\n 'lineDashOffset',\n 'lineJoin',\n 'lineWidth',\n 'miterLimit',\n 'font',\n 'textAlign',\n 'textBaseline',\n 'globalAlpha',\n 'globalCompositeOperation',\n 'imageSmoothingEnabled'\n];\nvar traceArrMax = 100;\nvar Context = (function () {\n function Context(canvas) {\n this.canvas = canvas;\n this._context = canvas._canvas.getContext('2d');\n if (Global_1.Konva.enableTrace) {\n this.traceArr = [];\n this._enableTrace();\n }\n }\n Context.prototype.fillShape = function (shape) {\n if (shape.fillEnabled()) {\n this._fill(shape);\n }\n };\n Context.prototype._fill = function (shape) {\n };\n Context.prototype.strokeShape = function (shape) {\n if (shape.hasStroke()) {\n this._stroke(shape);\n }\n };\n Context.prototype._stroke = function (shape) {\n };\n Context.prototype.fillStrokeShape = function (shape) {\n this.fillShape(shape);\n this.strokeShape(shape);\n };\n Context.prototype.getTrace = function (relaxed) {\n var traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;\n for (n = 0; n < len; n++) {\n trace = traceArr[n];\n method = trace.method;\n if (method) {\n args = trace.args;\n str += method;\n if (relaxed) {\n str += DOUBLE_PAREN;\n }\n else {\n if (Util_1.Util._isArray(args[0])) {\n str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;\n }\n else {\n str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;\n }\n }\n }\n else {\n str += trace.property;\n if (!relaxed) {\n str += EQUALS + trace.val;\n }\n }\n str += SEMICOLON;\n }\n return str;\n };\n Context.prototype.clearTrace = function () {\n this.traceArr = [];\n };\n Context.prototype._trace = function (str) {\n var traceArr = this.traceArr, len;\n traceArr.push(str);\n len = traceArr.length;\n if (len >= traceArrMax) {\n traceArr.shift();\n }\n };\n Context.prototype.reset = function () {\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);\n };\n Context.prototype.getCanvas = function () {\n return this.canvas;\n };\n Context.prototype.clear = function (bounds) {\n var canvas = this.getCanvas();\n if (bounds) {\n this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);\n }\n else {\n this.clearRect(0, 0, canvas.getWidth() / canvas.pixelRatio, canvas.getHeight() / canvas.pixelRatio);\n }\n };\n Context.prototype._applyLineCap = function (shape) {\n var lineCap = shape.getLineCap();\n if (lineCap) {\n this.setAttr('lineCap', lineCap);\n }\n };\n Context.prototype._applyOpacity = function (shape) {\n var absOpacity = shape.getAbsoluteOpacity();\n if (absOpacity !== 1) {\n this.setAttr('globalAlpha', absOpacity);\n }\n };\n Context.prototype._applyLineJoin = function (shape) {\n var lineJoin = shape.getLineJoin();\n if (lineJoin) {\n this.setAttr('lineJoin', lineJoin);\n }\n };\n Context.prototype.setAttr = function (attr, val) {\n this._context[attr] = val;\n };\n Context.prototype.arc = function (a0, a1, a2, a3, a4, a5) {\n this._context.arc(a0, a1, a2, a3, a4, a5);\n };\n Context.prototype.arcTo = function (a0, a1, a2, a3, a4) {\n this._context.arcTo(a0, a1, a2, a3, a4);\n };\n Context.prototype.beginPath = function () {\n this._context.beginPath();\n };\n Context.prototype.bezierCurveTo = function (a0, a1, a2, a3, a4, a5) {\n this._context.bezierCurveTo(a0, a1, a2, a3, a4, a5);\n };\n Context.prototype.clearRect = function (a0, a1, a2, a3) {\n this._context.clearRect(a0, a1, a2, a3);\n };\n Context.prototype.clip = function () {\n this._context.clip();\n };\n Context.prototype.closePath = function () {\n this._context.closePath();\n };\n Context.prototype.createImageData = function (a0, a1) {\n var a = arguments;\n if (a.length === 2) {\n return this._context.createImageData(a0, a1);\n }\n else if (a.length === 1) {\n return this._context.createImageData(a0);\n }\n };\n Context.prototype.createLinearGradient = function (a0, a1, a2, a3) {\n return this._context.createLinearGradient(a0, a1, a2, a3);\n };\n Context.prototype.createPattern = function (a0, a1) {\n return this._context.createPattern(a0, a1);\n };\n Context.prototype.createRadialGradient = function (a0, a1, a2, a3, a4, a5) {\n return this._context.createRadialGradient(a0, a1, a2, a3, a4, a5);\n };\n Context.prototype.drawImage = function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {\n var a = arguments, _context = this._context;\n if (a.length === 3) {\n _context.drawImage(a0, a1, a2);\n }\n else if (a.length === 5) {\n _context.drawImage(a0, a1, a2, a3, a4);\n }\n else if (a.length === 9) {\n _context.drawImage(a0, a1, a2, a3, a4, a5, a6, a7, a8);\n }\n };\n Context.prototype.ellipse = function (a0, a1, a2, a3, a4, a5, a6, a7) {\n this._context.ellipse(a0, a1, a2, a3, a4, a5, a6, a7);\n };\n Context.prototype.isPointInPath = function (x, y) {\n return this._context.isPointInPath(x, y);\n };\n Context.prototype.fill = function () {\n this._context.fill();\n };\n Context.prototype.fillRect = function (x, y, width, height) {\n this._context.fillRect(x, y, width, height);\n };\n Context.prototype.strokeRect = function (x, y, width, height) {\n this._context.strokeRect(x, y, width, height);\n };\n Context.prototype.fillText = function (a0, a1, a2) {\n this._context.fillText(a0, a1, a2);\n };\n Context.prototype.measureText = function (text) {\n return this._context.measureText(text);\n };\n Context.prototype.getImageData = function (a0, a1, a2, a3) {\n return this._context.getImageData(a0, a1, a2, a3);\n };\n Context.prototype.lineTo = function (a0, a1) {\n this._context.lineTo(a0, a1);\n };\n Context.prototype.moveTo = function (a0, a1) {\n this._context.moveTo(a0, a1);\n };\n Context.prototype.rect = function (a0, a1, a2, a3) {\n this._context.rect(a0, a1, a2, a3);\n };\n Context.prototype.putImageData = function (a0, a1, a2) {\n this._context.putImageData(a0, a1, a2);\n };\n Context.prototype.quadraticCurveTo = function (a0, a1, a2, a3) {\n this._context.quadraticCurveTo(a0, a1, a2, a3);\n };\n Context.prototype.restore = function () {\n this._context.restore();\n };\n Context.prototype.rotate = function (a0) {\n this._context.rotate(a0);\n };\n Context.prototype.save = function () {\n this._context.save();\n };\n Context.prototype.scale = function (a0, a1) {\n this._context.scale(a0, a1);\n };\n Context.prototype.setLineDash = function (a0) {\n if (this._context.setLineDash) {\n this._context.setLineDash(a0);\n }\n else if ('mozDash' in this._context) {\n this._context['mozDash'] = a0;\n }\n else if ('webkitLineDash' in this._context) {\n this._context['webkitLineDash'] = a0;\n }\n };\n Context.prototype.getLineDash = function () {\n return this._context.getLineDash();\n };\n Context.prototype.setTransform = function (a0, a1, a2, a3, a4, a5) {\n this._context.setTransform(a0, a1, a2, a3, a4, a5);\n };\n Context.prototype.stroke = function () {\n this._context.stroke();\n };\n Context.prototype.strokeText = function (a0, a1, a2, a3) {\n this._context.strokeText(a0, a1, a2, a3);\n };\n Context.prototype.transform = function (a0, a1, a2, a3, a4, a5) {\n this._context.transform(a0, a1, a2, a3, a4, a5);\n };\n Context.prototype.translate = function (a0, a1) {\n this._context.translate(a0, a1);\n };\n Context.prototype._enableTrace = function () {\n var that = this, len = CONTEXT_METHODS.length, _simplifyArray = Util_1.Util._simplifyArray, origSetter = this.setAttr, n, args;\n var func = function (methodName) {\n var origMethod = that[methodName], ret;\n that[methodName] = function () {\n args = _simplifyArray(Array.prototype.slice.call(arguments, 0));\n ret = origMethod.apply(that, arguments);\n that._trace({\n method: methodName,\n args: args\n });\n return ret;\n };\n };\n for (n = 0; n < len; n++) {\n func(CONTEXT_METHODS[n]);\n }\n that.setAttr = function () {\n origSetter.apply(that, arguments);\n var prop = arguments[0];\n var val = arguments[1];\n if (prop === 'shadowOffsetX' ||\n prop === 'shadowOffsetY' ||\n prop === 'shadowBlur') {\n val = val / this.canvas.getPixelRatio();\n }\n that._trace({\n property: prop,\n val: val\n });\n };\n };\n Context.prototype._applyGlobalCompositeOperation = function (node) {\n var globalCompositeOperation = node.getGlobalCompositeOperation();\n if (globalCompositeOperation !== 'source-over') {\n this.setAttr('globalCompositeOperation', globalCompositeOperation);\n }\n };\n return Context;\n}());\nexports.Context = Context;\nCONTEXT_PROPERTIES.forEach(function (prop) {\n Object.defineProperty(Context.prototype, prop, {\n get: function () {\n return this._context[prop];\n },\n set: function (val) {\n this._context[prop] = val;\n }\n });\n});\nvar SceneContext = (function (_super) {\n __extends(SceneContext, _super);\n function SceneContext() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n SceneContext.prototype._fillColor = function (shape) {\n var fill = shape.fill();\n this.setAttr('fillStyle', fill);\n shape._fillFunc(this);\n };\n SceneContext.prototype._fillPattern = function (shape) {\n var fillPatternX = shape.getFillPatternX(), fillPatternY = shape.getFillPatternY(), fillPatternRotation = Global_1.Konva.getAngle(shape.getFillPatternRotation()), fillPatternOffsetX = shape.getFillPatternOffsetX(), fillPatternOffsetY = shape.getFillPatternOffsetY(), fillPatternScaleX = shape.getFillPatternScaleX(), fillPatternScaleY = shape.getFillPatternScaleY();\n if (fillPatternX || fillPatternY) {\n this.translate(fillPatternX || 0, fillPatternY || 0);\n }\n if (fillPatternRotation) {\n this.rotate(fillPatternRotation);\n }\n if (fillPatternScaleX || fillPatternScaleY) {\n this.scale(fillPatternScaleX, fillPatternScaleY);\n }\n if (fillPatternOffsetX || fillPatternOffsetY) {\n this.translate(-1 * fillPatternOffsetX, -1 * fillPatternOffsetY);\n }\n this.setAttr('fillStyle', shape._getFillPattern());\n shape._fillFunc(this);\n };\n SceneContext.prototype._fillLinearGradient = function (shape) {\n var grd = shape._getLinearGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n };\n SceneContext.prototype._fillRadialGradient = function (shape) {\n var grd = shape._getRadialGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n };\n SceneContext.prototype._fill = function (shape) {\n var hasColor = shape.fill(), fillPriority = shape.getFillPriority();\n if (hasColor && fillPriority === 'color') {\n this._fillColor(shape);\n return;\n }\n var hasPattern = shape.getFillPatternImage();\n if (hasPattern && fillPriority === 'pattern') {\n this._fillPattern(shape);\n return;\n }\n var hasLinearGradient = shape.getFillLinearGradientColorStops();\n if (hasLinearGradient && fillPriority === 'linear-gradient') {\n this._fillLinearGradient(shape);\n return;\n }\n var hasRadialGradient = shape.getFillRadialGradientColorStops();\n if (hasRadialGradient && fillPriority === 'radial-gradient') {\n this._fillRadialGradient(shape);\n return;\n }\n if (hasColor) {\n this._fillColor(shape);\n }\n else if (hasPattern) {\n this._fillPattern(shape);\n }\n else if (hasLinearGradient) {\n this._fillLinearGradient(shape);\n }\n else if (hasRadialGradient) {\n this._fillRadialGradient(shape);\n }\n };\n SceneContext.prototype._strokeLinearGradient = function (shape) {\n var start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);\n if (colorStops) {\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n this.setAttr('strokeStyle', grd);\n }\n };\n SceneContext.prototype._stroke = function (shape) {\n var dash = shape.dash(), strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (shape.hasStroke()) {\n if (!strokeScaleEnabled) {\n this.save();\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n if (dash && shape.dashEnabled()) {\n this.setLineDash(dash);\n this.setAttr('lineDashOffset', shape.dashOffset());\n }\n this.setAttr('lineWidth', shape.strokeWidth());\n if (!shape.getShadowForStrokeEnabled()) {\n this.setAttr('shadowColor', 'rgba(0,0,0,0)');\n }\n var hasLinearGradient = shape.getStrokeLinearGradientColorStops();\n if (hasLinearGradient) {\n this._strokeLinearGradient(shape);\n }\n else {\n this.setAttr('strokeStyle', shape.stroke());\n }\n shape._strokeFunc(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n };\n SceneContext.prototype._applyShadow = function (shape) {\n var util = Util_1.Util, color = util.get(shape.getShadowRGBA(), 'black'), blur = util.get(shape.getShadowBlur(), 5), offset = util.get(shape.getShadowOffset(), {\n x: 0,\n y: 0\n }), scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;\n this.setAttr('shadowColor', color);\n this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));\n this.setAttr('shadowOffsetX', offset.x * scaleX);\n this.setAttr('shadowOffsetY', offset.y * scaleY);\n };\n return SceneContext;\n}(Context));\nexports.SceneContext = SceneContext;\nvar HitContext = (function (_super) {\n __extends(HitContext, _super);\n function HitContext() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n HitContext.prototype._fill = function (shape) {\n this.save();\n this.setAttr('fillStyle', shape.colorKey);\n shape._fillFuncHit(this);\n this.restore();\n };\n HitContext.prototype.strokeShape = function (shape) {\n if (shape.hasHitStroke()) {\n this._stroke(shape);\n }\n };\n HitContext.prototype._stroke = function (shape) {\n if (shape.hasHitStroke()) {\n var strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (!strokeScaleEnabled) {\n this.save();\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n var hitStrokeWidth = shape.hitStrokeWidth();\n var strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;\n this.setAttr('lineWidth', strokeWidth);\n this.setAttr('strokeStyle', shape.colorKey);\n shape._strokeFuncHit(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n };\n return HitContext;\n}(Context));\nexports.HitContext = HitContext;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar Captures = new Map();\nvar SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;\nfunction getCapturedShape(pointerId) {\n return Captures.get(pointerId);\n}\nexports.getCapturedShape = getCapturedShape;\nfunction createEvent(evt) {\n return {\n evt: evt,\n pointerId: evt.pointerId\n };\n}\nexports.createEvent = createEvent;\nfunction hasPointerCapture(pointerId, shape) {\n return Captures.get(pointerId) === shape;\n}\nexports.hasPointerCapture = hasPointerCapture;\nfunction setPointerCapture(pointerId, shape) {\n releaseCapture(pointerId);\n var stage = shape.getStage();\n if (!stage)\n return;\n Captures.set(pointerId, shape);\n if (SUPPORT_POINTER_EVENTS) {\n shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));\n }\n}\nexports.setPointerCapture = setPointerCapture;\nfunction releaseCapture(pointerId, target) {\n var shape = Captures.get(pointerId);\n if (!shape)\n return;\n var stage = shape.getStage();\n if (stage && stage.content) {\n }\n Captures.delete(pointerId);\n if (SUPPORT_POINTER_EVENTS) {\n shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));\n }\n}\nexports.releaseCapture = releaseCapture;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Container_1 = require(\"./Container\");\nvar Node_1 = require(\"./Node\");\nvar Factory_1 = require(\"./Factory\");\nvar Canvas_1 = require(\"./Canvas\");\nvar BaseLayer = (function (_super) {\n __extends(BaseLayer, _super);\n function BaseLayer(config) {\n var _this = _super.call(this, config) || this;\n _this.canvas = new Canvas_1.SceneCanvas();\n _this._waitingForDraw = false;\n _this.on('visibleChange', _this._checkVisibility);\n _this._checkVisibility();\n _this.on('imageSmoothingEnabledChange', _this._setSmoothEnabled);\n _this._setSmoothEnabled();\n return _this;\n }\n BaseLayer.prototype.createPNGStream = function () {\n var c = this.canvas._canvas;\n return c.createPNGStream();\n };\n BaseLayer.prototype.getCanvas = function () {\n return this.canvas;\n };\n BaseLayer.prototype.getHitCanvas = function () {\n return this.hitCanvas;\n };\n BaseLayer.prototype.getContext = function () {\n return this.getCanvas().getContext();\n };\n BaseLayer.prototype.clear = function (bounds) {\n this.getContext().clear(bounds);\n return this;\n };\n BaseLayer.prototype.setZIndex = function (index) {\n _super.prototype.setZIndex.call(this, index);\n var stage = this.getStage();\n if (stage) {\n stage.content.removeChild(this.getCanvas()._canvas);\n if (index < stage.children.length - 1) {\n stage.content.insertBefore(this.getCanvas()._canvas, stage.children[index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getCanvas()._canvas);\n }\n }\n return this;\n };\n BaseLayer.prototype.moveToTop = function () {\n Node_1.Node.prototype.moveToTop.call(this);\n var stage = this.getStage();\n if (stage) {\n stage.content.removeChild(this.getCanvas()._canvas);\n stage.content.appendChild(this.getCanvas()._canvas);\n }\n return true;\n };\n BaseLayer.prototype.moveUp = function () {\n var moved = Node_1.Node.prototype.moveUp.call(this);\n if (!moved) {\n return false;\n }\n var stage = this.getStage();\n if (!stage) {\n return false;\n }\n stage.content.removeChild(this.getCanvas()._canvas);\n if (this.index < stage.children.length - 1) {\n stage.content.insertBefore(this.getCanvas()._canvas, stage.children[this.index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getCanvas()._canvas);\n }\n return true;\n };\n BaseLayer.prototype.moveDown = function () {\n if (Node_1.Node.prototype.moveDown.call(this)) {\n var stage = this.getStage();\n if (stage) {\n var children = stage.children;\n stage.content.removeChild(this.getCanvas()._canvas);\n stage.content.insertBefore(this.getCanvas()._canvas, children[this.index + 1].getCanvas()._canvas);\n }\n return true;\n }\n return false;\n };\n BaseLayer.prototype.moveToBottom = function () {\n if (Node_1.Node.prototype.moveToBottom.call(this)) {\n var stage = this.getStage();\n if (stage) {\n var children = stage.children;\n stage.content.removeChild(this.getCanvas()._canvas);\n stage.content.insertBefore(this.getCanvas()._canvas, children[1].getCanvas()._canvas);\n }\n return true;\n }\n return false;\n };\n BaseLayer.prototype.getLayer = function () {\n return this;\n };\n BaseLayer.prototype.hitGraphEnabled = function () {\n return true;\n };\n BaseLayer.prototype.remove = function () {\n var _canvas = this.getCanvas()._canvas;\n Node_1.Node.prototype.remove.call(this);\n if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {\n _canvas.parentNode.removeChild(_canvas);\n }\n return this;\n };\n BaseLayer.prototype.getStage = function () {\n return this.parent;\n };\n BaseLayer.prototype.setSize = function (_a) {\n var width = _a.width, height = _a.height;\n this.canvas.setSize(width, height);\n this._setSmoothEnabled();\n return this;\n };\n BaseLayer.prototype._toKonvaCanvas = function (config) {\n config = config || {};\n config.width = config.width || this.getWidth();\n config.height = config.height || this.getHeight();\n config.x = config.x !== undefined ? config.x : this.x();\n config.y = config.y !== undefined ? config.y : this.y();\n return Node_1.Node.prototype._toKonvaCanvas.call(this, config);\n };\n BaseLayer.prototype._checkVisibility = function () {\n var visible = this.visible();\n if (visible) {\n this.canvas._canvas.style.display = 'block';\n }\n else {\n this.canvas._canvas.style.display = 'none';\n }\n };\n BaseLayer.prototype._setSmoothEnabled = function () {\n this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();\n };\n BaseLayer.prototype.getWidth = function () {\n if (this.parent) {\n return this.parent.width();\n }\n };\n BaseLayer.prototype.setWidth = function () {\n Util_1.Util.warn('Can not change width of layer. Use \"stage.width(value)\" function instead.');\n };\n BaseLayer.prototype.getHeight = function () {\n if (this.parent) {\n return this.parent.height();\n }\n };\n BaseLayer.prototype.setHeight = function () {\n Util_1.Util.warn('Can not change height of layer. Use \"stage.height(value)\" function instead.');\n };\n BaseLayer.prototype.getIntersection = function (pos, selector) {\n return null;\n };\n BaseLayer.prototype.batchDraw = function () {\n var _this = this;\n if (!this._waitingForDraw) {\n this._waitingForDraw = true;\n Util_1.Util.requestAnimFrame(function () {\n _this.draw();\n _this._waitingForDraw = false;\n });\n }\n return this;\n };\n BaseLayer.prototype._applyTransform = function (shape, context, top) {\n var m = shape.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n };\n return BaseLayer;\n}(Container_1.Container));\nexports.BaseLayer = BaseLayer;\nBaseLayer.prototype.nodeType = 'BaseLayer';\nFactory_1.Factory.addGetterSetter(BaseLayer, 'imageSmoothingEnabled', true);\nFactory_1.Factory.addGetterSetter(BaseLayer, 'clearBeforeDraw', true);\nUtil_1.Collection.mapMethods(BaseLayer);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Line = (function (_super) {\n __extends(Line, _super);\n function Line(config) {\n var _this = _super.call(this, config) || this;\n _this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {\n this._clearCache('tensionPoints');\n });\n return _this;\n }\n Line.prototype._sceneFunc = function (context) {\n var points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;\n if (!length) {\n return;\n }\n context.beginPath();\n context.moveTo(points[0], points[1]);\n if (tension !== 0 && length > 4) {\n tp = this.getTensionPoints();\n len = tp.length;\n n = closed ? 0 : 4;\n if (!closed) {\n context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);\n }\n while (n < len - 2) {\n context.bezierCurveTo(tp[n++], tp[n++], tp[n++], tp[n++], tp[n++], tp[n++]);\n }\n if (!closed) {\n context.quadraticCurveTo(tp[len - 2], tp[len - 1], points[length - 2], points[length - 1]);\n }\n }\n else if (bezier) {\n n = 2;\n while (n < length) {\n context.bezierCurveTo(points[n++], points[n++], points[n++], points[n++], points[n++], points[n++]);\n }\n }\n else {\n for (n = 2; n < length; n += 2) {\n context.lineTo(points[n], points[n + 1]);\n }\n }\n if (closed) {\n context.closePath();\n context.fillStrokeShape(this);\n }\n else {\n context.strokeShape(this);\n }\n };\n Line.prototype.getTensionPoints = function () {\n return this._getCache('tensionPoints', this._getTensionPoints);\n };\n Line.prototype._getTensionPoints = function () {\n if (this.closed()) {\n return this._getTensionPointsClosed();\n }\n else {\n return Util_1.Util._expandPoints(this.points(), this.tension());\n }\n };\n Line.prototype._getTensionPointsClosed = function () {\n var p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = Util_1.Util._getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = Util_1.Util._getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = Util_1.Util._expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]\n .concat(middle)\n .concat([\n lastControlPoints[0],\n lastControlPoints[1],\n p[len - 2],\n p[len - 1],\n lastControlPoints[2],\n lastControlPoints[3],\n firstControlPoints[0],\n firstControlPoints[1],\n p[0],\n p[1]\n ]);\n return tp;\n };\n Line.prototype.getWidth = function () {\n return this.getSelfRect().width;\n };\n Line.prototype.getHeight = function () {\n return this.getSelfRect().height;\n };\n Line.prototype.getSelfRect = function () {\n var points = this.points();\n if (points.length < 4) {\n return {\n x: points[0] || 0,\n y: points[1] || 0,\n width: 0,\n height: 0\n };\n }\n if (this.tension() !== 0) {\n points = __spreadArrays([\n points[0],\n points[1]\n ], this._getTensionPoints(), [\n points[points.length - 2],\n points[points.length - 1]\n ]);\n }\n else {\n points = this.points();\n }\n var minX = points[0];\n var maxX = points[0];\n var minY = points[1];\n var maxY = points[1];\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY\n };\n };\n return Line;\n}(Shape_1.Shape));\nexports.Line = Line;\nLine.prototype.className = 'Line';\nLine.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];\nGlobal_1._registerNode(Line);\nFactory_1.Factory.addGetterSetter(Line, 'closed', false);\nFactory_1.Factory.addGetterSetter(Line, 'bezier', false);\nFactory_1.Factory.addGetterSetter(Line, 'tension', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Line, 'points', [], Validators_1.getNumberArrayValidator());\nUtil_1.Collection.mapMethods(Line);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Global_1 = require(\"../Global\");\nvar Path = (function (_super) {\n __extends(Path, _super);\n function Path(config) {\n var _this = _super.call(this, config) || this;\n _this.dataArray = [];\n _this.pathLength = 0;\n _this.dataArray = Path.parsePathData(_this.data());\n _this.pathLength = 0;\n for (var i = 0; i < _this.dataArray.length; ++i) {\n _this.pathLength += _this.dataArray[i].pathLength;\n }\n _this.on('dataChange.konva', function () {\n this.dataArray = Path.parsePathData(this.data());\n this.pathLength = 0;\n for (var i = 0; i < this.dataArray.length; ++i) {\n this.pathLength += this.dataArray[i].pathLength;\n }\n });\n return _this;\n }\n Path.prototype._sceneFunc = function (context) {\n var ca = this.dataArray;\n context.beginPath();\n var isClosed = false;\n for (var n = 0; n < ca.length; n++) {\n var c = ca[n].command;\n var p = ca[n].points;\n switch (c) {\n case 'L':\n context.lineTo(p[0], p[1]);\n break;\n case 'M':\n context.moveTo(p[0], p[1]);\n break;\n case 'C':\n context.bezierCurveTo(p[0], p[1], p[2], p[3], p[4], p[5]);\n break;\n case 'Q':\n context.quadraticCurveTo(p[0], p[1], p[2], p[3]);\n break;\n case 'A':\n var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];\n var r = rx > ry ? rx : ry;\n var scaleX = rx > ry ? 1 : rx / ry;\n var scaleY = rx > ry ? ry / rx : 1;\n context.translate(cx, cy);\n context.rotate(psi);\n context.scale(scaleX, scaleY);\n context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);\n context.scale(1 / scaleX, 1 / scaleY);\n context.rotate(-psi);\n context.translate(-cx, -cy);\n break;\n case 'z':\n isClosed = true;\n context.closePath();\n break;\n }\n }\n if (!isClosed && !this.hasFill()) {\n context.strokeShape(this);\n }\n else {\n context.fillStrokeShape(this);\n }\n };\n Path.prototype.getSelfRect = function () {\n var points = [];\n this.dataArray.forEach(function (data) {\n if (data.command === 'A') {\n var start = data.points[4];\n var dTheta = data.points[5];\n var end = data.points[4] + dTheta;\n var inc = Math.PI / 180.0;\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n if (dTheta < 0) {\n for (var t = start - inc; t > end; t -= inc) {\n var point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);\n points.push(point.x, point.y);\n }\n }\n else {\n for (var t = start + inc; t < end; t += inc) {\n var point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);\n points.push(point.x, point.y);\n }\n }\n }\n else if (data.command === 'C') {\n for (var t = 0.0; t <= 1; t += 0.01) {\n var point = Path.getPointOnCubicBezier(t, data.start.x, data.start.y, data.points[0], data.points[1], data.points[2], data.points[3], data.points[4], data.points[5]);\n points.push(point.x, point.y);\n }\n }\n else {\n points = points.concat(data.points);\n }\n });\n var minX = points[0];\n var maxX = points[0];\n var minY = points[1];\n var maxY = points[1];\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n if (!isNaN(x)) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n }\n if (!isNaN(y)) {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n }\n return {\n x: Math.round(minX),\n y: Math.round(minY),\n width: Math.round(maxX - minX),\n height: Math.round(maxY - minY)\n };\n };\n Path.prototype.getLength = function () {\n return this.pathLength;\n };\n Path.prototype.getPointAtLength = function (length) {\n var point, i = 0, ii = this.dataArray.length;\n if (!ii) {\n return null;\n }\n while (i < ii && length > this.dataArray[i].pathLength) {\n length -= this.dataArray[i].pathLength;\n ++i;\n }\n if (i === ii) {\n point = this.dataArray[i - 1].points.slice(-2);\n return {\n x: point[0],\n y: point[1]\n };\n }\n if (length < 0.01) {\n point = this.dataArray[i].points.slice(0, 2);\n return {\n x: point[0],\n y: point[1]\n };\n }\n var cp = this.dataArray[i];\n var p = cp.points;\n switch (cp.command) {\n case 'L':\n return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);\n case 'C':\n return Path.getPointOnCubicBezier(length / cp.pathLength, cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);\n case 'Q':\n return Path.getPointOnQuadraticBezier(length / cp.pathLength, cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);\n case 'A':\n var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6];\n theta += (dTheta * length) / cp.pathLength;\n return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);\n }\n return null;\n };\n Path.getLineLength = function (x1, y1, x2, y2) {\n return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n };\n Path.getPointOnLine = function (dist, P1x, P1y, P2x, P2y, fromX, fromY) {\n if (fromX === undefined) {\n fromX = P1x;\n }\n if (fromY === undefined) {\n fromY = P1y;\n }\n var m = (P2y - P1y) / (P2x - P1x + 0.00000001);\n var run = Math.sqrt((dist * dist) / (1 + m * m));\n if (P2x < P1x) {\n run *= -1;\n }\n var rise = m * run;\n var pt;\n if (P2x === P1x) {\n pt = {\n x: fromX,\n y: fromY + rise\n };\n }\n else if ((fromY - P1y) / (fromX - P1x + 0.00000001) === m) {\n pt = {\n x: fromX + run,\n y: fromY + rise\n };\n }\n else {\n var ix, iy;\n var len = this.getLineLength(P1x, P1y, P2x, P2y);\n if (len < 0.00000001) {\n return undefined;\n }\n var u = (fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y);\n u = u / (len * len);\n ix = P1x + u * (P2x - P1x);\n iy = P1y + u * (P2y - P1y);\n var pRise = this.getLineLength(fromX, fromY, ix, iy);\n var pRun = Math.sqrt(dist * dist - pRise * pRise);\n run = Math.sqrt((pRun * pRun) / (1 + m * m));\n if (P2x < P1x) {\n run *= -1;\n }\n rise = m * run;\n pt = {\n x: ix + run,\n y: iy + rise\n };\n }\n return pt;\n };\n Path.getPointOnCubicBezier = function (pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {\n function CB1(t) {\n return t * t * t;\n }\n function CB2(t) {\n return 3 * t * t * (1 - t);\n }\n function CB3(t) {\n return 3 * t * (1 - t) * (1 - t);\n }\n function CB4(t) {\n return (1 - t) * (1 - t) * (1 - t);\n }\n var x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);\n var y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);\n return {\n x: x,\n y: y\n };\n };\n Path.getPointOnQuadraticBezier = function (pct, P1x, P1y, P2x, P2y, P3x, P3y) {\n function QB1(t) {\n return t * t;\n }\n function QB2(t) {\n return 2 * t * (1 - t);\n }\n function QB3(t) {\n return (1 - t) * (1 - t);\n }\n var x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);\n var y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);\n return {\n x: x,\n y: y\n };\n };\n Path.getPointOnEllipticalArc = function (cx, cy, rx, ry, theta, psi) {\n var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);\n var pt = {\n x: rx * Math.cos(theta),\n y: ry * Math.sin(theta)\n };\n return {\n x: cx + (pt.x * cosPsi - pt.y * sinPsi),\n y: cy + (pt.x * sinPsi + pt.y * cosPsi)\n };\n };\n Path.parsePathData = function (data) {\n if (!data) {\n return [];\n }\n var cs = data;\n var cc = [\n 'm',\n 'M',\n 'l',\n 'L',\n 'v',\n 'V',\n 'h',\n 'H',\n 'z',\n 'Z',\n 'c',\n 'C',\n 'q',\n 'Q',\n 't',\n 'T',\n 's',\n 'S',\n 'a',\n 'A'\n ];\n cs = cs.replace(new RegExp(' ', 'g'), ',');\n for (var n = 0; n < cc.length; n++) {\n cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);\n }\n var arr = cs.split('|');\n var ca = [];\n var coords = [];\n var cpx = 0;\n var cpy = 0;\n var re = /([-+]?((\\d+\\.\\d+)|((\\d+)|(\\.\\d+)))(?:e[-+]?\\d+)?)/gi;\n var match;\n for (n = 1; n < arr.length; n++) {\n var str = arr[n];\n var c = str.charAt(0);\n str = str.slice(1);\n coords.length = 0;\n while ((match = re.exec(str))) {\n coords.push(match[0]);\n }\n var p = [];\n for (var j = 0, jlen = coords.length; j < jlen; j++) {\n var parsed = parseFloat(coords[j]);\n if (!isNaN(parsed)) {\n p.push(parsed);\n }\n else {\n p.push(0);\n }\n }\n while (p.length > 0) {\n if (isNaN(p[0])) {\n break;\n }\n var cmd = null;\n var points = [];\n var startX = cpx, startY = cpy;\n var prevCmd, ctlPtx, ctlPty;\n var rx, ry, psi, fa, fs, x1, y1;\n switch (c) {\n case 'l':\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'L':\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'm':\n var dx = p.shift();\n var dy = p.shift();\n cpx += dx;\n cpy += dy;\n cmd = 'M';\n if (ca.length > 2 && ca[ca.length - 1].command === 'z') {\n for (var idx = ca.length - 2; idx >= 0; idx--) {\n if (ca[idx].command === 'M') {\n cpx = ca[idx].points[0] + dx;\n cpy = ca[idx].points[1] + dy;\n break;\n }\n }\n }\n points.push(cpx, cpy);\n c = 'l';\n break;\n case 'M':\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'M';\n points.push(cpx, cpy);\n c = 'L';\n break;\n case 'h':\n cpx += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'H':\n cpx = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'v':\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'V':\n cpy = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'C':\n points.push(p.shift(), p.shift(), p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'c':\n points.push(cpx + p.shift(), cpy + p.shift(), cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'S':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 's':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'Q':\n points.push(p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'q':\n points.push(cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(cpx, cpy);\n break;\n case 'T':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 't':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 'A':\n rx = p.shift();\n ry = p.shift();\n psi = p.shift();\n fa = p.shift();\n fs = p.shift();\n x1 = cpx;\n y1 = cpy;\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'A';\n points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);\n break;\n case 'a':\n rx = p.shift();\n ry = p.shift();\n psi = p.shift();\n fa = p.shift();\n fs = p.shift();\n x1 = cpx;\n y1 = cpy;\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'A';\n points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);\n break;\n }\n ca.push({\n command: cmd || c,\n points: points,\n start: {\n x: startX,\n y: startY\n },\n pathLength: this.calcLength(startX, startY, cmd || c, points)\n });\n }\n if (c === 'z' || c === 'Z') {\n ca.push({\n command: 'z',\n points: [],\n start: undefined,\n pathLength: 0\n });\n }\n }\n return ca;\n };\n Path.calcLength = function (x, y, cmd, points) {\n var len, p1, p2, t;\n var path = Path;\n switch (cmd) {\n case 'L':\n return path.getLineLength(x, y, points[0], points[1]);\n case 'C':\n len = 0.0;\n p1 = path.getPointOnCubicBezier(0, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);\n for (t = 0.01; t <= 1; t += 0.01) {\n p2 = path.getPointOnCubicBezier(t, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n return len;\n case 'Q':\n len = 0.0;\n p1 = path.getPointOnQuadraticBezier(0, x, y, points[0], points[1], points[2], points[3]);\n for (t = 0.01; t <= 1; t += 0.01) {\n p2 = path.getPointOnQuadraticBezier(t, x, y, points[0], points[1], points[2], points[3]);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n return len;\n case 'A':\n len = 0.0;\n var start = points[4];\n var dTheta = points[5];\n var end = points[4] + dTheta;\n var inc = Math.PI / 180.0;\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n p1 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], start, 0);\n if (dTheta < 0) {\n for (t = start - inc; t > end; t -= inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n else {\n for (t = start + inc; t < end; t += inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], end, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n return len;\n }\n return 0;\n };\n Path.convertEndpointToCenterParameterization = function (x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {\n var psi = psiDeg * (Math.PI / 180.0);\n var xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;\n var yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +\n (Math.cos(psi) * (y1 - y2)) / 2.0;\n var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /\n (rx * rx * (yp * yp) + ry * ry * (xp * xp)));\n if (fa === fs) {\n f *= -1;\n }\n if (isNaN(f)) {\n f = 0;\n }\n var cxp = (f * rx * yp) / ry;\n var cyp = (f * -ry * xp) / rx;\n var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;\n var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;\n var vMag = function (v) {\n return Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n };\n var vRatio = function (u, v) {\n return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));\n };\n var vAngle = function (u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));\n };\n var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);\n var u = [(xp - cxp) / rx, (yp - cyp) / ry];\n var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];\n var dTheta = vAngle(u, v);\n if (vRatio(u, v) <= -1) {\n dTheta = Math.PI;\n }\n if (vRatio(u, v) >= 1) {\n dTheta = 0;\n }\n if (fs === 0 && dTheta > 0) {\n dTheta = dTheta - 2 * Math.PI;\n }\n if (fs === 1 && dTheta < 0) {\n dTheta = dTheta + 2 * Math.PI;\n }\n return [cx, cy, rx, ry, theta, dTheta, psi, fs];\n };\n return Path;\n}(Shape_1.Shape));\nexports.Path = Path;\nPath.prototype.className = 'Path';\nPath.prototype._attrsAffectingSize = ['data'];\nGlobal_1._registerNode(Path);\nFactory_1.Factory.addGetterSetter(Path, 'data');\nUtil_1.Collection.mapMethods(Path);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Global_1 = require(\"../Global\");\nvar Rect = (function (_super) {\n __extends(Rect, _super);\n function Rect() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Rect.prototype._sceneFunc = function (context) {\n var cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();\n context.beginPath();\n if (!cornerRadius) {\n context.rect(0, 0, width, height);\n }\n else {\n var topLeft = 0;\n var topRight = 0;\n var bottomLeft = 0;\n var bottomRight = 0;\n if (typeof cornerRadius === 'number') {\n topLeft = topRight = bottomLeft = bottomRight = Math.min(cornerRadius, width / 2, height / 2);\n }\n else {\n topLeft = Math.min(cornerRadius[0], width / 2, height / 2);\n topRight = Math.min(cornerRadius[1], width / 2, height / 2);\n bottomRight = Math.min(cornerRadius[2], width / 2, height / 2);\n bottomLeft = Math.min(cornerRadius[3], width / 2, height / 2);\n }\n context.moveTo(topLeft, 0);\n context.lineTo(width - topRight, 0);\n context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);\n context.lineTo(width, height - bottomRight);\n context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);\n context.lineTo(bottomLeft, height);\n context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);\n context.lineTo(0, topLeft);\n context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);\n }\n context.closePath();\n context.fillStrokeShape(this);\n };\n return Rect;\n}(Shape_1.Shape));\nexports.Rect = Rect;\nRect.prototype.className = 'Rect';\nGlobal_1._registerNode(Rect);\nFactory_1.Factory.addGetterSetter(Rect, 'cornerRadius', 0);\nUtil_1.Collection.mapMethods(Rect);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Global_1 = require(\"../Global\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_2 = require(\"../Global\");\nvar AUTO = 'auto', CENTER = 'center', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'padding',\n 'align',\n 'verticalAlign',\n 'lineHeight',\n 'text',\n 'width',\n 'height',\n 'wrap',\n 'ellipsis',\n 'letterSpacing'\n], attrChangeListLen = ATTR_CHANGE_LIST.length;\nvar dummyContext;\nfunction getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util_1.Util.createCanvasElement().getContext(CONTEXT_2D);\n return dummyContext;\n}\nfunction _fillFunc(context) {\n context.fillText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction _strokeFunc(context) {\n context.strokeText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction checkDefaultFill(config) {\n config = config || {};\n if (!config.fillLinearGradientColorStops &&\n !config.fillRadialGradientColorStops &&\n !config.fillPatternImage) {\n config.fill = config.fill || 'black';\n }\n return config;\n}\nvar trimRight = String.prototype.trimRight ||\n function polyfill() {\n return this.replace(/[\\s\\xa0]+$/, '');\n };\nvar Text = (function (_super) {\n __extends(Text, _super);\n function Text(config) {\n var _this = _super.call(this, checkDefaultFill(config)) || this;\n _this._partialTextX = 0;\n _this._partialTextY = 0;\n for (var n = 0; n < attrChangeListLen; n++) {\n _this.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, _this._setTextData);\n }\n _this._setTextData();\n return _this;\n }\n Text.prototype._sceneFunc = function (context) {\n var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, textArr = this.textArr, textArrLen = textArr.length, verticalAlign = this.verticalAlign(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;\n var translateY = 0;\n var translateY = lineHeightPx / 2;\n var lineTranslateX = 0;\n var lineTranslateY = 0;\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', MIDDLE);\n context.setAttr('textAlign', LEFT);\n if (verticalAlign === MIDDLE) {\n alignY = (this.getHeight() - textArrLen * lineHeightPx - padding * 2) / 2;\n }\n else if (verticalAlign === BOTTOM) {\n alignY = this.getHeight() - textArrLen * lineHeightPx - padding * 2;\n }\n context.translate(padding, alignY + padding);\n for (n = 0; n < textArrLen; n++) {\n var lineTranslateX = 0;\n var lineTranslateY = 0;\n var obj = textArr[n], text = obj.text, width = obj.width, lastLine = n !== textArrLen - 1, spacesNumber, oneWord, lineWidth;\n context.save();\n if (align === RIGHT) {\n lineTranslateX += totalWidth - width - padding * 2;\n }\n else if (align === CENTER) {\n lineTranslateX += (totalWidth - width - padding * 2) / 2;\n }\n if (shouldUnderline) {\n context.save();\n context.beginPath();\n context.moveTo(lineTranslateX, translateY + lineTranslateY + Math.round(fontSize / 2));\n spacesNumber = text.split(' ').length - 1;\n oneWord = spacesNumber === 0;\n lineWidth =\n align === JUSTIFY && lastLine && !oneWord\n ? totalWidth - padding * 2\n : width;\n context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + Math.round(fontSize / 2));\n context.lineWidth = fontSize / 15;\n context.strokeStyle = fill;\n context.stroke();\n context.restore();\n }\n if (shouldLineThrough) {\n context.save();\n context.beginPath();\n context.moveTo(lineTranslateX, translateY + lineTranslateY);\n spacesNumber = text.split(' ').length - 1;\n oneWord = spacesNumber === 0;\n lineWidth =\n align === JUSTIFY && lastLine && !oneWord\n ? totalWidth - padding * 2\n : width;\n context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY);\n context.lineWidth = fontSize / 15;\n context.strokeStyle = fill;\n context.stroke();\n context.restore();\n }\n if (letterSpacing !== 0 || align === JUSTIFY) {\n spacesNumber = text.split(' ').length - 1;\n for (var li = 0; li < text.length; li++) {\n var letter = text[li];\n if (letter === ' ' && n !== textArrLen - 1 && align === JUSTIFY) {\n lineTranslateX += Math.floor((totalWidth - padding * 2 - width) / spacesNumber);\n }\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = letter;\n context.fillStrokeShape(this);\n lineTranslateX +=\n Math.round(this.measureSize(letter).width) + letterSpacing;\n }\n }\n else {\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = text;\n context.fillStrokeShape(this);\n }\n context.restore();\n if (textArrLen > 1) {\n translateY += lineHeightPx;\n }\n }\n };\n Text.prototype._hitFunc = function (context) {\n var width = this.getWidth(), height = this.getHeight();\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Text.prototype.setText = function (text) {\n var str = Util_1.Util._isString(text)\n ? text\n : text === null || text === undefined\n ? ''\n : text + '';\n this._setAttr(TEXT, str);\n return this;\n };\n Text.prototype.getWidth = function () {\n var isAuto = this.attrs.width === AUTO || this.attrs.width === undefined;\n return isAuto ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;\n };\n Text.prototype.getHeight = function () {\n var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;\n return isAuto\n ? this.fontSize() * this.textArr.length * this.lineHeight() +\n this.padding() * 2\n : this.attrs.height;\n };\n Text.prototype.getTextWidth = function () {\n return this.textWidth;\n };\n Text.prototype.getTextHeight = function () {\n Util_1.Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n };\n Text.prototype.measureSize = function (text) {\n var _context = getDummyContext(), fontSize = this.fontSize(), metrics;\n _context.save();\n _context.font = this._getContextFont();\n metrics = _context.measureText(text);\n _context.restore();\n return {\n width: metrics.width,\n height: fontSize\n };\n };\n Text.prototype._getContextFont = function () {\n if (Global_1.Konva.UA.isIE) {\n return (this.fontStyle() +\n SPACE +\n this.fontSize() +\n PX_SPACE +\n this.fontFamily());\n }\n return (this.fontStyle() +\n SPACE +\n this.fontVariant() +\n SPACE +\n this.fontSize() +\n PX_SPACE +\n this.fontFamily());\n };\n Text.prototype._addTextLine = function (line) {\n if (this.align() === JUSTIFY) {\n line = line.trim();\n }\n var width = this._getTextWidth(line);\n return this.textArr.push({ text: line, width: width });\n };\n Text.prototype._getTextWidth = function (text) {\n var letterSpacing = this.letterSpacing();\n var length = text.length;\n return (getDummyContext().measureText(text).width +\n (length ? letterSpacing * (length - 1) : 0));\n };\n Text.prototype._setTextData = function () {\n var lines = this.text().split('\\n'), fontSize = +this.fontSize(), textWidth = 0, lineHeightPx = this.lineHeight() * fontSize, width = this.attrs.width, height = this.attrs.height, fixedWidth = width !== AUTO && width !== undefined, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxWidth = width - padding * 2, maxHeightPx = height - padding * 2, currentHeightPx = 0, wrap = this.wrap(), shouldWrap = wrap !== NONE, wrapAtWord = wrap !== CHAR && shouldWrap, shouldAddEllipsis = this.ellipsis() && !shouldWrap;\n this.textArr = [];\n getDummyContext().font = this._getContextFont();\n var additionalWidth = shouldAddEllipsis ? this._getTextWidth(ELLIPSIS) : 0;\n for (var i = 0, max = lines.length; i < max; ++i) {\n var line = lines[i];\n var lineWidth = this._getTextWidth(line);\n if (fixedWidth && lineWidth > maxWidth) {\n while (line.length > 0) {\n var low = 0, high = line.length, match = '', matchWidth = 0;\n while (low < high) {\n var mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;\n if (substrWidth <= maxWidth) {\n low = mid + 1;\n match = substr + (shouldAddEllipsis ? ELLIPSIS : '');\n matchWidth = substrWidth;\n }\n else {\n high = mid;\n }\n }\n if (match) {\n if (wrapAtWord) {\n var wrapIndex;\n var nextChar = line[match.length];\n var nextIsSpaceOrDash = nextChar === SPACE || nextChar === DASH;\n if (nextIsSpaceOrDash && matchWidth <= maxWidth) {\n wrapIndex = match.length;\n }\n else {\n wrapIndex =\n Math.max(match.lastIndexOf(SPACE), match.lastIndexOf(DASH)) +\n 1;\n }\n if (wrapIndex > 0) {\n low = wrapIndex;\n match = match.slice(0, low);\n matchWidth = this._getTextWidth(match);\n }\n }\n match = match.trimRight();\n this._addTextLine(match);\n textWidth = Math.max(textWidth, matchWidth);\n currentHeightPx += lineHeightPx;\n if (!shouldWrap ||\n (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx)) {\n break;\n }\n line = line.slice(low);\n line = line.trimLeft();\n if (line.length > 0) {\n lineWidth = this._getTextWidth(line);\n if (lineWidth <= maxWidth) {\n this._addTextLine(line);\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, lineWidth);\n break;\n }\n }\n }\n else {\n break;\n }\n }\n }\n else {\n this._addTextLine(line);\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, lineWidth);\n }\n if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {\n break;\n }\n }\n this.textHeight = fontSize;\n this.textWidth = textWidth;\n };\n Text.prototype.getStrokeScaleEnabled = function () {\n return true;\n };\n return Text;\n}(Shape_1.Shape));\nexports.Text = Text;\nText.prototype._fillFunc = _fillFunc;\nText.prototype._strokeFunc = _strokeFunc;\nText.prototype.className = TEXT_UPPER;\nText.prototype._attrsAffectingSize = [\n 'text',\n 'fontSize',\n 'padding',\n 'wrap',\n 'lineHeight'\n];\nGlobal_2._registerNode(Text);\nFactory_1.Factory.overWriteSetter(Text, 'width', Validators_1.getNumberOrAutoValidator());\nFactory_1.Factory.overWriteSetter(Text, 'height', Validators_1.getNumberOrAutoValidator());\nFactory_1.Factory.addGetterSetter(Text, 'fontFamily', 'Arial');\nFactory_1.Factory.addGetterSetter(Text, 'fontSize', 12, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Text, 'fontStyle', NORMAL);\nFactory_1.Factory.addGetterSetter(Text, 'fontVariant', NORMAL);\nFactory_1.Factory.addGetterSetter(Text, 'padding', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Text, 'align', LEFT);\nFactory_1.Factory.addGetterSetter(Text, 'verticalAlign', TOP);\nFactory_1.Factory.addGetterSetter(Text, 'lineHeight', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Text, 'wrap', WORD);\nFactory_1.Factory.addGetterSetter(Text, 'ellipsis', false);\nFactory_1.Factory.addGetterSetter(Text, 'letterSpacing', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Text, 'text', '', Validators_1.getStringValidator());\nFactory_1.Factory.addGetterSetter(Text, 'textDecoration', '');\nUtil_1.Collection.mapMethods(Text);\n","const Pair = require('./pair')\nconst {anchor, Anchor} = require('./anchor')\nconst Puzzle = require('./puzzle');\nconst Piece = require('./piece');\nconst {Tab, Slot, None} = require('./insert');\nconst {NullValidator, PieceValidator, PuzzleValidator} = require('./validator');\nconst Structure = require('./structure');\nconst Outline = require('./outline');\nconst Canvas = require('./canvas');\nconst Manufacturer = require('./manufacturer');\nconst {InsertSequence, ...generators} = require('./sequence');\nconst Metadata = require('./metadata');\nconst SpatialMetadata = require('./spatial-metadata');\nconst {position, ...Position} = require('./position');\n\n/**\n * @module headbreaker\n * @exports headbreaker~anchor\n */\nmodule.exports = {\n\n\n anchor,\n\n\n position,\n\n Anchor,\n\n\n Puzzle,\n\n\n Piece,\n\n\n Canvas,\n\n\n Manufacturer,\n\n\n InsertSequence,\n\n\n PieceValidator,\n\n\n PuzzleValidator,\n\n\n NullValidator,\n\n\n Tab,\n\n\n Slot,\n\n\n None,\n\n\n Pair,\n\n\n Metadata,\n\n\n SpatialMetadata,\n\n\n Outline,\n\n\n Structure,\n\n\n Position,\n\n\n generators,\n\n\n painters: {\n Dummy: require('./dummy-painter'),\n Konva: require('./konva-painter')\n }\n}\n","/**\n * @private\n * @module between\n * */\n\n/**\n * @param {number} value\n * @param {number} min\n * @param {number} max\n * @returns {boolean}\n */\nfunction between(value, min, max) {\n return min <= value && value <= max;\n}\n\nmodule.exports = between;\n","/**\n * @private\n * @module Connector\n */\nconst {pivot} = require('./prelude');\n\n/**\n * @private\n */\nclass Connector {\n\n /**\n * @param {\"x\" | \"y\"} axis\n * @param {\"right\" | \"down\"} forward\n * @param {\"left\" | \"up\"} backward\n */\n constructor(axis, forward, backward) {\n\n this.axis = axis;\n\n this.forward = forward;\n this.backward = backward;\n\n this.forwardAnchor = `${forward}Anchor`;\n this.backwardAnchor = `${backward}Anchor`;\n\n this.forwardConnection = `${forward}Connection`;\n this.backwardConnection = `${backward}Connection`;\n }\n\n /**\n * @param {boolean} [back]\n */\n attract(one, other, back = false) {\n const [iron, magnet] = pivot(one, other, back);\n let dx, dy;\n if (magnet.centralAnchor[this.axis] > iron.centralAnchor[this.axis]) {\n [dx, dy] = magnet[this.backwardAnchor].diff(iron[this.forwardAnchor])\n } else {\n [dx, dy] = magnet[this.forwardAnchor].diff(iron[this.backwardAnchor])\n }\n iron.push(dx, dy);\n }\n\n\n /**\n * @param {number} delta\n * @returns {boolean}\n */\n openMovement(one, delta) {\n return (delta > 0 && !one[this.forwardConnection]) || (delta < 0 && !one[this.backwardConnection]) || delta == 0;\n }\n\n /**\n * @param {number} proximity\n * @returns {boolean}\n */\n canConnectWith(one, other, proximity) {\n return this.closeTo(one, other, proximity) && this.match(one, other);\n }\n\n /**\n *\n * @param {number} proximity\n * @returns {boolean}\n */\n closeTo(one, other, proximity) {\n return one[this.forwardAnchor].closeTo(other[this.backwardAnchor], proximity);\n }\n\n /**\n * @returns {boolean}\n */\n match(one, other) {\n return one[this.forward].match(other[this.backward]);\n }\n\n /**\n * @param {import('./piece')} one\n * @param {*} other\n * @param {number} proximity\n * @param {boolean} back\n */\n connectWith(one, other, proximity, back) {\n if (!this.canConnectWith(one, other, proximity)) {\n throw new Error(`can not connect ${this.forward}!`);\n }\n if (one[this.forwardConnection] !== other) {\n this.attract(other, one, back);\n one[this.forwardConnection] = other;\n other[this.backwardConnection] = one;\n one.fireConnect(other);\n }\n }\n}\n\nmodule.exports = {\n horizontal: new Connector(\"x\", \"right\", \"left\"),\n vertical: new Connector(\"y\", \"down\", \"up\")\n};\n","const {position} = require('./position');\n\n/**\n * @typedef {object} ImageMetadata\n * @property {HTMLImageElement} content\n * @property {import('./position').Position} [offset]\n * @property {number} [scale]\n */\n\n/**\n * @typedef {HTMLImageElement|ImageMetadata} ImageLike\n */\n\n/**\n * @module ImageMetadata\n */\n\n/**\n * Converts an image-like object into a true {@link ImageMetadata} object\n *\n * @param {ImageLike} imageLike\n * @returns {ImageMetadata}\n */\nfunction asImageMetadata(imageLike) {\n if (imageLike instanceof HTMLImageElement) {\n return {\n content: imageLike,\n offset: position(1, 1),\n scale: 1\n };\n }\n return imageLike;\n}\n\nmodule.exports = {\n asImageMetadata\n}\n","const Canvas = require('./canvas');\nconst Piece = require('./piece');\nconst Painter = require('./painter');\n\n/**\n * A {@link Painter} for testing purpouses that does not perform rendering\n *\n * @implements {Painter}\n */\nclass DummyPainter extends Painter {\n /**\n * @param {Canvas} canvas\n * @param {string} id\n */\n initialize(canvas, id) {\n canvas['__nullLayer__'] = {drawn: false, figures: 0};\n }\n\n /**\n * @param {Canvas} canvas\n */\n draw(canvas) {\n canvas['__nullLayer__'].drawn = true;\n }\n\n /**\n *\n * @param {Canvas} canvas\n * @param {Piece} _piece\n * @param {import('./canvas').Figure} _figure\n */\n sketch(canvas, _piece, _figure) {\n canvas['__nullLayer__'].figures++;\n }\n}\n\nmodule.exports = DummyPainter;\n","let Konva;\ntry {\n // @ts-ignore\n Konva = require('konva');\n} catch (e) {\n Konva = {\n Stage: class {\n constructor(_options) {\n throw new Error(\"Konva not loaded\");\n }\n }\n };\n}\n\nconst Canvas = require('./canvas');\nconst Outline = require('./outline');\nconst Piece = require('./piece');\nconst Pair = require('./pair');\nconst Position = require('./position');\nconst Painter = require('./painter');\n\n\n/**\n * @private\n * @param {Piece} model\n * @param {*} group\n */\nfunction currentPositionDiff(model, group) {\n return Pair.diff(group.x(),group.y(), model.metadata.currentPosition.x, model.metadata.currentPosition.y);\n}\n\n/**\n * A {@link Painter} that uses Konva.js as rendering backend\n * @implements {Painter}\n */\nclass KonvaPainter extends Painter {\n /** @typedef {import('./canvas').Figure} Figure */\n /** @typedef {import('./canvas').Group} Group */\n\n /**\n * @param {Canvas} canvas\n * @param {string} id\n */\n initialize(canvas, id) {\n var stage = new Konva.Stage({\n container: id,\n width: canvas.width,\n height: canvas.height\n });\n\n this._initializeLayer(stage, canvas);\n }\n\n _initializeLayer(stage, canvas) {\n var layer = new Konva.Layer();\n stage.add(layer);\n canvas['__konvaLayer__'] = layer;\n }\n\n /**\n * @param {Canvas} canvas\n */\n draw(canvas) {\n canvas['__konvaLayer__'].draw();\n }\n\n /**\n * @param {Canvas} canvas\n */\n reinitialize(canvas) {\n const layer = canvas['__konvaLayer__'];\n const stage = layer.getStage();\n layer.destroy();\n\n this._initializeLayer(stage, canvas);\n }\n\n /**\n *\n * @param {Canvas} canvas\n * @param {Piece} piece\n * @param {Figure} figure\n */\n sketch(canvas, piece, figure) {\n figure.group = new Konva.Group({\n x: piece.metadata.currentPosition.x,\n y: piece.metadata.currentPosition.y\n });\n\n const image = canvas._imageMetadataFor(piece);\n figure.shape = new Konva.Line({\n points: Outline.draw(piece, canvas.pieceSize, canvas.borderFill),\n fill: !image ? piece.metadata.color || 'black' : null,\n fillPatternImage: image && image.content,\n fillPatternScale: image && {x: image.scale, y: image.scale},\n fillPatternOffset: image && image.offset,\n tension: canvas.lineSoftness,\n stroke: piece.metadata.strokeColor || canvas.strokeColor,\n strokeWidth: canvas.strokeWidth,\n closed: true,\n });\n figure.group.add(figure.shape);\n figure.group.draggable('true');\n\n canvas['__konvaLayer__'].add(figure.group);\n }\n\n /**\n *\n * @param {Canvas} _canvas\n * @param {Piece} piece\n * @param {Figure} figure\n */\n label(_canvas, piece, figure) {\n figure.label = new Konva.Text({\n x: piece.metadata.label.x || (figure.group.width() / 2),\n y: piece.metadata.label.y || (figure.group.height() / 2),\n text: piece.metadata.label.text,\n fontSize: piece.metadata.label.fontSize,\n fontFamily: piece.metadata.label.fontFamily || 'Sans Serif',\n fill: piece.metadata.label.color || 'white',\n });\n figure.group.add(figure.label);\n }\n\n /**\n *\n * @param {Canvas} _canvas\n * @param {Group} group\n * @param {Piece} piece\n */\n physicalTranslate(_canvas, group, piece) {\n group.x(piece.centralAnchor.x);\n group.y(piece.centralAnchor.y);\n }\n\n /**\n * @param {Canvas} _canvas\n * @param {Piece} piece\n * @param {*} group\n */\n logicalTranslate(_canvas, piece, group) {\n Position.update(piece.metadata.currentPosition, group.x(), group.y());\n }\n\n /**\n * @param {Canvas} _canvas\n * @param {Piece} piece\n * @param {Group} group\n * @param {import('./painter').VectorAction} f\n */\n onDrag(_canvas, piece, group, f) {\n group.on('mouseover', () => {\n document.body.style.cursor = 'pointer';\n });\n group.on('mouseout', () => {\n document.body.style.cursor = 'default';\n });\n group.on('dragmove', () => {\n let [dx, dy] = currentPositionDiff(piece, group);\n f(dx, dy);\n });\n }\n\n /**\n * @param {Canvas} _canvas\n * @param {Piece} _piece\n * @param {Group} group\n * @param {import('./painter').Action} f\n */\n onDragEnd(_canvas, _piece, group, f) {\n group.on('dragend', () => {\n f()\n });\n }\n}\n\nmodule.exports = KonvaPainter;\n","var Konva = require('./_FullInternals').Konva;\nKonva._injectGlobal(Konva);\nexports['default'] = Konva;\nmodule.exports = exports['default'];\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar _CoreInternals_1 = require(\"./_CoreInternals\");\nvar Arc_1 = require(\"./shapes/Arc\");\nvar Arrow_1 = require(\"./shapes/Arrow\");\nvar Circle_1 = require(\"./shapes/Circle\");\nvar Ellipse_1 = require(\"./shapes/Ellipse\");\nvar Image_1 = require(\"./shapes/Image\");\nvar Label_1 = require(\"./shapes/Label\");\nvar Line_1 = require(\"./shapes/Line\");\nvar Path_1 = require(\"./shapes/Path\");\nvar Rect_1 = require(\"./shapes/Rect\");\nvar RegularPolygon_1 = require(\"./shapes/RegularPolygon\");\nvar Ring_1 = require(\"./shapes/Ring\");\nvar Sprite_1 = require(\"./shapes/Sprite\");\nvar Star_1 = require(\"./shapes/Star\");\nvar Text_1 = require(\"./shapes/Text\");\nvar TextPath_1 = require(\"./shapes/TextPath\");\nvar Transformer_1 = require(\"./shapes/Transformer\");\nvar Wedge_1 = require(\"./shapes/Wedge\");\nvar Blur_1 = require(\"./filters/Blur\");\nvar Brighten_1 = require(\"./filters/Brighten\");\nvar Contrast_1 = require(\"./filters/Contrast\");\nvar Emboss_1 = require(\"./filters/Emboss\");\nvar Enhance_1 = require(\"./filters/Enhance\");\nvar Grayscale_1 = require(\"./filters/Grayscale\");\nvar HSL_1 = require(\"./filters/HSL\");\nvar HSV_1 = require(\"./filters/HSV\");\nvar Invert_1 = require(\"./filters/Invert\");\nvar Kaleidoscope_1 = require(\"./filters/Kaleidoscope\");\nvar Mask_1 = require(\"./filters/Mask\");\nvar Noise_1 = require(\"./filters/Noise\");\nvar Pixelate_1 = require(\"./filters/Pixelate\");\nvar Posterize_1 = require(\"./filters/Posterize\");\nvar RGB_1 = require(\"./filters/RGB\");\nvar RGBA_1 = require(\"./filters/RGBA\");\nvar Sepia_1 = require(\"./filters/Sepia\");\nvar Solarize_1 = require(\"./filters/Solarize\");\nvar Threshold_1 = require(\"./filters/Threshold\");\nexports.Konva = _CoreInternals_1.Konva.Util._assign(_CoreInternals_1.Konva, {\n Arc: Arc_1.Arc,\n Arrow: Arrow_1.Arrow,\n Circle: Circle_1.Circle,\n Ellipse: Ellipse_1.Ellipse,\n Image: Image_1.Image,\n Label: Label_1.Label,\n Tag: Label_1.Tag,\n Line: Line_1.Line,\n Path: Path_1.Path,\n Rect: Rect_1.Rect,\n RegularPolygon: RegularPolygon_1.RegularPolygon,\n Ring: Ring_1.Ring,\n Sprite: Sprite_1.Sprite,\n Star: Star_1.Star,\n Text: Text_1.Text,\n TextPath: TextPath_1.TextPath,\n Transformer: Transformer_1.Transformer,\n Wedge: Wedge_1.Wedge,\n Filters: {\n Blur: Blur_1.Blur,\n Brighten: Brighten_1.Brighten,\n Contrast: Contrast_1.Contrast,\n Emboss: Emboss_1.Emboss,\n Enhance: Enhance_1.Enhance,\n Grayscale: Grayscale_1.Grayscale,\n HSL: HSL_1.HSL,\n HSV: HSV_1.HSV,\n Invert: Invert_1.Invert,\n Kaleidoscope: Kaleidoscope_1.Kaleidoscope,\n Mask: Mask_1.Mask,\n Noise: Noise_1.Noise,\n Pixelate: Pixelate_1.Pixelate,\n Posterize: Posterize_1.Posterize,\n RGB: RGB_1.RGB,\n RGBA: RGBA_1.RGBA,\n Sepia: Sepia_1.Sepia,\n Solarize: Solarize_1.Solarize,\n Threshold: Threshold_1.Threshold\n }\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Global_1 = require(\"./Global\");\nvar Util_1 = require(\"./Util\");\nvar Node_1 = require(\"./Node\");\nvar Container_1 = require(\"./Container\");\nvar Stage_1 = require(\"./Stage\");\nvar Layer_1 = require(\"./Layer\");\nvar FastLayer_1 = require(\"./FastLayer\");\nvar Group_1 = require(\"./Group\");\nvar DragAndDrop_1 = require(\"./DragAndDrop\");\nvar Shape_1 = require(\"./Shape\");\nvar Animation_1 = require(\"./Animation\");\nvar Tween_1 = require(\"./Tween\");\nvar Context_1 = require(\"./Context\");\nvar Canvas_1 = require(\"./Canvas\");\nexports.Konva = Util_1.Util._assign(Global_1.Konva, {\n Collection: Util_1.Collection,\n Util: Util_1.Util,\n Transform: Util_1.Transform,\n Node: Node_1.Node,\n ids: Node_1.ids,\n names: Node_1.names,\n Container: Container_1.Container,\n Stage: Stage_1.Stage,\n stages: Stage_1.stages,\n Layer: Layer_1.Layer,\n FastLayer: FastLayer_1.FastLayer,\n Group: Group_1.Group,\n DD: DragAndDrop_1.DD,\n Shape: Shape_1.Shape,\n shapes: Shape_1.shapes,\n Animation: Animation_1.Animation,\n Tween: Tween_1.Tween,\n Easings: Tween_1.Easings,\n Context: Context_1.Context,\n Canvas: Canvas_1.Canvas\n});\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Factory_1 = require(\"./Factory\");\nvar Container_1 = require(\"./Container\");\nvar Global_1 = require(\"./Global\");\nvar Canvas_1 = require(\"./Canvas\");\nvar DragAndDrop_1 = require(\"./DragAndDrop\");\nvar Global_2 = require(\"./Global\");\nvar PointerEvents = require(\"./PointerEvents\");\nvar STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', CONTEXTMENU = 'contextmenu', CLICK = 'click', DBL_CLICK = 'dblclick', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TAP = 'tap', DBL_TAP = 'dbltap', TOUCHMOVE = 'touchmove', WHEEL = 'wheel', CONTENT_MOUSEOUT = 'contentMouseout', CONTENT_MOUSEOVER = 'contentMouseover', CONTENT_MOUSEMOVE = 'contentMousemove', CONTENT_MOUSEDOWN = 'contentMousedown', CONTENT_MOUSEUP = 'contentMouseup', CONTENT_CONTEXTMENU = 'contentContextmenu', CONTENT_CLICK = 'contentClick', CONTENT_DBL_CLICK = 'contentDblclick', CONTENT_TOUCHSTART = 'contentTouchstart', CONTENT_TOUCHEND = 'contentTouchend', CONTENT_DBL_TAP = 'contentDbltap', CONTENT_TAP = 'contentTap', CONTENT_TOUCHMOVE = 'contentTouchmove', CONTENT_POINTERMOVE = 'contentPointermove', CONTENT_POINTERDOWN = 'contentPointerdown', CONTENT_POINTERUP = 'contentPointerup', CONTENT_WHEEL = 'contentWheel', RELATIVE = 'relative', KONVA_CONTENT = 'konvajs-content', SPACE = ' ', UNDERSCORE = '_', CONTAINER = 'container', MAX_LAYERS_NUMBER = 5, EMPTY_STRING = '', EVENTS = [\n MOUSEENTER,\n MOUSEDOWN,\n MOUSEMOVE,\n MOUSEUP,\n MOUSEOUT,\n TOUCHSTART,\n TOUCHMOVE,\n TOUCHEND,\n MOUSEOVER,\n WHEEL,\n CONTEXTMENU,\n POINTERDOWN,\n POINTERMOVE,\n POINTERUP,\n POINTERCANCEL,\n LOSTPOINTERCAPTURE\n], eventsLength = EVENTS.length;\nfunction addEvent(ctx, eventName) {\n ctx.content.addEventListener(eventName, function (evt) {\n ctx[UNDERSCORE + eventName](evt);\n }, false);\n}\nvar NO_POINTERS_MESSAGE = \"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);\";\nexports.stages = [];\nfunction checkNoClip(attrs) {\n if (attrs === void 0) { attrs = {}; }\n if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {\n Util_1.Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');\n }\n return attrs;\n}\nvar Stage = (function (_super) {\n __extends(Stage, _super);\n function Stage(config) {\n var _this = _super.call(this, checkNoClip(config)) || this;\n _this._pointerPositions = [];\n _this._changedPointerPositions = [];\n _this._buildDOM();\n _this._bindContentEvents();\n exports.stages.push(_this);\n _this.on('widthChange.konva heightChange.konva', _this._resizeDOM);\n _this.on('visibleChange.konva', _this._checkVisibility);\n _this.on('clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva', function () {\n checkNoClip(_this.attrs);\n });\n _this._checkVisibility();\n return _this;\n }\n Stage.prototype._validateAdd = function (child) {\n var isLayer = child.getType() === 'Layer';\n var isFastLayer = child.getType() === 'FastLayer';\n var valid = isLayer || isFastLayer;\n if (!valid) {\n Util_1.Util.throw('You may only add layers to the stage.');\n }\n };\n Stage.prototype._checkVisibility = function () {\n if (!this.content) {\n return;\n }\n var style = this.visible() ? '' : 'none';\n this.content.style.display = style;\n };\n Stage.prototype.setContainer = function (container) {\n if (typeof container === STRING) {\n if (container.charAt(0) === '.') {\n var className = container.slice(1);\n container = document.getElementsByClassName(className)[0];\n }\n else {\n var id;\n if (container.charAt(0) !== '#') {\n id = container;\n }\n else {\n id = container.slice(1);\n }\n container = document.getElementById(id);\n }\n if (!container) {\n throw 'Can not find container in document with id ' + id;\n }\n }\n this._setAttr(CONTAINER, container);\n if (this.content) {\n if (this.content.parentElement) {\n this.content.parentElement.removeChild(this.content);\n }\n container.appendChild(this.content);\n }\n return this;\n };\n Stage.prototype.shouldDrawHit = function () {\n return true;\n };\n Stage.prototype.clear = function () {\n var layers = this.children, len = layers.length, n;\n for (n = 0; n < len; n++) {\n layers[n].clear();\n }\n return this;\n };\n Stage.prototype.clone = function (obj) {\n if (!obj) {\n obj = {};\n }\n obj.container = document.createElement('div');\n return Container_1.Container.prototype.clone.call(this, obj);\n };\n Stage.prototype.destroy = function () {\n _super.prototype.destroy.call(this);\n var content = this.content;\n if (content && Util_1.Util._isInDocument(content)) {\n this.container().removeChild(content);\n }\n var index = exports.stages.indexOf(this);\n if (index > -1) {\n exports.stages.splice(index, 1);\n }\n return this;\n };\n Stage.prototype.getPointerPosition = function () {\n var pos = this._pointerPositions[0] || this._changedPointerPositions[0];\n if (!pos) {\n Util_1.Util.warn(NO_POINTERS_MESSAGE);\n return null;\n }\n return {\n x: pos.x,\n y: pos.y\n };\n };\n Stage.prototype._getPointerById = function (id) {\n return this._pointerPositions.find(function (p) { return p.id === id; });\n };\n Stage.prototype.getPointersPositions = function () {\n return this._pointerPositions;\n };\n Stage.prototype.getStage = function () {\n return this;\n };\n Stage.prototype.getContent = function () {\n return this.content;\n };\n Stage.prototype._toKonvaCanvas = function (config) {\n config = config || {};\n var x = config.x || 0, y = config.y || 0, canvas = new Canvas_1.SceneCanvas({\n width: config.width || this.width(),\n height: config.height || this.height(),\n pixelRatio: config.pixelRatio || 1\n }), _context = canvas.getContext()._context, layers = this.children;\n if (x || y) {\n _context.translate(-1 * x, -1 * y);\n }\n layers.each(function (layer) {\n if (!layer.isVisible()) {\n return;\n }\n var layerCanvas = layer._toKonvaCanvas(config);\n _context.drawImage(layerCanvas._canvas, x, y, layerCanvas.getWidth() / layerCanvas.getPixelRatio(), layerCanvas.getHeight() / layerCanvas.getPixelRatio());\n });\n return canvas;\n };\n Stage.prototype.getIntersection = function (pos, selector) {\n if (!pos) {\n return null;\n }\n var layers = this.children, len = layers.length, end = len - 1, n, shape;\n for (n = end; n >= 0; n--) {\n shape = layers[n].getIntersection(pos, selector);\n if (shape) {\n return shape;\n }\n }\n return null;\n };\n Stage.prototype._resizeDOM = function () {\n var width = this.width();\n var height = this.height();\n if (this.content) {\n this.content.style.width = width + PX;\n this.content.style.height = height + PX;\n }\n this.bufferCanvas.setSize(width, height);\n this.bufferHitCanvas.setSize(width, height);\n this.children.each(function (layer) {\n layer.setSize({ width: width, height: height });\n layer.draw();\n });\n };\n Stage.prototype.add = function (layer) {\n if (arguments.length > 1) {\n for (var i = 0; i < arguments.length; i++) {\n this.add(arguments[i]);\n }\n return this;\n }\n _super.prototype.add.call(this, layer);\n var length = this.children.length;\n if (length > MAX_LAYERS_NUMBER) {\n Util_1.Util.warn('The stage has ' +\n length +\n ' 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.');\n }\n layer.setSize({ width: this.width(), height: this.height() });\n layer.draw();\n if (Global_1.Konva.isBrowser) {\n this.content.appendChild(layer.canvas._canvas);\n }\n return this;\n };\n Stage.prototype.getParent = function () {\n return null;\n };\n Stage.prototype.getLayer = function () {\n return null;\n };\n Stage.prototype.hasPointerCapture = function (pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n };\n Stage.prototype.setPointerCapture = function (pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n };\n Stage.prototype.releaseCapture = function (pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n };\n Stage.prototype.getLayers = function () {\n return this.getChildren();\n };\n Stage.prototype._bindContentEvents = function () {\n if (!Global_1.Konva.isBrowser) {\n return;\n }\n for (var n = 0; n < eventsLength; n++) {\n addEvent(this, EVENTS[n]);\n }\n };\n Stage.prototype._mouseenter = function (evt) {\n this.setPointersPositions(evt);\n this._fire(MOUSEENTER, { evt: evt, target: this, currentTarget: this });\n };\n Stage.prototype._mouseover = function (evt) {\n this.setPointersPositions(evt);\n this._fire(CONTENT_MOUSEOVER, { evt: evt });\n this._fire(MOUSEOVER, { evt: evt, target: this, currentTarget: this });\n };\n Stage.prototype._mouseout = function (evt) {\n var _a;\n this.setPointersPositions(evt);\n var targetShape = ((_a = this.targetShape) === null || _a === void 0 ? void 0 : _a.getStage()) ? this.targetShape : null;\n var eventsEnabled = !DragAndDrop_1.DD.isDragging || Global_1.Konva.hitOnDragEnabled;\n if (targetShape && eventsEnabled) {\n targetShape._fireAndBubble(MOUSEOUT, { evt: evt });\n targetShape._fireAndBubble(MOUSELEAVE, { evt: evt });\n this._fire(MOUSELEAVE, { evt: evt, target: this, currentTarget: this });\n this.targetShape = null;\n }\n else if (eventsEnabled) {\n this._fire(MOUSELEAVE, {\n evt: evt,\n target: this,\n currentTarget: this\n });\n this._fire(MOUSEOUT, {\n evt: evt,\n target: this,\n currentTarget: this\n });\n }\n this.pointerPos = undefined;\n this._pointerPositions = [];\n this._fire(CONTENT_MOUSEOUT, { evt: evt });\n };\n Stage.prototype._mousemove = function (evt) {\n var _a;\n if (Global_1.Konva.UA.ieMobile) {\n return this._touchmove(evt);\n }\n this.setPointersPositions(evt);\n var pointerId = Util_1.Util._getFirstPointerId(evt);\n var shape;\n var targetShape = ((_a = this.targetShape) === null || _a === void 0 ? void 0 : _a.getStage()) ? this.targetShape : null;\n var eventsEnabled = !DragAndDrop_1.DD.isDragging || Global_1.Konva.hitOnDragEnabled;\n if (eventsEnabled) {\n shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n var differentTarget = targetShape !== shape;\n if (eventsEnabled && differentTarget) {\n if (targetShape) {\n targetShape._fireAndBubble(MOUSEOUT, { evt: evt, pointerId: pointerId }, shape);\n targetShape._fireAndBubble(MOUSELEAVE, { evt: evt, pointerId: pointerId }, shape);\n }\n shape._fireAndBubble(MOUSEOVER, { evt: evt, pointerId: pointerId }, targetShape);\n shape._fireAndBubble(MOUSEENTER, { evt: evt, pointerId: pointerId }, targetShape);\n shape._fireAndBubble(MOUSEMOVE, { evt: evt, pointerId: pointerId });\n this.targetShape = shape;\n }\n else {\n shape._fireAndBubble(MOUSEMOVE, { evt: evt, pointerId: pointerId });\n }\n }\n else {\n if (targetShape && eventsEnabled) {\n targetShape._fireAndBubble(MOUSEOUT, { evt: evt, pointerId: pointerId });\n targetShape._fireAndBubble(MOUSELEAVE, { evt: evt, pointerId: pointerId });\n this._fire(MOUSEOVER, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n this.targetShape = null;\n }\n this._fire(MOUSEMOVE, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n }\n this._fire(CONTENT_MOUSEMOVE, { evt: evt });\n }\n if (evt.cancelable) {\n evt.preventDefault();\n }\n };\n Stage.prototype._mousedown = function (evt) {\n if (Global_1.Konva.UA.ieMobile) {\n return this._touchstart(evt);\n }\n this.setPointersPositions(evt);\n var pointerId = Util_1.Util._getFirstPointerId(evt);\n var shape = this.getIntersection(this.getPointerPosition());\n DragAndDrop_1.DD.justDragged = false;\n Global_1.Konva.listenClickTap = true;\n if (shape && shape.isListening()) {\n this.clickStartShape = shape;\n shape._fireAndBubble(MOUSEDOWN, { evt: evt, pointerId: pointerId });\n }\n else {\n this._fire(MOUSEDOWN, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n }\n this._fire(CONTENT_MOUSEDOWN, { evt: evt });\n };\n Stage.prototype._mouseup = function (evt) {\n if (Global_1.Konva.UA.ieMobile) {\n return this._touchend(evt);\n }\n this.setPointersPositions(evt);\n var pointerId = Util_1.Util._getFirstPointerId(evt);\n var shape = this.getIntersection(this.getPointerPosition()), clickStartShape = this.clickStartShape, clickEndShape = this.clickEndShape, fireDblClick = false;\n if (Global_1.Konva.inDblClickWindow) {\n fireDblClick = true;\n clearTimeout(this.dblTimeout);\n }\n else if (!DragAndDrop_1.DD.justDragged) {\n Global_1.Konva.inDblClickWindow = true;\n clearTimeout(this.dblTimeout);\n }\n this.dblTimeout = setTimeout(function () {\n Global_1.Konva.inDblClickWindow = false;\n }, Global_1.Konva.dblClickWindow);\n if (shape && shape.isListening()) {\n this.clickEndShape = shape;\n shape._fireAndBubble(MOUSEUP, { evt: evt, pointerId: pointerId });\n if (Global_1.Konva.listenClickTap &&\n clickStartShape &&\n clickStartShape._id === shape._id) {\n shape._fireAndBubble(CLICK, { evt: evt, pointerId: pointerId });\n if (fireDblClick && clickEndShape && clickEndShape === shape) {\n shape._fireAndBubble(DBL_CLICK, { evt: evt, pointerId: pointerId });\n }\n }\n }\n else {\n this._fire(MOUSEUP, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n if (Global_1.Konva.listenClickTap) {\n this._fire(CLICK, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n }\n if (fireDblClick) {\n this._fire(DBL_CLICK, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: pointerId\n });\n }\n }\n this._fire(CONTENT_MOUSEUP, { evt: evt });\n if (Global_1.Konva.listenClickTap) {\n this._fire(CONTENT_CLICK, { evt: evt });\n if (fireDblClick) {\n this._fire(CONTENT_DBL_CLICK, { evt: evt });\n }\n }\n Global_1.Konva.listenClickTap = false;\n if (evt.cancelable) {\n evt.preventDefault();\n }\n };\n Stage.prototype._contextmenu = function (evt) {\n this.setPointersPositions(evt);\n var shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(CONTEXTMENU, { evt: evt });\n }\n else {\n this._fire(CONTEXTMENU, {\n evt: evt,\n target: this,\n currentTarget: this\n });\n }\n this._fire(CONTENT_CONTEXTMENU, { evt: evt });\n };\n Stage.prototype._touchstart = function (evt) {\n var _this = this;\n this.setPointersPositions(evt);\n var triggeredOnShape = false;\n this._changedPointerPositions.forEach(function (pos) {\n var shape = _this.getIntersection(pos);\n Global_1.Konva.listenClickTap = true;\n DragAndDrop_1.DD.justDragged = false;\n var hasShape = shape && shape.isListening();\n if (!hasShape) {\n return;\n }\n if (Global_1.Konva.captureTouchEventsEnabled) {\n shape.setPointerCapture(pos.id);\n }\n _this.tapStartShape = shape;\n shape._fireAndBubble(TOUCHSTART, { evt: evt, pointerId: pos.id }, _this);\n triggeredOnShape = true;\n if (shape.isListening() && shape.preventDefault() && evt.cancelable) {\n evt.preventDefault();\n }\n });\n if (!triggeredOnShape) {\n this._fire(TOUCHSTART, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id\n });\n }\n this._fire(CONTENT_TOUCHSTART, { evt: evt });\n };\n Stage.prototype._touchmove = function (evt) {\n var _this = this;\n this.setPointersPositions(evt);\n var eventsEnabled = !DragAndDrop_1.DD.isDragging || Global_1.Konva.hitOnDragEnabled;\n if (eventsEnabled) {\n var triggeredOnShape = false;\n var processedShapesIds = {};\n this._changedPointerPositions.forEach(function (pos) {\n var shape = PointerEvents.getCapturedShape(pos.id) || _this.getIntersection(pos);\n var hasShape = shape && shape.isListening();\n if (!hasShape) {\n return;\n }\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n shape._fireAndBubble(TOUCHMOVE, { evt: evt, pointerId: pos.id });\n triggeredOnShape = true;\n if (shape.isListening() && shape.preventDefault() && evt.cancelable) {\n evt.preventDefault();\n }\n });\n if (!triggeredOnShape) {\n this._fire(TOUCHMOVE, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id\n });\n }\n this._fire(CONTENT_TOUCHMOVE, { evt: evt });\n }\n if (DragAndDrop_1.DD.isDragging && DragAndDrop_1.DD.node.preventDefault() && evt.cancelable) {\n evt.preventDefault();\n }\n };\n Stage.prototype._touchend = function (evt) {\n var _this = this;\n this.setPointersPositions(evt);\n var clickEndShape = this.clickEndShape, fireDblClick = false;\n if (Global_1.Konva.inDblClickWindow) {\n fireDblClick = true;\n clearTimeout(this.dblTimeout);\n }\n else if (!DragAndDrop_1.DD.justDragged) {\n Global_1.Konva.inDblClickWindow = true;\n clearTimeout(this.dblTimeout);\n }\n this.dblTimeout = setTimeout(function () {\n Global_1.Konva.inDblClickWindow = false;\n }, Global_1.Konva.dblClickWindow);\n var triggeredOnShape = false;\n var processedShapesIds = {};\n var tapTriggered = false;\n var dblTapTriggered = false;\n this._changedPointerPositions.forEach(function (pos) {\n var shape = PointerEvents.getCapturedShape(pos.id) ||\n _this.getIntersection(pos);\n if (shape) {\n shape.releaseCapture(pos.id);\n }\n var hasShape = shape && shape.isListening();\n if (!hasShape) {\n return;\n }\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n _this.clickEndShape = shape;\n shape._fireAndBubble(TOUCHEND, { evt: evt, pointerId: pos.id });\n triggeredOnShape = true;\n if (Global_1.Konva.listenClickTap && shape === _this.tapStartShape) {\n tapTriggered = true;\n shape._fireAndBubble(TAP, { evt: evt, pointerId: pos.id });\n if (fireDblClick && clickEndShape && clickEndShape === shape) {\n dblTapTriggered = true;\n shape._fireAndBubble(DBL_TAP, { evt: evt, pointerId: pos.id });\n }\n }\n if (shape.isListening() && shape.preventDefault() && evt.cancelable) {\n evt.preventDefault();\n }\n });\n if (!triggeredOnShape) {\n this._fire(TOUCHEND, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id\n });\n }\n if (Global_1.Konva.listenClickTap && !tapTriggered) {\n this._fire(TAP, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id\n });\n }\n if (fireDblClick && !dblTapTriggered) {\n this._fire(DBL_TAP, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id\n });\n }\n this._fire(CONTENT_TOUCHEND, { evt: evt });\n if (Global_1.Konva.listenClickTap) {\n this._fire(CONTENT_TAP, { evt: evt });\n if (fireDblClick) {\n this._fire(CONTENT_DBL_TAP, { evt: evt });\n }\n }\n Global_1.Konva.listenClickTap = false;\n };\n Stage.prototype._wheel = function (evt) {\n this.setPointersPositions(evt);\n var shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(WHEEL, { evt: evt });\n }\n else {\n this._fire(WHEEL, {\n evt: evt,\n target: this,\n currentTarget: this\n });\n }\n this._fire(CONTENT_WHEEL, { evt: evt });\n };\n Stage.prototype._pointerdown = function (evt) {\n if (!Global_1.Konva._pointerEventsEnabled) {\n return;\n }\n this.setPointersPositions(evt);\n var shape = PointerEvents.getCapturedShape(evt.pointerId) ||\n this.getIntersection(this.getPointerPosition());\n if (shape) {\n shape._fireAndBubble(POINTERDOWN, PointerEvents.createEvent(evt));\n }\n };\n Stage.prototype._pointermove = function (evt) {\n if (!Global_1.Konva._pointerEventsEnabled) {\n return;\n }\n this.setPointersPositions(evt);\n var shape = PointerEvents.getCapturedShape(evt.pointerId) ||\n this.getIntersection(this.getPointerPosition());\n if (shape) {\n shape._fireAndBubble(POINTERMOVE, PointerEvents.createEvent(evt));\n }\n };\n Stage.prototype._pointerup = function (evt) {\n if (!Global_1.Konva._pointerEventsEnabled) {\n return;\n }\n this.setPointersPositions(evt);\n var shape = PointerEvents.getCapturedShape(evt.pointerId) ||\n this.getIntersection(this.getPointerPosition());\n if (shape) {\n shape._fireAndBubble(POINTERUP, PointerEvents.createEvent(evt));\n }\n PointerEvents.releaseCapture(evt.pointerId);\n };\n Stage.prototype._pointercancel = function (evt) {\n if (!Global_1.Konva._pointerEventsEnabled) {\n return;\n }\n this.setPointersPositions(evt);\n var shape = PointerEvents.getCapturedShape(evt.pointerId) ||\n this.getIntersection(this.getPointerPosition());\n if (shape) {\n shape._fireAndBubble(POINTERUP, PointerEvents.createEvent(evt));\n }\n PointerEvents.releaseCapture(evt.pointerId);\n };\n Stage.prototype._lostpointercapture = function (evt) {\n PointerEvents.releaseCapture(evt.pointerId);\n };\n Stage.prototype.setPointersPositions = function (evt) {\n var _this = this;\n var contentPosition = this._getContentPosition(), x = null, y = null;\n evt = evt ? evt : window.event;\n if (evt.touches !== undefined) {\n this._pointerPositions = [];\n this._changedPointerPositions = [];\n Util_1.Collection.prototype.each.call(evt.touches, function (touch) {\n _this._pointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY\n });\n });\n Util_1.Collection.prototype.each.call(evt.changedTouches || evt.touches, function (touch) {\n _this._changedPointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY\n });\n });\n }\n else {\n x = (evt.clientX - contentPosition.left) / contentPosition.scaleX;\n y = (evt.clientY - contentPosition.top) / contentPosition.scaleY;\n this.pointerPos = {\n x: x,\n y: y\n };\n this._pointerPositions = [{ x: x, y: y, id: Util_1.Util._getFirstPointerId(evt) }];\n this._changedPointerPositions = [\n { x: x, y: y, id: Util_1.Util._getFirstPointerId(evt) }\n ];\n }\n };\n Stage.prototype._setPointerPosition = function (evt) {\n Util_1.Util.warn('Method _setPointerPosition is deprecated. Use \"stage.setPointersPositions(event)\" instead.');\n this.setPointersPositions(evt);\n };\n Stage.prototype._getContentPosition = function () {\n if (!this.content || !this.content.getBoundingClientRect) {\n return {\n top: 0,\n left: 0,\n scaleX: 1,\n scaleY: 1\n };\n }\n var rect = this.content.getBoundingClientRect();\n return {\n top: rect.top,\n left: rect.left,\n scaleX: rect.width / this.content.clientWidth || 1,\n scaleY: rect.height / this.content.clientHeight || 1\n };\n };\n Stage.prototype._buildDOM = function () {\n this.bufferCanvas = new Canvas_1.SceneCanvas({\n width: this.width(),\n height: this.height()\n });\n this.bufferHitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: 1,\n width: this.width(),\n height: this.height()\n });\n if (!Global_1.Konva.isBrowser) {\n return;\n }\n var container = this.container();\n if (!container) {\n throw 'Stage has no container. A container is required.';\n }\n container.innerHTML = EMPTY_STRING;\n this.content = document.createElement('div');\n this.content.style.position = RELATIVE;\n this.content.style.userSelect = 'none';\n this.content.className = KONVA_CONTENT;\n this.content.setAttribute('role', 'presentation');\n container.appendChild(this.content);\n this._resizeDOM();\n };\n Stage.prototype.cache = function () {\n Util_1.Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');\n return this;\n };\n Stage.prototype.clearCache = function () {\n return this;\n };\n Stage.prototype.batchDraw = function () {\n this.children.each(function (layer) {\n layer.batchDraw();\n });\n return this;\n };\n return Stage;\n}(Container_1.Container));\nexports.Stage = Stage;\nStage.prototype.nodeType = STAGE;\nGlobal_2._registerNode(Stage);\nFactory_1.Factory.addGetterSetter(Stage, 'container');\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Container_1 = require(\"./Container\");\nvar Factory_1 = require(\"./Factory\");\nvar BaseLayer_1 = require(\"./BaseLayer\");\nvar Canvas_1 = require(\"./Canvas\");\nvar Shape_1 = require(\"./Shape\");\nvar Validators_1 = require(\"./Validators\");\nvar Global_1 = require(\"./Global\");\nvar HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [\n { x: 0, y: 0 },\n { x: -1, y: -1 },\n { x: 1, y: -1 },\n { x: 1, y: 1 },\n { x: -1, y: 1 }\n], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;\nvar Layer = (function (_super) {\n __extends(Layer, _super);\n function Layer() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.hitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: 1\n });\n return _this;\n }\n Layer.prototype.setSize = function (_a) {\n var width = _a.width, height = _a.height;\n _super.prototype.setSize.call(this, { width: width, height: height });\n this.hitCanvas.setSize(width, height);\n return this;\n };\n Layer.prototype._validateAdd = function (child) {\n var type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util_1.Util.throw('You may only add groups and shapes to a layer.');\n }\n };\n Layer.prototype.getIntersection = function (pos, selector) {\n var obj, i, intersectionOffset, shape;\n if (!this.hitGraphEnabled() || !this.isVisible()) {\n return null;\n }\n var spiralSearchDistance = 1;\n var continueSearch = false;\n while (true) {\n for (i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {\n intersectionOffset = INTERSECTION_OFFSETS[i];\n obj = this._getIntersection({\n x: pos.x + intersectionOffset.x * spiralSearchDistance,\n y: pos.y + intersectionOffset.y * spiralSearchDistance\n });\n shape = obj.shape;\n if (shape && selector) {\n return shape.findAncestor(selector, true);\n }\n else if (shape) {\n return shape;\n }\n continueSearch = !!obj.antialiased;\n if (!obj.antialiased) {\n break;\n }\n }\n if (continueSearch) {\n spiralSearchDistance += 1;\n }\n else {\n return null;\n }\n }\n };\n Layer.prototype._getIntersection = function (pos) {\n var ratio = this.hitCanvas.pixelRatio;\n var p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data, p3 = p[3], colorKey, shape;\n if (p3 === 255) {\n colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);\n shape = Shape_1.shapes[HASH + colorKey];\n if (shape) {\n return {\n shape: shape\n };\n }\n return {\n antialiased: true\n };\n }\n else if (p3 > 0) {\n return {\n antialiased: true\n };\n }\n return {};\n };\n Layer.prototype.drawScene = function (can, top) {\n var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());\n this._fire(BEFORE_DRAW, {\n node: this\n });\n if (this.clearBeforeDraw()) {\n canvas.getContext().clear();\n }\n Container_1.Container.prototype.drawScene.call(this, canvas, top);\n this._fire(DRAW, {\n node: this\n });\n return this;\n };\n Layer.prototype.drawHit = function (can, top) {\n var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);\n if (layer && layer.clearBeforeDraw()) {\n layer\n .getHitCanvas()\n .getContext()\n .clear();\n }\n Container_1.Container.prototype.drawHit.call(this, canvas, top);\n return this;\n };\n Layer.prototype.clear = function (bounds) {\n BaseLayer_1.BaseLayer.prototype.clear.call(this, bounds);\n this.getHitCanvas()\n .getContext()\n .clear(bounds);\n return this;\n };\n Layer.prototype.enableHitGraph = function () {\n this.hitGraphEnabled(true);\n return this;\n };\n Layer.prototype.disableHitGraph = function () {\n this.hitGraphEnabled(false);\n return this;\n };\n Layer.prototype.toggleHitCanvas = function () {\n if (!this.parent) {\n return;\n }\n var parent = this.parent;\n var added = !!this.hitCanvas._canvas.parentNode;\n if (added) {\n parent.content.removeChild(this.hitCanvas._canvas);\n }\n else {\n parent.content.appendChild(this.hitCanvas._canvas);\n }\n };\n return Layer;\n}(BaseLayer_1.BaseLayer));\nexports.Layer = Layer;\nLayer.prototype.nodeType = 'Layer';\nGlobal_1._registerNode(Layer);\nFactory_1.Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, Validators_1.getBooleanValidator());\nUtil_1.Collection.mapMethods(Layer);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Container_1 = require(\"./Container\");\nvar BaseLayer_1 = require(\"./BaseLayer\");\nvar Global_1 = require(\"./Global\");\nvar FastLayer = (function (_super) {\n __extends(FastLayer, _super);\n function FastLayer() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n FastLayer.prototype._validateAdd = function (child) {\n var type = child.getType();\n if (type !== 'Shape') {\n Util_1.Util.throw('You may only add shapes to a fast layer.');\n }\n };\n FastLayer.prototype.hitGraphEnabled = function () {\n return false;\n };\n FastLayer.prototype.drawScene = function (can) {\n var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());\n if (this.clearBeforeDraw()) {\n canvas.getContext().clear();\n }\n Container_1.Container.prototype.drawScene.call(this, canvas);\n return this;\n };\n FastLayer.prototype.draw = function () {\n this.drawScene();\n return this;\n };\n return FastLayer;\n}(BaseLayer_1.BaseLayer));\nexports.FastLayer = FastLayer;\nFastLayer.prototype.nodeType = 'FastLayer';\nGlobal_1._registerNode(FastLayer);\nUtil_1.Collection.mapMethods(FastLayer);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"./Util\");\nvar Animation_1 = require(\"./Animation\");\nvar Node_1 = require(\"./Node\");\nvar Global_1 = require(\"./Global\");\nvar blacklist = {\n node: 1,\n duration: 1,\n easing: 1,\n onFinish: 1,\n yoyo: 1\n}, PAUSED = 1, PLAYING = 2, REVERSING = 3, idCounter = 0, colorAttrs = ['fill', 'stroke', 'shadowColor'];\nvar TweenEngine = (function () {\n function TweenEngine(prop, propFunc, func, begin, finish, duration, yoyo) {\n this.prop = prop;\n this.propFunc = propFunc;\n this.begin = begin;\n this._pos = begin;\n this.duration = duration;\n this._change = 0;\n this.prevPos = 0;\n this.yoyo = yoyo;\n this._time = 0;\n this._position = 0;\n this._startTime = 0;\n this._finish = 0;\n this.func = func;\n this._change = finish - this.begin;\n this.pause();\n }\n TweenEngine.prototype.fire = function (str) {\n var handler = this[str];\n if (handler) {\n handler();\n }\n };\n TweenEngine.prototype.setTime = function (t) {\n if (t > this.duration) {\n if (this.yoyo) {\n this._time = this.duration;\n this.reverse();\n }\n else {\n this.finish();\n }\n }\n else if (t < 0) {\n if (this.yoyo) {\n this._time = 0;\n this.play();\n }\n else {\n this.reset();\n }\n }\n else {\n this._time = t;\n this.update();\n }\n };\n TweenEngine.prototype.getTime = function () {\n return this._time;\n };\n TweenEngine.prototype.setPosition = function (p) {\n this.prevPos = this._pos;\n this.propFunc(p);\n this._pos = p;\n };\n TweenEngine.prototype.getPosition = function (t) {\n if (t === undefined) {\n t = this._time;\n }\n return this.func(t, this.begin, this._change, this.duration);\n };\n TweenEngine.prototype.play = function () {\n this.state = PLAYING;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onPlay');\n };\n TweenEngine.prototype.reverse = function () {\n this.state = REVERSING;\n this._time = this.duration - this._time;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onReverse');\n };\n TweenEngine.prototype.seek = function (t) {\n this.pause();\n this._time = t;\n this.update();\n this.fire('onSeek');\n };\n TweenEngine.prototype.reset = function () {\n this.pause();\n this._time = 0;\n this.update();\n this.fire('onReset');\n };\n TweenEngine.prototype.finish = function () {\n this.pause();\n this._time = this.duration;\n this.update();\n this.fire('onFinish');\n };\n TweenEngine.prototype.update = function () {\n this.setPosition(this.getPosition(this._time));\n };\n TweenEngine.prototype.onEnterFrame = function () {\n var t = this.getTimer() - this._startTime;\n if (this.state === PLAYING) {\n this.setTime(t);\n }\n else if (this.state === REVERSING) {\n this.setTime(this.duration - t);\n }\n };\n TweenEngine.prototype.pause = function () {\n this.state = PAUSED;\n this.fire('onPause');\n };\n TweenEngine.prototype.getTimer = function () {\n return new Date().getTime();\n };\n return TweenEngine;\n}());\nvar Tween = (function () {\n function Tween(config) {\n var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key;\n if (typeof config.duration === 'undefined') {\n duration = 0.3;\n }\n else if (config.duration === 0) {\n duration = 0.001;\n }\n else {\n duration = config.duration;\n }\n this.node = node;\n this._id = idCounter++;\n var layers = node.getLayer() ||\n (node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);\n if (!layers) {\n Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');\n }\n this.anim = new Animation_1.Animation(function () {\n that.tween.onEnterFrame();\n }, layers);\n this.tween = new TweenEngine(key, function (i) {\n that._tweenFunc(i);\n }, easing, 0, 1, duration * 1000, yoyo);\n this._addListeners();\n if (!Tween.attrs[nodeId]) {\n Tween.attrs[nodeId] = {};\n }\n if (!Tween.attrs[nodeId][this._id]) {\n Tween.attrs[nodeId][this._id] = {};\n }\n if (!Tween.tweens[nodeId]) {\n Tween.tweens[nodeId] = {};\n }\n for (key in config) {\n if (blacklist[key] === undefined) {\n this._addAttr(key, config[key]);\n }\n }\n this.reset();\n this.onFinish = config.onFinish;\n this.onReset = config.onReset;\n }\n Tween.prototype._addAttr = function (key, end) {\n var node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA;\n tweenId = Tween.tweens[nodeId][key];\n if (tweenId) {\n delete Tween.attrs[nodeId][tweenId][key];\n }\n start = node.getAttr(key);\n if (Util_1.Util._isArray(end)) {\n diff = [];\n len = Math.max(end.length, start.length);\n if (key === 'points' && end.length !== start.length) {\n if (end.length > start.length) {\n trueStart = start;\n start = Util_1.Util._prepareArrayForTween(start, end, node.closed());\n }\n else {\n trueEnd = end;\n end = Util_1.Util._prepareArrayForTween(end, start, node.closed());\n }\n }\n if (key.indexOf('fill') === 0) {\n for (n = 0; n < len; n++) {\n if (n % 2 === 0) {\n diff.push(end[n] - start[n]);\n }\n else {\n var startRGBA = Util_1.Util.colorToRGBA(start[n]);\n endRGBA = Util_1.Util.colorToRGBA(end[n]);\n start[n] = startRGBA;\n diff.push({\n r: endRGBA.r - startRGBA.r,\n g: endRGBA.g - startRGBA.g,\n b: endRGBA.b - startRGBA.b,\n a: endRGBA.a - startRGBA.a\n });\n }\n }\n }\n else {\n for (n = 0; n < len; n++) {\n diff.push(end[n] - start[n]);\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n start = Util_1.Util.colorToRGBA(start);\n endRGBA = Util_1.Util.colorToRGBA(end);\n diff = {\n r: endRGBA.r - start.r,\n g: endRGBA.g - start.g,\n b: endRGBA.b - start.b,\n a: endRGBA.a - start.a\n };\n }\n else {\n diff = end - start;\n }\n Tween.attrs[nodeId][this._id][key] = {\n start: start,\n diff: diff,\n end: end,\n trueEnd: trueEnd,\n trueStart: trueStart\n };\n Tween.tweens[nodeId][key] = this._id;\n };\n Tween.prototype._tweenFunc = function (i) {\n var node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end;\n for (key in attrs) {\n attr = attrs[key];\n start = attr.start;\n diff = attr.diff;\n end = attr.end;\n if (Util_1.Util._isArray(start)) {\n newVal = [];\n len = Math.max(start.length, end.length);\n if (key.indexOf('fill') === 0) {\n for (n = 0; n < len; n++) {\n if (n % 2 === 0) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n else {\n newVal.push('rgba(' +\n Math.round(start[n].r + diff[n].r * i) +\n ',' +\n Math.round(start[n].g + diff[n].g * i) +\n ',' +\n Math.round(start[n].b + diff[n].b * i) +\n ',' +\n (start[n].a + diff[n].a * i) +\n ')');\n }\n }\n }\n else {\n for (n = 0; n < len; n++) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n newVal =\n 'rgba(' +\n Math.round(start.r + diff.r * i) +\n ',' +\n Math.round(start.g + diff.g * i) +\n ',' +\n Math.round(start.b + diff.b * i) +\n ',' +\n (start.a + diff.a * i) +\n ')';\n }\n else {\n newVal = start + diff * i;\n }\n node.setAttr(key, newVal);\n }\n };\n Tween.prototype._addListeners = function () {\n var _this = this;\n this.tween.onPlay = function () {\n _this.anim.start();\n };\n this.tween.onReverse = function () {\n _this.anim.start();\n };\n this.tween.onPause = function () {\n _this.anim.stop();\n };\n this.tween.onFinish = function () {\n var node = _this.node;\n var attrs = Tween.attrs[node._id][_this._id];\n if (attrs.points && attrs.points.trueEnd) {\n node.setAttr('points', attrs.points.trueEnd);\n }\n if (_this.onFinish) {\n _this.onFinish.call(_this);\n }\n };\n this.tween.onReset = function () {\n var node = _this.node;\n var attrs = Tween.attrs[node._id][_this._id];\n if (attrs.points && attrs.points.trueStart) {\n node.points(attrs.points.trueStart);\n }\n if (_this.onReset) {\n _this.onReset();\n }\n };\n };\n Tween.prototype.play = function () {\n this.tween.play();\n return this;\n };\n Tween.prototype.reverse = function () {\n this.tween.reverse();\n return this;\n };\n Tween.prototype.reset = function () {\n this.tween.reset();\n return this;\n };\n Tween.prototype.seek = function (t) {\n this.tween.seek(t * 1000);\n return this;\n };\n Tween.prototype.pause = function () {\n this.tween.pause();\n return this;\n };\n Tween.prototype.finish = function () {\n this.tween.finish();\n return this;\n };\n Tween.prototype.destroy = function () {\n var nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key;\n this.pause();\n for (key in attrs) {\n delete Tween.tweens[nodeId][key];\n }\n delete Tween.attrs[nodeId][thisId];\n };\n Tween.attrs = {};\n Tween.tweens = {};\n return Tween;\n}());\nexports.Tween = Tween;\nNode_1.Node.prototype.to = function (params) {\n var onFinish = params.onFinish;\n params.node = this;\n params.onFinish = function () {\n this.destroy();\n if (onFinish) {\n onFinish();\n }\n };\n var tween = new Tween(params);\n tween.play();\n};\nexports.Easings = {\n BackEaseIn: function (t, b, c, d) {\n var s = 1.70158;\n return c * (t /= d) * t * ((s + 1) * t - s) + b;\n },\n BackEaseOut: function (t, b, c, d) {\n var s = 1.70158;\n return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n },\n BackEaseInOut: function (t, b, c, d) {\n var s = 1.70158;\n if ((t /= d / 2) < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n },\n ElasticEaseIn: function (t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (-(a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b);\n },\n ElasticEaseOut: function (t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (a * Math.pow(2, -10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) +\n c +\n b);\n },\n ElasticEaseInOut: function (t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d / 2) === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n if (t < 1) {\n return (-0.5 *\n (a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +\n b);\n }\n return (a *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p) *\n 0.5 +\n c +\n b);\n },\n BounceEaseOut: function (t, b, c, d) {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n }\n else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n }\n else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n }\n else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n },\n BounceEaseIn: function (t, b, c, d) {\n return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;\n },\n BounceEaseInOut: function (t, b, c, d) {\n if (t < d / 2) {\n return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;\n }\n else {\n return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n }\n },\n EaseIn: function (t, b, c, d) {\n return c * (t /= d) * t + b;\n },\n EaseOut: function (t, b, c, d) {\n return -c * (t /= d) * (t - 2) + b;\n },\n EaseInOut: function (t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n },\n StrongEaseIn: function (t, b, c, d) {\n return c * (t /= d) * t * t * t * t + b;\n },\n StrongEaseOut: function (t, b, c, d) {\n return c * ((t = t / d - 1) * t * t * t * t + 1) + b;\n },\n StrongEaseInOut: function (t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t * t * t * t + b;\n }\n return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;\n },\n Linear: function (t, b, c, d) {\n return (c * t) / d + b;\n }\n};\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Global_1 = require(\"../Global\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_2 = require(\"../Global\");\nvar Arc = (function (_super) {\n __extends(Arc, _super);\n function Arc() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Arc.prototype._sceneFunc = function (context) {\n var angle = Global_1.Konva.getAngle(this.angle()), clockwise = this.clockwise();\n context.beginPath();\n context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);\n context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Arc.prototype.getWidth = function () {\n return this.outerRadius() * 2;\n };\n Arc.prototype.getHeight = function () {\n return this.outerRadius() * 2;\n };\n Arc.prototype.setWidth = function (width) {\n this.outerRadius(width / 2);\n };\n Arc.prototype.setHeight = function (height) {\n this.outerRadius(height / 2);\n };\n return Arc;\n}(Shape_1.Shape));\nexports.Arc = Arc;\nArc.prototype._centroid = true;\nArc.prototype.className = 'Arc';\nArc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\nGlobal_2._registerNode(Arc);\nFactory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Arc, 'angle', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Arc, 'clockwise', false, Validators_1.getBooleanValidator());\nUtil_1.Collection.mapMethods(Arc);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Line_1 = require(\"./Line\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Arrow = (function (_super) {\n __extends(Arrow, _super);\n function Arrow() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Arrow.prototype._sceneFunc = function (ctx) {\n _super.prototype._sceneFunc.call(this, ctx);\n var PI2 = Math.PI * 2;\n var points = this.points();\n var tp = points;\n var fromTension = this.tension() !== 0 && points.length > 4;\n if (fromTension) {\n tp = this.getTensionPoints();\n }\n var n = points.length;\n var dx, dy;\n if (fromTension) {\n dx = points[n - 2] - (tp[tp.length - 2] + tp[tp.length - 4]) / 2;\n dy = points[n - 1] - (tp[tp.length - 1] + tp[tp.length - 3]) / 2;\n }\n else {\n dx = points[n - 2] - points[n - 4];\n dy = points[n - 1] - points[n - 3];\n }\n var radians = (Math.atan2(dy, dx) + PI2) % PI2;\n var length = this.pointerLength();\n var width = this.pointerWidth();\n ctx.save();\n ctx.beginPath();\n ctx.translate(points[n - 2], points[n - 1]);\n ctx.rotate(radians);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n if (this.pointerAtBeginning()) {\n ctx.save();\n ctx.translate(points[0], points[1]);\n if (fromTension) {\n dx = (tp[0] + tp[2]) / 2 - points[0];\n dy = (tp[1] + tp[3]) / 2 - points[1];\n }\n else {\n dx = points[2] - points[0];\n dy = points[3] - points[1];\n }\n ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n }\n var isDashEnabled = this.dashEnabled();\n if (isDashEnabled) {\n this.attrs.dashEnabled = false;\n ctx.setLineDash([]);\n }\n ctx.fillStrokeShape(this);\n if (isDashEnabled) {\n this.attrs.dashEnabled = true;\n }\n };\n Arrow.prototype.getSelfRect = function () {\n var lineRect = _super.prototype.getSelfRect.call(this);\n var offset = this.pointerWidth() / 2;\n return {\n x: lineRect.x - offset,\n y: lineRect.y - offset,\n width: lineRect.width + offset * 2,\n height: lineRect.height + offset * 2\n };\n };\n return Arrow;\n}(Line_1.Line));\nexports.Arrow = Arrow;\nArrow.prototype.className = 'Arrow';\nGlobal_1._registerNode(Arrow);\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerLength', 10, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerWidth', 10, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);\nUtil_1.Collection.mapMethods(Arrow);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Circle = (function (_super) {\n __extends(Circle, _super);\n function Circle() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Circle.prototype._sceneFunc = function (context) {\n context.beginPath();\n context.arc(0, 0, this.radius(), 0, Math.PI * 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Circle.prototype.getWidth = function () {\n return this.radius() * 2;\n };\n Circle.prototype.getHeight = function () {\n return this.radius() * 2;\n };\n Circle.prototype.setWidth = function (width) {\n if (this.radius() !== width / 2) {\n this.radius(width / 2);\n }\n };\n Circle.prototype.setHeight = function (height) {\n if (this.radius() !== height / 2) {\n this.radius(height / 2);\n }\n };\n return Circle;\n}(Shape_1.Shape));\nexports.Circle = Circle;\nCircle.prototype._centroid = true;\nCircle.prototype.className = 'Circle';\nCircle.prototype._attrsAffectingSize = ['radius'];\nGlobal_1._registerNode(Circle);\nFactory_1.Factory.addGetterSetter(Circle, 'radius', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Circle);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Ellipse = (function (_super) {\n __extends(Ellipse, _super);\n function Ellipse() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Ellipse.prototype._sceneFunc = function (context) {\n var rx = this.radiusX(), ry = this.radiusY();\n context.beginPath();\n context.save();\n if (rx !== ry) {\n context.scale(1, ry / rx);\n }\n context.arc(0, 0, rx, 0, Math.PI * 2, false);\n context.restore();\n context.closePath();\n context.fillStrokeShape(this);\n };\n Ellipse.prototype.getWidth = function () {\n return this.radiusX() * 2;\n };\n Ellipse.prototype.getHeight = function () {\n return this.radiusY() * 2;\n };\n Ellipse.prototype.setWidth = function (width) {\n this.radiusX(width / 2);\n };\n Ellipse.prototype.setHeight = function (height) {\n this.radiusY(height / 2);\n };\n return Ellipse;\n}(Shape_1.Shape));\nexports.Ellipse = Ellipse;\nEllipse.prototype.className = 'Ellipse';\nEllipse.prototype._centroid = true;\nEllipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];\nGlobal_1._registerNode(Ellipse);\nFactory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Ellipse);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Image = (function (_super) {\n __extends(Image, _super);\n function Image() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Image.prototype._useBufferCanvas = function () {\n return !!((this.hasShadow() || this.getAbsoluteOpacity() !== 1) &&\n this.hasStroke() &&\n this.getStage());\n };\n Image.prototype._sceneFunc = function (context) {\n var width = this.width(), height = this.height(), image = this.image(), cropWidth, cropHeight, params;\n if (image) {\n cropWidth = this.cropWidth();\n cropHeight = this.cropHeight();\n if (cropWidth && cropHeight) {\n params = [\n image,\n this.cropX(),\n this.cropY(),\n cropWidth,\n cropHeight,\n 0,\n 0,\n width,\n height\n ];\n }\n else {\n params = [image, 0, 0, width, height];\n }\n }\n if (this.hasFill() || this.hasStroke()) {\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n context.drawImage.apply(context, params);\n }\n };\n Image.prototype._hitFunc = function (context) {\n var width = this.width(), height = this.height();\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Image.prototype.getWidth = function () {\n var _a;\n var image = this.image();\n return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (image ? image.width : 0);\n };\n Image.prototype.getHeight = function () {\n var _a;\n var image = this.image();\n return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (image ? image.height : 0);\n };\n Image.fromURL = function (url, callback) {\n var img = Util_1.Util.createImageElement();\n img.onload = function () {\n var image = new Image({\n image: img\n });\n callback(image);\n };\n img.crossOrigin = 'Anonymous';\n img.src = url;\n };\n return Image;\n}(Shape_1.Shape));\nexports.Image = Image;\nImage.prototype.className = 'Image';\nGlobal_1._registerNode(Image);\nFactory_1.Factory.addGetterSetter(Image, 'image');\nFactory_1.Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);\nFactory_1.Factory.addGetterSetter(Image, 'cropX', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Image, 'cropY', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Image, 'cropWidth', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Image, 'cropHeight', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Image);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Group_1 = require(\"../Group\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar ATTR_CHANGE_LIST = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'padding',\n 'lineHeight',\n 'text',\n 'width'\n], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;\nvar Label = (function (_super) {\n __extends(Label, _super);\n function Label(config) {\n var _this = _super.call(this, config) || this;\n _this.on('add.konva', function (evt) {\n this._addListeners(evt.child);\n this._sync();\n });\n return _this;\n }\n Label.prototype.getText = function () {\n return this.find('Text')[0];\n };\n Label.prototype.getTag = function () {\n return this.find('Tag')[0];\n };\n Label.prototype._addListeners = function (text) {\n var that = this, n;\n var func = function () {\n that._sync();\n };\n for (n = 0; n < attrChangeListLen; n++) {\n text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);\n }\n };\n Label.prototype.getWidth = function () {\n return this.getText().width();\n };\n Label.prototype.getHeight = function () {\n return this.getText().height();\n };\n Label.prototype._sync = function () {\n var text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;\n if (text && tag) {\n width = text.width();\n height = text.height();\n pointerDirection = tag.pointerDirection();\n pointerWidth = tag.pointerWidth();\n pointerHeight = tag.pointerHeight();\n x = 0;\n y = 0;\n switch (pointerDirection) {\n case UP:\n x = width / 2;\n y = -1 * pointerHeight;\n break;\n case RIGHT:\n x = width + pointerWidth;\n y = height / 2;\n break;\n case DOWN:\n x = width / 2;\n y = height + pointerHeight;\n break;\n case LEFT:\n x = -1 * pointerWidth;\n y = height / 2;\n break;\n }\n tag.setAttrs({\n x: -1 * x,\n y: -1 * y,\n width: width,\n height: height\n });\n text.setAttrs({\n x: -1 * x,\n y: -1 * y\n });\n }\n };\n return Label;\n}(Group_1.Group));\nexports.Label = Label;\nLabel.prototype.className = 'Label';\nGlobal_1._registerNode(Label);\nUtil_1.Collection.mapMethods(Label);\nvar Tag = (function (_super) {\n __extends(Tag, _super);\n function Tag() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Tag.prototype._sceneFunc = function (context) {\n var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = Math.min(this.cornerRadius(), width / 2, height / 2);\n context.beginPath();\n if (!cornerRadius) {\n context.moveTo(0, 0);\n }\n else {\n context.moveTo(cornerRadius, 0);\n }\n if (pointerDirection === UP) {\n context.lineTo((width - pointerWidth) / 2, 0);\n context.lineTo(width / 2, -1 * pointerHeight);\n context.lineTo((width + pointerWidth) / 2, 0);\n }\n if (!cornerRadius) {\n context.lineTo(width, 0);\n }\n else {\n context.lineTo(width - cornerRadius, 0);\n context.arc(width - cornerRadius, cornerRadius, cornerRadius, (Math.PI * 3) / 2, 0, false);\n }\n if (pointerDirection === RIGHT) {\n context.lineTo(width, (height - pointerHeight) / 2);\n context.lineTo(width + pointerWidth, height / 2);\n context.lineTo(width, (height + pointerHeight) / 2);\n }\n if (!cornerRadius) {\n context.lineTo(width, height);\n }\n else {\n context.lineTo(width, height - cornerRadius);\n context.arc(width - cornerRadius, height - cornerRadius, cornerRadius, 0, Math.PI / 2, false);\n }\n if (pointerDirection === DOWN) {\n context.lineTo((width + pointerWidth) / 2, height);\n context.lineTo(width / 2, height + pointerHeight);\n context.lineTo((width - pointerWidth) / 2, height);\n }\n if (!cornerRadius) {\n context.lineTo(0, height);\n }\n else {\n context.lineTo(cornerRadius, height);\n context.arc(cornerRadius, height - cornerRadius, cornerRadius, Math.PI / 2, Math.PI, false);\n }\n if (pointerDirection === LEFT) {\n context.lineTo(0, (height + pointerHeight) / 2);\n context.lineTo(-1 * pointerWidth, height / 2);\n context.lineTo(0, (height - pointerHeight) / 2);\n }\n if (cornerRadius) {\n context.lineTo(0, cornerRadius);\n context.arc(cornerRadius, cornerRadius, cornerRadius, Math.PI, (Math.PI * 3) / 2, false);\n }\n context.closePath();\n context.fillStrokeShape(this);\n };\n Tag.prototype.getSelfRect = function () {\n var x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();\n if (direction === UP) {\n y -= pointerHeight;\n height += pointerHeight;\n }\n else if (direction === DOWN) {\n height += pointerHeight;\n }\n else if (direction === LEFT) {\n x -= pointerWidth * 1.5;\n width += pointerWidth;\n }\n else if (direction === RIGHT) {\n width += pointerWidth * 1.5;\n }\n return {\n x: x,\n y: y,\n width: width,\n height: height\n };\n };\n return Tag;\n}(Shape_1.Shape));\nexports.Tag = Tag;\nTag.prototype.className = 'Tag';\nGlobal_1._registerNode(Tag);\nFactory_1.Factory.addGetterSetter(Tag, 'pointerDirection', NONE);\nFactory_1.Factory.addGetterSetter(Tag, 'pointerWidth', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Tag, 'pointerHeight', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Tag, 'cornerRadius', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Tag);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar RegularPolygon = (function (_super) {\n __extends(RegularPolygon, _super);\n function RegularPolygon() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n RegularPolygon.prototype._sceneFunc = function (context) {\n var sides = this.sides(), radius = this.radius(), n, x, y;\n context.beginPath();\n context.moveTo(0, 0 - radius);\n for (n = 1; n < sides; n++) {\n x = radius * Math.sin((n * 2 * Math.PI) / sides);\n y = -1 * radius * Math.cos((n * 2 * Math.PI) / sides);\n context.lineTo(x, y);\n }\n context.closePath();\n context.fillStrokeShape(this);\n };\n RegularPolygon.prototype.getWidth = function () {\n return this.radius() * 2;\n };\n RegularPolygon.prototype.getHeight = function () {\n return this.radius() * 2;\n };\n RegularPolygon.prototype.setWidth = function (width) {\n this.radius(width / 2);\n };\n RegularPolygon.prototype.setHeight = function (height) {\n this.radius(height / 2);\n };\n return RegularPolygon;\n}(Shape_1.Shape));\nexports.RegularPolygon = RegularPolygon;\nRegularPolygon.prototype.className = 'RegularPolygon';\nRegularPolygon.prototype._centroid = true;\nRegularPolygon.prototype._attrsAffectingSize = ['radius'];\nGlobal_1._registerNode(RegularPolygon);\nFactory_1.Factory.addGetterSetter(RegularPolygon, 'radius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(RegularPolygon, 'sides', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(RegularPolygon);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar PIx2 = Math.PI * 2;\nvar Ring = (function (_super) {\n __extends(Ring, _super);\n function Ring() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Ring.prototype._sceneFunc = function (context) {\n context.beginPath();\n context.arc(0, 0, this.innerRadius(), 0, PIx2, false);\n context.moveTo(this.outerRadius(), 0);\n context.arc(0, 0, this.outerRadius(), PIx2, 0, true);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Ring.prototype.getWidth = function () {\n return this.outerRadius() * 2;\n };\n Ring.prototype.getHeight = function () {\n return this.outerRadius() * 2;\n };\n Ring.prototype.setWidth = function (width) {\n this.outerRadius(width / 2);\n };\n Ring.prototype.setHeight = function (height) {\n this.outerRadius(height / 2);\n };\n return Ring;\n}(Shape_1.Shape));\nexports.Ring = Ring;\nRing.prototype.className = 'Ring';\nRing.prototype._centroid = true;\nRing.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\nGlobal_1._registerNode(Ring);\nFactory_1.Factory.addGetterSetter(Ring, 'innerRadius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Ring, 'outerRadius', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Ring);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Animation_1 = require(\"../Animation\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Sprite = (function (_super) {\n __extends(Sprite, _super);\n function Sprite(config) {\n var _this = _super.call(this, config) || this;\n _this._updated = true;\n _this.anim = new Animation_1.Animation(function () {\n var updated = _this._updated;\n _this._updated = false;\n return updated;\n });\n _this.on('animationChange.konva', function () {\n this.frameIndex(0);\n });\n _this.on('frameIndexChange.konva', function () {\n this._updated = true;\n });\n _this.on('frameRateChange.konva', function () {\n if (!this.anim.isRunning()) {\n return;\n }\n clearInterval(this.interval);\n this._setInterval();\n });\n return _this;\n }\n Sprite.prototype._sceneFunc = function (context) {\n var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), x = set[ix4 + 0], y = set[ix4 + 1], width = set[ix4 + 2], height = set[ix4 + 3], image = this.image();\n if (this.hasFill() || this.hasStroke()) {\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n if (offsets) {\n var offset = offsets[anim], ix2 = index * 2;\n context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);\n }\n else {\n context.drawImage(image, x, y, width, height, 0, 0, width, height);\n }\n }\n };\n Sprite.prototype._hitFunc = function (context) {\n var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), width = set[ix4 + 2], height = set[ix4 + 3];\n context.beginPath();\n if (offsets) {\n var offset = offsets[anim];\n var ix2 = index * 2;\n context.rect(offset[ix2 + 0], offset[ix2 + 1], width, height);\n }\n else {\n context.rect(0, 0, width, height);\n }\n context.closePath();\n context.fillShape(this);\n };\n Sprite.prototype._useBufferCanvas = function () {\n return ((this.hasShadow() || this.getAbsoluteOpacity() !== 1) && this.hasStroke());\n };\n Sprite.prototype._setInterval = function () {\n var that = this;\n this.interval = setInterval(function () {\n that._updateIndex();\n }, 1000 / this.frameRate());\n };\n Sprite.prototype.start = function () {\n if (this.isRunning()) {\n return;\n }\n var layer = this.getLayer();\n this.anim.setLayers(layer);\n this._setInterval();\n this.anim.start();\n };\n Sprite.prototype.stop = function () {\n this.anim.stop();\n clearInterval(this.interval);\n };\n Sprite.prototype.isRunning = function () {\n return this.anim.isRunning();\n };\n Sprite.prototype._updateIndex = function () {\n var index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;\n if (index < len - 1) {\n this.frameIndex(index + 1);\n }\n else {\n this.frameIndex(0);\n }\n };\n return Sprite;\n}(Shape_1.Shape));\nexports.Sprite = Sprite;\nSprite.prototype.className = 'Sprite';\nGlobal_1._registerNode(Sprite);\nFactory_1.Factory.addGetterSetter(Sprite, 'animation');\nFactory_1.Factory.addGetterSetter(Sprite, 'animations');\nFactory_1.Factory.addGetterSetter(Sprite, 'frameOffsets');\nFactory_1.Factory.addGetterSetter(Sprite, 'image');\nFactory_1.Factory.addGetterSetter(Sprite, 'frameIndex', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Sprite, 'frameRate', 17, Validators_1.getNumberValidator());\nFactory_1.Factory.backCompat(Sprite, {\n index: 'frameIndex',\n getIndex: 'getFrameIndex',\n setIndex: 'setFrameIndex'\n});\nUtil_1.Collection.mapMethods(Sprite);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar Star = (function (_super) {\n __extends(Star, _super);\n function Star() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Star.prototype._sceneFunc = function (context) {\n var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();\n context.beginPath();\n context.moveTo(0, 0 - outerRadius);\n for (var n = 1; n < numPoints * 2; n++) {\n var radius = n % 2 === 0 ? outerRadius : innerRadius;\n var x = radius * Math.sin((n * Math.PI) / numPoints);\n var y = -1 * radius * Math.cos((n * Math.PI) / numPoints);\n context.lineTo(x, y);\n }\n context.closePath();\n context.fillStrokeShape(this);\n };\n Star.prototype.getWidth = function () {\n return this.outerRadius() * 2;\n };\n Star.prototype.getHeight = function () {\n return this.outerRadius() * 2;\n };\n Star.prototype.setWidth = function (width) {\n this.outerRadius(width / 2);\n };\n Star.prototype.setHeight = function (height) {\n this.outerRadius(height / 2);\n };\n return Star;\n}(Shape_1.Shape));\nexports.Star = Star;\nStar.prototype.className = 'Star';\nStar.prototype._centroid = true;\nStar.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\nGlobal_1._registerNode(Star);\nFactory_1.Factory.addGetterSetter(Star, 'numPoints', 5, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Star, 'innerRadius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Star, 'outerRadius', 0, Validators_1.getNumberValidator());\nUtil_1.Collection.mapMethods(Star);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Path_1 = require(\"./Path\");\nvar Text_1 = require(\"./Text\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_1 = require(\"../Global\");\nvar EMPTY_STRING = '', NORMAL = 'normal';\nfunction _fillFunc(context) {\n context.fillText(this.partialText, 0, 0);\n}\nfunction _strokeFunc(context) {\n context.strokeText(this.partialText, 0, 0);\n}\nvar TextPath = (function (_super) {\n __extends(TextPath, _super);\n function TextPath(config) {\n var _this = _super.call(this, config) || this;\n _this.dummyCanvas = Util_1.Util.createCanvasElement();\n _this.dataArray = [];\n _this.dataArray = Path_1.Path.parsePathData(_this.attrs.data);\n _this.on('dataChange.konva', function () {\n this.dataArray = Path_1.Path.parsePathData(this.attrs.data);\n this._setTextData();\n });\n _this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva', _this._setTextData);\n if (config && config['getKerning']) {\n Util_1.Util.warn('getKerning TextPath API is deprecated. Please use \"kerningFunc\" instead.');\n _this.kerningFunc(config['getKerning']);\n }\n _this._setTextData();\n return _this;\n }\n TextPath.prototype._sceneFunc = function (context) {\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', this.textBaseline());\n context.setAttr('textAlign', 'left');\n context.save();\n var textDecoration = this.textDecoration();\n var fill = this.fill();\n var fontSize = this.fontSize();\n var glyphInfo = this.glyphInfo;\n if (textDecoration === 'underline') {\n context.beginPath();\n }\n for (var i = 0; i < glyphInfo.length; i++) {\n context.save();\n var p0 = glyphInfo[i].p0;\n context.translate(p0.x, p0.y);\n context.rotate(glyphInfo[i].rotation);\n this.partialText = glyphInfo[i].text;\n context.fillStrokeShape(this);\n if (textDecoration === 'underline') {\n if (i === 0) {\n context.moveTo(0, fontSize / 2 + 1);\n }\n context.lineTo(fontSize, fontSize / 2 + 1);\n }\n context.restore();\n }\n if (textDecoration === 'underline') {\n context.strokeStyle = fill;\n context.lineWidth = fontSize / 20;\n context.stroke();\n }\n context.restore();\n };\n TextPath.prototype._hitFunc = function (context) {\n context.beginPath();\n var glyphInfo = this.glyphInfo;\n if (glyphInfo.length >= 1) {\n var p0 = glyphInfo[0].p0;\n context.moveTo(p0.x, p0.y);\n }\n for (var i = 0; i < glyphInfo.length; i++) {\n var p1 = glyphInfo[i].p1;\n context.lineTo(p1.x, p1.y);\n }\n context.setAttr('lineWidth', this.fontSize());\n context.setAttr('strokeStyle', this.colorKey);\n context.stroke();\n };\n TextPath.prototype.getTextWidth = function () {\n return this.textWidth;\n };\n TextPath.prototype.getTextHeight = function () {\n Util_1.Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n };\n TextPath.prototype.setText = function (text) {\n return Text_1.Text.prototype.setText.call(this, text);\n };\n TextPath.prototype._getContextFont = function () {\n return Text_1.Text.prototype._getContextFont.call(this);\n };\n TextPath.prototype._getTextSize = function (text) {\n var dummyCanvas = this.dummyCanvas;\n var _context = dummyCanvas.getContext('2d');\n _context.save();\n _context.font = this._getContextFont();\n var metrics = _context.measureText(text);\n _context.restore();\n return {\n width: metrics.width,\n height: parseInt(this.attrs.fontSize, 10)\n };\n };\n TextPath.prototype._setTextData = function () {\n var that = this;\n var size = this._getTextSize(this.attrs.text);\n var letterSpacing = this.letterSpacing();\n var align = this.align();\n var kerningFunc = this.kerningFunc();\n this.textWidth = size.width;\n this.textHeight = size.height;\n var textFullWidth = Math.max(this.textWidth + ((this.attrs.text || '').length - 1) * letterSpacing, 0);\n this.glyphInfo = [];\n var fullPathWidth = 0;\n for (var l = 0; l < that.dataArray.length; l++) {\n if (that.dataArray[l].pathLength > 0) {\n fullPathWidth += that.dataArray[l].pathLength;\n }\n }\n var offset = 0;\n if (align === 'center') {\n offset = Math.max(0, fullPathWidth / 2 - textFullWidth / 2);\n }\n if (align === 'right') {\n offset = Math.max(0, fullPathWidth - textFullWidth);\n }\n var charArr = this.text().split('');\n var spacesNumber = this.text().split(' ').length - 1;\n var p0, p1, pathCmd;\n var pIndex = -1;\n var currentT = 0;\n var getNextPathSegment = function () {\n currentT = 0;\n var pathData = that.dataArray;\n for (var j = pIndex + 1; j < pathData.length; j++) {\n if (pathData[j].pathLength > 0) {\n pIndex = j;\n return pathData[j];\n }\n else if (pathData[j].command === 'M') {\n p0 = {\n x: pathData[j].points[0],\n y: pathData[j].points[1]\n };\n }\n }\n return {};\n };\n var findSegmentToFitCharacter = function (c) {\n var glyphWidth = that._getTextSize(c).width + letterSpacing;\n if (c === ' ' && align === 'justify') {\n glyphWidth += (fullPathWidth - textFullWidth) / spacesNumber;\n }\n var currLen = 0;\n var attempts = 0;\n p1 = undefined;\n while (Math.abs(glyphWidth - currLen) / glyphWidth > 0.01 &&\n attempts < 25) {\n attempts++;\n var cumulativePathLength = currLen;\n while (pathCmd === undefined) {\n pathCmd = getNextPathSegment();\n if (pathCmd &&\n cumulativePathLength + pathCmd.pathLength < glyphWidth) {\n cumulativePathLength += pathCmd.pathLength;\n pathCmd = undefined;\n }\n }\n if (pathCmd === {} || p0 === undefined) {\n return undefined;\n }\n var needNewSegment = false;\n switch (pathCmd.command) {\n case 'L':\n if (Path_1.Path.getLineLength(p0.x, p0.y, pathCmd.points[0], pathCmd.points[1]) > glyphWidth) {\n p1 = Path_1.Path.getPointOnLine(glyphWidth, p0.x, p0.y, pathCmd.points[0], pathCmd.points[1], p0.x, p0.y);\n }\n else {\n pathCmd = undefined;\n }\n break;\n case 'A':\n var start = pathCmd.points[4];\n var dTheta = pathCmd.points[5];\n var end = pathCmd.points[4] + dTheta;\n if (currentT === 0) {\n currentT = start + 0.00000001;\n }\n else if (glyphWidth > currLen) {\n currentT += ((Math.PI / 180.0) * dTheta) / Math.abs(dTheta);\n }\n else {\n currentT -= ((Math.PI / 360.0) * dTheta) / Math.abs(dTheta);\n }\n if ((dTheta < 0 && currentT < end) ||\n (dTheta >= 0 && currentT > end)) {\n currentT = end;\n needNewSegment = true;\n }\n p1 = Path_1.Path.getPointOnEllipticalArc(pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], currentT, pathCmd.points[6]);\n break;\n case 'C':\n if (currentT === 0) {\n if (glyphWidth > pathCmd.pathLength) {\n currentT = 0.00000001;\n }\n else {\n currentT = glyphWidth / pathCmd.pathLength;\n }\n }\n else if (glyphWidth > currLen) {\n currentT += (glyphWidth - currLen) / pathCmd.pathLength;\n }\n else {\n currentT -= (currLen - glyphWidth) / pathCmd.pathLength;\n }\n if (currentT > 1.0) {\n currentT = 1.0;\n needNewSegment = true;\n }\n p1 = Path_1.Path.getPointOnCubicBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], pathCmd.points[4], pathCmd.points[5]);\n break;\n case 'Q':\n if (currentT === 0) {\n currentT = glyphWidth / pathCmd.pathLength;\n }\n else if (glyphWidth > currLen) {\n currentT += (glyphWidth - currLen) / pathCmd.pathLength;\n }\n else {\n currentT -= (currLen - glyphWidth) / pathCmd.pathLength;\n }\n if (currentT > 1.0) {\n currentT = 1.0;\n needNewSegment = true;\n }\n p1 = Path_1.Path.getPointOnQuadraticBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3]);\n break;\n }\n if (p1 !== undefined) {\n currLen = Path_1.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);\n }\n if (needNewSegment) {\n needNewSegment = false;\n pathCmd = undefined;\n }\n }\n };\n var testChar = 'C';\n var glyphWidth = that._getTextSize(testChar).width + letterSpacing;\n var lettersInOffset = offset / glyphWidth - 1;\n for (var k = 0; k < lettersInOffset; k++) {\n findSegmentToFitCharacter(testChar);\n if (p0 === undefined || p1 === undefined) {\n break;\n }\n p0 = p1;\n }\n for (var i = 0; i < charArr.length; i++) {\n findSegmentToFitCharacter(charArr[i]);\n if (p0 === undefined || p1 === undefined) {\n break;\n }\n var width = Path_1.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);\n var kern = 0;\n if (kerningFunc) {\n try {\n kern = kerningFunc(charArr[i - 1], charArr[i]) * this.fontSize();\n }\n catch (e) {\n kern = 0;\n }\n }\n p0.x += kern;\n p1.x += kern;\n this.textWidth += kern;\n var midpoint = Path_1.Path.getPointOnLine(kern + width / 2.0, p0.x, p0.y, p1.x, p1.y);\n var rotation = Math.atan2(p1.y - p0.y, p1.x - p0.x);\n this.glyphInfo.push({\n transposeX: midpoint.x,\n transposeY: midpoint.y,\n text: charArr[i],\n rotation: rotation,\n p0: p0,\n p1: p1\n });\n p0 = p1;\n }\n };\n TextPath.prototype.getSelfRect = function () {\n if (!this.glyphInfo.length) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0\n };\n }\n var points = [];\n this.glyphInfo.forEach(function (info) {\n points.push(info.p0.x);\n points.push(info.p0.y);\n points.push(info.p1.x);\n points.push(info.p1.y);\n });\n var minX = points[0] || 0;\n var maxX = points[0] || 0;\n var minY = points[1] || 0;\n var maxY = points[1] || 0;\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n var fontSize = this.fontSize();\n return {\n x: minX - fontSize / 2,\n y: minY - fontSize / 2,\n width: maxX - minX + fontSize,\n height: maxY - minY + fontSize\n };\n };\n return TextPath;\n}(Shape_1.Shape));\nexports.TextPath = TextPath;\nTextPath.prototype._fillFunc = _fillFunc;\nTextPath.prototype._strokeFunc = _strokeFunc;\nTextPath.prototype._fillFuncHit = _fillFunc;\nTextPath.prototype._strokeFuncHit = _strokeFunc;\nTextPath.prototype.className = 'TextPath';\nTextPath.prototype._attrsAffectingSize = ['text', 'fontSize', 'data'];\nGlobal_1._registerNode(TextPath);\nFactory_1.Factory.addGetterSetter(TextPath, 'data');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontFamily', 'Arial');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontSize', 12, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(TextPath, 'fontStyle', NORMAL);\nFactory_1.Factory.addGetterSetter(TextPath, 'align', 'left');\nFactory_1.Factory.addGetterSetter(TextPath, 'letterSpacing', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(TextPath, 'textBaseline', 'middle');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontVariant', NORMAL);\nFactory_1.Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING);\nFactory_1.Factory.addGetterSetter(TextPath, 'textDecoration', null);\nFactory_1.Factory.addGetterSetter(TextPath, 'kerningFunc', null);\nUtil_1.Collection.mapMethods(TextPath);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Shape_1 = require(\"../Shape\");\nvar Rect_1 = require(\"./Rect\");\nvar Group_1 = require(\"../Group\");\nvar Global_1 = require(\"../Global\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_2 = require(\"../Global\");\nvar EVENTS_NAME = 'tr-konva';\nvar ATTR_CHANGE_LIST = [\n 'resizeEnabledChange',\n 'rotateAnchorOffsetChange',\n 'rotateEnabledChange',\n 'enabledAnchorsChange',\n 'anchorSizeChange',\n 'borderEnabledChange',\n 'borderStrokeChange',\n 'borderStrokeWidthChange',\n 'borderDashChange',\n 'anchorStrokeChange',\n 'anchorStrokeWidthChange',\n 'anchorFillChange',\n 'anchorCornerRadiusChange',\n 'ignoreStrokeChange',\n]\n .map(function (e) { return e + (\".\" + EVENTS_NAME); })\n .join(' ');\nvar NODES_RECT = 'nodesRect';\nvar TRANSFORM_CHANGE_STR = [\n 'widthChange',\n 'heightChange',\n 'scaleXChange',\n 'scaleYChange',\n 'skewXChange',\n 'skewYChange',\n 'rotationChange',\n 'offsetXChange',\n 'offsetYChange',\n 'transformsEnabledChange',\n 'strokeWidthChange',\n]\n .map(function (e) { return e + (\".\" + EVENTS_NAME); })\n .join(' ');\nvar ANGLES = {\n 'top-left': -45,\n 'top-center': 0,\n 'top-right': 45,\n 'middle-right': -90,\n 'middle-left': 90,\n 'bottom-left': -135,\n 'bottom-center': 180,\n 'bottom-right': 135,\n};\nvar TOUCH_DEVICE = 'ontouchstart' in Global_1.Konva._global;\nfunction getCursor(anchorName, rad) {\n if (anchorName === 'rotater') {\n return 'crosshair';\n }\n rad += Util_1.Util._degToRad(ANGLES[anchorName] || 0);\n var angle = ((Util_1.Util._radToDeg(rad) % 360) + 360) % 360;\n if (Util_1.Util._inRange(angle, 315 + 22.5, 360) || Util_1.Util._inRange(angle, 0, 22.5)) {\n return 'ns-resize';\n }\n else if (Util_1.Util._inRange(angle, 45 - 22.5, 45 + 22.5)) {\n return 'nesw-resize';\n }\n else if (Util_1.Util._inRange(angle, 90 - 22.5, 90 + 22.5)) {\n return 'ew-resize';\n }\n else if (Util_1.Util._inRange(angle, 135 - 22.5, 135 + 22.5)) {\n return 'nwse-resize';\n }\n else if (Util_1.Util._inRange(angle, 180 - 22.5, 180 + 22.5)) {\n return 'ns-resize';\n }\n else if (Util_1.Util._inRange(angle, 225 - 22.5, 225 + 22.5)) {\n return 'nesw-resize';\n }\n else if (Util_1.Util._inRange(angle, 270 - 22.5, 270 + 22.5)) {\n return 'ew-resize';\n }\n else if (Util_1.Util._inRange(angle, 315 - 22.5, 315 + 22.5)) {\n return 'nwse-resize';\n }\n else {\n Util_1.Util.error('Transformer has unknown angle for cursor detection: ' + angle);\n return 'pointer';\n }\n}\nvar ANCHORS_NAMES = [\n 'top-left',\n 'top-center',\n 'top-right',\n 'middle-right',\n 'middle-left',\n 'bottom-left',\n 'bottom-center',\n 'bottom-right',\n];\nvar MAX_SAFE_INTEGER = 100000000;\nfunction getCenter(shape) {\n return {\n x: shape.x +\n (shape.width / 2) * Math.cos(shape.rotation) +\n (shape.height / 2) * Math.sin(-shape.rotation),\n y: shape.y +\n (shape.height / 2) * Math.cos(shape.rotation) +\n (shape.width / 2) * Math.sin(shape.rotation),\n };\n}\nfunction rotateAroundPoint(shape, angleRad, point) {\n var x = point.x +\n (shape.x - point.x) * Math.cos(angleRad) -\n (shape.y - point.y) * Math.sin(angleRad);\n var y = point.y +\n (shape.x - point.x) * Math.sin(angleRad) +\n (shape.y - point.y) * Math.cos(angleRad);\n return __assign(__assign({}, shape), { rotation: shape.rotation + angleRad, x: x,\n y: y });\n}\nfunction rotateAroundCenter(shape, deltaRad) {\n var center = getCenter(shape);\n return rotateAroundPoint(shape, deltaRad, center);\n}\nfunction getSnap(snaps, newRotationRad, tol) {\n var snapped = newRotationRad;\n for (var i = 0; i < snaps.length; i++) {\n var angle = Global_1.Konva.getAngle(snaps[i]);\n var absDiff = Math.abs(angle - newRotationRad) % (Math.PI * 2);\n var dif = Math.min(absDiff, Math.PI * 2 - absDiff);\n if (dif < tol) {\n snapped = angle;\n }\n }\n return snapped;\n}\nvar Transformer = (function (_super) {\n __extends(Transformer, _super);\n function Transformer(config) {\n var _this = _super.call(this, config) || this;\n _this._transforming = false;\n _this._createElements();\n _this._handleMouseMove = _this._handleMouseMove.bind(_this);\n _this._handleMouseUp = _this._handleMouseUp.bind(_this);\n _this.update = _this.update.bind(_this);\n _this.on(ATTR_CHANGE_LIST, _this.update);\n if (_this.getNode()) {\n _this.update();\n }\n return _this;\n }\n Transformer.prototype.attachTo = function (node) {\n this.setNode(node);\n return this;\n };\n Transformer.prototype.setNode = function (node) {\n Util_1.Util.warn('tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.');\n return this.setNodes([node]);\n };\n Transformer.prototype.getNode = function () {\n return this._nodes && this._nodes[0];\n };\n Transformer.prototype.setNodes = function (nodes) {\n var _this = this;\n if (nodes === void 0) { nodes = []; }\n if (this._nodes && this._nodes.length) {\n this.detach();\n }\n this._nodes = nodes;\n if (nodes.length === 1) {\n this.rotation(nodes[0].rotation());\n }\n else {\n this.rotation(0);\n }\n this._nodes.forEach(function (node) {\n var additionalEvents = node._attrsAffectingSize\n .map(function (prop) { return prop + 'Change.' + EVENTS_NAME; })\n .join(' ');\n var onChange = function () {\n _this._resetTransformCache();\n if (!_this._transforming) {\n _this.update();\n }\n };\n node.on(additionalEvents, onChange);\n node.on(TRANSFORM_CHANGE_STR, onChange);\n node.on(\"_clearTransformCache.\" + EVENTS_NAME, onChange);\n node.on(\"xChange.\" + EVENTS_NAME + \" yChange.\" + EVENTS_NAME, onChange);\n _this._proxyDrag(node);\n });\n this._resetTransformCache();\n var elementsCreated = !!this.findOne('.top-left');\n if (elementsCreated) {\n this.update();\n }\n return this;\n };\n Transformer.prototype._proxyDrag = function (node) {\n var _this = this;\n var lastPos;\n node.on(\"dragstart.\" + EVENTS_NAME, function () {\n lastPos = node.getAbsolutePosition();\n });\n node.on(\"dragmove.\" + EVENTS_NAME, function () {\n if (!lastPos) {\n return;\n }\n var abs = node.getAbsolutePosition();\n var dx = abs.x - lastPos.x;\n var dy = abs.y - lastPos.y;\n _this.nodes().forEach(function (otherNode) {\n if (otherNode === node) {\n return;\n }\n if (otherNode.isDragging()) {\n return;\n }\n var otherAbs = otherNode.getAbsolutePosition();\n otherNode.setAbsolutePosition({\n x: otherAbs.x + dx,\n y: otherAbs.y + dy,\n });\n otherNode.startDrag();\n });\n lastPos = null;\n });\n };\n Transformer.prototype.getNodes = function () {\n return this._nodes;\n };\n Transformer.prototype.getActiveAnchor = function () {\n return this._movingAnchorName;\n };\n Transformer.prototype.detach = function () {\n if (this._nodes) {\n this._nodes.forEach(function (node) {\n node.off('.' + EVENTS_NAME);\n });\n }\n this._nodes = [];\n this._resetTransformCache();\n };\n Transformer.prototype._resetTransformCache = function () {\n this._clearCache(NODES_RECT);\n this._clearCache('transform');\n this._clearSelfAndDescendantCache('absoluteTransform');\n };\n Transformer.prototype._getNodeRect = function () {\n return this._getCache(NODES_RECT, this.__getNodeRect);\n };\n Transformer.prototype.__getNodeShape = function (node, rot, relative) {\n if (rot === void 0) { rot = this.rotation(); }\n var rect = node.getClientRect({\n skipTransform: true,\n skipShadow: true,\n skipStroke: this.ignoreStroke(),\n });\n var absScale = node.getAbsoluteScale(relative);\n var absPos = node.getAbsolutePosition(relative);\n var dx = rect.x * absScale.x - node.offsetX() * absScale.x;\n var dy = rect.y * absScale.y - node.offsetY() * absScale.y;\n var rotation = (Global_1.Konva.getAngle(node.getAbsoluteRotation()) + Math.PI * 2) %\n (Math.PI * 2);\n var box = {\n x: absPos.x + dx * Math.cos(rotation) + dy * Math.sin(-rotation),\n y: absPos.y + dy * Math.cos(rotation) + dx * Math.sin(rotation),\n width: rect.width * absScale.x,\n height: rect.height * absScale.y,\n rotation: rotation,\n };\n return rotateAroundPoint(box, -Global_1.Konva.getAngle(rot), {\n x: 0,\n y: 0,\n });\n };\n Transformer.prototype.__getNodeRect = function () {\n var _this = this;\n var node = this.getNode();\n if (!node) {\n return {\n x: -MAX_SAFE_INTEGER,\n y: -MAX_SAFE_INTEGER,\n width: 0,\n height: 0,\n rotation: 0,\n };\n }\n var totalPoints = [];\n this.nodes().map(function (node) {\n var box = node.getClientRect({\n skipTransform: true,\n skipShadow: true,\n skipStroke: _this.ignoreStroke(),\n });\n var points = [\n { x: box.x, y: box.y },\n { x: box.x + box.width, y: box.y },\n { x: box.x + box.width, y: box.y + box.height },\n { x: box.x, y: box.y + box.height },\n ];\n var trans = node.getAbsoluteTransform();\n points.forEach(function (point) {\n var transformed = trans.point(point);\n totalPoints.push(transformed);\n });\n });\n var tr = new Util_1.Transform();\n tr.rotate(-Global_1.Konva.getAngle(this.rotation()));\n var minX, minY, maxX, maxY;\n totalPoints.forEach(function (point) {\n var transformed = tr.point(point);\n if (minX === undefined) {\n minX = maxX = transformed.x;\n minY = maxY = transformed.y;\n }\n minX = Math.min(minX, transformed.x);\n minY = Math.min(minY, transformed.y);\n maxX = Math.max(maxX, transformed.x);\n maxY = Math.max(maxY, transformed.y);\n });\n tr.invert();\n var p = tr.point({ x: minX, y: minY });\n return {\n x: p.x,\n y: p.y,\n width: maxX - minX,\n height: maxY - minY,\n rotation: Global_1.Konva.getAngle(this.rotation()),\n };\n };\n Transformer.prototype.getX = function () {\n return this._getNodeRect().x;\n };\n Transformer.prototype.getY = function () {\n return this._getNodeRect().y;\n };\n Transformer.prototype.getWidth = function () {\n return this._getNodeRect().width;\n };\n Transformer.prototype.getHeight = function () {\n return this._getNodeRect().height;\n };\n Transformer.prototype._createElements = function () {\n this._createBack();\n ANCHORS_NAMES.forEach(function (name) {\n this._createAnchor(name);\n }.bind(this));\n this._createAnchor('rotater');\n };\n Transformer.prototype._createAnchor = function (name) {\n var _this = this;\n var anchor = new Rect_1.Rect({\n stroke: 'rgb(0, 161, 255)',\n fill: 'white',\n strokeWidth: 1,\n name: name + ' _anchor',\n dragDistance: 0,\n draggable: true,\n hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',\n });\n var self = this;\n anchor.on('mousedown touchstart', function (e) {\n self._handleMouseDown(e);\n });\n anchor.on('dragstart', function (e) {\n anchor.stopDrag();\n e.cancelBubble = true;\n });\n anchor.on('dragend', function (e) {\n e.cancelBubble = true;\n });\n anchor.on('mouseenter', function () {\n var rad = Global_1.Konva.getAngle(_this.rotation());\n var cursor = getCursor(name, rad);\n anchor.getStage().content.style.cursor = cursor;\n _this._cursorChange = true;\n });\n anchor.on('mouseout', function () {\n anchor.getStage().content.style.cursor = '';\n _this._cursorChange = false;\n });\n this.add(anchor);\n };\n Transformer.prototype._createBack = function () {\n var _this = this;\n var back = new Shape_1.Shape({\n name: 'back',\n width: 0,\n height: 0,\n draggable: true,\n sceneFunc: function (ctx) {\n var tr = this.getParent();\n var padding = tr.padding();\n ctx.beginPath();\n ctx.rect(-padding, -padding, this.width() + padding * 2, this.height() + padding * 2);\n ctx.moveTo(this.width() / 2, -padding);\n if (tr.rotateEnabled()) {\n ctx.lineTo(this.width() / 2, -tr.rotateAnchorOffset() * Util_1.Util._sign(this.height()) - padding);\n }\n ctx.fillStrokeShape(this);\n },\n hitFunc: function (ctx, shape) {\n if (!_this.shouldOverdrawWholeArea()) {\n return;\n }\n var padding = _this.padding();\n ctx.beginPath();\n ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);\n ctx.fillStrokeShape(shape);\n },\n });\n this.add(back);\n this._proxyDrag(back);\n };\n Transformer.prototype._handleMouseDown = function (e) {\n this._movingAnchorName = e.target.name().split(' ')[0];\n var attrs = this._getNodeRect();\n var width = attrs.width;\n var height = attrs.height;\n var hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));\n this.sin = Math.abs(height / hypotenuse);\n this.cos = Math.abs(width / hypotenuse);\n window.addEventListener('mousemove', this._handleMouseMove);\n window.addEventListener('touchmove', this._handleMouseMove);\n window.addEventListener('mouseup', this._handleMouseUp, true);\n window.addEventListener('touchend', this._handleMouseUp, true);\n this._transforming = true;\n var ap = e.target.getAbsolutePosition();\n var pos = e.target.getStage().getPointerPosition();\n this._anchorDragOffset = {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n };\n this._fire('transformstart', { evt: e, target: this.getNode() });\n this.getNode()._fire('transformstart', { evt: e, target: this.getNode() });\n };\n Transformer.prototype._handleMouseMove = function (e) {\n var x, y, newHypotenuse;\n var anchorNode = this.findOne('.' + this._movingAnchorName);\n var stage = anchorNode.getStage();\n stage.setPointersPositions(e);\n var pp = stage.getPointerPosition();\n var newNodePos = {\n x: pp.x - this._anchorDragOffset.x,\n y: pp.y - this._anchorDragOffset.y,\n };\n var oldAbs = anchorNode.getAbsolutePosition();\n anchorNode.setAbsolutePosition(newNodePos);\n var newAbs = anchorNode.getAbsolutePosition();\n if (oldAbs.x === newAbs.x && oldAbs.y === newAbs.y) {\n return;\n }\n if (this._movingAnchorName === 'rotater') {\n var attrs = this._getNodeRect();\n x = anchorNode.x() - attrs.width / 2;\n y = -anchorNode.y() + attrs.height / 2;\n var delta = Math.atan2(-y, x) + Math.PI / 2;\n if (attrs.height < 0) {\n delta -= Math.PI;\n }\n var oldRotation = Global_1.Konva.getAngle(this.rotation());\n var newRotation = oldRotation + delta;\n var tol = Global_1.Konva.getAngle(this.rotationSnapTolerance());\n var snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);\n var diff = snappedRot - attrs.rotation;\n var shape = rotateAroundCenter(attrs, diff);\n this._fitNodesInto(shape, e);\n return;\n }\n var keepProportion = this.keepRatio() || e.shiftKey;\n var centeredScaling = this.centeredScaling() || e.altKey;\n if (this._movingAnchorName === 'top-left') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.bottom-right').x(),\n y: this.findOne('.bottom-right').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n var reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.top-left').x(comparePoint.x - x);\n this.findOne('.top-left').y(comparePoint.y - y);\n }\n }\n else if (this._movingAnchorName === 'top-center') {\n this.findOne('.top-left').y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'top-right') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.bottom-left').x(),\n y: this.findOne('.bottom-left').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n var reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.top-right').x(comparePoint.x + x);\n this.findOne('.top-right').y(comparePoint.y - y);\n }\n var pos = anchorNode.position();\n this.findOne('.top-left').y(pos.y);\n this.findOne('.bottom-right').x(pos.x);\n }\n else if (this._movingAnchorName === 'middle-left') {\n this.findOne('.top-left').x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'middle-right') {\n this.findOne('.bottom-right').x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'bottom-left') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.top-right').x(),\n y: this.findOne('.top-right').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n var reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;\n var reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n anchorNode.x(comparePoint.x - x);\n anchorNode.y(comparePoint.y + y);\n }\n pos = anchorNode.position();\n this.findOne('.top-left').x(pos.x);\n this.findOne('.bottom-right').y(pos.y);\n }\n else if (this._movingAnchorName === 'bottom-center') {\n this.findOne('.bottom-right').y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'bottom-right') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.top-left').x(),\n y: this.findOne('.top-left').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n var reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.bottom-right').x(comparePoint.x + x);\n this.findOne('.bottom-right').y(comparePoint.y + y);\n }\n }\n else {\n console.error(new Error('Wrong position argument of selection resizer: ' +\n this._movingAnchorName));\n }\n var centeredScaling = this.centeredScaling() || e.altKey;\n if (centeredScaling) {\n var topLeft = this.findOne('.top-left');\n var bottomRight = this.findOne('.bottom-right');\n var topOffsetX = topLeft.x();\n var topOffsetY = topLeft.y();\n var bottomOffsetX = this.getWidth() - bottomRight.x();\n var bottomOffsetY = this.getHeight() - bottomRight.y();\n bottomRight.move({\n x: -topOffsetX,\n y: -topOffsetY,\n });\n topLeft.move({\n x: bottomOffsetX,\n y: bottomOffsetY,\n });\n }\n var absPos = this.findOne('.top-left').getAbsolutePosition();\n x = absPos.x;\n y = absPos.y;\n var width = this.findOne('.bottom-right').x() - this.findOne('.top-left').x();\n var height = this.findOne('.bottom-right').y() - this.findOne('.top-left').y();\n this._fitNodesInto({\n x: x,\n y: y,\n width: width,\n height: height,\n rotation: Global_1.Konva.getAngle(this.rotation()),\n }, e);\n };\n Transformer.prototype._handleMouseUp = function (e) {\n this._removeEvents(e);\n };\n Transformer.prototype.getAbsoluteTransform = function () {\n return this.getTransform();\n };\n Transformer.prototype._removeEvents = function (e) {\n if (this._transforming) {\n this._transforming = false;\n window.removeEventListener('mousemove', this._handleMouseMove);\n window.removeEventListener('touchmove', this._handleMouseMove);\n window.removeEventListener('mouseup', this._handleMouseUp, true);\n window.removeEventListener('touchend', this._handleMouseUp, true);\n var node = this.getNode();\n this._fire('transformend', { evt: e, target: node });\n if (node) {\n node.fire('transformend', { evt: e, target: node });\n }\n this._movingAnchorName = null;\n }\n };\n Transformer.prototype._fitNodesInto = function (newAttrs, evt) {\n var _this = this;\n var oldAttrs = this._getNodeRect();\n var minSize = 1;\n if (Util_1.Util._inRange(newAttrs.width, -this.padding() * 2 - minSize, minSize)) {\n this.update();\n return;\n }\n if (Util_1.Util._inRange(newAttrs.height, -this.padding() * 2 - minSize, minSize)) {\n this.update();\n return;\n }\n var allowNegativeScale = true;\n var t = new Util_1.Transform();\n t.rotate(Global_1.Konva.getAngle(this.rotation()));\n if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('left') >= 0) {\n var offset = t.point({\n x: -this.padding() * 2,\n y: 0,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n newAttrs.width += this.padding() * 2;\n this._movingAnchorName = this._movingAnchorName.replace('left', 'right');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n if (!allowNegativeScale) {\n this.update();\n return;\n }\n }\n else if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('right') >= 0) {\n var offset = t.point({\n x: this.padding() * 2,\n y: 0,\n });\n this._movingAnchorName = this._movingAnchorName.replace('right', 'left');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.width += this.padding() * 2;\n if (!allowNegativeScale) {\n this.update();\n return;\n }\n }\n if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('top') >= 0) {\n var offset = t.point({\n x: 0,\n y: -this.padding() * 2,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n this._movingAnchorName = this._movingAnchorName.replace('top', 'bottom');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.height += this.padding() * 2;\n if (!allowNegativeScale) {\n this.update();\n return;\n }\n }\n else if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('bottom') >= 0) {\n var offset = t.point({\n x: 0,\n y: this.padding() * 2,\n });\n this._movingAnchorName = this._movingAnchorName.replace('bottom', 'top');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.height += this.padding() * 2;\n if (!allowNegativeScale) {\n this.update();\n return;\n }\n }\n if (this.boundBoxFunc()) {\n var bounded = this.boundBoxFunc()(oldAttrs, newAttrs);\n if (bounded) {\n newAttrs = bounded;\n }\n else {\n Util_1.Util.warn('boundBoxFunc returned falsy. You should return new bound rect from it!');\n }\n }\n var baseSize = 10000000;\n var oldTr = new Util_1.Transform();\n oldTr.translate(oldAttrs.x, oldAttrs.y);\n oldTr.rotate(oldAttrs.rotation);\n oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);\n var newTr = new Util_1.Transform();\n newTr.translate(newAttrs.x, newAttrs.y);\n newTr.rotate(newAttrs.rotation);\n newTr.scale(newAttrs.width / baseSize, newAttrs.height / baseSize);\n var delta = newTr.multiply(oldTr.invert());\n this._nodes.forEach(function (node) {\n var parentTransform = node.getParent().getAbsoluteTransform();\n var localTransform = node.getTransform().copy();\n localTransform.translate(node.offsetX(), node.offsetY());\n var newLocalTransform = new Util_1.Transform();\n newLocalTransform\n .multiply(parentTransform.copy().invert())\n .multiply(delta)\n .multiply(parentTransform)\n .multiply(localTransform);\n var attrs = newLocalTransform.decompose();\n node._batchTransformChanges(function () {\n node.setAttrs(attrs);\n });\n _this._fire('transform', { evt: evt, target: node });\n node._fire('transform', { evt: evt, target: node });\n });\n this.rotation(Util_1.Util._getRotation(newAttrs.rotation));\n this._resetTransformCache();\n this.update();\n this.getLayer().batchDraw();\n };\n Transformer.prototype.forceUpdate = function () {\n this._resetTransformCache();\n this.update();\n };\n Transformer.prototype._batchChangeChild = function (selector, attrs) {\n var anchor = this.findOne(selector);\n anchor._batchTransformChanges(function () {\n anchor.setAttrs(attrs);\n });\n };\n Transformer.prototype.update = function () {\n var _this = this;\n var attrs = this._getNodeRect();\n this.rotation(Util_1.Util._getRotation(attrs.rotation));\n var width = attrs.width;\n var height = attrs.height;\n var enabledAnchors = this.enabledAnchors();\n var resizeEnabled = this.resizeEnabled();\n var padding = this.padding();\n var anchorSize = this.anchorSize();\n this.find('._anchor').each(function (node) {\n node._batchTransformChanges(function () {\n node.setAttrs({\n width: anchorSize,\n height: anchorSize,\n offsetX: anchorSize / 2,\n offsetY: anchorSize / 2,\n stroke: _this.anchorStroke(),\n strokeWidth: _this.anchorStrokeWidth(),\n fill: _this.anchorFill(),\n cornerRadius: _this.anchorCornerRadius(),\n });\n });\n });\n this._batchChangeChild('.top-left', {\n x: 0,\n y: 0,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-left') >= 0,\n });\n this._batchChangeChild('.top-center', {\n x: width / 2,\n y: 0,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-center') >= 0,\n });\n this._batchChangeChild('.top-right', {\n x: width,\n y: 0,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-right') >= 0,\n });\n this._batchChangeChild('.middle-left', {\n x: 0,\n y: height / 2,\n offsetX: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-left') >= 0,\n });\n this._batchChangeChild('.middle-right', {\n x: width,\n y: height / 2,\n offsetX: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-right') >= 0,\n });\n this._batchChangeChild('.bottom-left', {\n x: 0,\n y: height,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-left') >= 0,\n });\n this._batchChangeChild('.bottom-center', {\n x: width / 2,\n y: height,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-center') >= 0,\n });\n this._batchChangeChild('.bottom-right', {\n x: width,\n y: height,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,\n });\n this._batchChangeChild('.rotater', {\n x: width / 2,\n y: -this.rotateAnchorOffset() * Util_1.Util._sign(height) - padding,\n visible: this.rotateEnabled(),\n });\n this._batchChangeChild('.back', {\n width: width,\n height: height,\n visible: this.borderEnabled(),\n stroke: this.borderStroke(),\n strokeWidth: this.borderStrokeWidth(),\n dash: this.borderDash(),\n x: 0,\n y: 0,\n });\n };\n Transformer.prototype.isTransforming = function () {\n return this._transforming;\n };\n Transformer.prototype.stopTransform = function () {\n if (this._transforming) {\n this._removeEvents();\n var anchorNode = this.findOne('.' + this._movingAnchorName);\n if (anchorNode) {\n anchorNode.stopDrag();\n }\n }\n };\n Transformer.prototype.destroy = function () {\n if (this.getStage() && this._cursorChange) {\n this.getStage().content.style.cursor = '';\n }\n Group_1.Group.prototype.destroy.call(this);\n this.detach();\n this._removeEvents();\n return this;\n };\n Transformer.prototype.toObject = function () {\n return Node_1.Node.prototype.toObject.call(this);\n };\n return Transformer;\n}(Group_1.Group));\nexports.Transformer = Transformer;\nfunction validateAnchors(val) {\n if (!(val instanceof Array)) {\n Util_1.Util.warn('enabledAnchors value should be an array');\n }\n if (val instanceof Array) {\n val.forEach(function (name) {\n if (ANCHORS_NAMES.indexOf(name) === -1) {\n Util_1.Util.warn('Unknown anchor name: ' +\n name +\n '. Available names are: ' +\n ANCHORS_NAMES.join(', '));\n }\n });\n }\n return val || [];\n}\nTransformer.prototype.className = 'Transformer';\nGlobal_2._registerNode(Transformer);\nFactory_1.Factory.addGetterSetter(Transformer, 'enabledAnchors', ANCHORS_NAMES, validateAnchors);\nFactory_1.Factory.addGetterSetter(Transformer, 'resizeEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorSize', 10, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'rotationSnaps', []);\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'rotationSnapTolerance', 5, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorStroke', 'rgb(0, 161, 255)');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorStrokeWidth', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorFill', 'white');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorCornerRadius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderStroke', 'rgb(0, 161, 255)');\nFactory_1.Factory.addGetterSetter(Transformer, 'borderStrokeWidth', 1, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderDash');\nFactory_1.Factory.addGetterSetter(Transformer, 'keepRatio', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'centeredScaling', false);\nFactory_1.Factory.addGetterSetter(Transformer, 'ignoreStroke', false);\nFactory_1.Factory.addGetterSetter(Transformer, 'padding', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Transformer, 'node');\nFactory_1.Factory.addGetterSetter(Transformer, 'nodes');\nFactory_1.Factory.addGetterSetter(Transformer, 'boundBoxFunc');\nFactory_1.Factory.addGetterSetter(Transformer, 'shouldOverdrawWholeArea', false);\nFactory_1.Factory.backCompat(Transformer, {\n lineEnabled: 'borderEnabled',\n rotateHandlerOffset: 'rotateAnchorOffset',\n enabledHandlers: 'enabledAnchors',\n});\nUtil_1.Collection.mapMethods(Transformer);\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../Util\");\nvar Factory_1 = require(\"../Factory\");\nvar Shape_1 = require(\"../Shape\");\nvar Global_1 = require(\"../Global\");\nvar Validators_1 = require(\"../Validators\");\nvar Global_2 = require(\"../Global\");\nvar Wedge = (function (_super) {\n __extends(Wedge, _super);\n function Wedge() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Wedge.prototype._sceneFunc = function (context) {\n context.beginPath();\n context.arc(0, 0, this.radius(), 0, Global_1.Konva.getAngle(this.angle()), this.clockwise());\n context.lineTo(0, 0);\n context.closePath();\n context.fillStrokeShape(this);\n };\n Wedge.prototype.getWidth = function () {\n return this.radius() * 2;\n };\n Wedge.prototype.getHeight = function () {\n return this.radius() * 2;\n };\n Wedge.prototype.setWidth = function (width) {\n this.radius(width / 2);\n };\n Wedge.prototype.setHeight = function (height) {\n this.radius(height / 2);\n };\n return Wedge;\n}(Shape_1.Shape));\nexports.Wedge = Wedge;\nWedge.prototype.className = 'Wedge';\nWedge.prototype._centroid = true;\nWedge.prototype._attrsAffectingSize = ['radius'];\nGlobal_2._registerNode(Wedge);\nFactory_1.Factory.addGetterSetter(Wedge, 'radius', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Wedge, 'angle', 0, Validators_1.getNumberValidator());\nFactory_1.Factory.addGetterSetter(Wedge, 'clockwise', false);\nFactory_1.Factory.backCompat(Wedge, {\n angleDeg: 'angle',\n getAngleDeg: 'getAngle',\n setAngleDeg: 'setAngle'\n});\nUtil_1.Collection.mapMethods(Wedge);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nfunction BlurStack() {\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n}\nvar mul_table = [\n 512,\n 512,\n 456,\n 512,\n 328,\n 456,\n 335,\n 512,\n 405,\n 328,\n 271,\n 456,\n 388,\n 335,\n 292,\n 512,\n 454,\n 405,\n 364,\n 328,\n 298,\n 271,\n 496,\n 456,\n 420,\n 388,\n 360,\n 335,\n 312,\n 292,\n 273,\n 512,\n 482,\n 454,\n 428,\n 405,\n 383,\n 364,\n 345,\n 328,\n 312,\n 298,\n 284,\n 271,\n 259,\n 496,\n 475,\n 456,\n 437,\n 420,\n 404,\n 388,\n 374,\n 360,\n 347,\n 335,\n 323,\n 312,\n 302,\n 292,\n 282,\n 273,\n 265,\n 512,\n 497,\n 482,\n 468,\n 454,\n 441,\n 428,\n 417,\n 405,\n 394,\n 383,\n 373,\n 364,\n 354,\n 345,\n 337,\n 328,\n 320,\n 312,\n 305,\n 298,\n 291,\n 284,\n 278,\n 271,\n 265,\n 259,\n 507,\n 496,\n 485,\n 475,\n 465,\n 456,\n 446,\n 437,\n 428,\n 420,\n 412,\n 404,\n 396,\n 388,\n 381,\n 374,\n 367,\n 360,\n 354,\n 347,\n 341,\n 335,\n 329,\n 323,\n 318,\n 312,\n 307,\n 302,\n 297,\n 292,\n 287,\n 282,\n 278,\n 273,\n 269,\n 265,\n 261,\n 512,\n 505,\n 497,\n 489,\n 482,\n 475,\n 468,\n 461,\n 454,\n 447,\n 441,\n 435,\n 428,\n 422,\n 417,\n 411,\n 405,\n 399,\n 394,\n 389,\n 383,\n 378,\n 373,\n 368,\n 364,\n 359,\n 354,\n 350,\n 345,\n 341,\n 337,\n 332,\n 328,\n 324,\n 320,\n 316,\n 312,\n 309,\n 305,\n 301,\n 298,\n 294,\n 291,\n 287,\n 284,\n 281,\n 278,\n 274,\n 271,\n 268,\n 265,\n 262,\n 259,\n 257,\n 507,\n 501,\n 496,\n 491,\n 485,\n 480,\n 475,\n 470,\n 465,\n 460,\n 456,\n 451,\n 446,\n 442,\n 437,\n 433,\n 428,\n 424,\n 420,\n 416,\n 412,\n 408,\n 404,\n 400,\n 396,\n 392,\n 388,\n 385,\n 381,\n 377,\n 374,\n 370,\n 367,\n 363,\n 360,\n 357,\n 354,\n 350,\n 347,\n 344,\n 341,\n 338,\n 335,\n 332,\n 329,\n 326,\n 323,\n 320,\n 318,\n 315,\n 312,\n 310,\n 307,\n 304,\n 302,\n 299,\n 297,\n 294,\n 292,\n 289,\n 287,\n 285,\n 282,\n 280,\n 278,\n 275,\n 273,\n 271,\n 269,\n 267,\n 265,\n 263,\n 261,\n 259\n];\nvar shg_table = [\n 9,\n 11,\n 12,\n 13,\n 13,\n 14,\n 14,\n 15,\n 15,\n 15,\n 15,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 18,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 21,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 22,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 23,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24,\n 24\n];\nfunction filterGaussBlurRGBA(imageData, radius) {\n var pixels = imageData.data, width = imageData.width, height = imageData.height;\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;\n var div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius];\n for (i = 1; i < div; i++) {\n stack = stack.next = new BlurStack();\n if (i === radiusPlus1) {\n stackEnd = stack;\n }\n }\n stack.next = stackStart;\n yw = yi = 0;\n for (y = 0; y < height; y++) {\n r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n for (i = 1; i < radiusPlus1; i++) {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = pixels[p + 1]) * rbs;\n b_sum += (stack.b = pb = pixels[p + 2]) * rbs;\n a_sum += (stack.a = pa = pixels[p + 3]) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n }\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++) {\n pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa !== 0) {\n pa = 255 / pa;\n pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n }\n else {\n pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;\n }\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n r_in_sum += stackIn.r = pixels[p];\n g_in_sum += stackIn.g = pixels[p + 1];\n b_in_sum += stackIn.b = pixels[p + 2];\n a_in_sum += stackIn.a = pixels[p + 3];\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n a_sum += a_in_sum;\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += 4;\n }\n yw += width;\n }\n for (x = 0; x < width; x++) {\n g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n yp = width;\n for (i = 1; i <= radius; i++) {\n yi = (yp + x) << 2;\n r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;\n b_sum += (stack.b = pb = pixels[yi + 2]) * rbs;\n a_sum += (stack.a = pa = pixels[yi + 3]) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n if (i < heightMinus1) {\n yp += width;\n }\n }\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++) {\n p = yi << 2;\n pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa > 0) {\n pa = 255 / pa;\n pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n }\n else {\n pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;\n }\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p =\n (x +\n ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width) <<\n 2;\n r_sum += r_in_sum += stackIn.r = pixels[p];\n g_sum += g_in_sum += stackIn.g = pixels[p + 1];\n b_sum += b_in_sum += stackIn.b = pixels[p + 2];\n a_sum += a_in_sum += stackIn.a = pixels[p + 3];\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += width;\n }\n }\n}\nexports.Blur = function Blur(imageData) {\n var radius = Math.round(this.blurRadius());\n if (radius > 0) {\n filterGaussBlurRGBA(imageData, radius);\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blurRadius', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Brighten = function (imageData) {\n var brightness = this.brightness() * 255, data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'brightness', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Contrast = function (imageData) {\n var adjust = Math.pow((this.contrast() + 100) / 100, 2);\n var data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i;\n for (i = 0; i < nPixels; i += 4) {\n red = data[i];\n green = data[i + 1];\n blue = data[i + 2];\n red /= 255;\n red -= 0.5;\n red *= adjust;\n red += 0.5;\n red *= 255;\n green /= 255;\n green -= 0.5;\n green *= adjust;\n green += 0.5;\n green *= 255;\n blue /= 255;\n blue -= 0.5;\n blue *= adjust;\n blue += 0.5;\n blue *= 255;\n red = red < 0 ? 0 : red > 255 ? 255 : red;\n green = green < 0 ? 0 : green > 255 ? 255 : green;\n blue = blue < 0 ? 0 : blue > 255 ? 255 : blue;\n data[i] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'contrast', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Util_1 = require(\"../Util\");\nvar Validators_1 = require(\"../Validators\");\nexports.Emboss = function (imageData) {\n var strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), dirY = 0, dirX = 0, data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;\n switch (direction) {\n case 'top-left':\n dirY = -1;\n dirX = -1;\n break;\n case 'top':\n dirY = -1;\n dirX = 0;\n break;\n case 'top-right':\n dirY = -1;\n dirX = 1;\n break;\n case 'right':\n dirY = 0;\n dirX = 1;\n break;\n case 'bottom-right':\n dirY = 1;\n dirX = 1;\n break;\n case 'bottom':\n dirY = 1;\n dirX = 0;\n break;\n case 'bottom-left':\n dirY = 1;\n dirX = -1;\n break;\n case 'left':\n dirY = 0;\n dirX = -1;\n break;\n default:\n Util_1.Util.error('Unknown emboss direction: ' + direction);\n }\n do {\n var offsetY = (y - 1) * w4;\n var otherY = dirY;\n if (y + otherY < 1) {\n otherY = 0;\n }\n if (y + otherY > h) {\n otherY = 0;\n }\n var offsetYOther = (y - 1 + otherY) * w * 4;\n var x = w;\n do {\n var offset = offsetY + (x - 1) * 4;\n var otherX = dirX;\n if (x + otherX < 1) {\n otherX = 0;\n }\n if (x + otherX > w) {\n otherX = 0;\n }\n var offsetOther = offsetYOther + (x - 1 + otherX) * 4;\n var dR = data[offset] - data[offsetOther];\n var dG = data[offset + 1] - data[offsetOther + 1];\n var dB = data[offset + 2] - data[offsetOther + 2];\n var dif = dR;\n var absDif = dif > 0 ? dif : -dif;\n var absG = dG > 0 ? dG : -dG;\n var absB = dB > 0 ? dB : -dB;\n if (absG > absDif) {\n dif = dG;\n }\n if (absB > absDif) {\n dif = dB;\n }\n dif *= strength;\n if (blend) {\n var r = data[offset] + dif;\n var g = data[offset + 1] + dif;\n var b = data[offset + 2] + dif;\n data[offset] = r > 255 ? 255 : r < 0 ? 0 : r;\n data[offset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;\n data[offset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;\n }\n else {\n var grey = greyLevel - dif;\n if (grey < 0) {\n grey = 0;\n }\n else if (grey > 255) {\n grey = 255;\n }\n data[offset] = data[offset + 1] = data[offset + 2] = grey;\n }\n } while (--x);\n } while (--y);\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossStrength', 0.5, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossWhiteLevel', 0.5, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossDirection', 'top-left', null, Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossBlend', false, null, Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nfunction remap(fromValue, fromMin, fromMax, toMin, toMax) {\n var fromRange = fromMax - fromMin, toRange = toMax - toMin, toValue;\n if (fromRange === 0) {\n return toMin + toRange / 2;\n }\n if (toRange === 0) {\n return toMin;\n }\n toValue = (fromValue - fromMin) / fromRange;\n toValue = toRange * toValue + toMin;\n return toValue;\n}\nexports.Enhance = function (imageData) {\n var data = imageData.data, nSubPixels = data.length, rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b, i;\n var enhanceAmount = this.enhance();\n if (enhanceAmount === 0) {\n return;\n }\n for (i = 0; i < nSubPixels; i += 4) {\n r = data[i + 0];\n if (r < rMin) {\n rMin = r;\n }\n else if (r > rMax) {\n rMax = r;\n }\n g = data[i + 1];\n if (g < gMin) {\n gMin = g;\n }\n else if (g > gMax) {\n gMax = g;\n }\n b = data[i + 2];\n if (b < bMin) {\n bMin = b;\n }\n else if (b > bMax) {\n bMax = b;\n }\n }\n if (rMax === rMin) {\n rMax = 255;\n rMin = 0;\n }\n if (gMax === gMin) {\n gMax = 255;\n gMin = 0;\n }\n if (bMax === bMin) {\n bMax = 255;\n bMin = 0;\n }\n var rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;\n if (enhanceAmount > 0) {\n rGoalMax = rMax + enhanceAmount * (255 - rMax);\n rGoalMin = rMin - enhanceAmount * (rMin - 0);\n gGoalMax = gMax + enhanceAmount * (255 - gMax);\n gGoalMin = gMin - enhanceAmount * (gMin - 0);\n bGoalMax = bMax + enhanceAmount * (255 - bMax);\n bGoalMin = bMin - enhanceAmount * (bMin - 0);\n }\n else {\n rMid = (rMax + rMin) * 0.5;\n rGoalMax = rMax + enhanceAmount * (rMax - rMid);\n rGoalMin = rMin + enhanceAmount * (rMin - rMid);\n gMid = (gMax + gMin) * 0.5;\n gGoalMax = gMax + enhanceAmount * (gMax - gMid);\n gGoalMin = gMin + enhanceAmount * (gMin - gMid);\n bMid = (bMax + bMin) * 0.5;\n bGoalMax = bMax + enhanceAmount * (bMax - bMid);\n bGoalMin = bMin + enhanceAmount * (bMin - bMid);\n }\n for (i = 0; i < nSubPixels; i += 4) {\n data[i + 0] = remap(data[i + 0], rMin, rMax, rGoalMin, rGoalMax);\n data[i + 1] = remap(data[i + 1], gMin, gMax, gGoalMin, gGoalMax);\n data[i + 2] = remap(data[i + 2], bMin, bMax, bGoalMin, bGoalMax);\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'enhance', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Grayscale = function (imageData) {\n var data = imageData.data, len = data.length, i, brightness;\n for (i = 0; i < len; i += 4) {\n brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];\n data[i] = brightness;\n data[i + 1] = brightness;\n data[i + 2] = brightness;\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'luminance', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nexports.HSL = function (imageData) {\n var data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127, i;\n var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;\n var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;\n var r, g, b, a;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b + l;\n data[i + 1] = gr * r + gg * g + gb * b + l;\n data[i + 2] = br * r + bg * g + bb * b + l;\n data[i + 3] = a;\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.HSV = function (imageData) {\n var data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, i;\n var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;\n var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;\n var r, g, b, a;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b;\n data[i + 1] = gr * r + gg * g + gb * b;\n data[i + 2] = br * r + bg * g + bb * b;\n data[i + 3] = a;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'value', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Invert = function (imageData) {\n var data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Util_1 = require(\"../Util\");\nvar Validators_1 = require(\"../Validators\");\nvar ToPolar = function (src, dst, opt) {\n var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, r = 0, g = 0, b = 0, a = 0;\n var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n x = xSize - xMid;\n y = ySize - yMid;\n rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n var rSize = ySize, tSize = xSize, radius, theta;\n var conversion = ((360 / tSize) * Math.PI) / 180, sin, cos;\n for (theta = 0; theta < tSize; theta += 1) {\n sin = Math.sin(theta * conversion);\n cos = Math.cos(theta * conversion);\n for (radius = 0; radius < rSize; radius += 1) {\n x = Math.floor(xMid + ((rMax * radius) / rSize) * cos);\n y = Math.floor(yMid + ((rMax * radius) / rSize) * sin);\n i = (y * xSize + x) * 4;\n r = srcPixels[i + 0];\n g = srcPixels[i + 1];\n b = srcPixels[i + 2];\n a = srcPixels[i + 3];\n i = (theta + radius * xSize) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\nvar FromPolar = function (src, dst, opt) {\n var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, dx, dy, r = 0, g = 0, b = 0, a = 0;\n var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n x = xSize - xMid;\n y = ySize - yMid;\n rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n var rSize = ySize, tSize = xSize, radius, theta, phaseShift = opt.polarRotation || 0;\n var x1, y1;\n for (x = 0; x < xSize; x += 1) {\n for (y = 0; y < ySize; y += 1) {\n dx = x - xMid;\n dy = y - yMid;\n radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax;\n theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360;\n theta = (theta * tSize) / 360;\n x1 = Math.floor(theta);\n y1 = Math.floor(radius);\n i = (y1 * xSize + x1) * 4;\n r = srcPixels[i + 0];\n g = srcPixels[i + 1];\n b = srcPixels[i + 2];\n a = srcPixels[i + 3];\n i = (y * xSize + x) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\nexports.Kaleidoscope = function (imageData) {\n var xSize = imageData.width, ySize = imageData.height;\n var x, y, xoff, i, r, g, b, a, srcPos, dstPos;\n var power = Math.round(this.kaleidoscopePower());\n var angle = Math.round(this.kaleidoscopeAngle());\n var offset = Math.floor((xSize * (angle % 360)) / 360);\n if (power < 1) {\n return;\n }\n var tempCanvas = Util_1.Util.createCanvasElement();\n tempCanvas.width = xSize;\n tempCanvas.height = ySize;\n var scratchData = tempCanvas\n .getContext('2d')\n .getImageData(0, 0, xSize, ySize);\n ToPolar(imageData, scratchData, {\n polarCenterX: xSize / 2,\n polarCenterY: ySize / 2\n });\n var minSectionSize = xSize / Math.pow(2, power);\n while (minSectionSize <= 8) {\n minSectionSize = minSectionSize * 2;\n power -= 1;\n }\n minSectionSize = Math.ceil(minSectionSize);\n var sectionSize = minSectionSize;\n var xStart = 0, xEnd = sectionSize, xDelta = 1;\n if (offset + minSectionSize > xSize) {\n xStart = sectionSize;\n xEnd = 0;\n xDelta = -1;\n }\n for (y = 0; y < ySize; y += 1) {\n for (x = xStart; x !== xEnd; x += xDelta) {\n xoff = Math.round(x + offset) % xSize;\n srcPos = (xSize * y + xoff) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + x) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n }\n for (y = 0; y < ySize; y += 1) {\n sectionSize = Math.floor(minSectionSize);\n for (i = 0; i < power; i += 1) {\n for (x = 0; x < sectionSize + 1; x += 1) {\n srcPos = (xSize * y + x) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + sectionSize * 2 - x - 1) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n sectionSize *= 2;\n }\n }\n FromPolar(scratchData, imageData, { polarRotation: 0 });\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopePower', 2, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopeAngle', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nfunction pixelAt(idata, x, y) {\n var idx = (y * idata.width + x) * 4;\n var d = [];\n d.push(idata.data[idx++], idata.data[idx++], idata.data[idx++], idata.data[idx++]);\n return d;\n}\nfunction rgbDistance(p1, p2) {\n return Math.sqrt(Math.pow(p1[0] - p2[0], 2) +\n Math.pow(p1[1] - p2[1], 2) +\n Math.pow(p1[2] - p2[2], 2));\n}\nfunction rgbMean(pTab) {\n var m = [0, 0, 0];\n for (var i = 0; i < pTab.length; i++) {\n m[0] += pTab[i][0];\n m[1] += pTab[i][1];\n m[2] += pTab[i][2];\n }\n m[0] /= pTab.length;\n m[1] /= pTab.length;\n m[2] /= pTab.length;\n return m;\n}\nfunction backgroundMask(idata, threshold) {\n var rgbv_no = pixelAt(idata, 0, 0);\n var rgbv_ne = pixelAt(idata, idata.width - 1, 0);\n var rgbv_so = pixelAt(idata, 0, idata.height - 1);\n var rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);\n var thres = threshold || 10;\n if (rgbDistance(rgbv_no, rgbv_ne) < thres &&\n rgbDistance(rgbv_ne, rgbv_se) < thres &&\n rgbDistance(rgbv_se, rgbv_so) < thres &&\n rgbDistance(rgbv_so, rgbv_no) < thres) {\n var mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);\n var mask = [];\n for (var i = 0; i < idata.width * idata.height; i++) {\n var d = rgbDistance(mean, [\n idata.data[i * 4],\n idata.data[i * 4 + 1],\n idata.data[i * 4 + 2]\n ]);\n mask[i] = d < thres ? 0 : 255;\n }\n return mask;\n }\n}\nfunction applyMask(idata, mask) {\n for (var i = 0; i < idata.width * idata.height; i++) {\n idata.data[4 * i + 3] = mask[i];\n }\n}\nfunction erodeMask(mask, sw, sh) {\n var weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a === 255 * 8 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction dilateMask(mask, sw, sh) {\n var weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a >= 255 * 4 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction smoothEdgeMask(mask, sw, sh) {\n var weights = [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a;\n }\n }\n return maskResult;\n}\nexports.Mask = function (imageData) {\n var threshold = this.threshold(), mask = backgroundMask(imageData, threshold);\n if (mask) {\n mask = erodeMask(mask, imageData.width, imageData.height);\n mask = dilateMask(mask, imageData.width, imageData.height);\n mask = smoothEdgeMask(mask, imageData.width, imageData.height);\n applyMask(imageData, mask);\n }\n return imageData;\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Noise = function (imageData) {\n var amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2, i;\n for (i = 0; i < nPixels; i += 4) {\n data[i + 0] += half - 2 * half * Math.random();\n data[i + 1] += half - 2 * half * Math.random();\n data[i + 2] += half - 2 * half * Math.random();\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'noise', 0.2, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Util_1 = require(\"../Util\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Pixelate = function (imageData) {\n var pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i, red, green, blue, alpha, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), xBinStart, xBinEnd, yBinStart, yBinEnd, xBin, yBin, pixelsInBin, data = imageData.data;\n if (pixelSize <= 0) {\n Util_1.Util.error('pixelSize value can not be <= 0');\n return;\n }\n for (xBin = 0; xBin < nBinsX; xBin += 1) {\n for (yBin = 0; yBin < nBinsY; yBin += 1) {\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n xBinStart = xBin * pixelSize;\n xBinEnd = xBinStart + pixelSize;\n yBinStart = yBin * pixelSize;\n yBinEnd = yBinStart + pixelSize;\n pixelsInBin = 0;\n for (x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n i = (width * y + x) * 4;\n red += data[i + 0];\n green += data[i + 1];\n blue += data[i + 2];\n alpha += data[i + 3];\n pixelsInBin += 1;\n }\n }\n red = red / pixelsInBin;\n green = green / pixelsInBin;\n blue = blue / pixelsInBin;\n alpha = alpha / pixelsInBin;\n for (x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n i = (width * y + x) * 4;\n data[i + 0] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n data[i + 3] = alpha;\n }\n }\n }\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'pixelSize', 8, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Posterize = function (imageData) {\n var levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels, i;\n for (i = 0; i < len; i += 1) {\n data[i] = Math.floor(data[i] / scale) * scale;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'levels', 0.5, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.RGB = function (imageData) {\n var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), i, brightness;\n for (i = 0; i < nPixels; i += 4) {\n brightness =\n (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;\n data[i] = brightness * red;\n data[i + 1] = brightness * green;\n data[i + 2] = brightness * blue;\n data[i + 3] = data[i + 3];\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.RGBA = function (imageData) {\n var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha(), i, ia;\n for (i = 0; i < nPixels; i += 4) {\n ia = 1 - alpha;\n data[i] = red * alpha + data[i] * ia;\n data[i + 1] = green * alpha + data[i + 1] * ia;\n data[i + 2] = blue * alpha + data[i + 2] * ia;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'alpha', 1, function (val) {\n this._filterUpToDate = false;\n if (val > 1) {\n return 1;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return val;\n }\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Sepia = function (imageData) {\n var data = imageData.data, nPixels = data.length, i, r, g, b;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189);\n data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168);\n data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Solarize = function (imageData) {\n var data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;\n do {\n var offsetY = (y - 1) * w4;\n var x = w;\n do {\n var offset = offsetY + (x - 1) * 4;\n var r = data[offset];\n var g = data[offset + 1];\n var b = data[offset + 2];\n if (r > 127) {\n r = 255 - r;\n }\n if (g > 127) {\n g = 255 - g;\n }\n if (b > 127) {\n b = 255 - b;\n }\n data[offset] = r;\n data[offset + 1] = g;\n data[offset + 2] = b;\n } while (--x);\n } while (--y);\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Factory_1 = require(\"../Factory\");\nvar Node_1 = require(\"../Node\");\nvar Validators_1 = require(\"../Validators\");\nexports.Threshold = function (imageData) {\n var level = this.threshold() * 255, data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 1) {\n data[i] = data[i] < level ? 0 : 255;\n }\n};\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0.5, Validators_1.getNumberValidator(), Factory_1.Factory.afterSetFilter);\n"],"sourceRoot":""}
@@ -0,0 +1,10 @@
1
+ require 'mumukit'
2
+
3
+ Mumukit.runner_name = 'puzzle'
4
+ Mumukit.configure do |config|
5
+ end
6
+
7
+ require_relative './assets_server'
8
+ require_relative './version_hook'
9
+ require_relative './metadata_hook'
10
+ require_relative './test_hook'
@@ -0,0 +1,28 @@
1
+ class PuzzleTestHook < Mumukit::Templates::FileHook
2
+ def run!(positions)
3
+ if !positions.expected || positions_relatively_equal(positions.expected, positions.actual)
4
+ ['', :passed]
5
+ else
6
+ ['', :failed]
7
+ end
8
+ end
9
+
10
+ def compile(req)
11
+ {
12
+ expected: parse_positions(req),
13
+ actual: JSON.parse(req.content)['positions']
14
+ }.to_struct
15
+ end
16
+
17
+ def parse_positions(req)
18
+ (req.test =~ /Muzzle\.expect\((.+?)\)/m) && (JSON.parse($1) rescue nil)
19
+ end
20
+
21
+ def positions_relatively_equal(expected, actual)
22
+ x_offset = actual.first.first - (100 * expected.first.first)
23
+ y_offset = actual.first[1] - (100 * expected.first[1])
24
+ actual.flat_map { |x, y| [x - x_offset, y - y_offset] } == expected.flatten.map { |it| it * 100 }
25
+ end
26
+ end
27
+
28
+
@@ -0,0 +1,3 @@
1
+ module PuzzleVersionHook
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumuki-puzzle-runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mumukit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.35'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.35'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mumukit-bridge
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.8'
97
+ description:
98
+ email:
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - lib/assets_server.rb
104
+ - lib/metadata_hook.rb
105
+ - lib/public/css/muzzle-editor.css
106
+ - lib/public/css/muzzle.css
107
+ - lib/public/js/muzzle-editor.js
108
+ - lib/public/js/muzzle.js
109
+ - lib/public/vendor/headbreaker.d.ts
110
+ - lib/public/vendor/headbreaker.js
111
+ - lib/public/vendor/headbreaker.js.map
112
+ - lib/puzzle_runner.rb
113
+ - lib/test_hook.rb
114
+ - lib/version_hook.rb
115
+ homepage: http://github.com/mumuki/mumuki-puzzle-runner
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubygems_version: 3.0.6
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Puzzle Runner for Mumuki
138
+ test_files: []