@inweb/markup 25.11.2 → 25.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markup.js +11498 -11084
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js.map +1 -1
- package/package.json +4 -4
package/dist/markup.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Markup=t.ODA.Markup||{}))}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r={exports:{}},a={},n={},s={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const i=Math.PI/180;t.glob=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.14",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>t.Konva.angleDeg?e*i:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(s);var o={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=s;class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){var e=Math.cos(t),i=Math.sin(t),r=this.m[0]*e+this.m[2]*i,a=this.m[1]*e+this.m[3]*i,n=this.m[0]*-i+this.m[2]*e,s=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=a,this.m[2]=n,this.m[3]=s,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){var i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,a=this.m[2]+this.m[0]*t,n=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=a,this.m[3]=n,this}multiply(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],a=this.m[1]*t.m[2]+this.m[3]*t.m[3],n=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],s=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]=a,this.m[4]=n,this.m[5]=s,this}invert(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,r=-this.m[2]*t,a=this.m[0]*t,n=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),s=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]=a,this.m[4]=n,this.m[5]=s,this}getMatrix(){return this.m}decompose(){var e=this.m[0],i=this.m[1],r=this.m[2],a=this.m[3],n=e*a-i*r;let s={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var o=Math.sqrt(e*e+i*i);s.rotation=i>0?Math.acos(e/o):-Math.acos(e/o),s.scaleX=o,s.scaleY=n/o,s.skewX=(e*r+i*a)/n,s.skewY=0}else if(0!=r||0!=a){var h=Math.sqrt(r*r+a*a);s.rotation=Math.PI/2-(a>0?Math.acos(-r/h):-Math.acos(r/h)),s.scaleX=n/h,s.scaleY=h,s.skewX=0,s.skewY=(e*r+i*a)/n}return s.rotation=t.Util._getRotation(s.rotation),s}}t.Transform=i;var r=Math.PI/180,a=180/Math.PI,n="Konva error: ",o={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},h=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,l=[];const d="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){l.push(t),1===l.length&&d((function(){const t=l;l=[],t.forEach((function(t){t()}))}))},createCanvasElement(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){var r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){for(var t=(16777215*Math.random()|0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB(t){var e;return t in o?{r:(e=o[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=h.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){var e=o[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){var e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,a=Number(i[1])/100,n=Number(i[2])/100;let s,o,h;if(0===a)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};s=n<.5?n*(1+a):n+a-n*a;const l=2*n-s,d=[0,0,0];for(let t=0;t<3;t++)o=r+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(s-l)*o:2*o<1?s:3*o<2?l+(s-l)*(2/3-o)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){var e={};for(var i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*r,radToDeg:t=>t*a,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(n+t)},error(t){console.error(n+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(var i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,r,a,n){var s,o,h,l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)s=t,o=e,h=(a-i)*(a-i)+(n-r)*(n-r);else{var d=((a-t)*(i-t)+(n-e)*(r-e))/l;d<0?(s=t,o=e,h=(t-a)*(t-a)+(e-n)*(e-n)):d>1?(s=i,o=r,h=(i-a)*(i-a)+(r-n)*(r-n)):h=((s=t+d*(i-t))-a)*(s-a)+((o=e+d*(r-e))-n)*(o-n)}return[s,o,h]},_getProjectionToLine(e,i,r){var a=t.Util.cloneObject(e),n=Number.MAX_VALUE;return i.forEach((function(s,o){if(r||o!==i.length-1){var h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(s.x,s.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],g=l[2];g<n&&(a.x=d,a.y=c,n=g)}})),a},_prepareArrayForTween(e,i,r){var a,n=[],s=[];if(e.length>i.length){var o=i;i=e,e=o}for(a=0;a<e.length;a+=2)n.push({x:e[a],y:e[a+1]});for(a=0;a<i.length;a+=2)s.push({x:i[a],y:i[a+1]});var h=[];return s.forEach((function(e){var i=t.Util._getProjectionToLine(e,n,r);h.push(i.x),h.push(i.y)})),h},_prepareToStringify(e){var i;for(var r in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,r){let a=0,n=0,s=0,o=0;"number"==typeof r?a=n=s=o=Math.min(r,e/2,i/2):(a=Math.min(r[0]||0,e/2,i/2),n=Math.min(r[1]||0,e/2,i/2),o=Math.min(r[2]||0,e/2,i/2),s=Math.min(r[3]||0,e/2,i/2)),t.moveTo(a,0),t.lineTo(e-n,0),t.arc(e-n,n,n,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(s,i),t.arc(s,i-s,s,Math.PI/2,Math.PI,!1),t.lineTo(0,a),t.arc(a,a,a,Math.PI,3*Math.PI/2,!1)}}}(o);var h={},l={},d={};Object.defineProperty(d,"__esModule",{value:!0}),d.getComponentValidator=d.getBooleanValidator=d.getNumberArrayValidator=d.getFunctionValidator=d.getStringOrGradientValidator=d.getStringValidator=d.getNumberOrAutoValidator=d.getNumberOrArrayOfNumbersValidator=d.getNumberValidator=d.alphaComponent=d.RGBComponent=void 0;const c=s,g=o;function u(t){return g.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||g.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}d.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},d.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},d.getNumberValidator=function(){if(c.Konva.isUnminified)return function(t,e){return g.Util._isNumber(t)||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},d.getNumberOrArrayOfNumbersValidator=function(t){if(c.Konva.isUnminified)return function(e,i){let r=g.Util._isNumber(e),a=g.Util._isArray(e)&&e.length==t;return r||a||g.Util.warn(u(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},d.getNumberOrAutoValidator=function(){if(c.Konva.isUnminified)return function(t,e){return g.Util._isNumber(t)||"auto"===t||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},d.getStringValidator=function(){if(c.Konva.isUnminified)return function(t,e){return g.Util._isString(t)||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},d.getStringOrGradientValidator=function(){if(c.Konva.isUnminified)return function(t,e){const i=g.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},d.getFunctionValidator=function(){if(c.Konva.isUnminified)return function(t,e){return g.Util._isFunction(t)||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},d.getNumberArrayValidator=function(){if(c.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(g.Util._isArray(t)?t.forEach((function(t){g.Util._isNumber(t)||g.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},d.getBooleanValidator=function(){if(c.Konva.isUnminified)return function(t,e){return!0===t||!1===t||g.Util.warn(u(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},d.getComponentValidator=function(t){if(c.Konva.isUnminified)return function(e,i){return null==e||g.Util.isObject(e)||g.Util.warn(u(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=o,i=d;var r="get",a="set";t.Factory={addGetterSetter(e,i,r,a,n){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,a,n),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,a){var n=r+e.Util._capitalize(i);t.prototype[n]=t.prototype[n]||function(){var t=this.attrs[i];return void 0===t?a:t}},addSetter(i,r,n,s){var o=a+e.Util._capitalize(r);i.prototype[o]||t.Factory.overWriteSetter(i,r,n,s)},overWriteSetter(t,i,r,n){var s=a+e.Util._capitalize(i);t.prototype[s]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,s,o,h,l){var d,c,g=o.length,u=e.Util._capitalize,f=r+u(s),p=a+u(s);n.prototype[f]=function(){var t={};for(d=0;d<g;d++)t[c=o[d]]=this.getAttr(s+u(c));return t};var v=(0,i.getComponentValidator)(o);n.prototype[p]=function(t){var e,i=this.attrs[s];for(e in h&&(t=h.call(this,t)),v&&v.call(this,t,s),t)t.hasOwnProperty(e)&&this._setAttr(s+u(e),t[e]);return t||o.forEach((t=>{this._setAttr(s+u(t),void 0)})),this._fireChangeEvent(s,i,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,s)},addOverloadedGetterSetter(t,i){var n=e.Util._capitalize(i),s=a+n,o=r+n;t.prototype[i]=function(){return arguments.length?(this[s](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,a,n,s){e.Util.error("Adding deprecated "+a);var o=r+e.Util._capitalize(a),h=a+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);var t=this.attrs[a];return void 0===t?n:t},t.Factory.addSetter(i,a,s,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,a)},backCompat(t,i){e.Util.each(i,(function(i,n){var s=t.prototype[n],o=r+e.Util._capitalize(i),h=a+e.Util._capitalize(i);function l(){s.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(l);var f={},p={};Object.defineProperty(p,"__esModule",{value:!0}),p.HitContext=p.SceneContext=p.Context=void 0;const v=o,_=s;var m=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class y{constructor(t){this.canvas=t,_.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){var i,r,a,n,s=this.traceArr,o=s.length,h="";for(i=0;i<o;i++)(a=(r=s[i]).method)?(n=r.args,h+=a,t?h+="()":v.Util._isArray(n[0])?h+="(["+n.join(",")+"])":(e&&(n=n.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+n.join(",")+")")):(h+=r.property,t||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}reset(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,a,n){this._context.arc(t,e,i,r,a,n)}arcTo(t,e,i,r,a){this._context.arcTo(t,e,i,r,a)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,a,n){this._context.bezierCurveTo(t,e,i,r,a,n)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,a,n){return this._context.createRadialGradient(t,e,i,r,a,n)}drawImage(t,e,i,r,a,n,s,o,h){var l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,a):9===l.length&&d.drawImage(t,e,i,r,a,n,s,o,h)}ellipse(t,e,i,r,a,n,s,o){this._context.ellipse(t,e,i,r,a,n,s,o)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,a){this._context.roundRect(t,e,i,r,a)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,r,a,n){this._context.setTransform(t,e,i,r,a,n)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,a,n){this._context.transform(t,e,i,r,a,n)}translate(t,e){this._context.translate(t,e)}_enableTrace(){var t,e,i=this,r=m.length,a=this.setAttr,n=function(t){var r,a=i[t];i[t]=function(){return e=function(t){var e,i,r=[],a=t.length,n=v.Util;for(e=0;e<a;e++)i=t[e],n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),r.push(i);return r}(Array.prototype.slice.call(arguments,0)),r=a.apply(i,arguments),i._trace({method:t,args:e}),r}};for(t=0;t<r;t++)n(m[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})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}p.Context=y,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(y.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));p.SceneContext=class extends y{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const a=t.getFillLinearGradientColorStops();if(a&&"linear-gradient"===i)return void this._fillLinearGradient(t);const n=t.getFillRadialGradientColorStops();n&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):a?this._fillLinearGradient(t):n&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(var n=0;n<r.length;n+=2)a.addColorStop(r[n],r[n+1]);this.setAttr("strokeStyle",a)}}_stroke(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,r,a=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,s=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",s.x*l),this.setAttr("shadowOffsetY",s.y*d)}};p.HitContext=class extends y{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const a=t.getStrokeScaleEnabled();if(!a){this.save();var e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(t);var i=t.hitStrokeWidth(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),a||this.restore()}}},Object.defineProperty(f,"__esModule",{value:!0}),f.HitCanvas=f.SceneCanvas=f.Canvas=void 0;const x=o,b=p,S=s,w=l,C=d;var k;class P{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||S.Konva.pixelRatio||function(){if(k)return k;var t=x.Util.createCanvasElement(),e=t.getContext("2d");return k=(S.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),x.Util.releaseCanvas(t),k}();this.pixelRatio=e,this._canvas=x.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return x.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}f.Canvas=P,w.Factory.addGetterSetter(P,"pixelRatio",void 0,(0,C.getNumberValidator)());f.SceneCanvas=class extends P{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new b.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};f.HitCanvas=class extends P{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new b.HitContext(this),this.setSize(t.width,t.height)}};var T={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=s,i=o;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach(((t,a)=>{const{node:n}=t,s=n.getStage();s.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=s._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){var h=n.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<h)return;if(n.startDrag({evt:e}),!n.isDragging())return}n._setDragPosition(e,t),r.push(n)}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const r=[];t.DD._dragElements.forEach((a=>{const{node:n}=a,s=n.getStage();i&&s.setPointersPositions(i);if(!s._changedPointerPositions.find((t=>t.id===a.pointerId)))return;"dragging"!==a.dragStatus&&"stopped"!==a.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,a.dragStatus="stopped");const o=a.node.getLayer()||a.node instanceof e.Konva.Stage&&a.node;o&&-1===r.indexOf(o)&&r.push(o)})),r.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1))}(T),Object.defineProperty(h,"__esModule",{value:!0}),h.Node=void 0;const A=o,M=l,F=f,R=s,I=T,E=d;var O="absoluteOpacity",G="allEventListeners",D="absoluteTransform",L="absoluteScale",N="canvas",U="listening",B="mouseenter",W="mouseleave",z="Shape",H=" ",V="stage",j="transform",K="visible",X=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(H);let Y=1;class q{constructor(t){this._id=Y++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==j&&t!==D||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){var i=this._cache.get(t);return(void 0===i||(t===j||t===D)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(H);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(N)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===D&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(N)){const{scene:t,filter:e,hit:i}=this._cache.get(N);A.Util.releaseCanvas(t,e,i),this._cache.delete(N)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var r=Math.ceil(e.width||i.width),a=Math.ceil(e.height||i.height),n=e.pixelRatio,s=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,d=e.hitCanvasPixelRatio||1;if(!r||!a)return void A.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");r+=2*h+(Math.abs(Math.round(i.x)-s)>.5?1:0),a+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),s-=h,o-=h;var c=new F.SceneCanvas({pixelRatio:n,width:r,height:a}),g=new F.SceneCanvas({pixelRatio:n,width:0,height:0,willReadFrequently:!0}),u=new F.HitCanvas({pixelRatio:d,width:r,height:a}),f=c.getContext(),p=u.getContext();return u.isCache=!0,c.isCache=!0,this._cache.delete(N),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),f.save(),p.save(),f.translate(-s,-o),p.translate(-s,-o),this._isUnderCache=!0,this._clearSelfAndDescendantCache(O),this._clearSelfAndDescendantCache(L),this.drawScene(c,this),this.drawHit(u,this),this._isUnderCache=!1,f.restore(),p.restore(),l&&(f.save(),f.beginPath(),f.rect(0,0,r,a),f.closePath(),f.setAttr("strokeStyle","red"),f.setAttr("lineWidth",5),f.stroke(),f.restore()),this._cache.set(N,{scene:c,filter:g,hit:u,x:s,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(N)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){var i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],r=1/0,a=1/0,n=-1/0,s=-1/0,o=this.getAbsoluteTransform(e);return i.forEach((function(t){var e=o.point(t);void 0===r&&(r=n=e.x,a=s=e.y),r=Math.min(r,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),s=Math.max(s,e.y)})),{x:r,y:a,width:n-r,height:s-a}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){var t,e,i,r,a=this.filters(),n=this._getCanvasCache(),s=n.scene,o=n.filter,h=o.getContext();if(a){if(!this._filterUpToDate){var l=s.pixelRatio;o.setSize(s.width/s.pixelRatio,s.height/s.pixelRatio);try{for(t=a.length,h.clear(),h.drawImage(s._canvas,0,0,s.getWidth()/l,s.getHeight()/l),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)"function"==typeof(r=a[i])?(r.call(this,e),h.putImageData(e,0,0)):A.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){A.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 o}return s}on(t,e){if(this._cache&&this._cache.delete(G),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,a,n,s=t.split(H),o=s.length;for(i=0;i<o;i++)a=(r=s[i].split("."))[0],n=r[1]||"",this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:n,handler:e});return this}off(t,e){var i,r,a,n,s,o=(t||"").split(H),h=o.length;if(this._cache&&this._cache.delete(G),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<h;i++)if(n=(a=o[i].split("."))[0],s=a[1],n)this.eventListeners[n]&&this._off(n,s,e);else for(r in this.eventListeners)this._off(r,s,e);return this}dispatchEvent(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){var r=this;this.on(t,(function(t){for(var a=t.target.findAncestors(e,!0,r),n=0;n<a.length;n++)(t=A.Util.cloneObject(t)).currentTarget=a[n],i.call(a[n],t)}))}remove(){return this.isDragging()&&this.stopDrag(),I.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(D),this._clearSelfAndDescendantCache(O),this._clearSelfAndDescendantCache(L),this._clearSelfAndDescendantCache(V),this._clearSelfAndDescendantCache(K),this._clearSelfAndDescendantCache(U)}_remove(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){var e="get"+A.Util._capitalize(t);return A.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges((()=>{var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+A.Util._capitalize(e),A.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(U,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(K,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),r=!1;I.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0)}));var a=!e&&!R.Konva.hitOnDragEnabled&&(r||R.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var t,e,i,r,a=this.getDepth(),n=this,s=0;const o=this.getStage();return"Stage"!==n.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],s++,r.nodeType!==z&&(t=t.concat(r.getChildren().slice())),r._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=a&&o(t)}(o.getChildren()),s}getDepth(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(j),this._clearSelfAndDescendantCache(D)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;var e=t.getPointerPosition();if(!e)return null;var i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var r=this.getAbsoluteTransform(t).getMatrix(),a=new A.Transform,n=this.offset();return a.m=r.slice(),a.translate(n.x,n.y),a.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(j);var a=this._getAbsoluteTransform().copy();return a.invert(),a.translate(t.x,t.y),t={x:this.attrs.x+a.getTranslation().x,y:this.attrs.y+a.getTranslation().y},this._setTransform(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(j),this._clearSelfAndDescendantCache(D),this}_setTransform(t){var e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){var t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){var e=t.x,i=t.y,r=this.x(),a=this.y();return void 0!==e&&(r+=e),void 0!==i&&(a+=i),this.setPosition({x:r,y:a}),this}_eachAncestorReverse(t,e){var i,r,a=[],n=this.getParent();if(!e||e._id!==this._id){for(a.unshift(this);n&&(!e||n._id!==e._id);)a.unshift(n),n=n.parent;for(i=a.length,r=0;r<i;r++)t(a[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return A.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return A.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return A.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return A.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return A.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&A.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(O,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t,e,i,r,a=this.getAttrs();const n={attrs:{},className:this.getClassName()};for(t in a)e=a[t],A.Util.isObject(e)&&!A.Util._isPlainObject(e)&&!A.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete a[t],r=i?i.call(this):null,a[t]=e,r!==e&&(n.attrs[t]=e));return A.Util._prepareToStringify(n)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){var r=[];e&&this._isMatch(t)&&r.push(this);for(var a=this.parent;a;){if(a===i)return r;a._isMatch(t)&&r.push(a),a=a.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,r=t.replace(/ /g,"").split(","),a=r.length;for(e=0;e<a;e++)if(i=r[e],A.Util.isValidSelector(i)||(A.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),A.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),A.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){var t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(V,this._getStage)}_getStage(){var t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(D,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new A.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this._cache.get(D)||new A.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){const t=this.attrs.x||0,i=this.attrs.y||0,r=this.attrs.offsetX||0,a=this.attrs.offsetY||0;e.translate(t-r,i-a)}return e.dirty=!1,e}getAbsoluteScale(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(j,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(j)||new A.Transform;i.reset();var r=this.x(),a=this.y(),n=R.Konva.getAngle(this.rotation()),s=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,d=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return 0===r&&0===a||i.translate(r,a),0!==n&&i.rotate(n),0===h&&0===l||i.skew(h,l),1===s&&1===o||i.scale(s,o),0===d&&0===c||i.translate(-1*d,-1*c),i.dirty=!1,i}clone(t){var e,i,r,a,n,s=A.Util.cloneObject(this.attrs);for(e in t)s[e]=t[e];var o=new this.constructor(s);for(e in this.eventListeners)for(r=(i=this.eventListeners[e]).length,a=0;a<r;a++)(n=i[a]).name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(n));return o}_toKonvaCanvas(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),a=void 0!==t.y?t.y:Math.floor(e.y),n=t.pixelRatio||1,s=new F.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:n}),o=s.getContext();const h=new F.SceneCanvas({width:s.width/s.pixelRatio+Math.abs(r),height:s.height/s.pixelRatio+Math.abs(a),pixelRatio:s.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(r||a)&&o.translate(-1*r,-1*a),this.drawScene(s,void 0,h),o.restore(),s}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,A.Util._urlToImage(this.toDataURL(t),(function(t){e(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():R.Konva.dragDistance}_off(t,e,i){var r,a,n,s=this.eventListeners[t];for(r=0;r<s.length;r++)if(a=s[r].name,n=s[r].handler,!("konva"===a&&"konva"!==e||e&&a!==e||i&&i!==n)){if(s.splice(r,1),0===s.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){var i=this["set"+A.Util._capitalize(t)];return A.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(R.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||A.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){var r;void 0!==i&&((r=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){if(e&&this.nodeType===z&&(e.target=this),!((t===B||t===W)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=(t===B||t===W)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const a=null!==(e=this._cache.get(G))&&void 0!==e?e:{};let n=null==a?void 0:a[t];if(void 0===n){n=[];let e=Object.getPrototypeOf(this);for(;e;){const a=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];n.push(...a),e=Object.getPrototypeOf(e)}a[t]=n,this._cache.set(G,a)}return n}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var r=0;r<i.length;r++)i[r].handler.call(this,e);const a=this.eventListeners[t];if(a)for(r=0;r<a.length;r++)a[r].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){var e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition();if(i){var a=i._getPointerById(e)||i._changedPointerPositions[0]||r;I.DD._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-r.x,y:a.y-r.y},dragStatus:"ready",pointerId:e})}}startDrag(t,e=!0){I.DD._dragElements.has(this._id)||this._createDragElement(t);I.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(i){var r={x:i.x-e.offset.x,y:i.y-e.offset.y},a=this.dragBoundFunc();if(void 0!==a){const e=a.call(this,r,t);e?r=e:A.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(t){const e=I.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),I.DD._endDragBefore(t),I.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=I.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if((!(void 0!==t.evt.button)||R.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;I.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=I.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&I.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return A.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return A.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,r,a,n=q.prototype.getClassName.call(t),s=t.children;e&&(t.attrs.container=e),R.Konva[n]||(A.Util.warn('Can not find a node with class name "'+n+'". Fallback to "Shape".'),n="Shape");if(i=new(0,R.Konva[n])(t.attrs),s)for(r=s.length,a=0;a<r;a++)i.add(q._createNode(s[a]));return i}}h.Node=q,q.prototype.nodeType="Node",q.prototype._attrsAffectingSize=[],q.prototype.eventListeners={},q.prototype.on.call(q.prototype,X,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(j),this._clearSelfAndDescendantCache(D))})),q.prototype.on.call(q.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(K)})),q.prototype.on.call(q.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(U)})),q.prototype.on.call(q.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(O)}));const Q=M.Factory.addGetterSetter;Q(q,"zIndex"),Q(q,"absolutePosition"),Q(q,"position"),Q(q,"x",0,(0,E.getNumberValidator)()),Q(q,"y",0,(0,E.getNumberValidator)()),Q(q,"globalCompositeOperation","source-over",(0,E.getStringValidator)()),Q(q,"opacity",1,(0,E.getNumberValidator)()),Q(q,"name","",(0,E.getStringValidator)()),Q(q,"id","",(0,E.getStringValidator)()),Q(q,"rotation",0,(0,E.getNumberValidator)()),M.Factory.addComponentsGetterSetter(q,"scale",["x","y"]),Q(q,"scaleX",1,(0,E.getNumberValidator)()),Q(q,"scaleY",1,(0,E.getNumberValidator)()),M.Factory.addComponentsGetterSetter(q,"skew",["x","y"]),Q(q,"skewX",0,(0,E.getNumberValidator)()),Q(q,"skewY",0,(0,E.getNumberValidator)()),M.Factory.addComponentsGetterSetter(q,"offset",["x","y"]),Q(q,"offsetX",0,(0,E.getNumberValidator)()),Q(q,"offsetY",0,(0,E.getNumberValidator)()),Q(q,"dragDistance",null,(0,E.getNumberValidator)()),Q(q,"width",0,(0,E.getNumberValidator)()),Q(q,"height",0,(0,E.getNumberValidator)()),Q(q,"listening",!0,(0,E.getBooleanValidator)()),Q(q,"preventDefault",!0,(0,E.getBooleanValidator)()),Q(q,"filters",null,(function(t){return this._filterUpToDate=!1,t})),Q(q,"visible",!0,(0,E.getBooleanValidator)()),Q(q,"transformsEnabled","all",(0,E.getStringValidator)()),Q(q,"size"),Q(q,"dragBoundFunc"),Q(q,"draggable",!1,(0,E.getBooleanValidator)()),M.Factory.backCompat(q,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var J={};Object.defineProperty(J,"__esModule",{value:!0}),J.Container=void 0;const Z=l,$=h,tt=d;class et extends $.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[];var i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(var e=0;e<t.length;e++)this.add(t[e]);return this}const i=t[0];return i.getParent()?(i.moveTo(this),this):(this._validateAdd(i),i.index=this.getChildren().length,i.parent=this,i._clearCaches(),this.getChildren().push(i),this._fire("add",{child:i}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){var i=[];return this._descendants((r=>{const a=r._isMatch(t);return a&&i.push(r),!(!a||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){var t=$.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){var e=$.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}getAllIntersections(t){var e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){var r=this.getLayer(),a=t||r&&r.getCanvas(),n=a&&a.getContext(),s=this._getCanvasCache(),o=s&&s.scene,h=a&&a.isCache;if(!this.isVisible()&&!h)return this;if(o){n.save();var l=this.getAbsoluteTransform(e).getMatrix();n.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",a,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),r=t||i&&i.hitCanvas,a=r&&r.getContext(),n=this._getCanvasCache();if(n&&n.hit){a.save();var s=this.getAbsoluteTransform(e).getMatrix();a.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var a,n=e&&e.getContext(),s=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof s&&"number"==typeof o||h;const d=i===this;if(l){n.save();var c=this.getAbsoluteTransform(i),g=c.getMatrix();let t;if(n.transform(g[0],g[1],g[2],g[3],g[4],g[5]),n.beginPath(),h)t=h.call(this,n,this);else{var u=this.clipX(),f=this.clipY();n.rect(u||0,f||0,s,o)}n.clip.apply(n,t),g=c.copy().invert().getMatrix(),n.transform(g[0],g[1],g[2],g[3],g[4],g[5])}var p=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;p&&(n.save(),n._applyGlobalCompositeOperation(this)),null===(a=this.children)||void 0===a||a.forEach((function(a){a[t](e,i,r)})),p&&n.restore(),l&&n.restore()}getClientRect(t={}){var e,i,r,a,n,s=t.skipTransform,o=t.relativeTo,h={x:1/0,y:1/0,width:0,height:0},l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var s=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===s.width&&0===s.height||(void 0===i?(i=s.x,r=s.y,a=s.x+s.width,n=s.y+s.height):(i=Math.min(i,s.x),r=Math.min(r,s.y),a=Math.max(a,s.x+s.width),n=Math.max(n,s.y+s.height)))}}));for(var d=this.find("Shape"),c=!1,g=0;g<d.length;g++){if(d[g]._isVisible(this)){c=!0;break}}return h=c&&void 0!==i?{x:i,y:r,width:a-i,height:n-r}:{x:0,y:0,width:0,height:0},s?h:this._transformedRect(h,o)}}J.Container=et,Z.Factory.addComponentsGetterSetter(et,"clip",["x","y","width","height"]),Z.Factory.addGetterSetter(et,"clipX",void 0,(0,tt.getNumberValidator)()),Z.Factory.addGetterSetter(et,"clipY",void 0,(0,tt.getNumberValidator)()),Z.Factory.addGetterSetter(et,"clipWidth",void 0,(0,tt.getNumberValidator)()),Z.Factory.addGetterSetter(et,"clipHeight",void 0,(0,tt.getNumberValidator)()),Z.Factory.addGetterSetter(et,"clipFunc");var it={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.releaseCapture=rt.setPointerCapture=rt.hasPointerCapture=rt.createEvent=rt.getCapturedShape=void 0;const at=s,nt=new Map,st=void 0!==at.Konva._global.PointerEvent;function ot(t){return{evt:t,pointerId:t.pointerId}}function ht(t,e){const i=nt.get(t);if(!i)return;const r=i.getStage();r&&r.content,nt.delete(t),st&&i._fire("lostpointercapture",ot(new PointerEvent("lostpointercapture")))}rt.getCapturedShape=function(t){return nt.get(t)},rt.createEvent=ot,rt.hasPointerCapture=function(t,e){return nt.get(t)===e},rt.setPointerCapture=function(t,e){ht(t),e.getStage()&&(nt.set(t,e),st&&e._fire("gotpointercapture",ot(new PointerEvent("gotpointercapture"))))},rt.releaseCapture=ht,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=o,i=l,r=J,a=s,n=f,h=T,d=s,c=rt;var g="mouseleave",u="mouseover",p="mouseenter",v="mousemove",_="mousedown",m="mouseup",y="pointermove",x="pointerdown",b="pointerup",S="pointercancel",w="pointerout",C="pointerleave",k="pointerover",P="pointerenter",A="contextmenu",M="touchstart",F="touchend",R="touchmove",I="touchcancel",E="wheel",O=[[p,"_pointerenter"],[_,"_pointerdown"],[v,"_pointermove"],[m,"_pointerup"],[g,"_pointerleave"],[M,"_pointerdown"],[R,"_pointermove"],[F,"_pointerup"],[I,"_pointercancel"],[u,"_pointerover"],[E,"_wheel"],[A,"_contextmenu"],[x,"_pointerdown"],[y,"_pointermove"],[b,"_pointerup"],[S,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const G={mouse:{[w]:"mouseout",[C]:g,[k]:u,[P]:p,[y]:v,[x]:_,[b]:m,[S]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[w]:"touchout",[C]:"touchleave",[k]:"touchover",[P]:"touchenter",[y]:R,[x]:M,[b]:F,[S]:I,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[w]:w,[C]:C,[k]:k,[P]:P,[y]:y,[x]:x,[b]:b,[S]:S,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},D=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",L=t=>{const e=D(t);return"pointer"===e?a.Konva.pointerEventsEnabled&&G.pointer:"touch"===e?G.touch:"mouse"===e?G.mouse:void 0};function N(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class U extends r.Container{constructor(e){super(N(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{N(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(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}shouldDrawHit(){return!0}clear(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();var i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);var r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.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)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new n.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach((function(e){if(e.isVisible()){var r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}})),e}getIntersection(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){const r=i[e].getIntersection(t);if(r)return r}return null}_resizeDOM(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(t);var n=this.children.length;return n>5&&e.Util.warn("The stage has "+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."),t.setSize({width:this.width(),height:this.height()}),t.draw(),a.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return c.hasPointerCapture(t,this)}setPointerCapture(t){c.setPointerCapture(t,this)}releaseCapture(t){c.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&O.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=L(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=L(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=L(t.type),i=D(t.type);if(e){this.setPointersPositions(t);var r=this._getTargetShape(i),n=!(a.Konva.isDragging()||a.Konva.isTransforming())||a.Konva.hitOnDragEnabled;r&&n?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):n&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(t){const e=L(t.type),i=D(t.type);if(e){this.setPointersPositions(t);var r=!1;this._changedPointerPositions.forEach((n=>{var s=this.getIntersection(n);if(h.DD.justDragged=!1,a.Konva["_"+i+"ListenClick"]=!0,!s||!s.isListening())return void(this[i+"ClickStartShape"]=void 0);a.Konva.capturePointerEventsEnabled&&s.setPointerCapture(n.id),this[i+"ClickStartShape"]=s,s._fireAndBubble(e.pointerdown,{evt:t,pointerId:n.id}),r=!0;const o=t.type.indexOf("touch")>=0;s.preventDefault()&&t.cancelable&&o&&t.preventDefault()})),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(t){const e=L(t.type),i=D(t.type);if(!e)return;if(a.Konva.isDragging()&&h.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!(!(a.Konva.isDragging()||a.Konva.isTransforming())||a.Konva.hitOnDragEnabled))return;var r={};let n=!1;var s=this._getTargetShape(i);this._changedPointerPositions.forEach((a=>{const o=c.getCapturedShape(a.id)||this.getIntersection(a),h=a.id,l={evt:t,pointerId:h};var d=s!==o;if(d&&s&&(s._fireAndBubble(e.pointerout,{...l},o),s._fireAndBubble(e.pointerleave,{...l},o)),o){if(r[o._id])return;r[o._id]=!0}o&&o.isListening()?(n=!0,d&&(o._fireAndBubble(e.pointerover,{...l},s),o._fireAndBubble(e.pointerenter,{...l},s),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):s&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)})),n||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=L(t.type),i=D(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"];var s={};let o=!1;this._changedPointerPositions.forEach((l=>{const d=c.getCapturedShape(l.id)||this.getIntersection(l);if(d){if(d.releaseCapture(l.id),s[d._id])return;s[d._id]=!0}const g=l.id,u={evt:t,pointerId:g};let f=!1;a.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):h.DD.justDragged||(a.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){a.Konva["_"+i+"InDblClickWindow"]=!1}),a.Konva.dblClickWindow),d&&d.isListening()?(o=!0,this[i+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...u}),a.Konva["_"+i+"ListenClick"]&&r&&r===d&&(d._fireAndBubble(e.pointerclick,{...u}),f&&n&&n===d&&d._fireAndBubble(e.pointerdblclick,{...u}))):(this[i+"ClickEndShape"]=null,a.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:g}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:g}))})),o||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(A,{evt:t}):this._fire(A,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(E,{evt:t}):this._fire(E,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=c.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(b,c.createEvent(t)),c.releaseCapture(t.pointerId)}_lostpointercapture(t){c.releaseCapture(t.pointerId)}setPointersPositions(t){var i=this._getContentPosition(),r=null,a=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._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,a=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:a},this._pointerPositions=[{x:r,y:a,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:a,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){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}}_buildDOM(){if(this.bufferCanvas=new n.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new n.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),a.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()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=U,U.prototype.nodeType="Stage",(0,d._registerNode)(U),i.Factory.addGetterSetter(U,"container"),a.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(it);var lt={},dt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=s,i=o,r=l,a=h,n=d,c=s,g=rt;var u="hasShadow",f="shadowRGBA",p="patternImage",v="linearGradient",_="radialGradient";let m;function y(){return m||(m=i.Util.createCanvasElement().getContext("2d"),m)}t.shapes={};class x extends a.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(u,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(p,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=y().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const a=r.getMatrix(),n="undefined"==typeof DOMMatrix?{a:a[0],b:a[1],c:a[2],d:a[3],e:a[4],f:a[5]}:new DOMMatrix(a);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(v,this.__getLinearGradient)}__getLinearGradient(){var t=this.fillLinearGradientColorStops();if(t){for(var e=y(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),a=e.createLinearGradient(i.x,i.y,r.x,r.y),n=0;n<t.length;n+=2)a.addColorStop(t[n],t[n+1]);return a}}_getRadialGradient(){return this._getCache(_,this.__getRadialGradient)}__getRadialGradient(){var t=this.fillRadialGradientColorStops();if(t){for(var e=y(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),a=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),n=0;n<t.length;n+=2)a.addColorStop(t[n],t[n+1]);return a}}getShadowRGBA(){return this._getCache(f,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){var e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return a.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),r=this.hasStroke(),a=1!==this.getAbsoluteOpacity();if(i&&r&&a)return!0;const n=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(i&&r&&n&&s)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){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}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const r=t.skipTransform,a=t.relativeTo||e&&this.getStage()||void 0,n=this.getSelfRect(),s=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=n.width+s,h=n.height+s,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,g=o+Math.abs(d),u=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:g+2*f,height:u+2*f,x:-(s/2+f)+Math.min(d,0)+n.x,y:-(s/2+f)+Math.min(c,0)+n.y};return r?p:this._transformedRect(p,a)}drawScene(t,e,i){var r,a,n=this.getLayer(),s=t||n.getCanvas(),o=s.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow(),c=s.isCache,g=e===this;if(!this.isVisible()&&!g)return this;if(h){o.save();var u=this.getAbsoluteTransform(e).getMatrix();return o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!c){r=this.getStage();const t=i||r.bufferCanvas;(a=t.getContext()).clear(),a.save(),a._applyLineJoin(this);var f=this.getAbsoluteTransform(e).getMatrix();a.transform(f[0],f[1],f[2],f[3],f[4],f[5]),l.call(this,a,this),a.restore();var p=t.pixelRatio;d&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/p,t.height/p)}else{if(o._applyLineJoin(this),!g){f=this.getAbsoluteTransform(e).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}d&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;var a=this.getLayer(),n=t||a.hitCanvas,s=n&&n.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){s.save();var d=this.getAbsoluteTransform(e).getMatrix();return s.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(s),s.restore(),this}if(!o)return this;s.save(),s._applyLineJoin(this);if(!(this===e)){var c=this.getAbsoluteTransform(e).getMatrix();s.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return o.call(this,s,this),s.restore(),this}drawHitFromCache(t=0){var e,r,a,n,s,o=this._getCanvasCache(),h=this._getCachedSceneCanvas(),l=o.hit,d=l.getContext(),c=l.getWidth(),g=l.getHeight();d.clear(),d.drawImage(h._canvas,0,0,c,g);try{for(a=(r=(e=d.getImageData(0,0,c,g)).data).length,n=i.Util._hexToRgb(this.colorKey),s=0;s<a;s+=4)r[s+3]>t?(r[s]=n.r,r[s+1]=n.g,r[s+2]=n.b,r[s+3]=255):r[s+3]=0;d.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return g.hasPointerCapture(t,this)}setPointerCapture(t){g.setPointerCapture(t,this)}releaseCapture(t){g.releaseCapture(t,this)}}t.Shape=x,x.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},x.prototype._strokeFunc=function(t){t.stroke()},x.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},x.prototype._strokeFuncHit=function(t){t.stroke()},x.prototype._centroid=!1,x.prototype.nodeType="Shape",(0,c._registerNode)(x),x.prototype.eventListeners={},x.prototype.on.call(x.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(u)})),x.prototype.on.call(x.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(f)})),x.prototype.on.call(x.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(p)})),x.prototype.on.call(x.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(v)})),x.prototype.on.call(x.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(_)})),r.Factory.addGetterSetter(x,"stroke",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(x,"strokeWidth",2,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(x,"hitStrokeWidth","auto",(0,n.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(x,"strokeHitEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(x,"perfectDrawEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(x,"shadowForStrokeEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(x,"lineJoin"),r.Factory.addGetterSetter(x,"lineCap"),r.Factory.addGetterSetter(x,"sceneFunc"),r.Factory.addGetterSetter(x,"hitFunc"),r.Factory.addGetterSetter(x,"dash"),r.Factory.addGetterSetter(x,"dashOffset",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"shadowColor",void 0,(0,n.getStringValidator)()),r.Factory.addGetterSetter(x,"shadowBlur",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"shadowOpacity",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(x,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(x,"shadowOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"shadowOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillPatternImage"),r.Factory.addGetterSetter(x,"fill",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(x,"fillPatternX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillPatternY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(x,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(x,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(x,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(x,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(x,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(x,"fillEnabled",!0),r.Factory.addGetterSetter(x,"strokeEnabled",!0),r.Factory.addGetterSetter(x,"shadowEnabled",!0),r.Factory.addGetterSetter(x,"dashEnabled",!0),r.Factory.addGetterSetter(x,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(x,"fillPriority","color"),r.Factory.addComponentsGetterSetter(x,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(x,"fillPatternOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillPatternOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(x,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(x,"fillPatternScaleX",1,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(x,"fillPatternScaleY",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(x,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(x,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(x,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(x,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(x,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(x,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(x,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(x,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(x,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(x,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(x,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(x,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(x,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(x,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(x,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(x,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(x,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(x,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(x,"fillPatternRotation",0),r.Factory.addGetterSetter(x,"fillRule",void 0,(0,n.getStringValidator)()),r.Factory.backCompat(x,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(dt),Object.defineProperty(lt,"__esModule",{value:!0}),lt.Layer=void 0;const ct=o,gt=J,ut=h,ft=l,pt=f,vt=d,_t=dt,mt=s;var yt=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],xt=yt.length;class bt extends gt.Container{constructor(t){super(t),this.canvas=new pt.SceneCanvas,this.hitCanvas=new pt.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){ut.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!ut.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(ut.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(ut.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var t=this.getNativeCanvasElement();return ut.Node.prototype.remove.call(this),t&&t.parentNode&&ct.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&ct.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(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(),ut.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){ct.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){ct.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,ct.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(let r=0;r<xt;r++){const a=yt[r],n=this._getIntersection({x:t.x+a.x*e,y:t.y+a.y*e}),s=n.shape;if(s)return s;if(i=!!n.antialiased,!n.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,r=i[3];if(255===r){const t=ct.Util._rgbToHex(i[0],i[1],i[2]),e=_t.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,e){var i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),gt.Container.prototype.drawScene.call(this,r,e),this._fire("draw",{node:this}),this}drawHit(t,e){var i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),gt.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){ct.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return ct.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}destroy(){return ct.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}lt.Layer=bt,bt.prototype.nodeType="Layer",(0,mt._registerNode)(bt),ft.Factory.addGetterSetter(bt,"imageSmoothingEnabled",!0),ft.Factory.addGetterSetter(bt,"clearBeforeDraw",!0),ft.Factory.addGetterSetter(bt,"hitGraphEnabled",!0,(0,vt.getBooleanValidator)());var St={};Object.defineProperty(St,"__esModule",{value:!0}),St.FastLayer=void 0;const wt=o,Ct=lt,kt=s;class Pt extends Ct.Layer{constructor(t){super(t),this.listening(!1),wt.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}St.FastLayer=Pt,Pt.prototype.nodeType="FastLayer",(0,kt._registerNode)(Pt);var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Group=void 0;const At=o,Mt=J,Ft=s;class Rt extends Mt.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&At.Util.throw("You may only add groups and shapes to groups.")}}Tt.Group=Rt,Rt.prototype.nodeType="Group",(0,Ft._registerNode)(Rt);var It={};Object.defineProperty(It,"__esModule",{value:!0}),It.Animation=void 0;const Et=s,Ot=o,Gt=Et.glob.performance&&Et.glob.performance.now?function(){return Et.glob.performance.now()}:function(){return(new Date).getTime()};class Dt{constructor(t,e){this.id=Dt.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Gt(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Dt.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Gt(),Dt._addAnimation(this),this}stop(){return Dt._removeAnimation(this),this}_updateFrameObject(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}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const r=e[i],a=r.layers,n=r.func;r._updateFrameObject(Gt());const s=a.length;let o;if(o=!n||!1!==n.call(r,r.frame),o)for(let e=0;e<s;e++){const i=a[e];void 0!==i._id&&(t[i._id]=i)}}for(let e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=Dt;t.animations.length?(t._runFrames(),Ot.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ot.Util.requestAnimFrame(this._animationLoop))}}It.Animation=Dt,Dt.animations=[],Dt.animIdCounter=0,Dt.animRunning=!1;var Lt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=o,i=It,r=h,a=s;var n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},l=0,d=["fill","stroke","shadowColor"];class c{constructor(t,e,i,r,a,n,s){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=n,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=a-this.begin,this.pause()}fire(t){var e=this[t];e&&e()}setTime(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())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class g{constructor(r){var s,o,h=this,d=r.node,u=d._id,f=r.easing||t.Easings.Linear,p=!!r.yoyo;s=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=d,this._id=l++;var v=d.getLayer()||(d instanceof a.Konva.Stage?d.getLayers():null);for(o in v||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){h.tween.onEnterFrame()}),v),this.tween=new c(o,(function(t){h._tweenFunc(t)}),f,0,1,1e3*s,p),this._addListeners(),g.attrs[u]||(g.attrs[u]={}),g.attrs[u][this._id]||(g.attrs[u][this._id]={}),g.tweens[u]||(g.tweens[u]={}),r)void 0===n[o]&&this._addAttr(o,r[o]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){var r,a,n,s,o,h,l,c,u=this.node,f=u._id;if((n=g.tweens[f][t])&&delete g.attrs[f][n][t],r=u.getAttr(t),e.Util._isArray(i))if(a=[],o=Math.max(i.length,r.length),"points"===t&&i.length!==r.length&&(i.length>r.length?(l=r,r=e.Util._prepareArrayForTween(r,i,u.closed())):(h=i,i=e.Util._prepareArrayForTween(i,r,u.closed()))),0===t.indexOf("fill"))for(s=0;s<o;s++)if(s%2==0)a.push(i[s]-r[s]);else{var p=e.Util.colorToRGBA(r[s]);c=e.Util.colorToRGBA(i[s]),r[s]=p,a.push({r:c.r-p.r,g:c.g-p.g,b:c.b-p.b,a:c.a-p.a})}else for(s=0;s<o;s++)a.push(i[s]-r[s]);else-1!==d.indexOf(t)?(r=e.Util.colorToRGBA(r),a={r:(c=e.Util.colorToRGBA(i)).r-r.r,g:c.g-r.g,b:c.b-r.b,a:c.a-r.a}):a=i-r;g.attrs[f][this._id][t]={start:r,diff:a,end:i,trueEnd:h,trueStart:l},g.tweens[f][t]=this._id}_tweenFunc(t){var i,r,a,n,s,o,h,l,c=this.node,u=g.attrs[c._id][this._id];for(i in u){if(a=(r=u[i]).start,n=r.diff,l=r.end,e.Util._isArray(a))if(s=[],h=Math.max(a.length,l.length),0===i.indexOf("fill"))for(o=0;o<h;o++)o%2==0?s.push((a[o]||0)+n[o]*t):s.push("rgba("+Math.round(a[o].r+n[o].r*t)+","+Math.round(a[o].g+n[o].g*t)+","+Math.round(a[o].b+n[o].b*t)+","+(a[o].a+n[o].a*t)+")");else for(o=0;o<h;o++)s.push((a[o]||0)+n[o]*t);else s=-1!==d.indexOf(i)?"rgba("+Math.round(a.r+n.r*t)+","+Math.round(a.g+n.g*t)+","+Math.round(a.b+n.b*t)+","+(a.a+n.a*t)+")":a+n*t;c.setAttr(i,s)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var t=this.node,e=g.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var t=this.node,e=g.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var t,e=this.node._id,i=this._id,r=g.tweens[e];for(t in this.pause(),r)delete g.tweens[e][t];delete g.attrs[e][i]}}t.Tween=g,g.attrs={},g.tweens={},r.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new g(t).play()},t.Easings={BackEaseIn(t,e,i,r){var a=1.70158;return i*(t/=r)*t*((a+1)*t-a)+e},BackEaseOut(t,e,i,r){var a=1.70158;return i*((t=t/r-1)*t*((a+1)*t+a)+1)+e},BackEaseInOut(t,e,i,r){var a=1.70158;return(t/=r/2)<1?i/2*(t*t*((1+(a*=1.525))*t-a))+e:i/2*((t-=2)*t*((1+(a*=1.525))*t+a)+2)+e},ElasticEaseIn(t,e,i,r,a,n){var s=0;return 0===t?e:1==(t/=r)?e+i:(n||(n=.3*r),!a||a<Math.abs(i)?(a=i,s=n/4):s=n/(2*Math.PI)*Math.asin(i/a),-a*Math.pow(2,10*(t-=1))*Math.sin((t*r-s)*(2*Math.PI)/n)+e)},ElasticEaseOut(t,e,i,r,a,n){var s=0;return 0===t?e:1==(t/=r)?e+i:(n||(n=.3*r),!a||a<Math.abs(i)?(a=i,s=n/4):s=n/(2*Math.PI)*Math.asin(i/a),a*Math.pow(2,-10*t)*Math.sin((t*r-s)*(2*Math.PI)/n)+i+e)},ElasticEaseInOut(t,e,i,r,a,n){var s=0;return 0===t?e:2==(t/=r/2)?e+i:(n||(n=r*(.3*1.5)),!a||a<Math.abs(i)?(a=i,s=n/4):s=n/(2*Math.PI)*Math.asin(i/a),t<1?a*Math.pow(2,10*(t-=1))*Math.sin((t*r-s)*(2*Math.PI)/n)*-.5+e:a*Math.pow(2,-10*(t-=1))*Math.sin((t*r-s)*(2*Math.PI)/n)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(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:(e,i,r,a)=>r-t.Easings.BounceEaseOut(a-e,0,r,a)+i,BounceEaseInOut:(e,i,r,a)=>e<a/2?.5*t.Easings.BounceEaseIn(2*e,0,r,a)+i:.5*t.Easings.BounceEaseOut(2*e-a,0,r,a)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(Lt),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=s,i=o,r=h,a=J,n=it,l=lt,d=St,c=Tt,g=T,u=dt,v=It,_=Lt,m=p,y=f;t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:a.Container,Stage:n.Stage,stages:n.stages,Layer:l.Layer,FastLayer:d.FastLayer,Group:c.Group,DD:g.DD,Shape:u.Shape,shapes:u.shapes,Animation:v.Animation,Tween:_.Tween,Easings:_.Easings,Context:m.Context,Canvas:y.Canvas}),t.default=t.Konva}(n);var Nt={};Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.Arc=void 0;const Ut=l,Bt=dt,Wt=s,zt=d,Ht=s;class Vt extends Bt.Shape{_sceneFunc(t){var e=Wt.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)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),r=Wt.Konva.getAngle(i?360-this.angle():this.angle()),a=Math.cos(Math.min(r,Math.PI)),n=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),s=Math.sin(Math.min(r,Math.PI/2)),o=a*(a>0?t:e),h=n*(n>0?t:e),l=s*(s>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}Nt.Arc=Vt,Vt.prototype._centroid=!0,Vt.prototype.className="Arc",Vt.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Ht._registerNode)(Vt),Ut.Factory.addGetterSetter(Vt,"innerRadius",0,(0,zt.getNumberValidator)()),Ut.Factory.addGetterSetter(Vt,"outerRadius",0,(0,zt.getNumberValidator)()),Ut.Factory.addGetterSetter(Vt,"angle",0,(0,zt.getNumberValidator)()),Ut.Factory.addGetterSetter(Vt,"clockwise",!1,(0,zt.getBooleanValidator)());var jt={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.Line=void 0;const Xt=l,Yt=dt,qt=d,Qt=s;function Jt(t,e,i,r,a,n,s){var o=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(a-i,2)+Math.pow(n-r,2)),l=s*o/(o+h),d=s*h/(o+h);return[i-l*(a-t),r-l*(n-e),i+d*(a-t),r+d*(n-e)]}function Zt(t,e){var i,r,a=t.length,n=[];for(i=2;i<a-2;i+=2)r=Jt(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(r[0])||(n.push(r[0]),n.push(r[1]),n.push(t[i]),n.push(t[i+1]),n.push(r[2]),n.push(r[3]));return n}class $t extends Yt.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){var e,i,r,a=this.points(),n=a.length,s=this.tension(),o=this.closed(),h=this.bezier();if(n){if(t.beginPath(),t.moveTo(a[0],a[1]),0!==s&&n>4){for(i=(e=this.getTensionPoints()).length,r=o?0:4,o||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++]);o||t.quadraticCurveTo(e[i-2],e[i-1],a[n-2],a[n-1])}else if(h)for(r=2;r<n;)t.bezierCurveTo(a[r++],a[r++],a[r++],a[r++],a[r++],a[r++]);else for(r=2;r<n;r+=2)t.lineTo(a[r],a[r+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Zt(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),r=Jt(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),a=Jt(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),n=Zt(t,i);return[r[2],r[3]].concat(n).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){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()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points())[0],a=t[0],n=t[1],s=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),a=Math.max(a,e),n=Math.min(n,i),s=Math.max(s,i);return{x:r,y:n,width:a-r,height:s-n}}}Kt.Line=$t,$t.prototype.className="Line",$t.prototype._attrsAffectingSize=["points","bezier","tension"],(0,Qt._registerNode)($t),Xt.Factory.addGetterSetter($t,"closed",!1),Xt.Factory.addGetterSetter($t,"bezier",!1),Xt.Factory.addGetterSetter($t,"tension",0,(0,qt.getNumberValidator)()),Xt.Factory.addGetterSetter($t,"points",[],(0,qt.getNumberArrayValidator)());var te={},ee={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];t.getCubicArcLength=(i,r,a)=>{let n,s,o;n=a/2,s=0;for(let a=0;a<20;a++)o=n*t.tValues[20][a]+n,s+=t.cValues[20][a]*e(i,r,o);return n*s};function e(t,e,r){const a=i(1,r,t),n=i(1,r,e),s=a*a+n*n;return Math.sqrt(s)}t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],a=e[0]-2*e[1]+e[2],n=2*t[1]-2*t[0],s=2*e[1]-2*e[0],o=4*(r*r+a*a),h=4*(r*n+a*s),l=n*n+s*s;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,g=l/o-d*d,u=c*c+g>0?Math.sqrt(c*c+g):0,f=d*d+g>0?Math.sqrt(d*d+g):0,p=d+Math.sqrt(d*d+g)!==0?g*Math.log(Math.abs((c+u)/(d+f))):0;return Math.sqrt(o)/2*(c*u-d*f+p)};const i=(e,r,a)=>{const n=a.length-1;let s,o;if(0===n)return 0;if(0===e){o=0;for(let e=0;e<=n;e++)o+=t.binomialCoefficients[n][e]*Math.pow(1-r,n-e)*Math.pow(r,e)*a[e];return o}s=new Array(n);for(let t=0;t<n;t++)s[t]=n*(a[t+1]-a[t]);return i(e-1,r,s)};t.t2length=(t,e,i)=>{let r=1,a=t/e,n=(t-i(a))/e,s=0;for(;r>.001;){const o=i(a+n),h=Math.abs(t-o)/e;if(h<r)r=h,a+=n;else{const s=i(a-n),o=Math.abs(t-s)/e;o<r?(r=o,a-=n):n/=2}if(s++,s>500)break}return a}}(ee),Object.defineProperty(te,"__esModule",{value:!0}),te.Path=void 0;const ie=l,re=dt,ae=s,ne=ee;class se extends re.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=se.parsePathData(this.data()),this.pathLength=se.getPathLength(this.dataArray)}_sceneFunc(t){var e=this.dataArray;t.beginPath();for(var i=!1,r=0;r<e.length;r++){var a=e[r].command,n=e[r].points;switch(a){case"L":t.lineTo(n[0],n[1]);break;case"M":t.moveTo(n[0],n[1]);break;case"C":t.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case"Q":t.quadraticCurveTo(n[0],n[1],n[2],n[3]);break;case"A":var s=n[0],o=n[1],h=n[2],l=n[3],d=n[4],c=n[5],g=n[6],u=n[7],f=h>l?h:l,p=h>l?1:h/l,v=h>l?l/h:1;t.translate(s,o),t.rotate(g),t.scale(p,v),t.arc(0,0,f,d,d+c,1-u),t.scale(1/p,1/v),t.rotate(-g),t.translate(-s,-o);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){var t=[];this.dataArray.forEach((function(e){if("A"===e.command){var i=e.points[4],r=e.points[5],a=e.points[4]+r,n=Math.PI/180;if(Math.abs(i-a)<n&&(n=Math.abs(i-a)),r<0)for(let r=i-n;r>a;r-=n){const i=se.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}else for(let r=i+n;r<a;r+=n){const i=se.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const r=se.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(r.x,r.y)}else t=t.concat(e.points)}));for(var e,i,r=t[0],a=t[0],n=t[1],s=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(r=Math.min(r,e),a=Math.max(a,e)),isNaN(i)||(n=Math.min(n,i),s=Math.max(s,i));return{x:r,y:n,width:a-r,height:s-n}}getLength(){return this.pathLength}getPointAtLength(t){return se.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(var i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){var i,r=0,a=e.length;if(!a)return null;for(;r<a&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===a)return{x:(i=e[r-1].points.slice(-2))[0],y:i[1]};if(t<.01)return{x:(i=e[r].points.slice(0,2))[0],y:i[1]};var n=e[r],s=n.points;switch(n.command){case"L":return se.getPointOnLine(t,n.start.x,n.start.y,s[0],s[1]);case"C":return se.getPointOnCubicBezier((0,ne.t2length)(t,se.getPathLength(e),(t=>(0,ne.getCubicArcLength)([n.start.x,s[0],s[2],s[4]],[n.start.y,s[1],s[3],s[5]],t))),n.start.x,n.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case"Q":return se.getPointOnQuadraticBezier((0,ne.t2length)(t,se.getPathLength(e),(t=>(0,ne.getQuadraticArcLength)([n.start.x,s[0],s[2]],[n.start.y,s[1],s[3]],t))),n.start.x,n.start.y,s[0],s[1],s[2],s[3]);case"A":var o=s[0],h=s[1],l=s[2],d=s[3],c=s[4],g=s[5],u=s[6];return c+=g*t/n.pathLength,se.getPointOnEllipticalArc(o,h,l,d,c,u)}return null}static getPointOnLine(t,e,i,r,a,n,s){n=null!=n?n:e,s=null!=s?s:i;const o=this.getLineLength(e,i,r,a);if(o<1e-10)return{x:e,y:i};if(r===e)return{x:n,y:s+(a>i?t:-t)};const h=(a-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(s-i-h*(n-e))<1e-10)return{x:n+l,y:s+d};const c=((n-e)*(r-e)+(s-i)*(a-i))/(o*o),g=e+c*(r-e),u=i+c*(a-i),f=this.getLineLength(n,s,g,u),p=Math.sqrt(t*t-f*f),v=Math.sqrt(p*p/(1+h*h))*(r<e?-1:1);return{x:g+v,y:u+h*v}}static getPointOnCubicBezier(t,e,i,r,a,n,s,o,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function g(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+n*d(t)+r*c(t)+e*g(t),y:h*l(t)+s*d(t)+a*c(t)+i*g(t)}}static getPointOnQuadraticBezier(t,e,i,r,a,n,s){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:n*o(t)+r*h(t)+e*l(t),y:s*o(t)+a*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,a,n){var s=Math.cos(n),o=Math.sin(n),h=i*Math.cos(a),l=r*Math.sin(a);return{x:t+(h*s-l*o),y:e+(h*o+l*s)}}static parsePathData(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 a,n=e.split("|"),s=[],o=[],h=0,l=0,d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<n.length;r++){var c=n[r],g=c.charAt(0);for(c=c.slice(1),o.length=0;a=d.exec(c);)o.push(a[0]);for(var u=[],f=0,p=o.length;f<p;f++)if("00"!==o[f]){var v=parseFloat(o[f]);isNaN(v)?u.push(0):u.push(v)}else u.push(0,0);for(;u.length>0&&!isNaN(u[0]);){var _,m,y,x,b,S,w,C,k,P,T="",A=[],M=h,F=l;switch(g){case"l":h+=u.shift(),l+=u.shift(),T="L",A.push(h,l);break;case"L":h=u.shift(),l=u.shift(),A.push(h,l);break;case"m":var R=u.shift(),I=u.shift();if(h+=R,l+=I,T="M",s.length>2&&"z"===s[s.length-1].command)for(var E=s.length-2;E>=0;E--)if("M"===s[E].command){h=s[E].points[0]+R,l=s[E].points[1]+I;break}A.push(h,l),g="l";break;case"M":h=u.shift(),l=u.shift(),T="M",A.push(h,l),g="L";break;case"h":h+=u.shift(),T="L",A.push(h,l);break;case"H":h=u.shift(),T="L",A.push(h,l);break;case"v":l+=u.shift(),T="L",A.push(h,l);break;case"V":l=u.shift(),T="L",A.push(h,l);break;case"C":A.push(u.shift(),u.shift(),u.shift(),u.shift()),h=u.shift(),l=u.shift(),A.push(h,l);break;case"c":A.push(h+u.shift(),l+u.shift(),h+u.shift(),l+u.shift()),h+=u.shift(),l+=u.shift(),T="C",A.push(h,l);break;case"S":m=h,y=l,"C"===(_=s[s.length-1]).command&&(m=h+(h-_.points[2]),y=l+(l-_.points[3])),A.push(m,y,u.shift(),u.shift()),h=u.shift(),l=u.shift(),T="C",A.push(h,l);break;case"s":m=h,y=l,"C"===(_=s[s.length-1]).command&&(m=h+(h-_.points[2]),y=l+(l-_.points[3])),A.push(m,y,h+u.shift(),l+u.shift()),h+=u.shift(),l+=u.shift(),T="C",A.push(h,l);break;case"Q":A.push(u.shift(),u.shift()),h=u.shift(),l=u.shift(),A.push(h,l);break;case"q":A.push(h+u.shift(),l+u.shift()),h+=u.shift(),l+=u.shift(),T="Q",A.push(h,l);break;case"T":m=h,y=l,"Q"===(_=s[s.length-1]).command&&(m=h+(h-_.points[0]),y=l+(l-_.points[1])),h=u.shift(),l=u.shift(),T="Q",A.push(m,y,h,l);break;case"t":m=h,y=l,"Q"===(_=s[s.length-1]).command&&(m=h+(h-_.points[0]),y=l+(l-_.points[1])),h+=u.shift(),l+=u.shift(),T="Q",A.push(m,y,h,l);break;case"A":x=u.shift(),b=u.shift(),S=u.shift(),w=u.shift(),C=u.shift(),k=h,P=l,h=u.shift(),l=u.shift(),T="A",A=this.convertEndpointToCenterParameterization(k,P,h,l,w,C,x,b,S);break;case"a":x=u.shift(),b=u.shift(),S=u.shift(),w=u.shift(),C=u.shift(),k=h,P=l,h+=u.shift(),l+=u.shift(),T="A",A=this.convertEndpointToCenterParameterization(k,P,h,l,w,C,x,b,S)}s.push({command:T||g,points:A,start:{x:M,y:F},pathLength:this.calcLength(M,F,T||g,A)})}"z"!==g&&"Z"!==g||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,r){var a,n,s,o,h=se;switch(i){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,ne.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,ne.getQuadraticArcLength)([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":a=0;var l=r[4],d=r[5],c=r[4]+d,g=Math.PI/180;if(Math.abs(l-c)<g&&(g=Math.abs(l-c)),n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],l,0),d<0)for(o=l-g;o>c;o-=g)s=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),a+=h.getLineLength(n.x,n.y,s.x,s.y),n=s;else for(o=l+g;o<c;o+=g)s=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),a+=h.getLineLength(n.x,n.y,s.x,s.y),n=s;return s=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),a+=h.getLineLength(n.x,n.y,s.x,s.y)}return 0}static convertEndpointToCenterParameterization(t,e,i,r,a,n,s,o,h){var l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,g=d*d/(s*s)+c*c/(o*o);g>1&&(s*=Math.sqrt(g),o*=Math.sqrt(g));var u=Math.sqrt((s*s*(o*o)-s*s*(c*c)-o*o*(d*d))/(s*s*(c*c)+o*o*(d*d)));a===n&&(u*=-1),isNaN(u)&&(u=0);var f=u*s*c/o,p=u*-o*d/s,v=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+r)/2+Math.sin(l)*f+Math.cos(l)*p,m=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(m(t)*m(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(d-f)/s,(c-p)/o]),S=[(d-f)/s,(c-p)/o],w=[(-1*d-f)/s,(-1*c-p)/o],C=x(S,w);return y(S,w)<=-1&&(C=Math.PI),y(S,w)>=1&&(C=0),0===n&&C>0&&(C-=2*Math.PI),1===n&&C<0&&(C+=2*Math.PI),[v,_,s,o,b,C,l,n]}}te.Path=se,se.prototype.className="Path",se.prototype._attrsAffectingSize=["data"],(0,ae._registerNode)(se),ie.Factory.addGetterSetter(se,"data"),Object.defineProperty(jt,"__esModule",{value:!0}),jt.Arrow=void 0;const oe=l,he=Kt,le=d,de=s,ce=te;class ge extends he.Line{_sceneFunc(t){super._sceneFunc(t);var e=2*Math.PI,i=this.points(),r=i,a=0!==this.tension()&&i.length>4;a&&(r=this.getTensionPoints());var n,s,o=this.pointerLength(),h=i.length;if(a){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[h-2],i[h-1]],e=ce.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),a=ce.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);n=i[h-2]-a.x,s=i[h-1]-a.y}else n=i[h-2]-i[h-4],s=i[h-1]-i[h-3];var l=(Math.atan2(s,n)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[h-2],i[h-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),a?(n=(r[0]+r[2])/2-i[0],s=(r[1]+r[3])/2-i[1]):(n=i[2]-i[0],s=i[3]-i[1]),t.rotate((Math.atan2(-s,-n)+e)%e),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){var e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}}jt.Arrow=ge,ge.prototype.className="Arrow",(0,de._registerNode)(ge),oe.Factory.addGetterSetter(ge,"pointerLength",10,(0,le.getNumberValidator)()),oe.Factory.addGetterSetter(ge,"pointerWidth",10,(0,le.getNumberValidator)()),oe.Factory.addGetterSetter(ge,"pointerAtBeginning",!1),oe.Factory.addGetterSetter(ge,"pointerAtEnding",!0);var ue={};Object.defineProperty(ue,"__esModule",{value:!0}),ue.Circle=void 0;const fe=l,pe=dt,ve=d,_e=s;class me extends pe.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}ue.Circle=me,me.prototype._centroid=!0,me.prototype.className="Circle",me.prototype._attrsAffectingSize=["radius"],(0,_e._registerNode)(me),fe.Factory.addGetterSetter(me,"radius",0,(0,ve.getNumberValidator)());var ye={};Object.defineProperty(ye,"__esModule",{value:!0}),ye.Ellipse=void 0;const xe=l,be=dt,Se=d,we=s;class Ce extends be.Shape{_sceneFunc(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)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}ye.Ellipse=Ce,Ce.prototype.className="Ellipse",Ce.prototype._centroid=!0,Ce.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,we._registerNode)(Ce),xe.Factory.addComponentsGetterSetter(Ce,"radius",["x","y"]),xe.Factory.addGetterSetter(Ce,"radiusX",0,(0,Se.getNumberValidator)()),xe.Factory.addGetterSetter(Ce,"radiusY",0,(0,Se.getNumberValidator)());var ke={};Object.defineProperty(ke,"__esModule",{value:!0}),ke.Image=void 0;const Pe=o,Te=l,Ae=dt,Me=s,Fe=d;let Re=class t extends Ae.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),r=this.cornerRadius(),a=this.attrs.image;let n;if(a){const t=this.attrs.cropWidth,r=this.attrs.cropHeight;n=t&&r?[a,this.cropX(),this.cropY(),t,r,0,0,e,i]:[a,0,0,e,i]}(this.hasFill()||this.hasStroke()||r)&&(t.beginPath(),r?Pe.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),a&&(r&&t.clip(),t.drawImage.apply(t,n))}_hitFunc(t){var e=this.width(),i=this.height(),r=this.cornerRadius();t.beginPath(),r?Pe.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,r=null){var a=Pe.Util.createImageElement();a.onload=function(){var e=new t({image:a});i(e)},a.onerror=r,a.crossOrigin="Anonymous",a.src=e}};ke.Image=Re,Re.prototype.className="Image",(0,Me._registerNode)(Re),Te.Factory.addGetterSetter(Re,"cornerRadius",0,(0,Fe.getNumberOrArrayOfNumbersValidator)(4)),Te.Factory.addGetterSetter(Re,"image"),Te.Factory.addComponentsGetterSetter(Re,"crop",["x","y","width","height"]),Te.Factory.addGetterSetter(Re,"cropX",0,(0,Fe.getNumberValidator)()),Te.Factory.addGetterSetter(Re,"cropY",0,(0,Fe.getNumberValidator)()),Te.Factory.addGetterSetter(Re,"cropWidth",0,(0,Fe.getNumberValidator)()),Te.Factory.addGetterSetter(Re,"cropHeight",0,(0,Fe.getNumberValidator)());var Ie={};Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.Tag=Ie.Label=void 0;const Ee=l,Oe=dt,Ge=Tt,De=d,Le=s;var Ne=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Ue="up",Be="right",We="down",ze="left",He=Ne.length;class Ve extends Ge.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){var e,i=this,r=function(){i._sync()};for(e=0;e<He;e++)t.on(Ne[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var t,e,i,r,a,n,s,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),r=h.pointerWidth(),s=h.pointerHeight(),a=0,n=0,i){case Ue:a=t/2,n=-1*s;break;case Be:a=t+r,n=e/2;break;case We:a=t/2,n=e+s;break;case ze:a=-1*r,n=e/2}h.setAttrs({x:-1*a,y:-1*n,width:t,height:e}),o.setAttrs({x:-1*a,y:-1*n})}}}Ie.Label=Ve,Ve.prototype.className="Label",(0,Le._registerNode)(Ve);class je extends Oe.Shape{_sceneFunc(t){var e=this.width(),i=this.height(),r=this.pointerDirection(),a=this.pointerWidth(),n=this.pointerHeight(),s=this.cornerRadius();let o=0,h=0,l=0,d=0;"number"==typeof s?o=h=l=d=Math.min(s,e/2,i/2):(o=Math.min(s[0]||0,e/2,i/2),h=Math.min(s[1]||0,e/2,i/2),d=Math.min(s[2]||0,e/2,i/2),l=Math.min(s[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),r===Ue&&(t.lineTo((e-a)/2,0),t.lineTo(e/2,-1*n),t.lineTo((e+a)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),r===Be&&(t.lineTo(e,(i-n)/2),t.lineTo(e+a,i/2),t.lineTo(e,(i+n)/2)),t.lineTo(e,i-d),t.arc(e-d,i-d,d,0,Math.PI/2,!1),r===We&&(t.lineTo((e+a)/2,i),t.lineTo(e/2,i+n),t.lineTo((e-a)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),r===ze&&(t.lineTo(0,(i+n)/2),t.lineTo(-1*a,i/2),t.lineTo(0,(i-n)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){var t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),a=this.pointerDirection(),n=this.width(),s=this.height();return a===Ue?(e-=r,s+=r):a===We?s+=r:a===ze?(t-=1.5*i,n+=i):a===Be&&(n+=1.5*i),{x:t,y:e,width:n,height:s}}}Ie.Tag=je,je.prototype.className="Tag",(0,Le._registerNode)(je),Ee.Factory.addGetterSetter(je,"pointerDirection","none"),Ee.Factory.addGetterSetter(je,"pointerWidth",0,(0,De.getNumberValidator)()),Ee.Factory.addGetterSetter(je,"pointerHeight",0,(0,De.getNumberValidator)()),Ee.Factory.addGetterSetter(je,"cornerRadius",0,(0,De.getNumberOrArrayOfNumbersValidator)(4));var Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.Rect=void 0;const Xe=l,Ye=dt,qe=s,Qe=o,Je=d;class Ze extends Ye.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?Qe.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}}Ke.Rect=Ze,Ze.prototype.className="Rect",(0,qe._registerNode)(Ze),Xe.Factory.addGetterSetter(Ze,"cornerRadius",0,(0,Je.getNumberOrArrayOfNumbersValidator)(4));var $e={};Object.defineProperty($e,"__esModule",{value:!0}),$e.RegularPolygon=void 0;const ti=l,ei=dt,ii=d,ri=s;class ai extends ei.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(var r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();var e=t[0].x,i=t[0].y,r=t[0].x,a=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),a=Math.max(a,t.y)})),{x:e,y:r,width:i-e,height:a-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}$e.RegularPolygon=ai,ai.prototype.className="RegularPolygon",ai.prototype._centroid=!0,ai.prototype._attrsAffectingSize=["radius"],(0,ri._registerNode)(ai),ti.Factory.addGetterSetter(ai,"radius",0,(0,ii.getNumberValidator)()),ti.Factory.addGetterSetter(ai,"sides",0,(0,ii.getNumberValidator)());var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.Ring=void 0;const si=l,oi=dt,hi=d,li=s;var di=2*Math.PI;class ci extends oi.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,di,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),di,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ni.Ring=ci,ci.prototype.className="Ring",ci.prototype._centroid=!0,ci.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,li._registerNode)(ci),si.Factory.addGetterSetter(ci,"innerRadius",0,(0,hi.getNumberValidator)()),si.Factory.addGetterSetter(ci,"outerRadius",0,(0,hi.getNumberValidator)());var gi={};Object.defineProperty(gi,"__esModule",{value:!0}),gi.Sprite=void 0;const ui=l,fi=dt,pi=It,vi=d,_i=s;class mi extends fi.Shape{constructor(t){super(t),this._updated=!0,this.anim=new pi.Animation((()=>{var t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,a=this.animations()[e],n=this.frameOffsets(),s=a[r+0],o=a[r+1],h=a[r+2],l=a[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(n){var c=n[e],g=2*i;t.drawImage(d,s,o,h,l,c[g+0],c[g+1],h,l)}else t.drawImage(d,s,o,h,l,0,0,h,l)}_hitFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,a=this.animations()[e],n=this.frameOffsets(),s=a[r+2],o=a[r+3];if(t.beginPath(),n){var h=n[e],l=2*i;t.rect(h[l+0],h[l+1],s,o)}else t.rect(0,0,s,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}gi.Sprite=mi,mi.prototype.className="Sprite",(0,_i._registerNode)(mi),ui.Factory.addGetterSetter(mi,"animation"),ui.Factory.addGetterSetter(mi,"animations"),ui.Factory.addGetterSetter(mi,"frameOffsets"),ui.Factory.addGetterSetter(mi,"image"),ui.Factory.addGetterSetter(mi,"frameIndex",0,(0,vi.getNumberValidator)()),ui.Factory.addGetterSetter(mi,"frameRate",17,(0,vi.getNumberValidator)()),ui.Factory.backCompat(mi,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var yi={};Object.defineProperty(yi,"__esModule",{value:!0}),yi.Star=void 0;const xi=l,bi=dt,Si=d,wi=s;class Ci extends bi.Shape{_sceneFunc(t){var e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var a=1;a<2*r;a++){var n=a%2==0?i:e,s=n*Math.sin(a*Math.PI/r),o=-1*n*Math.cos(a*Math.PI/r);t.lineTo(s,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}yi.Star=Ci,Ci.prototype.className="Star",Ci.prototype._centroid=!0,Ci.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,wi._registerNode)(Ci),xi.Factory.addGetterSetter(Ci,"numPoints",5,(0,Si.getNumberValidator)()),xi.Factory.addGetterSetter(Ci,"innerRadius",0,(0,Si.getNumberValidator)()),xi.Factory.addGetterSetter(Ci,"outerRadius",0,(0,Si.getNumberValidator)());var ki={};Object.defineProperty(ki,"__esModule",{value:!0}),ki.Text=ki.stringToArray=void 0;const Pi=o,Ti=l,Ai=dt,Mi=s,Fi=d,Ri=s;function Ii(t){return Array.from(t)}ki.stringToArray=Ii;var Ei,Oi="auto",Gi="inherit",Di="justify",Li="left",Ni="middle",Ui="normal",Bi=" ",Wi="none",zi=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Hi=zi.length;function Vi(){return Ei||(Ei=Pi.Util.createCanvasElement().getContext("2d"))}class ji extends Ai.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(var e=0;e<Hi;e++)this.on(zi[e]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e=this.textArr,i=e.length;if(this.text()){var r,a=this.padding(),n=this.fontSize(),s=this.lineHeight()*n,o=this.verticalAlign(),h=this.direction(),l=0,d=this.align(),c=this.getWidth(),g=this.letterSpacing(),u=this.fill(),f=this.textDecoration(),p=-1!==f.indexOf("underline"),v=-1!==f.indexOf("line-through");h=h===Gi?t.direction:h;var _=s/2,m=Ni;if(Mi.Konva._fixTextRendering){var y=this.measureSize("M");m="alphabetic",_=(y.fontBoundingBoxAscent-y.fontBoundingBoxDescent)/2+s/2}var x=0,b=0;for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",m),t.setAttr("textAlign",Li),o===Ni?l=(this.getHeight()-i*s-2*a)/2:"bottom"===o&&(l=this.getHeight()-i*s-2*a),t.translate(a,l+a),r=0;r<i;r++){x=0,b=0;var S,w,C,k=e[r],P=k.text,T=k.width,A=k.lastInParagraph;if(t.save(),"right"===d?x+=c-T-2*a:"center"===d&&(x+=(c-T-2*a)/2),p){t.save(),t.beginPath();const e=x,i=_+b+(Mi.Konva._fixTextRendering?Math.round(n/4):Math.round(n/2));t.moveTo(e,i),w=0===(S=P.split(" ").length-1),C=d!==Di||A?T:c-2*a,t.lineTo(e+Math.round(C),i),t.lineWidth=n/15;const r=this._getLinearGradient();t.strokeStyle=r||u,t.stroke(),t.restore()}if(v){t.save(),t.beginPath();let e=Mi.Konva._fixTextRendering?-Math.round(n/4):0;t.moveTo(x,_+b+e),w=0===(S=P.split(" ").length-1),C=d===Di&&A&&!w?c-2*a:T,t.lineTo(x+Math.round(C),_+b+e),t.lineWidth=n/15;const i=this._getLinearGradient();t.strokeStyle=i||u,t.stroke(),t.restore()}if("rtl"===h||0===g&&d!==Di)0!==g&&t.setAttr("letterSpacing",`${g}px`),this._partialTextX=x,this._partialTextY=_+b,this._partialText=P,t.fillStrokeShape(this);else{S=P.split(" ").length-1;for(var M=Ii(P),F=0;F<M.length;F++){var R=M[F];" "!==R||A||d!==Di||(x+=(c-2*a-T)/S),this._partialTextX=x,this._partialTextY=_+b,this._partialText=R,t.fillStrokeShape(this),x+=this.measureSize(R).width+g}}t.restore(),i>1&&(_+=s)}}}_hitFunc(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){var e=Pi.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Oi||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Oi||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Pi.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,r,a,n,s,o,h,l,d,c,g,u=Vi(),f=this.fontSize();u.save(),u.font=this._getContextFont(),g=u.measureText(t),u.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=g.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=g.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=g.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(a=g.actualBoundingBoxRight)&&void 0!==a?a:75.732421875*p,alphabeticBaseline:null!==(n=g.alphabeticBaseline)&&void 0!==n?n:0,emHeightAscent:null!==(s=g.emHeightAscent)&&void 0!==s?s:100*p,emHeightDescent:null!==(o=g.emHeightDescent)&&void 0!==o?o:-20*p,fontBoundingBoxAscent:null!==(h=g.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=g.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=g.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=g.ideographicBaseline)&&void 0!==c?c:-21*p,width:g.width,height:f}}_getContextFont(){return this.fontStyle()+Bi+this.fontVariant()+Bi+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===Di&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){var e=this.letterSpacing(),i=t.length;return Vi().measureText(t).width+(i?e*(i-1):0)}_setTextData(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,a=this.attrs.width,n=this.attrs.height,s=a!==Oi&&void 0!==a,o=n!==Oi&&void 0!==n,h=this.padding(),l=a-2*h,d=n-2*h,c=0,g=this.wrap(),u="char"!==g&&g!==Wi,f=this.ellipsis();this.textArr=[],Vi().font=this._getContextFont();for(var p=f?this._getTextWidth("…"):0,v=0,_=t.length;v<_;++v){var m=t[v],y=this._getTextWidth(m);if(s&&y>l)for(;m.length>0;){for(var x=0,b=m.length,S="",w=0;x<b;){var C=x+b>>>1,k=m.slice(0,C+1),P=this._getTextWidth(k)+p;P<=l?(x=C+1,S=k,w=P):b=C}if(!S)break;if(u){var T,A=m[S.length];(T=(A===Bi||"-"===A)&&w<=l?S.length:Math.max(S.lastIndexOf(Bi),S.lastIndexOf("-"))+1)>0&&(x=T,S=S.slice(0,x),w=this._getTextWidth(S))}if(S=S.trimRight(),this._addTextLine(S),i=Math.max(i,w),c+=r,this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if((m=(m=m.slice(x)).trimLeft()).length>0&&(y=this._getTextWidth(m))<=l){this._addTextLine(m),c+=r,i=Math.max(i,y);break}}else this._addTextLine(m),c+=r,i=Math.max(i,y),this._shouldHandleEllipsis(c)&&v<_-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&c+r>d)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){var e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,a=r!==Oi&&void 0!==r,n=r-2*this.padding();return!(this.wrap()!==Wi)||a&&t+i>n}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==Oi&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(a&&r){if(e)this._getTextWidth(a.text+"…")<i||(a.text=a.text.slice(0,a.text.length-3));this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}ki.Text=ji,ji.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},ji.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},ji.prototype.className="Text",ji.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,Ri._registerNode)(ji),Ti.Factory.overWriteSetter(ji,"width",(0,Fi.getNumberOrAutoValidator)()),Ti.Factory.overWriteSetter(ji,"height",(0,Fi.getNumberOrAutoValidator)()),Ti.Factory.addGetterSetter(ji,"direction",Gi),Ti.Factory.addGetterSetter(ji,"fontFamily","Arial"),Ti.Factory.addGetterSetter(ji,"fontSize",12,(0,Fi.getNumberValidator)()),Ti.Factory.addGetterSetter(ji,"fontStyle",Ui),Ti.Factory.addGetterSetter(ji,"fontVariant",Ui),Ti.Factory.addGetterSetter(ji,"padding",0,(0,Fi.getNumberValidator)()),Ti.Factory.addGetterSetter(ji,"align",Li),Ti.Factory.addGetterSetter(ji,"verticalAlign","top"),Ti.Factory.addGetterSetter(ji,"lineHeight",1,(0,Fi.getNumberValidator)()),Ti.Factory.addGetterSetter(ji,"wrap","word"),Ti.Factory.addGetterSetter(ji,"ellipsis",!1,(0,Fi.getBooleanValidator)()),Ti.Factory.addGetterSetter(ji,"letterSpacing",0,(0,Fi.getNumberValidator)()),Ti.Factory.addGetterSetter(ji,"text","",(0,Fi.getStringValidator)()),Ti.Factory.addGetterSetter(ji,"textDecoration","");var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0}),Ki.TextPath=void 0;const Xi=o,Yi=l,qi=dt,Qi=te,Ji=ki,Zi=d,$i=s;var tr="normal";function er(t){t.fillText(this.partialText,0,0)}function ir(t){t.strokeText(this.partialText,0,0)}class rr extends qi.Shape{constructor(t){super(t),this.dummyCanvas=Xi.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Qi.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:Qi.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Qi.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(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(),a=this.glyphInfo;"underline"===e&&t.beginPath();for(var n=0;n<a.length;n++){t.save();var s=a[n].p0;t.translate(s.x,s.y),t.rotate(a[n].rotation),this.partialText=a[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&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()}_hitFunc(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 a=e[r].p1;t.lineTo(a.x,a.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Xi.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return Ji.Text.prototype.setText.call(this,t)}_getContextFont(){return Ji.Text.prototype._getContextFont.call(this)}_getTextSize(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.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),r=this.align(),a=this.kerningFunc(),n=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let s=0;"center"===r&&(s=Math.max(0,this.pathLength/2-n/2)),"right"===r&&(s=Math.max(0,this.pathLength-n));const o=(0,Ji.stringToArray)(this.text());let h=s;for(var l=0;l<o.length;l++){const t=this._getPointAtLength(h);if(!t)return;let e=this._getTextSize(o[l]).width+i;if(" "===o[l]&&"justify"===r){const t=this.text().split(" ").length-1;e+=(this.pathLength-n)/t}const s=this._getPointAtLength(h+e);if(!s)return;const d=Qi.Path.getLineLength(t.x,t.y,s.x,s.y);let c=0;if(a)try{c=a(o[l-1],o[l])*this.fontSize()}catch(t){c=0}t.x+=c,s.x+=c,this.textWidth+=c;const g=Qi.Path.getPointOnLine(c+d/2,t.x,t.y,s.x,s.y),u=Math.atan2(s.y-t.y,s.x-t.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:o[l],rotation:u,p0:t,p1:s}),h+=e}}getSelfRect(){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,a=t[0]||0,n=t[1]||0,s=t[1]||0,o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),a=Math.max(a,e),n=Math.min(n,i),s=Math.max(s,i);var h=this.fontSize();return{x:r-h/2,y:n-h/2,width:a-r+h,height:s-n+h}}destroy(){return Xi.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}Ki.TextPath=rr,rr.prototype._fillFunc=er,rr.prototype._strokeFunc=ir,rr.prototype._fillFuncHit=er,rr.prototype._strokeFuncHit=ir,rr.prototype.className="TextPath",rr.prototype._attrsAffectingSize=["text","fontSize","data"],(0,$i._registerNode)(rr),Yi.Factory.addGetterSetter(rr,"data"),Yi.Factory.addGetterSetter(rr,"fontFamily","Arial"),Yi.Factory.addGetterSetter(rr,"fontSize",12,(0,Zi.getNumberValidator)()),Yi.Factory.addGetterSetter(rr,"fontStyle",tr),Yi.Factory.addGetterSetter(rr,"align","left"),Yi.Factory.addGetterSetter(rr,"letterSpacing",0,(0,Zi.getNumberValidator)()),Yi.Factory.addGetterSetter(rr,"textBaseline","middle"),Yi.Factory.addGetterSetter(rr,"fontVariant",tr),Yi.Factory.addGetterSetter(rr,"text",""),Yi.Factory.addGetterSetter(rr,"textDecoration",null),Yi.Factory.addGetterSetter(rr,"kerningFunc",null);var ar={};Object.defineProperty(ar,"__esModule",{value:!0}),ar.Transformer=void 0;const nr=o,sr=l,or=h,hr=dt,lr=Ke,dr=Tt,cr=s,gr=d,ur=s;var fr="tr-konva",pr=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${fr}`)).join(" "),vr="nodesRect",_r=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],mr={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const yr="ontouchstart"in cr.Konva._global;var xr=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function br(t,e,i){const r=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),a=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:r,y:a}}function Sr(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return br(t,e,i)}let wr=0;class Cr extends dr.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(pr,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return nr.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return fr+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(nr.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(_r.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const r=t.getAbsolutePosition(),a=r.x-e.x,n=r.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+a,y:r.y+n}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(vr),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(vr,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){var r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),a=t.getAbsoluteScale(i),n=t.getAbsolutePosition(i),s=r.x*a.x-t.offsetX()*a.x,o=r.y*a.y-t.offsetY()*a.y;const h=(cr.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return br({x:n.x+s*Math.cos(h)+o*Math.sin(-h),y:n.y+o*Math.cos(h)+s*Math.sin(h),width:r.width*a.x,height:r.height*a.y,rotation:h},-cr.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map((e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var r=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],a=e.getAbsoluteTransform();r.forEach((function(e){var i=a.point(e);t.push(i)}))}));const e=new nr.Transform;e.rotate(-cr.Konva.getAngle(this.rotation()));var i=1/0,r=1/0,a=-1/0,n=-1/0;t.forEach((function(t){var s=e.point(t);void 0===i&&(i=a=s.x,r=n=s.y),i=Math.min(i,s.x),r=Math.min(r,s.y),a=Math.max(a,s.x),n=Math.max(n,s.y)})),e.invert();const s=e.point({x:i,y:r});return{x:s.x,y:s.y,width:a-i,height:n-r,rotation:cr.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),xr.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new lr.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:yr?10:"auto"}),i=this;e.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),e.on("dragstart",(t=>{e.stopDrag(),t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),e.on("mouseenter",(()=>{var i=cr.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),a=function(t,e,i){if("rotater"===t)return i;e+=nr.Util.degToRad(mr[t]||0);var r=(nr.Util.radToDeg(e)%360+360)%360;return nr.Util._inRange(r,337.5,360)||nr.Util._inRange(r,0,22.5)?"ns-resize":nr.Util._inRange(r,22.5,67.5)?"nesw-resize":nr.Util._inRange(r,67.5,112.5)?"ew-resize":nr.Util._inRange(r,112.5,157.5)?"nwse-resize":nr.Util._inRange(r,157.5,202.5)?"ns-resize":nr.Util._inRange(r,202.5,247.5)?"nesw-resize":nr.Util._inRange(r,247.5,292.5)?"ew-resize":nr.Util._inRange(r,292.5,337.5)?"nwse-resize":(nr.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(t,i,r);e.getStage().content&&(e.getStage().content.style.cursor=a),this._cursorChange=!0})),e.on("mouseout",(()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(e)}_createBack(){var t=new hr.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){var i=e.getParent(),r=i.padding();t.beginPath(),t.rect(-r,-r,e.width()+2*r,e.height()+2*r),t.moveTo(e.width()/2,-r),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*nr.Util._sign(e.height())-r),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(this.shouldOverdrawWholeArea()){var i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}}});this.add(t),this._proxyDrag(t),t.on("dragstart",(t=>{t.cancelBubble=!0})),t.on("dragmove",(t=>{t.cancelBubble=!0})),t.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(!this._transforming){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,r=e.height,a=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/a),this.cos=Math.abs(i/a),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var n=t.target.getAbsolutePosition(),s=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-n.x,y:s.y-n.y},wr++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}}_handleMouseMove(t){var e,i,r,a=this.findOne("."+this._movingAnchorName),n=a.getStage();n.setPointersPositions(t);const s=n.getPointerPosition();let o={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const h=a.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),a.setAbsolutePosition(o);const l=a.getAbsolutePosition();if(h.x!==l.x||h.y!==l.y)if("rotater"!==this._movingAnchorName){var d,c=this.shiftBehavior();d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){var u=g?{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(u.x-a.x(),2)+Math.pow(u.y-a.y(),2));var f=this.findOne(".top-left").x()>u.x?-1:1,p=this.findOne(".top-left").y()>u.y?-1:1;e=r*this.cos*f,i=r*this.sin*p,this.findOne(".top-left").x(u.x-e),this.findOne(".top-left").y(u.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(a.y());else if("top-right"===this._movingAnchorName){if(d){u=g?{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(a.x()-u.x,2)+Math.pow(u.y-a.y(),2));f=this.findOne(".top-right").x()<u.x?-1:1,p=this.findOne(".top-right").y()>u.y?-1:1;e=r*this.cos*f,i=r*this.sin*p,this.findOne(".top-right").x(u.x+e),this.findOne(".top-right").y(u.y-i)}var v=a.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(a.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(a.x());else if("bottom-left"===this._movingAnchorName){if(d){u=g?{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(u.x-a.x(),2)+Math.pow(a.y()-u.y,2));f=u.x<a.x()?-1:1,p=a.y()<u.y?-1:1;e=r*this.cos*f,i=r*this.sin*p,a.x(u.x-e),a.y(u.y+i)}v=a.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(a.y());else if("bottom-right"===this._movingAnchorName){if(d){u=g?{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(a.x()-u.x,2)+Math.pow(a.y()-u.y,2));f=this.findOne(".bottom-right").x()<u.x?-1:1,p=this.findOne(".bottom-right").y()<u.y?-1:1;e=r*this.cos*f,i=r*this.sin*p,this.findOne(".bottom-right").x(u.x+e),this.findOne(".bottom-right").y(u.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey){var _=this.findOne(".top-left"),m=this.findOne(".bottom-right"),y=_.x(),x=_.y(),b=this.getWidth()-m.x(),S=this.getHeight()-m.y();m.move({x:-y,y:-x}),_.move({x:b,y:S})}var w=this.findOne(".top-left").getAbsolutePosition();e=w.x,i=w.y;var C=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),k=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:C,height:k,rotation:cr.Konva.getAngle(this.rotation())},t)}else{var P=this._getNodeRect();e=a.x()-P.width/2,i=-a.y()+P.height/2;let r=Math.atan2(-i,e)+Math.PI/2;P.height<0&&(r-=Math.PI);const n=cr.Konva.getAngle(this.rotation())+r,s=cr.Konva.getAngle(this.rotationSnapTolerance()),o=Sr(P,function(t,e,i){let r=e;for(let a=0;a<t.length;a++){const n=cr.Konva.getAngle(t[a]),s=Math.abs(n-e)%(2*Math.PI);Math.min(s,2*Math.PI-s)<i&&(r=n)}return r}(this.rotationSnaps(),n,s)-P.rotation);this._fitNodesInto(o,t)}}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var i=this.getNode();wr--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(t,e){var i=this._getNodeRect();if(nr.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(nr.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var r=new nr.Transform;if(r.rotate(cr.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=r.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=r.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:nr.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const a=1e7,n=new nr.Transform;n.translate(i.x,i.y),n.rotate(i.rotation),n.scale(i.width/a,i.height/a);const s=new nr.Transform,o=t.width/a,h=t.height/a;!1===this.flipEnabled()?(s.translate(t.x,t.y),s.rotate(t.rotation),s.translate(t.width<0?t.width:0,t.height<0?t.height:0),s.scale(Math.abs(o),Math.abs(h))):(s.translate(t.x,t.y),s.rotate(t.rotation),s.scale(o,h));const l=s.multiply(n.invert());this._nodes.forEach((t=>{var e;const i=t.getParent().getAbsoluteTransform(),r=t.getTransform().copy();r.translate(t.offsetX(),t.offsetY());const a=new nr.Transform;a.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(r);const n=a.decompose();t.setAttrs(n),null===(e=t.getLayer())||void 0===e||e.batchDraw()})),this.rotation(nr.Util._getRotation(t.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t,e=this._getNodeRect();this.rotation(nr.Util._getRotation(e.rotation));var i=e.width,r=e.height,a=this.enabledAnchors(),n=this.resizeEnabled(),s=this.padding(),o=this.anchorSize();const h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+s,offsetY:o/2+s,visible:n&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+s,visible:n&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-s,offsetY:o/2+s,visible:n&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:o/2+s,visible:n&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:o/2-s,visible:n&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:o/2+s,offsetY:o/2-s,visible:n&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:o/2-s,visible:n&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:o/2-s,offsetY:o/2-s,visible:n&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*nr.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});const l=this.anchorStyleFunc();l&&h.forEach((t=>{l(t)})),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),dr.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return or.Node.prototype.toObject.call(this)}clone(t){return or.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}ar.Transformer=Cr,Cr.isTransforming=()=>wr>0,Cr.prototype.className="Transformer",(0,ur._registerNode)(Cr),sr.Factory.addGetterSetter(Cr,"enabledAnchors",xr,(function(t){return t instanceof Array||nr.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===xr.indexOf(t)&&nr.Util.warn("Unknown anchor name: "+t+". Available names are: "+xr.join(", "))})),t||[]})),sr.Factory.addGetterSetter(Cr,"flipEnabled",!0,(0,gr.getBooleanValidator)()),sr.Factory.addGetterSetter(Cr,"resizeEnabled",!0),sr.Factory.addGetterSetter(Cr,"anchorSize",10,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"rotateEnabled",!0),sr.Factory.addGetterSetter(Cr,"rotateLineVisible",!0),sr.Factory.addGetterSetter(Cr,"rotationSnaps",[]),sr.Factory.addGetterSetter(Cr,"rotateAnchorOffset",50,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"rotateAnchorCursor","crosshair"),sr.Factory.addGetterSetter(Cr,"rotationSnapTolerance",5,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"borderEnabled",!0),sr.Factory.addGetterSetter(Cr,"anchorStroke","rgb(0, 161, 255)"),sr.Factory.addGetterSetter(Cr,"anchorStrokeWidth",1,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"anchorFill","white"),sr.Factory.addGetterSetter(Cr,"anchorCornerRadius",0,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"borderStroke","rgb(0, 161, 255)"),sr.Factory.addGetterSetter(Cr,"borderStrokeWidth",1,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"borderDash"),sr.Factory.addGetterSetter(Cr,"keepRatio",!0),sr.Factory.addGetterSetter(Cr,"shiftBehavior","default"),sr.Factory.addGetterSetter(Cr,"centeredScaling",!1),sr.Factory.addGetterSetter(Cr,"ignoreStroke",!1),sr.Factory.addGetterSetter(Cr,"padding",0,(0,gr.getNumberValidator)()),sr.Factory.addGetterSetter(Cr,"node"),sr.Factory.addGetterSetter(Cr,"nodes"),sr.Factory.addGetterSetter(Cr,"boundBoxFunc"),sr.Factory.addGetterSetter(Cr,"anchorDragBoundFunc"),sr.Factory.addGetterSetter(Cr,"anchorStyleFunc"),sr.Factory.addGetterSetter(Cr,"shouldOverdrawWholeArea",!1),sr.Factory.addGetterSetter(Cr,"useSingleNodeRotation",!0),sr.Factory.backCompat(Cr,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var kr={};Object.defineProperty(kr,"__esModule",{value:!0}),kr.Wedge=void 0;const Pr=l,Tr=dt,Ar=s,Mr=d,Fr=s;class Rr extends Tr.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Ar.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}kr.Wedge=Rr,Rr.prototype.className="Wedge",Rr.prototype._centroid=!0,Rr.prototype._attrsAffectingSize=["radius"],(0,Fr._registerNode)(Rr),Pr.Factory.addGetterSetter(Rr,"radius",0,(0,Mr.getNumberValidator)()),Pr.Factory.addGetterSetter(Rr,"angle",0,(0,Mr.getNumberValidator)()),Pr.Factory.addGetterSetter(Rr,"clockwise",!1),Pr.Factory.backCompat(Rr,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Ir={};Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.Blur=void 0;const Er=l,Or=h,Gr=d;function Dr(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Lr=[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],Nr=[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];Ir.Blur=function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,r,a,n,s,o,h,l,d,c,g,u,f,p,v,_,m,y,x,b,S,w,C,k,P=t.data,T=t.width,A=t.height,M=e+e+1,F=T-1,R=A-1,I=e+1,E=I*(I+1)/2,O=new Dr,G=null,D=O,L=null,N=null,U=Lr[e],B=Nr[e];for(a=1;a<M;a++)D=D.next=new Dr,a===I&&(G=D);for(D.next=O,h=o=0,r=0;r<A;r++){for(_=m=y=x=l=d=c=g=0,u=I*(b=P[o]),f=I*(S=P[o+1]),p=I*(w=P[o+2]),v=I*(C=P[o+3]),l+=E*b,d+=E*S,c+=E*w,g+=E*C,D=O,a=0;a<I;a++)D.r=b,D.g=S,D.b=w,D.a=C,D=D.next;for(a=1;a<I;a++)n=o+((F<a?F:a)<<2),l+=(D.r=b=P[n])*(k=I-a),d+=(D.g=S=P[n+1])*k,c+=(D.b=w=P[n+2])*k,g+=(D.a=C=P[n+3])*k,_+=b,m+=S,y+=w,x+=C,D=D.next;for(L=O,N=G,i=0;i<T;i++)P[o+3]=C=g*U>>B,0!==C?(C=255/C,P[o]=(l*U>>B)*C,P[o+1]=(d*U>>B)*C,P[o+2]=(c*U>>B)*C):P[o]=P[o+1]=P[o+2]=0,l-=u,d-=f,c-=p,g-=v,u-=L.r,f-=L.g,p-=L.b,v-=L.a,n=h+((n=i+e+1)<F?n:F)<<2,l+=_+=L.r=P[n],d+=m+=L.g=P[n+1],c+=y+=L.b=P[n+2],g+=x+=L.a=P[n+3],L=L.next,u+=b=N.r,f+=S=N.g,p+=w=N.b,v+=C=N.a,_-=b,m-=S,y-=w,x-=C,N=N.next,o+=4;h+=T}for(i=0;i<T;i++){for(m=y=x=_=d=c=g=l=0,u=I*(b=P[o=i<<2]),f=I*(S=P[o+1]),p=I*(w=P[o+2]),v=I*(C=P[o+3]),l+=E*b,d+=E*S,c+=E*w,g+=E*C,D=O,a=0;a<I;a++)D.r=b,D.g=S,D.b=w,D.a=C,D=D.next;for(s=T,a=1;a<=e;a++)o=s+i<<2,l+=(D.r=b=P[o])*(k=I-a),d+=(D.g=S=P[o+1])*k,c+=(D.b=w=P[o+2])*k,g+=(D.a=C=P[o+3])*k,_+=b,m+=S,y+=w,x+=C,D=D.next,a<R&&(s+=T);for(o=i,L=O,N=G,r=0;r<A;r++)P[3+(n=o<<2)]=C=g*U>>B,C>0?(C=255/C,P[n]=(l*U>>B)*C,P[n+1]=(d*U>>B)*C,P[n+2]=(c*U>>B)*C):P[n]=P[n+1]=P[n+2]=0,l-=u,d-=f,c-=p,g-=v,u-=L.r,f-=L.g,p-=L.b,v-=L.a,n=i+((n=r+I)<R?n:R)*T<<2,l+=_+=L.r=P[n],d+=m+=L.g=P[n+1],c+=y+=L.b=P[n+2],g+=x+=L.a=P[n+3],L=L.next,u+=b=N.r,f+=S=N.g,p+=w=N.b,v+=C=N.a,_-=b,m-=S,y-=w,x-=C,N=N.next,o+=T}}(t,e)},Er.Factory.addGetterSetter(Or.Node,"blurRadius",0,(0,Gr.getNumberValidator)(),Er.Factory.afterSetFilter);var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.Brighten=void 0;const Br=l,Wr=h,zr=d;Ur.Brighten=function(t){var e,i=255*this.brightness(),r=t.data,a=r.length;for(e=0;e<a;e+=4)r[e]+=i,r[e+1]+=i,r[e+2]+=i},Br.Factory.addGetterSetter(Wr.Node,"brightness",0,(0,zr.getNumberValidator)(),Br.Factory.afterSetFilter);var Hr={};Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.Contrast=void 0;const Vr=l,jr=h,Kr=d;Hr.Contrast=function(t){var e,i=Math.pow((this.contrast()+100)/100,2),r=t.data,a=r.length,n=150,s=150,o=150;for(e=0;e<a;e+=4)n=r[e],s=r[e+1],o=r[e+2],n/=255,n-=.5,n*=i,n+=.5,s/=255,s-=.5,s*=i,s+=.5,o/=255,o-=.5,o*=i,o+=.5,n=(n*=255)<0?0:n>255?255:n,s=(s*=255)<0?0:s>255?255:s,o=(o*=255)<0?0:o>255?255:o,r[e]=n,r[e+1]=s,r[e+2]=o},Vr.Factory.addGetterSetter(jr.Node,"contrast",0,(0,Kr.getNumberValidator)(),Vr.Factory.afterSetFilter);var Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.Emboss=void 0;const Yr=l,qr=h,Qr=o,Jr=d;Xr.Emboss=function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),a=this.embossBlend(),n=0,s=0,o=t.data,h=t.width,l=t.height,d=4*h,c=l;switch(r){case"top-left":n=-1,s=-1;break;case"top":n=-1,s=0;break;case"top-right":n=-1,s=1;break;case"right":n=0,s=1;break;case"bottom-right":n=1,s=1;break;case"bottom":n=1,s=0;break;case"bottom-left":n=1,s=-1;break;case"left":n=0,s=-1;break;default:Qr.Util.error("Unknown emboss direction: "+r)}do{var g=(c-1)*d,u=n;c+u<1&&(u=0),c+u>l&&(u=0);var f=(c-1+u)*h*4,p=h;do{var v=g+4*(p-1),_=s;p+_<1&&(_=0),p+_>h&&(_=0);var m=f+4*(p-1+_),y=o[v]-o[m],x=o[v+1]-o[m+1],b=o[v+2]-o[m+2],S=y,w=S>0?S:-S;if((x>0?x:-x)>w&&(S=x),(b>0?b:-b)>w&&(S=b),S*=e,a){var C=o[v]+S,k=o[v+1]+S,P=o[v+2]+S;o[v]=C>255?255:C<0?0:C,o[v+1]=k>255?255:k<0?0:k,o[v+2]=P>255?255:P<0?0:P}else{var T=i-S;T<0?T=0:T>255&&(T=255),o[v]=o[v+1]=o[v+2]=T}}while(--p)}while(--c)},Yr.Factory.addGetterSetter(qr.Node,"embossStrength",.5,(0,Jr.getNumberValidator)(),Yr.Factory.afterSetFilter),Yr.Factory.addGetterSetter(qr.Node,"embossWhiteLevel",.5,(0,Jr.getNumberValidator)(),Yr.Factory.afterSetFilter),Yr.Factory.addGetterSetter(qr.Node,"embossDirection","top-left",null,Yr.Factory.afterSetFilter),Yr.Factory.addGetterSetter(qr.Node,"embossBlend",!1,null,Yr.Factory.afterSetFilter);var Zr={};Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.Enhance=void 0;const $r=l,ta=h,ea=d;function ia(t,e,i,r,a){var n=i-e,s=a-r;return 0===n?r+s/2:0===s?r:s*((t-e)/n)+r}Zr.Enhance=function(t){var e,i,r,a,n=t.data,s=n.length,o=n[0],h=o,l=n[1],d=l,c=n[2],g=c,u=this.enhance();if(0!==u){for(a=0;a<s;a+=4)(e=n[a+0])<o?o=e:e>h&&(h=e),(i=n[a+1])<l?l=i:i>d&&(d=i),(r=n[a+2])<c?c=r:r>g&&(g=r);var f,p,v,_,m,y,x,b,S;for(h===o&&(h=255,o=0),d===l&&(d=255,l=0),g===c&&(g=255,c=0),u>0?(p=h+u*(255-h),v=o-u*(o-0),m=d+u*(255-d),y=l-u*(l-0),b=g+u*(255-g),S=c-u*(c-0)):(p=h+u*(h-(f=.5*(h+o))),v=o+u*(o-f),m=d+u*(d-(_=.5*(d+l))),y=l+u*(l-_),b=g+u*(g-(x=.5*(g+c))),S=c+u*(c-x)),a=0;a<s;a+=4)n[a+0]=ia(n[a+0],o,h,v,p),n[a+1]=ia(n[a+1],l,d,y,m),n[a+2]=ia(n[a+2],c,g,S,b)}},$r.Factory.addGetterSetter(ta.Node,"enhance",0,(0,ea.getNumberValidator)(),$r.Factory.afterSetFilter);var ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.Grayscale=void 0;ra.Grayscale=function(t){var e,i,r=t.data,a=r.length;for(e=0;e<a;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};var aa={};Object.defineProperty(aa,"__esModule",{value:!0}),aa.HSL=void 0;const na=l,sa=h,oa=d;na.Factory.addGetterSetter(sa.Node,"hue",0,(0,oa.getNumberValidator)(),na.Factory.afterSetFilter),na.Factory.addGetterSetter(sa.Node,"saturation",0,(0,oa.getNumberValidator)(),na.Factory.afterSetFilter),na.Factory.addGetterSetter(sa.Node,"luminance",0,(0,oa.getNumberValidator)(),na.Factory.afterSetFilter);aa.HSL=function(t){var e,i,r,a,n,s=t.data,o=s.length,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=127*this.luminance(),c=1*h*Math.cos(l*Math.PI/180),g=1*h*Math.sin(l*Math.PI/180),u=.299+.701*c+.167*g,f=.587-.587*c+.33*g,p=.114-.114*c-.497*g,v=.299-.299*c-.328*g,_=.587+.413*c+.035*g,m=.114-.114*c+.293*g,y=.299-.3*c+1.25*g,x=.587-.586*c-1.05*g,b=.114+.886*c-.2*g;for(e=0;e<o;e+=4)i=s[e+0],r=s[e+1],a=s[e+2],n=s[e+3],s[e+0]=u*i+f*r+p*a+d,s[e+1]=v*i+_*r+m*a+d,s[e+2]=y*i+x*r+b*a+d,s[e+3]=n};var ha={};Object.defineProperty(ha,"__esModule",{value:!0}),ha.HSV=void 0;const la=l,da=h,ca=d;ha.HSV=function(t){var e,i,r,a,n,s=t.data,o=s.length,h=Math.pow(2,this.value()),l=Math.pow(2,this.saturation()),d=Math.abs(this.hue()+360)%360,c=h*l*Math.cos(d*Math.PI/180),g=h*l*Math.sin(d*Math.PI/180),u=.299*h+.701*c+.167*g,f=.587*h-.587*c+.33*g,p=.114*h-.114*c-.497*g,v=.299*h-.299*c-.328*g,_=.587*h+.413*c+.035*g,m=.114*h-.114*c+.293*g,y=.299*h-.3*c+1.25*g,x=.587*h-.586*c-1.05*g,b=.114*h+.886*c-.2*g;for(e=0;e<o;e+=4)i=s[e+0],r=s[e+1],a=s[e+2],n=s[e+3],s[e+0]=u*i+f*r+p*a,s[e+1]=v*i+_*r+m*a,s[e+2]=y*i+x*r+b*a,s[e+3]=n},la.Factory.addGetterSetter(da.Node,"hue",0,(0,ca.getNumberValidator)(),la.Factory.afterSetFilter),la.Factory.addGetterSetter(da.Node,"saturation",0,(0,ca.getNumberValidator)(),la.Factory.afterSetFilter),la.Factory.addGetterSetter(da.Node,"value",0,(0,ca.getNumberValidator)(),la.Factory.afterSetFilter);var ga={};Object.defineProperty(ga,"__esModule",{value:!0}),ga.Invert=void 0;ga.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]};var ua={};Object.defineProperty(ua,"__esModule",{value:!0}),ua.Kaleidoscope=void 0;const fa=l,pa=h,va=o,_a=d;ua.Kaleidoscope=function(t){var e,i,r,a,n,s,o,h,l,d=t.width,c=t.height,g=Math.round(this.kaleidoscopePower()),u=Math.round(this.kaleidoscopeAngle()),f=Math.floor(d*(u%360)/360);if(!(g<1)){var p=va.Util.createCanvasElement();p.width=d,p.height=c;var v=p.getContext("2d").getImageData(0,0,d,c);va.Util.releaseCanvas(p),function(t,e,i){var r,a,n,s,o=t.data,h=e.data,l=t.width,d=t.height,c=i.polarCenterX||l/2,g=i.polarCenterY||d/2,u=0,f=0,p=0,v=0,_=Math.sqrt(c*c+g*g);a=l-c,n=d-g,_=(s=Math.sqrt(a*a+n*n))>_?s:_;var m,y,x,b,S=d,w=l,C=360/w*Math.PI/180;for(y=0;y<w;y+=1)for(x=Math.sin(y*C),b=Math.cos(y*C),m=0;m<S;m+=1)a=Math.floor(c+_*m/S*b),u=o[0+(r=4*((n=Math.floor(g+_*m/S*x))*l+a))],f=o[r+1],p=o[r+2],v=o[r+3],h[0+(r=4*(y+m*l))]=u,h[r+1]=f,h[r+2]=p,h[r+3]=v}(t,v,{polarCenterX:d/2,polarCenterY:c/2});for(var _=d/Math.pow(2,g);_<=8;)_*=2,g-=1;var m=_=Math.ceil(_),y=0,x=m,b=1;for(f+_>d&&(y=m,x=0,b=-1),i=0;i<c;i+=1)for(e=y;e!==x;e+=b)h=4*(d*i+Math.round(e+f)%d),a=v.data[h+0],n=v.data[h+1],s=v.data[h+2],o=v.data[h+3],l=4*(d*i+e),v.data[l+0]=a,v.data[l+1]=n,v.data[l+2]=s,v.data[l+3]=o;for(i=0;i<c;i+=1)for(m=Math.floor(_),r=0;r<g;r+=1){for(e=0;e<m+1;e+=1)h=4*(d*i+e),a=v.data[h+0],n=v.data[h+1],s=v.data[h+2],o=v.data[h+3],l=4*(d*i+2*m-e-1),v.data[l+0]=a,v.data[l+1]=n,v.data[l+2]=s,v.data[l+3]=o;m*=2}!function(t,e,i){var r,a,n,s,o,h,l=t.data,d=e.data,c=t.width,g=t.height,u=i.polarCenterX||c/2,f=i.polarCenterY||g/2,p=0,v=0,_=0,m=0,y=Math.sqrt(u*u+f*f);a=c-u,n=g-f,y=(h=Math.sqrt(a*a+n*n))>y?h:y;var x,b,S,w=g,C=c;for(a=0;a<c;a+=1)for(n=0;n<g;n+=1)s=a-u,o=n-f,x=Math.sqrt(s*s+o*o)*w/y,b=(b=(180*Math.atan2(o,s)/Math.PI+360+0)%360)*C/360,S=Math.floor(b),p=l[0+(r=4*(Math.floor(x)*c+S))],v=l[r+1],_=l[r+2],m=l[r+3],d[0+(r=4*(n*c+a))]=p,d[r+1]=v,d[r+2]=_,d[r+3]=m}(v,t,{polarRotation:0})}},fa.Factory.addGetterSetter(pa.Node,"kaleidoscopePower",2,(0,_a.getNumberValidator)(),fa.Factory.afterSetFilter),fa.Factory.addGetterSetter(pa.Node,"kaleidoscopeAngle",0,(0,_a.getNumberValidator)(),fa.Factory.afterSetFilter);var ma={};Object.defineProperty(ma,"__esModule",{value:!0}),ma.Mask=void 0;const ya=l,xa=h,ba=d;function Sa(t,e,i){var r=4*(i*t.width+e),a=[];return a.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),a}function wa(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))}ma.Mask=function(t){var e=function(t,e){var i=Sa(t,0,0),r=Sa(t,t.width-1,0),a=Sa(t,0,t.height-1),n=Sa(t,t.width-1,t.height-1),s=e||10;if(wa(i,r)<s&&wa(r,n)<s&&wa(n,a)<s&&wa(a,i)<s){for(var o=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,n,a]),h=[],l=0;l<t.width*t.height;l++){var d=wa(o,[t.data[4*l],t.data[4*l+1],t.data[4*l+2]]);h[l]=d<s?0:255}return h}}(t,this.threshold());return e&&function(t,e){for(var i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e=function(t,e,i){for(var r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],a=Math.round(Math.sqrt(r.length)),n=Math.floor(a/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<a;c++)for(var g=0;g<a;g++){var u=o+c-n,f=h+g-n;if(u>=0&&u<i&&f>=0&&f<e){var p=r[c*a+g];d+=t[u*e+f]*p}}s[l]=d}return s}(e=function(t,e,i){for(var r=[1,1,1,1,1,1,1,1,1],a=Math.round(Math.sqrt(r.length)),n=Math.floor(a/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<a;c++)for(var g=0;g<a;g++){var u=o+c-n,f=h+g-n;if(u>=0&&u<i&&f>=0&&f<e){var p=r[c*a+g];d+=t[u*e+f]*p}}s[l]=d>=1020?255:0}return s}(e=function(t,e,i){for(var r=[1,1,1,1,0,1,1,1,1],a=Math.round(Math.sqrt(r.length)),n=Math.floor(a/2),s=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<a;c++)for(var g=0;g<a;g++){var u=o+c-n,f=h+g-n;if(u>=0&&u<i&&f>=0&&f<e){var p=r[c*a+g];d+=t[u*e+f]*p}}s[l]=2040===d?255:0}return s}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},ya.Factory.addGetterSetter(xa.Node,"threshold",0,(0,ba.getNumberValidator)(),ya.Factory.afterSetFilter);var Ca={};Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.Noise=void 0;const ka=l,Pa=h,Ta=d;Ca.Noise=function(t){var e,i=255*this.noise(),r=t.data,a=r.length,n=i/2;for(e=0;e<a;e+=4)r[e+0]+=n-2*n*Math.random(),r[e+1]+=n-2*n*Math.random(),r[e+2]+=n-2*n*Math.random()},ka.Factory.addGetterSetter(Pa.Node,"noise",.2,(0,Ta.getNumberValidator)(),ka.Factory.afterSetFilter);var Aa={};Object.defineProperty(Aa,"__esModule",{value:!0}),Aa.Pixelate=void 0;const Ma=l,Fa=o,Ra=h,Ia=d;Aa.Pixelate=function(t){var e,i,r,a,n,s,o,h,l,d,c,g,u,f,p=Math.ceil(this.pixelSize()),v=t.width,_=t.height,m=Math.ceil(v/p),y=Math.ceil(_/p),x=t.data;if(p<=0)Fa.Util.error("pixelSize value can not be <= 0");else for(g=0;g<m;g+=1)for(u=0;u<y;u+=1){for(a=0,n=0,s=0,o=0,l=(h=g*p)+p,c=(d=u*p)+p,f=0,e=h;e<l;e+=1)if(!(e>=v))for(i=d;i<c;i+=1)i>=_||(a+=x[(r=4*(v*i+e))+0],n+=x[r+1],s+=x[r+2],o+=x[r+3],f+=1);for(a/=f,n/=f,s/=f,o/=f,e=h;e<l;e+=1)if(!(e>=v))for(i=d;i<c;i+=1)i>=_||(x[(r=4*(v*i+e))+0]=a,x[r+1]=n,x[r+2]=s,x[r+3]=o)}},Ma.Factory.addGetterSetter(Ra.Node,"pixelSize",8,(0,Ia.getNumberValidator)(),Ma.Factory.afterSetFilter);var Ea={};Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.Posterize=void 0;const Oa=l,Ga=h,Da=d;Ea.Posterize=function(t){var e,i=Math.round(254*this.levels())+1,r=t.data,a=r.length,n=255/i;for(e=0;e<a;e+=1)r[e]=Math.floor(r[e]/n)*n},Oa.Factory.addGetterSetter(Ga.Node,"levels",.5,(0,Da.getNumberValidator)(),Oa.Factory.afterSetFilter);var La={};Object.defineProperty(La,"__esModule",{value:!0}),La.RGB=void 0;const Na=l,Ua=h,Ba=d;La.RGB=function(t){var e,i,r=t.data,a=r.length,n=this.red(),s=this.green(),o=this.blue();for(e=0;e<a;e+=4)i=(.34*r[e]+.5*r[e+1]+.16*r[e+2])/255,r[e]=i*n,r[e+1]=i*s,r[e+2]=i*o,r[e+3]=r[e+3]},Na.Factory.addGetterSetter(Ua.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Na.Factory.addGetterSetter(Ua.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Na.Factory.addGetterSetter(Ua.Node,"blue",0,Ba.RGBComponent,Na.Factory.afterSetFilter);var Wa={};Object.defineProperty(Wa,"__esModule",{value:!0}),Wa.RGBA=void 0;const za=l,Ha=h,Va=d;Wa.RGBA=function(t){var e,i,r=t.data,a=r.length,n=this.red(),s=this.green(),o=this.blue(),h=this.alpha();for(e=0;e<a;e+=4)i=1-h,r[e]=n*h+r[e]*i,r[e+1]=s*h+r[e+1]*i,r[e+2]=o*h+r[e+2]*i},za.Factory.addGetterSetter(Ha.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),za.Factory.addGetterSetter(Ha.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),za.Factory.addGetterSetter(Ha.Node,"blue",0,Va.RGBComponent,za.Factory.afterSetFilter),za.Factory.addGetterSetter(Ha.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var ja={};Object.defineProperty(ja,"__esModule",{value:!0}),ja.Sepia=void 0;ja.Sepia=function(t){var e,i,r,a,n=t.data,s=n.length;for(e=0;e<s;e+=4)i=n[e+0],r=n[e+1],a=n[e+2],n[e+0]=Math.min(255,.393*i+.769*r+.189*a),n[e+1]=Math.min(255,.349*i+.686*r+.168*a),n[e+2]=Math.min(255,.272*i+.534*r+.131*a)};var Ka={};Object.defineProperty(Ka,"__esModule",{value:!0}),Ka.Solarize=void 0;Ka.Solarize=function(t){var e=t.data,i=t.width,r=4*i,a=t.height;do{var n=(a-1)*r,s=i;do{var o=n+4*(s-1),h=e[o],l=e[o+1],d=e[o+2];h>127&&(h=255-h),l>127&&(l=255-l),d>127&&(d=255-d),e[o]=h,e[o+1]=l,e[o+2]=d}while(--s)}while(--a)};var Xa={};Object.defineProperty(Xa,"__esModule",{value:!0}),Xa.Threshold=void 0;const Ya=l,qa=h,Qa=d;Xa.Threshold=function(t){var e,i=255*this.threshold(),r=t.data,a=r.length;for(e=0;e<a;e+=1)r[e]=r[e]<i?0:255},Ya.Factory.addGetterSetter(qa.Node,"threshold",.5,(0,Qa.getNumberValidator)(),Ya.Factory.afterSetFilter),Object.defineProperty(a,"__esModule",{value:!0}),a.Konva=void 0;const Ja=n,Za=Nt,$a=jt,tn=ue,en=ye,rn=ke,an=Ie,nn=Kt,sn=te,on=Ke,hn=$e,ln=ni,dn=gi,cn=yi,gn=ki,un=Ki,fn=ar,pn=kr,vn=Ir,_n=Ur,mn=Hr,yn=Xr,xn=Zr,bn=ra,Sn=aa,wn=ha,Cn=ga,kn=ua,Pn=ma,Tn=Ca,An=Aa,Mn=Ea,Fn=La,Rn=Wa,In=ja,En=Ka,On=Xa;a.Konva=Ja.Konva.Util._assign(Ja.Konva,{Arc:Za.Arc,Arrow:$a.Arrow,Circle:tn.Circle,Ellipse:en.Ellipse,Image:rn.Image,Label:an.Label,Tag:an.Tag,Line:nn.Line,Path:sn.Path,Rect:on.Rect,RegularPolygon:hn.RegularPolygon,Ring:ln.Ring,Sprite:dn.Sprite,Star:cn.Star,Text:gn.Text,TextPath:un.TextPath,Transformer:fn.Transformer,Wedge:pn.Wedge,Filters:{Blur:vn.Blur,Brighten:_n.Brighten,Contrast:mn.Contrast,Emboss:yn.Emboss,Enhance:xn.Enhance,Grayscale:bn.Grayscale,HSL:Sn.HSL,HSV:wn.HSV,Invert:Cn.Invert,Kaleidoscope:kn.Kaleidoscope,Mask:Pn.Mask,Noise:Tn.Noise,Pixelate:An.Pixelate,Posterize:Mn.Posterize,RGB:Fn.RGB,RGBA:Rn.RGBA,Sepia:In.Sepia,Solarize:En.Solarize,Threshold:On.Threshold}});var Gn=r.exports;Object.defineProperty(Gn,"__esModule",{value:!0});const Dn=a;r.exports=Dn.Konva;var Ln=i(r.exports);class Nn{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class Un{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Bn=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Wn{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const a=[];t.points.forEach((t=>a.push(t.x,t.y))),this._ref=new Ln.Line({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:a,draggable:!0,strokeScaleEnabled:!1,dash:Bn.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Bn.get("dot"):t="dot";break;case Bn.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Bn.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class zn{constructor(t,e=null){var i,r,a;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Ln.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(i=t.fontSize)&&void 0!==i?i:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(a=t.rotation)&&void 0!==a?a:0}),this._ref.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let a=this._ref.width();i&&(a*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);a<50&&(a=50),n<Math.round(this.getFontSize())&&(n=Math.round(this.getFontSize())),i&&this._ref.width(a),r&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class Hn{constructor(t,e=null){var i,r,a,n;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Ln.Rect({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(a=t.width)&&void 0!==a?a:200,height:null!==(n=t.height)&&void 0!==n?n:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let a=this._ref.width();i&&(a*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);a<50&&(a=50),n<50&&(n=50),i&&this._ref.width(a),r&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}}class Vn{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Ln.Ellipse({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let a=this._ref.radiusX();i&&(a*=e.scaleX);let n=this._ref.radiusY();r&&(n*=e.scaleY);a<25&&(a=25),n<25&&(n=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:a,y:a}):this._ref.radius({x:n,y:n}):this._ref.radius({x:a,y:n}),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}}class jn{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Ln.Arrow({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y])}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e])}}class Kn{constructor(t,e=null){var i,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",e)return e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ln.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(i=t.width)&&void 0!==i?i:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let a=this._ref.width();i&&(a*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(a),this._ref.height(a*this._ratio)):(this._ref.width(n/this._ratio),this._ref.height(n)):(i&&this._ref.width(a),r&&this._ref.height(n)),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}}class Xn{constructor(t,e=null){var i,r,a,n;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const s=16;this._ref=new Ln.Shape({x:t.position.x,y:t.position.y,width:null!==(i=t.width)&&void 0!==i?i:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(a=t.color)&&void 0!==a?a:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],r=(a={x:0,y:0},n=this._ref.width(),o=this._ref.height(),{x:a.x+n/2,y:a.y+o/2});var a,n,o;t.beginPath();for(let e=0;e<i.length-1;e++){let a=30;const n=i[e+1].x-i[e].x,o=i[e+1].y-i[e].y,h=Math.sqrt(n*n+o*o),l=Math.floor(h/a);a=30+l/(h%a);let d=i[e].x+n/l/2,c=i[e].y+o/l/2;const g=i[e+1].x,u=i[e+1].y,f=Math.atan((u-c)/(g-d)),p=f+Math.PI,v=d>r.x&&c>r.y;for(let e=0;e<l;e++)v?t.arc(d,c,s,f,p):t.arc(d,c,s,p,f),d+=n/l,c+=o/l}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let a=this._ref.width();i&&(a*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);a<100&&(a=100),n<100&&(n=100),i&&this._ref.width(a),r&&this._ref.height(n),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const Yn={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Wn(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new zn(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new Hn(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new Vn(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new jn(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new Kn(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new Xn(e,t)}};t.Markup=class{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Un(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i))},this.pan=t=>{const e={x:this._konvaStage.x()+t.dX,y:this._konvaStage.y()+t.dY};this._konvaStage.position(e)},this.zoomAt=t=>{const e=this._konvaStage.scaleX()*t.data;this._konvaStage.scale({x:e,y:e});const i={x:t.x-(t.x-this._konvaStage.x())*t.data,y:t.y-(t.y-this._konvaStage.y())*t.data};this._konvaStage.position(i)},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,r){if(!Ln)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new Nn,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";const a=this._container.parentElement;a.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(a),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this._viewer.emit({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){const r=new Un(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}colorizeSelectedMarkups(t,e,i){const r=new Un(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}setViewpoint(t){var e,i,r,a,n,s,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(r=t.texts)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(a=t.rectangles)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(n=t.ellipses)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,t.radius,t.line_width,t.color,t.id)})),null===(s=t.arrows)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&Yn[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=Yn[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(Yn).forEach((e=>{const i=Yn[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(Yn).find((t=>t.name===e));return i?i.initializer(t):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=Yn[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Ln.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ln.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ln.Group,e.add(this._groupImages),this._groupGeometry=new Ln.Group,e.add(this._groupGeometry),this._groupTexts=new Ln.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Ln.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,a,n,s=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const n=this.getRelativePointerPosition(t);a=n,s=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(r=this.addLine([n.x,n.y,n.x,n.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(s){const e=this.getRelativePointerPosition(t),i=a&&e.x===a.x&&e.y===a.y,r=i?a.x:Math.min(a.x,e.x),n=i?a.y:Math.min(a.y,e.y),s=i?200:Math.abs(a.x-e.x),o=i?200:Math.abs(a.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:n},s,o):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:n},{x:s/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:a.x,y:a.y},{x:i?a.x+200:e.x,y:i?n:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:n},Math.max(100,s),Math.max(100,o)))}n=void 0,s=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!s)return;const i=this.getRelativePointerPosition(t),o=a&&i.x===a.x&&i.y===a.y,h=o?a.x:Math.min(a.x,i.x),l=o?a.y:Math.min(a.y,i.y),d=o?200:Math.abs(a.x-i.x),c=o?200:Math.abs(a.y-i.y);"Line"===this._markupMode?r.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?n?n.setEndPoint(i.x,i.y):n=this.addArrow({x:a.x,y:a.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?n?(n.setPosition(h,l),n.setWidth(d),n.setHeight(c)):n=this.addRectangle({x:h,y:l},d,c):"Ellipse"===this._markupMode?n?(n.setPosition(h,l),n.setRadiusX(d),n.setRadiusY(c)):n=this.addEllipse({x:h,y:l},{x:d,y:c}):"Cloud"===this._markupMode&&(n?(n.setPosition(h,l),n.setWidth(Math.max(100,d)),n.setHeight(Math.max(100,c))):n=this.addCloud({x:h,y:l},d,c))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,a=i.nodes().indexOf(e.target)>=0;if(r||a){if(r&&a){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!a){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.points();if(!i)return;const r=[],a=e.getAbsoluteTransform();for(let t=0;t<i.length;t+=2){const e=a.point({x:i[t],y:i[t+1]}),n=this._worldTransformer.screenToWorld(e);r.push(n)}const n=new Wn(null,e),s={id:n.id(),points:r,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(s)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),r=e.position(),a=this._konvaStage.getAbsoluteTransform(),n=a.point({x:r.x,y:r.y}),s=this._worldTransformer.screenToWorld(n),o=new zn(null,e),h={id:o.id(),position:s,text:o.getText(),text_size:.02*i.y,angle:o.getRotation(),color:o.getColor(),font_size:o.getFontSize()*a.getMatrix()[0]};t.push(h)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),a=r.point({x:i.x,y:i.y}),n=this._worldTransformer.screenToWorld(a),s=r.getMatrix()[0],o=new Hn(null,e),h={id:o.id(),position:n,width:o.getWidth()*s,height:o.getHeigth()*s,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),a=r.point({x:i.x,y:i.y}),n=this._worldTransformer.screenToWorld(a),s=r.getMatrix()[0],o=new Vn(null,e),h={id:o.id(),position:n,radius:{x:e.getRadiusX()*s,y:e.getRadiusY()*s},line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),a=this._worldTransformer.screenToWorld(r),n=i.point({x:e.points()[2],y:e.points()[3]}),s=this._worldTransformer.screenToWorld(n),o=new jn(null,e),h={id:o.id(),start:a,end:s,color:o.getColor()};t.push(h)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),a=r.point({x:i.x,y:i.y}),n=this._worldTransformer.screenToWorld(a),s=r.getMatrix()[0],o=new Kn(null,e),h={id:o.id(),position:n,src:o.getSrc(),width:o.getWidth()*s,height:o.getHeight()*s};t.push(h)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),a=r.point({x:i.x,y:i.y}),n=this._worldTransformer.screenToWorld(a),s=r.getMatrix()[0],o=new Xn(null,e),h={id:o.id(),position:n,width:o.getWidth()*s,height:o.getHeigth()*s,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,a){if(!t||0===t.length)return;const n=[];for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});const s=new Wn({points:n,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:a});return this.addObject(s),s}createTextInput(t,e,i,r,a){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},a&&(this._textInputRef.value=a),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},r.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,a,n,s){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(a&&a>h&&(!n||n<h)){const t=.02;n=a/(this._worldTransformer.getScale().y/t)/34}const l=new zn({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:n||this.fontSize,color:r||this._markupColor.asHex(),id:s});return this.addObject(l),l}addRectangle(t,e,i,r,a,n){if(!t)return;const s=new Hn({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:a||this._markupColor.asHex(),id:n});return this.addObject(s),s}addEllipse(t,e,i,r,a){if(!t)return;const n=new Vn({position:t,radius:e,lineWidth:i,color:r||this._markupColor.asHex(),id:a});return this.addObject(n),n}addArrow(t,e,i,r){if(!t||!e)return;const a=new jn({start:t,end:e,color:i||this._markupColor.asHex(),id:r});return this.addObject(a),a}addCloud(t,e,i,r,a,n){if(!t||!e||!i)return;const s=new Xn({position:t,width:e,height:i,color:a||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:n});return this.addObject(s),s}addImage(t,e,i,r,a){var n;if(!t||!e)return;null===(n=this.getSelectedObjects().at(0))||void 0===n||n.delete(),this.clearSelected(),this.removeImageInput();const s=new Kn({position:t,src:e,width:i,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:a});return this.addObject(s),s}}}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Markup=t.ODA.Markup||{}))}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n={exports:{}},s={},a={},o={};function h(){return r||(r=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const i=Math.PI/180;t.glob=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.16",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>t.Konva.angleDeg?e*i:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(o)),o}var l,d={};function c(){return l||(l=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=h();class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.m[0]*e+this.m[2]*i,n=this.m[1]*e+this.m[3]*i,s=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=n,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,n=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=n,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],n=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,r=-this.m[2]*t,n=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=n,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],s=e*n-i*r,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);a.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=s/t,a.skewX=(e*r+i*n)/s,a.skewY=0}else if(0!=r||0!=n){const t=Math.sqrt(r*r+n*n);a.rotation=Math.PI/2-(n>0?Math.acos(-r/t):-Math.acos(r/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*r+i*n)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=i;let r=Math.PI/180,n=180/Math.PI,s="Konva error: ",a={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,l=[];const d="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){l.push(t),1===l.length&&d((function(){const t=l;l=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=a[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,n=Number(i[1])/100,s=Number(i[2])/100;let a,o,h;if(0===n)return h=255*s,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=s<.5?s*(1+n):s+n-s*n;const l=2*s-a,d=[0,0,0];for(let t=0;t<3;t++)o=r+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*r,radToDeg:t=>t*n,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,r,n,s){let a,o,h;const l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)a=t,o=e,h=(n-i)*(n-i)+(s-r)*(s-r);else{const d=((n-t)*(i-t)+(s-e)*(r-e))/l;d<0?(a=t,o=e,h=(t-n)*(t-n)+(e-s)*(e-s)):d>1?(a=i,o=r,h=(i-n)*(i-n)+(r-s)*(r-s)):(a=t+d*(i-t),o=e+d*(r-e),h=(a-n)*(a-n)+(o-s)*(o-s))}return[a,o,h]},_getProjectionToLine(e,i,r){const n=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return i.forEach((function(a,o){if(!r&&o===i.length-1)return;const h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(a.x,a.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<s&&(n.x=d,n.y=c,s=u)})),n},_prepareArrayForTween(e,i,r){let n,s=[],a=[];if(e.length>i.length){const t=i;i=e,e=t}for(n=0;n<e.length;n+=2)s.push({x:e[n],y:e[n+1]});for(n=0;n<i.length;n+=2)a.push({x:i[n],y:i[n+1]});const o=[];return a.forEach((function(e){const i=t.Util._getProjectionToLine(e,s,r);o.push(i.x),o.push(i.y)})),o},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const r in e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,r){let n=0,s=0,a=0,o=0;"number"==typeof r?n=s=a=o=Math.min(r,e/2,i/2):(n=Math.min(r[0]||0,e/2,i/2),s=Math.min(r[1]||0,e/2,i/2),o=Math.min(r[2]||0,e/2,i/2),a=Math.min(r[3]||0,e/2,i/2)),t.moveTo(n,0),t.lineTo(e-s,0),t.arc(e-s,s,s,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,n),t.arc(n,n,n,Math.PI,3*Math.PI/2,!1)}}}(d)),d}var u,g,f={},p={},_={};function m(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},_.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},_.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number.'),t}},_.getNumberOrArrayOfNumbersValidator=function(r){if(t.Konva.isUnminified)return function(t,n){const s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==r;return s||a||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+r+")"),t}},_.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or "auto".'),t}},_.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string.'),t}},_.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,r){const n=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return n||s||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string or a native gradient.'),t}},_.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a function.'),t}},_.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,r){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&t instanceof n||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+r+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a array of numbers.')),t}},_.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,r){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a boolean.'),t}},_.getComponentValidator=function(r){if(t.Konva.isUnminified)return function(t,n){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+r),t}};const t=h(),e=c();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return _}function y(){return g||(g=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=c(),i=m(),r="get",n="set";t.Factory={addGetterSetter(e,i,r,n,s){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,n,s),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,n){const s=r+e.Util._capitalize(i);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[i];return void 0===t?n:t}},addSetter(i,r,s,a){const o=n+e.Util._capitalize(r);i.prototype[o]||t.Factory.overWriteSetter(i,r,s,a)},overWriteSetter(t,i,r,s){const a=n+e.Util._capitalize(i);t.prototype[a]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,h,l){let d,c,u=o.length,g=e.Util._capitalize,f=r+g(a),p=n+g(a);s.prototype[f]=function(){const t={};for(d=0;d<u;d++)c=o[d],t[c]=this.getAttr(a+g(c));return t};const _=(0,i.getComponentValidator)(o);s.prototype[p]=function(t){let e,i=this.attrs[a];for(e in h&&(t=h.call(this,t)),_&&_.call(this,t,a),t)t.hasOwnProperty(e)&&this._setAttr(a+g(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+g(t),void 0)})),this._fireChangeEvent(a,i,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(t,i){const s=e.Util._capitalize(i),a=n+s,o=r+s;t.prototype[i]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,n,s,a){e.Util.error("Adding deprecated "+n);const o=r+e.Util._capitalize(n),h=n+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);const t=this.attrs[n];return void 0===t?s:t},t.Factory.addSetter(i,n,a,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,n)},backCompat(t,i){e.Util.each(i,(function(i,s){const a=t.prototype[s],o=r+e.Util._capitalize(i),h=n+e.Util._capitalize(i);function l(){a.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(p)),p}var v,x,b={},S={};function w(){if(v)return S;v=1,Object.defineProperty(S,"__esModule",{value:!0}),S.HitContext=S.SceneContext=S.Context=void 0;const t=c(),e=h();const i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let r=class{constructor(t){this.canvas=t,e.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(e,i){let r,n,s,a,o=this.traceArr,h=o.length,l="";for(r=0;r<h;r++)n=o[r],s=n.method,s?(a=n.args,l+=s,e?l+="()":t.Util._isArray(a[0])?l+="(["+a.join(",")+"])":(i&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),l+="("+a.join(",")+")")):(l+=n.property,e||(l+="="+n.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,n,s){this._context.arc(t,e,i,r,n,s)}arcTo(t,e,i,r,n){this._context.arcTo(t,e,i,r,n)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,n,s){this._context.bezierCurveTo(t,e,i,r,n,s)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,n,s){return this._context.createRadialGradient(t,e,i,r,n,s)}drawImage(t,e,i,r,n,s,a,o,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,n):9===l.length&&d.drawImage(t,e,i,r,n,s,a,o,h)}ellipse(t,e,i,r,n,s,a,o){this._context.ellipse(t,e,i,r,n,s,a,o)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,n){this._context.roundRect(t,e,i,r,n)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,r,n,s){this._context.setTransform(t,e,i,r,n,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,n,s){this._context.transform(t,e,i,r,n,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,r,n=this,s=i.length,a=this.setAttr;const o=function(e){let i,s=n[e];n[e]=function(){return r=function(e){let i,r,n=[],s=e.length,a=t.Util;for(i=0;i<s;i++)r=e[i],a._isNumber(r)?r=Math.round(1e3*r)/1e3:a._isString(r)||(r+=""),n.push(r);return n}(Array.prototype.slice.call(arguments,0)),i=s.apply(n,arguments),n._trace({method:e,args:r}),i}};for(e=0;e<s;e++)o(i[e]);n.setAttr=function(){a.apply(n,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),n._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};S.Context=r,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(r.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));S.SceneContext=class extends r{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const n=t.getFillLinearGradientColorStops();if(n&&"linear-gradient"===i)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):n?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),n=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(let t=0;t<r.length;t+=2)n.addColorStop(r[t],r[t+1]);this.setAttr("strokeStyle",n)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,r;const n=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",n),this.setAttr("shadowBlur",s*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*d)}};return S.HitContext=class extends r{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},S}function C(){if(x)return b;x=1,Object.defineProperty(b,"__esModule",{value:!0}),b.HitCanvas=b.SceneCanvas=b.Canvas=void 0;const t=c(),e=w(),i=h(),r=y(),n=m();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const r=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),r=e.getContext("2d");return s=(i.Konva._global.devicePixelRatio||1)/(r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=r,this._canvas=t.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};b.Canvas=a,r.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,n.getNumberValidator)());b.SceneCanvas=class extends a{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return b.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},b}var k,P,T={};function A(){return k||(k=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=h(),i=c();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach(((t,n)=>{const{node:s}=t,a=s.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const i=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<i)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),r.push(s)}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const r=[];t.DD._dragElements.forEach((n=>{const{node:s}=n,a=s.getStage();i&&a.setPointersPositions(i);if(!a._changedPointerPositions.find((t=>t.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof e.Konva.Stage&&n.node;o&&-1===r.indexOf(o)&&r.push(o)})),r.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(T)),T}function M(){if(P)return f;P=1,Object.defineProperty(f,"__esModule",{value:!0}),f.Node=void 0;const t=c(),e=y(),i=C(),r=h(),n=A(),s=m(),a="absoluteOpacity",o="allEventListeners",l="absoluteTransform",d="absoluteScale",u="canvas",g="listening",p="mouseenter",_="mouseleave",v="Shape",x=" ",b="stage",S="transform",w="visible",k=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(x);let T=1,M=class e{constructor(t){this._id=T++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==S&&t!==l||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===S||t===l)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(x);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(u)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(u)){const{scene:e,filter:i,hit:r}=this._cache.get(u);t.Util.releaseCanvas(e,i,r),this._cache.delete(u)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const r=e||{};let n={};void 0!==r.x&&void 0!==r.y&&void 0!==r.width&&void 0!==r.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(r.width||n.width),o=Math.ceil(r.height||n.height),h=r.pixelRatio,l=void 0===r.x?Math.floor(n.x):r.x,c=void 0===r.y?Math.floor(n.y):r.y,g=r.offset||0,f=r.drawBorder||!1,p=r.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*g+(Math.abs(Math.round(n.x)-l)>.5?1:0),o+=2*g+(Math.abs(Math.round(n.y)-c)>.5?1:0),l-=g,c-=g;const _=new i.SceneCanvas({pixelRatio:h,width:s,height:o}),m=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),y=new i.HitCanvas({pixelRatio:p,width:s,height:o}),v=_.getContext(),x=y.getContext();return y.isCache=!0,_.isCache=!0,this._cache.delete(u),this._filterUpToDate=!1,!1===r.imageSmoothingEnabled&&(_.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),v.save(),x.save(),v.translate(-l,-c),x.translate(-l,-c),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(d),this.drawScene(_,this),this.drawHit(y,this),this._isUnderCache=!1,v.restore(),x.restore(),f&&(v.save(),v.beginPath(),v.rect(0,0,s,o),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.set(u,{scene:_,filter:m,hit:y,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(u)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let r=1/0,n=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.point(t);void 0===r&&(r=s=e.x,n=a=e.y),r=Math.min(r,e.x),n=Math.min(n,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:r,y:n,width:s-r,height:a-n}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,i,r,n,s=this.filters(),a=this._getCanvasCache(),o=a.scene,h=a.filter,l=h.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;h.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,l.clear(),l.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),r=0;r<e;r++)n=s[r],"function"==typeof n?(n.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof n+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let i,r,n,s,a,h=t.split(x),l=h.length;for(i=0;i<l;i++)r=h[i],n=r.split("."),s=n[0],a=n[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let i,r,n,s,a,h,l=(t||"").split(x),d=l.length;if(this._cache&&this._cache.delete(o),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<d;i++)if(n=l[i],s=n.split("."),a=s[0],h=s[1],a)this.eventListeners[a]&&this._off(a,h,e);else for(r in this.eventListeners)this._off(r,h,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(e,i,r){const n=this;this.on(e,(function(e){const s=e.target.findAncestors(i,!0,n);for(let i=0;i<s.length;i++)(e=t.Util.cloneObject(e)).currentTarget=s[i],r.call(s[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),n.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(b),this._clearSelfAndDescendantCache(w),this._clearSelfAndDescendantCache(g)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,r;if(!e)return this;for(i in e)"children"!==i&&(r="set"+t.Util._capitalize(i),t.Util._isFunction(this[r])?this[r](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(g,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(w,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let s=!1;n.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(s=!0)}));const a=!e&&!r.Konva.hitOnDragEnabled&&(s||r.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,r,n=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],a++,r.nodeType!==v&&(t=t.concat(r.getChildren().slice())),r._id===s._id&&(i=e);t.length>0&&t[0].getDepth()<=n&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(S),this._clearSelfAndDescendantCache(l)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(e){let i=!1,r=this.parent;for(;r;){if(r.isCached()){i=!0;break}r=r.parent}i&&!e&&(e=!0);const n=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=n.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(S);const n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(t.x,t.y),t={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(S),this._clearSelfAndDescendantCache(l),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,r=this.x(),n=this.y();return void 0!==e&&(r+=e),void 0!==i&&(n+=i),this.setPosition({x:r,y:n}),this}_eachAncestorReverse(t,e){let i,r,n=[],s=this.getParent();if(!e||e._id!==this._id){for(n.unshift(this);s&&(!e||s._id!==e._id);)n.unshift(s),s=s.parent;for(i=n.length,r=0;r<i;r++)t(n[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let e,i,r,n,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)i=a[e],s=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),s||(r="function"==typeof this[e]&&this[e],delete a[e],n=r?r.call(this):null,a[e]=i,n!==i&&(o.attrs[e]=i));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const r=[];e&&this._isMatch(t)&&r.push(this);let n=this.parent;for(;n;){if(n===i)return r;n._isMatch(t)&&r.push(n),n=n.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,r,n=e.replace(/ /g,"").split(","),s=n.length;for(i=0;i<s;i++)if(r=n[i],t.Util.isValidSelector(r)||(t.Util.warn('Selector "'+r+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===r.charAt(0)){if(this.id()===r.slice(1))return!0}else if("."===r.charAt(0)){if(this.hasName(r.slice(1)))return!0}else if(this.className===r||this.nodeType===r)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(b,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(l,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(l)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,r=this.attrs.offsetX||0,n=this.attrs.offsetY||0;i.translate(t-r,e-n)}return i.dirty=!1,i}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(S,this._getTransform)}_getTransform(){var e,i;const n=this._cache.get(S)||new t.Transform;n.reset();const s=this.x(),a=this.y(),o=r.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,d=this.attrs.skewX||0,c=this.attrs.skewY||0,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;return 0===s&&0===a||n.translate(s,a),0!==o&&n.rotate(o),0===d&&0===c||n.skew(d,c),1===h&&1===l||n.scale(h,l),0===u&&0===g||n.translate(-1*u,-1*g),n.dirty=!1,n}clone(e){let i,r,n,s,a,o=t.Util.cloneObject(this.attrs);for(i in e)o[i]=e[i];const h=new this.constructor(o);for(i in this.eventListeners)for(r=this.eventListeners[i],n=r.length,s=0;s<n;s++)a=r[s],a.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(a));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),r=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(r?r.width():0),height:t.height||Math.ceil(e.height)||(r?r.height():0),pixelRatio:a}),h=o.getContext(),l=new i.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(n),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(n||s)&&h.translate(-1*n,-1*s),this.drawScene(o,void 0,l),h.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(e){return new Promise(((i,r)=>{try{const r=null==e?void 0:e.callback;r&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==r||r(t)}))}catch(t){r(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():r.Konva.dragDistance}_off(t,e,i){let r,n,s,a=this.eventListeners[t];for(r=0;r<a.length;r++)if(n=a[r].name,s=a[r].handler,!("konva"===n&&"konva"!==e||e&&n!==e||i&&i!==s)){if(a.splice(r,1),0===a.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(e,i){const r=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(r)?r.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(r.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const r=this.attrs[e];(r!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,i),this._requestDraw())}_setComponentAttr(t,e,i){let r;void 0!==i&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){e&&this.nodeType===v&&(e.target=this);if(!((t===p||t===_)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const r=(t===p||t===_)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const n=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==n?void 0:n[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const n=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];s.push(...n),e=Object.getPrototypeOf(e)}n[t]=s,this._cache.set(o,n)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var r=0;r<i.length;r++)i[r].handler.call(this,e);const n=this.eventListeners[t];if(n)for(r=0;r<n.length;r++)n[r].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||r;n.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-r.x,y:s.y-r.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){n.DD._dragElements.has(this._id)||this._createDragElement(t);n.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,i){const r=this.getStage()._getPointerById(i.pointerId);if(!r)return;let n={x:r.x-i.offset.x,y:r.y-i.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const i=s.call(this,n,e);i?n=i:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=n.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),n.DD._endDragBefore(t),n.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=n.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if(!(!(void 0!==t.evt.button)||r.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;n.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=n.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&n.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const i=this.getStage();if(!i)return!1;const r={x:-e.x,y:-e.y,width:i.width()+2*e.x,height:i.height()+2*e.y};return t.Util.haveIntersection(r,this.getClientRect())}static create(e,i){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,i)}static _createNode(i,n){let s,a,o,h=e.prototype.getClassName.call(i),l=i.children;n&&(i.attrs.container=n),r.Konva[h]||(t.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(s=new(0,r.Konva[h])(i.attrs),l)for(a=l.length,o=0;o<a;o++)s.add(e._createNode(l[o]));return s}};f.Node=M,M.prototype.nodeType="Node",M.prototype._attrsAffectingSize=[],M.prototype.eventListeners={},M.prototype.on.call(M.prototype,k,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(S),this._clearSelfAndDescendantCache(l))})),M.prototype.on.call(M.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(w)})),M.prototype.on.call(M.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(g)})),M.prototype.on.call(M.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(a)}));const F=e.Factory.addGetterSetter;return F(M,"zIndex"),F(M,"absolutePosition"),F(M,"position"),F(M,"x",0,(0,s.getNumberValidator)()),F(M,"y",0,(0,s.getNumberValidator)()),F(M,"globalCompositeOperation","source-over",(0,s.getStringValidator)()),F(M,"opacity",1,(0,s.getNumberValidator)()),F(M,"name","",(0,s.getStringValidator)()),F(M,"id","",(0,s.getStringValidator)()),F(M,"rotation",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(M,"scale",["x","y"]),F(M,"scaleX",1,(0,s.getNumberValidator)()),F(M,"scaleY",1,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(M,"skew",["x","y"]),F(M,"skewX",0,(0,s.getNumberValidator)()),F(M,"skewY",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(M,"offset",["x","y"]),F(M,"offsetX",0,(0,s.getNumberValidator)()),F(M,"offsetY",0,(0,s.getNumberValidator)()),F(M,"dragDistance",null,(0,s.getNumberValidator)()),F(M,"width",0,(0,s.getNumberValidator)()),F(M,"height",0,(0,s.getNumberValidator)()),F(M,"listening",!0,(0,s.getBooleanValidator)()),F(M,"preventDefault",!0,(0,s.getBooleanValidator)()),F(M,"filters",null,(function(t){return this._filterUpToDate=!1,t})),F(M,"visible",!0,(0,s.getBooleanValidator)()),F(M,"transformsEnabled","all",(0,s.getStringValidator)()),F(M,"size"),F(M,"dragBoundFunc"),F(M,"draggable",!1,(0,s.getBooleanValidator)()),e.Factory.backCompat(M,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),f}var F,R={};function I(){if(F)return R;F=1,Object.defineProperty(R,"__esModule",{value:!0}),R.Container=void 0;const t=y(),e=M(),i=m();let r=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((r=>{const n=r._isMatch(t);return n&&i.push(r),!(!n||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){i.add(t.clone())})),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const r=this.getLayer(),n=t||r&&r.getCanvas(),s=n&&n.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=n&&n.isCache;if(!this.isVisible()&&!h)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",n,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),r=t||i&&i.hitCanvas,n=r&&r.getContext(),s=this._getCanvasCache();if(s&&s.hit){n.save();const t=this.getAbsoluteTransform(e).getMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(n),n.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var n;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,d=i===this;if(l){s.save();const t=this.getAbsoluteTransform(i);let e,r=t.getMatrix();if(s.transform(r[0],r[1],r[2],r[3],r[4],r[5]),s.beginPath(),h)e=h.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),r=t.copy().invert().getMatrix(),s.transform(r[0],r[1],r[2],r[3],r[4],r[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(n=this.children)||void 0===n||n.forEach((function(n){n[t](e,i,r)})),c&&s.restore(),l&&s.restore()}getClientRect(t={}){var e;const i=t.skipTransform,r=t.relativeTo;let n,s,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===n?(n=i.x,s=i.y,a=i.x+i.width,o=i.y+i.height):(n=Math.min(n,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))}));const d=this.find("Shape");let c=!1;for(let t=0;t<d.length;t++){if(d[t]._isVisible(this)){c=!0;break}}return h=c&&void 0!==n?{x:n,y:s,width:a-n,height:o-s}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,r)}};return R.Container=r,t.Factory.addComponentsGetterSetter(r,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(r,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipFunc"),R}var E,O,D={},G={};function L(){if(E)return G;E=1,Object.defineProperty(G,"__esModule",{value:!0}),G.getCapturedShape=function(t){return e.get(t)},G.createEvent=r,G.hasPointerCapture=function(t,i){return e.get(t)===i},G.setPointerCapture=function(t,s){n(t);if(!s.getStage())return;e.set(t,s),i&&s._fire("gotpointercapture",r(new PointerEvent("gotpointercapture")))},G.releaseCapture=n;const t=h(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function r(t){return{evt:t,pointerId:t.pointerId}}function n(t,n){const s=e.get(t);if(!s)return;const a=s.getStage();a&&a.content,e.delete(t),i&&s._fire("lostpointercapture",r(new PointerEvent("lostpointercapture")))}return G}var N,U,B={},W={};function z(){return N||(N=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=h(),i=c(),r=y(),n=M(),s=m(),a=h(),o=L(),l="hasShadow",d="shadowRGBA",u="patternImage",g="linearGradient",f="radialGradient";let p;function _(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class v extends n.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(l,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(u,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=_().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=r.getMatrix(),s="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(g,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=_(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),n=e.createLinearGradient(i.x,i.y,r.x,r.y);for(let e=0;e<t.length;e+=2)n.addColorStop(t[e],t[e+1]);return n}}_getRadialGradient(){return this._getCache(f,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=_(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),n=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)n.addColorStop(t[e],t[e+1]);return n}}getShadowRGBA(){return this._getCache(d,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return n.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),r=this.hasStroke(),n=1!==this.getAbsoluteOpacity();if(i&&r&&n)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&r&&s&&a)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const r=t.skipTransform,n=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,h=s.height+a,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=o+Math.abs(d),g=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(a/2+f)+Math.min(d,0)+s.x,y:-(a/2+f)+Math.min(c,0)+s.y};return r?p:this._transformedRect(p,n)}drawScene(t,e,i){const r=this.getLayer();let n,s,a=t||r.getCanvas(),o=a.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow();const c=a.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!c){n=this.getStage();const t=i||n.bufferCanvas;s=t.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var g=this.getAbsoluteTransform(e).getMatrix();s.transform(g[0],g[1],g[2],g[3],g[4],g[5]),l.call(this,s,this),s.restore();const r=t.pixelRatio;d&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/r,t.height/r)}else{if(o._applyLineJoin(this),!u){g=this.getAbsoluteTransform(e).getMatrix();o.transform(g[0],g[1],g[2],g[3],g[4],g[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}d&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;const n=this.getLayer(),s=t||n.hitCanvas,a=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;a.save(),a._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){let e,r,n,s,a,o,h=this._getCanvasCache(),l=this._getCachedSceneCanvas(),d=h.hit,c=d.getContext(),u=d.getWidth(),g=d.getHeight();c.clear(),c.drawImage(l._canvas,0,0,u,g);try{for(e=c.getImageData(0,0,u,g),r=e.data,n=r.length,s=i.Util._hexToRgb(this.colorKey),a=0;a<n;a+=4)o=r[a+3],o>t?(r[a]=s.r,r[a+1]=s.g,r[a+2]=s.b,r[a+3]=255):r[a+3]=0;c.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=v,v.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},v.prototype._strokeFunc=function(t){t.stroke()},v.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},v.prototype._strokeFuncHit=function(t){t.stroke()},v.prototype._centroid=!1,v.prototype.nodeType="Shape",(0,a._registerNode)(v),v.prototype.eventListeners={},v.prototype.on.call(v.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),v.prototype.on.call(v.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(d)})),v.prototype.on.call(v.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(u)})),v.prototype.on.call(v.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(g)})),v.prototype.on.call(v.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(f)})),r.Factory.addGetterSetter(v,"stroke",void 0,(0,s.getStringOrGradientValidator)()),r.Factory.addGetterSetter(v,"strokeWidth",2,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(v,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(v,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),r.Factory.addGetterSetter(v,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),r.Factory.addGetterSetter(v,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),r.Factory.addGetterSetter(v,"lineJoin"),r.Factory.addGetterSetter(v,"lineCap"),r.Factory.addGetterSetter(v,"sceneFunc"),r.Factory.addGetterSetter(v,"hitFunc"),r.Factory.addGetterSetter(v,"dash"),r.Factory.addGetterSetter(v,"dashOffset",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"shadowColor",void 0,(0,s.getStringValidator)()),r.Factory.addGetterSetter(v,"shadowBlur",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"shadowOpacity",1,(0,s.getNumberValidator)()),r.Factory.addComponentsGetterSetter(v,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(v,"shadowOffsetX",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"shadowOffsetY",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillPatternImage"),r.Factory.addGetterSetter(v,"fill",void 0,(0,s.getStringOrGradientValidator)()),r.Factory.addGetterSetter(v,"fillPatternX",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillPatternY",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(v,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(v,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(v,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(v,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(v,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(v,"fillEnabled",!0),r.Factory.addGetterSetter(v,"strokeEnabled",!0),r.Factory.addGetterSetter(v,"shadowEnabled",!0),r.Factory.addGetterSetter(v,"dashEnabled",!0),r.Factory.addGetterSetter(v,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(v,"fillPriority","color"),r.Factory.addComponentsGetterSetter(v,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(v,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),r.Factory.addComponentsGetterSetter(v,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(v,"fillPatternScaleX",1,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(v,"fillPatternScaleY",1,(0,s.getNumberValidator)()),r.Factory.addComponentsGetterSetter(v,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(v,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(v,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(v,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(v,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(v,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(v,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(v,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(v,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(v,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(v,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(v,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(v,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(v,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(v,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(v,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(v,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(v,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(v,"fillPatternRotation",0),r.Factory.addGetterSetter(v,"fillRule",void 0,(0,s.getStringValidator)()),r.Factory.backCompat(v,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(W)),W}function H(){if(U)return B;U=1,Object.defineProperty(B,"__esModule",{value:!0}),B.Layer=void 0;const t=c(),e=I(),i=M(),r=y(),n=C(),s=m(),a=z(),o=h(),l=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=l.length;let u=class extends e.Container{constructor(t){super(t),this.canvas=new n.SceneCanvas,this.hitCanvas=new n.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){i.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!i.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(i.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(i.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(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(),i.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let r=0;r<d;r++){const n=l[r],s=this._getIntersection({x:t.x+n.x*e,y:t.y+n.y*e}),a=s.shape;if(a)return a;if(i=!!s.antialiased,!s.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,n=r[3];if(255===n){const e=t.Util._rgbToHex(r[0],r[1],r[2]),i=a.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,i){const r=this.getLayer(),n=t||r&&r.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),e.Container.prototype.drawScene.call(this,n,i),this._fire("draw",{node:this}),this}drawHit(t,i){const r=this.getLayer(),n=t||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,n,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return B.Layer=u,u.prototype.nodeType="Layer",(0,o._registerNode)(u),r.Factory.addGetterSetter(u,"imageSmoothingEnabled",!0),r.Factory.addGetterSetter(u,"clearBeforeDraw",!0),r.Factory.addGetterSetter(u,"hitGraphEnabled",!0,(0,s.getBooleanValidator)()),B}var V,j={};var K,X={};function Y(){if(K)return X;K=1,Object.defineProperty(X,"__esModule",{value:!0}),X.Group=void 0;const t=c(),e=I(),i=h();let r=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return X.Group=r,r.prototype.nodeType="Group",(0,i._registerNode)(r),X}var q,Q={};function J(){if(q)return Q;q=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.Animation=void 0;const t=h(),e=c(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let r=class t{constructor(e,r){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(r)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._removeAnimation(this),this}_updateFrameObject(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}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let r=0;r<e.length;r++){const n=e[r],s=n.layers,a=n.func;n._updateFrameObject(i());const o=s.length;let h;if(h=!a||!1!==a.call(n,n.frame),h)for(let e=0;e<o;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return Q.Animation=r,r.animations=[],r.animIdCounter=0,r.animRunning=!1,Q}var Z,$,tt={};function et(){return $||($=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=h(),i=c(),r=M(),n=I(),s=(O||(O=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=c(),i=y(),r=I(),n=h(),s=C(),a=A(),o=h(),l=L(),d="mouseleave",u="mouseover",g="mouseenter",f="mousemove",p="mousedown",_="mouseup",m="pointermove",v="pointerdown",x="pointerup",b="pointercancel",S="pointerout",w="pointerleave",k="pointerover",P="pointerenter",T="contextmenu",M="touchstart",F="touchend",R="touchmove",E="touchcancel",O="wheel",D=[[g,"_pointerenter"],[p,"_pointerdown"],[f,"_pointermove"],[_,"_pointerup"],[d,"_pointerleave"],[M,"_pointerdown"],[R,"_pointermove"],[F,"_pointerup"],[E,"_pointercancel"],[u,"_pointerover"],[O,"_wheel"],[T,"_contextmenu"],[v,"_pointerdown"],[m,"_pointermove"],[x,"_pointerup"],[b,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],G={mouse:{[S]:"mouseout",[w]:d,[k]:u,[P]:g,[m]:f,[v]:p,[x]:_,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[S]:"touchout",[w]:"touchleave",[k]:"touchover",[P]:"touchenter",[m]:R,[v]:M,[x]:F,[b]:E,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[S]:S,[w]:w,[k]:k,[P]:P,[m]:m,[v]:v,[x]:x,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},N=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",U=t=>{const e=N(t);return"pointer"===e?n.Konva.pointerEventsEnabled&&G.pointer:"touch"===e?G.touch:"mouse"===e?G.mouse:void 0};function B(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class W extends r.Container{constructor(e){super(B(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{B(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e)}if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){let t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.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)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach((function(e){if(!e.isVisible())return;const r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())})),e}getIntersection(t){if(!t)return null;let e,i=this.children;for(e=i.length-1;e>=0;e--){const r=i[e].getIntersection(t);if(r)return r}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const r=this.children.length;return r>5&&e.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."),t.setSize({width:this.width(),height:this.height()}),t.draw(),n.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return l.hasPointerCapture(t,this)}setPointerCapture(t){l.setPointerCapture(t,this)}releaseCapture(t){l.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){n.Konva.isBrowser&&D.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=U(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=U(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=U(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this._getTargetShape(i),s=!(n.Konva.isDragging()||n.Konva.isTransforming())||n.Konva.hitOnDragEnabled;r&&s?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=U(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);let r=!1;this._changedPointerPositions.forEach((s=>{const o=this.getIntersection(s);if(a.DD.justDragged=!1,n.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return void(this[i+"ClickStartShape"]=void 0);n.Konva.capturePointerEventsEnabled&&o.setPointerCapture(s.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),r=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=U(t.type),i=N(t.type);if(!e)return;if(n.Konva.isDragging()&&a.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(n.Konva.isDragging()||n.Konva.isTransforming())&&!n.Konva.hitOnDragEnabled)return;const r={};let s=!1;const o=this._getTargetShape(i);this._changedPointerPositions.forEach((n=>{const a=l.getCapturedShape(n.id)||this.getIntersection(n),h=n.id,d={evt:t,pointerId:h},c=o!==a;if(c&&o&&(o._fireAndBubble(e.pointerout,{...d},a),o._fireAndBubble(e.pointerleave,{...d},a)),a){if(r[a._id])return;r[a._id]=!0}a&&a.isListening()?(s=!0,c&&(a._fireAndBubble(e.pointerover,{...d},o),a._fireAndBubble(e.pointerenter,{...d},o),this[i+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...d})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)})),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=U(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],o={};let h=!1;this._changedPointerPositions.forEach((d=>{const c=l.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),o[c._id])return;o[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let f=!1;n.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):a.DD.justDragged||(n.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){n.Konva["_"+i+"InDblClickWindow"]=!1}),n.Konva.dblClickWindow),c&&c.isListening()?(h=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),n.Konva["_"+i+"ListenClick"]&&r&&r===c&&(c._fireAndBubble(e.pointerclick,{...g}),f&&s&&s===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,n.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),h||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),n.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(T,{evt:t}):this._fire(T,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(O,{evt:t}):this._fire(O,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=l.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(x,l.createEvent(t)),l.releaseCapture(t.pointerId)}_lostpointercapture(t){l.releaseCapture(t.pointerId)}setPointersPositions(t){let i=this._getContentPosition(),r=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._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:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:n,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const 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}}_buildDOM(){if(this.bufferCanvas=new s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!n.Konva.isBrowser)return;const 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()}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=W,W.prototype.nodeType="Stage",(0,o._registerNode)(W),i.Factory.addGetterSetter(W,"container"),n.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(D)),D),a=H(),o=function(){if(V)return j;V=1,Object.defineProperty(j,"__esModule",{value:!0}),j.FastLayer=void 0;const t=c(),e=H(),i=h();let r=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return j.FastLayer=r,r.prototype.nodeType="FastLayer",(0,i._registerNode)(r),j}(),l=Y(),d=A(),u=z(),g=J(),f=(Z||(Z=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=c(),i=J(),r=M(),n=h();let s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=0,o=["fill","stroke","shadowColor"];class l{constructor(t,e,i,r,n,s,a){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=s,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()}fire(t){const e=this[t];e&&e()}setTime(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())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class d{constructor(r){let o,h,c=this,u=r.node,g=u._id,f=r.easing||t.Easings.Linear,p=!!r.yoyo;o=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=u,this._id=a++;const _=u.getLayer()||(u instanceof n.Konva.Stage?u.getLayers():null);for(h in _||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){c.tween.onEnterFrame()}),_),this.tween=new l(h,(function(t){c._tweenFunc(t)}),f,0,1,1e3*o,p),this._addListeners(),d.attrs[g]||(d.attrs[g]={}),d.attrs[g][this._id]||(d.attrs[g][this._id]={}),d.tweens[g]||(d.tweens[g]={}),r)void 0===s[h]&&this._addAttr(h,r[h]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){let r,n,s,a,h,l,c,u,g=this.node,f=g._id;if(s=d.tweens[f][t],s&&delete d.attrs[f][s][t],r=g.getAttr(t),e.Util._isArray(i))if(n=[],h=Math.max(i.length,r.length),"points"===t&&i.length!==r.length&&(i.length>r.length?(c=r,r=e.Util._prepareArrayForTween(r,i,g.closed())):(l=i,i=e.Util._prepareArrayForTween(i,r,g.closed()))),0===t.indexOf("fill"))for(a=0;a<h;a++)if(a%2==0)n.push(i[a]-r[a]);else{const t=e.Util.colorToRGBA(r[a]);u=e.Util.colorToRGBA(i[a]),r[a]=t,n.push({r:u.r-t.r,g:u.g-t.g,b:u.b-t.b,a:u.a-t.a})}else for(a=0;a<h;a++)n.push(i[a]-r[a]);else-1!==o.indexOf(t)?(r=e.Util.colorToRGBA(r),u=e.Util.colorToRGBA(i),n={r:u.r-r.r,g:u.g-r.g,b:u.b-r.b,a:u.a-r.a}):n=i-r;d.attrs[f][this._id][t]={start:r,diff:n,end:i,trueEnd:l,trueStart:c},d.tweens[f][t]=this._id}_tweenFunc(t){let i,r,n,s,a,h,l,c,u=this.node,g=d.attrs[u._id][this._id];for(i in g){if(r=g[i],n=r.start,s=r.diff,c=r.end,e.Util._isArray(n))if(a=[],l=Math.max(n.length,c.length),0===i.indexOf("fill"))for(h=0;h<l;h++)h%2==0?a.push((n[h]||0)+s[h]*t):a.push("rgba("+Math.round(n[h].r+s[h].r*t)+","+Math.round(n[h].g+s[h].g*t)+","+Math.round(n[h].b+s[h].b*t)+","+(n[h].a+s[h].a*t)+")");else for(h=0;h<l;h++)a.push((n[h]||0)+s[h]*t);else a=-1!==o.indexOf(i)?"rgba("+Math.round(n.r+s.r*t)+","+Math.round(n.g+s.g*t)+","+Math.round(n.b+s.b*t)+","+(n.a+s.a*t)+")":n+s*t;u.setAttr(i,a)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=d.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=d.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t,e=this.node._id,i=this._id,r=d.tweens[e];for(t in this.pause(),r)delete d.tweens[e][t];delete d.attrs[e][i]}}t.Tween=d,d.attrs={},d.tweens={},r.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new d(t).play()},t.Easings={BackEaseIn(t,e,i,r){const n=1.70158;return i*(t/=r)*t*((n+1)*t-n)+e},BackEaseOut(t,e,i,r){const n=1.70158;return i*((t=t/r-1)*t*((n+1)*t+n)+1)+e},BackEaseInOut(t,e,i,r){let 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(t,e,i,r,n,s){let a=0;return 0===t?e:1==(t/=r)?e+i:(s||(s=.3*r),!n||n<Math.abs(i)?(n=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/n),-n*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,i,r,n,s){let a=0;return 0===t?e:1==(t/=r)?e+i:(s||(s=.3*r),!n||n<Math.abs(i)?(n=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/n),n*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/s)+i+e)},ElasticEaseInOut(t,e,i,r,n,s){let a=0;return 0===t?e:2==(t/=r/2)?e+i:(s||(s=r*(.3*1.5)),!n||n<Math.abs(i)?(n=i,a=s/4):a=s/(2*Math.PI)*Math.asin(i/n),t<1?n*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/s)*-.5+e:n*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/s)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(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:(e,i,r,n)=>r-t.Easings.BounceEaseOut(n-e,0,r,n)+i,BounceEaseInOut:(e,i,r,n)=>e<n/2?.5*t.Easings.BounceEaseIn(2*e,0,r,n)+i:.5*t.Easings.BounceEaseOut(2*e-n,0,r,n)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(tt)),tt),p=w(),_=C();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:n.Container,Stage:s.Stage,stages:s.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:l.Group,DD:d.DD,Shape:u.Shape,shapes:u.shapes,Animation:g.Animation,Tween:f.Tween,Easings:f.Easings,Context:p.Context,Canvas:_.Canvas}),t.default=t.Konva}(a)),a}var it,rt={};var nt,st={},at={};function ot(){if(nt)return at;nt=1,Object.defineProperty(at,"__esModule",{value:!0}),at.Line=void 0;const t=y(),e=h(),i=z(),r=m();function n(t,e,i,r,n,s,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(n-i,2)+Math.pow(s-r,2)),l=a*o/(o+h),d=a*h/(o+h);return[i-l*(n-t),r-l*(s-e),i+d*(n-t),r+d*(s-e)]}function s(t,e){const i=t.length,r=[];for(let s=2;s<i-2;s+=2){const i=n(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(t[s]),r.push(t[s+1]),r.push(i[2]),r.push(i[3]))}return r}let a=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,i,r,n=this.points(),s=n.length,a=this.tension(),o=this.closed(),h=this.bezier();if(s){if(t.beginPath(),t.moveTo(n[0],n[1]),0!==a&&s>4){for(e=this.getTensionPoints(),i=e.length,r=o?0:4,o||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++]);o||t.quadraticCurveTo(e[i-2],e[i-1],n[s-2],n[s-1])}else if(h)for(r=2;r<s;)t.bezierCurveTo(n[r++],n[r++],n[r++],n[r++],n[r++],n[r++]);else for(r=2;r<s;r+=2)t.lineTo(n[r],n[r+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():s(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),r=n(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),a=n(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),o=s(t,i);return[r[2],r[3]].concat(o).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,r=t[0],n=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),n=Math.max(n,e),s=Math.min(s,i),a=Math.max(a,i);return{x:r,y:s,width:n-r,height:a-s}}};return at.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(a),t.Factory.addGetterSetter(a,"closed",!1),t.Factory.addGetterSetter(a,"bezier",!1),t.Factory.addGetterSetter(a,"tension",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(a,"points",[],(0,r.getNumberArrayValidator)()),at}var ht,lt,dt,ct={},ut={};function gt(){if(lt)return ct;lt=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Path=void 0;const t=y(),e=z(),i=h(),r=(ht||(ht=1,function(t){function e(t,e,r){const n=i(1,r,t),s=i(1,r,e),a=n*n+s*s;return Math.sqrt(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,r,n)=>{let s,a;const o=n/2;s=0;for(let n=0;n<20;n++)a=o*t.tValues[20][n]+o,s+=t.cValues[20][n]*e(i,r,a);return o*s},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],n=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(r*r+n*n),h=4*(r*s+n*a),l=s*s+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,u=l/o-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,f=d*d+u>0?Math.sqrt(d*d+u):0,p=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+f))):0;return Math.sqrt(o)/2*(c*g-d*f+p)};const i=(e,r,n)=>{const s=n.length-1;let a,o;if(0===s)return 0;if(0===e){o=0;for(let e=0;e<=s;e++)o+=t.binomialCoefficients[s][e]*Math.pow(1-r,s-e)*Math.pow(r,e)*n[e];return o}a=new Array(s);for(let t=0;t<s;t++)a[t]=s*(n[t+1]-n[t]);return i(e-1,r,a)};t.t2length=(t,e,i)=>{let r=1,n=t/e,s=(t-i(n))/e,a=0;for(;r>.001;){const o=i(n+s),h=Math.abs(t-o)/e;if(h<r)r=h,n+=s;else{const a=i(n-s),o=Math.abs(t-a)/e;o<r?(r=o,n-=s):s/=2}if(a++,a>500)break}return n}}(ut)),ut);let n=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let f=0;f<e.length;f++){const p=e[f].command,_=e[f].points;switch(p){case"L":t.lineTo(_[0],_[1]);break;case"M":t.moveTo(_[0],_[1]);break;case"C":t.bezierCurveTo(_[0],_[1],_[2],_[3],_[4],_[5]);break;case"Q":t.quadraticCurveTo(_[0],_[1],_[2],_[3]);break;case"A":var r=_[0],n=_[1],s=_[2],a=_[3],o=_[4],h=_[5],l=_[6],d=_[7],c=s>a?s:a,u=s>a?1:s/a,g=s>a?a/s:1;t.translate(r,n),t.rotate(l),t.scale(u,g),t.arc(0,0,c,o,o+h,1-d),t.scale(1/u,1/g),t.rotate(-l),t.translate(-r,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(i){if("A"===i.command){const r=i.points[4],n=i.points[5],s=i.points[4]+n;let a=Math.PI/180;if(Math.abs(r-s)<a&&(a=Math.abs(r-s)),n<0)for(let n=r-a;n>s;n-=a){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],n,0);e.push(r.x,r.y)}else for(let n=r+a;n<s;n+=a){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],n,0);e.push(r.x,r.y)}}else if("C"===i.command)for(let r=0;r<=1;r+=.01){const n=t.getPointOnCubicBezier(r,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(n.x,n.y)}else e=e.concat(i.points)}));let i,r,n=e[0],s=e[0],a=e[1],o=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],r=e[2*t+1],isNaN(i)||(n=Math.min(n,i),s=Math.max(s,i)),isNaN(r)||(a=Math.min(a,r),o=Math.max(o,r));return{x:n,y:a,width:s-n,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let n,s=0,a=i.length;if(!a)return null;for(;s<a&&e>i[s].pathLength;)e-=i[s].pathLength,++s;if(s===a)return n=i[s-1].points.slice(-2),{x:n[0],y:n[1]};if(e<.01)return n=i[s].points.slice(0,2),{x:n[0],y:n[1]};const o=i[s],h=o.points;switch(o.command){case"L":return t.getPointOnLine(e,o.start.x,o.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,r.t2length)(e,t.getPathLength(i),(t=>(0,r.getCubicArcLength)([o.start.x,h[0],h[2],h[4]],[o.start.y,h[1],h[3],h[5]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,r.t2length)(e,t.getPathLength(i),(t=>(0,r.getQuadraticArcLength)([o.start.x,h[0],h[2]],[o.start.y,h[1],h[3]],t))),o.start.x,o.start.y,h[0],h[1],h[2],h[3]);case"A":var l=h[0],d=h[1],c=h[2],u=h[3],g=h[4],f=h[5],p=h[6];return g+=f*e/o.pathLength,t.getPointOnEllipticalArc(l,d,c,u,g,p)}return null}static getPointOnLine(t,e,i,r,n,s,a){s=null!=s?s:e,a=null!=a?a:i;const o=this.getLineLength(e,i,r,n);if(o<1e-10)return{x:e,y:i};if(r===e)return{x:s,y:a+(n>i?t:-t)};const h=(n-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(a-i-h*(s-e))<1e-10)return{x:s+l,y:a+d};const c=((s-e)*(r-e)+(a-i)*(n-i))/(o*o),u=e+c*(r-e),g=i+c*(n-i),f=this.getLineLength(s,a,u,g),p=Math.sqrt(t*t-f*f),_=Math.sqrt(p*p/(1+h*h))*(r<e?-1:1);return{x:u+_,y:g+h*_}}static getPointOnCubicBezier(t,e,i,r,n,s,a,o,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+s*d(t)+r*c(t)+e*u(t),y:h*l(t)+a*d(t)+n*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,r,n,s,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:s*o(t)+r*h(t)+e*l(t),y:a*o(t)+n*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,n,s){const a=Math.cos(s),o=Math.sin(s),h=i*Math.cos(n),l=r*Math.sin(n);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const 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]);const n=e.split("|"),s=[],a=[];let o=0,h=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let d;for(r=1;r<n.length;r++){let t=n[r],e=t.charAt(0);for(t=t.slice(1),a.length=0;d=l.exec(t);)a.push(d[0]);const i=[];for(let t=0,e=a.length;t<e;t++){if("00"===a[t]){i.push(0,0);continue}const e=parseFloat(a[t]);isNaN(e)?i.push(0):i.push(e)}for(;i.length>0&&!isNaN(i[0]);){let t="",r=[];const n=o,a=h;var c,u,g,f,p,_,m,y,v,x;switch(e){case"l":o+=i.shift(),h+=i.shift(),t="L",r.push(o,h);break;case"L":o=i.shift(),h=i.shift(),r.push(o,h);break;case"m":var b=i.shift(),S=i.shift();if(o+=b,h+=S,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){o=s[t].points[0]+b,h=s[t].points[1]+S;break}r.push(o,h),e="l";break;case"M":o=i.shift(),h=i.shift(),t="M",r.push(o,h),e="L";break;case"h":o+=i.shift(),t="L",r.push(o,h);break;case"H":o=i.shift(),t="L",r.push(o,h);break;case"v":h+=i.shift(),t="L",r.push(o,h);break;case"V":h=i.shift(),t="L",r.push(o,h);break;case"C":r.push(i.shift(),i.shift(),i.shift(),i.shift()),o=i.shift(),h=i.shift(),r.push(o,h);break;case"c":r.push(o+i.shift(),h+i.shift(),o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",r.push(o,h);break;case"S":u=o,g=h,"C"===(c=s[s.length-1]).command&&(u=o+(o-c.points[2]),g=h+(h-c.points[3])),r.push(u,g,i.shift(),i.shift()),o=i.shift(),h=i.shift(),t="C",r.push(o,h);break;case"s":u=o,g=h,"C"===(c=s[s.length-1]).command&&(u=o+(o-c.points[2]),g=h+(h-c.points[3])),r.push(u,g,o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="C",r.push(o,h);break;case"Q":r.push(i.shift(),i.shift()),o=i.shift(),h=i.shift(),r.push(o,h);break;case"q":r.push(o+i.shift(),h+i.shift()),o+=i.shift(),h+=i.shift(),t="Q",r.push(o,h);break;case"T":u=o,g=h,"Q"===(c=s[s.length-1]).command&&(u=o+(o-c.points[0]),g=h+(h-c.points[1])),o=i.shift(),h=i.shift(),t="Q",r.push(u,g,o,h);break;case"t":u=o,g=h,"Q"===(c=s[s.length-1]).command&&(u=o+(o-c.points[0]),g=h+(h-c.points[1])),o+=i.shift(),h+=i.shift(),t="Q",r.push(u,g,o,h);break;case"A":f=i.shift(),p=i.shift(),_=i.shift(),m=i.shift(),y=i.shift(),v=o,x=h,o=i.shift(),h=i.shift(),t="A",r=this.convertEndpointToCenterParameterization(v,x,o,h,m,y,f,p,_);break;case"a":f=i.shift(),p=i.shift(),_=i.shift(),m=i.shift(),y=i.shift(),v=o,x=h,o+=i.shift(),h+=i.shift(),t="A",r=this.convertEndpointToCenterParameterization(v,x,o,h,m,y,f,p,_)}s.push({command:t||e,points:r,start:{x:n,y:a},pathLength:this.calcLength(n,a,t||e,r)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,i,n,s){let a,o,h,l;const d=t;switch(n){case"L":return d.getLineLength(e,i,s[0],s[1]);case"C":return(0,r.getCubicArcLength)([e,s[0],s[2],s[4]],[i,s[1],s[3],s[5]],1);case"Q":return(0,r.getQuadraticArcLength)([e,s[0],s[2]],[i,s[1],s[3]],1);case"A":a=0;var c=s[4],u=s[5],g=s[4]+u,f=Math.PI/180;if(Math.abs(c-g)<f&&(f=Math.abs(c-g)),o=d.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),u<0)for(l=c-f;l>g;l-=f)h=d.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=d.getLineLength(o.x,o.y,h.x,h.y),o=h;else for(l=c+f;l<g;l+=f)h=d.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],l,0),a+=d.getLineLength(o.x,o.y,h.x,h.y),o=h;return h=d.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],g,0),a+=d.getLineLength(o.x,o.y,h.x,h.y),a}return 0}static convertEndpointToCenterParameterization(t,e,i,r,n,s,a,o,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,u=d*d/(a*a)+c*c/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let g=Math.sqrt((a*a*(o*o)-a*a*(c*c)-o*o*(d*d))/(a*a*(c*c)+o*o*(d*d)));n===s&&(g*=-1),isNaN(g)&&(g=0);const f=g*a*c/o,p=g*-o*d/a,_=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,m=(e+r)/2+Math.sin(l)*f+Math.cos(l)*p,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},v=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(v(t,e))},b=x([1,0],[(d-f)/a,(c-p)/o]),S=[(d-f)/a,(c-p)/o],w=[(-1*d-f)/a,(-1*c-p)/o];let C=x(S,w);return v(S,w)<=-1&&(C=Math.PI),v(S,w)>=1&&(C=0),0===s&&C>0&&(C-=2*Math.PI),1===s&&C<0&&(C+=2*Math.PI),[_,m,a,o,b,C,l,s]}};return ct.Path=n,n.prototype.className="Path",n.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(n),t.Factory.addGetterSetter(n,"data"),ct}var ft,pt={};var _t,mt={};var yt,vt={};var xt,bt={};var St,wt={};function Ct(){if(St)return wt;St=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.Rect=void 0;const t=y(),e=z(),i=h(),r=c(),n=m();let s=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?r.Util.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}};return wt.Rect=s,s.prototype.className="Rect",(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),wt}var kt,Pt={};var Tt,At={};var Mt,Ft={};var Rt,It={};var Et,Ot={};function Dt(){if(Et)return Ot;Et=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Text=void 0,Ot.stringToArray=a;const t=c(),e=y(),i=z(),r=h(),n=m(),s=h();function a(t){return[...t].reduce(((t,e,i,r)=>(/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(e)?t.push(e):/\p{Regional_Indicator}{2}/u.test(e+(r[i+1]||""))?t.push(e+r[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:t.push(e),t)),[])}const o="auto",l="inherit",d="justify",u="left",g="middle",f="normal",p=" ",_="none",v=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],x=v.length;let b;function S(){return b||(b=t.Util.createCanvasElement().getContext("2d"),b)}let w=class extends i.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<x;t++)this.on(v[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let n,s=this.padding(),o=this.fontSize(),h=this.lineHeight()*o,c=this.verticalAlign(),f=this.direction(),p=0,_=this.align(),m=this.getWidth(),y=this.letterSpacing(),v=this.fill(),x=this.textDecoration(),b=-1!==x.indexOf("underline"),S=-1!==x.indexOf("line-through");f=f===l?t.direction:f;let w=h/2,C=g;if(r.Konva._fixTextRendering){const t=this.measureSize("M");C="alphabetic",w=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+h/2}var k=0,P=0;for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",C),t.setAttr("textAlign",u),c===g?p=(this.getHeight()-i*h-2*s)/2:"bottom"===c&&(p=this.getHeight()-i*h-2*s),t.translate(s,p+s),n=0;n<i;n++){k=0,P=0;var T,A,M,F=e[n],R=F.text,I=F.width,E=F.lastInParagraph;if(t.save(),"right"===_?k+=m-I-2*s:"center"===_&&(k+=(m-I-2*s)/2),b){t.save(),t.beginPath();const e=k,i=w+P+(r.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,i),A=0===(T=R.split(" ").length-1),M=_!==d||E?I:m-2*s,t.lineTo(e+Math.round(M),i),t.lineWidth=o/15;const n=this._getLinearGradient();t.strokeStyle=n||v,t.stroke(),t.restore()}if(S){t.save(),t.beginPath();const e=r.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(k,w+P+e),A=0===(T=R.split(" ").length-1),M=_===d&&E&&!A?m-2*s:I,t.lineTo(k+Math.round(M),w+P+e),t.lineWidth=o/15;const i=this._getLinearGradient();t.strokeStyle=i||v,t.stroke(),t.restore()}if("rtl"===f||0===y&&_!==d)0!==y&&t.setAttr("letterSpacing",`${y}px`),this._partialTextX=k,this._partialTextY=w+P,this._partialText=R,t.fillStrokeShape(this);else{T=R.split(" ").length-1;const e=a(R);for(let i=0;i<e.length;i++){const r=e[i];" "!==r||E||_!==d||(k+=(m-2*s-I)/T),this._partialTextX=k,this._partialTextY=w+P,this._partialText=r,t.fillStrokeShape(this),k+=this.measureSize(r).width+y}}t.restore(),i>1&&(w+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===o||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===o||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,r,n,s,a,o,h,l,d,c;let u,g=S(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=u.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(n=u.actualBoundingBoxRight)&&void 0!==n?n:75.732421875*p,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===d&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return S().measureText(t).width+(i?e*(i-1):0)}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,n=this.attrs.width,s=this.attrs.height,a=n!==o&&void 0!==n,h=s!==o&&void 0!==s,l=this.padding(),d=n-2*l,c=s-2*l,u=0,g=this.wrap(),f="char"!==g&&g!==_,m=this.ellipsis();this.textArr=[],S().font=this._getContextFont();const y=m?this._getTextWidth("…"):0;for(let e=0,n=t.length;e<n;++e){let s=t[e],o=this._getTextWidth(s);if(a&&o>d)for(;s.length>0;){let t=0,e=s.length,n="",a=0;for(;t<e;){const i=t+e>>>1,r=s.slice(0,i+1),o=this._getTextWidth(r)+y;o<=d?(t=i+1,n=r,a=o):e=i}if(!n)break;if(f){var v;const e=s[n.length];(v=(e===p||"-"===e)&&a<=d?n.length:Math.max(n.lastIndexOf(p),n.lastIndexOf("-"))+1)>0&&(t=v,n=n.slice(0,t),a=this._getTextWidth(n))}n=n.trimRight(),this._addTextLine(n),i=Math.max(i,a),u+=r;if(this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}if(s=s.slice(t),s=s.trimLeft(),s.length>0&&(o=this._getTextWidth(s),o<=d)){this._addTextLine(s),u+=r,i=Math.max(i,o);break}}else this._addTextLine(s),u+=r,i=Math.max(i,o),this._shouldHandleEllipsis(u)&&e<n-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),h&&u+r>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,n=r!==o&&void 0!==r,s=r-2*this.padding();return!(this.wrap()!==_)||n&&t+i>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==o&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),n=this.textArr[this.textArr.length-1];if(n&&r){if(e){this._getTextWidth(n.text+"…")<i||(n.text=n.text.slice(0,n.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(n.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}};return Ot.Text=w,w.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype.className="Text",w.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,s._registerNode)(w),e.Factory.overWriteSetter(w,"width",(0,n.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(w,"height",(0,n.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(w,"direction",l),e.Factory.addGetterSetter(w,"fontFamily","Arial"),e.Factory.addGetterSetter(w,"fontSize",12,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(w,"fontStyle",f),e.Factory.addGetterSetter(w,"fontVariant",f),e.Factory.addGetterSetter(w,"padding",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(w,"align",u),e.Factory.addGetterSetter(w,"verticalAlign","top"),e.Factory.addGetterSetter(w,"lineHeight",1,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(w,"wrap","word"),e.Factory.addGetterSetter(w,"ellipsis",!1,(0,n.getBooleanValidator)()),e.Factory.addGetterSetter(w,"letterSpacing",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(w,"text","",(0,n.getStringValidator)()),e.Factory.addGetterSetter(w,"textDecoration",""),Ot}var Gt,Lt={};var Nt,Ut={};function Bt(){if(Nt)return Ut;Nt=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.Transformer=void 0;const t=c(),e=y(),i=M(),r=z(),n=Ct(),s=Y(),a=h(),o=m(),l=h(),d="tr-konva",u=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${d}`)).join(" "),g="nodesRect",f=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"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 a.Konva._global;const v=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function x(t,e,i){const 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{...t,rotation:t.rotation+e,x:r,y:n}}function b(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return x(t,e,i)}let S=0,w=class extends s.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(u,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return d+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(f.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const r=t.getAbsolutePosition(),n=r.x-e.x,s=r.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+n,y:r.y+s}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(g),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(g,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=t.getAbsoluteScale(i),s=t.getAbsolutePosition(i),o=r.x*n.x-t.offsetX()*n.x,h=r.y*n.y-t.offsetY()*n.y,l=(a.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return x({x:s.x+o*Math.cos(l)+h*Math.sin(-l),y:s.y+h*Math.cos(l)+o*Math.sin(l),width:r.width*n.x,height:r.height*n.y,rotation:l},-a.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],n=t.getAbsoluteTransform();r.forEach((function(t){const i=n.point(t);e.push(i)}))}));const i=new t.Transform;i.rotate(-a.Konva.getAngle(this.rotation()));let r=1/0,n=1/0,s=-1/0,o=-1/0;e.forEach((function(t){const e=i.point(t);void 0===r&&(r=s=e.x,n=o=e.y),r=Math.min(r,e.x),n=Math.min(n,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y)})),i.invert();const h=i.point({x:r,y:n});return{x:h.x,y:h.y,width:s-r,height:o-n,rotation:a.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),v.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const i=new n.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:_?10:"auto"}),r=this;i.on("mousedown touchstart",(function(t){r._handleMouseDown(t)})),i.on("dragstart",(t=>{i.stopDrag(),t.cancelBubble=!0})),i.on("dragend",(t=>{t.cancelBubble=!0})),i.on("mouseenter",(()=>{const r=a.Konva.getAngle(this.rotation()),n=this.rotateAnchorCursor(),s=function(e,i,r){if("rotater"===e)return r;i+=t.Util.degToRad(p[e]||0);const n=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(n,337.5,360)||t.Util._inRange(n,0,22.5)?"ns-resize":t.Util._inRange(n,22.5,67.5)?"nesw-resize":t.Util._inRange(n,67.5,112.5)?"ew-resize":t.Util._inRange(n,112.5,157.5)?"nwse-resize":t.Util._inRange(n,157.5,202.5)?"ns-resize":t.Util._inRange(n,202.5,247.5)?"nesw-resize":t.Util._inRange(n,247.5,292.5)?"ew-resize":t.Util._inRange(n,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(e,r,n);i.getStage().content&&(i.getStage().content.style.cursor=s),this._cursorChange=!0})),i.on("mouseout",(()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(i)}_createBack(){const e=new r.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const r=i.getParent(),n=r.padding();e.beginPath(),e.rect(-n,-n,i.width()+2*n,i.height()+2*n),e.moveTo(i.width()/2,-n),r.rotateEnabled()&&r.rotateLineVisible()&&e.lineTo(i.width()/2,-r.rotateAnchorOffset()*t.Util._sign(i.height())-n),e.fillStrokeShape(i)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const 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),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},S++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,i,r;const n=this.findOne("."+this._movingAnchorName),s=n.getStage();s.setPointersPositions(t);const o=s.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=n.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),n.setAbsolutePosition(h);const d=n.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const r=this._getNodeRect();e=n.x()-r.width/2,i=-n.y()+r.height/2;let s=Math.atan2(-i,e)+Math.PI/2;r.height<0&&(s-=Math.PI);const o=a.Konva.getAngle(this.rotation())+s,h=a.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let r=e;for(let n=0;n<t.length;n++){const s=a.Konva.getAngle(t[n]),o=Math.abs(s-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<i&&(r=s)}return r}(this.rotationSnaps(),o,h),d=b(r,l-r.rotation);return void this._fitNodesInto(d,t)}const c=this.shiftBehavior();let u;u="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var f=g?{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(f.x-n.x(),2)+Math.pow(f.y-n.y(),2));var p=this.findOne(".top-left").x()>f.x?-1:1,_=this.findOne(".top-left").y()>f.y?-1:1;e=r*this.cos*p,i=r*this.sin*_,this.findOne(".top-left").x(f.x-e),this.findOne(".top-left").y(f.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(n.y());else if("top-right"===this._movingAnchorName){if(u){f=g?{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()-f.x,2)+Math.pow(f.y-n.y(),2));p=this.findOne(".top-right").x()<f.x?-1:1,_=this.findOne(".top-right").y()>f.y?-1:1;e=r*this.cos*p,i=r*this.sin*_,this.findOne(".top-right").x(f.x+e),this.findOne(".top-right").y(f.y-i)}var m=n.position();this.findOne(".top-left").y(m.y),this.findOne(".bottom-right").x(m.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(u){f=g?{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(f.x-n.x(),2)+Math.pow(n.y()-f.y,2));p=f.x<n.x()?-1:1,_=n.y()<f.y?-1:1;e=r*this.cos*p,i=r*this.sin*_,n.x(f.x-e),n.y(f.y+i)}m=n.position(),this.findOne(".top-left").x(m.x),this.findOne(".bottom-right").y(m.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(n.y());else if("bottom-right"===this._movingAnchorName){if(u){f=g?{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()-f.x,2)+Math.pow(n.y()-f.y,2));p=this.findOne(".bottom-right").x()<f.x?-1:1,_=this.findOne(".bottom-right").y()<f.y?-1:1;e=r*this.cos*p,i=r*this.sin*_,this.findOne(".bottom-right").x(f.x+e),this.findOne(".bottom-right").y(f.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),r=t.y(),n=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-i,y:-r}),t.move({x:n,y:s})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,i=y.y;const v=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),x=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:v,height:x,rotation:a.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();S--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,i){const r=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const n=new t.Transform;if(n.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=n.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=n.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(r,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,o=new t.Transform;o.translate(r.x,r.y),o.rotate(r.rotation),o.scale(r.width/s,r.height/s);const h=new t.Transform,l=e.width/s,d=e.height/s;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,d));const c=h.multiply(o.invert());this._nodes.forEach((e=>{var i;const r=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());const s=new t.Transform;s.multiply(r.copy().invert()).multiply(c).multiply(r).multiply(n);const a=s.decompose();e.setAttrs(a),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const r=i.width,n=i.height,s=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach((t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+o,offsetY:h/2+o,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:h/2+o,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:h/2-o,offsetY:h/2+o,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:h/2+o,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:n/2,offsetX:h/2-o,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:h/2+o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:n,offsetY:h/2-o,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:n,offsetX:h/2-o,offsetY:h/2-o,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*t.Util._sign(n)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const d=this.anchorStyleFunc();d&&l.forEach((t=>{d(t)})),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),s.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return Ut.Transformer=w,w.isTransforming=()=>S>0,w.prototype.className="Transformer",(0,l._registerNode)(w),e.Factory.addGetterSetter(w,"enabledAnchors",v,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===v.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+v.join(", "))})),e||[]})),e.Factory.addGetterSetter(w,"flipEnabled",!0,(0,o.getBooleanValidator)()),e.Factory.addGetterSetter(w,"resizeEnabled",!0),e.Factory.addGetterSetter(w,"anchorSize",10,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateEnabled",!0),e.Factory.addGetterSetter(w,"rotateLineVisible",!0),e.Factory.addGetterSetter(w,"rotationSnaps",[]),e.Factory.addGetterSetter(w,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(w,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderEnabled",!0),e.Factory.addGetterSetter(w,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"anchorFill","white"),e.Factory.addGetterSetter(w,"anchorCornerRadius",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"borderStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderDash"),e.Factory.addGetterSetter(w,"keepRatio",!0),e.Factory.addGetterSetter(w,"shiftBehavior","default"),e.Factory.addGetterSetter(w,"centeredScaling",!1),e.Factory.addGetterSetter(w,"ignoreStroke",!1),e.Factory.addGetterSetter(w,"padding",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(w,"node"),e.Factory.addGetterSetter(w,"nodes"),e.Factory.addGetterSetter(w,"boundBoxFunc"),e.Factory.addGetterSetter(w,"anchorDragBoundFunc"),e.Factory.addGetterSetter(w,"anchorStyleFunc"),e.Factory.addGetterSetter(w,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(w,"useSingleNodeRotation",!0),e.Factory.backCompat(w,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),Ut}var Wt,zt={};var Ht,Vt={};function jt(){if(Ht)return Vt;Ht=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Blur=void 0;const t=y(),e=M(),i=m();function r(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const n=[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],s=[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];return Vt.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,a=t.width,o=t.height;let h,l,d,c,u,g,f,p,_,m,y,v,x,b,S,w,C,k,P,T,A,M,F,R,I=e+e+1,E=a-1,O=o-1,D=e+1,G=D*(D+1)/2,L=new r,N=null,U=L,B=null,W=null,z=n[e],H=s[e];for(d=1;d<I;d++)U=U.next=new r,d===D&&(N=U);for(U.next=L,f=g=0,l=0;l<o;l++){for(w=C=k=P=p=_=m=y=0,v=D*(T=i[g]),x=D*(A=i[g+1]),b=D*(M=i[g+2]),S=D*(F=i[g+3]),p+=G*T,_+=G*A,m+=G*M,y+=G*F,U=L,d=0;d<D;d++)U.r=T,U.g=A,U.b=M,U.a=F,U=U.next;for(d=1;d<D;d++)c=g+((E<d?E:d)<<2),p+=(U.r=T=i[c])*(R=D-d),_+=(U.g=A=i[c+1])*R,m+=(U.b=M=i[c+2])*R,y+=(U.a=F=i[c+3])*R,w+=T,C+=A,k+=M,P+=F,U=U.next;for(B=L,W=N,h=0;h<a;h++)i[g+3]=F=y*z>>H,0!==F?(F=255/F,i[g]=(p*z>>H)*F,i[g+1]=(_*z>>H)*F,i[g+2]=(m*z>>H)*F):i[g]=i[g+1]=i[g+2]=0,p-=v,_-=x,m-=b,y-=S,v-=B.r,x-=B.g,b-=B.b,S-=B.a,c=f+((c=h+e+1)<E?c:E)<<2,w+=B.r=i[c],C+=B.g=i[c+1],k+=B.b=i[c+2],P+=B.a=i[c+3],p+=w,_+=C,m+=k,y+=P,B=B.next,v+=T=W.r,x+=A=W.g,b+=M=W.b,S+=F=W.a,w-=T,C-=A,k-=M,P-=F,W=W.next,g+=4;f+=a}for(h=0;h<a;h++){for(C=k=P=w=_=m=y=p=0,g=h<<2,v=D*(T=i[g]),x=D*(A=i[g+1]),b=D*(M=i[g+2]),S=D*(F=i[g+3]),p+=G*T,_+=G*A,m+=G*M,y+=G*F,U=L,d=0;d<D;d++)U.r=T,U.g=A,U.b=M,U.a=F,U=U.next;for(u=a,d=1;d<=e;d++)g=u+h<<2,p+=(U.r=T=i[g])*(R=D-d),_+=(U.g=A=i[g+1])*R,m+=(U.b=M=i[g+2])*R,y+=(U.a=F=i[g+3])*R,w+=T,C+=A,k+=M,P+=F,U=U.next,d<O&&(u+=a);for(g=h,B=L,W=N,l=0;l<o;l++)c=g<<2,i[c+3]=F=y*z>>H,F>0?(F=255/F,i[c]=(p*z>>H)*F,i[c+1]=(_*z>>H)*F,i[c+2]=(m*z>>H)*F):i[c]=i[c+1]=i[c+2]=0,p-=v,_-=x,m-=b,y-=S,v-=B.r,x-=B.g,b-=B.b,S-=B.a,c=h+((c=l+D)<O?c:O)*a<<2,p+=w+=B.r=i[c],_+=C+=B.g=i[c+1],m+=k+=B.b=i[c+2],y+=P+=B.a=i[c+3],B=B.next,v+=T=W.r,x+=A=W.g,b+=M=W.b,S+=F=W.a,w-=T,C-=A,k-=M,P-=F,W=W.next,g+=a}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Vt}var Kt,Xt={};var Yt,qt={};var Qt,Jt={};var Zt,$t={};var te,ee={};var ie,re={};var ne,se={};var ae,oe={};var he,le={};function de(){if(he)return le;he=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Kaleidoscope=void 0;const t=y(),e=M(),i=c(),r=m();return le.Kaleidoscope=function(t){const e=t.width,r=t.height;let n,s,a,o,h,l,d,c,u,g,f=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),_=Math.floor(e*(p%360)/360);if(f<1)return;const m=i.Util.createCanvasElement();m.width=e,m.height=r;const y=m.getContext("2d").getImageData(0,0,e,r);i.Util.releaseCanvas(m),function(t,e,i){let r,n,s,a,o=t.data,h=e.data,l=t.width,d=t.height,c=i.polarCenterX||l/2,u=i.polarCenterY||d/2,g=0,f=0,p=0,_=0,m=Math.sqrt(c*c+u*u);n=l-c,s=d-u,a=Math.sqrt(n*n+s*s),m=a>m?a:m;let y,v,x,b,S=d,w=l,C=360/w*Math.PI/180;for(v=0;v<w;v+=1)for(x=Math.sin(v*C),b=Math.cos(v*C),y=0;y<S;y+=1)n=Math.floor(c+m*y/S*b),s=Math.floor(u+m*y/S*x),r=4*(s*l+n),g=o[r+0],f=o[r+1],p=o[r+2],_=o[r+3],r=4*(v+y*l),h[r+0]=g,h[r+1]=f,h[r+2]=p,h[r+3]=_}(t,y,{polarCenterX:e/2,polarCenterY:r/2});let v=e/Math.pow(2,f);for(;v<=8;)v*=2,f-=1;v=Math.ceil(v);let x=v,b=0,S=x,w=1;for(_+v>e&&(b=x,S=0,w=-1),s=0;s<r;s+=1)for(n=b;n!==S;n+=w)a=Math.round(n+_)%e,u=4*(e*s+a),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*s+n),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;for(s=0;s<r;s+=1)for(x=Math.floor(v),o=0;o<f;o+=1){for(n=0;n<x+1;n+=1)u=4*(e*s+n),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*s+2*x-n-1),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;x*=2}!function(t,e,i){let r,n,s,a,o,h,l=t.data,d=e.data,c=t.width,u=t.height,g=i.polarCenterX||c/2,f=i.polarCenterY||u/2,p=0,_=0,m=0,y=0,v=Math.sqrt(g*g+f*f);n=c-g,s=u-f,h=Math.sqrt(n*n+s*s),v=h>v?h:v;let x,b,S,w,C=u,k=c;for(n=0;n<c;n+=1)for(s=0;s<u;s+=1)a=n-g,o=s-f,x=Math.sqrt(a*a+o*o)*C/v,b=(180*Math.atan2(o,a)/Math.PI+360+0)%360,b=b*k/360,S=Math.floor(b),w=Math.floor(x),r=4*(w*c+S),p=l[r+0],_=l[r+1],m=l[r+2],y=l[r+3],r=4*(s*c+n),d[r+0]=p,d[r+1]=_,d[r+2]=m,d[r+3]=y}(y,t,{polarRotation:0})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),le}var ce,ue={};function ge(){if(ce)return ue;ce=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Mask=void 0;const t=y(),e=M(),i=m();function r(t,e,i){let r=4*(i*t.width+e);const n=[];return n.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),n}function n(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}return ue.Mask=function(t){let e=function(t,e){const i=r(t,0,0),s=r(t,t.width-1,0),a=r(t,0,t.height-1),o=r(t,t.width-1,t.height-1),h=e||10;if(n(i,s)<h&&n(s,o)<h&&n(o,a)<h&&n(a,i)<h){const e=function(t){const e=[0,0,0];for(let 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}([s,i,o,a]),r=[];for(let i=0;i<t.width*t.height;i++){const s=n(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);r[i]=s<h?0:255}return r}}(t,this.threshold());return e&&(e=function(t,e,i){const r=[1,1,1,1,0,1,1,1,1],n=Math.round(Math.sqrt(r.length)),s=Math.floor(n/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<n;a++)for(let l=0;l<n;l++){const c=o+a-s,u=h+l-s;if(c>=0&&c<i&&u>=0&&u<e){const i=r[a*n+l];d+=t[c*e+u]*i}}a[l]=2040===d?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const r=[1,1,1,1,1,1,1,1,1],n=Math.round(Math.sqrt(r.length)),s=Math.floor(n/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<n;a++)for(let l=0;l<n;l++){const c=o+a-s,u=h+l-s;if(c>=0&&c<i&&u>=0&&u<e){const i=r[a*n+l];d+=t[c*e+u]*i}}a[l]=d>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const 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)),s=Math.floor(n/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<n;a++)for(let l=0;l<n;l++){const c=o+a-s,u=h+l-s;if(c>=0&&c<i&&u>=0&&u<e){const i=r[a*n+l];d+=t[c*e+u]*i}}a[l]=d}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ue}var fe,pe={};var _e,me={};var ye,ve={};var xe,be={};var Se,we={};var Ce,ke={};var Pe,Te={};var Ae,Me,Fe={};function Re(){if(Me)return s;Me=1,Object.defineProperty(s,"__esModule",{value:!0}),s.Konva=void 0;const t=et(),e=function(){if(it)return rt;it=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.Arc=void 0;const t=y(),e=z(),i=h(),r=m(),n=h();let s=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),r=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,r),t.arc(0,0,this.innerRadius(),e,0,!r),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),r=this.clockwise(),n=i.Konva.getAngle(r?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),o=Math.sin(Math.min(n,Math.PI/2)),h=s*(s>0?t:e),l=a*(a>0?t:e),d=o*(o>0?e:t);return{x:h,y:r?-1*d:l,width:1*e-h,height:d-l}}};return rt.Arc=s,s.prototype._centroid=!0,s.prototype.className="Arc",s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1,(0,r.getBooleanValidator)()),rt}(),i=function(){if(dt)return st;dt=1,Object.defineProperty(st,"__esModule",{value:!0}),st.Arrow=void 0;const t=y(),e=ot(),i=m(),r=h(),n=gt();let s=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let r=i;const s=0!==this.tension()&&i.length>4;s&&(r=this.getTensionPoints());const a=this.pointerLength(),o=i.length;let h,l;if(s){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[o-2],i[o-1]],e=n.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),s=n.Path.getPointOnQuadraticBezier(Math.min(1,1-a/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[o-2]-s.x,l=i[o-1]-s.y}else h=i[o-2]-i[o-4],l=i[o-1]-i[o-3];const d=(Math.atan2(l,h)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[o-2],i[o-1]),t.rotate(d),t.moveTo(0,0),t.lineTo(-a,c/2),t.lineTo(-a,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(h=(r[0]+r[2])/2-i[0],l=(r[1]+r[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-a,c/2),t.lineTo(-a,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}};return st.Arrow=s,s.prototype.className="Arrow",(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerAtBeginning",!1),t.Factory.addGetterSetter(s,"pointerAtEnding",!0),st}(),r=function(){if(ft)return pt;ft=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.Circle=void 0;const t=y(),e=z(),i=m(),r=h();let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}};return pt.Circle=n,n.prototype._centroid=!0,n.prototype.className="Circle",n.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,i.getNumberValidator)()),pt}(),n=function(){if(_t)return mt;_t=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.Ellipse=void 0;const t=y(),e=z(),i=m(),r=h();let n=class extends e.Shape{_sceneFunc(t){const 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)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}};return mt.Ellipse=n,n.prototype.className="Ellipse",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,r._registerNode)(n),t.Factory.addComponentsGetterSetter(n,"radius",["x","y"]),t.Factory.addGetterSetter(n,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"radiusY",0,(0,i.getNumberValidator)()),mt}(),a=function(){if(yt)return vt;yt=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.Image=void 0;const t=c(),e=y(),i=z(),r=h(),n=m();class s extends i.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const i=this.getWidth(),r=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;a=t&&e?[s,this.cropX(),this.cropY(),t,e,0,0,i,r]:[s,0,0,i,r]}(this.hasFill()||this.hasStroke()||n)&&(e.beginPath(),n?t.Util.drawRoundedRectPath(e,i,r,n):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)),s&&(n&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){const i=this.width(),r=this.height(),n=this.cornerRadius();e.beginPath(),n?t.Util.drawRoundedRectPath(e,i,r,n):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,r=null){const n=t.Util.createImageElement();n.onload=function(){const t=new s({image:n});i(t)},n.onerror=r,n.crossOrigin="Anonymous",n.src=e}}return vt.Image=s,s.prototype.className="Image",(0,r._registerNode)(s),e.Factory.addGetterSetter(s,"cornerRadius",0,(0,n.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(s,"image"),e.Factory.addComponentsGetterSetter(s,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(s,"cropX",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropY",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropWidth",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropHeight",0,(0,n.getNumberValidator)()),vt}(),o=function(){if(xt)return bt;xt=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.Tag=bt.Label=void 0;const t=y(),e=z(),i=Y(),r=m(),n=h(),s=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="up",o="right",l="down",d="left",c=s.length;let u=class extends i.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const r=function(){i._sync()};for(e=0;e<c;e++)t.on(s[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,r,n,s,h,c=this.getText(),u=this.getTag();if(c&&u){switch(t=c.width(),e=c.height(),i=u.pointerDirection(),r=u.pointerWidth(),h=u.pointerHeight(),n=0,s=0,i){case a:n=t/2,s=-1*h;break;case o:n=t+r,s=e/2;break;case l:n=t/2,s=e+h;break;case d:n=-1*r,s=e/2}u.setAttrs({x:-1*n,y:-1*s,width:t,height:e}),c.setAttrs({x:-1*n,y:-1*s})}}};bt.Label=u,u.prototype.className="Label",(0,n._registerNode)(u);class g extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),r=this.pointerDirection(),n=this.pointerWidth(),s=this.pointerHeight(),h=this.cornerRadius();let c=0,u=0,g=0,f=0;"number"==typeof h?c=u=g=f=Math.min(h,e/2,i/2):(c=Math.min(h[0]||0,e/2,i/2),u=Math.min(h[1]||0,e/2,i/2),f=Math.min(h[2]||0,e/2,i/2),g=Math.min(h[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(c,0),r===a&&(t.lineTo((e-n)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+n)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),r===o&&(t.lineTo(e,(i-s)/2),t.lineTo(e+n,i/2),t.lineTo(e,(i+s)/2)),t.lineTo(e,i-f),t.arc(e-f,i-f,f,0,Math.PI/2,!1),r===l&&(t.lineTo((e+n)/2,i),t.lineTo(e/2,i+s),t.lineTo((e-n)/2,i)),t.lineTo(g,i),t.arc(g,i-g,g,Math.PI/2,Math.PI,!1),r===d&&(t.lineTo(0,(i+s)/2),t.lineTo(-1*n,i/2),t.lineTo(0,(i-s)/2)),t.lineTo(0,c),t.arc(c,c,c,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),n=this.pointerDirection(),s=this.width(),h=this.height();return n===a?(e-=r,h+=r):n===l?h+=r:n===d?(t-=1.5*i,s+=i):n===o&&(s+=1.5*i),{x:t,y:e,width:s,height:h}}}return bt.Tag=g,g.prototype.className="Tag",(0,n._registerNode)(g),t.Factory.addGetterSetter(g,"pointerDirection","none"),t.Factory.addGetterSetter(g,"pointerWidth",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"pointerHeight",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),bt}(),l=ot(),d=gt(),u=Ct(),g=function(){if(kt)return Pt;kt=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.RegularPolygon=void 0;const t=y(),e=z(),i=m(),r=h();let n=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,r=t[0].x,n=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.y)})),{x:e,y:r,width:i-e,height:n-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Pt.RegularPolygon=n,n.prototype.className="RegularPolygon",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"sides",0,(0,i.getNumberValidator)()),Pt}(),f=function(){if(Tt)return At;Tt=1,Object.defineProperty(At,"__esModule",{value:!0}),At.Ring=void 0;const t=y(),e=z(),i=m(),r=h(),n=2*Math.PI;let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,n,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),n,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return At.Ring=s,s.prototype.className="Ring",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),At}(),p=function(){if(Mt)return Ft;Mt=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.Sprite=void 0;const t=y(),e=z(),i=J(),r=m(),n=h();let s=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),r=4*i,n=this.animations()[e],s=this.frameOffsets(),a=n[r+0],o=n[r+1],h=n[r+2],l=n[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(s){const r=s[e],n=2*i;t.drawImage(d,a,o,h,l,r[n+0],r[n+1],h,l)}else t.drawImage(d,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),r=4*i,n=this.animations()[e],s=this.frameOffsets(),a=n[r+2],o=n[r+3];if(t.beginPath(),s){const r=s[e],n=2*i;t.rect(r[n+0],r[n+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}};return Ft.Sprite=s,s.prototype.className="Sprite",(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"animation"),t.Factory.addGetterSetter(s,"animations"),t.Factory.addGetterSetter(s,"frameOffsets"),t.Factory.addGetterSetter(s,"image"),t.Factory.addGetterSetter(s,"frameIndex",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"frameRate",17,(0,r.getNumberValidator)()),t.Factory.backCompat(s,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Ft}(),_=function(){if(Rt)return It;Rt=1,Object.defineProperty(It,"__esModule",{value:!0}),It.Star=void 0;const t=y(),e=z(),i=m(),r=h();let n=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let n=1;n<2*r;n++){const s=n%2==0?i:e,a=s*Math.sin(n*Math.PI/r),o=-1*s*Math.cos(n*Math.PI/r);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}};return It.Star=n,n.prototype.className="Star",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,i.getNumberValidator)()),It}(),v=Dt(),x=function(){if(Gt)return Lt;Gt=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.TextPath=void 0;const t=c(),e=y(),i=z(),r=gt(),n=Dt(),s=m(),a=h(),o="normal";function l(t){t.fillText(this.partialText,0,0)}function d(t){t.strokeText(this.partialText,0,0)}let u=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return r.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:r.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=r.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),r=this.fontSize(),n=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<n.length;i++){t.save();const s=n[i].p0;t.translate(s.x,s.y),t.rotate(n[i].rotation),this.partialText=n[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&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()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const r=e[i].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return n.Text.prototype.setText.call(this,t)}_getContextFont(){return n.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===s&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(h=Math.max(0,this.pathLength-o));const l=(0,n.stringToArray)(this.text());let d=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(d);if(!e)return;let n=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===s){const t=this.text().split(" ").length-1;n+=(this.pathLength-o)/t}const h=this._getPointAtLength(d+n);if(!h)return;const c=r.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(a)try{u=a(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const g=r.Path.getPointOnLine(u+c/2,e.x,e.y,h.x,h.y),f=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:l[t],rotation:f,p0:e,p1:h}),d+=n}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const 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)}));let e,i,r=t[0]||0,n=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),n=Math.max(n,e),s=Math.min(s,i),a=Math.max(a,i);const o=this.fontSize();return{x:r-o/2,y:s-o/2,width:n-r+o,height:a-s+o}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Lt.TextPath=u,u.prototype._fillFunc=l,u.prototype._strokeFunc=d,u.prototype._fillFuncHit=l,u.prototype._strokeFuncHit=d,u.prototype.className="TextPath",u.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(u),e.Factory.addGetterSetter(u,"data"),e.Factory.addGetterSetter(u,"fontFamily","Arial"),e.Factory.addGetterSetter(u,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(u,"fontStyle",o),e.Factory.addGetterSetter(u,"align","left"),e.Factory.addGetterSetter(u,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(u,"textBaseline","middle"),e.Factory.addGetterSetter(u,"fontVariant",o),e.Factory.addGetterSetter(u,"text",""),e.Factory.addGetterSetter(u,"textDecoration",null),e.Factory.addGetterSetter(u,"kerningFunc",null),Lt}(),b=Bt(),S=function(){if(Wt)return zt;Wt=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.Wedge=void 0;const t=y(),e=z(),i=h(),r=m(),n=h();let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return zt.Wedge=s,s.prototype.className="Wedge",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1),t.Factory.backCompat(s,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),zt}(),w=jt(),C=function(){if(Kt)return Xt;Kt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Brighten=void 0;const t=y(),e=M(),i=m();return Xt.Brighten=function(t){let 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},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Xt}(),k=function(){if(Yt)return qt;Yt=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.Contrast=void 0;const t=y(),e=M(),i=m();return qt.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2);let i,r=t.data,n=r.length,s=150,a=150,o=150;for(i=0;i<n;i+=4)s=r[i],a=r[i+1],o=r[i+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,r[i]=s,r[i+1]=a,r[i+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),qt}(),P=function(){if(Qt)return Jt;Qt=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Emboss=void 0;const t=y(),e=M(),i=c(),r=m();return Jt.Emboss=function(t){let e=10*this.embossStrength(),r=255*this.embossWhiteLevel(),n=this.embossDirection(),s=this.embossBlend(),a=0,o=0,h=t.data,l=t.width,d=t.height,c=4*l,u=d;switch(n){case"top-left":a=-1,o=-1;break;case"top":a=-1,o=0;break;case"top-right":a=-1,o=1;break;case"right":a=0,o=1;break;case"bottom-right":a=1,o=1;break;case"bottom":a=1,o=0;break;case"bottom-left":a=1,o=-1;break;case"left":a=0,o=-1;break;default:i.Util.error("Unknown emboss direction: "+n)}do{const t=(u-1)*c;let i=a;u+i<1&&(i=0),u+i>d&&(i=0);const n=(u-1+i)*l*4;let g=l;do{const i=t+4*(g-1);let a=o;g+a<1&&(a=0),g+a>l&&(a=0);const d=n+4*(g-1+a),c=h[i]-h[d],u=h[i+1]-h[d+1],f=h[i+2]-h[d+2];let p=c;const _=p>0?p:-p;if((u>0?u:-u)>_&&(p=u),(f>0?f:-f)>_&&(p=f),p*=e,s){const t=h[i]+p,e=h[i+1]+p,r=h[i+2]+p;h[i]=t>255?255:t<0?0:t,h[i+1]=e>255?255:e<0?0:e,h[i+2]=r>255?255:r<0?0:r}else{let t=r-p;t<0?t=0:t>255&&(t=255),h[i]=h[i+1]=h[i+2]=t}}while(--g)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",null,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,null,t.Factory.afterSetFilter),Jt}(),T=function(){if(Zt)return $t;Zt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.Enhance=void 0;const t=y(),e=M(),i=m();function r(t,e,i,r,n){let s,a=i-e,o=n-r;return 0===a?r+o/2:0===o?r:(s=(t-e)/a,s=o*s+r,s)}return $t.Enhance=function(t){let e,i,n,s,a=t.data,o=a.length,h=a[0],l=h,d=a[1],c=d,u=a[2],g=u;const f=this.enhance();if(0===f)return;for(s=0;s<o;s+=4)e=a[s+0],e<h?h=e:e>l&&(l=e),i=a[s+1],i<d?d=i:i>c&&(c=i),n=a[s+2],n<u?u=n:n>g&&(g=n);let p,_,m,y,v,x,b,S,w;for(l===h&&(l=255,h=0),c===d&&(c=255,d=0),g===u&&(g=255,u=0),f>0?(_=l+f*(255-l),m=h-f*(h-0),v=c+f*(255-c),x=d-f*(d-0),S=g+f*(255-g),w=u-f*(u-0)):(p=.5*(l+h),_=l+f*(l-p),m=h+f*(h-p),y=.5*(c+d),v=c+f*(c-y),x=d+f*(d-y),b=.5*(g+u),S=g+f*(g-b),w=u+f*(u-b)),s=0;s<o;s+=4)a[s+0]=r(a[s+0],h,l,m,_),a[s+1]=r(a[s+1],d,c,x,v),a[s+2]=r(a[s+2],u,g,w,S)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),$t}(),A=(te||(te=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Grayscale=void 0,ee.Grayscale=function(t){let 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}),ee),F=function(){if(ie)return re;ie=1,Object.defineProperty(re,"__esModule",{value:!0}),re.HSL=void 0;const t=y(),e=M(),i=m();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),re.HSL=function(t){let e,i=t.data,r=i.length,n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=127*this.luminance();const o=1*n*Math.cos(s*Math.PI/180),h=1*n*Math.sin(s*Math.PI/180),l=.299+.701*o+.167*h,d=.587-.587*o+.33*h,c=.114-.114*o-.497*h,u=.299-.299*o-.328*h,g=.587+.413*o+.035*h,f=.114-.114*o+.293*h,p=.299-.3*o+1.25*h,_=.587-.586*o-1.05*h,m=.114+.886*o-.2*h;let y,v,x,b;for(e=0;e<r;e+=4)y=i[e+0],v=i[e+1],x=i[e+2],b=i[e+3],i[e+0]=l*y+d*v+c*x+a,i[e+1]=u*y+g*v+f*x+a,i[e+2]=p*y+_*v+m*x+a,i[e+3]=b},re}(),R=function(){if(ne)return se;ne=1,Object.defineProperty(se,"__esModule",{value:!0}),se.HSV=void 0;const t=y(),e=M(),i=m();return se.HSV=function(t){const e=t.data,i=e.length,r=Math.pow(2,this.value()),n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=r*n*Math.cos(s*Math.PI/180),o=r*n*Math.sin(s*Math.PI/180),h=.299*r+.701*a+.167*o,l=.587*r-.587*a+.33*o,d=.114*r-.114*a-.497*o,c=.299*r-.299*a-.328*o,u=.587*r+.413*a+.035*o,g=.114*r-.114*a+.293*o,f=.299*r-.3*a+1.25*o,p=.587*r-.586*a-1.05*o,_=.114*r+.886*a-.2*o;let m,y,v,x;for(let t=0;t<i;t+=4)m=e[t+0],y=e[t+1],v=e[t+2],x=e[t+3],e[t+0]=h*m+l*y+d*v,e[t+1]=c*m+u*y+g*v,e[t+2]=f*m+p*y+_*v,e[t+3]=x},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),se}(),I=(ae||(ae=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.Invert=void 0,oe.Invert=function(t){let 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]}),oe),E=de(),O=ge(),D=function(){if(fe)return pe;fe=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.Noise=void 0;const t=y(),e=M(),i=m();return pe.Noise=function(t){const e=255*this.noise(),i=t.data,r=i.length,n=e/2;for(let t=0;t<r;t+=4)i[t+0]+=n-2*n*Math.random(),i[t+1]+=n-2*n*Math.random(),i[t+2]+=n-2*n*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),pe}(),G=function(){if(_e)return me;_e=1,Object.defineProperty(me,"__esModule",{value:!0}),me.Pixelate=void 0;const t=y(),e=c(),i=M(),r=m();return me.Pixelate=function(t){let i,r,n,s,a,o,h,l,d,c,u,g,f,p,_=Math.ceil(this.pixelSize()),m=t.width,y=t.height,v=Math.ceil(m/_),x=Math.ceil(y/_),b=t.data;if(_<=0)e.Util.error("pixelSize value can not be <= 0");else for(g=0;g<v;g+=1)for(f=0;f<x;f+=1){for(s=0,a=0,o=0,h=0,l=g*_,d=l+_,c=f*_,u=c+_,p=0,i=l;i<d;i+=1)if(!(i>=m))for(r=c;r<u;r+=1)r>=y||(n=4*(m*r+i),s+=b[n+0],a+=b[n+1],o+=b[n+2],h+=b[n+3],p+=1);for(s/=p,a/=p,o/=p,h/=p,i=l;i<d;i+=1)if(!(i>=m))for(r=c;r<u;r+=1)r>=y||(n=4*(m*r+i),b[n+0]=s,b[n+1]=a,b[n+2]=o,b[n+3]=h)}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),me}(),L=function(){if(ye)return ve;ye=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.Posterize=void 0;const t=y(),e=M(),i=m();return ve.Posterize=function(t){let e,i=Math.round(254*this.levels())+1,r=t.data,n=r.length,s=255/i;for(e=0;e<n;e+=1)r[e]=Math.floor(r[e]/s)*s},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ve}(),N=function(){if(xe)return be;xe=1,Object.defineProperty(be,"__esModule",{value:!0}),be.RGB=void 0;const t=y(),e=M(),i=m();return be.RGB=function(t){let e,i,r=t.data,n=r.length,s=this.red(),a=this.green(),o=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*s,r[e+1]=i*a,r[e+2]=i*o,r[e+3]=r[e+3]},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),be}(),U=function(){if(Se)return we;Se=1,Object.defineProperty(we,"__esModule",{value:!0}),we.RGBA=void 0;const t=y(),e=M(),i=m();return we.RGBA=function(t){const e=t.data,i=e.length,r=this.red(),n=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=r*a+e[t]*i,e[t+1]=n*a+e[t+1]*i,e[t+2]=s*a+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),we}(),B=(Ce||(Ce=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.Sepia=void 0,ke.Sepia=function(t){let e,i,r,n,s=t.data,a=s.length;for(e=0;e<a;e+=4)i=s[e+0],r=s[e+1],n=s[e+2],s[e+0]=Math.min(255,.393*i+.769*r+.189*n),s[e+1]=Math.min(255,.349*i+.686*r+.168*n),s[e+2]=Math.min(255,.272*i+.534*r+.131*n)}),ke),W=(Pe||(Pe=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Solarize=void 0,Te.Solarize=function(t){const e=t.data,i=t.width,r=4*i;let n=t.height;do{const t=(n-1)*r;let s=i;do{const i=t+4*(s-1);let r=e[i],n=e[i+1],a=e[i+2];r>127&&(r=255-r),n>127&&(n=255-n),a>127&&(a=255-a),e[i]=r,e[i+1]=n,e[i+2]=a}while(--s)}while(--n)}),Te),H=function(){if(Ae)return Fe;Ae=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.Threshold=void 0;const t=y(),e=M(),i=m();return Fe.Threshold=function(t){const e=255*this.threshold(),i=t.data,r=i.length;for(let t=0;t<r;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Fe}();return s.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:r.Circle,Ellipse:n.Ellipse,Image:a.Image,Label:o.Label,Tag:o.Tag,Line:l.Line,Path:d.Path,Rect:u.Rect,RegularPolygon:g.RegularPolygon,Ring:f.Ring,Sprite:p.Sprite,Star:_.Star,Text:v.Text,TextPath:x.TextPath,Transformer:b.Transformer,Wedge:S.Wedge,Filters:{Blur:w.Blur,Brighten:C.Brighten,Contrast:k.Contrast,Emboss:P.Emboss,Enhance:T.Enhance,Grayscale:A.Grayscale,HSL:F.HSL,HSV:R.HSV,Invert:I.Invert,Kaleidoscope:E.Kaleidoscope,Mask:O.Mask,Noise:D.Noise,Pixelate:G.Pixelate,Posterize:L.Posterize,RGB:N.RGB,RGBA:U.RGBA,Sepia:B.Sepia,Solarize:W.Solarize,Threshold:H.Threshold}}),s}var Ie,Ee=n.exports;var Oe=i(function(){if(Ie)return n.exports;Ie=1,Object.defineProperty(Ee,"__esModule",{value:!0});const t=Re();return n.exports=t.Konva,n.exports}());class De{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class Ge{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Le=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Ne{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const n=[];t.points.forEach((t=>n.push(t.x,t.y))),this._ref=new Oe.Line({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:n,draggable:!0,strokeScaleEnabled:!1,dash:Le.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Le.get("dot"):t="dot";break;case Le.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Le.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class Ue{constructor(t,e=null){var i,r,n;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Oe.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(i=t.fontSize)&&void 0!==i?i:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(n=t.rotation)&&void 0!==n?n:0}),this._ref.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let n=this._ref.width();i&&(n*=e.scaleX);let s=this._ref.height();r&&(s*=e.scaleY);n<50&&(n=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),i&&this._ref.width(n),r&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class Be{constructor(t,e=null){var i,r,n,s;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Oe.Rect({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(s=t.height)&&void 0!==s?s:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let n=this._ref.width();i&&(n*=e.scaleX);let s=this._ref.height();r&&(s*=e.scaleY);n<50&&(n=50),s<50&&(s=50),i&&this._ref.width(n),r&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}}class We{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Oe.Ellipse({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let n=this._ref.radiusX();i&&(n*=e.scaleX);let s=this._ref.radiusY();r&&(s*=e.scaleY);n<25&&(n=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:n,y:n}):this._ref.radius({x:s,y:s}):this._ref.radius({x:n,y:s}),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}}class ze{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Oe.Arrow({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y])}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e])}}class He{constructor(t,e=null){var i,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",e)return e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Oe.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(i=t.width)&&void 0!==i?i:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let n=this._ref.width();i&&(n*=e.scaleX);let s=this._ref.height();r&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(n),this._ref.height(n*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(i&&this._ref.width(n),r&&this._ref.height(s)),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}}class Ve{constructor(t,e=null){var i,r,n,s;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const a=16;this._ref=new Oe.Shape({x:t.position.x,y:t.position.y,width:null!==(i=t.width)&&void 0!==i?i:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],r=(n={x:0,y:0},s=this._ref.width(),o=this._ref.height(),{x:n.x+s/2,y:n.y+o/2});var n,s,o;t.beginPath();for(let e=0;e<i.length-1;e++){let n=30;const s=i[e+1].x-i[e].x,o=i[e+1].y-i[e].y,h=Math.sqrt(s*s+o*o),l=Math.floor(h/n);n=30+l/(h%n);let d=i[e].x+s/l/2,c=i[e].y+o/l/2;const u=i[e+1].x,g=i[e+1].y,f=Math.atan((g-c)/(u-d)),p=f+Math.PI,_=d>r.x&&c>r.y;for(let e=0;e<l;e++)_?t.arc(d,c,a,f,p):t.arc(d,c,a,p,f),d+=s/l,c+=o/l}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let n=this._ref.width();i&&(n*=e.scaleX);let s=this._ref.height();r&&(s*=e.scaleY);n<100&&(n=100),s<100&&(s=100),i&&this._ref.width(n),r&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const je={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Ne(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new Ue(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new Be(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new We(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new ze(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new He(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new Ve(e,t)}};t.Markup=class{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Ge(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i))},this.pan=t=>{const e={x:this._konvaStage.x()+t.dX,y:this._konvaStage.y()+t.dY};this._konvaStage.position(e)},this.zoomAt=t=>{const e=this._konvaStage.scaleX()*t.data;this._konvaStage.scale({x:e,y:e});const i={x:t.x-(t.x-this._konvaStage.x())*t.data,y:t.y-(t.y-this._konvaStage.y())*t.data};this._konvaStage.position(i)},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,r){if(!Oe)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new De,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";const n=this._container.parentElement;n.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(n),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this._viewer.emit({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){const r=new Ge(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}colorizeSelectedMarkups(t,e,i){const r=new Ge(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}setViewpoint(t){var e,i,r,n,s,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(r=t.texts)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(n=t.rectangles)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,t.radius,t.line_width,t.color,t.id)})),null===(a=t.arrows)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&je[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=je[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(je).forEach((e=>{const i=je[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(je).find((t=>t.name===e));return i?i.initializer(t):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=je[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Oe.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Oe.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Oe.Group,e.add(this._groupImages),this._groupGeometry=new Oe.Group,e.add(this._groupGeometry),this._groupTexts=new Oe.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Oe.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,n,s,a=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const s=this.getRelativePointerPosition(t);n=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(r=this.addLine([s.x,s.y,s.x,s.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=n&&e.x===n.x&&e.y===n.y,r=i?n.x:Math.min(n.x,e.x),s=i?n.y:Math.min(n.y,e.y),a=i?200:Math.abs(n.x-e.x),o=i?200:Math.abs(n.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:s},a,o):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:s},{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:n.x,y:n.y},{x:i?n.x+200:e.x,y:i?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:s},Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!a)return;const i=this.getRelativePointerPosition(t),o=n&&i.x===n.x&&i.y===n.y,h=o?n.x:Math.min(n.x,i.x),l=o?n.y:Math.min(n.y,i.y),d=o?200:Math.abs(n.x-i.x),c=o?200:Math.abs(n.y-i.y);"Line"===this._markupMode?r.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(i.x,i.y):s=this.addArrow({x:n.x,y:n.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?s?(s.setPosition(h,l),s.setWidth(d),s.setHeight(c)):s=this.addRectangle({x:h,y:l},d,c):"Ellipse"===this._markupMode?s?(s.setPosition(h,l),s.setRadiusX(d),s.setRadiusY(c)):s=this.addEllipse({x:h,y:l},{x:d,y:c}):"Cloud"===this._markupMode&&(s?(s.setPosition(h,l),s.setWidth(Math.max(100,d)),s.setHeight(Math.max(100,c))):s=this.addCloud({x:h,y:l},d,c))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,n=i.nodes().indexOf(e.target)>=0;if(r||n){if(r&&n){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!n){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.points();if(!i)return;const r=[],n=e.getAbsoluteTransform();for(let t=0;t<i.length;t+=2){const e=n.point({x:i[t],y:i[t+1]}),s=this._worldTransformer.screenToWorld(e);r.push(s)}const s=new Ne(null,e),a={id:s.id(),points:r,color:s.getColor()||"#ff0000",type:s.getLineType()||this.lineType,width:s.getLineWidth()||this.lineWidth};t.push(a)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),r=e.position(),n=this._konvaStage.getAbsoluteTransform(),s=n.point({x:r.x,y:r.y}),a=this._worldTransformer.screenToWorld(s),o=new Ue(null,e),h={id:o.id(),position:a,text:o.getText(),text_size:.02*i.y,angle:o.getRotation(),color:o.getColor(),font_size:o.getFontSize()*n.getMatrix()[0]};t.push(h)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),n=r.point({x:i.x,y:i.y}),s=this._worldTransformer.screenToWorld(n),a=r.getMatrix()[0],o=new Be(null,e),h={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),n=r.point({x:i.x,y:i.y}),s=this._worldTransformer.screenToWorld(n),a=r.getMatrix()[0],o=new We(null,e),h={id:o.id(),position:s,radius:{x:e.getRadiusX()*a,y:e.getRadiusY()*a},line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),n=this._worldTransformer.screenToWorld(r),s=i.point({x:e.points()[2],y:e.points()[3]}),a=this._worldTransformer.screenToWorld(s),o=new ze(null,e),h={id:o.id(),start:n,end:a,color:o.getColor()};t.push(h)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),n=r.point({x:i.x,y:i.y}),s=this._worldTransformer.screenToWorld(n),a=r.getMatrix()[0],o=new He(null,e),h={id:o.id(),position:s,src:o.getSrc(),width:o.getWidth()*a,height:o.getHeight()*a};t.push(h)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.position(),r=this._konvaStage.getAbsoluteTransform(),n=r.point({x:i.x,y:i.y}),s=this._worldTransformer.screenToWorld(n),a=r.getMatrix()[0],o=new Ve(null,e),h={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(h)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,n){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new Ne({points:s,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:n});return this.addObject(a),a}createTextInput(t,e,i,r,n){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},n&&(this._textInputRef.value=n),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},r.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,n,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(n&&n>h&&(!s||s<h)){const t=.02;s=n/(this._worldTransformer.getScale().y/t)/34}const l=new Ue({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:s||this.fontSize,color:r||this._markupColor.asHex(),id:a});return this.addObject(l),l}addRectangle(t,e,i,r,n,s){if(!t)return;const a=new Be({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:n||this._markupColor.asHex(),id:s});return this.addObject(a),a}addEllipse(t,e,i,r,n){if(!t)return;const s=new We({position:t,radius:e,lineWidth:i,color:r||this._markupColor.asHex(),id:n});return this.addObject(s),s}addArrow(t,e,i,r){if(!t||!e)return;const n=new ze({start:t,end:e,color:i||this._markupColor.asHex(),id:r});return this.addObject(n),n}addCloud(t,e,i,r,n,s){if(!t||!e||!i)return;const a=new Ve({position:t,width:e,height:i,color:n||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:s});return this.addObject(a),a}addImage(t,e,i,r,n){var s;if(!t||!e)return;null===(s=this.getSelectedObjects().at(0))||void 0===s||s.delete(),this.clearSelected(),this.removeImageInput();const a=new He({position:t,src:e,width:i,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:n});return this.addObject(a),a}}}));
|