g(x,c))a[d]=x,a[n]=c,d=n;else break a}}return b}\nfunction g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if(\"object\"===typeof performance&&\"function\"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,q=p.now();exports.unstable_now=function(){return p.now()-q}}var r=[],t=[],u=1,v=null,y=3,z=!1,A=!1,B=!1,D=\"function\"===typeof setTimeout?setTimeout:null,E=\"function\"===typeof clearTimeout?clearTimeout:null,F=\"undefined\"!==typeof setImmediate?setImmediate:null;\n\"undefined\"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(a){for(var b=h(t);null!==b;){if(null===b.callback)k(t);else if(b.startTime<=a)k(t),b.sortIndex=b.expirationTime,f(r,b);else break;b=h(t)}}function H(a){B=!1;G(a);if(!A)if(null!==h(r))A=!0,I(J);else{var b=h(t);null!==b&&K(H,b.startTime-a)}}\nfunction J(a,b){A=!1;B&&(B=!1,E(L),L=-1);z=!0;var c=y;try{G(b);for(v=h(r);null!==v&&(!(v.expirationTime>b)||a&&!M());){var d=v.callback;if(\"function\"===typeof d){v.callback=null;y=v.priorityLevel;var e=d(v.expirationTime<=b);b=exports.unstable_now();\"function\"===typeof e?v.callback=e:v===h(r)&&k(r);G(b)}else k(r);v=h(r)}if(null!==v)var w=!0;else{var m=h(t);null!==m&&K(H,m.startTime-b);w=!1}return w}finally{v=null,y=c,z=!1}}var N=!1,O=null,L=-1,P=5,Q=-1;\nfunction M(){return exports.unstable_now()-Qa||125d?(a.sortIndex=c,f(t,a),null===h(r)&&a===h(t)&&(B?(E(L),L=-1):B=!0,K(H,c-d))):(a.sortIndex=e,f(r,a),A||z||(A=!0,I(J)));return a};\nexports.unstable_shouldYield=M;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/scheduler.production.min.js');\n} else {\n module.exports = require('./cjs/scheduler.development.js');\n}\n","/**\n * @license React\n * react-dom.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n/*\n Modernizr 3.0.0pre (Custom Build) | MIT\n*/\n'use strict';var aa=require(\"react\"),ca=require(\"scheduler\");function p(a){for(var b=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+a,c=1;cb}return!1}function v(a,b,c,d,e,f,g){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=d;this.attributeNamespace=e;this.mustUseProperty=c;this.propertyName=a;this.type=b;this.sanitizeURL=f;this.removeEmptyString=g}var z={};\n\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(a){z[a]=new v(a,0,!1,a,null,!1,!1)});[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(a){var b=a[0];z[b]=new v(b,1,!1,a[1],null,!1,!1)});[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(a){z[a]=new v(a,2,!1,a.toLowerCase(),null,!1,!1)});\n[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(a){z[a]=new v(a,2,!1,a,null,!1,!1)});\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(a){z[a]=new v(a,3,!1,a.toLowerCase(),null,!1,!1)});\n[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(a){z[a]=new v(a,3,!0,a,null,!1,!1)});[\"capture\",\"download\"].forEach(function(a){z[a]=new v(a,4,!1,a,null,!1,!1)});[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(a){z[a]=new v(a,6,!1,a,null,!1,!1)});[\"rowSpan\",\"start\"].forEach(function(a){z[a]=new v(a,5,!1,a.toLowerCase(),null,!1,!1)});var ra=/[\\-:]([a-z])/g;function sa(a){return a[1].toUpperCase()}\n\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(a){var b=a.replace(ra,\nsa);z[b]=new v(b,1,!1,a,null,!1,!1)});\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,\"http://www.w3.org/1999/xlink\",!1,!1)});[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,\"http://www.w3.org/XML/1998/namespace\",!1,!1)});[\"tabIndex\",\"crossOrigin\"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!1,!1)});\nz.xlinkHref=new v(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0,!1);[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!0,!0)});\nfunction ta(a,b,c,d){var e=z.hasOwnProperty(b)?z[b]:null;if(null!==e?0!==e.type:d||!(2h||e[g]!==f[h]){var k=\"\\n\"+e[g].replace(\" at new \",\" at \");a.displayName&&k.includes(\"\")&&(k=k.replace(\"\",a.displayName));return k}while(1<=g&&0<=h)}break}}}finally{Na=!1,Error.prepareStackTrace=c}return(a=a?a.displayName||a.name:\"\")?Ma(a):\"\"}\nfunction Pa(a){switch(a.tag){case 5:return Ma(a.type);case 16:return Ma(\"Lazy\");case 13:return Ma(\"Suspense\");case 19:return Ma(\"SuspenseList\");case 0:case 2:case 15:return a=Oa(a.type,!1),a;case 11:return a=Oa(a.type.render,!1),a;case 1:return a=Oa(a.type,!0),a;default:return\"\"}}\nfunction Qa(a){if(null==a)return null;if(\"function\"===typeof a)return a.displayName||a.name||null;if(\"string\"===typeof a)return a;switch(a){case ya:return\"Fragment\";case wa:return\"Portal\";case Aa:return\"Profiler\";case za:return\"StrictMode\";case Ea:return\"Suspense\";case Fa:return\"SuspenseList\"}if(\"object\"===typeof a)switch(a.$$typeof){case Ca:return(a.displayName||\"Context\")+\".Consumer\";case Ba:return(a._context.displayName||\"Context\")+\".Provider\";case Da:var b=a.render;a=a.displayName;a||(a=b.displayName||\nb.name||\"\",a=\"\"!==a?\"ForwardRef(\"+a+\")\":\"ForwardRef\");return a;case Ga:return b=a.displayName||null,null!==b?b:Qa(a.type)||\"Memo\";case Ha:b=a._payload;a=a._init;try{return Qa(a(b))}catch(c){}}return null}\nfunction Ra(a){var b=a.type;switch(a.tag){case 24:return\"Cache\";case 9:return(b.displayName||\"Context\")+\".Consumer\";case 10:return(b._context.displayName||\"Context\")+\".Provider\";case 18:return\"DehydratedFragment\";case 11:return a=b.render,a=a.displayName||a.name||\"\",b.displayName||(\"\"!==a?\"ForwardRef(\"+a+\")\":\"ForwardRef\");case 7:return\"Fragment\";case 5:return b;case 4:return\"Portal\";case 3:return\"Root\";case 6:return\"Text\";case 16:return Qa(b);case 8:return b===za?\"StrictMode\":\"Mode\";case 22:return\"Offscreen\";\ncase 12:return\"Profiler\";case 21:return\"Scope\";case 13:return\"Suspense\";case 19:return\"SuspenseList\";case 25:return\"TracingMarker\";case 1:case 0:case 17:case 2:case 14:case 15:if(\"function\"===typeof b)return b.displayName||b.name||null;if(\"string\"===typeof b)return b}return null}function Sa(a){switch(typeof a){case \"boolean\":case \"number\":case \"string\":case \"undefined\":return a;case \"object\":return a;default:return\"\"}}\nfunction Ta(a){var b=a.type;return(a=a.nodeName)&&\"input\"===a.toLowerCase()&&(\"checkbox\"===b||\"radio\"===b)}\nfunction Ua(a){var b=Ta(a)?\"checked\":\"value\",c=Object.getOwnPropertyDescriptor(a.constructor.prototype,b),d=\"\"+a[b];if(!a.hasOwnProperty(b)&&\"undefined\"!==typeof c&&\"function\"===typeof c.get&&\"function\"===typeof c.set){var e=c.get,f=c.set;Object.defineProperty(a,b,{configurable:!0,get:function(){return e.call(this)},set:function(a){d=\"\"+a;f.call(this,a)}});Object.defineProperty(a,b,{enumerable:c.enumerable});return{getValue:function(){return d},setValue:function(a){d=\"\"+a},stopTracking:function(){a._valueTracker=\nnull;delete a[b]}}}}function Va(a){a._valueTracker||(a._valueTracker=Ua(a))}function Wa(a){if(!a)return!1;var b=a._valueTracker;if(!b)return!0;var c=b.getValue();var d=\"\";a&&(d=Ta(a)?a.checked?\"true\":\"false\":a.value);a=d;return a!==c?(b.setValue(a),!0):!1}function Xa(a){a=a||(\"undefined\"!==typeof document?document:void 0);if(\"undefined\"===typeof a)return null;try{return a.activeElement||a.body}catch(b){return a.body}}\nfunction Ya(a,b){var c=b.checked;return A({},b,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=c?c:a._wrapperState.initialChecked})}function Za(a,b){var c=null==b.defaultValue?\"\":b.defaultValue,d=null!=b.checked?b.checked:b.defaultChecked;c=Sa(null!=b.value?b.value:c);a._wrapperState={initialChecked:d,initialValue:c,controlled:\"checkbox\"===b.type||\"radio\"===b.type?null!=b.checked:null!=b.value}}function ab(a,b){b=b.checked;null!=b&&ta(a,\"checked\",b,!1)}\nfunction bb(a,b){ab(a,b);var c=Sa(b.value),d=b.type;if(null!=c)if(\"number\"===d){if(0===c&&\"\"===a.value||a.value!=c)a.value=\"\"+c}else a.value!==\"\"+c&&(a.value=\"\"+c);else if(\"submit\"===d||\"reset\"===d){a.removeAttribute(\"value\");return}b.hasOwnProperty(\"value\")?cb(a,b.type,c):b.hasOwnProperty(\"defaultValue\")&&cb(a,b.type,Sa(b.defaultValue));null==b.checked&&null!=b.defaultChecked&&(a.defaultChecked=!!b.defaultChecked)}\nfunction db(a,b,c){if(b.hasOwnProperty(\"value\")||b.hasOwnProperty(\"defaultValue\")){var d=b.type;if(!(\"submit\"!==d&&\"reset\"!==d||void 0!==b.value&&null!==b.value))return;b=\"\"+a._wrapperState.initialValue;c||b===a.value||(a.value=b);a.defaultValue=b}c=a.name;\"\"!==c&&(a.name=\"\");a.defaultChecked=!!a._wrapperState.initialChecked;\"\"!==c&&(a.name=c)}\nfunction cb(a,b,c){if(\"number\"!==b||Xa(a.ownerDocument)!==a)null==c?a.defaultValue=\"\"+a._wrapperState.initialValue:a.defaultValue!==\"\"+c&&(a.defaultValue=\"\"+c)}var eb=Array.isArray;\nfunction fb(a,b,c,d){a=a.options;if(b){b={};for(var e=0;e\"+b.valueOf().toString()+\"\";for(b=mb.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;b.firstChild;)a.appendChild(b.firstChild)}});\nfunction ob(a,b){if(b){var c=a.firstChild;if(c&&c===a.lastChild&&3===c.nodeType){c.nodeValue=b;return}}a.textContent=b}\nvar pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,\nzoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=[\"Webkit\",\"ms\",\"Moz\",\"O\"];Object.keys(pb).forEach(function(a){qb.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);pb[b]=pb[a]})});function rb(a,b,c){return null==b||\"boolean\"===typeof b||\"\"===b?\"\":c||\"number\"!==typeof b||0===b||pb.hasOwnProperty(a)&&pb[a]?(\"\"+b).trim():b+\"px\"}\nfunction sb(a,b){a=a.style;for(var c in b)if(b.hasOwnProperty(c)){var d=0===c.indexOf(\"--\"),e=rb(c,b[c],d);\"float\"===c&&(c=\"cssFloat\");d?a.setProperty(c,e):a[c]=e}}var tb=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});\nfunction ub(a,b){if(b){if(tb[a]&&(null!=b.children||null!=b.dangerouslySetInnerHTML))throw Error(p(137,a));if(null!=b.dangerouslySetInnerHTML){if(null!=b.children)throw Error(p(60));if(\"object\"!==typeof b.dangerouslySetInnerHTML||!(\"__html\"in b.dangerouslySetInnerHTML))throw Error(p(61));}if(null!=b.style&&\"object\"!==typeof b.style)throw Error(p(62));}}\nfunction vb(a,b){if(-1===a.indexOf(\"-\"))return\"string\"===typeof b.is;switch(a){case \"annotation-xml\":case \"color-profile\":case \"font-face\":case \"font-face-src\":case \"font-face-uri\":case \"font-face-format\":case \"font-face-name\":case \"missing-glyph\":return!1;default:return!0}}var wb=null;function xb(a){a=a.target||a.srcElement||window;a.correspondingUseElement&&(a=a.correspondingUseElement);return 3===a.nodeType?a.parentNode:a}var yb=null,zb=null,Ab=null;\nfunction Bb(a){if(a=Cb(a)){if(\"function\"!==typeof yb)throw Error(p(280));var b=a.stateNode;b&&(b=Db(b),yb(a.stateNode,a.type,b))}}function Eb(a){zb?Ab?Ab.push(a):Ab=[a]:zb=a}function Fb(){if(zb){var a=zb,b=Ab;Ab=zb=null;Bb(a);if(b)for(a=0;a>>=0;return 0===a?32:31-(pc(a)/qc|0)|0}var rc=64,sc=4194304;\nfunction tc(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;\ndefault:return a}}function uc(a,b){var c=a.pendingLanes;if(0===c)return 0;var d=0,e=a.suspendedLanes,f=a.pingedLanes,g=c&268435455;if(0!==g){var h=g&~e;0!==h?d=tc(h):(f&=g,0!==f&&(d=tc(f)))}else g=c&~e,0!==g?d=tc(g):0!==f&&(d=tc(f));if(0===d)return 0;if(0!==b&&b!==d&&0===(b&e)&&(e=d&-d,f=b&-b,e>=f||16===e&&0!==(f&4194240)))return b;0!==(d&4)&&(d|=c&16);b=a.entangledLanes;if(0!==b)for(a=a.entanglements,b&=d;0c;c++)b.push(a);return b}\nfunction Ac(a,b,c){a.pendingLanes|=b;536870912!==b&&(a.suspendedLanes=0,a.pingedLanes=0);a=a.eventTimes;b=31-oc(b);a[b]=c}function Bc(a,b){var c=a.pendingLanes&~b;a.pendingLanes=b;a.suspendedLanes=0;a.pingedLanes=0;a.expiredLanes&=b;a.mutableReadLanes&=b;a.entangledLanes&=b;b=a.entanglements;var d=a.eventTimes;for(a=a.expirationTimes;0=be),ee=String.fromCharCode(32),fe=!1;\nfunction ge(a,b){switch(a){case \"keyup\":return-1!==$d.indexOf(b.keyCode);case \"keydown\":return 229!==b.keyCode;case \"keypress\":case \"mousedown\":case \"focusout\":return!0;default:return!1}}function he(a){a=a.detail;return\"object\"===typeof a&&\"data\"in a?a.data:null}var ie=!1;function je(a,b){switch(a){case \"compositionend\":return he(b);case \"keypress\":if(32!==b.which)return null;fe=!0;return ee;case \"textInput\":return a=b.data,a===ee&&fe?null:a;default:return null}}\nfunction ke(a,b){if(ie)return\"compositionend\"===a||!ae&&ge(a,b)?(a=nd(),md=ld=kd=null,ie=!1,a):null;switch(a){case \"paste\":return null;case \"keypress\":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1=b)return{node:c,offset:b-a};a=d}a:{for(;c;){if(c.nextSibling){c=c.nextSibling;break a}c=c.parentNode}c=void 0}c=Je(c)}}function Le(a,b){return a&&b?a===b?!0:a&&3===a.nodeType?!1:b&&3===b.nodeType?Le(a,b.parentNode):\"contains\"in a?a.contains(b):a.compareDocumentPosition?!!(a.compareDocumentPosition(b)&16):!1:!1}\nfunction Me(){for(var a=window,b=Xa();b instanceof a.HTMLIFrameElement;){try{var c=\"string\"===typeof b.contentWindow.location.href}catch(d){c=!1}if(c)a=b.contentWindow;else break;b=Xa(a.document)}return b}function Ne(a){var b=a&&a.nodeName&&a.nodeName.toLowerCase();return b&&(\"input\"===b&&(\"text\"===a.type||\"search\"===a.type||\"tel\"===a.type||\"url\"===a.type||\"password\"===a.type)||\"textarea\"===b||\"true\"===a.contentEditable)}\nfunction Oe(a){var b=Me(),c=a.focusedElem,d=a.selectionRange;if(b!==c&&c&&c.ownerDocument&&Le(c.ownerDocument.documentElement,c)){if(null!==d&&Ne(c))if(b=d.start,a=d.end,void 0===a&&(a=b),\"selectionStart\"in c)c.selectionStart=b,c.selectionEnd=Math.min(a,c.value.length);else if(a=(b=c.ownerDocument||document)&&b.defaultView||window,a.getSelection){a=a.getSelection();var e=c.textContent.length,f=Math.min(d.start,e);d=void 0===d.end?f:Math.min(d.end,e);!a.extend&&f>d&&(e=d,d=f,f=e);e=Ke(c,f);var g=Ke(c,\nd);e&&g&&(1!==a.rangeCount||a.anchorNode!==e.node||a.anchorOffset!==e.offset||a.focusNode!==g.node||a.focusOffset!==g.offset)&&(b=b.createRange(),b.setStart(e.node,e.offset),a.removeAllRanges(),f>d?(a.addRange(b),a.extend(g.node,g.offset)):(b.setEnd(g.node,g.offset),a.addRange(b)))}b=[];for(a=c;a=a.parentNode;)1===a.nodeType&&b.push({element:a,left:a.scrollLeft,top:a.scrollTop});\"function\"===typeof c.focus&&c.focus();for(c=0;c=document.documentMode,Qe=null,Re=null,Se=null,Te=!1;\nfunction Ue(a,b,c){var d=c.window===c?c.document:9===c.nodeType?c:c.ownerDocument;Te||null==Qe||Qe!==Xa(d)||(d=Qe,\"selectionStart\"in d&&Ne(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Se&&Ie(Se,d)||(Se=d,d=oe(Re,\"onSelect\"),0Tf||(a.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G(a,b){Tf++;Sf[Tf]=a.current;a.current=b}var Vf={},H=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(a,b){var c=a.type.contextTypes;if(!c)return Vf;var d=a.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===b)return d.__reactInternalMemoizedMaskedChildContext;var e={},f;for(f in c)e[f]=b[f];d&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=b,a.__reactInternalMemoizedMaskedChildContext=e);return e}\nfunction Zf(a){a=a.childContextTypes;return null!==a&&void 0!==a}function $f(){E(Wf);E(H)}function ag(a,b,c){if(H.current!==Vf)throw Error(p(168));G(H,b);G(Wf,c)}function bg(a,b,c){var d=a.stateNode;b=b.childContextTypes;if(\"function\"!==typeof d.getChildContext)return c;d=d.getChildContext();for(var e in d)if(!(e in b))throw Error(p(108,Ra(a)||\"Unknown\",e));return A({},c,d)}\nfunction cg(a){a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Vf;Xf=H.current;G(H,a);G(Wf,Wf.current);return!0}function dg(a,b,c){var d=a.stateNode;if(!d)throw Error(p(169));c?(a=bg(a,b,Xf),d.__reactInternalMemoizedMergedChildContext=a,E(Wf),E(H),G(H,a)):E(Wf);G(Wf,c)}var eg=null,fg=!1,gg=!1;function hg(a){null===eg?eg=[a]:eg.push(a)}function ig(a){fg=!0;hg(a)}\nfunction jg(){if(!gg&&null!==eg){gg=!0;var a=0,b=C;try{var c=eg;for(C=1;a>=g;e-=g;rg=1<<32-oc(b)+e|c<w?(x=u,u=null):x=u.sibling;var n=r(e,u,h[w],k);if(null===n){null===u&&(u=x);break}a&&u&&null===n.alternate&&b(e,u);g=f(n,g,w);null===m?l=n:m.sibling=n;m=n;u=x}if(w===h.length)return c(e,u),I&&tg(e,w),l;if(null===u){for(;ww?(x=m,m=null):x=m.sibling;var t=r(e,m,n.value,k);if(null===t){null===m&&(m=x);break}a&&m&&null===t.alternate&&b(e,m);g=f(t,g,w);null===u?l=t:u.sibling=t;u=t;m=x}if(n.done)return c(e,\nm),I&&tg(e,w),l;if(null===m){for(;!n.done;w++,n=h.next())n=q(e,n.value,k),null!==n&&(g=f(n,g,w),null===u?l=n:u.sibling=n,u=n);I&&tg(e,w);return l}for(m=d(e,m);!n.done;w++,n=h.next())n=y(m,e,w,n.value,k),null!==n&&(a&&null!==n.alternate&&m.delete(null===n.key?w:n.key),g=f(n,g,w),null===u?l=n:u.sibling=n,u=n);a&&m.forEach(function(a){return b(e,a)});I&&tg(e,w);return l}function J(a,d,f,h){\"object\"===typeof f&&null!==f&&f.type===ya&&null===f.key&&(f=f.props.children);if(\"object\"===typeof f&&null!==f){switch(f.$$typeof){case va:a:{for(var k=\nf.key,l=d;null!==l;){if(l.key===k){k=f.type;if(k===ya){if(7===l.tag){c(a,l.sibling);d=e(l,f.props.children);d.return=a;a=d;break a}}else if(l.elementType===k||\"object\"===typeof k&&null!==k&&k.$$typeof===Ha&&Ng(k)===l.type){c(a,l.sibling);d=e(l,f.props);d.ref=Lg(a,l,f);d.return=a;a=d;break a}c(a,l);break}else b(a,l);l=l.sibling}f.type===ya?(d=Tg(f.props.children,a.mode,h,f.key),d.return=a,a=d):(h=Rg(f.type,f.key,f.props,null,a.mode,h),h.ref=Lg(a,d,f),h.return=a,a=h)}return g(a);case wa:a:{for(l=f.key;null!==\nd;){if(d.key===l)if(4===d.tag&&d.stateNode.containerInfo===f.containerInfo&&d.stateNode.implementation===f.implementation){c(a,d.sibling);d=e(d,f.children||[]);d.return=a;a=d;break a}else{c(a,d);break}else b(a,d);d=d.sibling}d=Sg(f,a.mode,h);d.return=a;a=d}return g(a);case Ha:return l=f._init,J(a,d,l(f._payload),h)}if(eb(f))return n(a,d,f,h);if(Ka(f))return t(a,d,f,h);Mg(a,f)}return\"string\"===typeof f&&\"\"!==f||\"number\"===typeof f?(f=\"\"+f,null!==d&&6===d.tag?(c(a,d.sibling),d=e(d,f),d.return=a,a=d):\n(c(a,d),d=Qg(f,a.mode,h),d.return=a,a=d),g(a)):c(a,d)}return J}var Ug=Og(!0),Vg=Og(!1),Wg=Uf(null),Xg=null,Yg=null,Zg=null;function $g(){Zg=Yg=Xg=null}function ah(a){var b=Wg.current;E(Wg);a._currentValue=b}function bh(a,b,c){for(;null!==a;){var d=a.alternate;(a.childLanes&b)!==b?(a.childLanes|=b,null!==d&&(d.childLanes|=b)):null!==d&&(d.childLanes&b)!==b&&(d.childLanes|=b);if(a===c)break;a=a.return}}\nfunction ch(a,b){Xg=a;Zg=Yg=null;a=a.dependencies;null!==a&&null!==a.firstContext&&(0!==(a.lanes&b)&&(dh=!0),a.firstContext=null)}function eh(a){var b=a._currentValue;if(Zg!==a)if(a={context:a,memoizedValue:b,next:null},null===Yg){if(null===Xg)throw Error(p(308));Yg=a;Xg.dependencies={lanes:0,firstContext:a}}else Yg=Yg.next=a;return b}var fh=null;function gh(a){null===fh?fh=[a]:fh.push(a)}\nfunction hh(a,b,c,d){var e=b.interleaved;null===e?(c.next=c,gh(b)):(c.next=e.next,e.next=c);b.interleaved=c;return ih(a,d)}function ih(a,b){a.lanes|=b;var c=a.alternate;null!==c&&(c.lanes|=b);c=a;for(a=a.return;null!==a;)a.childLanes|=b,c=a.alternate,null!==c&&(c.childLanes|=b),c=a,a=a.return;return 3===c.tag?c.stateNode:null}var jh=!1;function kh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}\nfunction lh(a,b){a=a.updateQueue;b.updateQueue===a&&(b.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function mh(a,b){return{eventTime:a,lane:b,tag:0,payload:null,callback:null,next:null}}\nfunction nh(a,b,c){var d=a.updateQueue;if(null===d)return null;d=d.shared;if(0!==(K&2)){var e=d.pending;null===e?b.next=b:(b.next=e.next,e.next=b);d.pending=b;return ih(a,c)}e=d.interleaved;null===e?(b.next=b,gh(d)):(b.next=e.next,e.next=b);d.interleaved=b;return ih(a,c)}function oh(a,b,c){b=b.updateQueue;if(null!==b&&(b=b.shared,0!==(c&4194240))){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Cc(a,c)}}\nfunction ph(a,b){var c=a.updateQueue,d=a.alternate;if(null!==d&&(d=d.updateQueue,c===d)){var e=null,f=null;c=c.firstBaseUpdate;if(null!==c){do{var g={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};null===f?e=f=g:f=f.next=g;c=c.next}while(null!==c);null===f?e=f=b:f=f.next=b}else e=f=b;c={baseState:d.baseState,firstBaseUpdate:e,lastBaseUpdate:f,shared:d.shared,effects:d.effects};a.updateQueue=c;return}a=c.lastBaseUpdate;null===a?c.firstBaseUpdate=b:a.next=\nb;c.lastBaseUpdate=b}\nfunction qh(a,b,c,d){var e=a.updateQueue;jh=!1;var f=e.firstBaseUpdate,g=e.lastBaseUpdate,h=e.shared.pending;if(null!==h){e.shared.pending=null;var k=h,l=k.next;k.next=null;null===g?f=l:g.next=l;g=k;var m=a.alternate;null!==m&&(m=m.updateQueue,h=m.lastBaseUpdate,h!==g&&(null===h?m.firstBaseUpdate=l:h.next=l,m.lastBaseUpdate=k))}if(null!==f){var q=e.baseState;g=0;m=l=k=null;h=f;do{var r=h.lane,y=h.eventTime;if((d&r)===r){null!==m&&(m=m.next={eventTime:y,lane:0,tag:h.tag,payload:h.payload,callback:h.callback,\nnext:null});a:{var n=a,t=h;r=b;y=c;switch(t.tag){case 1:n=t.payload;if(\"function\"===typeof n){q=n.call(y,q,r);break a}q=n;break a;case 3:n.flags=n.flags&-65537|128;case 0:n=t.payload;r=\"function\"===typeof n?n.call(y,q,r):n;if(null===r||void 0===r)break a;q=A({},q,r);break a;case 2:jh=!0}}null!==h.callback&&0!==h.lane&&(a.flags|=64,r=e.effects,null===r?e.effects=[h]:r.push(h))}else y={eventTime:y,lane:r,tag:h.tag,payload:h.payload,callback:h.callback,next:null},null===m?(l=m=y,k=q):m=m.next=y,g|=r;\nh=h.next;if(null===h)if(h=e.shared.pending,null===h)break;else r=h,h=r.next,r.next=null,e.lastBaseUpdate=r,e.shared.pending=null}while(1);null===m&&(k=q);e.baseState=k;e.firstBaseUpdate=l;e.lastBaseUpdate=m;b=e.shared.interleaved;if(null!==b){e=b;do g|=e.lane,e=e.next;while(e!==b)}else null===f&&(e.shared.lanes=0);rh|=g;a.lanes=g;a.memoizedState=q}}\nfunction sh(a,b,c){a=b.effects;b.effects=null;if(null!==a)for(b=0;bc?c:4;a(!0);var d=Gh.transition;Gh.transition={};try{a(!1),b()}finally{C=c,Gh.transition=d}}function wi(){return Uh().memoizedState}\nfunction xi(a,b,c){var d=yi(a);c={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(zi(a))Ai(b,c);else if(c=hh(a,b,c,d),null!==c){var e=R();gi(c,a,d,e);Bi(c,b,d)}}\nfunction ii(a,b,c){var d=yi(a),e={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(zi(a))Ai(b,e);else{var f=a.alternate;if(0===a.lanes&&(null===f||0===f.lanes)&&(f=b.lastRenderedReducer,null!==f))try{var g=b.lastRenderedState,h=f(g,c);e.hasEagerState=!0;e.eagerState=h;if(He(h,g)){var k=b.interleaved;null===k?(e.next=e,gh(b)):(e.next=k.next,k.next=e);b.interleaved=e;return}}catch(l){}finally{}c=hh(a,b,e,d);null!==c&&(e=R(),gi(c,a,d,e),Bi(c,b,d))}}\nfunction zi(a){var b=a.alternate;return a===M||null!==b&&b===M}function Ai(a,b){Jh=Ih=!0;var c=a.pending;null===c?b.next=b:(b.next=c.next,c.next=b);a.pending=b}function Bi(a,b,c){if(0!==(c&4194240)){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Cc(a,c)}}\nvar Rh={readContext:eh,useCallback:P,useContext:P,useEffect:P,useImperativeHandle:P,useInsertionEffect:P,useLayoutEffect:P,useMemo:P,useReducer:P,useRef:P,useState:P,useDebugValue:P,useDeferredValue:P,useTransition:P,useMutableSource:P,useSyncExternalStore:P,useId:P,unstable_isNewReconciler:!1},Oh={readContext:eh,useCallback:function(a,b){Th().memoizedState=[a,void 0===b?null:b];return a},useContext:eh,useEffect:mi,useImperativeHandle:function(a,b,c){c=null!==c&&void 0!==c?c.concat([a]):null;return ki(4194308,\n4,pi.bind(null,b,a),c)},useLayoutEffect:function(a,b){return ki(4194308,4,a,b)},useInsertionEffect:function(a,b){return ki(4,2,a,b)},useMemo:function(a,b){var c=Th();b=void 0===b?null:b;a=a();c.memoizedState=[a,b];return a},useReducer:function(a,b,c){var d=Th();b=void 0!==c?c(b):b;d.memoizedState=d.baseState=b;a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b};d.queue=a;a=a.dispatch=xi.bind(null,M,a);return[d.memoizedState,a]},useRef:function(a){var b=\nTh();a={current:a};return b.memoizedState=a},useState:hi,useDebugValue:ri,useDeferredValue:function(a){return Th().memoizedState=a},useTransition:function(){var a=hi(!1),b=a[0];a=vi.bind(null,a[1]);Th().memoizedState=a;return[b,a]},useMutableSource:function(){},useSyncExternalStore:function(a,b,c){var d=M,e=Th();if(I){if(void 0===c)throw Error(p(407));c=c()}else{c=b();if(null===Q)throw Error(p(349));0!==(Hh&30)||di(d,b,c)}e.memoizedState=c;var f={value:c,getSnapshot:b};e.queue=f;mi(ai.bind(null,d,\nf,a),[a]);d.flags|=2048;bi(9,ci.bind(null,d,f,c,b),void 0,null);return c},useId:function(){var a=Th(),b=Q.identifierPrefix;if(I){var c=sg;var d=rg;c=(d&~(1<<32-oc(d)-1)).toString(32)+c;b=\":\"+b+\"R\"+c;c=Kh++;0\\x3c/script>\",a=a.removeChild(a.firstChild)):\n\"string\"===typeof d.is?a=g.createElement(c,{is:d.is}):(a=g.createElement(c),\"select\"===c&&(g=a,d.multiple?g.multiple=!0:d.size&&(g.size=d.size))):a=g.createElementNS(a,c);a[Of]=b;a[Pf]=d;zj(a,b,!1,!1);b.stateNode=a;a:{g=vb(c,d);switch(c){case \"dialog\":D(\"cancel\",a);D(\"close\",a);e=d;break;case \"iframe\":case \"object\":case \"embed\":D(\"load\",a);e=d;break;case \"video\":case \"audio\":for(e=0;eGj&&(b.flags|=128,d=!0,Dj(f,!1),b.lanes=4194304)}else{if(!d)if(a=Ch(g),null!==a){if(b.flags|=128,d=!0,c=a.updateQueue,null!==c&&(b.updateQueue=c,b.flags|=4),Dj(f,!0),null===f.tail&&\"hidden\"===f.tailMode&&!g.alternate&&!I)return S(b),null}else 2*B()-f.renderingStartTime>Gj&&1073741824!==c&&(b.flags|=128,d=!0,Dj(f,!1),b.lanes=4194304);f.isBackwards?(g.sibling=b.child,b.child=g):(c=f.last,null!==c?c.sibling=g:b.child=g,f.last=g)}if(null!==f.tail)return b=f.tail,f.rendering=\nb,f.tail=b.sibling,f.renderingStartTime=B(),b.sibling=null,c=L.current,G(L,d?c&1|2:c&1),b;S(b);return null;case 22:case 23:return Hj(),d=null!==b.memoizedState,null!==a&&null!==a.memoizedState!==d&&(b.flags|=8192),d&&0!==(b.mode&1)?0!==(fj&1073741824)&&(S(b),b.subtreeFlags&6&&(b.flags|=8192)):S(b),null;case 24:return null;case 25:return null}throw Error(p(156,b.tag));}\nfunction Ij(a,b){wg(b);switch(b.tag){case 1:return Zf(b.type)&&$f(),a=b.flags,a&65536?(b.flags=a&-65537|128,b):null;case 3:return zh(),E(Wf),E(H),Eh(),a=b.flags,0!==(a&65536)&&0===(a&128)?(b.flags=a&-65537|128,b):null;case 5:return Bh(b),null;case 13:E(L);a=b.memoizedState;if(null!==a&&null!==a.dehydrated){if(null===b.alternate)throw Error(p(340));Ig()}a=b.flags;return a&65536?(b.flags=a&-65537|128,b):null;case 19:return E(L),null;case 4:return zh(),null;case 10:return ah(b.type._context),null;case 22:case 23:return Hj(),\nnull;case 24:return null;default:return null}}var Jj=!1,U=!1,Kj=\"function\"===typeof WeakSet?WeakSet:Set,V=null;function Lj(a,b){var c=a.ref;if(null!==c)if(\"function\"===typeof c)try{c(null)}catch(d){W(a,b,d)}else c.current=null}function Mj(a,b,c){try{c()}catch(d){W(a,b,d)}}var Nj=!1;\nfunction Oj(a,b){Cf=dd;a=Me();if(Ne(a)){if(\"selectionStart\"in a)var c={start:a.selectionStart,end:a.selectionEnd};else a:{c=(c=a.ownerDocument)&&c.defaultView||window;var d=c.getSelection&&c.getSelection();if(d&&0!==d.rangeCount){c=d.anchorNode;var e=d.anchorOffset,f=d.focusNode;d=d.focusOffset;try{c.nodeType,f.nodeType}catch(F){c=null;break a}var g=0,h=-1,k=-1,l=0,m=0,q=a,r=null;b:for(;;){for(var y;;){q!==c||0!==e&&3!==q.nodeType||(h=g+e);q!==f||0!==d&&3!==q.nodeType||(k=g+d);3===q.nodeType&&(g+=\nq.nodeValue.length);if(null===(y=q.firstChild))break;r=q;q=y}for(;;){if(q===a)break b;r===c&&++l===e&&(h=g);r===f&&++m===d&&(k=g);if(null!==(y=q.nextSibling))break;q=r;r=q.parentNode}q=y}c=-1===h||-1===k?null:{start:h,end:k}}else c=null}c=c||{start:0,end:0}}else c=null;Df={focusedElem:a,selectionRange:c};dd=!1;for(V=b;null!==V;)if(b=V,a=b.child,0!==(b.subtreeFlags&1028)&&null!==a)a.return=b,V=a;else for(;null!==V;){b=V;try{var n=b.alternate;if(0!==(b.flags&1024))switch(b.tag){case 0:case 11:case 15:break;\ncase 1:if(null!==n){var t=n.memoizedProps,J=n.memoizedState,x=b.stateNode,w=x.getSnapshotBeforeUpdate(b.elementType===b.type?t:Ci(b.type,t),J);x.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var u=b.stateNode.containerInfo;1===u.nodeType?u.textContent=\"\":9===u.nodeType&&u.documentElement&&u.removeChild(u.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p(163));}}catch(F){W(b,b.return,F)}a=b.sibling;if(null!==a){a.return=b.return;V=a;break}V=b.return}n=Nj;Nj=!1;return n}\nfunction Pj(a,b,c){var d=b.updateQueue;d=null!==d?d.lastEffect:null;if(null!==d){var e=d=d.next;do{if((e.tag&a)===a){var f=e.destroy;e.destroy=void 0;void 0!==f&&Mj(b,c,f)}e=e.next}while(e!==d)}}function Qj(a,b){b=b.updateQueue;b=null!==b?b.lastEffect:null;if(null!==b){var c=b=b.next;do{if((c.tag&a)===a){var d=c.create;c.destroy=d()}c=c.next}while(c!==b)}}function Rj(a){var b=a.ref;if(null!==b){var c=a.stateNode;switch(a.tag){case 5:a=c;break;default:a=c}\"function\"===typeof b?b(a):b.current=a}}\nfunction Sj(a){var b=a.alternate;null!==b&&(a.alternate=null,Sj(b));a.child=null;a.deletions=null;a.sibling=null;5===a.tag&&(b=a.stateNode,null!==b&&(delete b[Of],delete b[Pf],delete b[of],delete b[Qf],delete b[Rf]));a.stateNode=null;a.return=null;a.dependencies=null;a.memoizedProps=null;a.memoizedState=null;a.pendingProps=null;a.stateNode=null;a.updateQueue=null}function Tj(a){return 5===a.tag||3===a.tag||4===a.tag}\nfunction Uj(a){a:for(;;){for(;null===a.sibling;){if(null===a.return||Tj(a.return))return null;a=a.return}a.sibling.return=a.return;for(a=a.sibling;5!==a.tag&&6!==a.tag&&18!==a.tag;){if(a.flags&2)continue a;if(null===a.child||4===a.tag)continue a;else a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}\nfunction Vj(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?8===c.nodeType?c.parentNode.insertBefore(a,b):c.insertBefore(a,b):(8===c.nodeType?(b=c.parentNode,b.insertBefore(a,c)):(b=c,b.appendChild(a)),c=c._reactRootContainer,null!==c&&void 0!==c||null!==b.onclick||(b.onclick=Bf));else if(4!==d&&(a=a.child,null!==a))for(Vj(a,b,c),a=a.sibling;null!==a;)Vj(a,b,c),a=a.sibling}\nfunction Wj(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?c.insertBefore(a,b):c.appendChild(a);else if(4!==d&&(a=a.child,null!==a))for(Wj(a,b,c),a=a.sibling;null!==a;)Wj(a,b,c),a=a.sibling}var X=null,Xj=!1;function Yj(a,b,c){for(c=c.child;null!==c;)Zj(a,b,c),c=c.sibling}\nfunction Zj(a,b,c){if(lc&&\"function\"===typeof lc.onCommitFiberUnmount)try{lc.onCommitFiberUnmount(kc,c)}catch(h){}switch(c.tag){case 5:U||Lj(c,b);case 6:var d=X,e=Xj;X=null;Yj(a,b,c);X=d;Xj=e;null!==X&&(Xj?(a=X,c=c.stateNode,8===a.nodeType?a.parentNode.removeChild(c):a.removeChild(c)):X.removeChild(c.stateNode));break;case 18:null!==X&&(Xj?(a=X,c=c.stateNode,8===a.nodeType?Kf(a.parentNode,c):1===a.nodeType&&Kf(a,c),bd(a)):Kf(X,c.stateNode));break;case 4:d=X;e=Xj;X=c.stateNode.containerInfo;Xj=!0;\nYj(a,b,c);X=d;Xj=e;break;case 0:case 11:case 14:case 15:if(!U&&(d=c.updateQueue,null!==d&&(d=d.lastEffect,null!==d))){e=d=d.next;do{var f=e,g=f.destroy;f=f.tag;void 0!==g&&(0!==(f&2)?Mj(c,b,g):0!==(f&4)&&Mj(c,b,g));e=e.next}while(e!==d)}Yj(a,b,c);break;case 1:if(!U&&(Lj(c,b),d=c.stateNode,\"function\"===typeof d.componentWillUnmount))try{d.props=c.memoizedProps,d.state=c.memoizedState,d.componentWillUnmount()}catch(h){W(c,b,h)}Yj(a,b,c);break;case 21:Yj(a,b,c);break;case 22:c.mode&1?(U=(d=U)||null!==\nc.memoizedState,Yj(a,b,c),U=d):Yj(a,b,c);break;default:Yj(a,b,c)}}function ak(a){var b=a.updateQueue;if(null!==b){a.updateQueue=null;var c=a.stateNode;null===c&&(c=a.stateNode=new Kj);b.forEach(function(b){var d=bk.bind(null,a,b);c.has(b)||(c.add(b),b.then(d,d))})}}\nfunction ck(a,b){var c=b.deletions;if(null!==c)for(var d=0;de&&(e=g);d&=~f}d=e;d=B()-d;d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3E3>d?3E3:4320>d?4320:1960*lk(d/1960))-d;if(10a?16:a;if(null===wk)var d=!1;else{a=wk;wk=null;xk=0;if(0!==(K&6))throw Error(p(331));var e=K;K|=4;for(V=a.current;null!==V;){var f=V,g=f.child;if(0!==(V.flags&16)){var h=f.deletions;if(null!==h){for(var k=0;kB()-fk?Kk(a,0):rk|=c);Dk(a,b)}function Yk(a,b){0===b&&(0===(a.mode&1)?b=1:(b=sc,sc<<=1,0===(sc&130023424)&&(sc=4194304)));var c=R();a=ih(a,b);null!==a&&(Ac(a,b,c),Dk(a,c))}function uj(a){var b=a.memoizedState,c=0;null!==b&&(c=b.retryLane);Yk(a,c)}\nfunction bk(a,b){var c=0;switch(a.tag){case 13:var d=a.stateNode;var e=a.memoizedState;null!==e&&(c=e.retryLane);break;case 19:d=a.stateNode;break;default:throw Error(p(314));}null!==d&&d.delete(b);Yk(a,c)}var Vk;\nVk=function(a,b,c){if(null!==a)if(a.memoizedProps!==b.pendingProps||Wf.current)dh=!0;else{if(0===(a.lanes&c)&&0===(b.flags&128))return dh=!1,yj(a,b,c);dh=0!==(a.flags&131072)?!0:!1}else dh=!1,I&&0!==(b.flags&1048576)&&ug(b,ng,b.index);b.lanes=0;switch(b.tag){case 2:var d=b.type;ij(a,b);a=b.pendingProps;var e=Yf(b,H.current);ch(b,c);e=Nh(null,b,d,a,e,c);var f=Sh();b.flags|=1;\"object\"===typeof e&&null!==e&&\"function\"===typeof e.render&&void 0===e.$$typeof?(b.tag=1,b.memoizedState=null,b.updateQueue=\nnull,Zf(d)?(f=!0,cg(b)):f=!1,b.memoizedState=null!==e.state&&void 0!==e.state?e.state:null,kh(b),e.updater=Ei,b.stateNode=e,e._reactInternals=b,Ii(b,d,a,c),b=jj(null,b,d,!0,f,c)):(b.tag=0,I&&f&&vg(b),Xi(null,b,e,c),b=b.child);return b;case 16:d=b.elementType;a:{ij(a,b);a=b.pendingProps;e=d._init;d=e(d._payload);b.type=d;e=b.tag=Zk(d);a=Ci(d,a);switch(e){case 0:b=cj(null,b,d,a,c);break a;case 1:b=hj(null,b,d,a,c);break a;case 11:b=Yi(null,b,d,a,c);break a;case 14:b=$i(null,b,d,Ci(d.type,a),c);break a}throw Error(p(306,\nd,\"\"));}return b;case 0:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),cj(a,b,d,e,c);case 1:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),hj(a,b,d,e,c);case 3:a:{kj(b);if(null===a)throw Error(p(387));d=b.pendingProps;f=b.memoizedState;e=f.element;lh(a,b);qh(b,d,null,c);var g=b.memoizedState;d=g.element;if(f.isDehydrated)if(f={element:d,isDehydrated:!1,cache:g.cache,pendingSuspenseBoundaries:g.pendingSuspenseBoundaries,transitions:g.transitions},b.updateQueue.baseState=\nf,b.memoizedState=f,b.flags&256){e=Ji(Error(p(423)),b);b=lj(a,b,d,c,e);break a}else if(d!==e){e=Ji(Error(p(424)),b);b=lj(a,b,d,c,e);break a}else for(yg=Lf(b.stateNode.containerInfo.firstChild),xg=b,I=!0,zg=null,c=Vg(b,null,d,c),b.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{Ig();if(d===e){b=Zi(a,b,c);break a}Xi(a,b,d,c)}b=b.child}return b;case 5:return Ah(b),null===a&&Eg(b),d=b.type,e=b.pendingProps,f=null!==a?a.memoizedProps:null,g=e.children,Ef(d,e)?g=null:null!==f&&Ef(d,f)&&(b.flags|=32),\ngj(a,b),Xi(a,b,g,c),b.child;case 6:return null===a&&Eg(b),null;case 13:return oj(a,b,c);case 4:return yh(b,b.stateNode.containerInfo),d=b.pendingProps,null===a?b.child=Ug(b,null,d,c):Xi(a,b,d,c),b.child;case 11:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),Yi(a,b,d,e,c);case 7:return Xi(a,b,b.pendingProps,c),b.child;case 8:return Xi(a,b,b.pendingProps.children,c),b.child;case 12:return Xi(a,b,b.pendingProps.children,c),b.child;case 10:a:{d=b.type._context;e=b.pendingProps;f=b.memoizedProps;\ng=e.value;G(Wg,d._currentValue);d._currentValue=g;if(null!==f)if(He(f.value,g)){if(f.children===e.children&&!Wf.current){b=Zi(a,b,c);break a}}else for(f=b.child,null!==f&&(f.return=b);null!==f;){var h=f.dependencies;if(null!==h){g=f.child;for(var k=h.firstContext;null!==k;){if(k.context===d){if(1===f.tag){k=mh(-1,c&-c);k.tag=2;var l=f.updateQueue;if(null!==l){l=l.shared;var m=l.pending;null===m?k.next=k:(k.next=m.next,m.next=k);l.pending=k}}f.lanes|=c;k=f.alternate;null!==k&&(k.lanes|=c);bh(f.return,\nc,b);h.lanes|=c;break}k=k.next}}else if(10===f.tag)g=f.type===b.type?null:f.child;else if(18===f.tag){g=f.return;if(null===g)throw Error(p(341));g.lanes|=c;h=g.alternate;null!==h&&(h.lanes|=c);bh(g,c,b);g=f.sibling}else g=f.child;if(null!==g)g.return=f;else for(g=f;null!==g;){if(g===b){g=null;break}f=g.sibling;if(null!==f){f.return=g.return;g=f;break}g=g.return}f=g}Xi(a,b,e.children,c);b=b.child}return b;case 9:return e=b.type,d=b.pendingProps.children,ch(b,c),e=eh(e),d=d(e),b.flags|=1,Xi(a,b,d,c),\nb.child;case 14:return d=b.type,e=Ci(d,b.pendingProps),e=Ci(d.type,e),$i(a,b,d,e,c);case 15:return bj(a,b,b.type,b.pendingProps,c);case 17:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),ij(a,b),b.tag=1,Zf(d)?(a=!0,cg(b)):a=!1,ch(b,c),Gi(b,d,e),Ii(b,d,e,c),jj(null,b,d,!0,a,c);case 19:return xj(a,b,c);case 22:return dj(a,b,c)}throw Error(p(156,b.tag));};function Fk(a,b){return ac(a,b)}\nfunction $k(a,b,c,d){this.tag=a;this.key=c;this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null;this.index=0;this.ref=null;this.pendingProps=b;this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null;this.mode=d;this.subtreeFlags=this.flags=0;this.deletions=null;this.childLanes=this.lanes=0;this.alternate=null}function Bg(a,b,c,d){return new $k(a,b,c,d)}function aj(a){a=a.prototype;return!(!a||!a.isReactComponent)}\nfunction Zk(a){if(\"function\"===typeof a)return aj(a)?1:0;if(void 0!==a&&null!==a){a=a.$$typeof;if(a===Da)return 11;if(a===Ga)return 14}return 2}\nfunction Pg(a,b){var c=a.alternate;null===c?(c=Bg(a.tag,b,a.key,a.mode),c.elementType=a.elementType,c.type=a.type,c.stateNode=a.stateNode,c.alternate=a,a.alternate=c):(c.pendingProps=b,c.type=a.type,c.flags=0,c.subtreeFlags=0,c.deletions=null);c.flags=a.flags&14680064;c.childLanes=a.childLanes;c.lanes=a.lanes;c.child=a.child;c.memoizedProps=a.memoizedProps;c.memoizedState=a.memoizedState;c.updateQueue=a.updateQueue;b=a.dependencies;c.dependencies=null===b?null:{lanes:b.lanes,firstContext:b.firstContext};\nc.sibling=a.sibling;c.index=a.index;c.ref=a.ref;return c}\nfunction Rg(a,b,c,d,e,f){var g=2;d=a;if(\"function\"===typeof a)aj(a)&&(g=1);else if(\"string\"===typeof a)g=5;else a:switch(a){case ya:return Tg(c.children,e,f,b);case za:g=8;e|=8;break;case Aa:return a=Bg(12,c,b,e|2),a.elementType=Aa,a.lanes=f,a;case Ea:return a=Bg(13,c,b,e),a.elementType=Ea,a.lanes=f,a;case Fa:return a=Bg(19,c,b,e),a.elementType=Fa,a.lanes=f,a;case Ia:return pj(c,e,f,b);default:if(\"object\"===typeof a&&null!==a)switch(a.$$typeof){case Ba:g=10;break a;case Ca:g=9;break a;case Da:g=11;\nbreak a;case Ga:g=14;break a;case Ha:g=16;d=null;break a}throw Error(p(130,null==a?a:typeof a,\"\"));}b=Bg(g,c,b,e);b.elementType=a;b.type=d;b.lanes=f;return b}function Tg(a,b,c,d){a=Bg(7,a,d,b);a.lanes=c;return a}function pj(a,b,c,d){a=Bg(22,a,d,b);a.elementType=Ia;a.lanes=c;a.stateNode={isHidden:!1};return a}function Qg(a,b,c){a=Bg(6,a,null,b);a.lanes=c;return a}\nfunction Sg(a,b,c){b=Bg(4,null!==a.children?a.children:[],a.key,b);b.lanes=c;b.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation};return b}\nfunction al(a,b,c,d,e){this.tag=b;this.containerInfo=a;this.finishedWork=this.pingCache=this.current=this.pendingChildren=null;this.timeoutHandle=-1;this.callbackNode=this.pendingContext=this.context=null;this.callbackPriority=0;this.eventTimes=zc(0);this.expirationTimes=zc(-1);this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0;this.entanglements=zc(0);this.identifierPrefix=d;this.onRecoverableError=e;this.mutableSourceEagerHydrationData=\nnull}function bl(a,b,c,d,e,f,g,h,k){a=new al(a,b,c,h,k);1===b?(b=1,!0===f&&(b|=8)):b=0;f=Bg(3,null,null,b);a.current=f;f.stateNode=a;f.memoizedState={element:d,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null};kh(f);return a}function cl(a,b,c){var d=3 0 ? charat(characters, --position) : 0\n\n\tif (column--, character === 10)\n\t\tcolumn = 1, line--\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function next () {\n\tcharacter = position < length ? charat(characters, position++) : 0\n\n\tif (column++, character === 10)\n\t\tcolumn = 1, line++\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function peek () {\n\treturn charat(characters, position)\n}\n\n/**\n * @return {number}\n */\nexport function caret () {\n\treturn position\n}\n\n/**\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function slice (begin, end) {\n\treturn substr(characters, begin, end)\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function token (type) {\n\tswitch (type) {\n\t\t// \\0 \\t \\n \\r \\s whitespace token\n\t\tcase 0: case 9: case 10: case 13: case 32:\n\t\t\treturn 5\n\t\t// ! + , / > @ ~ isolate token\n\t\tcase 33: case 43: case 44: case 47: case 62: case 64: case 126:\n\t\t// ; { } breakpoint token\n\t\tcase 59: case 123: case 125:\n\t\t\treturn 4\n\t\t// : accompanied token\n\t\tcase 58:\n\t\t\treturn 3\n\t\t// \" ' ( [ opening delimit token\n\t\tcase 34: case 39: case 40: case 91:\n\t\t\treturn 2\n\t\t// ) ] closing delimit token\n\t\tcase 41: case 93:\n\t\t\treturn 1\n\t}\n\n\treturn 0\n}\n\n/**\n * @param {string} value\n * @return {any[]}\n */\nexport function alloc (value) {\n\treturn line = column = 1, length = strlen(characters = value), position = 0, []\n}\n\n/**\n * @param {any} value\n * @return {any}\n */\nexport function dealloc (value) {\n\treturn characters = '', value\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function delimit (type) {\n\treturn trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))\n}\n\n/**\n * @param {string} value\n * @return {string[]}\n */\nexport function tokenize (value) {\n\treturn dealloc(tokenizer(alloc(value)))\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function whitespace (type) {\n\twhile (character = peek())\n\t\tif (character < 33)\n\t\t\tnext()\n\t\telse\n\t\t\tbreak\n\n\treturn token(type) > 2 || token(character) > 3 ? '' : ' '\n}\n\n/**\n * @param {string[]} children\n * @return {string[]}\n */\nexport function tokenizer (children) {\n\twhile (next())\n\t\tswitch (token(character)) {\n\t\t\tcase 0: append(identifier(position - 1), children)\n\t\t\t\tbreak\n\t\t\tcase 2: append(delimit(character), children)\n\t\t\t\tbreak\n\t\t\tdefault: append(from(character), children)\n\t\t}\n\n\treturn children\n}\n\n/**\n * @param {number} index\n * @param {number} count\n * @return {string}\n */\nexport function escaping (index, count) {\n\twhile (--count && next())\n\t\t// not 0-9 A-F a-f\n\t\tif (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))\n\t\t\tbreak\n\n\treturn slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function delimiter (type) {\n\twhile (next())\n\t\tswitch (character) {\n\t\t\t// ] ) \" '\n\t\t\tcase type:\n\t\t\t\treturn position\n\t\t\t// \" '\n\t\t\tcase 34: case 39:\n\t\t\t\tif (type !== 34 && type !== 39)\n\t\t\t\t\tdelimiter(character)\n\t\t\t\tbreak\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (type === 41)\n\t\t\t\t\tdelimiter(type)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tnext()\n\t\t\t\tbreak\n\t\t}\n\n\treturn position\n}\n\n/**\n * @param {number} type\n * @param {number} index\n * @return {number}\n */\nexport function commenter (type, index) {\n\twhile (next())\n\t\t// //\n\t\tif (type + character === 47 + 10)\n\t\t\tbreak\n\t\t// /*\n\t\telse if (type + character === 42 + 42 && peek() === 47)\n\t\t\tbreak\n\n\treturn '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())\n}\n\n/**\n * @param {number} index\n * @return {string}\n */\nexport function identifier (index) {\n\twhile (!token(peek()))\n\t\tnext()\n\n\treturn slice(index, position)\n}\n","import {COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {abs, charat, trim, from, sizeof, strlen, substr, append, replace, indexof} from './Utility.js'\nimport {node, char, prev, next, peek, token, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'\n\n/**\n * @param {string} value\n * @return {object[]}\n */\nexport function compile (value) {\n\treturn dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string[]} rule\n * @param {string[]} rules\n * @param {string[]} rulesets\n * @param {number[]} pseudo\n * @param {number[]} points\n * @param {string[]} declarations\n * @return {object}\n */\nexport function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {\n\tvar index = 0\n\tvar offset = 0\n\tvar length = pseudo\n\tvar atrule = 0\n\tvar property = 0\n\tvar previous = 0\n\tvar variable = 1\n\tvar scanning = 1\n\tvar ampersand = 1\n\tvar character = 0\n\tvar type = ''\n\tvar props = rules\n\tvar children = rulesets\n\tvar reference = rule\n\tvar characters = type\n\n\twhile (scanning)\n\t\tswitch (previous = character, character = next()) {\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (previous != 108 && charat(characters, length - 1) == 58) {\n\t\t\t\t\tif (indexof(characters += replace(delimit(character), '&', '&\\f'), '&\\f', abs(index ? points[index - 1] : 0)) != -1)\n\t\t\t\t\t\tampersand = -1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t// \" ' [\n\t\t\tcase 34: case 39: case 91:\n\t\t\t\tcharacters += delimit(character)\n\t\t\t\tbreak\n\t\t\t// \\t \\n \\r \\s\n\t\t\tcase 9: case 10: case 13: case 32:\n\t\t\t\tcharacters += whitespace(previous)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tcharacters += escaping(caret() - 1, 7)\n\t\t\t\tcontinue\n\t\t\t// /\n\t\t\tcase 47:\n\t\t\t\tswitch (peek()) {\n\t\t\t\t\tcase 42: case 47:\n\t\t\t\t\t\tappend(comment(commenter(next(), caret()), root, parent, declarations), declarations)\n\t\t\t\t\t\tif ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters) && substr(characters, -1, void 0) !== ' ') characters += ' '\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcharacters += '/'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t// {\n\t\t\tcase 123 * variable:\n\t\t\t\tpoints[index++] = strlen(characters) * ampersand\n\t\t\t// } ; \\0\n\t\t\tcase 125 * variable: case 59: case 0:\n\t\t\t\tswitch (character) {\n\t\t\t\t\t// \\0 }\n\t\t\t\t\tcase 0: case 125: scanning = 0\n\t\t\t\t\t// ;\n\t\t\t\t\tcase 59 + offset: if (ampersand == -1) characters = replace(characters, /\\f/g, '')\n\t\t\t\t\t\tif (property > 0 && (strlen(characters) - length || (variable === 0 && previous === 47)))\n\t\t\t\t\t\t\tappend(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @ ;\n\t\t\t\t\tcase 59: characters += ';'\n\t\t\t\t\t// { rule/at-rule\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tappend(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets)\n\n\t\t\t\t\t\tif (character === 123)\n\t\t\t\t\t\t\tif (offset === 0)\n\t\t\t\t\t\t\t\tparse(characters, root, reference, reference, props, rulesets, length, points, children)\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tswitch (atrule) {\n\t\t\t\t\t\t\t\t\t// c(ontainer)\n\t\t\t\t\t\t\t\t\tcase 99:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 3) === 110) break\n\t\t\t\t\t\t\t\t\t// l(ayer)\n\t\t\t\t\t\t\t\t\tcase 108:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 2) === 97) break\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\toffset = 0\n\t\t\t\t\t\t\t\t\t// d(ocument) m(edia) s(upports)\n\t\t\t\t\t\t\t\t\tcase 100: case 109: case 115:\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (offset) parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children)\n\t\t\t\t\t\t\t\telse parse(characters, reference, reference, reference, [''], children, 0, points, children)\n\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tindex = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo\n\t\t\t\tbreak\n\t\t\t// :\n\t\t\tcase 58:\n\t\t\t\tlength = 1 + strlen(characters), property = previous\n\t\t\tdefault:\n\t\t\t\tif (variable < 1)\n\t\t\t\t\tif (character == 123)\n\t\t\t\t\t\t--variable\n\t\t\t\t\telse if (character == 125 && variable++ == 0 && prev() == 125)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\tswitch (characters += from(character), character * variable) {\n\t\t\t\t\t// &\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\tampersand = offset > 0 ? 1 : (characters += '\\f', -1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// ,\n\t\t\t\t\tcase 44:\n\t\t\t\t\t\tpoints[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @\n\t\t\t\t\tcase 64:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (peek() === 45)\n\t\t\t\t\t\t\tcharacters += delimit(next())\n\n\t\t\t\t\t\tatrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// -\n\t\t\t\t\tcase 45:\n\t\t\t\t\t\tif (previous === 45 && strlen(characters) == 2)\n\t\t\t\t\t\t\tvariable = 0\n\t\t\t\t}\n\t\t}\n\n\treturn rulesets\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} index\n * @param {number} offset\n * @param {string[]} rules\n * @param {number[]} points\n * @param {string} type\n * @param {string[]} props\n * @param {string[]} children\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {\n\tvar post = offset - 1\n\tvar rule = offset === 0 ? rules : ['']\n\tvar size = sizeof(rule)\n\n\tfor (var i = 0, j = 0, k = 0; i < index; ++i)\n\t\tfor (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)\n\t\t\tif (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\\f/g, rule[x])))\n\t\t\t\tprops[k++] = z\n\n\treturn node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)\n}\n\n/**\n * @param {number} value\n * @param {object} root\n * @param {object?} parent\n * @param {object[]} siblings\n * @return {object}\n */\nexport function comment (value, root, parent, siblings) {\n\treturn node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function declaration (value, root, parent, length, siblings) {\n\treturn node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)\n}\n","import {MS, MOZ, WEBKIT} from './Enum.js'\nimport {hash, charat, strlen, indexof, replace, substr, match} from './Utility.js'\n\n/**\n * @param {string} value\n * @param {number} length\n * @param {object[]} children\n * @return {string}\n */\nexport function prefix (value, length, children) {\n\tswitch (hash(value, length)) {\n\t\t// color-adjust\n\t\tcase 5103:\n\t\t\treturn WEBKIT + 'print-' + value + value\n\t\t// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)\n\t\tcase 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921:\n\t\t// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break\n\t\tcase 5572: case 6356: case 5844: case 3191: case 6645: case 3005:\n\t\t// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)\n\t\tcase 4215: case 6389: case 5109: case 5365: case 5621: case 3829:\n\t\t// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position\n\t\tcase 6391: case 5879: case 5623: case 6135: case 4599:\n\t\t\treturn WEBKIT + value + value\n\t\t// mask-composite\n\t\tcase 4855:\n\t\t\treturn WEBKIT + value.replace('add', 'source-over').replace('substract', 'source-out').replace('intersect', 'source-in').replace('exclude', 'xor') + value\n\t\t// tab-size\n\t\tcase 4789:\n\t\t\treturn MOZ + value + value\n\t\t// appearance, user-select, transform, hyphens, text-size-adjust\n\t\tcase 5349: case 4246: case 4810: case 6968: case 2756:\n\t\t\treturn WEBKIT + value + MOZ + value + MS + value + value\n\t\t// writing-mode\n\t\tcase 5936:\n\t\t\tswitch (charat(value, length + 11)) {\n\t\t\t\t// vertical-l(r)\n\t\t\t\tcase 114:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb') + value\n\t\t\t\t// vertical-r(l)\n\t\t\t\tcase 108:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb-rl') + value\n\t\t\t\t// horizontal(-)tb\n\t\t\t\tcase 45:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'lr') + value\n\t\t\t\t// default: fallthrough to below\n\t\t\t}\n\t\t// flex, flex-direction, scroll-snap-type, writing-mode\n\t\tcase 6828: case 4268: case 2903:\n\t\t\treturn WEBKIT + value + MS + value + value\n\t\t// order\n\t\tcase 6165:\n\t\t\treturn WEBKIT + value + MS + 'flex-' + value + value\n\t\t// align-items\n\t\tcase 5187:\n\t\t\treturn WEBKIT + value + replace(value, /(\\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value\n\t\t// align-self\n\t\tcase 5443:\n\t\t\treturn WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/g, '') + (!match(value, /flex-|baseline/) ? MS + 'grid-row-' + replace(value, /flex-|-self/g, '') : '') + value\n\t\t// align-content\n\t\tcase 4675:\n\t\t\treturn WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/g, '') + value\n\t\t// flex-shrink\n\t\tcase 5548:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value\n\t\t// flex-basis\n\t\tcase 5292:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value\n\t\t// flex-grow\n\t\tcase 6060:\n\t\t\treturn WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value\n\t\t// transition\n\t\tcase 4554:\n\t\t\treturn WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value\n\t\t// cursor\n\t\tcase 6187:\n\t\t\treturn replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value\n\t\t// background, background-image\n\t\tcase 5495: case 3959:\n\t\t\treturn replace(value, /(image-set\\([^]*)/, WEBKIT + '$1' + '$`$1')\n\t\t// justify-content\n\t\tcase 4968:\n\t\t\treturn replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /space-between/, 'justify') + WEBKIT + value + value\n\t\t// justify-self\n\t\tcase 4200:\n\t\t\tif (!match(value, /flex-|baseline/)) return MS + 'grid-column-align' + substr(value, length) + value\n\t\t\tbreak\n\t\t// grid-template-(columns|rows)\n\t\tcase 2592: case 3360:\n\t\t\treturn MS + replace(value, 'template-', '') + value\n\t\t// grid-(row|column)-start\n\t\tcase 4384: case 3616:\n\t\t\tif (children && children.some(function (element, index) { return length = index, match(element.props, /grid-\\w+-end/) })) {\n\t\t\t\treturn ~indexof(value + (children = children[length].value), 'span', 0) ? value : (MS + replace(value, '-start', '') + value + MS + 'grid-row-span:' + (~indexof(children, 'span', 0) ? match(children, /\\d+/) : +match(children, /\\d+/) - +match(value, /\\d+/)) + ';')\n\t\t\t}\n\t\t\treturn MS + replace(value, '-start', '') + value\n\t\t// grid-(row|column)-end\n\t\tcase 4896: case 4128:\n\t\t\treturn (children && children.some(function (element) { return match(element.props, /grid-\\w+-start/) })) ? value : MS + replace(replace(value, '-end', '-span'), 'span ', '') + value\n\t\t// (margin|padding)-inline-(start|end)\n\t\tcase 4095: case 3583: case 4068: case 2532:\n\t\t\treturn replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value\n\t\t// (min|max)?(width|height|inline-size|block-size)\n\t\tcase 8116: case 7059: case 5753: case 5535:\n\t\tcase 5445: case 5701: case 4933: case 4677:\n\t\tcase 5533: case 5789: case 5021: case 4765:\n\t\t\t// stretch, max-content, min-content, fill-available\n\t\t\tif (strlen(value) - 1 - length > 6)\n\t\t\t\tswitch (charat(value, length + 1)) {\n\t\t\t\t\t// (m)ax-content, (m)in-content\n\t\t\t\t\tcase 109:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (charat(value, length + 4) !== 45)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t// (f)ill-available, (f)it-content\n\t\t\t\t\tcase 102:\n\t\t\t\t\t\treturn replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value\n\t\t\t\t\t// (s)tretch\n\t\t\t\t\tcase 115:\n\t\t\t\t\t\treturn ~indexof(value, 'stretch', 0) ? prefix(replace(value, 'stretch', 'fill-available'), length, children) + value : value\n\t\t\t\t}\n\t\t\tbreak\n\t\t// grid-(column|row)\n\t\tcase 5152: case 5920:\n\t\t\treturn replace(value, /(.+?):(\\d+)(\\s*\\/\\s*(span)?\\s*(\\d+))?(.*)/, function (_, a, b, c, d, e, f) { return (MS + a + ':' + b + f) + (c ? (MS + a + '-span:' + (d ? e : +e - +b)) + f : '') + value })\n\t\t// position: sticky\n\t\tcase 4949:\n\t\t\t// stick(y)?\n\t\t\tif (charat(value, length + 6) === 121)\n\t\t\t\treturn replace(value, ':', ':' + WEBKIT) + value\n\t\t\tbreak\n\t\t// display: (flex|inline-flex|grid|inline-grid)\n\t\tcase 6444:\n\t\t\tswitch (charat(value, charat(value, 14) === 45 ? 18 : 11)) {\n\t\t\t\t// (inline-)?fle(x)\n\t\t\t\tcase 120:\n\t\t\t\t\treturn replace(value, /(.+:)([^;\\s!]+)(;|(\\s+)?!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value\n\t\t\t\t// (inline-)?gri(d)\n\t\t\t\tcase 100:\n\t\t\t\t\treturn replace(value, ':', ':' + MS) + value\n\t\t\t}\n\t\t\tbreak\n\t\t// scroll-margin, scroll-margin-(top|right|bottom|left)\n\t\tcase 5719: case 2647: case 2135: case 3927: case 2391:\n\t\t\treturn replace(value, 'scroll-', 'scroll-snap-') + value\n\t}\n\n\treturn value\n}\n","import {IMPORT, LAYER, COMMENT, RULESET, DECLARATION, KEYFRAMES, NAMESPACE} from './Enum.js'\nimport {strlen} from './Utility.js'\n\n/**\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function serialize (children, callback) {\n\tvar output = ''\n\n\tfor (var i = 0; i < children.length; i++)\n\t\toutput += callback(children[i], i, children, callback) || ''\n\n\treturn output\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function stringify (element, index, children, callback) {\n\tswitch (element.type) {\n\t\tcase LAYER: if (element.children.length) break\n\t\tcase IMPORT: case NAMESPACE: case DECLARATION: return element.return = element.return || element.value\n\t\tcase COMMENT: return ''\n\t\tcase KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'\n\t\tcase RULESET: if (!strlen(element.value = element.props.join(','))) return ''\n\t}\n\n\treturn strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''\n}\n","import {MS, MOZ, WEBKIT, RULESET, KEYFRAMES, DECLARATION} from './Enum.js'\nimport {match, charat, substr, strlen, sizeof, replace, combine, filter, assign} from './Utility.js'\nimport {copy, lift, tokenize} from './Tokenizer.js'\nimport {serialize} from './Serializer.js'\nimport {prefix} from './Prefixer.js'\n\n/**\n * @param {function[]} collection\n * @return {function}\n */\nexport function middleware (collection) {\n\tvar length = sizeof(collection)\n\n\treturn function (element, index, children, callback) {\n\t\tvar output = ''\n\n\t\tfor (var i = 0; i < length; i++)\n\t\t\toutput += collection[i](element, index, children, callback) || ''\n\n\t\treturn output\n\t}\n}\n\n/**\n * @param {function} callback\n * @return {function}\n */\nexport function rulesheet (callback) {\n\treturn function (element) {\n\t\tif (!element.root)\n\t\t\tif (element = element.return)\n\t\t\t\tcallback(element)\n\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n */\nexport function prefixer (element, index, children, callback) {\n\tif (element.length > -1)\n\t\tif (!element.return)\n\t\t\tswitch (element.type) {\n\t\t\t\tcase DECLARATION: element.return = prefix(element.value, element.length, children)\n\t\t\t\t\treturn\n\t\t\t\tcase KEYFRAMES:\n\t\t\t\t\treturn serialize([copy(element, {value: replace(element.value, '@', '@' + WEBKIT)})], callback)\n\t\t\t\tcase RULESET:\n\t\t\t\t\tif (element.length)\n\t\t\t\t\t\treturn combine(children = element.props, function (value) {\n\t\t\t\t\t\t\tswitch (match(value, callback = /(::plac\\w+|:read-\\w+)/)) {\n\t\t\t\t\t\t\t\t// :read-(only|write)\n\t\t\t\t\t\t\t\tcase ':read-only': case ':read-write':\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(read-\\w+)/, ':' + MOZ + '$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [value]}))\n\t\t\t\t\t\t\t\t\tassign(element, {props: filter(children, callback)})\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t// :placeholder\n\t\t\t\t\t\t\t\tcase '::placeholder':\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, ':' + WEBKIT + 'input-$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, ':' + MOZ + '$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, MS + 'input-$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [value]}))\n\t\t\t\t\t\t\t\t\tassign(element, {props: filter(children, callback)})\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn ''\n\t\t\t\t\t\t})\n\t\t\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n */\nexport function namespace (element) {\n\tswitch (element.type) {\n\t\tcase RULESET:\n\t\t\telement.props = element.props.map(function (value) {\n\t\t\t\treturn combine(tokenize(value), function (value, index, children) {\n\t\t\t\t\tswitch (charat(value, 0)) {\n\t\t\t\t\t\t// \\f\n\t\t\t\t\t\tcase 12:\n\t\t\t\t\t\t\treturn substr(value, 1, strlen(value))\n\t\t\t\t\t\t// \\0 ( + > ~\n\t\t\t\t\t\tcase 0: case 40: case 43: case 62: case 126:\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t// :\n\t\t\t\t\t\tcase 58:\n\t\t\t\t\t\t\tif (children[++index] === 'global')\n\t\t\t\t\t\t\t\tchildren[index] = '', children[++index] = '\\f' + substr(children[index], index = 1, -1)\n\t\t\t\t\t\t// \\s\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\treturn index === 1 ? '' : value\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tswitch (index) {\n\t\t\t\t\t\t\t\tcase 0: element = value\n\t\t\t\t\t\t\t\t\treturn sizeof(children) > 1 ? '' : value\n\t\t\t\t\t\t\t\tcase index = sizeof(children) - 1: case 2:\n\t\t\t\t\t\t\t\t\treturn index === 2 ? value + element + element : value + element\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t}\n}\n","import e from\"@emotion/is-prop-valid\";import t,{createElement as n}from\"react\";import*as o from\"stylis\";import{RULESET as s}from\"stylis\";var r,i;const c=\"undefined\"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||\"data-styled\",a=\"active\",l=\"data-styled-version\",u=\"6.5.3\",h=\"/*!sc*/\\n\",d=\"undefined\"!=typeof window&&\"undefined\"!=typeof document;function p(e){if(\"undefined\"!=typeof process&&void 0!==process.env){const t=process.env[e];if(void 0!==t&&\"\"!==t)return\"false\"!==t}}const f=Boolean(\"boolean\"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:null!==(i=null!==(r=p(\"REACT_APP_SC_DISABLE_SPEEDY\"))&&void 0!==r?r:p(\"SC_DISABLE_SPEEDY\"))&&void 0!==i?i:\"undefined\"!=typeof process&&void 0!==process.env&&\"production\"!==process.env.NODE_ENV),m=\"sc-keyframes-\",y={},g=\"production\"!==process.env.NODE_ENV?{1:\"Cannot create styled-component for component: %s.\\n\\n\",2:\"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\\n\\n- Are you trying to reuse it across renders?\\n- Are you accidentally calling collectStyles twice?\\n\\n\",3:\"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\\n\\n\",4:\"The `StyleSheetManager` expects a valid target or sheet prop!\\n\\n- Does this error occur on the client and is your target falsy?\\n- Does this error occur on the server and is the sheet falsy?\\n\\n\",5:\"The clone method cannot be used on the client!\\n\\n- Are you running in a client-like environment on the server?\\n- Are you trying to run SSR on the client?\\n\\n\",6:\"Trying to insert a new style tag, but the given Node is unmounted!\\n\\n- Are you using a custom target that isn't mounted?\\n- Does your document not have a valid head element?\\n- Have you accidentally removed a style tag manually?\\n\\n\",7:'ThemeProvider: Please return an object from your \"theme\" prop function, e.g.\\n\\n```js\\ntheme={() => ({})}\\n```\\n\\n',8:'ThemeProvider: Please make your \"theme\" prop an object.\\n\\n',9:\"Missing document ``\\n\\n\",10:\"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\\n\\n\",11:\"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\\n\\n\",12:\"It seems you are interpolating a keyframe declaration (%s) into an untagged string. Please wrap your string in the css\\\\`\\\\` helper which ensures the styles are injected correctly. See https://styled-components.com/docs/api#css\\n\\n\",13:\"%s is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.\\n\\n\",14:'ThemeProvider: \"theme\" prop is required.\\n\\n',15:\"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to ``, please make sure each plugin is uniquely-named, e.g.\\n\\n```js\\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\\n```\\n\\n\",16:\"Reached the limit of how many styled components may be created at group %s.\\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\\nas for instance in your render method then you may be running into this limitation.\\n\\n\",17:\"CSSStyleSheet could not be found on HTMLStyleElement.\\nHas styled-components' style tag been unmounted or altered by another script?\\n\\n\",18:\"Accessing `useTheme` hook outside of a `` element.\\n\\n```jsx\\nimport { useTheme } from 'styled-components';\\nexport function StyledCompoent({ children }) {\\n const theme = useTheme();\\n return {children}
;\\n}\\n\\nimport { StyledComponent } from './StyledComponent';\\nimport { theme } from './theme';\\nexport function App() {\\n return (\\n \\n \\n \\n );\\n}\\n```\\n\\nIf you need access to the theme in an uncertain composition scenario, `React.useContext(ThemeContext)` will not emit an error if there is no `ThemeProvider` ancestor.\\n\"}:{};function v(e,...t){return\"production\"===process.env.NODE_ENV?new Error(`An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#${e} for more information.${t.length>0?` Args: ${t.join(\", \")}`:\"\"}`):new Error(function(...e){let t=e[0];const n=[];for(let t=1,o=e.length;t{t=t.replace(/%[a-z]/,e)}),t}(g[e],...t).trim())}const S=1<<30;let b=new Map,w=new Map,N=1;const C=e=>{if(b.has(e))return b.get(e);for(;w.has(N);)N++;const t=N++;if(\"production\"!==process.env.NODE_ENV&&((0|t)<0||t>S))throw v(16,`${t}`);return b.set(e,t),w.set(t,e),t},O=e=>w.get(e),E=(e,t)=>{N=t+1,b.set(e,t),w.set(t,e)},A=/invalid hook call/i,P=new Set,_=(e,n)=>{if(\"production\"!==process.env.NODE_ENV){const o=`The component ${e}${n?` with the id of \"${n}\"`:\"\"} has been created dynamically.\\nYou may see this warning because you've called styled inside another component.\\nTo resolve this only create new StyledComponents outside of any render method and function component.\\nSee https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.\\n`,s=console.error;try{let e=!0;console.error=(t,...n)=>{A.test(t)?(e=!1,P.delete(o)):s(t,...n)},\"function\"==typeof t.useState&&t.useState(null),e&&!P.has(o)&&(console.warn(o),P.add(o))}catch(e){A.test(e.message)&&P.delete(o)}finally{console.error=s}}},I=Object.freeze([]),$=Object.freeze({});function R(e,t,n=$){return e.theme!==n.theme&&e.theme||t||n.theme}const j=/[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~-]+/g,x=/(^-|-$)/g;function T(e){return e.replace(j,\"-\").replace(x,\"\")}const k=/(a)(d)/gi,D=e=>String.fromCharCode(e+(e>25?39:97));function V(e){let t,n=\"\";for(t=Math.abs(e);t>52;t=t/52|0)n=D(t%52)+n;return(D(t%52)+n).replace(k,\"$1-$2\")}const M=5381,G=(e,t)=>{let n=t.length;for(;n;)e=33*e^t.charCodeAt(--n);return e},F=e=>G(M,e);function z(e){return V(F(e)>>>0)}function W(e){return\"production\"!==process.env.NODE_ENV&&\"string\"==typeof e&&e||e.displayName||e.name||\"Component\"}function L(e){return\"string\"==typeof e&&(\"production\"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}function B(e){return L(e)?`styled.${e}`:`Styled(${W(e)})`}const q=Symbol.for(\"react.memo\"),H=Symbol.for(\"react.forward_ref\"),Y={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},U={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},J={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},X={[H]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[q]:J};function K(e){return(\"type\"in(t=e)&&t.type.$$typeof)===q?J:\"$$typeof\"in e?X[e.$$typeof]:Y;var t}const Q=Object.defineProperty,Z=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,te=Object.getOwnPropertyDescriptor,ne=Object.getPrototypeOf,oe=Object.prototype;function se(e,t,n){if(\"string\"!=typeof t){const o=ne(t);o&&o!==oe&&se(e,o,n);const s=Z(t).concat(ee(t)),r=K(e),i=K(t);for(let o=0;othis._cGroup)for(let n=this._cGroup;n=e;n--)t-=this.groupSizes[n];return this._cGroup=e,this._cIndex=t,t}insertRules(e,t){if(e>=this.groupSizes.length){const t=this.groupSizes,n=t.length;let o=n;for(;e>=o;)if(o<<=1,o<0)throw v(16,`${e}`);this.groupSizes=new Uint32Array(o),this.groupSizes.set(t),this.length=o;for(let e=n;e0&&this._cGroup>e&&(this._cIndex+=o)}clearGroup(e){if(e0&&this._cGroup>e&&(this._cIndex-=t)}}getGroup(e){let t=\"\";if(e>=this.length||0===this.groupSizes[e])return t;const n=this.groupSizes[e],o=this.indexOfGroup(e),s=o+n;for(let e=o;e\"undefined\"!=typeof ShadowRoot&&e instanceof ShadowRoot||\"host\"in e&&11===e.nodeType,ge=e=>{if(!e)return document;if(ye(e))return e;if(\"getRootNode\"in e){const t=e.getRootNode();if(ye(t))return t}return document},ve=(e,t,n)=>{const o=n.split(\",\");let s;for(let n=0,r=o.length;n{var n;const o=(null!==(n=t.textContent)&&void 0!==n?n:\"\").split(h),s=[];for(let t=0,n=o.length;t{const t=ge(e.options.target).querySelectorAll(fe);for(let n=0,o=t.length;n{const n=document.head,o=e||n,s=document.createElement(\"style\"),r=(e=>{const t=Array.from(e.querySelectorAll(`style[${c}]`));return t[t.length-1]})(o),i=void 0!==r?r.nextSibling:null;s.setAttribute(c,a),s.setAttribute(l,u);const h=t||Ne();return h&&s.setAttribute(\"nonce\",h),o.insertBefore(s,i),s},Oe=class{constructor(e,t){this.element=Ce(e,t),this.element.appendChild(document.createTextNode(\"\")),this.sheet=(e=>{var t;if(e.sheet)return e.sheet;const n=null!==(t=e.getRootNode().styleSheets)&&void 0!==t?t:document.styleSheets;for(let t=0,o=n.length;t=0){const n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e(e=>{const t=e.getTag(),{length:n}=t;let o=\"\";for(let s=0;s0&&(l+=e+\",\");o+=i+a+'{content:\"'+l+'\"}'+h}return o})(this))}rehydrate(){!this.server&&d&&be(this)}reconstructWithOptions(e,t=!0){const n=new _e(Object.assign(Object.assign({},this.options),e),this.gs,t&&this.names||void 0);return n.keyframeIds=new Set(this.keyframeIds),!this.server&&d&&e.target!==this.options.target&&ge(this.options.target)!==ge(e.target)&&be(n),n}allocateGSInstance(e){return this.gs[e]=(this.gs[e]||0)+1}getTag(){return this.tag||(this.tag=(e=(({useCSSOMInjection:e,target:t,nonce:n})=>e?new Oe(t,n):new Ee(t,n))(this.options),new pe(e)));var e}hasNameForId(e,t){var n,o;return null!==(o=null===(n=this.names.get(e))||void 0===n?void 0:n.has(t))&&void 0!==o&&o}registerName(e,t){C(e),e.startsWith(m)&&this.keyframeIds.add(e);const n=this.names.get(e);n?n.add(t):this.names.set(e,new Set([t]))}insertRules(e,t,n){this.registerName(e,t),this.getTag().insertRules(C(e),n)}clearNames(e){this.names.has(e)&&this.names.get(e).clear()}clearRules(e){this.getTag().clearGroup(C(e)),this.clearNames(e)}clearTag(){this.tag=void 0}}const Ie=new WeakSet,$e={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function Re(e,t){return null==t||\"boolean\"==typeof t||\"\"===t?\"\":\"number\"!=typeof t||0===t||e in $e||e.startsWith(\"--\")?String(t).trim():t+\"px\"}const je=47;function xe(e){if(45===e.charCodeAt(0)&&45===e.charCodeAt(1))return e;let t=\"\";for(let n=0;n=65&&o<=90?\"-\"+String.fromCharCode(o+32):e[n]}return t.startsWith(\"ms-\")?\"-\"+t:t}const Te=Symbol.for(\"sc-keyframes\");function ke(e){return\"object\"==typeof e&&null!==e&&Te in e}function De(e){return re(e)&&!(e.prototype&&e.prototype.isReactComponent)}const Ve=e=>null==e||!1===e||\"\"===e,Me=Symbol.for(\"react.client.reference\");function Ge(e){return e.$$typeof===Me}function Fe(e){const t=e.$$id,n=(t&&t.includes(\"#\")?t.split(\"#\").pop():t)||e.name||\"unknown\";console.warn(`Interpolating a client component (${n}) as a selector is not supported in server components. The component selector pattern requires access to the component's internal class name, which is not available across the server/client boundary. Use a plain CSS class selector instead.`)}function ze(e,t){for(const n in e){const o=e[n];e.hasOwnProperty(n)&&!Ve(o)&&(Array.isArray(o)&&Ie.has(o)||re(o)?t.push(xe(n)+\":\",o,\";\"):ue(o)?(t.push(n+\" {\"),ze(o,t),t.push(\"}\")):t.push(xe(n)+\": \"+Re(n,o)+\";\"))}}function We(e,t,n,o,s=[]){if(Ve(e))return s;const r=typeof e;if(\"string\"===r)return s.push(e),s;if(\"function\"===r){if(Ge(e))return\"production\"!==process.env.NODE_ENV&&Fe(e),s;if(De(e)&&t){const r=e(t);return\"production\"===process.env.NODE_ENV||\"object\"!=typeof r||Array.isArray(r)||ke(r)||ue(r)||null===r||console.error(`${W(e)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),We(r,t,n,o,s)}return s.push(e),s}if(Array.isArray(e)){for(let r=0;r>>0),this.dynamicNameCache.size>=200){const e=this.dynamicNameCache.keys().next().value;void 0!==e&&this.dynamicNameCache.delete(e)}this.dynamicNameCache.set(e,r)}if(!t.hasNameForId(this.componentId,r)){const e=n(s,\".\"+r,void 0,this.componentId);t.insertRules(this.componentId,r,e)}o=ae(o,r)}}return o}}const qe=/&/g;function He(e,t){let n=0;for(;--t>=0&&92===e.charCodeAt(t);)n++;return!(1&~n)}function Ye(e){const t=e.length;let n=\"\",o=0,s=0,r=0,i=!1,c=!1;for(let a=0;ao.startsWith(s)&&o.endsWith(s)&&o.replaceAll(s,\"\").length>0?`.${n}`:e,c=t.slice();c.push(e=>{e.type===o.RULESET&&e.value.includes(\"&\")&&(r||(r=new RegExp(`\\\\${s}\\\\b`,\"g\")),e.props[0]=e.props[0].replace(qe,s).replace(r,i))}),e.prefix&&c.push(o.prefixer),c.push(o.stringify);let a=[];const l=o.middleware(c.concat(o.rulesheet(e=>a.push(e)))),u=(t,i=\"\",c=\"\",u=\"&\")=>{n=u,s=i,r=void 0;const h=function(e){const t=-1!==e.indexOf(\"//\"),n=-1!==e.indexOf(\"}\");if(!t&&!n)return e;if(!t)return Ye(e);const o=e.length;let s=\"\",r=0,i=0,c=0,a=0,l=0,u=!1;for(;i0)i++;else if(42===t&&i+10&&a--,i++;else a++,i++;else i++;else 0===c?c=t:c===t&&(c=0),i++}return u?(r{let t=s;return e.sheet?t=e.sheet:e.target?t=t.reconstructWithOptions(void 0!==e.nonce?{target:e.target,nonce:e.nonce}:{target:e.target},!1):void 0!==e.nonce&&(t=t.reconstructWithOptions({nonce:e.nonce})),e.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[e.disableCSSOMInjection,e.nonce,e.sheet,e.target,s]),i=t.useMemo(()=>{var t;return void 0===e.stylisPlugins&&void 0===e.namespace&&void 0===e.enableVendorPrefixes?o.stylis:Je({options:{namespace:e.namespace,prefix:e.enableVendorPrefixes},plugins:null!==(t=e.stylisPlugins)&&void 0!==t?t:o.stylisPlugins})},[e.enableVendorPrefixes,e.namespace,e.stylisPlugins,o.stylis,o.stylisPlugins]),c=\"shouldForwardProp\"in e?e.shouldForwardProp:o.shouldForwardProp,a=null!==(n=e.stylisPlugins)&&void 0!==n?n:o.stylisPlugins,l=t.useMemo(()=>({shouldForwardProp:c,styleSheet:r,stylis:i,stylisPlugins:a}),[c,r,i,a]);return t.createElement(Qe.Provider,{value:l},e.children)}const nt=t.createContext(void 0),ot=nt.Consumer;function st(){const e=t.useContext(nt);if(!e)throw v(18);return e}function rt(e){const n=t.useContext(nt),o=t.useMemo(()=>function(e,t){if(!e)throw v(14);if(re(e)){const n=e(t);if(\"production\"!==process.env.NODE_ENV&&(null===n||Array.isArray(n)||\"object\"!=typeof n))throw v(7);return n}if(Array.isArray(e)||\"object\"!=typeof e)throw v(8);return t?Object.assign(Object.assign({},t),e):e}(e.theme,n),[e.theme,n]);return e.children?t.createElement(nt.Provider,{value:o},e.children):null}const it=Object.prototype.hasOwnProperty,ct={};function at(e,t){const n=\"string\"!=typeof e?\"sc\":T(e);ct[n]=(ct[n]||0)+1;const o=n+\"-\"+z(u+n+ct[n]);return t?t+\"-\"+o:o}let lt;function ut(o,s,r){const i=ce(o),c=o,a=!L(o),{attrs:l=I,componentId:u=at(s.displayName,s.parentComponentId),displayName:h=B(o)}=s,d=s.displayName&&s.componentId?T(s.displayName)+\"-\"+s.componentId:s.componentId||u,p=i&&c.attrs?c.attrs.concat(l).filter(Boolean):l;let{shouldForwardProp:f}=s;if(i&&c.shouldForwardProp){const e=c.shouldForwardProp;if(s.shouldForwardProp){const t=s.shouldForwardProp;f=(n,o)=>e(n,o)&&t(n,o)}else f=e}const m=new Be(r,d,i?c.componentStyle:void 0);function y(o,s){return function(o,s,r){const{attrs:i,componentStyle:c,defaultProps:a,foldedComponentIds:l,styledComponentId:u,target:h}=o,d=t.useContext(nt),p=et(),f=o.shouldForwardProp||p.shouldForwardProp;\"production\"!==process.env.NODE_ENV&&t.useDebugValue&&t.useDebugValue(u);const m=R(s,d,a)||$;let y,g;{const e=t.useRef(null),n=e.current;if(null!==n&&n[1]===m&&n[2]===p.styleSheet&&n[3]===p.stylis&&n[7]===c&&function(e,t,n){const o=e,s=t;let r=0;for(const e in s)if(it.call(s,e)&&(r++,o[e]!==s[e]))return!1;return r===n}(n[0],s,n[4]))y=n[5],g=n[6];else{y=function(e,t,n){const o=Object.assign(Object.assign({},t),{className:void 0,theme:n}),s=e.length>1;for(let n=0;n\\` (connect an API like \\`@emotion/is-prop-valid\\`) or consider using transient props (\\`$\\` prefix for automatic filtering.)`))));return r}(y,v,m,f);let b=ae(l,u);return g&&(b+=\" \"+g),y.className&&(b+=\" \"+y.className),S[L(v)&&v.includes(\"-\")?\"class\":\"className\"]=b,r&&(S.ref=r),n(v,S)}(g,o,s)}y.displayName=h;let g=t.forwardRef(y);return g.attrs=p,g.componentStyle=m,g.displayName=h,g.shouldForwardProp=f,g.foldedComponentIds=i?ae(c.foldedComponentIds,c.styledComponentId):\"\",g.styledComponentId=d,g.target=i?c.target:o,Object.defineProperty(g,\"defaultProps\",{get(){return this._foldedDefaultProps},set(e){this._foldedDefaultProps=i?function(e,...t){for(const n of t)he(e,n,!0);return e}({},c.defaultProps,e):e}}),\"production\"!==process.env.NODE_ENV&&(_(h,d),g.warnTooManyClasses=((e,t)=>{let n={},o=!1;return s=>{!o&&(n[s]=!0,Object.keys(n).length>=200)&&(console.warn(`Over 200 classes were generated for component ${e}${t?` with the id of \"${t}\"`:\"\"}.\\nConsider using the attrs method, together with a style object for frequently changed styles.\\nExample:\\n const Component = styled.div.attrs(props => ({\\n style: {\\n background: props.background,\\n },\\n }))\\`width: 100%;\\`\\n\\n `),o=!0,n={})}})(h,d)),de(g,()=>`.${g.styledComponentId}`),a&&se(g,o,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),g}var ht=new Set([\"a\",\"abbr\",\"address\",\"area\",\"article\",\"aside\",\"audio\",\"b\",\"bdi\",\"bdo\",\"blockquote\",\"body\",\"button\",\"br\",\"canvas\",\"caption\",\"cite\",\"code\",\"col\",\"colgroup\",\"data\",\"datalist\",\"dd\",\"del\",\"details\",\"dfn\",\"dialog\",\"div\",\"dl\",\"dt\",\"em\",\"embed\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hgroup\",\"hr\",\"html\",\"i\",\"iframe\",\"img\",\"input\",\"ins\",\"kbd\",\"label\",\"legend\",\"li\",\"main\",\"map\",\"mark\",\"menu\",\"meter\",\"nav\",\"object\",\"ol\",\"optgroup\",\"option\",\"output\",\"p\",\"picture\",\"pre\",\"progress\",\"q\",\"rp\",\"rt\",\"ruby\",\"s\",\"samp\",\"search\",\"section\",\"select\",\"slot\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"template\",\"textarea\",\"tfoot\",\"th\",\"thead\",\"time\",\"tr\",\"u\",\"ul\",\"var\",\"video\",\"wbr\",\"circle\",\"clipPath\",\"defs\",\"ellipse\",\"feBlend\",\"feColorMatrix\",\"feComponentTransfer\",\"feComposite\",\"feConvolveMatrix\",\"feDiffuseLighting\",\"feDisplacementMap\",\"feDistantLight\",\"feDropShadow\",\"feFlood\",\"feFuncA\",\"feFuncB\",\"feFuncG\",\"feFuncR\",\"feGaussianBlur\",\"feImage\",\"feMerge\",\"feMergeNode\",\"feMorphology\",\"feOffset\",\"fePointLight\",\"feSpecularLighting\",\"feSpotLight\",\"feTile\",\"feTurbulence\",\"filter\",\"foreignObject\",\"g\",\"image\",\"line\",\"linearGradient\",\"marker\",\"mask\",\"path\",\"pattern\",\"polygon\",\"polyline\",\"radialGradient\",\"rect\",\"stop\",\"svg\",\"switch\",\"symbol\",\"text\",\"textPath\",\"tspan\",\"use\"]);function dt(e,t){const n=[e[0]];for(let o=0,s=t.length;o(Ie.add(e),e);function ft(e,...t){if(re(e)||ue(e))return pt(We(dt(I,[e,...t])));const n=e;return 0===t.length&&1===n.length&&\"string\"==typeof n[0]?We(n):pt(We(dt(n,t)))}function mt(e,t,n=$){if(!t)throw v(1,t);const o=(o,...s)=>e(t,n,ft(o,...s));return o.attrs=o=>mt(e,t,Object.assign(Object.assign({},n),{attrs:Array.prototype.concat(n.attrs,o).filter(Boolean)})),o.withConfig=o=>mt(e,t,Object.assign(Object.assign({},n),o)),o}const yt=e=>mt(ut,e),gt=yt;ht.forEach(e=>{gt[e]=yt(e)});class vt{constructor(e,t){this.instanceRules=new Map,this.rules=e,this.componentId=t,this.isStatic=function(e){for(let t=0;t{const n=et(),i=t.useContext(nt);let a;{const e=t.useRef(null);null===e.current&&(e.current=n.styleSheet.allocateGSInstance(s)),a=e.current}\"production\"!==process.env.NODE_ENV&&t.Children.count(e.children)&&console.warn(`The global style component ${s} was given child JSX. createGlobalStyle does not render children.`),\"production\"!==process.env.NODE_ENV&&o.some(e=>\"string\"==typeof e&&-1!==e.indexOf(\"@import\"))&&console.warn(\"Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical meta tag to the stylesheet, or simply embedding it manually in your index.html section for a simpler app.\"),n.styleSheet.server&&c(a,e,n.styleSheet,i,n.stylis);{const o=r.isStatic?[a,n.styleSheet,r]:[a,e,n.styleSheet,i,n.stylis,r],l=t.useRef(r);t.useLayoutEffect(()=>{n.styleSheet.server||(l.current!==r&&(n.styleSheet.clearRules(s),l.current=r),c(a,e,n.styleSheet,i,n.stylis))},o),t.useLayoutEffect(()=>()=>{n.styleSheet.server||r.removeStyles(a,n.styleSheet)},[a,n.styleSheet,r])}return n.styleSheet.server&&r.instanceRules.delete(a),null};function c(e,t,n,o,s){if(r.isStatic)r.renderStyles(e,y,n,s);else{const c=Object.assign(Object.assign({},t),{theme:R(t,o,i.defaultProps)});r.renderStyles(e,c,n,s)}}return t.memo(i)}function bt(e,t,n,o,s){for(const r in e){const i=e[r],c=s?s+\"-\"+r:r;if(\"object\"==typeof i&&null!==i){const e={};bt(i,t,e,o,c),n[r]=e}else n[r]=o(c,i,r)}}function wt(e,t,n,o){let s=\"\";for(const r in e){const i=e[r],c=t[r],a=o?o+\"-\"+r:r;\"object\"==typeof i&&null!==i?\"object\"==typeof c&&null!==c&&(s+=wt(i,c,n,a)):void 0!==c&&\"function\"!=typeof c&&(s+=\"--\"+n+a+\":\"+c+\";\")}return s}function Nt(e,t){var n,o;const s=(null!==(n=null==t?void 0:t.prefix)&&void 0!==n?n:\"sc\")+\"-\",r=null!==(o=null==t?void 0:t.selector)&&void 0!==o?o:\":root\",i=function(e,t){const n={};return bt(e,t,n,e=>\"--\"+t+e),n}(e,s),c=function(e,t){const n={};return bt(e,t,n,(e,n)=>{if(\"production\"!==process.env.NODE_ENV){const t=String(n);let o=0;for(let e=0;ewt(e,t.theme,s)}\n }\n `;return Object.assign(c,{GlobalStyle:a,raw:e,vars:i,resolve(t){if(!d)throw new Error(\"createTheme.resolve() is client-only\");const n=null!=t?t:document.documentElement;return function(e,t,n){const o={};return bt(e,t,o,(e,o)=>n.getPropertyValue(\"--\"+t+e).trim()||o),o}(e,s,getComputedStyle(n))}})}var Ct;class Ot{constructor(e,t){this[Ct]=!0,this.inject=(e,t=Ke)=>{const n=this.getName(t);if(!e.hasNameForId(this.id,n)){const o=t(this.rules,n,\"@keyframes\");e.insertRules(this.id,n,o)}},this.name=e,this.id=m+e,this.rules=t,C(this.id),de(this,()=>{throw v(12,String(this.name))})}getName(e=Ke){return e.hash?this.name+V(+e.hash>>>0):this.name}}function Et(e,...t){\"production\"!==process.env.NODE_ENV&&\"undefined\"!=typeof navigator&&\"ReactNative\"===navigator.product&&console.warn(\"`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.\");const n=le(ft(e,...t)),o=z(n);return new Ot(o,n)}function At(e){const n=t.forwardRef((n,o)=>{const s=R(n,t.useContext(nt),e.defaultProps);return\"production\"!==process.env.NODE_ENV&&void 0===s&&console.warn(`[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"${W(e)}\"`),t.createElement(e,Object.assign(Object.assign({},n),{theme:s,ref:o}))});return n.displayName=`WithTheme(${W(e)})`,se(n,e)}Ct=Te;class Pt{constructor({nonce:e}={}){this._emitSheetCSS=()=>{const e=this.instance.toString();if(!e)return\"\";const t=this.instance.options.nonce||Ne();return``},this.getStyleTags=()=>{if(this.sealed)throw v(2);return this._emitSheetCSS()},this.getStyleElement=()=>{if(this.sealed)throw v(2);const e=this.instance.toString();if(!e)return[];const n={[c]:\"\",[l]:u,dangerouslySetInnerHTML:{__html:e}},o=this.instance.options.nonce||Ne();return o&&(n.nonce=o),[t.createElement(\"style\",Object.assign({},n,{key:\"sc-0-0\"}))]},this.seal=()=>{this.sealed=!0},this.instance=new _e({isServer:!0,nonce:e}),this.sealed=!1}collectStyles(e){if(this.sealed)throw v(2);return t.createElement(tt,{sheet:this.instance},e)}interleaveWithNodeStream(e){throw v(3)}}const _t={StyleSheet:_e,mainSheet:Xe};\"production\"!==process.env.NODE_ENV&&\"undefined\"!=typeof navigator&&\"ReactNative\"===navigator.product&&console.warn(\"It looks like you've imported 'styled-components' on React Native.\\nPerhaps you're looking to import 'styled-components/native'?\\nRead more about this at https://styled-components.com/docs/basics#react-native\");const It=`__sc-${c}__`;\"production\"!==process.env.NODE_ENV&&\"test\"!==process.env.NODE_ENV&&\"undefined\"!=typeof window&&(window[It]||(window[It]=0),1===window[It]&&console.warn(\"It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\\n\\nSee https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page for more info.\"),window[It]+=1);const $t=/:(?:(first)-child|(last)-child|(only)-child|(nth-child)\\(([^()]+)\\)|(nth-last-child)\\(([^()]+)\\))/g,Rt=`:not(style[${c}])`,jt=`style[${c}]`;function xt(e){return-1===e.indexOf(\"-child\")?e:($t.lastIndex=0,e.replace($t,(e,t,n,o,s,r,i,c)=>t?`:nth-child(1 of ${Rt})`:n?`:nth-last-child(1 of ${Rt})`:o?`:nth-child(1 of ${Rt}):nth-last-child(1 of ${Rt})`:s?-1!==r.indexOf(\" of \")?e:`:nth-child(${r} of ${Rt})`:-1!==c.indexOf(\" of \")?e:`:nth-last-child(${c} of ${Rt})`))}function Tt(e,t){if(-1===e.indexOf(\"+\"))return;let n=0,o=0;for(let s=0;s \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright OpenJS Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used to detect hot functions by number of calls within a span of milliseconds. */\nvar HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n asyncTag = '[object AsyncFunction]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n nullTag = '[object Null]',\n objectTag = '[object Object]',\n proxyTag = '[object Proxy]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n undefinedTag = '[object Undefined]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined,\n Symbol = root.Symbol,\n Uint8Array = root.Uint8Array,\n allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,\n getPrototype = overArg(Object.getPrototypeOf, Object),\n objectCreate = Object.create,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\nvar defineProperty = (function() {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n}());\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,\n nativeMax = Math.max,\n nativeNow = Date.now;\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map'),\n nativeCreate = getNative(Object, 'create');\n\n/**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} proto The object to inherit from.\n * @returns {Object} Returns the new object.\n */\nvar baseCreate = (function() {\n function object() {}\n return function(proto) {\n if (!isObject(proto)) {\n return {};\n }\n if (objectCreate) {\n return objectCreate(proto);\n }\n object.prototype = proto;\n var result = new object;\n object.prototype = undefined;\n return result;\n };\n}());\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\n/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\n/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * This function is like `assignValue` except that it doesn't assign\n * `undefined` values.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignMergeValue(object, key, value) {\n if ((value !== undefined && !eq(object[key], value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n}\n\n/**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n}\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n}\n\n/**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\nvar baseFor = createBaseFor();\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.merge` without support for multiple sources.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMerge(object, source, srcIndex, customizer, stack) {\n if (object === source) {\n return;\n }\n baseFor(source, function(srcValue, key) {\n stack || (stack = new Stack);\n if (isObject(srcValue)) {\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n }\n else {\n var newValue = customizer\n ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)\n : undefined;\n\n if (newValue === undefined) {\n newValue = srcValue;\n }\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n}\n\n/**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n var objValue = safeGet(object, key),\n srcValue = safeGet(source, key),\n stacked = stack.get(srcValue);\n\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n var newValue = customizer\n ? customizer(objValue, srcValue, (key + ''), object, source, stack)\n : undefined;\n\n var isCommon = newValue === undefined;\n\n if (isCommon) {\n var isArr = isArray(srcValue),\n isBuff = !isArr && isBuffer(srcValue),\n isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n\n newValue = srcValue;\n if (isArr || isBuff || isTyped) {\n if (isArray(objValue)) {\n newValue = objValue;\n }\n else if (isArrayLikeObject(objValue)) {\n newValue = copyArray(objValue);\n }\n else if (isBuff) {\n isCommon = false;\n newValue = cloneBuffer(srcValue, true);\n }\n else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n }\n else {\n newValue = [];\n }\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n }\n else if (!isObject(objValue) || isFunction(objValue)) {\n newValue = initCloneObject(srcValue);\n }\n }\n else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n}\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n}\n\n/**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar baseSetToString = !defineProperty ? identity : function(func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n};\n\n/**\n * Creates a clone of `buffer`.\n *\n * @private\n * @param {Buffer} buffer The buffer to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Buffer} Returns the cloned buffer.\n */\nfunction cloneBuffer(buffer, isDeep) {\n if (isDeep) {\n return buffer.slice();\n }\n var length = buffer.length,\n result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n\n buffer.copy(result);\n return result;\n}\n\n/**\n * Creates a clone of `arrayBuffer`.\n *\n * @private\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\nfunction cloneArrayBuffer(arrayBuffer) {\n var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n}\n\n/**\n * Creates a clone of `typedArray`.\n *\n * @private\n * @param {Object} typedArray The typed array to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned typed array.\n */\nfunction cloneTypedArray(typedArray, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n}\n\n/**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\nfunction copyArray(source, array) {\n var index = -1,\n length = source.length;\n\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n}\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\n/**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\n/**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\nfunction initCloneObject(object) {\n return (typeof object.constructor == 'function' && !isPrototype(object))\n ? baseCreate(getPrototype(object))\n : {};\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\n/**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\nfunction overRest(func, start, transform) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n}\n\n/**\n * Gets the value at `key`, unless `key` is \"__proto__\" or \"constructor\".\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction safeGet(object, key) {\n if (key === 'constructor' && typeof object[key] === 'function') {\n return;\n }\n\n if (key == '__proto__') {\n return;\n }\n\n return object[key];\n}\n\n/**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar setToString = shortOut(baseSetToString);\n\n/**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\nfunction shortOut(func) {\n var count = 0,\n lastCalled = 0;\n\n return function() {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n/**\n * Converts `value` to a plain object flattening inherited enumerable string\n * keyed properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\nfunction toPlainObject(value) {\n return copyObject(value, keysIn(value));\n}\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\n\n/**\n * This method is like `_.assign` except that it recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to `undefined` are\n * skipped if a destination value exists. Array and plain object properties\n * are merged recursively. Other objects and value types are overridden by\n * assignment. Source objects are applied from left to right. Subsequent\n * sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {\n * 'a': [{ 'b': 2 }, { 'd': 4 }]\n * };\n *\n * var other = {\n * 'a': [{ 'c': 3 }, { 'e': 5 }]\n * };\n *\n * _.merge(object, other);\n * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }\n */\nvar merge = createAssigner(function(object, source, srcIndex) {\n baseMerge(object, source, srcIndex);\n});\n\n/**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\nfunction constant(value) {\n return function() {\n return value;\n };\n}\n\n/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\n\n/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nmodule.exports = merge;\n","function _arrayLikeToArray(r, a) {\n (null == a || a > r.length) && (a = r.length);\n for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n return n;\n}\nexport { _arrayLikeToArray as default };","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nfunction _arrayWithoutHoles(r) {\n if (Array.isArray(r)) return arrayLikeToArray(r);\n}\nexport { _arrayWithoutHoles as default };","function _iterableToArray(r) {\n if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r);\n}\nexport { _iterableToArray as default };","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nfunction _unsupportedIterableToArray(r, a) {\n if (r) {\n if (\"string\" == typeof r) return arrayLikeToArray(r, a);\n var t = {}.toString.call(r).slice(8, -1);\n return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;\n }\n}\nexport { _unsupportedIterableToArray as default };","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _nonIterableSpread as default };","import arrayWithoutHoles from \"./arrayWithoutHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableSpread from \"./nonIterableSpread.js\";\nfunction _toConsumableArray(r) {\n return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();\n}\nexport { _toConsumableArray as default };","import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nexport function generateClassNames(componentName, subClassNames) {\n var generateClassName = function generateClassName(subClassName) {\n return \"Sfx\".concat(componentName).concat(subClassName ? \"-\".concat(subClassName) : '');\n };\n var classNameArray = [];\n if (subClassNames) {\n if (Array.isArray(subClassNames)) {\n classNameArray.push.apply(classNameArray, _toConsumableArray(subClassNames.filter(function (subClassName) {\n return typeof subClassName === 'string';\n }).map(function (subClassName) {\n return generateClassName(subClassName);\n })));\n } else if (typeof subClassNames === 'string') {\n classNameArray.push(generateClassName(subClassNames));\n }\n }\n if (classNameArray.length === 0) {\n classNameArray.push(generateClassName());\n }\n return classNameArray.join(' ');\n}","import { forwardRef } from 'react';\n/**\r\n * Wrapper around React's `forwardRef` function, which adds a `displayName` to each component\r\n * created using it\r\n */\nexport function intrinsicComponent(render, displayName) {\n var component = /*#__PURE__*/forwardRef(render);\n component.displayName = displayName || render.name;\n return component;\n}","/**\r\n * If your prop can be either a function or a plain value, this function handles\r\n * its usage for you – just provide the reference for a 'maybe function' and the arguments\r\n * to call it with\r\n */\nexport function applyPolymorphicFunctionProp(prop) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n return typeof prop === 'function' ? prop.apply(void 0, args) : prop;\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\n/**\r\n * If you are using a namespace for your styled components, this can come in handy giving each\r\n * styled component in this namespace a displayName which gives better debugging experience\r\n */\nexport function applyDisplayNames(styledObject) {\n return Object.keys(styledObject).reduce(function (newStyledObject, styledComponentName) {\n var styledComponent = styledObject[styledComponentName];\n styledComponent.displayName = \"\".concat(styledComponentName);\n return Object.assign(newStyledObject, _defineProperty({}, styledComponentName, styledComponent));\n }, {});\n}","/**\r\n * passes {value} to {ref}\r\n * Useful if you want to expose the ref of an inner component to the public API\r\n * while still using it inside the component.\r\n * @param ref A ref callback or ref object. If anything falsy, this is a no-op.\r\n */\nexport default function setRef(ref, value) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}","import * as React from 'react';\nimport setRef from './set-ref';\nexport function useForkRef(refA, refB) {\n /**\r\n * This will create a new function if the ref props change and are defined.\r\n * This means react will call the old forkRef with `null` and the new forkRef\r\n * with the ref. Cleanup naturally emerges from this behavior.\r\n */\n return React.useMemo(function () {\n if (refA == null && refB == null) {\n return null;\n }\n return function (refValue) {\n setRef(refA, refValue);\n setRef(refB, refValue);\n };\n }, [refA, refB]);\n}","export function restrictNumber(number) {\n var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var max = arguments.length > 2 ? arguments[2] : undefined;\n // we are not assigning default value for it as if max was null it will override the default value.\n var currentMax = max || 1000000;\n var convertedNumber = +number;\n return Math.min(Math.max(min, convertedNumber), currentMax);\n}","export function mapNumber(number, oldMin, oldMax, newMin, newMax) {\n return (number - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin;\n}","import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nexport var rgbStringToArray = function rgbStringToArray(rgbColorString) {\n return rgbColorString.replaceAll(/[^\\d,]/gi, '').split(',').map(function (n) {\n return +n;\n });\n};\nexport var hexToRgb = function hexToRgb(hexColor) {\n // if (!hexColor) return { r: 0, g: 0, b: 0 };\n if (!hexColor) return [0, 0, 0];\n return [Number.parseInt(hexColor.slice(1, 3), 16), Number.parseInt(hexColor.slice(3, 5), 16), Number.parseInt(hexColor.slice(5, 7), 16)];\n};\nvar rgbChannelToHex = function rgbChannelToHex(channel) {\n return channel.toString(16).padStart(2, '0');\n};\nexport var rgbToHex = function rgbToHex() {\n for (var _len = arguments.length, rgbColor = new Array(_len), _key = 0; _key < _len; _key++) {\n rgbColor[_key] = arguments[_key];\n }\n return \"#\".concat(rgbColor.map(rgbChannelToHex).join(''));\n};\nexport var hslToHex = function hslToHex(h, s, l) {\n var dividedL = l / 100;\n var a = s * Math.min(dividedL, 1 - dividedL) / 100;\n var f = function f(n) {\n var k = (n + h / 30) % 12;\n var color = dividedL - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n return rgbChannelToHex(Math.round(255 * color));\n };\n return \"#\".concat(f(0)).concat(f(8)).concat(f(4));\n};\nexport var rgbToHsl = function rgbToHsl() {\n for (var _len2 = arguments.length, rgbColor = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n rgbColor[_key2] = arguments[_key2];\n }\n var r = rgbColor[0],\n g = rgbColor[1],\n b = rgbColor[2];\n r /= 255;\n g /= 255;\n b /= 255;\n var min = Math.min(r, g, b);\n var max = Math.max(r, g, b);\n var h;\n var s;\n var l = (max + min) / 2;\n if (max === min) {\n h = 0;\n s = 0;\n } else {\n var diff = max - min;\n s = l > 0.5 ? diff / (2 - max - min) : diff / (max + min);\n switch (max) {\n case r:\n h = (g - b) / diff + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / diff + 2;\n break;\n case b:\n h = (r - g) / diff + 4;\n break;\n default:\n h = 0;\n }\n h /= 6;\n }\n\n // * 360 for having the hue in degrees\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)];\n};\nexport var colorToHsl = function colorToHsl(color) {\n if (color.startsWith('#')) {\n var hex = color;\n if (color.length === 4) {\n hex = \"#\".concat(color[1]).concat(color[1]).concat(color[2]).concat(color[2]).concat(color[3]).concat(color[3]);\n }\n return rgbToHsl.apply(void 0, _toConsumableArray(hexToRgb(hex)));\n }\n if (color.startsWith('rgb')) {\n var colorInRgb = rgbStringToArray(color);\n return rgbToHsl.apply(void 0, _toConsumableArray(colorInRgb));\n }\n\n // if the color is in text and no one from previous then return the default color which is black\n if (typeof color === 'string') {\n return [0, 0, 0];\n }\n return color;\n};\nexport var colorToRgb = function colorToRgb(color) {\n // we are not handling (hsl/color name) here cause we are accepting only HEX and RGB colors as default colors from user.\n if (color.startsWith('#')) {\n return hexToRgb(color);\n }\n if (color.startsWith('rgb')) {\n return rgbStringToArray(color);\n }\n if (typeof color === 'string') {\n return [0, 0, 0];\n }\n return color;\n};\nexport var colorToHex = function colorToHex(color) {\n if (color.startsWith('#')) {\n if (color.length === 7) {\n return color;\n }\n return \"#\".concat(color[0]).concat(color[0]).concat(color[1]).concat(color[1]).concat(color[2]).concat(color[2]);\n }\n if (color.startsWith('rgb')) {\n return rgbToHex.apply(void 0, _toConsumableArray(rgbStringToArray(color)));\n }\n if (typeof color === 'string') {\n return '#000000';\n }\n return color;\n};\nvar checkIsBlack = function checkIsBlack(s, l) {\n return l === 0 && (s === 0 || s === 1);\n};\nvar checkIsWhite = function checkIsWhite(s, l) {\n return s === 0 && l === 1;\n};\n\n// both hsv and hsl values are in [0, 1] except h is in [0, 360]\nexport var hsvToHsl = function hsvToHsl(h, s, v) {\n var newS = s;\n var l = (2 - s) * v / 2;\n if (l !== 0) {\n if (l === 1) {\n newS = 0;\n } else if (l < 0.5) {\n newS = newS * v / (l * 2);\n } else {\n newS = newS * v / (2 - l * 2);\n }\n }\n var isBlack = checkIsBlack(newS, l);\n return [isBlack || checkIsWhite(newS, l) ? 0 : h, isBlack ? 0 : Math.round(newS * 100), Math.round(l * 100)];\n};\n\n// both hsv and hsl values are in [0, 1] except h is in [0, 360]\nexport var hslToHsv = function hslToHsv(h, s, l) {\n var newS = s;\n var newL = l * 2;\n newS *= newL <= 1 ? newL : 2 - newL;\n var v = (newL + newS) / 2;\n newS = 2 * newS / (newL + newS);\n\n // return [h, newS, v];\n var isBlack = checkIsBlack(newS, l);\n return [isBlack || checkIsWhite(newS, l) ? 0 : h, isBlack ? 0 : Math.round(newS * 100), Math.round(v * 100)];\n};\n\n// TODO: validating 3 color code for Hex\n// /^#([\\da-f]{3}){1,2}$/i.test(color)colorToHex\nexport var validateHex = function validateHex(color) {\n return /^#[\\da-f]{6}$/i.test(color);\n};","export function getElemDocumentCoords(elem) {\n if (!elem) {\n return null;\n }\n var box = elem.getBoundingClientRect();\n var _document = document,\n body = _document.body;\n var docEl = document.documentElement;\n var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n var clientTop = docEl.clientTop || body.clientTop || 0;\n var clientLeft = docEl.clientLeft || body.clientLeft || 0;\n var top = box.top + scrollTop - clientTop;\n var left = box.left + scrollLeft - clientLeft;\n return {\n top: Math.round(top),\n left: Math.round(left),\n width: box.width,\n height: box.height\n };\n}","export function asc(a, b) {\n return a - b;\n}\nexport function valueToPercent(value, min, max) {\n return (value - min) * 100 / (max - min);\n}\nexport function percentToValue(percent, min, max) {\n return (max - min) * percent + min;\n}\nfunction getDecimalPrecision(num) {\n // This handles the case when num is very small (0.00000001), js will turn this into 1e-8.\n // When num is bigger than 1 or less than -1 it won't get converted to this notation so it's fine.\n if (Math.abs(num) < 1) {\n var parts = num.toExponential().split('e-');\n var matissaDecimalPart = parts[0].split('.')[1];\n return (matissaDecimalPart ? matissaDecimalPart.length : 0) + Number.parseInt(parts[1], 10);\n }\n var decimalPart = num.toString().split('.')[1];\n return decimalPart ? decimalPart.length : 0;\n}\nexport function roundValueToStep(value, step, min) {\n var nearest = Math.round((value - min) / step) * step + min;\n return Number(nearest.toFixed(getDecimalPrecision(step)));\n}\nexport function setValueIndex(_ref) {\n var values = _ref.values,\n newValue = _ref.newValue,\n index = _ref.index;\n var output = values.slice();\n output[index] = newValue;\n return output.sort(asc);\n}\nexport function findClosest(values, currentValue) {\n var _values$reduce = values.reduce(function (acc, value, index) {\n var distance = Math.abs(currentValue - value);\n if (acc === null || distance < acc.distance || distance === acc.distance) {\n return {\n distance: distance,\n index: index\n };\n }\n return acc;\n }, null),\n closestIndex = _values$reduce.index;\n return closestIndex;\n}\nexport function ownerDocument(node) {\n return node && node.ownerDocument || document;\n}\nexport function clamp(value, min, max) {\n if (value == null) {\n return min;\n }\n return Math.min(Math.max(min, value), max);\n}\nexport function trackFinger(event, touchId) {\n if (touchId.current !== undefined && event.changedTouches) {\n for (var i = 0; i < event.changedTouches.length; i += 1) {\n var touch = event.changedTouches[i];\n if (touch.identifier === touchId.current) {\n return {\n x: touch.clientX,\n y: touch.clientY\n };\n }\n }\n return false;\n }\n return {\n x: event.clientX,\n y: event.clientY\n };\n}\nexport var axisProps = {\n horizontal: {\n offset: function offset(percent) {\n return {\n left: \"\".concat(percent, \"%\")\n };\n },\n leap: function leap(percent) {\n return {\n width: \"\".concat(percent, \"%\")\n };\n }\n },\n 'horizontal-reverse': {\n offset: function offset(percent) {\n return {\n right: \"\".concat(percent, \"%\")\n };\n },\n leap: function leap(percent) {\n return {\n width: \"\".concat(percent, \"%\")\n };\n }\n },\n vertical: {\n offset: function offset(percent) {\n return {\n bottom: \"\".concat(percent, \"%\")\n };\n },\n leap: function leap(percent) {\n return {\n height: \"\".concat(percent, \"%\")\n };\n }\n }\n};\nexport function focusThumb(_ref2) {\n var sliderRef = _ref2.sliderRef,\n activeIndex = _ref2.activeIndex,\n setActive = _ref2.setActive;\n var doc = ownerDocument(sliderRef.current);\n if (!sliderRef.current.contains(doc.activeElement) || Number(doc.activeElement.getAttribute('data-index')) !== activeIndex) {\n var _sliderRef$current$qu;\n (_sliderRef$current$qu = sliderRef.current.querySelector(\"[type=\\\"range\\\"][data-index=\\\"\".concat(activeIndex, \"\\\"]\"))) === null || _sliderRef$current$qu === void 0 || _sliderRef$current$qu.focus();\n }\n if (setActive) {\n setActive(activeIndex);\n }\n}","export var Color = {\n TextPrimary: 'txt-primary',\n TextSecondary: 'txt-secondary',\n TextSecondaryInvert: 'txt-secondary-invert',\n TextPlaceholder: 'txt-placeholder',\n TextWarning: 'txt-warning',\n TextError: 'txt-error',\n TextInfo: 'txt-info',\n AccentPrimary: 'accent-primary',\n AccentPrimaryHover: 'accent-primary-hover',\n AccentPrimaryActive: 'accent-primary-active',\n AccentPrimaryDisabled: 'accent-primary-disabled',\n AccentSecondaryDisabled: 'accent-secondary-disabled',\n AccentStateless: 'accent-stateless',\n AccentStateless_0_4_Opacity: 'accent-stateless_0_4_opacity',\n Accent_0_5_5_Opacity: 'accent_0_5_5_opacity',\n Accent_0_5_Opacity: 'accent_0_5_opacity',\n Accent_0_7_Opacity: 'accent_0_7_opacity',\n Accent_1_2_Opacity: 'accent_1_2_opacity',\n Accent_1_8_Opacity: 'accent_1_8_opacity',\n Accent_2_8_Opacity: 'accent_2_8_opacity',\n Accent_4_0_Opacity: 'accent_4_0_opacity',\n BackgroundGrey: 'bg-grey',\n BackgroundStateless: 'bg-stateless',\n BackgroundActive: 'bg-active',\n BackgroundBaseLight: 'bg-base-light',\n BackgroundBaseMedium: 'bg-base-medium',\n BackgroundPrimary: 'bg-primary',\n BackgroundPrimaryLight: 'bg-primary-light',\n BackgroundPrimaryHover: 'bg-primary-hover',\n BackgroundPrimaryActive: 'bg-primary-active',\n BackgroundPrimaryStateless: 'bg-primary-stateless',\n BackgroundPrimary_0_5_Opacity: 'bg-primary-0-5-opacity',\n BackgroundSecondary: 'bg-secondary',\n BackgroundHover: 'bg-hover',\n BackgroundGreen: 'bg-green',\n BackgroundGreenMedium: 'bg-green-medium',\n BackgroundBlue: 'bg-blue',\n BackgroundRed: 'bg-red',\n BackgroundRedLight: 'bg-red-light',\n BackgroundRedMedium: 'background-red-medium',\n BackgroundOrange: 'bg-orange',\n BackgroundTooltip: 'bg-tooltip',\n IconsPrimary: 'icon-primary',\n IconsPrimaryOpacity_0_6: 'icons-primary-opacity-0-6',\n IconsSecondary: 'icons-secondary',\n IconsPlaceholder: 'icons-placeholder',\n IconsInvert: 'icons-invert',\n IconsMuted: 'icons-muted',\n IconsPrimaryHover: 'icons-primary-hover',\n IconsSecondaryHover: 'icons-secondary-hover',\n ButtonPrimaryText: 'btn-primary-text',\n ButtonPrimaryText_0_6: 'btn-primary-text-0-6',\n ButtonPrimaryText_0_4: 'btn-primary-text-0-4',\n ButtonDisabledText: 'btn-disabled-text',\n ButtonSecondaryText: 'btn-secondary-text',\n LinkPrimary: 'link-primary',\n LinkStateless: 'link-stateless',\n LinkHover: 'link-hover',\n LinkActive: 'link-active',\n LinkMuted: 'link-muted',\n LinkPressed: 'link-pressed',\n BordersPrimary: 'borders-primary',\n BordersPrimaryHover: 'borders-primary-hover',\n BordersSecondary: 'borders-secondary',\n BordersStrong: 'borders-strong',\n BordersInvert: 'borders-invert',\n BorderHoverBottom: 'border-hover-bottom',\n BorderActiveBottom: 'border-active-bottom',\n BorderPrimaryStateless: 'border-primary-stateless',\n BordersDisabled: 'borders-disabled',\n BordersButton: 'borders-button',\n BordersItem: 'borders-item',\n BordersBaseLight: 'borders-base-light',\n BordersBaseMedium: 'borders-base-medium',\n BordersGreen: 'borders-green',\n BordersGreenMedium: 'borders-green-medium',\n BordersRed: 'borders-red',\n ActiveSecondary: 'active-secondary',\n ActiveSecondaryHover: 'active-secondary-hover',\n Tag: 'tag',\n StatesErrorDisabledText: 'states-error-disabled-text',\n Error: 'error',\n Error_0_28_Opacity: 'error-0-28-opacity',\n Error_0_12_Opacity: 'error-0-12-opacity',\n ErrorHover: 'error-hover',\n ErrorActive: 'error-active',\n Success: 'success',\n SuccessHover: 'success-hover',\n SuccessActive: 'success-Active',\n Warning: 'warning',\n WarningHover: 'warning-hover',\n WarningActive: 'warning-active',\n Info: 'info',\n Modified: 'modified',\n Red: 'red',\n Orange: 'orange',\n Salad: 'salad',\n Green: 'green',\n Blue: 'blue',\n Indigo: 'indigo',\n Violet: 'violet',\n Pink: 'pink',\n GradientRight: 'gradient-right',\n Extra_0_3_Overlay: 'extra-0-3-overlay',\n GradientRightActive: 'gradient-right-active',\n GradientRightHover: 'gradient-right-hover',\n Extra_0_5_Overlay: 'extra-0-5-overlay',\n Extra_0_7_Overlay: 'extra-0-7-overlay',\n Extra_0_9_Overlay: 'extra-0-9-overlay',\n Red_0_1_Overlay: 'red-0-1-overlay',\n Orange_0_1_Overlay: 'orange-0-1-overlay',\n Accent_0_8_Overlay: 'accent-0-8-overlay',\n Green_0_2_Overlay: 'green-0-2-Overlay',\n Link: 'link',\n Camera: 'camera',\n GoogleDrive: 'google-drive',\n Dropbox: 'dropbox',\n OneDrive: 'one-drive',\n Device: 'device',\n Instagram: 'instagram',\n FreeImages: 'free-images',\n FreeIcons: 'free-icons',\n Canvas: 'canvas',\n Box: 'box',\n ScreenCast: 'screen-cast',\n Unsplash: 'unsplash',\n LightShadow: 'light-shadow',\n MediumShadow: 'medium-shadow',\n LargeShadow: 'large-shadow',\n XLargeShadow: 'x-large-shadow'\n};","import { css } from 'styled-components';\nimport { Color as PaletteColor } from '../types/palette';\nexport var scrollBar = function scrollBar(_ref) {\n var palette = _ref.theme.palette;\n return css([\"&::-webkit-scrollbar{width:12px;}&::-webkit-scrollbar-thumb{background:\", \";border:4px solid \", \";border-radius:99px;height:92px;padding:4px 6px;}\"], palette[PaletteColor.BorderPrimaryStateless], palette[PaletteColor.ActiveSecondary]);\n};","export var ignoreEvent = function ignoreEvent(event) {\n var tagName = event.target.tagName;\n if (tagName === 'INPUT' || tagName === 'TEXTAREA') {\n event.stopPropagation();\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n};","export var BorderRadiusSize = {\n Sm: 'sm',\n Md: 'md',\n Lg: 'lg'\n};","import { createGlobalStyle, css } from 'styled-components';\nvar Typography = /*#__PURE__*/createGlobalStyle([\"\", \";\"], function (_ref) {\n var theme = _ref.theme;\n var baseLineHeight = theme.typography.baseLineHeight;\n return css([\"h1,h2,h3,h4,h5,h6,p,small{line-height:\", \";}\"], baseLineHeight);\n});\nexport default Typography;","export var FontWeight = {\n Thin: 100,\n ExtraLight: 200,\n Light: 300,\n Regular: 400,\n Medium: 500,\n SemiBold: 600,\n Bold: 700,\n ExtraBold: 800,\n Black: 900\n};","export var FontVariant = {\n TextExtraSmall: 'text-extra-small',\n TextSmall: 'text-small',\n TextSmallUp: 'text-small-up',\n TextMedium: 'text-medium',\n TextLarge: 'text-large',\n TextExtraLarge: 'text-extra-large',\n TextXExtraLarge: 'text-x-extra-large',\n TitleH6: 'title-h6',\n TitleH5: 'title-h5',\n TitleH4: 'title-h4',\n TitleH3: 'title-h3',\n TitleH2: 'title-h2',\n TitleH1: 'title-h1',\n LabelExtraSmall: 'label-extra-small',\n LabelExtraSmallEmphasis: 'label-extra-small-emphasis',\n LabelExtraSmallUp: 'label-extra-small-up',\n LabelSmall: 'label-small',\n LabelSmallEmphasis: 'label-small-emphasis',\n LabelSmallUp: 'label-small-up',\n LabelSmallUpEmphasis: 'label-small-up-emphasis',\n LabelMedium: 'label-medium',\n LabelMediumEmphasis: 'label-medium-emphasis',\n LabelLarge: 'label-large',\n LabelLargeEmphasis: 'label-large-emphasis',\n LabelLargeUp: 'label-large-up',\n LabelExtraLargeEmphasis: 'label-extra-large-emphasis',\n LabelExtraLarge: 'label-extra-large',\n LabelXExtraLargeEmphasis: 'label-x-extra-large-emphasis',\n LabelXExtraLarge: 'label-x-extra-large',\n LabelXXExtraLargeEmphasis: 'label-x-x-extra-large-emphasis',\n LabelXXExtraLarge: 'label-x-x-extra-large',\n LabelXXXExtraLarge: 'label-x-x-x-extra-large',\n ButtonSmEmphasis: 'btn-sm-emphasis',\n ButtonSm: 'btn-sm',\n ButtonSmUpEmphasis: 'btn-sm-up-emphasis',\n ButtonSmUp: 'btn-sm-up',\n ButtonMdEmphasis: 'btn-md-emphasis',\n ButtonMd: 'btn-md',\n ButtonLgEmphasis: 'btn-lg-emphasis',\n ButtonLg: 'btn-lg',\n ButtonLgUpEmphasis: 'btn-lg-up-emphasis',\n ButtonLgUp: 'btn-lg-up',\n LinkSmall: 'link-small',\n LinkSmallEmphasis: 'link-small-emphasis',\n LinkSmallUp: 'link-small-up',\n LinkSmallUpEmphasis: 'link-small-up-emphasis',\n LinkMedium: 'link-medium',\n LinkMediumEmphasis: 'link-medium-emphasis',\n LinkLarge: 'link-large',\n LinkLargeEmphasis: 'link-large-emphasis',\n LinkLargeUp: 'link-large-up',\n LinkLargeUpEmphasis: 'link-large-up-emphasis',\n InputSm: 'input-sm',\n InputSmUp: 'input-sm-up',\n InputMd: 'input-md',\n InputLg: 'input-lg'\n};","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nimport { FontVariant, FontWeight } from '../../../../utils/types/typography';\nvar defaultFontValue = {\n fontFamily: '\"Roboto\"',\n fontStyle: 'normal',\n fontWeight: FontWeight.Regular\n};\nvar getLabelFontVariants = function getLabelFontVariants() {\n var _ref;\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _ref = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, FontVariant.LabelExtraSmall, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '10px',\n lineHeight: '12px'\n }, fontOverride)), FontVariant.LabelExtraSmallEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: 'Bold',\n fontSize: '10px',\n lineHeight: '12px'\n }, fontOverride)), FontVariant.LabelExtraSmallUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '11px',\n lineHeight: '12px'\n }, fontOverride)), FontVariant.LabelSmall, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.LabelSmallEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.LabelSmallUp, _objectSpread(_objectSpread({\n fontSize: '13px',\n lineHeight: '16px'\n }, defaultFontValue), fontOverride)), FontVariant.LabelSmallUpEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LabelMedium, _objectSpread(_objectSpread({\n fontSize: '14px',\n lineHeight: '16px'\n }, defaultFontValue), fontOverride)), FontVariant.LabelMediumEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LabelLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, FontVariant.LabelLargeEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.LabelLargeUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Regular,\n fontSize: '18px',\n lineHeight: '20px'\n }, fontOverride)), FontVariant.LabelExtraLargeEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '24px',\n lineHeight: '28px'\n }, fontOverride)), FontVariant.LabelExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Regular,\n fontSize: '24px',\n lineHeight: '28px'\n }, fontOverride)), FontVariant.LabelXExtraLargeEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '32px',\n lineHeight: '36px'\n }, fontOverride)), FontVariant.LabelXExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '32px',\n lineHeight: '36px'\n }, fontOverride)), FontVariant.LabelXXExtraLargeEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '48px',\n lineHeight: '54px'\n }, fontOverride)), FontVariant.LabelXXExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '48px',\n lineHeight: '54px'\n }, fontOverride)), FontVariant.LabelXXXExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '60px',\n lineHeight: '68px'\n }, fontOverride));\n};\nvar getTextFontVariants = function getTextFontVariants() {\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FontVariant.TextExtraSmall, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '11px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.TextSmall, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '12px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.TextSmallUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '13px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.TextMedium, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '14px',\n lineHeight: '20px'\n }, fontOverride)), FontVariant.TextLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '16px',\n lineHeight: '22px'\n }, fontOverride)), FontVariant.TextExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '18px',\n lineHeight: '26px'\n }, fontOverride)), FontVariant.TextXExtraLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '28px',\n lineHeight: '40px'\n }, fontOverride));\n};\nvar getButtonFontVariants = function getButtonFontVariants() {\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FontVariant.ButtonSmEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.ButtonSm, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.ButtonSmUpEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.ButtonSmUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.ButtonMdEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.ButtonMd, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.ButtonLgEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.ButtonLg, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.ButtonLgUpEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '18px',\n lineHeight: '20px'\n }, fontOverride)), FontVariant.ButtonLgUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '18px',\n lineHeight: '20px'\n }, fontOverride));\n};\nvar getLinkFontVariants = function getLinkFontVariants() {\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FontVariant.LinkSmall, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.LinkSmallEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.LinkSmallUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LinkSmallUpEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LinkMedium, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LinkMediumEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.LinkLarge, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.LinkLargeEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.LinkLargeUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '18px',\n lineHeight: '20px'\n }, fontOverride)), FontVariant.LinkLargeUpEmphasis, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '18px',\n lineHeight: '20px'\n }, fontOverride));\n};\nvar getInputFontVariants = function getInputFontVariants() {\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FontVariant.InputSm, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '12px',\n lineHeight: '14px'\n }, fontOverride)), FontVariant.InputSmUp, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '13px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.InputMd, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '14px',\n lineHeight: '16px'\n }, fontOverride)), FontVariant.InputLg, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontSize: '16px',\n lineHeight: '18px'\n }, fontOverride));\n};\nvar getTitleFontVariants = function getTitleFontVariants() {\n var fontOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FontVariant.TitleH6, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '12px',\n lineHeight: '18px'\n }, fontOverride)), FontVariant.TitleH5, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '14px',\n lineHeight: '21px'\n }, fontOverride)), FontVariant.TitleH4, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '16px',\n lineHeight: '24px'\n }, fontOverride)), FontVariant.TitleH3, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '18px',\n lineHeight: '27px'\n }, fontOverride)), FontVariant.TitleH2, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '20px',\n lineHeight: '30px'\n }, fontOverride)), FontVariant.TitleH1, _objectSpread(_objectSpread({}, defaultFontValue), {}, {\n fontWeight: FontWeight.Medium,\n fontSize: '28px',\n lineHeight: '42px'\n }, fontOverride));\n};\nexport var getDefaultTypography = function getDefaultTypography() {\n var typographyOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _objectSpread(_objectSpread({\n fontFamily: defaultFontValue.fontFamily,\n baseLineHeight: 1.375\n }, typographyOverride), {}, {\n font: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getLabelFontVariants(typographyOverride)), getTextFontVariants(typographyOverride)), getButtonFontVariants(typographyOverride)), getLinkFontVariants(typographyOverride)), getInputFontVariants(typographyOverride)), getTitleFontVariants(typographyOverride))\n });\n};","import { createGlobalStyle /* , css */ } from 'styled-components';\n\n// Example with theme: ${({ theme }) => css``;\n\nvar CommonStyles = /*#__PURE__*/createGlobalStyle([\"@keyframes spinner{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}.Menu-open{overflow:hidden;}.Modal-open{overflow:hidden;}\"]);\nexport default CommonStyles;","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nvar _accent, _background, _borders, _states, _uploader, _extra;\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nimport { Color } from '../../../../utils/types/palette';\n//TODO: update theme to include grouped palette\n//TODO:change color values from rgb to hex\nexport var groupedPalette = {\n text: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.TextPrimary, 'rgba(55, 65, 75, 1)'), Color.TextSecondary, 'rgba(118, 138, 159, 1)'), Color.TextSecondaryInvert, 'rgba(213, 216, 220, 1)'), Color.TextPlaceholder, 'rgba(169, 182, 194, 1)'), Color.TextWarning, 'rgba(196, 110, 0, 1)'), Color.TextError, 'rgba(185, 33, 46, 1)'), Color.TextInfo, 'rgba(35, 117, 171, 1)'),\n accent: (_accent = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_accent, Color.AccentPrimary, 'rgba(104, 121, 235, 1)'), Color.AccentPrimaryHover, 'rgba(96, 111, 209, 1)'), Color.AccentPrimaryActive, 'rgba(73, 88, 188, 1)'), Color.AccentPrimaryDisabled, 'rgba(233, 238, 242, 1)'), Color.AccentSecondaryDisabled, '#F9FBFC'), Color.AccentStateless, 'rgba(104, 121, 235, 1)'), Color.AccentStateless_0_4_Opacity, 'rgba(104, 121, 235, 0.4)'), Color.Accent_0_5_5_Opacity, 'rgba(96, 111, 209, 0.55)'), Color.Accent_0_7_Opacity, 'rgba(96, 111, 209, 0.7)'), Color.Accent_0_5_Opacity, 'rgba(104, 121, 235, 0.05)'), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_accent, Color.Accent_1_2_Opacity, 'rgba(104, 121, 235, 0.12)'), Color.Accent_1_8_Opacity, 'rgba(104, 121, 235, 0.18)'), Color.Accent_2_8_Opacity, 'rgba(104, 121, 235, 0.28)'), Color.Accent_4_0_Opacity, 'rgba(104, 121, 235, 0.4)')),\n background: (_background = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_background, Color.BackgroundGrey, 'rgba(216, 224, 232, 1)'), Color.BackgroundStateless, 'rgba(255, 255, 255, 1)'), Color.BackgroundActive, 'rgba(243, 247, 250, 1)'), Color.BackgroundBaseLight, 'rgba(235, 239, 252, 1)'), Color.BackgroundBaseMedium, 'rgba(227, 231, 251, 1)'), Color.BackgroundPrimary, 'rgba(243, 245, 247, 1)'), Color.BackgroundPrimaryLight, 'rgba(243, 245, 247, 1)'), Color.BackgroundPrimaryHover, 'rgba(239, 243, 246, 1)'), Color.BackgroundPrimaryActive, 'rgba(93, 109, 126, 1)'), Color.BackgroundPrimary_0_5_Opacity, 'rgba(255, 255, 255, 0.500)'), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_background, Color.BackgroundPrimaryStateless, '#CCD6DE'), Color.BackgroundSecondary, 'rgba(255, 255, 255, 1)'), Color.BackgroundHover, 'rgba(249, 251, 252, 1)'), Color.BackgroundGreen, 'rgba(237, 250, 244, 1)'), Color.BackgroundGreenMedium, 'rgba(227, 250, 239, 1)'), Color.BackgroundBlue, 'rgba(244, 249, 255, 1)'), Color.BackgroundRed, 'rgba(253, 244, 242, 1)'), Color.BackgroundRedLight, 'rgba(255, 245, 245, 1)'), Color.BackgroundRedMedium, 'rgba(247, 228, 230, 1)'), Color.BackgroundOrange, 'rgba(255, 249, 242, 1)'), _defineProperty(_background, Color.BackgroundTooltip, 'rgba(79, 98, 118, 1)')),\n icons: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.IconsPrimary, 'rgba(118, 138, 159, 1)'), Color.IconsPrimaryOpacity_0_6, 'rgba(93, 109, 126, 0.600)'), Color.IconsSecondary, 'rgba(151, 166, 182, 1)'), Color.IconsPlaceholder, 'rgba(223, 231, 237, 1)'), Color.IconsInvert, 'rgba(255, 255, 255, 1)'), Color.IconsMuted, 'rgba(169, 182, 194, 1)'), Color.IconsPrimaryHover, 'rgba(79, 98, 118, 1)'), Color.IconsSecondaryHover, 'rgba(118, 138, 159, 1)'),\n button: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.ButtonPrimaryText, 'rgba(255, 255, 255, 1)'), Color.ButtonPrimaryText_0_6, 'rgba(255, 255, 255, 0.6)'), Color.ButtonPrimaryText_0_4, 'rgba(255, 255, 255, 0.4)'), Color.ButtonDisabledText, 'rgba(169, 182, 194, 1)'), Color.ButtonSecondaryText, 'rgba(0, 0, 0, 1)'),\n link: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.LinkPrimary, 'rgba(118, 138, 159, 1)'), Color.LinkStateless, 'rgba(118, 138, 159, 1)'), Color.LinkHover, 'rgba(79, 98, 118, 1)'), Color.LinkActive, 'rgba(55, 65, 75, 1)'), Color.LinkPressed, 'rgba(104, 121, 235, 1)'), Color.LinkMuted, 'rgba(169, 182, 194, 1)'),\n borders: (_borders = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_borders, Color.BordersPrimary, 'rgba(204, 214, 222, 1)'), Color.BordersPrimaryHover, 'rgba(104, 118, 134, 1)'), Color.BordersSecondary, 'rgba(236, 240, 243, 1)'), Color.BordersStrong, 'rgba(204, 214, 222, 1)'), Color.BordersInvert, 'rgba(85, 99, 115, 1)'), Color.BorderHoverBottom, 'rgba(104, 121, 235, 0.18)'), Color.BorderActiveBottom, '#4958BC'), Color.BorderPrimaryStateless, 'rgba(204, 214, 222, 1)'), Color.BordersDisabled, 'rgba(73, 88, 188, 0.4)'), Color.BordersButton, 'rgba(151, 166, 182, 1)'), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_borders, Color.BordersItem, 'rgba(226, 232, 236, 1)'), Color.BordersBaseLight, 'rgba(211, 219, 250, 1)'), Color.BordersBaseMedium, 'rgba(164, 175, 227, 1)'), Color.BordersGreen, 'rgba(27, 161, 99, 0.22)'), Color.BordersGreenMedium, 'rgba(27, 161, 99, 0.4)'), Color.BordersRed, 'rgba(185, 33, 46, 0.4)')),\n states: (_states = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_states, Color.Error, 'rgba(246, 61, 61, 1)'), Color.Error_0_28_Opacity, 'rgba(185, 33, 46, 0.28)'), Color.Error_0_12_Opacity, 'rgba(255, 86, 78, 0.1)'), Color.ErrorHover, 'rgba(216, 46, 46, 1)'), Color.ErrorActive, 'rgba(185, 33, 46, 1)'), Color.Success, 'rgba(38, 193, 122, 1)'), Color.SuccessHover, 'rgba(30, 154, 98, 1)'), Color.SuccessActive, 'rgba(23, 116, 73, 1)'), Color.Warning, 'rgba(255, 172, 74, 1)'), Color.WarningHover, 'rgba(237, 145, 7, 1)'), _defineProperty(_defineProperty(_defineProperty(_states, Color.WarningActive, 'rgba(224, 135, 0, 1)'), Color.Info, 'rgba(41, 127, 184, 1)'), Color.Modified, 'rgba(165, 166, 246, 1)')),\n flat: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.Red, 'rgba(219, 46, 50, 1)'), Color.Orange, 'rgba(255, 168, 0, 1)'), Color.Salad, 'rgba(143, 176, 33, 1)'), Color.Green, 'rgba(22, 160, 134, 1)'), Color.Blue, 'rgba(41, 127, 184, 1)'), Color.Indigo, 'rgba(91, 72, 162, 1)'), Color.Violet, 'rgba(141, 68, 173, 1)'), Color.Pink, 'rgba(211, 92, 158, 1)'),\n uploader: (_uploader = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_uploader, Color.Link, 'rgba(250, 166, 68, 1)'), Color.Camera, 'rgba(73, 186, 224, 1)'), Color.GoogleDrive, 'rgba(81, 136, 238, 1)'), Color.Dropbox, 'rgba(17, 40, 124, 1)'), Color.OneDrive, 'rgba(40, 100, 186, 1)'), Color.Device, 'rgba(102, 73, 209, 1)'), Color.Instagram, 'rgba(244, 70, 154, 1)'), Color.Unsplash, 'rgba(173, 38, 220, 1)'), Color.FreeImages, 'rgba(16, 163, 135, 1)'), Color.FreeIcons, 'rgba(62, 207, 139, 1)'), _defineProperty(_defineProperty(_defineProperty(_uploader, Color.Canvas, 'rgba(36, 190, 202, 1)'), Color.Box, 'rgba(0, 97, 213, 1)'), Color.ScreenCast, 'rgba(48, 61, 78, 1)')),\n extra: (_extra = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_extra, Color.GradientRight, 'linear-gradient(270deg, #FFFFFF 1.56%, rgba(255, 255, 255, 0.89) 52.4%, rgba(255, 255, 255, 0.532165) 76.04%, rgba(255, 255, 255, 0) 100%)'), Color.Extra_0_3_Overlay, 'rgba(79, 98, 118, 0.3)'), Color.GradientRightActive, 'linear-gradient(270deg, #F3F7FA 1.56%, #F3F7FA 52.4%, rgba(243, 247, 250, 0.53) 76.04%, rgba(243, 247, 250, 0) 100%)'), Color.GradientRightHover, 'linear-gradient(270deg, #F9FBFC 1.56%, #F9FBFC 52.4%, rgba(249, 251, 252, 0.53) 76.04%, rgba(249, 251, 252, 0) 100%)'), Color.Extra_0_5_Overlay, 'rgba(79, 98, 118, 0.5)'), Color.Extra_0_7_Overlay, 'rgba(79, 98, 118, 0.7)'), Color.Extra_0_9_Overlay, 'rgba(79, 98, 118, 0.9)'), Color.Red_0_1_Overlay, 'rgba(232, 91, 70, 0.1)'), Color.Orange_0_1_Overlay, 'rgba(250, 157, 47, 0.1)'), Color.Accent_0_8_Overlay, 'rgba(104, 121, 235, 0.08)'), _defineProperty(_extra, Color.Green_0_2_Overlay, 'rgba(27, 161, 99, 0.2)'))\n};\nexport var lightPalette = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, groupedPalette.text), groupedPalette.accent), groupedPalette.background), groupedPalette.icons), groupedPalette.button), groupedPalette.link), groupedPalette.borders), groupedPalette.states), groupedPalette.flat), groupedPalette.uploader), groupedPalette.extra), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Color.ActiveSecondary, '#FFFFFF'), Color.ActiveSecondaryHover, 'rgba(104, 121, 235, 0.05)'), Color.Tag, '#889AAC'), Color.StatesErrorDisabledText, 'rgba(185, 33, 46, 0.3)'), Color.LightShadow, 'rgba(146, 166, 188, 0.2)'), Color.MediumShadow, 'rgba(146, 166, 188, 0.24)'), Color.LargeShadow, 'rgba(146, 166, 188, 0.32)'), Color.XLargeShadow, 'rgba(146, 166, 188, 0.5)'));\nexport var defaultPalette = lightPalette;","export var Shadows = {\n ShadowSm: 'shadow-sm',\n ShadowMd: 'shadow-md',\n ShadowLg: 'shadow-lg',\n ShadowXl: 'shadow-xl',\n Label: 'label',\n Header: 'header',\n HeaderPopup: 'header-popup',\n FooterPopup: 'footer-popup',\n LeftPanelMd: 'left-panel-md',\n RightPanelMd: 'right-panel-md',\n LeftPanelSm: 'left-panel-sm',\n RightPanelSm: 'right-panel-sm'\n};","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nvar _shadows;\nimport { Shadows } from '../../../../utils/types/shadows';\nexport var shadows = (_shadows = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_shadows, Shadows.ShadowSm, '0px 1px 2px 0px rgba(146, 166, 188, 0.2)'), Shadows.ShadowMd, ' 0px 1px 4px 0px rgba(146, 166, 188, 0.24)'), Shadows.ShadowLg, ' 0px 2px 6px 0px rgba(146, 166, 188, 0.32)'), Shadows.ShadowXl, ' 0px 2px 6px 0px rgba(146, 166, 188, 0.5)'), Shadows.Label, ' 0px 1px 3px 0px rgba(77, 78, 78, 0.15)'), Shadows.Header, ' 0px 6px 10px 0px rgba(146, 166, 188, 0.2)'), Shadows.HeaderPopup, ' 0px 3px 7px 0px rgba(146, 166, 188, 0.16)'), Shadows.FooterPopup, ' 0px -4px 8px 0px rgba(208, 215, 220, 0.22)'), Shadows.LeftPanelMd, ' 6px 8px 12px 0px rgba(146, 166, 188, 0.14)'), Shadows.RightPanelMd, '-6px 8px 12px 0px rgba(146, 166, 188, 0.14)'), _defineProperty(_defineProperty(_shadows, Shadows.LeftPanelSm, '6px -4px 12px 0px rgba(146, 166, 188, 0.14)'), Shadows.RightPanelSm, '-6px -4px 12px 0px rgba(146, 166, 188, 0.14)'));\nexport var defaultShadows = shadows;","export var Breakpoint = {\n Xs: 'xs',\n Sm: 'sm',\n Md: 'md',\n Lg: 'lg',\n Xl: 'xl',\n Xxl: 'xxl',\n Xxxl: 'xxxl'\n};\nexport var BreakpointClass = {\n Xs: '.sfx-breakpoint-xs',\n Sm: '.sfx-breakpoint-sm',\n Md: '.sfx-breakpoint-md',\n Lg: '.sfx-breakpoint-lg',\n Xl: '.sfx-breakpoint-xl',\n Xxl: '.sfx-breakpoint-xxl',\n Xxxl: '.sfx-breakpoint-xxxl'\n};","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { Breakpoint } from '../../../../utils/types/css';\nexport var defaultBreakpoints = {\n keys: [Breakpoint.Xs, Breakpoint.Sm, Breakpoint.Md, Breakpoint.Lg, Breakpoint.Xl],\n values: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Breakpoint.Xs, 0), Breakpoint.Sm, 576), Breakpoint.Md, 768), Breakpoint.Lg, 1084), Breakpoint.Xl, 1342), Breakpoint.Xxl, 1600), Breakpoint.Xxxl, 1920),\n classes: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Breakpoint.Xs, '.sfx-breakpoint-xs'), Breakpoint.Sm, '.sfx-breakpoint-sm'), Breakpoint.Md, '.sfx-breakpoint-md'), Breakpoint.Lg, '.sfx-breakpoint-lg'), Breakpoint.Xl, '.sfx-breakpoint-xl'), Breakpoint.Xxl, '.sfx-breakpoint-xxl'), Breakpoint.Xxxl, '.sfx-breakpoint-xxxl'),\n getBreakpointClass: function getBreakpointClass() {\n return '';\n },\n up: function up() {\n return '';\n },\n down: function down() {\n return '';\n },\n between: function between() {\n return '';\n },\n only: function only() {\n return '';\n }\n};","import { defaultBreakpoints } from './default-breakpoints';\nvar createBreakpoints = function createBreakpoints(breakpoints) {\n var _breakpoints$values = breakpoints.values,\n values = _breakpoints$values === void 0 ? defaultBreakpoints.values : _breakpoints$values,\n _breakpoints$classes = breakpoints.classes,\n classes = _breakpoints$classes === void 0 ? defaultBreakpoints.classes : _breakpoints$classes;\n var unit = 'px';\n var keys = Object.keys(values);\n var up = function up(key) {\n var value = typeof values[key] === 'number' ? values[key] : key;\n return \"@media (min-width:\".concat(value).concat(unit, \")\");\n };\n var down = function down(key) {\n var value = values[key];\n return \"@media (max-width:\".concat(value).concat(unit, \")\");\n };\n var between = function between(start, end) {\n var endIndex = keys.indexOf(end);\n return \"@media (min-width:\".concat(values[start]).concat(unit, \") and (max-width:\").concat(values[keys[endIndex]]).concat(unit, \")\");\n };\n var only = function only(key) {\n if (keys.indexOf(key) + 1 < keys.length) {\n return between(key, keys[keys.indexOf(key) + 1]);\n }\n return up(key);\n };\n var getBreakpointClass = function getBreakpointClass(width, hideSelector) {\n var removeSelector = function removeSelector(str) {\n return str.slice(1);\n };\n if (width >= values.xs && width < values.sm) {\n return hideSelector ? removeSelector(classes.xs) : classes.xs;\n }\n if (width >= values.sm && width < values.md) {\n return hideSelector ? removeSelector(classes.sm) : classes.sm;\n }\n if (width >= values.md && width < values.lg) {\n return hideSelector ? removeSelector(classes.md) : classes.md;\n }\n if (width >= values.lg && width < values.xl) {\n return hideSelector ? removeSelector(classes.lg) : classes.lg;\n }\n if (width >= values.xl && width < values.xxl) {\n return hideSelector ? removeSelector(classes.xl) : classes.xl;\n }\n if (width >= values.xxl && width < values.xxxl) {\n return hideSelector ? removeSelector(classes.xxl) : classes.xxl;\n }\n if (width >= values.xxxl) {\n return hideSelector ? removeSelector(classes.xxxl) : classes.xxxl;\n }\n return hideSelector ? removeSelector(classes.md) : classes.md;\n };\n return {\n keys: keys,\n values: values,\n classes: classes,\n getBreakpointClass: getBreakpointClass,\n up: up,\n down: down,\n between: between,\n only: only\n };\n};\nexport default createBreakpoints;","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nimport React, { useMemo } from 'react';\nimport { ThemeProvider as SCThemeProvider } from 'styled-components';\nimport merge from 'lodash.merge';\nimport { applyPolymorphicFunctionProp } from '../../utils/functions';\nimport { BorderRadiusSize } from '../../utils/types/shape';\nimport { Typography, CommonStyles } from '../roots';\nimport { defaultPalette } from '../roots/palette';\nimport { defaultShadows } from '../roots/shadows';\nimport { getDefaultTypography } from '../roots/typography';\nimport createBreakpoints from '../roots/breakpoints/entity/create-breakpoints';\nvar defaultShape = {\n borderRadius: _defineProperty(_defineProperty(_defineProperty({}, BorderRadiusSize.Sm, '2px'), BorderRadiusSize.Md, '4px'), BorderRadiusSize.Lg, '8px')\n};\nvar ThemeProvider = function ThemeProvider(_ref) {\n var children = _ref.children,\n _ref$theme = _ref.theme,\n theme = _ref$theme === void 0 ? {} : _ref$theme;\n var _theme$palette = theme.palette,\n paletteOverride = _theme$palette === void 0 ? {} : _theme$palette,\n _theme$breakpoints = theme.breakpoints,\n breakpointsOverride = _theme$breakpoints === void 0 ? {} : _theme$breakpoints,\n _theme$typography = theme.typography,\n typographyOverride = _theme$typography === void 0 ? {} : _theme$typography,\n _theme$shape = theme.shape,\n shapeOverride = _theme$shape === void 0 ? {} : _theme$shape,\n _theme$shadows = theme.shadows,\n shadowsOverride = _theme$shadows === void 0 ? {} : _theme$shadows;\n var finalTheme = useMemo(function () {\n var palette = _objectSpread(_objectSpread({}, defaultPalette), paletteOverride);\n var breakpoints = createBreakpoints(breakpointsOverride);\n var shadows = _objectSpread(_objectSpread({}, defaultShadows), shadowsOverride);\n return {\n palette: palette,\n breakpoints: breakpoints,\n typography: getDefaultTypography(typographyOverride),\n shape: _objectSpread({}, merge(_objectSpread({}, defaultShape), _objectSpread({}, shapeOverride))),\n shadows: shadows\n };\n }, [JSON.stringify(theme)]);\n return /*#__PURE__*/React.createElement(SCThemeProvider, {\n theme: finalTheme\n }, /*#__PURE__*/React.createElement(React.Fragment, null, applyPolymorphicFunctionProp(children, finalTheme), /*#__PURE__*/React.createElement(CommonStyles, null), /*#__PURE__*/React.createElement(Typography, null)));\n};\nexport default ThemeProvider;","function _arrayWithHoles(r) {\n if (Array.isArray(r)) return r;\n}\nexport { _arrayWithHoles as default };","function _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = !0,\n o = !1;\n try {\n if (i = (t = t.call(r)).next, 0 === l) {\n if (Object(t) !== t) return;\n f = !1;\n } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = !0, n = r;\n } finally {\n try {\n if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}\nexport { _iterableToArrayLimit as default };","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _nonIterableRest as default };","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nfunction _slicedToArray(r, e) {\n return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();\n}\nexport { _slicedToArray as default };","function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","/*\n * Konva JavaScript Framework v10.5.0\n * http://konvajs.org/\n * Licensed under the MIT\n * Date: @@date\n *\n * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)\n * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)\n *\n * @license\n */\nconst PI_OVER_180 = Math.PI / 180;\n/**\n * @namespace Konva\n */\nfunction detectBrowser() {\n return (typeof window !== 'undefined' &&\n // browser case\n ({}.toString.call(window) === '[object Window]' ||\n // electron case\n {}.toString.call(window) === '[object global]'));\n}\nexport const glob = typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : typeof WorkerGlobalScope !== 'undefined'\n ? self\n : {};\nexport const Konva = {\n _global: glob,\n version: '10.5.0',\n isBrowser: detectBrowser(),\n isUnminified: /param/.test(function (param) { }.toString()),\n dblClickWindow: 400,\n getAngle(angle) {\n return Konva.angleDeg ? angle * PI_OVER_180 : angle;\n },\n enableTrace: false,\n pointerEventsEnabled: true,\n /**\n * Should Konva automatically update canvas on any changes. Default is true.\n * @property autoDrawEnabled\n * @default true\n * @name autoDrawEnabled\n * @memberof Konva\n * @example\n * Konva.autoDrawEnabled = true;\n */\n autoDrawEnabled: true,\n /**\n * Should we enable hit detection while dragging? For performance reasons, by default it is false.\n * But on some rare cases you want to see hit graph and check intersections. Just set it to true.\n * @property hitOnDragEnabled\n * @default false\n * @name hitOnDragEnabled\n * @memberof Konva\n * @example\n * Konva.hitOnDragEnabled = true;\n */\n hitOnDragEnabled: false,\n /**\n * Should we capture touch events and bind them to the touchstart target? That is how it works on DOM elements.\n * The case: we touchstart on div1, then touchmove out of that element into another element div2.\n * DOM will continue trigger touchmove events on div1 (not div2). Because events are \"captured\" into initial target.\n * By default Konva do not do that and will trigger touchmove on another element, while pointer is moving.\n * @property capturePointerEventsEnabled\n * @default false\n * @name capturePointerEventsEnabled\n * @memberof Konva\n * @example\n * Konva.capturePointerEventsEnabled = true;\n */\n capturePointerEventsEnabled: false,\n _mouseListenClick: false,\n _touchListenClick: false,\n _pointerListenClick: false,\n _mouseInDblClickWindow: false,\n _touchInDblClickWindow: false,\n _pointerInDblClickWindow: false,\n _renderBackend: 'web', // web, node-canvas, skia-canvas\n /**\n * Use legacy text rendering. with \"middle\" baseline by default.\n * @property legacyTextRendering\n * @default false\n * @name legacyTextRendering\n * @memberof Konva\n * @example\n * Konva.legacyTextRendering = true;\n */\n legacyTextRendering: false,\n /**\n * Global pixel ratio configuration. KonvaJS automatically detect pixel ratio of current device.\n * But you may override such property, if you want to use your value. Set this value before any components initializations.\n * @property pixelRatio\n * @default window.devicePixelRatio || 1\n * @name pixelRatio\n * @memberof Konva\n * @example\n * // before any Konva code:\n * Konva.pixelRatio = 1;\n */\n pixelRatio: (typeof window !== 'undefined' && window.devicePixelRatio) || 1,\n /**\n * Drag distance property. If you start to drag a node you may want to wait until pointer is moved to some distance from start point\n * on either axis, only then start dragging. Default is 3px.\n * @property dragDistance\n * @default 3\n * @memberof Konva\n * @example\n * Konva.dragDistance = 10;\n */\n dragDistance: 3,\n /**\n * Use degree values for angle properties. You may set this property to false if you want to use radian values.\n * @property angleDeg\n * @default true\n * @memberof Konva\n * @example\n * node.rotation(45); // 45 degrees\n * Konva.angleDeg = false;\n * node.rotation(Math.PI / 2); // PI/2 radian\n */\n angleDeg: true,\n /**\n * Show warnings about wrong API usage (`Konva.Util.warn`). Errors are always printed\n * @property showWarnings\n * @default true\n * @memberof Konva\n * @example\n * Konva.showWarnings = false;\n */\n showWarnings: true,\n /**\n * Configure what mouse buttons can be used for drag and drop.\n * Default value is [0, 1] - left and middle mouse buttons.\n * @property dragButtons\n * @default [0, 1]\n * @memberof Konva\n * @example\n * // enable left and right mouse buttons\n * Konva.dragButtons = [0, 2];\n */\n dragButtons: [0, 1],\n /**\n * returns whether or not drag and drop is currently active\n * @method\n * @memberof Konva\n */\n isDragging() {\n return Konva['DD'].isDragging;\n },\n /**\n * returns whether or not a Transformer is currently transforming a node\n * @method\n * @memberof Konva\n */\n isTransforming() {\n var _a, _b;\n return (_b = (_a = Konva['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming()) !== null && _b !== void 0 ? _b : false;\n },\n /**\n * returns whether or not a drag and drop operation is ready, but may\n * not necessarily have started\n * @method\n * @memberof Konva\n */\n isDragReady() {\n return !!Konva['DD'].node;\n },\n /**\n * Should Konva release canvas elements on destroy. Default is true.\n * Useful to avoid memory leak issues in Safari on macOS/iOS.\n * @property releaseCanvasOnDestroy\n * @default true\n * @name releaseCanvasOnDestroy\n * @memberof Konva\n * @example\n * Konva.releaseCanvasOnDestroy = true;\n */\n releaseCanvasOnDestroy: true,\n document: glob.document,\n // insert Konva into global namespace (window)\n // it is required for npm packages\n _injectGlobal(Konva) {\n if (typeof glob.Konva !== 'undefined') {\n console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');\n }\n glob.Konva = Konva;\n },\n};\nexport const _registerNode = (NodeClass) => {\n Konva[NodeClass.prototype.getClassName()] = NodeClass;\n};\nKonva._injectGlobal(Konva);\n","import { Konva } from \"./Global.js\";\nconst NODE_ERROR = `Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because \"document\" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the \"canvas-backend\" or \"skia-backend\" module.\n\nbash: npm install canvas\njs: import \"konva/canvas-backend\";\n\nor\n\nbash: npm install skia-canvas\njs: import \"konva/skia-backend\";\n`;\nconst ensureBrowser = () => {\n if (typeof document === 'undefined') {\n throw new Error(NODE_ERROR);\n }\n};\n/*\n * Last updated November 2011\n * By Simon Sarris\n * www.simonsarris.com\n * sarris@acm.org\n *\n * Free to use and distribute at will\n * So long as you are nice to people, etc\n */\n/*\n * The usage of this class was inspired by some of the work done by a forked\n * project, KineticJS-Ext by Wappworks, which is based on Simon's Transform\n * class. Modified by Eric Rowell\n */\n/**\n * Transform constructor.\n * In most of the cases you don't need to use it in your app. Because it is for internal usage in Konva core.\n * But there is a documentation for that class in case you still want\n * to make some manual calculations.\n * @constructor\n * @param {Array} [m] Optional six-element matrix\n * @memberof Konva\n */\nexport class Transform {\n constructor(m) {\n this.dirty = false;\n this.m = m ? m.slice() : [1, 0, 0, 1, 0, 0];\n }\n reset() {\n this.m[0] = 1;\n this.m[1] = 0;\n this.m[2] = 0;\n this.m[3] = 1;\n this.m[4] = 0;\n this.m[5] = 0;\n }\n /**\n * Copy Konva.Transform object\n * @method\n * @name Konva.Transform#copy\n * @returns {Konva.Transform}\n * @example\n * const tr = shape.getTransform().copy()\n */\n copy() {\n return new Transform(this.m);\n }\n copyInto(tr) {\n tr.m[0] = this.m[0];\n tr.m[1] = this.m[1];\n tr.m[2] = this.m[2];\n tr.m[3] = this.m[3];\n tr.m[4] = this.m[4];\n tr.m[5] = this.m[5];\n }\n /**\n * Transform point\n * @method\n * @name Konva.Transform#point\n * @param {Object} point 2D point(x, y)\n * @returns {Object} 2D point(x, y)\n */\n point(point) {\n const m = this.m;\n return {\n x: m[0] * point.x + m[2] * point.y + m[4],\n y: m[1] * point.x + m[3] * point.y + m[5],\n };\n }\n /**\n * Apply translation\n * @method\n * @name Konva.Transform#translate\n * @param {Number} x\n * @param {Number} y\n * @returns {Konva.Transform}\n */\n translate(x, y) {\n this.m[4] += this.m[0] * x + this.m[2] * y;\n this.m[5] += this.m[1] * x + this.m[3] * y;\n return this;\n }\n /**\n * Apply scale\n * @method\n * @name Konva.Transform#scale\n * @param {Number} sx\n * @param {Number} sy\n * @returns {Konva.Transform}\n */\n scale(sx, sy) {\n this.m[0] *= sx;\n this.m[1] *= sx;\n this.m[2] *= sy;\n this.m[3] *= sy;\n return this;\n }\n /**\n * Apply rotation\n * @method\n * @name Konva.Transform#rotate\n * @param {Number} rad Angle in radians\n * @returns {Konva.Transform}\n */\n rotate(rad) {\n const c = Math.cos(rad);\n const s = Math.sin(rad);\n const m11 = this.m[0] * c + this.m[2] * s;\n const m12 = this.m[1] * c + this.m[3] * s;\n const m21 = this.m[0] * -s + this.m[2] * c;\n const m22 = this.m[1] * -s + this.m[3] * c;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n }\n /**\n * Returns the translation\n * @method\n * @name Konva.Transform#getTranslation\n * @returns {Object} 2D point(x, y)\n */\n getTranslation() {\n return {\n x: this.m[4],\n y: this.m[5],\n };\n }\n /**\n * Apply skew\n * @method\n * @name Konva.Transform#skew\n * @param {Number} sx\n * @param {Number} sy\n * @returns {Konva.Transform}\n */\n skew(sx, sy) {\n const m11 = this.m[0] + this.m[2] * sy;\n const m12 = this.m[1] + this.m[3] * sy;\n const m21 = this.m[2] + this.m[0] * sx;\n const m22 = this.m[3] + this.m[1] * sx;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n }\n /**\n * Transform multiplication\n * @method\n * @name Konva.Transform#multiply\n * @param {Konva.Transform} matrix\n * @returns {Konva.Transform}\n */\n multiply(matrix) {\n const m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];\n const m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];\n const m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];\n const m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];\n const dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];\n const dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n this.m[4] = dx;\n this.m[5] = dy;\n return this;\n }\n /**\n * Invert the matrix\n * @method\n * @name Konva.Transform#invert\n * @returns {Konva.Transform}\n */\n // a transform with a zero scale on an axis has no inverse\n isInvertible() {\n return this.m[0] * this.m[3] - this.m[1] * this.m[2] !== 0;\n }\n invert() {\n const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);\n const m0 = this.m[3] * d;\n const m1 = -this.m[1] * d;\n const m2 = -this.m[2] * d;\n const m3 = this.m[0] * d;\n const m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);\n const m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);\n this.m[0] = m0;\n this.m[1] = m1;\n this.m[2] = m2;\n this.m[3] = m3;\n this.m[4] = m4;\n this.m[5] = m5;\n return this;\n }\n /**\n * return matrix\n * @method\n * @name Konva.Transform#getMatrix\n */\n getMatrix() {\n return this.m;\n }\n /**\n * convert transformation matrix back into node's attributes\n * @method\n * @name Konva.Transform#decompose\n * @returns {Konva.Transform}\n */\n decompose() {\n const a = this.m[0];\n const b = this.m[1];\n const c = this.m[2];\n const d = this.m[3];\n const e = this.m[4];\n const f = this.m[5];\n const delta = a * d - b * c;\n const result = {\n x: e,\n y: f,\n rotation: 0,\n scaleX: 0,\n scaleY: 0,\n skewX: 0,\n skewY: 0,\n };\n // Apply the QR-like decomposition. A zero determinant (a scale of 0, or\n // a shear that collapses the plane) has no skew, rather than a NaN or\n // an infinite one\n if (a != 0 || b != 0) {\n const r = Math.sqrt(a * a + b * b);\n result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);\n result.scaleX = r;\n result.scaleY = delta / r;\n result.skewX = delta && (a * c + b * d) / delta;\n result.skewY = 0;\n }\n else if (c != 0 || d != 0) {\n const s = Math.sqrt(c * c + d * d);\n result.rotation =\n Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));\n result.scaleX = delta / s;\n result.scaleY = s;\n result.skewX = 0;\n result.skewY = delta && (a * c + b * d) / delta;\n }\n else {\n // a = b = c = d = 0\n }\n result.rotation = Util._getRotation(result.rotation);\n return result;\n }\n}\n// CONSTANTS\nconst OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', COLORS = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n transparent: [0, 0, 0, 0],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n// Cache for canvas farbling detection\nlet _isCanvasFarblingActive = null;\n// A stage may be rendered in another window than the one Konva was imported\n// into, and a window that is not visible gives almost no frames. So frames are\n// asked from the window of the stage, and the callbacks are kept per window\nconst defaultWindow = typeof window !== 'undefined' ? window : {};\nconst animQueues = new WeakMap();\nconst requestFrame = (win, f) => {\n if (typeof win.requestAnimationFrame === 'function') {\n win.requestAnimationFrame(f);\n }\n else if (typeof requestAnimationFrame !== 'undefined') {\n requestAnimationFrame(f);\n }\n else {\n setTimeout(f, 16); // 60fps ≈ 16.67ms per frame\n }\n};\nconst capitalizeCache = new Map();\n// the common ancestor of every typed array\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description\nexport const TypedArray = Object.getPrototypeOf(Int8Array);\n// Split the components of rgb()/hsl(). CSS separates them with commas (legacy\n// syntax), or with spaces and a slash before the alpha (CSS Color 4 syntax),\n// but never with both. Keep the two apart, so that a space inside a\n// comma-separated color adds no component. A component the user left empty\n// stays as \"\", which then fails the color.\nconst splitColorComponents = (str) => {\n const components = str.trim();\n return components.indexOf(',') === -1\n ? components.split(/\\s*\\/\\s*|\\s+/)\n : components.split(/\\s*,\\s*/);\n};\n// A CSS number: \"50\", \"-0.5\", \".5\", \"1e2\". Everything else, from \"50abc\" to\n// \"0x10\" and \"1.2.3\", is not a number and makes the color fail.\nconst NUMBER_SOURCE = '[+-]?(?:\\\\d+\\\\.?\\\\d*|\\\\.\\\\d+)(?:e[+-]?\\\\d+)?';\n// A component is a number with an optional \"%\" sign.\nconst COLOR_COMPONENT_REGEX = new RegExp(`^(${NUMBER_SOURCE})(%?)$`, 'i');\n// Parse one color component. 100% is `max`: 255 for the color channels of\n// rgb(), 1 for the alpha, 100 for the saturation and the lightness of hsl().\nconst parseColorComponent = (value, max) => {\n const match = COLOR_COMPONENT_REGEX.exec(value);\n if (!match) {\n return NaN;\n }\n return match[2] ? (Number(match[1]) / 100) * max : Number(match[1]);\n};\n// parseInt() stops at the first character it can not read, so \"#0g0000\" would\n// give a valid black instead of failing. The hex parsers test the shape first.\nconst HEX_COLOR_REGEX = /^#[0-9a-f]+$/i;\n// Keep a fraction in [0, 1]. NaN stays NaN, so a bad value still fails.\nconst clamp01 = (value) => Math.min(Math.max(value, 0), 1);\n// The hue of hsl() is the same number, with a CSS Color 4 angle unit\n// instead of the \"%\" sign. No unit means degrees.\nconst HUE_REGEX = new RegExp(`^(${NUMBER_SOURCE})(deg|grad|rad|turn)?$`, 'i');\nconst HUE_UNITS = {\n deg: 1,\n grad: 0.9,\n rad: DEG180_OVER_PI,\n turn: 360,\n};\n/**\n * @namespace Util\n * @memberof Konva\n */\n// a negative corner radius would throw in context.arc()\nfunction clampRadius(radius, max) {\n return Math.min(Math.max(radius || 0, 0), max);\n}\nexport const Util = {\n /*\n * cherry-picked utilities from underscore.js\n */\n _isElement(obj) {\n return !!(obj && obj.nodeType == 1);\n },\n _isFunction(obj) {\n return !!(obj && obj.constructor && obj.call && obj.apply);\n },\n _isPlainObject(obj) {\n return !!obj && obj.constructor === Object;\n },\n _isArray(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_ARRAY;\n },\n _isNumber(obj) {\n return (Object.prototype.toString.call(obj) === OBJECT_NUMBER &&\n !isNaN(obj) &&\n isFinite(obj));\n },\n _isString(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_STRING;\n },\n _isBoolean(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_BOOLEAN;\n },\n // arrays are objects too\n isObject(val) {\n return val instanceof Object;\n },\n isValidSelector(selector) {\n if (typeof selector !== 'string') {\n return false;\n }\n const firstChar = selector[0];\n return (firstChar === '#' ||\n firstChar === '.' ||\n firstChar === firstChar.toUpperCase());\n },\n _sign(number) {\n if (number === 0) {\n // that is not what sign usually returns\n // but that is what we need\n return 1;\n }\n if (number > 0) {\n return 1;\n }\n else {\n return -1;\n }\n },\n requestAnimFrame(callback, win) {\n const target = (win && !win.closed && win) || defaultWindow;\n let queue = animQueues.get(target);\n if (!queue) {\n queue = [];\n animQueues.set(target, queue);\n requestFrame(target, function () {\n animQueues.delete(target);\n queue.forEach(function (cb) {\n cb();\n });\n });\n }\n queue.push(callback);\n },\n createCanvasElement() {\n ensureBrowser();\n const canvas = document.createElement('canvas');\n // on some environments canvas.style is readonly\n try {\n canvas.style = canvas.style || {};\n }\n catch (e) { }\n return canvas;\n },\n createImageElement() {\n ensureBrowser();\n return document.createElement('img');\n },\n _isInDocument(el) {\n // not `el.parentNode == document`, because the element may belong to\n // another document: an iframe, or a popout window\n return !!el.isConnected;\n },\n /*\n * arg can be an image object or image data\n */\n _urlToImage(url, callback) {\n // if arg is a string, then it's a data url\n const imageObj = Util.createImageElement();\n imageObj.onload = function () {\n callback(imageObj);\n };\n imageObj.src = url;\n },\n _rgbToHex(r, g, b) {\n return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n },\n _hexToRgb(hex) {\n hex = hex.replace(HASH, EMPTY_STRING);\n const bigint = parseInt(hex, 16);\n return {\n r: (bigint >> 16) & 255,\n g: (bigint >> 8) & 255,\n b: bigint & 255,\n };\n },\n /**\n * return random hex color\n * @method\n * @memberof Konva.Util\n * @example\n * shape.fill(Konva.Util.getRandomColor());\n */\n getRandomColor() {\n let randColor = ((Math.random() * 0xffffff) << 0).toString(16);\n while (randColor.length < 6) {\n randColor = ZERO + randColor;\n }\n return HASH + randColor;\n },\n /**\n * Check if canvas farbling is active (e.g., Brave browser fingerprinting protection)\n * @method\n * @memberof Konva.Util\n * @returns {Boolean}\n */\n isCanvasFarblingActive() {\n if (_isCanvasFarblingActive !== null) {\n return _isCanvasFarblingActive;\n }\n if (typeof document === 'undefined') {\n _isCanvasFarblingActive = false;\n return false;\n }\n const c = this.createCanvasElement();\n c.width = 10;\n c.height = 10;\n const ctx = c.getContext('2d', {\n willReadFrequently: true,\n });\n ctx.clearRect(0, 0, 10, 10);\n ctx.fillStyle = '#282828'; // 40, 40, 40\n ctx.fillRect(0, 0, 10, 10);\n const d = ctx.getImageData(0, 0, 10, 10).data;\n let isFarbling = false;\n for (let i = 0; i < 100; i++) {\n if (d[i * 4] !== 40 ||\n d[i * 4 + 1] !== 40 ||\n d[i * 4 + 2] !== 40 ||\n d[i * 4 + 3] !== 255) {\n isFarbling = true;\n break;\n }\n }\n _isCanvasFarblingActive = isFarbling;\n this.releaseCanvas(c);\n return _isCanvasFarblingActive;\n },\n /**\n * Get a random color for hit detection (snapped to the hit color grid)\n * @method\n * @memberof Konva.Util\n * @returns {String} hex color string\n */\n getHitColor() {\n const channel = () => (Math.random() * 256) | 0;\n return this.getHitColorKey(channel(), channel(), channel());\n },\n /**\n * Get hit color key from RGB values (snapped to the hit color grid)\n * @method\n * @memberof Konva.Util\n * @param {Number} r - red component (0-255)\n * @param {Number} g - green component (0-255)\n * @param {Number} b - blue component (0-255)\n * @returns {String} hex color key string\n */\n getHitColorKey(r, g, b) {\n // hit colours live on a grid, so a pixel of the hit graph that reads\n // back slightly off still rounds to the key of its shape: an edge pixel\n // is stored premultiplied by its alpha and comes back off by up to one\n // per channel, canvas farbling (Brave) adds a little noise on top\n const step = this.isCanvasFarblingActive() ? 5 : 3;\n const snap = (value) => Math.round(value / step) * step;\n return HASH + this._rgbToHex(snap(r), snap(g), snap(b));\n },\n /**\n * Snap a hex color to the hit color grid\n * @method\n * @memberof Konva.Util\n * @param {String} hex - hex color string (e.g., \"#ff00ff\")\n * @returns {String} snapped hex color string\n */\n getSnappedHexColor(hex) {\n const { r, g, b } = this._hexToRgb(hex);\n return this.getHitColorKey(r, g, b);\n },\n /**\n * get RGB components of a color\n * @method\n * @memberof Konva.Util\n * @param {String} color\n * @example\n * // each of the following examples return {r:0, g:0, b:255}\n * var rgb = Konva.Util.getRGB('blue');\n * var rgb = Konva.Util.getRGB('#0000ff');\n * var rgb = Konva.Util.getRGB('rgb(0,0,255)');\n */\n getRGB(color) {\n var _a;\n // black for a color we can not parse\n const { r = 0, g = 0, b = 0 } = (_a = Util.colorToRGBA(color)) !== null && _a !== void 0 ? _a : {};\n return { r, g, b };\n },\n // convert any color string to RGBA object\n // from https://github.com/component/color-parser\n colorToRGBA(str) {\n // a CSS custom property keeps the space after the colon,\n // so \"--brand: #ff0000\" gives us \" #ff0000\"\n str = (str || '').trim() || 'black';\n const color = Util._namedColorToRBA(str) ||\n Util._hex3ColorToRGBA(str) ||\n Util._hex4ColorToRGBA(str) ||\n Util._hex6ColorToRGBA(str) ||\n Util._hex8ColorToRGBA(str) ||\n Util._rgbColorToRGBA(str) ||\n Util._hslColorToRGBA(str);\n // a NaN component stays invisible until it reaches the canvas and drops the\n // shape, so a color we can not fully parse must fail as a whole\n if (color && [color.r, color.g, color.b, color.a].every(Util._isNumber)) {\n return color;\n }\n },\n // Parse named css color. Like \"green\"\n _namedColorToRBA(str) {\n const c = COLORS[str.toLowerCase()];\n if (!c) {\n return null;\n }\n return {\n r: c[0],\n g: c[1],\n b: c[2],\n a: c.length > 3 ? c[3] : 1,\n };\n },\n // Parse rgb(n, n, n), rgba(n, n, n, n) and rgb(n n n / n)\n _rgbColorToRGBA(str) {\n const match = /^rgba?\\(([^)]*)\\)$/i.exec(str);\n if (!match) {\n return;\n }\n const parts = splitColorComponents(match[1]);\n if (parts.length < 3 || parts.length > 4) {\n return;\n }\n return {\n r: parseColorComponent(parts[0], 255),\n g: parseColorComponent(parts[1], 255),\n b: parseColorComponent(parts[2], 255),\n a: parts.length > 3 ? parseColorComponent(parts[3], 1) : 1,\n };\n },\n // Parse #nnnnnnnn\n _hex8ColorToRGBA(str) {\n if (str.length === 9 && HEX_COLOR_REGEX.test(str)) {\n return {\n r: parseInt(str.slice(1, 3), 16),\n g: parseInt(str.slice(3, 5), 16),\n b: parseInt(str.slice(5, 7), 16),\n a: parseInt(str.slice(7, 9), 16) / 0xff,\n };\n }\n },\n // Parse #nnnnnn\n _hex6ColorToRGBA(str) {\n if (str.length === 7 && HEX_COLOR_REGEX.test(str)) {\n return {\n r: parseInt(str.slice(1, 3), 16),\n g: parseInt(str.slice(3, 5), 16),\n b: parseInt(str.slice(5, 7), 16),\n a: 1,\n };\n }\n },\n // Parse #nnnn\n _hex4ColorToRGBA(str) {\n if (str.length === 5 && HEX_COLOR_REGEX.test(str)) {\n return {\n r: parseInt(str[1] + str[1], 16),\n g: parseInt(str[2] + str[2], 16),\n b: parseInt(str[3] + str[3], 16),\n a: parseInt(str[4] + str[4], 16) / 0xff,\n };\n }\n },\n // Parse #nnn\n _hex3ColorToRGBA(str) {\n if (str.length === 4 && HEX_COLOR_REGEX.test(str)) {\n return {\n r: parseInt(str[1] + str[1], 16),\n g: parseInt(str[2] + str[2], 16),\n b: parseInt(str[3] + str[3], 16),\n a: 1,\n };\n }\n },\n // Code adapted from https://github.com/Qix-/color-convert/blob/master/conversions.js#L244\n // Parse hsl(h, s%, l%), hsla(h, s%, l%, n) and hsl(h s% l% / n)\n _hslColorToRGBA(str) {\n const match = /^hsla?\\(([^)]*)\\)$/i.exec(str);\n if (!match) {\n return;\n }\n const parts = splitColorComponents(match[1]);\n if (parts.length < 3 || parts.length > 4) {\n return;\n }\n // a hue we can not parse gives a gray color instead of a NaN one,\n // so colorToRGBA() can not catch it at the end\n const hue = HUE_REGEX.exec(parts[0]);\n if (!hue) {\n return;\n }\n const unit = hue[2];\n const degrees = Number(hue[1]) * (unit ? HUE_UNITS[unit.toLowerCase()] : 1);\n if (!isFinite(degrees)) {\n return;\n }\n // the hue is an angle, so keep it in [0, 360) to also accept\n // negative angles and angles over one full turn\n const h = (((degrees % 360) + 360) % 360) / 360;\n // the saturation and the lightness are percentages of 1, written with or\n // without the \"%\" sign, so read them out of 100 and then scale them down.\n // CSS keeps them in [0, 1]; out of that range the math gives a negative\n // channel, which the canvas can not read at all.\n const s = clamp01(parseColorComponent(parts[1], 100) / 100);\n const l = clamp01(parseColorComponent(parts[2], 100) / 100);\n const a = parts.length > 3 ? parseColorComponent(parts[3], 1) : 1;\n const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const t1 = 2 * l - t2;\n const rgb = [0, 0, 0];\n for (let i = 0; i < 3; i++) {\n let t3 = h + (1 / 3) * -(i - 1);\n if (t3 < 0) {\n t3++;\n }\n if (t3 > 1) {\n t3--;\n }\n let val;\n if (6 * t3 < 1) {\n val = t1 + (t2 - t1) * 6 * t3;\n }\n else if (2 * t3 < 1) {\n val = t2;\n }\n else if (3 * t3 < 2) {\n val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n }\n else {\n val = t1;\n }\n rgb[i] = val * 255;\n }\n return {\n r: Math.round(rgb[0]),\n g: Math.round(rgb[1]),\n b: Math.round(rgb[2]),\n a,\n };\n },\n // the bounds of a flat [x0, y0, x1, y1, ...] array. A NaN coordinate is\n // skipped so one bad point cannot turn the whole box into NaN; no usable\n // point at all is an empty rect\n _getPointsRect(points) {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < points.length; i += 2) {\n const x = points[i];\n const y = points[i + 1];\n if (!isNaN(x)) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n }\n if (!isNaN(y)) {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n }\n if (!isFinite(minX + minY)) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n },\n /**\n * check intersection of two client rectangles\n * @method\n * @memberof Konva.Util\n * @param {Object} r1 - { x, y, width, height } client rectangle\n * @param {Object} r2 - { x, y, width, height } client rectangle\n * @example\n * const overlapping = Konva.Util.haveIntersection(shape1.getClientRect(), shape2.getClientRect());\n */\n haveIntersection(r1, r2) {\n return !(r2.x > r1.x + r1.width ||\n r2.x + r2.width < r1.x ||\n r2.y > r1.y + r1.height ||\n r2.y + r2.height < r1.y);\n },\n // a deep copy of plain objects and arrays; class instances and elements\n // are shared, typed arrays are copied\n cloneObject(obj) {\n const copy = {};\n for (const key in obj) {\n copy[key] = Util._cloneValue(obj[key]);\n }\n return copy;\n },\n _cloneValue(val) {\n if (Util._isArray(val)) {\n // a flat array (points) is sliced, an array holding objects copied deep\n return val.some((item) => typeof item === 'object')\n ? val.map(Util._cloneValue)\n : val.slice();\n }\n if (Util._isPlainObject(val)) {\n return Util.cloneObject(val);\n }\n return val instanceof TypedArray ? val.slice() : val;\n },\n cloneArray(arr) {\n return arr.slice(0);\n },\n degToRad(deg) {\n return deg * PI_OVER_DEG180;\n },\n radToDeg(rad) {\n return rad * DEG180_OVER_PI;\n },\n _getRotation(radians) {\n return Konva.angleDeg ? Util.radToDeg(radians) : radians;\n },\n // Memoized — called per-attr per setAttrs; input vocabulary is bounded.\n _capitalize(str) {\n const cached = capitalizeCache.get(str);\n if (cached !== undefined)\n return cached;\n const out = str.charAt(0).toUpperCase() + str.slice(1);\n capitalizeCache.set(str, out);\n return out;\n },\n throw(str) {\n throw new Error(KONVA_ERROR + str);\n },\n error(str) {\n console.error(KONVA_ERROR + str);\n },\n warn(str) {\n if (!Konva.showWarnings) {\n return;\n }\n console.warn(KONVA_WARNING + str);\n },\n _batchEvents(batch, run) {\n if (!batch)\n return run();\n let called = false;\n let active = true;\n try {\n batch(() => {\n if (called || !active) {\n Util.warn('eventBatchFunc must call its argument exactly once, synchronously.');\n return;\n }\n called = true;\n run();\n });\n }\n finally {\n active = false;\n if (!called) {\n Util.warn('eventBatchFunc must call its argument synchronously.');\n }\n }\n },\n each(obj, func) {\n for (const key in obj) {\n func(key, obj[key]);\n }\n },\n _inRange(val, left, right) {\n return left <= val && val < right;\n },\n _getProjectionToSegment(x1, y1, x2, y2, x3, y3) {\n let x, y, dist;\n const pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n if (pd2 == 0) {\n x = x1;\n y = y1;\n dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);\n }\n else {\n const u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;\n if (u < 0) {\n x = x1;\n y = y1;\n dist = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);\n }\n else if (u > 1.0) {\n x = x2;\n y = y2;\n dist = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);\n }\n else {\n x = x1 + u * (x2 - x1);\n y = y1 + u * (y2 - y1);\n dist = (x - x3) * (x - x3) + (y - y3) * (y - y3);\n }\n }\n return [x, y, dist];\n },\n // line as array of points.\n // line might be closed\n _getProjectionToLine(pt, line, isClosed) {\n const pc = Util.cloneObject(pt);\n let dist = Number.MAX_VALUE;\n line.forEach(function (p1, i) {\n if (!isClosed && i === line.length - 1) {\n return;\n }\n const p2 = line[(i + 1) % line.length];\n const proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);\n const px = proj[0], py = proj[1], pdist = proj[2];\n if (pdist < dist) {\n pc.x = px;\n pc.y = py;\n dist = pdist;\n }\n });\n return pc;\n },\n _prepareArrayForTween(startArray, endArray, isClosed) {\n const start = [], end = [];\n if (startArray.length > endArray.length) {\n const temp = endArray;\n endArray = startArray;\n startArray = temp;\n }\n for (let n = 0; n < startArray.length; n += 2) {\n start.push({\n x: startArray[n],\n y: startArray[n + 1],\n });\n }\n for (let n = 0; n < endArray.length; n += 2) {\n end.push({\n x: endArray[n],\n y: endArray[n + 1],\n });\n }\n const newStart = [];\n end.forEach(function (point) {\n const pr = Util._getProjectionToLine(point, start, isClosed);\n newStart.push(pr.x);\n newStart.push(pr.y);\n });\n return newStart;\n },\n // copies plain objects and arrays without DOM elements and circular\n // references, so the input (the live attrs of a node) is never modified.\n // Other objects (Date, class instances) are kept as they are\n _prepareToStringify(obj, ancestors = new Set()) {\n const copy = Util._isArray(obj) ? [] : {};\n ancestors.add(obj);\n for (const key of Object.keys(obj)) {\n const val = obj[key];\n if (Util._isElement(val) || ancestors.has(val)) {\n continue;\n }\n copy[key] =\n Util._isPlainObject(val) || Util._isArray(val)\n ? Util._prepareToStringify(val, ancestors)\n : val;\n }\n ancestors.delete(obj);\n return copy;\n },\n // very simplified version of Object.assign\n _assign(target, source) {\n for (const key in source) {\n target[key] = source[key];\n }\n return target;\n },\n _getFirstPointerId(evt) {\n if (!evt.touches) {\n // try to use pointer id or fake id\n return evt.pointerId || 999;\n }\n else {\n return evt.changedTouches[0].identifier;\n }\n },\n releaseCanvas(...canvases) {\n if (!Konva.releaseCanvasOnDestroy)\n return;\n canvases.forEach((c) => {\n c.width = 0;\n c.height = 0;\n });\n },\n // [topLeft, topRight, bottomRight, bottomLeft] radii that fit the box\n _cornerRadii(cornerRadius, width, height) {\n const max = Math.min(width, height) / 2;\n if (typeof cornerRadius === 'number') {\n const radius = clampRadius(cornerRadius, max);\n return [radius, radius, radius, radius];\n }\n return [\n clampRadius(cornerRadius[0], max),\n clampRadius(cornerRadius[1], max),\n clampRadius(cornerRadius[2], max),\n clampRadius(cornerRadius[3], max),\n ];\n },\n drawRoundedRectPath(context, width, height, cornerRadius) {\n // if negative dimensions, abs width/height and move rectangle\n let xOrigin = width < 0 ? width : 0;\n let yOrigin = height < 0 ? height : 0;\n width = Math.abs(width);\n height = Math.abs(height);\n const [topLeft, topRight, bottomRight, bottomLeft] = Util._cornerRadii(cornerRadius, width, height);\n context.moveTo(xOrigin + topLeft, yOrigin);\n context.lineTo(xOrigin + width - topRight, yOrigin);\n context.arc(xOrigin + width - topRight, yOrigin + topRight, topRight, (Math.PI * 3) / 2, 0, false);\n context.lineTo(xOrigin + width, yOrigin + height - bottomRight);\n context.arc(xOrigin + width - bottomRight, yOrigin + height - bottomRight, bottomRight, 0, Math.PI / 2, false);\n context.lineTo(xOrigin + bottomLeft, yOrigin + height);\n context.arc(xOrigin + bottomLeft, yOrigin + height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);\n context.lineTo(xOrigin, yOrigin + topLeft);\n context.arc(xOrigin + topLeft, yOrigin + topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);\n },\n drawRoundedPolygonPath(context, points, sides, radius, cornerRadius) {\n radius = Math.abs(radius);\n for (let i = 0; i < sides; i++) {\n const prev = points[(i - 1 + sides) % sides];\n const curr = points[i];\n const next = points[(i + 1) % sides];\n const vec1 = { x: curr.x - prev.x, y: curr.y - prev.y };\n const vec2 = { x: next.x - curr.x, y: next.y - curr.y };\n const len1 = Math.hypot(vec1.x, vec1.y);\n const len2 = Math.hypot(vec2.x, vec2.y);\n let currCornerRadius;\n if (typeof cornerRadius === 'number') {\n currCornerRadius = cornerRadius;\n }\n else {\n currCornerRadius = i < cornerRadius.length ? cornerRadius[i] : 0;\n }\n const maxCornerRadius = radius * Math.cos(Math.PI / sides);\n // cornerRadius creates perfect circle at 1/2 radius\n currCornerRadius =\n maxCornerRadius * Math.min(1, (currCornerRadius / radius) * 2);\n const normalVec1 = { x: vec1.x / len1, y: vec1.y / len1 };\n const normalVec2 = { x: vec2.x / len2, y: vec2.y / len2 };\n const p1 = {\n x: curr.x - normalVec1.x * currCornerRadius,\n y: curr.y - normalVec1.y * currCornerRadius,\n };\n const p2 = {\n x: curr.x + normalVec2.x * currCornerRadius,\n y: curr.y + normalVec2.y * currCornerRadius,\n };\n if (i === 0) {\n context.moveTo(p1.x, p1.y);\n }\n else {\n context.lineTo(p1.x, p1.y);\n }\n context.arcTo(curr.x, curr.y, p2.x, p2.y, currCornerRadius);\n }\n },\n};\n","import { Util } from \"./Util.js\";\nimport { Konva } from \"./Global.js\";\nfunction simplifyArray(arr) {\n const retArr = [], len = arr.length, util = Util;\n for (let n = 0; n < len; n++) {\n let val = arr[n];\n if (util._isNumber(val)) {\n val = Math.round(val * 1000) / 1000;\n }\n else if (!util._isString(val)) {\n val = val + '';\n }\n retArr.push(val);\n }\n return retArr;\n}\nconst COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', SEMICOLON = ';', DOUBLE_PAREN = '()', \n// EMPTY_STRING = '',\nEQUALS = '=', \n// SET = 'set',\nCONTEXT_METHODS = [\n 'arc',\n 'arcTo',\n 'beginPath',\n 'bezierCurveTo',\n 'clearRect',\n 'clip',\n 'closePath',\n 'createLinearGradient',\n 'createPattern',\n 'createRadialGradient',\n 'drawImage',\n 'ellipse',\n 'fill',\n 'fillText',\n 'getImageData',\n 'createImageData',\n 'lineTo',\n 'moveTo',\n 'putImageData',\n 'quadraticCurveTo',\n 'rect',\n 'roundRect',\n 'restore',\n 'rotate',\n 'save',\n 'scale',\n 'setLineDash',\n 'setTransform',\n 'stroke',\n 'strokeText',\n 'transform',\n 'translate',\n];\nconst CONTEXT_PROPERTIES = [\n 'fillStyle',\n 'strokeStyle',\n 'shadowColor',\n 'shadowBlur',\n 'shadowOffsetX',\n 'shadowOffsetY',\n 'letterSpacing',\n 'lineCap',\n 'lineDashOffset',\n 'lineJoin',\n 'lineWidth',\n 'miterLimit',\n 'direction',\n 'font',\n 'textAlign',\n 'textBaseline',\n 'globalAlpha',\n 'globalCompositeOperation',\n 'imageSmoothingEnabled',\n 'filter',\n];\nconst traceArrMax = 100;\n// Check if CSS filters are supported in the current browser\nlet _cssFiltersSupported = null;\nexport function isCSSFiltersSupported() {\n if (_cssFiltersSupported !== null) {\n return _cssFiltersSupported;\n }\n try {\n const canvas = Util.createCanvasElement();\n const ctx = canvas.getContext('2d');\n _cssFiltersSupported = !!ctx && 'filter' in ctx;\n Util.releaseCanvas(canvas);\n }\n catch (e) {\n _cssFiltersSupported = false;\n }\n return _cssFiltersSupported;\n}\n/**\n * Konva wrapper around native 2d canvas context. It has almost the same API of 2d context with some additional functions.\n * With core Konva shapes you don't need to use this object. But you will use it if you want to create\n * a [custom shape](/docs/react/Custom_Shape.html) or a [custom hit regions](/docs/events/Custom_Hit_Region.html).\n * For full information about each 2d context API use [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)\n * @constructor\n * @memberof Konva\n * @example\n * const rect = new Konva.Shape({\n * fill: 'red',\n * width: 100,\n * height: 100,\n * sceneFunc: (ctx, shape) => {\n * // ctx - is context wrapper\n * // shape - is instance of Konva.Shape, so it equals to \"rect\" variable\n * ctx.rect(0, 0, shape.getAttr('width'), shape.getAttr('height'));\n *\n * // automatically fill shape from props and draw hit region\n * ctx.fillStrokeShape(shape);\n * }\n * })\n */\nexport class Context {\n constructor(canvas) {\n this.canvas = canvas;\n if (Konva.enableTrace) {\n this.traceArr = [];\n this._enableTrace();\n }\n }\n /**\n * fill shape\n * @method\n * @name Konva.Context#fillShape\n * @param {Konva.Shape} shape\n */\n fillShape(shape) {\n if (shape.fillEnabled()) {\n this._fill(shape);\n }\n }\n _fill(shape) {\n // abstract\n }\n /**\n * stroke shape\n * @method\n * @name Konva.Context#strokeShape\n * @param {Konva.Shape} shape\n */\n strokeShape(shape) {\n if (shape.hasStroke()) {\n this._stroke(shape);\n }\n }\n _stroke(shape) {\n // abstract\n }\n /**\n * fill then stroke\n * @method\n * @name Konva.Context#fillStrokeShape\n * @param {Konva.Shape} shape\n */\n fillStrokeShape(shape) {\n if (shape.attrs.fillAfterStrokeEnabled) {\n this.strokeShape(shape);\n this.fillShape(shape);\n }\n else {\n this.fillShape(shape);\n this.strokeShape(shape);\n }\n }\n getTrace(relaxed, rounded) {\n let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;\n for (n = 0; n < len; n++) {\n trace = traceArr[n];\n method = trace.method;\n // methods\n if (method) {\n args = trace.args;\n str += method;\n if (relaxed) {\n str += DOUBLE_PAREN;\n }\n else {\n if (rounded) {\n args = args.map((a) => (typeof a === 'number' ? Math.floor(a) : a));\n }\n str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;\n }\n }\n else {\n // properties\n str += trace.property;\n if (!relaxed) {\n str += EQUALS + trace.val;\n }\n }\n str += SEMICOLON;\n }\n return str;\n }\n clearTrace() {\n this.traceArr = [];\n }\n _trace(str) {\n let traceArr = this.traceArr, len;\n traceArr.push(str);\n len = traceArr.length;\n if (len >= traceArrMax) {\n traceArr.shift();\n }\n }\n /**\n * reset canvas context transform\n * @method\n * @name Konva.Context#reset\n */\n reset() {\n const pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);\n }\n /**\n * get canvas wrapper\n * @method\n * @name Konva.Context#getCanvas\n * @returns {Konva.Canvas}\n */\n getCanvas() {\n return this.canvas;\n }\n /**\n * clear canvas\n * @method\n * @name Konva.Context#clear\n * @param {Object} [bounds]\n * @param {Number} [bounds.x]\n * @param {Number} [bounds.y]\n * @param {Number} [bounds.width]\n * @param {Number} [bounds.height]\n */\n clear(bounds) {\n const canvas = this.getCanvas();\n if (bounds) {\n this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);\n }\n else {\n this.clearRect(0, 0, canvas.getWidth() / canvas.pixelRatio, canvas.getHeight() / canvas.pixelRatio);\n }\n }\n _applyLineCap(shape) {\n const lineCap = shape.attrs.lineCap;\n if (lineCap) {\n this.setAttr('lineCap', lineCap);\n }\n }\n _applyOpacity(shape) {\n const absOpacity = shape.getAbsoluteOpacity();\n if (absOpacity !== 1) {\n this.setAttr('globalAlpha', absOpacity);\n }\n }\n _applyLineJoin(shape) {\n const lineJoin = shape.attrs.lineJoin;\n if (lineJoin) {\n this.setAttr('lineJoin', lineJoin);\n }\n }\n _applyMiterLimit(shape) {\n const miterLimit = shape.attrs.miterLimit;\n if (miterLimit != null) {\n this.setAttr('miterLimit', miterLimit);\n }\n }\n setAttr(attr, val) {\n this._context[attr] = val;\n }\n /**\n * arc function.\n * @method\n * @name Konva.Context#arc\n */\n arc(x, y, radius, startAngle, endAngle, counterClockwise) {\n this._context.arc(x, y, radius, startAngle, endAngle, counterClockwise);\n }\n /**\n * arcTo function.\n * @method\n * @name Konva.Context#arcTo\n *\n */\n arcTo(x1, y1, x2, y2, radius) {\n this._context.arcTo(x1, y1, x2, y2, radius);\n }\n /**\n * beginPath function.\n * @method\n * @name Konva.Context#beginPath\n */\n beginPath() {\n this._context.beginPath();\n }\n /**\n * bezierCurveTo function.\n * @method\n * @name Konva.Context#bezierCurveTo\n */\n bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {\n this._context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);\n }\n /**\n * clearRect function.\n * @method\n * @name Konva.Context#clearRect\n */\n clearRect(x, y, width, height) {\n this._context.clearRect(x, y, width, height);\n }\n clip(...args) {\n this._context.clip.apply(this._context, args);\n }\n /**\n * closePath function.\n * @method\n * @name Konva.Context#closePath\n */\n closePath() {\n this._context.closePath();\n }\n /**\n * createImageData function.\n * @method\n * @name Konva.Context#createImageData\n */\n createImageData(width, height) {\n const a = arguments;\n if (a.length === 2) {\n return this._context.createImageData(width, height);\n }\n else if (a.length === 1) {\n return this._context.createImageData(width);\n }\n }\n /**\n * createLinearGradient function.\n * @method\n * @name Konva.Context#createLinearGradient\n */\n createLinearGradient(x0, y0, x1, y1) {\n return this._context.createLinearGradient(x0, y0, x1, y1);\n }\n /**\n * createPattern function.\n * @method\n * @name Konva.Context#createPattern\n */\n createPattern(image, repetition) {\n return this._context.createPattern(image, repetition);\n }\n /**\n * createRadialGradient function.\n * @method\n * @name Konva.Context#createRadialGradient\n */\n createRadialGradient(x0, y0, r0, x1, y1, r1) {\n return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);\n }\n /**\n * drawImage function.\n * @method\n * @name Konva.Context#drawImage\n */\n drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {\n // this._context.drawImage(...arguments);\n const a = arguments, _context = this._context;\n if (a.length === 3) {\n _context.drawImage(image, sx, sy);\n }\n else if (a.length === 5) {\n _context.drawImage(image, sx, sy, sWidth, sHeight);\n }\n else if (a.length === 9) {\n _context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);\n }\n }\n /**\n * ellipse function.\n * @method\n * @name Konva.Context#ellipse\n */\n ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {\n this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);\n }\n /**\n * isPointInPath function.\n * @method\n * @name Konva.Context#isPointInPath\n */\n isPointInPath(x, y, path, fillRule) {\n if (path) {\n return this._context.isPointInPath(path, x, y, fillRule);\n }\n return this._context.isPointInPath(x, y, fillRule);\n }\n fill(...args) {\n // this._context.fill();\n this._context.fill.apply(this._context, args);\n }\n /**\n * fillRect function.\n * @method\n * @name Konva.Context#fillRect\n */\n fillRect(x, y, width, height) {\n this._context.fillRect(x, y, width, height);\n }\n /**\n * strokeRect function.\n * @method\n * @name Konva.Context#strokeRect\n */\n strokeRect(x, y, width, height) {\n this._context.strokeRect(x, y, width, height);\n }\n /**\n * fillText function.\n * @method\n * @name Konva.Context#fillText\n */\n fillText(text, x, y, maxWidth) {\n if (maxWidth) {\n this._context.fillText(text, x, y, maxWidth);\n }\n else {\n this._context.fillText(text, x, y);\n }\n }\n /**\n * measureText function.\n * @method\n * @name Konva.Context#measureText\n */\n measureText(text) {\n return this._context.measureText(text);\n }\n /**\n * getImageData function.\n * @method\n * @name Konva.Context#getImageData\n */\n getImageData(sx, sy, sw, sh) {\n return this._context.getImageData(sx, sy, sw, sh);\n }\n /**\n * lineTo function.\n * @method\n * @name Konva.Context#lineTo\n */\n lineTo(x, y) {\n this._context.lineTo(x, y);\n }\n /**\n * moveTo function.\n * @method\n * @name Konva.Context#moveTo\n */\n moveTo(x, y) {\n this._context.moveTo(x, y);\n }\n /**\n * rect function.\n * @method\n * @name Konva.Context#rect\n */\n rect(x, y, width, height) {\n this._context.rect(x, y, width, height);\n }\n /**\n * roundRect function.\n * @method\n * @name Konva.Context#roundRect\n */\n roundRect(x, y, width, height, radii) {\n this._context.roundRect(x, y, width, height, radii);\n }\n /**\n * putImageData function.\n * @method\n * @name Konva.Context#putImageData\n */\n putImageData(imageData, dx, dy) {\n this._context.putImageData(imageData, dx, dy);\n }\n /**\n * quadraticCurveTo function.\n * @method\n * @name Konva.Context#quadraticCurveTo\n */\n quadraticCurveTo(cpx, cpy, x, y) {\n this._context.quadraticCurveTo(cpx, cpy, x, y);\n }\n /**\n * restore function.\n * @method\n * @name Konva.Context#restore\n */\n restore() {\n this._context.restore();\n }\n /**\n * rotate function.\n * @method\n * @name Konva.Context#rotate\n */\n rotate(angle) {\n this._context.rotate(angle);\n }\n /**\n * save function.\n * @method\n * @name Konva.Context#save\n */\n save() {\n this._context.save();\n }\n /**\n * scale function.\n * @method\n * @name Konva.Context#scale\n */\n scale(x, y) {\n this._context.scale(x, y);\n }\n /**\n * setLineDash function.\n * @method\n * @name Konva.Context#setLineDash\n */\n setLineDash(segments) {\n this._context.setLineDash(segments);\n }\n /**\n * getLineDash function.\n * @method\n * @name Konva.Context#getLineDash\n */\n getLineDash() {\n return this._context.getLineDash();\n }\n /**\n * setTransform function.\n * @method\n * @name Konva.Context#setTransform\n */\n setTransform(a, b, c, d, e, f) {\n this._context.setTransform(a, b, c, d, e, f);\n }\n /**\n * stroke function.\n * @method\n * @name Konva.Context#stroke\n */\n stroke(path2d) {\n if (path2d) {\n this._context.stroke(path2d);\n }\n else {\n this._context.stroke();\n }\n }\n /**\n * strokeText function.\n * @method\n * @name Konva.Context#strokeText\n */\n strokeText(text, x, y, maxWidth) {\n this._context.strokeText(text, x, y, maxWidth);\n }\n /**\n * transform function.\n * @method\n * @name Konva.Context#transform\n */\n transform(a, b, c, d, e, f) {\n this._context.transform(a, b, c, d, e, f);\n }\n /**\n * translate function.\n * @method\n * @name Konva.Context#translate\n */\n translate(x, y) {\n this._context.translate(x, y);\n }\n _enableTrace() {\n let that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;\n // to prevent creating scope function at each loop\n const func = function (methodName) {\n let origMethod = that[methodName], ret;\n that[methodName] = function () {\n args = simplifyArray(Array.prototype.slice.call(arguments, 0));\n ret = origMethod.apply(that, arguments);\n that._trace({\n method: methodName,\n args: args,\n });\n return ret;\n };\n };\n // methods\n for (n = 0; n < len; n++) {\n func(CONTEXT_METHODS[n]);\n }\n // attrs\n that.setAttr = function () {\n origSetter.apply(that, arguments);\n const prop = arguments[0];\n let val = arguments[1];\n if (prop === 'shadowOffsetX' ||\n prop === 'shadowOffsetY' ||\n prop === 'shadowBlur') {\n val = val / this.canvas.getPixelRatio();\n }\n that._trace({\n property: prop,\n val: val,\n });\n };\n }\n _applyGlobalCompositeOperation(node) {\n const op = node.attrs.globalCompositeOperation;\n const def = !op || op === 'source-over';\n if (!def) {\n this.setAttr('globalCompositeOperation', op);\n }\n }\n}\nCONTEXT_PROPERTIES.forEach(function (prop) {\n Object.defineProperty(Context.prototype, prop, {\n get() {\n return this._context[prop];\n },\n set(val) {\n this._context[prop] = val;\n },\n });\n});\nexport class SceneContext extends Context {\n constructor(canvas, { willReadFrequently = false } = {}) {\n super(canvas);\n this._context = canvas._canvas.getContext('2d', {\n willReadFrequently,\n });\n }\n _fillColor(shape) {\n const fill = shape.fill();\n this.setAttr('fillStyle', fill);\n shape._fillFunc(this);\n }\n _fillPattern(shape) {\n // `imageSmoothingEnabled` (set on the layer/context) controls pattern\n // smoothing in the browser. node-canvas ignores it for pattern fills and\n // instead exposes a non-standard `patternQuality` property, so mirror the\n // current smoothing setting onto it to keep both backends consistent.\n const context = this._context;\n if ('patternQuality' in context) {\n context.patternQuality = context.imageSmoothingEnabled\n ? 'good'\n : 'nearest';\n }\n this.setAttr('fillStyle', shape._getFillPattern());\n shape._fillFunc(this);\n }\n _fillLinearGradient(shape) {\n const grd = shape._getLinearGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n }\n _fillRadialGradient(shape) {\n const grd = shape._getRadialGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n }\n _fill(shape) {\n const hasColor = shape.fill(), fillPriority = shape.getFillPriority();\n // priority fills\n if (hasColor && fillPriority === 'color') {\n this._fillColor(shape);\n return;\n }\n const hasPattern = shape.getFillPatternImage();\n if (hasPattern && fillPriority === 'pattern') {\n this._fillPattern(shape);\n return;\n }\n const hasLinearGradient = shape.getFillLinearGradientColorStops();\n if (hasLinearGradient && fillPriority === 'linear-gradient') {\n this._fillLinearGradient(shape);\n return;\n }\n const hasRadialGradient = shape.getFillRadialGradientColorStops();\n if (hasRadialGradient && fillPriority === 'radial-gradient') {\n this._fillRadialGradient(shape);\n return;\n }\n // now just try and fill with whatever is available\n if (hasColor) {\n this._fillColor(shape);\n }\n else if (hasPattern) {\n this._fillPattern(shape);\n }\n else if (hasLinearGradient) {\n this._fillLinearGradient(shape);\n }\n else if (hasRadialGradient) {\n this._fillRadialGradient(shape);\n }\n }\n _strokeLinearGradient(shape) {\n const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);\n if (colorStops) {\n // build color stops\n for (let n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n this.setAttr('strokeStyle', grd);\n }\n }\n _stroke(shape) {\n const dash = shape.dash(), \n // ignore strokeScaleEnabled for Text\n strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (!strokeScaleEnabled) {\n this.save();\n const pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n if (dash && shape.dashEnabled()) {\n this.setLineDash(dash);\n this.setAttr('lineDashOffset', shape.dashOffset());\n }\n this.setAttr('lineWidth', shape.strokeWidth());\n if (!shape.getShadowForStrokeEnabled()) {\n this.setAttr('shadowColor', 'rgba(0,0,0,0)');\n }\n const hasLinearGradient = shape.getStrokeLinearGradientColorStops();\n if (hasLinearGradient) {\n this._strokeLinearGradient(shape);\n }\n else {\n this.setAttr('strokeStyle', shape.stroke());\n }\n shape._strokeFunc(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n _applyShadow(shape) {\n var _a;\n const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = shape.getShadowBlur(), offset = shape.getShadowOffset(), scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;\n this.setAttr('shadowColor', color);\n this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));\n this.setAttr('shadowOffsetX', offset.x * scaleX);\n this.setAttr('shadowOffsetY', offset.y * scaleY);\n }\n}\nexport class HitContext extends Context {\n constructor(canvas) {\n super(canvas);\n this._context = canvas._canvas.getContext('2d', {\n willReadFrequently: true,\n });\n }\n _fill(shape) {\n this.save();\n this.setAttr('fillStyle', shape.colorKey);\n shape._fillFuncHit(this);\n this.restore();\n }\n strokeShape(shape) {\n if (shape.hasHitStroke()) {\n this._stroke(shape);\n }\n }\n _stroke(shape) {\n // ignore strokeScaleEnabled for Text\n const strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (!strokeScaleEnabled) {\n this.save();\n const pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n const hitStrokeWidth = shape.hitStrokeWidth();\n const strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;\n this.setAttr('lineWidth', strokeWidth);\n this.setAttr('strokeStyle', shape.colorKey);\n shape._strokeFuncHit(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n}\n","import { Util } from \"./Util.js\";\nimport { SceneContext, HitContext } from \"./Context.js\";\nimport { Konva } from \"./Global.js\";\n/**\n * Canvas Renderer constructor. It is a wrapper around native canvas element.\n * Usually you don't need to use it manually.\n * @constructor\n * @abstract\n * @memberof Konva\n * @param {Object} config\n * @param {Number} config.width\n * @param {Number} config.height\n * @param {Number} config.pixelRatio\n */\nexport class Canvas {\n constructor(config) {\n this.pixelRatio = 1;\n // the bitmap size, in device pixels\n this.width = 0;\n this.height = 0;\n // the size the canvas was given, in CSS pixels; the bitmap truncates it\n this._logicalWidth = 0;\n this._logicalHeight = 0;\n this.isCache = false;\n // origin of a buffer canvas in the coordinate space of the canvas it is\n // drawn back into, see Shape.drawScene\n this.x = 0;\n this.y = 0;\n const conf = config || {};\n // a Konva.pixelRatio reset to undefined or 0 means the device ratio\n const pixelRatio = conf.pixelRatio ||\n Konva.pixelRatio ||\n Konva._global.devicePixelRatio ||\n 1;\n this.pixelRatio = pixelRatio;\n this._canvas = Util.createCanvasElement();\n // set inline styles\n this._canvas.style.padding = '0';\n this._canvas.style.margin = '0';\n this._canvas.style.border = '0';\n this._canvas.style.background = 'transparent';\n this._canvas.style.position = 'absolute';\n this._canvas.style.top = '0';\n this._canvas.style.left = '0';\n }\n /**\n * get canvas context\n * @method\n * @name Konva.Canvas#getContext\n * @returns {CanvasContext} context\n */\n getContext() {\n return this.context;\n }\n /**\n * get pixel ratio\n * @method\n * @name Konva.Canvas#getPixelRatio\n * @returns {Number} pixel ratio\n * @example\n * var pixelRatio = layer.getCanvas.getPixelRatio();\n */\n getPixelRatio() {\n return this.pixelRatio;\n }\n /**\n * set pixel ratio\n * KonvaJS automatically handles pixel ratio adustments in order to render crisp drawings\n * on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios\n * of 1. Some high end tablets and phones, like iPhones and iPads have a device pixel ratio\n * of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel\n * ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise\n * specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel\n * ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1.\n * @method\n * @name Konva.Canvas#setPixelRatio\n * @param {Number} pixelRatio\n * @example\n * layer.getCanvas().setPixelRatio(3);\n */\n setPixelRatio(pixelRatio) {\n this.pixelRatio = pixelRatio;\n this.setSize(this._logicalWidth, this._logicalHeight);\n }\n setWidth(width) {\n this.setSize(width, this._logicalHeight);\n }\n setHeight(height) {\n this.setSize(this._logicalWidth, height);\n }\n getWidth() {\n return this.width;\n }\n getHeight() {\n return this.height;\n }\n // the bitmap holds whole pixels: a fractional pixel ratio truncates, and\n // a size that does not match the bitmap would resample every draw of it\n _bitmapSize(size) {\n return Math.floor((size || 0) * this.pixelRatio);\n }\n setSize(width, height) {\n // a NaN or Infinity size would silently give an empty bitmap\n if (!isFinite(width !== null && width !== void 0 ? width : 0) || !isFinite(height !== null && height !== void 0 ? height : 0)) {\n Util.error(`Canvas size must be finite numbers, got ${width}x${height}. The canvas is left empty.`);\n width = height = 0;\n }\n width = width || 0;\n height = height || 0;\n const pixelRatio = this.pixelRatio;\n this._logicalWidth = width;\n this._logicalHeight = height;\n // take into account pixel ratio. Assigning a dimension reallocates the\n // bitmap and resets the whole context state, so scale once after both\n this.width = this._canvas.width = this._bitmapSize(width);\n this.height = this._canvas.height = this._bitmapSize(height);\n this._canvas.style.width = width + 'px';\n this._canvas.style.height = height + 'px';\n this.getContext()._context.scale(pixelRatio, pixelRatio);\n }\n // setSize() re-allocates and clears the canvas even for the same size,\n // so lazily sized canvases use this to stay untouched when nothing changed\n setSizeIfChanged(width, height) {\n if (this.width !== this._bitmapSize(width) ||\n this.height !== this._bitmapSize(height)) {\n this.setSize(width, height);\n }\n }\n /**\n * to data url\n * @method\n * @name Konva.Canvas#toDataURL\n * @param {String} mimeType\n * @param {Number} quality between 0 and 1 for jpg mime types\n * @returns {String} data url string\n */\n toDataURL(mimeType, quality) {\n try {\n // If this call fails (due to browser bug, like in Firefox 3.6),\n // then revert to previous no-parameter image/png behavior\n return this._canvas.toDataURL(mimeType, quality);\n }\n catch (e) {\n try {\n return this._canvas.toDataURL();\n }\n catch (err) {\n Util.error('Unable to get data URL. ' +\n err.message +\n ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n return '';\n }\n }\n }\n}\nexport class SceneCanvas extends Canvas {\n constructor(config = { width: 0, height: 0, willReadFrequently: false }) {\n super(config);\n this.context = new SceneContext(this, {\n willReadFrequently: config.willReadFrequently,\n });\n this.setSize(config.width, config.height);\n }\n}\nexport class HitCanvas extends Canvas {\n constructor(config = { width: 0, height: 0 }) {\n super(config);\n this.hitCanvas = true;\n this.context = new HitContext(this);\n this.setSize(config.width, config.height);\n }\n}\n","import { Konva } from \"./Global.js\";\nimport { Util } from \"./Util.js\";\nexport const DD = {\n get isDragging() {\n let flag = false;\n DD._dragElements.forEach((elem) => {\n if (elem.dragStatus === 'dragging') {\n flag = true;\n }\n });\n return flag;\n },\n justDragged: false,\n get node() {\n // return first dragging node\n let node;\n DD._dragElements.forEach((elem) => {\n node = elem.node;\n });\n return node;\n },\n _dragElements: new Map(),\n // Konva is imported into one window, but a stage may be rendered in another\n // one: an iframe, or a window opened with `window.open`. Such a window sends\n // its pointer events to itself, so `Konva.Stage` asks for every window it is\n // rendered in. The handlers get the window they listen to, as only that\n // window has pointer positions the stages of that window can use\n _listenToWindow(win) {\n const endDragBefore = (evt) => DD._endDragBefore(evt, win);\n const drag = (evt) => DD._batchEvents(() => DD._drag(evt, win), win);\n const endDragAfter = (evt) => DD._batchEvents(() => DD._endDragAfter(evt));\n win.addEventListener('mouseup', endDragBefore, true);\n win.addEventListener('touchend', endDragBefore, true);\n // add touchcancel to fix this: https://github.com/konvajs/konva/issues/1843\n win.addEventListener('touchcancel', endDragBefore, true);\n win.addEventListener('mousemove', drag);\n win.addEventListener('touchmove', drag);\n win.addEventListener('mouseup', endDragAfter, false);\n win.addEventListener('touchend', endDragAfter, false);\n win.addEventListener('touchcancel', endDragAfter, false);\n },\n _batchEvents(callback, win) {\n if (!DD._dragElements.size)\n return;\n // One scope per integration, even when several stages use the same callback.\n // Keep all positions and handlers in the original order across those stages.\n const batches = new Set();\n for (const { node } of DD._dragElements.values()) {\n const stage = node.getStage();\n if (!stage || (win && stage._getOwnerWindow() !== win))\n continue;\n const batch = stage.eventBatchFunc();\n if (batch)\n batches.add(batch);\n }\n let run = callback;\n for (const batch of batches) {\n const next = run;\n run = () => Util._batchEvents(batch, next);\n }\n run();\n },\n // methods\n _drag(evt, win) {\n const nodesToFireEvents = [];\n // reading the positions forces a layout, so do it once per stage\n const positioned = new Set();\n DD._dragElements.forEach((elem, key) => {\n const { node } = elem;\n // we need to find pointer relative to that node\n const stage = node.getStage();\n // a pointer position of another window is relative to another viewport,\n // it would drag the node to a random place\n if (win && stage._getOwnerWindow() !== win) {\n return;\n }\n if (!positioned.has(stage)) {\n stage.setPointersPositions(evt);\n positioned.add(stage);\n }\n // it is possible that user call startDrag without any event\n // it that case we need to detect first movable pointer and attach it into the node\n if (elem.pointerId === undefined) {\n elem.pointerId = Util._getFirstPointerId(evt);\n }\n const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);\n // not related pointer\n if (!pos) {\n return;\n }\n if (elem.dragStatus !== 'dragging') {\n const dragDistance = node.dragDistance();\n const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));\n if (distance < dragDistance) {\n return;\n }\n node.startDrag({ evt });\n // a user can stop dragging inside `dragstart`\n if (!node.isDragging()) {\n return;\n }\n }\n node._setDragPosition(evt, elem);\n nodesToFireEvents.push(node);\n });\n // call dragmove only after ALL positions are changed\n nodesToFireEvents.forEach((node) => {\n // node may have been destroyed during a previous dragmove handler\n if (!node.getStage()) {\n return;\n }\n node.fire('dragmove', {\n type: 'dragmove',\n target: node,\n evt: evt,\n }, true);\n });\n },\n // dragBefore and dragAfter allows us to set correct order of events\n // setup all in dragbefore, and stop dragging only after pointerup triggered.\n _endDragBefore(evt, win) {\n const drawNodes = [];\n const positioned = new Set();\n DD._dragElements.forEach((elem, key) => {\n const { node } = elem;\n // we need to find pointer relative to that node\n const stage = node.getStage();\n // a pointer released in another window ends the drag too - the pointer\n // is up everywhere - but its position is not used for this stage\n if (evt &&\n !positioned.has(stage) &&\n (!win || stage._getOwnerWindow() === win)) {\n stage.setPointersPositions(evt);\n positioned.add(stage);\n }\n // a drag started without an event (node.startDrag()) that has not\n // moved yet has no pointer: any release ends it\n const released = elem.pointerId === undefined ||\n stage._changedPointerPositions.some((pos) => pos.id === elem.pointerId);\n // that pointer is not related: a \"ready\" element of another pointer\n // waits for its own release\n if (!released) {\n return;\n }\n if (elem.dragStatus === 'ready') {\n DD._dragElements.delete(key);\n }\n else {\n // if a node is stopped manually we still need to reset events:\n DD.justDragged = true;\n Konva._mouseListenClick = false;\n Konva._touchListenClick = false;\n // for real pointer input this reset comes too late — \"pointerup\" fired\n // before this handler — so Stage._pointerup also checks the live drag\n // state for the pointer family (issue #1756)\n Konva._pointerListenClick = false;\n elem.dragStatus = 'stopped';\n // a node that has not moved needs no redraw\n const drawNode = elem.node.getLayer() ||\n (elem.node instanceof Konva['Stage'] && elem.node);\n if (drawNode && drawNodes.indexOf(drawNode) === -1) {\n drawNodes.push(drawNode);\n }\n }\n });\n // draw in a sync way\n // because mousemove event may trigger BEFORE batch draw is called\n // but as we have not hit canvas updated yet, it will trigger incorrect mouseover/mouseout events\n drawNodes.forEach((drawNode) => {\n drawNode.draw();\n });\n },\n _endDragAfter(evt) {\n DD._dragElements.forEach((elem, key) => {\n if (elem.dragStatus !== 'stopped') {\n return;\n }\n elem.node.fire('dragend', {\n type: 'dragend',\n target: elem.node,\n evt: evt,\n }, true);\n // a dragend handler may have started a new drag of the node\n if (elem.dragStatus !== 'dragging') {\n DD._dragElements.delete(key);\n }\n });\n },\n};\n","import { Konva } from \"./Global.js\";\nconst Captures = new Map();\n// we may use this module for capturing touch events too\n// so make sure we don't do something super specific to pointer\nconst SUPPORT_POINTER_EVENTS = Konva._global['PointerEvent'] !== undefined;\nexport function getCapturedShape(pointerId) {\n return Captures.get(pointerId);\n}\nexport function createEvent(evt) {\n return {\n evt,\n pointerId: evt.pointerId,\n };\n}\nexport function hasPointerCapture(pointerId, shape) {\n return Captures.get(pointerId) === shape;\n}\nexport function setPointerCapture(pointerId, shape) {\n var _a;\n releaseCapture(pointerId);\n const stage = shape.getStage();\n if (!stage)\n return;\n Captures.set(pointerId, shape);\n if (SUPPORT_POINTER_EVENTS) {\n // capture on the DOM level too, so the stage keeps receiving the events\n // of that pointer even when it moves outside of the stage container\n // https://github.com/konvajs/konva/issues/1992\n try {\n (_a = stage.content) === null || _a === void 0 ? void 0 : _a.setPointerCapture(pointerId);\n }\n catch (e) {\n // capture is possible only for an active pointer;\n // ids of mouse and touch events (999 and touch identifiers) and\n // programmatic calls outside of a pointer event land here\n }\n shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));\n }\n}\n// a destroyed node must not keep receiving the events of its pointer\nexport function releaseCapturesOf(node) {\n Captures.forEach((shape, pointerId) => {\n if (shape === node) {\n releaseCapture(pointerId);\n }\n });\n}\nexport function releaseCapture(pointerId, target) {\n var _a;\n const shape = Captures.get(pointerId);\n // a node can only release its own capture\n if (!shape || (target && shape !== target))\n return;\n const stage = shape.getStage();\n Captures.delete(pointerId);\n if (SUPPORT_POINTER_EVENTS) {\n try {\n (_a = stage === null || stage === void 0 ? void 0 : stage.content) === null || _a === void 0 ? void 0 : _a.releasePointerCapture(pointerId);\n }\n catch (e) {\n // same as in setPointerCapture: the pointer may not be active\n }\n shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));\n }\n}\n","import { Konva } from \"./Global.js\";\nimport { TypedArray, Util } from \"./Util.js\";\nfunction _formatValue(val) {\n if (Util._isString(val)) {\n return '\"' + val + '\"';\n }\n if (Object.prototype.toString.call(val) === '[object Number]') {\n return val;\n }\n if (Util._isBoolean(val)) {\n return val;\n }\n return Object.prototype.toString.call(val);\n}\nexport function RGBComponent(val) {\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n return Math.round(val);\n}\nexport function getNumberValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n if (!Util._isNumber(val)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number.');\n }\n return val;\n };\n }\n}\nexport function getNumberOrArrayOfNumbersValidator(noOfElements) {\n if (Konva.isUnminified) {\n return function (val, attr) {\n let isNumber = Util._isNumber(val);\n let isValidArray = Util._isArray(val) && val.length == noOfElements;\n if (!isNumber && !isValidArray) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number or Array(' +\n noOfElements +\n ')');\n }\n return val;\n };\n }\n}\nexport function getNumberOrAutoValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n const isNumber = Util._isNumber(val);\n const isAuto = val === 'auto';\n if (!(isNumber || isAuto)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number or \"auto\".');\n }\n return val;\n };\n }\n}\nexport function getStringValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n if (!Util._isString(val)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a string.');\n }\n return val;\n };\n }\n}\nexport function getStringOrGradientValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n const isString = Util._isString(val);\n const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||\n (val && val['addColorStop']);\n if (!(isString || isGradient)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a string or a native gradient.');\n }\n return val;\n };\n }\n}\nexport function getNumberArrayValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n if (val instanceof TypedArray) {\n return val;\n }\n if (!Util._isArray(val)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a array of numbers.');\n }\n else {\n val.forEach(function (item) {\n if (!Util._isNumber(item)) {\n Util.warn('\"' +\n attr +\n '\" attribute has non numeric element ' +\n item +\n '. Make sure that all elements are numbers.');\n }\n });\n }\n return val;\n };\n }\n}\nexport function getBooleanValidator() {\n if (Konva.isUnminified) {\n return function (val, attr) {\n const isBool = val === true || val === false;\n if (!isBool) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a boolean.');\n }\n return val;\n };\n }\n}\nexport function getComponentValidator(components) {\n if (Konva.isUnminified) {\n return function (val, attr) {\n // ignore validation on undefined value, because it will reset to defalt\n if (val === undefined || val === null) {\n return val;\n }\n if (!Util.isObject(val)) {\n Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be an object with properties ' +\n components);\n }\n return val;\n };\n }\n}\n","import { Util } from \"./Util.js\";\nimport { getComponentValidator } from \"./Validators.js\";\nconst GET = 'get';\nconst SET = 'set';\nexport const Factory = {\n addGetterSetter(constructor, attr, def, validator, after) {\n Factory.addGetter(constructor, attr, def);\n Factory.addSetter(constructor, attr, validator, after);\n Factory.addOverloadedGetterSetter(constructor, attr);\n },\n addGetter(constructor, attr, def) {\n const method = GET + Util._capitalize(attr);\n constructor.prototype[method] =\n constructor.prototype[method] ||\n function () {\n const val = this.attrs[attr];\n return val === undefined ? def : val;\n };\n },\n addSetter(constructor, attr, validator, after) {\n const method = SET + Util._capitalize(attr);\n if (!constructor.prototype[method]) {\n Factory.overWriteSetter(constructor, attr, validator, after);\n }\n },\n overWriteSetter(constructor, attr, validator, after) {\n const method = SET + Util._capitalize(attr);\n constructor.prototype[method] = function (val) {\n if (validator && val !== undefined && val !== null) {\n val = validator.call(this, val, attr);\n }\n this._setAttr(attr, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n },\n addComponentsGetterSetter(constructor, attr, components, validator, after) {\n const len = components.length, capitalize = Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), keys = components.map((c) => attr + capitalize(c)), \n // built-in components have their own getters, e.g. getOffsetX\n getters = keys.map((key) => GET + capitalize(key));\n // getter\n constructor.prototype[getter] = function () {\n const ret = {};\n for (let n = 0; n < len; n++) {\n const get = this[getters[n]];\n ret[components[n]] = get ? get.call(this) : this.attrs[keys[n]];\n }\n return ret;\n };\n const basicValidator = getComponentValidator(components);\n // setter\n constructor.prototype[setter] = function (val) {\n const oldVal = this.attrs[attr];\n if (validator) {\n val = validator.call(this, val, attr);\n }\n if (basicValidator) {\n basicValidator.call(this, val, attr);\n }\n for (const key in val) {\n if (!val.hasOwnProperty(key)) {\n continue;\n }\n this._setAttr(attr + capitalize(key), val[key]);\n }\n if (!val) {\n components.forEach((component) => {\n this._setAttr(attr + capitalize(component), undefined);\n });\n }\n this._fireChangeEvent(attr, oldVal, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n Factory.addOverloadedGetterSetter(constructor, attr);\n },\n addOverloadedGetterSetter(constructor, attr) {\n const capitalizedAttr = Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;\n const accessor = function () {\n // setting\n if (arguments.length) {\n this[setter](arguments[0]);\n return this;\n }\n // getting\n return this[getter]();\n };\n // marks the accessor for toObject()\n accessor._isAttrAccessor = true;\n constructor.prototype[attr] = accessor;\n },\n backCompat(constructor, methods) {\n Util.each(methods, function (oldMethodName, newMethodName) {\n const method = constructor.prototype[newMethodName];\n const oldGetter = GET + Util._capitalize(oldMethodName);\n const oldSetter = SET + Util._capitalize(oldMethodName);\n function deprecated() {\n Util.error('\"' +\n oldMethodName +\n '\" method is deprecated and will be removed soon. Use \"\"' +\n newMethodName +\n '\" instead.');\n return method.apply(this, arguments);\n }\n constructor.prototype[oldMethodName] = deprecated;\n constructor.prototype[oldGetter] = deprecated;\n constructor.prototype[oldSetter] = deprecated;\n });\n },\n afterSetFilter() {\n this._filterUpToDate = false;\n },\n};\n","import { HitCanvas, SceneCanvas } from \"./Canvas.js\";\nimport { isCSSFiltersSupported } from \"./Context.js\";\nimport { DD } from \"./DragAndDrop.js\";\nimport * as PointerEvents from \"./PointerEvents.js\";\nimport { Factory } from \"./Factory.js\";\nimport { Konva } from \"./Global.js\";\nimport { Transform, Util } from \"./Util.js\";\nimport { getBooleanValidator, getNumberValidator, getStringValidator, } from \"./Validators.js\";\n// CSS filter parser for fallback to function filters\nfunction parseCSSFilters(cssFilter) {\n // Parse common CSS filter functions and map to Konva filters\n const filterRegex = /(\\w+)\\(([^)]+)\\)/g;\n let match;\n while ((match = filterRegex.exec(cssFilter)) !== null) {\n const [, filterName, filterValue] = match;\n switch (filterName) {\n case 'blur': {\n const blurRadius = parseFloat(filterValue.replace('px', ''));\n return function (imageData) {\n // CSS blur uses standard deviation, Stack Blur uses radius\n // Empirical testing shows CSS blur needs ~0.5 scaling for visual match\n this.blurRadius(blurRadius * 0.5);\n // Access filters through dynamic import to avoid circular dependency\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Blur) {\n KonvaFilters.Blur.call(this, imageData);\n }\n };\n }\n case 'brightness': {\n const brightness = filterValue.includes('%')\n ? parseFloat(filterValue) / 100\n : parseFloat(filterValue);\n return function (imageData) {\n this.brightness(brightness); // CSS uses multiplier\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Brightness) {\n KonvaFilters.Brightness.call(this, imageData);\n }\n };\n }\n case 'contrast': {\n const contrast = parseFloat(filterValue);\n return function (imageData) {\n // Convert CSS contrast to Konva parameter using square root conversion\n // to account for Konva's quadratic scaling: Math.pow((param + 100) / 100, 2)\n const konvaContrast = 100 * (Math.sqrt(contrast) - 1);\n this.contrast(konvaContrast);\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Contrast) {\n KonvaFilters.Contrast.call(this, imageData);\n }\n };\n }\n case 'grayscale': {\n return function (imageData) {\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Grayscale) {\n KonvaFilters.Grayscale.call(this, imageData);\n }\n };\n }\n case 'sepia': {\n return function (imageData) {\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Sepia) {\n KonvaFilters.Sepia.call(this, imageData);\n }\n };\n }\n case 'invert': {\n return function (imageData) {\n const KonvaFilters = Konva.Filters;\n if (KonvaFilters && KonvaFilters.Invert) {\n KonvaFilters.Invert.call(this, imageData);\n }\n };\n }\n default:\n Util.warn(`CSS filter \"${filterName}\" is not supported in fallback mode. Consider using function filters for better compatibility.`);\n break;\n }\n }\n return () => { };\n}\n// CONSTANTS\nconst ABSOLUTE_OPACITY = 'absoluteOpacity', ABSOLUTE_TRANSFORM = 'absoluteTransform', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', POINTERENTER = 'pointerenter', POINTERLEAVE = 'pointerleave', TOUCHENTER = 'touchenter', TOUCHLEAVE = 'touchleave', NON_BUBBLING_EVENTS = [\n MOUSEENTER,\n MOUSELEAVE,\n POINTERENTER,\n POINTERLEAVE,\n TOUCHENTER,\n TOUCHLEAVE,\n], SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [\n 'xChange.konva',\n 'yChange.konva',\n 'scaleXChange.konva',\n 'scaleYChange.konva',\n 'skewXChange.konva',\n 'skewYChange.konva',\n 'rotationChange.konva',\n 'offsetXChange.konva',\n 'offsetYChange.konva',\n 'transformsEnabledChange.konva',\n].join(SPACE);\nlet idCounter = 1;\n// \"perfect drawing\" buffer for cache() and toCanvas(): it mirrors the target\n// canvas and is drawn back at (x, y) in the target's coordinate space.\n// It starts empty and Shape.drawScene sizes it on first use, so nodes\n// without buffered shapes never allocate it.\nfunction createBufferCanvas(target, x, y) {\n const bufferCanvas = new SceneCanvas({\n width: 0,\n height: 0,\n pixelRatio: target.pixelRatio,\n });\n bufferCanvas.x = x;\n bufferCanvas.y = y;\n return bufferCanvas;\n}\n/**\n * Node constructor. Nodes are entities that can be transformed, layered,\n * and have bound events. The stage, layers, groups, and shapes all extend Node.\n * @constructor\n * @memberof Konva\n * @param {Object} config\n * @@nodeParams\n */\nexport class Node {\n constructor(config) {\n this._id = idCounter++;\n this.eventListeners = {};\n this.attrs = {};\n this.index = 0;\n this.parent = null;\n // derived values (transforms, visibility, opacity...), see _getCache()\n this._cache = {};\n // canvases of cache(), see _getCanvasCache()\n this._canvasCache = null;\n this._batchingTransformChange = false;\n this._needClearTransformCache = false;\n this._filterUpToDate = false;\n this._isUnderCache = false;\n this._dragEventId = null;\n this._shouldFireChangeEvents = false;\n // on initial set attrs wi don't need to fire change events\n // because nobody is listening to them yet\n this.setAttrs(config);\n this._shouldFireChangeEvents = true;\n // all change event listeners are attached to the prototype\n }\n hasChildren() {\n return false;\n }\n _clearCache(attr) {\n // if we want to clear transform cache\n // we don't really need to remove it from the cache\n // but instead mark as \"dirty\"\n // so we don't need to create a new instance next time\n if ((attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM) &&\n this._cache[attr]) {\n this._cache[attr].dirty = true;\n }\n else if (attr) {\n this._cache[attr] = undefined;\n }\n else {\n this._cache = {};\n // clearCache() also reaches descendants whose ancestor transform changes\n // were suppressed while cached. Invalidate their saved Transformer bounds.\n if (this._attrsVersion !== undefined)\n this._attrsVersion++;\n }\n }\n // drop the cached canvases and give their memory back\n _releaseCanvasCache() {\n const cache = this._canvasCache;\n if (cache) {\n Util.releaseCanvas(cache.scene._canvas, cache.filter._canvas, ...(cache.hit ? [cache.hit._canvas] : []));\n this._canvasCache = null;\n }\n }\n _getCache(attr, privateGetter) {\n let cache = this._cache[attr];\n // for transform the cache can be NOT empty\n // but we still need to recalculate it if it is dirty\n const isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;\n const invalid = cache === undefined || (isTransform && cache.dirty === true);\n // if not cached, we need to set it using the private getter method.\n if (invalid) {\n cache = privateGetter.call(this);\n this._cache[attr] = cache;\n }\n return cache;\n }\n _getCanvasCache() {\n return this._canvasCache;\n }\n /*\n * when the logic for a cached result depends on ancestor propagation, use this\n * method to clear self and children cache\n */\n _clearSelfAndDescendantCache(attr) {\n this._clearCache(attr);\n // trigger clear cache, so transformer can use it\n if (attr === ABSOLUTE_TRANSFORM) {\n this.fire('absoluteTransformChange');\n }\n }\n static _runAfterAbsTransformCascade(cb) {\n if (Node._absTransformCascadeDepth > 0) {\n Node._pendingAfterCascade.push(cb);\n }\n else {\n cb();\n }\n }\n /**\n * clear cached canvas\n * @method\n * @name Konva.Node#clearCache\n * @returns {Konva.Node}\n * @example\n * node.clearCache();\n */\n clearCache() {\n this._releaseCanvasCache();\n this._clearSelfAndDescendantCache();\n this._requestDraw();\n return this;\n }\n /**\n * cache node to improve drawing performance, apply filters, or create more accurate\n * hit regions. For all basic shapes size of cache canvas will be automatically detected.\n * If you need to cache your custom `Konva.Shape` instance you have to pass shape's bounding box\n * properties. Look at [https://konvajs.org/docs/performance/Shape_Caching.html](https://konvajs.org/docs/performance/Shape_Caching.html) for more information.\n * @method\n * @name Konva.Node#cache\n * @param {Object} [config]\n * @param {Number} [config.x]\n * @param {Number} [config.y]\n * @param {Number} [config.width]\n * @param {Number} [config.height]\n * @param {Number} [config.offset] increase canvas size by `offset` pixel in all directions.\n * @param {Boolean} [config.drawBorder] when set to true, a red border will be drawn around the cached\n * region for debugging purposes\n * @param {Number} [config.pixelRatio] pixel ratio of the cache canvas, the canvas pixels per CSS pixel of the node. Default is `Konva.pixelRatio`, the device pixel ratio. A higher value keeps the cache sharp when the node is scaled up.\n * @param {Boolean} [config.imageSmoothingEnabled] control imageSmoothingEnabled property of created canvas for cache\n * @param {Number} [config.hitCanvasPixelRatio] change quality (or pixel ratio) of cached hit canvas.\n * @returns {Konva.Node}\n * @example\n * // cache a shape with the x,y position of the bounding box at the center and\n * // the width and height of the bounding box equal to the width and height of\n * // the shape obtained from shape.width() and shape.height()\n * image.cache();\n *\n * // cache a node and define the bounding box position and size\n * node.cache({\n * x: -30,\n * y: -30,\n * width: 100,\n * height: 200\n * });\n *\n * // cache a node and draw a red border around the bounding box\n * // for debugging purposes\n * node.cache({\n * x: -30,\n * y: -30,\n * width: 100,\n * height: 200,\n * offset : 10,\n * drawBorder: true\n * });\n */\n cache(config) {\n const conf = config || {};\n let rect = {};\n // don't call getClientRect if we have all attributes\n // it means call it only if have one undefined\n if (conf.x === undefined ||\n conf.y === undefined ||\n conf.width === undefined ||\n conf.height === undefined) {\n rect = this.getClientRect({\n skipTransform: true,\n relativeTo: this.getParent() || undefined,\n });\n }\n let width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;\n if (!width || !height || !isFinite(x + y + width + height)) {\n Util.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${x}, ${y}, ${width}x${height}). Caching is skipped.`);\n return this;\n }\n // because using Math.floor on x, y position may shift drawing\n // to avoid shift we need to increase size\n // but we better to avoid it, for better filters flows\n const extraPaddingX = Math.abs(Math.round(rect.x) - x) > 0.5 ? 1 : 0;\n const extraPaddingY = Math.abs(Math.round(rect.y) - y) > 0.5 ? 1 : 0;\n width += offset * 2 + extraPaddingX;\n height += offset * 2 + extraPaddingY;\n x -= offset;\n y -= offset;\n const cachedSceneCanvas = new SceneCanvas({\n pixelRatio: pixelRatio,\n width: width,\n height: height,\n }), cachedFilterCanvas = new SceneCanvas({\n pixelRatio: pixelRatio,\n width: 0,\n height: 0,\n willReadFrequently: true,\n }), sceneContext = cachedSceneCanvas.getContext();\n const bufferCanvas = createBufferCanvas(cachedSceneCanvas, x, y);\n cachedSceneCanvas.isCache = true;\n this._releaseCanvasCache();\n this._filterUpToDate = false;\n if (conf.imageSmoothingEnabled === false) {\n cachedSceneCanvas.getContext()._context.imageSmoothingEnabled = false;\n cachedFilterCanvas.getContext()._context.imageSmoothingEnabled = false;\n }\n sceneContext.save();\n sceneContext.translate(-x, -y);\n // extra flag to skip on getAbsolute opacity calc\n this._isUnderCache = true;\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n try {\n this.drawScene(cachedSceneCanvas, this, bufferCanvas);\n }\n catch (e) {\n Util.releaseCanvas(cachedSceneCanvas._canvas);\n throw e;\n }\n finally {\n this._isUnderCache = false;\n // descendants cached their opacity relative to this node while drawing\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n sceneContext.restore();\n // the buffer is only needed while drawing\n Util.releaseCanvas(bufferCanvas._canvas);\n }\n // this will draw a red border around the cached box for\n // debugging purposes\n if (drawBorder) {\n sceneContext.save();\n sceneContext.beginPath();\n sceneContext.rect(0, 0, width, height);\n sceneContext.closePath();\n sceneContext.setAttr('strokeStyle', 'red');\n sceneContext.setAttr('lineWidth', 5);\n sceneContext.stroke();\n sceneContext.restore();\n }\n this._canvasCache = {\n scene: cachedSceneCanvas,\n filter: cachedFilterCanvas,\n // the hit canvas is built on demand (see _getCachedHitCanvas)\n hit: null,\n hitConfig: {\n pixelRatio: hitCanvasPixelRatio,\n width: width,\n height: height,\n },\n x: x,\n y: y,\n };\n this._requestDraw();\n return this;\n }\n // build the hit canvas of a cached node lazily - only when the hit graph\n // is actually needed, so a non-listening node never allocates it\n // https://github.com/konvajs/konva/issues/2009\n _getCachedHitCanvas(top) {\n // top === this means the node is drawing into its own cache right now:\n // the build below re-enters drawHit for this very node, and consulting\n // the not-yet-stored canvas again would recurse forever\n if (top === this) {\n return null;\n }\n const cache = this._getCanvasCache();\n if (!cache) {\n return null;\n }\n if (cache.hit) {\n return cache.hit;\n }\n const hitCanvas = new HitCanvas(cache.hitConfig);\n hitCanvas.isCache = true;\n const hitContext = hitCanvas.getContext();\n hitContext.save();\n hitContext.translate(-cache.x, -cache.y);\n this.drawHit(hitCanvas, this);\n hitContext.restore();\n cache.hit = hitCanvas;\n return hitCanvas;\n }\n /**\n * determine if node is currently cached\n * @method\n * @name Konva.Node#isCached\n * @returns {Boolean}\n */\n isCached() {\n return !!this._canvasCache;\n }\n /**\n * Return client rectangle {x, y, width, height} of node. This rectangle also include all styling (strokes, shadows, etc).\n * The purpose of the method is similar to getBoundingClientRect API of the DOM.\n * @method\n * @name Konva.Node#getClientRect\n * @param {Object} config\n * @param {Boolean} [config.skipTransform] should we apply transform to node for calculating rect?\n * @param {Boolean} [config.skipShadow] should we apply shadow to the node for calculating bound box?\n * @param {Boolean} [config.skipStroke] should we apply stroke to the node for calculating bound box?\n * @param {Object} [config.relativeTo] calculate client rect relative to one of the parents\n * @returns {Object} rect with {x, y, width, height} properties\n * @example\n * var rect = new Konva.Rect({\n * width : 100,\n * height : 100,\n * x : 50,\n * y : 50,\n * strokeWidth : 4,\n * stroke : 'black',\n * offsetX : 50,\n * scaleY : 2\n * });\n *\n * // get client rect without think off transformations (position, rotation, scale, offset, etc)\n * rect.getClientRect({ skipTransform: true});\n * // returns {\n * // x : -2, // two pixels for stroke / 2\n * // y : -2,\n * // width : 104, // increased by 4 for stroke\n * // height : 104\n * //}\n *\n * // get client rect with transformation applied\n * rect.getClientRect();\n * // returns Object {x: -2, y: 46, width: 104, height: 208}\n */\n getClientRect(config) {\n // abstract method\n // redefine in Container and Shape\n throw new Error('abstract \"getClientRect\" method call');\n }\n _transformedRect(rect, top) {\n const points = [\n { x: rect.x, y: rect.y },\n { x: rect.x + rect.width, y: rect.y },\n { x: rect.x + rect.width, y: rect.y + rect.height },\n { x: rect.x, y: rect.y + rect.height },\n ];\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n const trans = this.getAbsoluteTransform(top);\n points.forEach(function (point) {\n const transformed = trans.point(point);\n minX = Math.min(minX, transformed.x);\n minY = Math.min(minY, transformed.y);\n maxX = Math.max(maxX, transformed.x);\n maxY = Math.max(maxY, transformed.y);\n });\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n _drawCachedSceneCanvas(context) {\n context.save();\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n const canvasCache = this._getCanvasCache();\n context.translate(canvasCache.x, canvasCache.y);\n const cacheCanvas = this._getCachedSceneCanvas();\n const ratio = cacheCanvas.pixelRatio;\n context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);\n context.restore();\n }\n _drawCachedHitCanvas(context, hitCanvas) {\n const canvasCache = this._getCanvasCache();\n context.save();\n context.translate(canvasCache.x, canvasCache.y);\n context.drawImage(hitCanvas._canvas, 0, 0, hitCanvas.width / hitCanvas.pixelRatio, hitCanvas.height / hitCanvas.pixelRatio);\n context.restore();\n }\n _getCachedSceneCanvas() {\n let filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;\n if (!filters || filters.length === 0) {\n return sceneCanvas;\n }\n if (this._filterUpToDate) {\n return filterCanvas;\n }\n let useNativeOnly = true;\n for (let i = 0; i < filters.length; i++) {\n if (typeof filters[i] !== 'string' || !isCSSFiltersSupported()) {\n useNativeOnly = false;\n break;\n }\n }\n const ratio = sceneCanvas.pixelRatio;\n filterCanvas.setSizeIfChanged(sceneCanvas._logicalWidth, sceneCanvas._logicalHeight);\n if (useNativeOnly) {\n const finalFilter = filters.join(' ');\n filterContext.clear();\n filterContext.save();\n filterContext.setAttr('filter', finalFilter);\n filterContext.drawImage(sceneCanvas._canvas, 0, 0, sceneCanvas.getWidth() / ratio, sceneCanvas.getHeight() / ratio);\n filterContext.restore();\n this._filterUpToDate = true;\n return filterCanvas;\n }\n try {\n len = filters.length;\n filterContext.clear();\n // copy cached canvas onto filter context\n filterContext.drawImage(sceneCanvas._canvas, 0, 0, sceneCanvas.getWidth() / ratio, sceneCanvas.getHeight() / ratio);\n imageData = filterContext.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight());\n // apply filters to filter context\n for (n = 0; n < len; n++) {\n filter = filters[n];\n if (typeof filter === 'string') {\n filter = parseCSSFilters(filter);\n }\n filter.call(this, imageData);\n }\n filterContext.putImageData(imageData, 0, 0);\n }\n catch (e) {\n Util.error('Unable to apply filter. ' +\n e.message +\n ' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n }\n this._filterUpToDate = true;\n return filterCanvas;\n }\n /**\n * bind events to the node. KonvaJS supports mouseover, mousemove,\n * mouseout, mouseenter, mouseleave, mousedown, mouseup, wheel, contextmenu, click, dblclick, touchstart, touchmove,\n * touchend, tap, dbltap, dragstart, dragmove, dragend and destroy events.\n * Pass in a string of events delimited by a space to bind multiple events at once\n * such as 'mousedown mouseup mousemove'. Include a namespace to bind an\n * event by name such as 'click.foobar'.\n * @method\n * @name Konva.Node#on\n * @param {String} evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'\n * @param {Function} handler The handler function. The first argument of that function is event object. Event object has `target` as main target of the event, `currentTarget` as current node listener and `evt` as native browser event.\n * @returns {Konva.Node}\n * @example\n * // add click listener\n * node.on('click', function() {\n * console.log('you clicked me!');\n * });\n *\n * // get the target node\n * node.on('click', function(evt) {\n * console.log(evt.target);\n * });\n *\n * // stop event propagation\n * node.on('click', function(evt) {\n * evt.cancelBubble = true;\n * });\n *\n * // bind multiple listeners\n * node.on('click touchstart', function() {\n * console.log('you clicked/touched me!');\n * });\n *\n * // namespace listener\n * node.on('click.foo', function() {\n * console.log('you clicked/touched me!');\n * });\n *\n * // get the event type\n * node.on('click tap', function(evt) {\n * var eventType = evt.type;\n * });\n *\n * // get native event object\n * node.on('click tap', function(evt) {\n * var nativeEvent = evt.evt;\n * });\n *\n * // for change events, get the old and new val\n * node.on('xChange', function(evt) {\n * var oldVal = evt.oldVal;\n * var newVal = evt.newVal;\n * });\n *\n * // get event targets\n * // with event delegations\n * layer.on('click', 'Group', function(evt) {\n * var shape = evt.target;\n * var group = evt.currentTarget;\n * });\n */\n on(...args) {\n this._prepareListeners();\n const evtStr = args[0];\n const selectorOrHandler = args[1];\n const handler = args[2];\n if (args.length === 3) {\n return this._delegate.apply(this, args);\n }\n const events = evtStr.split(SPACE);\n /*\n * loop through types and attach event listeners to\n * each one. eg. 'click mouseover.namespace mouseout'\n * will create three event bindings\n */\n for (let n = 0; n < events.length; n++) {\n const event = events[n];\n const parts = event.split('.');\n const baseEvent = parts[0];\n const name = parts[1] || '';\n // create events array if it doesn't exist\n if (!this.eventListeners[baseEvent]) {\n this.eventListeners[baseEvent] = [];\n }\n this.eventListeners[baseEvent].push({ name, handler: selectorOrHandler });\n }\n return this;\n }\n /**\n * remove event bindings from the node. Pass in a string of\n * event types delimmited by a space to remove multiple event\n * bindings at once such as 'mousedown mouseup mousemove'.\n * include a namespace to remove an event binding by name\n * such as 'click.foobar'. If you only give a name like '.foobar',\n * all events in that namespace will be removed.\n * @method\n * @name Konva.Node#off\n * @param {String} evtStr e.g. 'click', 'mousedown touchstart', '.foobar'\n * @returns {Konva.Node}\n * @example\n * // remove listener\n * node.off('click');\n *\n * // remove multiple listeners\n * node.off('click touchstart');\n *\n * // remove listener by name\n * node.off('click.foo');\n */\n // listeners added to a prototype go into its own map, not the parent's,\n // and the lists flattened from the prototype chain so far are stale\n _prepareListeners() {\n if (this === this.constructor.prototype) {\n if (!this.hasOwnProperty('eventListeners')) {\n this.eventListeners = {};\n }\n Node.protoListenerMap = new WeakMap();\n }\n }\n off(evtStr, callback) {\n this._prepareListeners();\n let events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;\n if (!evtStr) {\n // remove all events\n for (t in this.eventListeners) {\n this._off(t);\n }\n }\n for (n = 0; n < len; n++) {\n event = events[n];\n parts = event.split('.');\n baseEvent = parts[0];\n name = parts[1];\n if (baseEvent) {\n if (this.eventListeners[baseEvent]) {\n this._off(baseEvent, name, callback);\n }\n }\n else {\n for (t in this.eventListeners) {\n this._off(t, name, callback);\n }\n }\n }\n return this;\n }\n // some event aliases for third party integration like HammerJS\n dispatchEvent(evt) {\n const e = {\n target: this,\n type: evt.type,\n evt: evt,\n };\n this.fire(evt.type, e);\n return this;\n }\n addEventListener(type, handler) {\n // we have to pass native event to handler\n this.on(type, function (evt) {\n handler.call(this, evt.evt);\n });\n return this;\n }\n removeEventListener(type) {\n this.off(type);\n return this;\n }\n // like node.on\n _delegate(event, selector, handler) {\n const stopNode = this;\n this.on(event, function (evt) {\n const targets = evt.target.findAncestors(selector, true, stopNode);\n for (let i = 0; i < targets.length; i++) {\n evt = Util.cloneObject(evt);\n evt.currentTarget = targets[i];\n handler.call(targets[i], evt);\n }\n });\n return this;\n }\n /**\n * remove a node from parent, but don't destroy. You can reuse the node later.\n * @method\n * @name Konva.Node#remove\n * @returns {Konva.Node}\n * @example\n * node.remove();\n */\n remove() {\n if (this.isDragging()) {\n this.stopDrag();\n }\n // we can have drag element but that is not dragged yet\n // so just clear it\n DD._dragElements.delete(this._id);\n // also remove any dragging descendants, otherwise they'll\n // have a broken parent chain and crash on getStage()\n DD._dragElements.forEach((elem, key) => {\n if (this.isAncestorOf(elem.node)) {\n DD._dragElements.delete(key);\n }\n });\n this._remove();\n return this;\n }\n _clearCaches() {\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n this._clearSelfAndDescendantCache(STAGE);\n this._clearSelfAndDescendantCache(VISIBLE);\n this._clearSelfAndDescendantCache(LISTENING);\n }\n _remove() {\n // every cached attr that is calculated via node tree\n // traversal must be cleared when removing a node\n this._clearCaches();\n const parent = this.getParent();\n if (parent && parent.children) {\n parent.children.splice(this.index, 1);\n parent._setChildrenIndices();\n this.parent = null;\n }\n }\n /**\n * remove and destroy a node. Kill it and delete forever! You should not reuse node after destroy().\n * If the node is a container (Group, Stage or Layer) it will destroy all children too.\n * The node fires a `destroy` event first, so anything holding a reference to it can let go.\n * When an ancestor is being destroyed the node is already detached from its parent at that point.\n * @method\n * @name Konva.Node#destroy\n * @example\n * node.on('destroy', () => console.log('gone'));\n * node.destroy();\n */\n destroy() {\n this._fire('destroy', { target: this });\n PointerEvents.releaseCapturesOf(this);\n this.remove();\n this.clearCache();\n return this;\n }\n /**\n * get attr\n * @method\n * @name Konva.Node#getAttr\n * @param {String} attr\n * @returns {Integer|String|Object|Array}\n * @example\n * var x = node.getAttr('x');\n */\n getAttr(attr) {\n const method = 'get' + Util._capitalize(attr);\n if (Util._isFunction(this[method])) {\n return this[method]();\n }\n // otherwise get directly\n return this.attrs[attr];\n }\n /**\n * get ancestors\n * @method\n * @name Konva.Node#getAncestors\n * @returns {Array}\n * @example\n * shape.getAncestors().forEach(function(node) {\n * console.log(node.id());\n * })\n */\n getAncestors() {\n let parent = this.getParent(), ancestors = [];\n while (parent) {\n ancestors.push(parent);\n parent = parent.getParent();\n }\n return ancestors;\n }\n /**\n * get attrs object literal\n * @method\n * @name Konva.Node#getAttrs\n * @returns {Object}\n */\n getAttrs() {\n return this.attrs || {};\n }\n /**\n * set multiple attrs at once using an object literal\n * @method\n * @name Konva.Node#setAttrs\n * @param {Object} config object containing key value pairs\n * @returns {Konva.Node}\n * @example\n * node.setAttrs({\n * x: 5,\n * fill: 'red'\n * });\n */\n setAttrs(config) {\n this._batchTransformChanges(() => {\n let key, method;\n if (!config) {\n return this;\n }\n for (key in config) {\n if (key === CHILDREN) {\n continue;\n }\n method = SET + Util._capitalize(key);\n // use setter if available\n if (Util._isFunction(this[method])) {\n this[method](config[key]);\n }\n else {\n // otherwise set directly\n this._setAttr(key, config[key]);\n }\n }\n });\n return this;\n }\n /**\n * determine if node is listening for events by taking into account ancestors.\n *\n * Parent | Self | isListening\n * listening | listening |\n * ----------+-----------+------------\n * T | T | T\n * T | F | F\n * F | T | F\n * F | F | F\n *\n * @method\n * @name Konva.Node#isListening\n * @returns {Boolean}\n */\n isListening() {\n return this._getCache(LISTENING, this._isListening);\n }\n _isListening(relativeTo) {\n const listening = this.listening();\n if (!listening) {\n return false;\n }\n const parent = this.getParent();\n if (parent && parent !== relativeTo && this !== relativeTo) {\n return parent._isListening(relativeTo);\n }\n else {\n return true;\n }\n }\n /**\n * determine if node is visible by taking into account ancestors.\n *\n * Parent | Self | isVisible\n * visible | visible |\n * ----------+-----------+------------\n * T | T | T\n * T | F | F\n * F | T | F\n * F | F | F\n * @method\n * @name Konva.Node#isVisible\n * @returns {Boolean}\n */\n isVisible() {\n return this._getCache(VISIBLE, this._isVisible);\n }\n _isVisible(relativeTo) {\n const visible = this.visible();\n if (!visible) {\n return false;\n }\n const parent = this.getParent();\n if (parent && parent !== relativeTo && this !== relativeTo) {\n return parent._isVisible(relativeTo);\n }\n else {\n return true;\n }\n }\n shouldDrawHit(top) {\n if (top) {\n return this._isVisible(top) && this._isListening(top);\n }\n return this.isListening() && this.isVisible();\n }\n /**\n * show node. set visible = true\n * @method\n * @name Konva.Node#show\n * @returns {Konva.Node}\n */\n show() {\n this.visible(true);\n return this;\n }\n /**\n * hide node. Hidden nodes are no longer detectable\n * @method\n * @name Konva.Node#hide\n * @returns {Konva.Node}\n */\n hide() {\n this.visible(false);\n return this;\n }\n getZIndex() {\n return this.index || 0;\n }\n /**\n * get absolute z-index which takes into account sibling\n * and ancestor indices\n * @method\n * @name Konva.Node#getAbsoluteZIndex\n * @returns {Integer}\n */\n getAbsoluteZIndex() {\n let depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;\n function addChildren(children) {\n nodes = [];\n len = children.length;\n for (n = 0; n < len; n++) {\n child = children[n];\n index++;\n if (child.nodeType !== SHAPE) {\n nodes = nodes.concat(child.children);\n }\n if (child._id === that._id) {\n n = len;\n }\n }\n if (nodes.length > 0 && nodes[0].getDepth() <= depth) {\n addChildren(nodes);\n }\n }\n const stage = this.getStage();\n if (that.nodeType !== UPPER_STAGE && stage) {\n addChildren(stage.children);\n }\n return index;\n }\n /**\n * get node depth in node tree. Returns an integer.\n * e.g. Stage depth will always be 0. Layers will always be 1. Groups and Shapes will always\n * be >= 2\n * @method\n * @name Konva.Node#getDepth\n * @returns {Integer}\n * @example\n * var depth = shape.getDepth(); // 2 for a shape right inside of a layer\n */\n getDepth() {\n let depth = 0, parent = this.parent;\n while (parent) {\n depth++;\n parent = parent.parent;\n }\n return depth;\n }\n // sometimes we do several attributes changes\n // like node.position(pos)\n // for performance reasons, lets batch transform reset\n // so it work faster\n _batchTransformChanges(func) {\n this._batchingTransformChange = true;\n try {\n func();\n }\n finally {\n this._batchingTransformChange = false;\n if (this._needClearTransformCache) {\n this._needClearTransformCache = false;\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n }\n }\n }\n setPosition(pos) {\n this._batchTransformChanges(() => {\n this.x(pos.x);\n this.y(pos.y);\n });\n return this;\n }\n getPosition() {\n return {\n x: this.x(),\n y: this.y(),\n };\n }\n /**\n * get position of first pointer (like mouse or first touch) relative to local coordinates of current node\n * @method\n * @name Konva.Node#getRelativePointerPosition\n * @returns {Konva.Node}\n * @example\n *\n * // let's think we have a rectangle at position x = 10, y = 10\n * // now we clicked at x = 15, y = 15 of the stage\n * // if you want to know position of the click, related to the rectangle you can use\n * rect.getRelativePointerPosition();\n */\n getRelativePointerPosition() {\n const stage = this.getStage();\n if (!stage) {\n return null;\n }\n // get pointer (say mouse or touch) position\n const pos = stage.getPointerPosition();\n if (!pos) {\n return null;\n }\n const transform = this.getAbsoluteTransform().copy();\n // to detect relative position we need to invert transform\n transform.invert();\n // now we can find relative point\n return transform.point(pos);\n }\n /**\n * get absolute position of a node. That function can be used to calculate absolute position, but relative to any ancestor\n * @method\n * @name Konva.Node#getAbsolutePosition\n * @param {Object} [top] optional ancestor node\n * @returns {Konva.Node}\n * @example\n *\n * // returns absolute position relative to top-left corner of canvas\n * node.getAbsolutePosition();\n *\n * // calculate absolute position of node, inside stage\n * // so stage transforms are ignored\n * node.getAbsolutePosition(stage)\n */\n getAbsolutePosition(top) {\n const absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Transform(), offset = this.offset();\n // clone the matrix array\n absoluteTransform.m = absoluteMatrix.slice();\n absoluteTransform.translate(offset.x, offset.y);\n return absoluteTransform.getTranslation();\n }\n setAbsolutePosition(pos) {\n const { x, y, ...origTrans } = this._clearTransform();\n // don't clear translation\n this.attrs.x = x;\n this.attrs.y = y;\n // important, use non cached value\n this._clearCache(TRANSFORM);\n const it = this._getAbsoluteTransform().copy();\n const invertible = it.isInvertible();\n it.invert();\n it.translate(pos.x, pos.y);\n const { x: dx, y: dy } = it.getTranslation();\n this._setTransform(origTrans);\n if (invertible) {\n this.setPosition({ x: this.attrs.x + dx, y: this.attrs.y + dy });\n }\n else {\n Util.warn('Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).');\n }\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n return this;\n }\n _setTransform(trans) {\n let key;\n for (key in trans) {\n this.attrs[key] = trans[key];\n }\n }\n _clearTransform() {\n const trans = {\n x: this.x(),\n y: this.y(),\n rotation: this.rotation(),\n scaleX: this.scaleX(),\n scaleY: this.scaleY(),\n offsetX: this.offsetX(),\n offsetY: this.offsetY(),\n skewX: this.skewX(),\n skewY: this.skewY(),\n };\n this.attrs.x = 0;\n this.attrs.y = 0;\n this.attrs.rotation = 0;\n this.attrs.scaleX = 1;\n this.attrs.scaleY = 1;\n this.attrs.offsetX = 0;\n this.attrs.offsetY = 0;\n this.attrs.skewX = 0;\n this.attrs.skewY = 0;\n // return original transform\n return trans;\n }\n /**\n * move node by an amount relative to its current position\n * @method\n * @name Konva.Node#move\n * @param {Object} change\n * @param {Number} change.x\n * @param {Number} change.y\n * @returns {Konva.Node}\n * @example\n * // move node in x direction by 1px and y direction by 2px\n * node.move({\n * x: 1,\n * y: 2\n * });\n */\n move(change) {\n let changeX = change.x, changeY = change.y, x = this.x(), y = this.y();\n if (changeX !== undefined) {\n x += changeX;\n }\n if (changeY !== undefined) {\n y += changeY;\n }\n this.setPosition({ x: x, y: y });\n return this;\n }\n /**\n * rotate node by an amount in degrees relative to its current rotation\n * @method\n * @name Konva.Node#rotate\n * @param {Number} theta\n * @returns {Konva.Node}\n */\n rotate(theta) {\n this.rotation(this.rotation() + theta);\n return this;\n }\n /**\n * move node to the top of its siblings\n * @method\n * @name Konva.Node#moveToTop\n * @returns {Boolean}\n */\n moveToTop() {\n if (!this.parent) {\n Util.warn('Node has no parent. moveToTop function is ignored.');\n return false;\n }\n const index = this.index, len = this.parent.children.length;\n if (index < len - 1) {\n this.parent.children.splice(index, 1);\n this.parent.children.push(this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n /**\n * move node up\n * @method\n * @name Konva.Node#moveUp\n * @returns {Boolean} flag is moved or not\n */\n moveUp() {\n if (!this.parent) {\n Util.warn('Node has no parent. moveUp function is ignored.');\n return false;\n }\n const index = this.index, len = this.parent.children.length;\n if (index < len - 1) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index + 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n /**\n * move node down\n * @method\n * @name Konva.Node#moveDown\n * @returns {Boolean}\n */\n moveDown() {\n if (!this.parent) {\n Util.warn('Node has no parent. moveDown function is ignored.');\n return false;\n }\n const index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index - 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n /**\n * move node to the bottom of its siblings\n * @method\n * @name Konva.Node#moveToBottom\n * @returns {Boolean}\n */\n moveToBottom() {\n if (!this.parent) {\n Util.warn('Node has no parent. moveToBottom function is ignored.');\n return false;\n }\n const index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.unshift(this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n setZIndex(zIndex) {\n if (!this.parent) {\n Util.warn('Node has no parent. zIndex parameter is ignored.');\n return this;\n }\n if (zIndex < 0 || zIndex >= this.parent.children.length) {\n Util.warn('Unexpected value ' +\n zIndex +\n ' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' +\n (this.parent.children.length - 1) +\n '.');\n }\n const index = this.index;\n this.parent.children.splice(index, 1);\n this.parent.children.splice(zIndex, 0, this);\n this.parent._setChildrenIndices();\n return this;\n }\n /**\n * get absolute opacity\n * @method\n * @name Konva.Node#getAbsoluteOpacity\n * @returns {Number}\n */\n getAbsoluteOpacity() {\n return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);\n }\n _getAbsoluteOpacity() {\n let absOpacity = this.opacity();\n const parent = this.getParent();\n if (parent && !parent._isUnderCache) {\n absOpacity *= parent.getAbsoluteOpacity();\n }\n return absOpacity;\n }\n /**\n * move node to another container\n * @method\n * @name Konva.Node#moveTo\n * @param {Container} newContainer\n * @returns {Konva.Node}\n * @example\n * // move node from current layer into layer2\n * node.moveTo(layer2);\n */\n moveTo(newContainer) {\n // do nothing if new container is already parent\n if (this.getParent() !== newContainer) {\n this._remove();\n newContainer.add(this);\n }\n return this;\n }\n /**\n * convert Node into an object for serialization. Returns an object.\n * @method\n * @name Konva.Node#toObject\n * @returns {Object}\n */\n toObject() {\n var _a;\n let attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;\n const obj = {\n attrs: {},\n className: this.getClassName(),\n };\n for (key in attrs) {\n val = attrs[key];\n // if value is object and object is not plain\n // like class instance, we should skip it and to not include\n nonPlainObject =\n Util.isObject(val) && !Util._isPlainObject(val) && !Util._isArray(val);\n if (nonPlainObject) {\n continue;\n }\n // a custom attribute may share its name with a node method, so only\n // the accessors generated by Factory are asked for the default value\n getter = ((_a = this[key]) === null || _a === void 0 ? void 0 : _a._isAttrAccessor) && this[key];\n // remove attr value so that we can extract the default value from the getter\n delete attrs[key];\n defaultValue = getter ? getter.call(this) : null;\n // restore attr value\n attrs[key] = val;\n if (defaultValue !== val) {\n obj.attrs[key] = Util.isObject(val)\n ? Util._prepareToStringify(val)\n : val;\n }\n }\n return obj;\n }\n /**\n * convert Node into a JSON string. Returns a JSON string.\n * @method\n * @name Konva.Node#toJSON\n * @returns {String}\n */\n toJSON() {\n return JSON.stringify(this.toObject());\n }\n /**\n * get parent container\n * @method\n * @name Konva.Node#getParent\n * @returns {Konva.Node}\n */\n getParent() {\n return this.parent;\n }\n /**\n * get all ancestors (parent then parent of the parent, etc) of the node\n * @method\n * @name Konva.Node#findAncestors\n * @param {String} selector selector for search\n * @param {Boolean} [includeSelf] show we think that node is ancestro itself?\n * @param {Konva.Node} [stopNode] optional node where we need to stop searching (one of ancestors)\n * @returns {Array} [ancestors]\n * @example\n * // get one of the parent group\n * var parentGroups = node.findAncestors('Group');\n */\n findAncestors(selector, includeSelf, stopNode) {\n const res = [];\n if (includeSelf && this._isMatch(selector)) {\n res.push(this);\n }\n let ancestor = this.parent;\n while (ancestor) {\n if (ancestor === stopNode) {\n return res;\n }\n if (ancestor._isMatch(selector)) {\n res.push(ancestor);\n }\n ancestor = ancestor.parent;\n }\n return res;\n }\n isAncestorOf(node) {\n return false;\n }\n /**\n * get ancestor (parent or parent of the parent, etc) of the node that match passed selector\n * @method\n * @name Konva.Node#findAncestor\n * @param {String} selector selector for search\n * @param {Boolean} [includeSelf] show we think that node is ancestro itself?\n * @param {Konva.Node} [stopNode] optional node where we need to stop searching (one of ancestors)\n * @returns {Konva.Node} ancestor\n * @example\n * // get one of the parent group\n * var group = node.findAncestors('.mygroup');\n */\n findAncestor(selector, includeSelf, stopNode) {\n return this.findAncestors(selector, includeSelf, stopNode)[0];\n }\n // is current node match passed selector?\n _isMatch(selector) {\n if (!selector) {\n return false;\n }\n if (typeof selector === 'function') {\n return selector(this);\n }\n let selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;\n for (n = 0; n < len; n++) {\n sel = selectorArr[n];\n if (!Util.isValidSelector(sel)) {\n Util.warn('Selector \"' +\n sel +\n '\" is invalid. Allowed selectors examples are \"#foo\", \".bar\" or \"Group\".');\n Util.warn('If you have a custom shape with such className, please change it to start with upper letter like \"Triangle\".');\n Util.warn('Konva is awesome, right?');\n }\n // id selector\n if (sel.charAt(0) === '#') {\n if (this.id() === sel.slice(1)) {\n return true;\n }\n }\n else if (sel.charAt(0) === '.') {\n // name selector\n if (this.hasName(sel.slice(1))) {\n return true;\n }\n }\n else if (this.className === sel || this.nodeType === sel) {\n return true;\n }\n }\n return false;\n }\n /**\n * get layer ancestor\n * @method\n * @name Konva.Node#getLayer\n * @returns {Konva.Layer}\n */\n getLayer() {\n const parent = this.getParent();\n return parent ? parent.getLayer() : null;\n }\n /**\n * get stage ancestor\n * @method\n * @name Konva.Node#getStage\n * @returns {Konva.Stage}\n */\n getStage() {\n return this._getCache(STAGE, this._getStage);\n }\n _getStage() {\n const parent = this.getParent();\n if (parent) {\n return parent.getStage();\n }\n else {\n return null;\n }\n }\n /**\n * fire event\n * @method\n * @name Konva.Node#fire\n * @param {String} eventType event type. can be a regular event, like click, mouseover, or mouseout, or it can be a custom event, like myCustomEvent\n * @param {Event} [evt] event object\n * @param {Boolean} [bubble] setting the value to false, or leaving it undefined, will result in the event\n * not bubbling. Setting the value to true will result in the event bubbling.\n * @returns {Konva.Node}\n * @example\n * // manually fire click event\n * node.fire('click');\n *\n * // fire custom event\n * node.fire('foo');\n *\n * // fire custom event with custom event object\n * node.fire('foo', {\n * bar: 10\n * });\n *\n * // fire click event that bubbles\n * node.fire('click', null, true);\n */\n fire(eventType, evt, bubble) {\n evt = evt || {};\n evt.target = evt.target || this;\n // bubble\n if (bubble) {\n this._fireAndBubble(eventType, evt);\n }\n else {\n // no bubble\n this._fire(eventType, evt);\n }\n return this;\n }\n /**\n * get absolute transform of the node which takes into\n * account its ancestor transforms\n * @method\n * @name Konva.Node#getAbsoluteTransform\n * @returns {Konva.Transform}\n */\n getAbsoluteTransform(top) {\n // relative to an ancestor, or under a cached one, the result can't come\n // from the cache: a cached container keeps the transform caches of its\n // descendants while it moves (see Container._clearSelfAndDescendantCache)\n if (top || this._hasCachedAncestor()) {\n return this._getAbsoluteTransform(top);\n }\n return this._getCache(ABSOLUTE_TRANSFORM, this._getCachedAbsoluteTransform);\n }\n _hasCachedAncestor() {\n let parent = this.parent;\n while (parent) {\n if (parent.isCached()) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n // relative to `top`: the transforms of `top` and of its ancestors are\n // left out. Goes through the parent, so an ancestor that redefines its\n // absolute transform (Konva.Transformer) is honoured\n _getAbsoluteTransform(top) {\n const at = new Transform();\n if (this === top) {\n return at;\n }\n if (this.parent && this.parent !== top) {\n this.parent.getAbsoluteTransform(top).copyInto(at);\n }\n return this._multiplyOwnTransform(at);\n }\n // the cached transform of the parent, then the own one\n _getCachedAbsoluteTransform() {\n const at = this._cache[ABSOLUTE_TRANSFORM] || new Transform();\n if (this.parent) {\n this.parent.getAbsoluteTransform().copyInto(at);\n }\n else {\n at.reset();\n }\n this._multiplyOwnTransform(at);\n at.dirty = false;\n return at;\n }\n _multiplyOwnTransform(at) {\n const transformsEnabled = this.transformsEnabled();\n if (transformsEnabled === 'all') {\n at.multiply(this.getTransform());\n }\n else if (transformsEnabled === 'position') {\n // use \"attrs\" directly, because it is a bit faster\n const x = this.attrs.x || 0;\n const y = this.attrs.y || 0;\n const offsetX = this.attrs.offsetX || 0;\n const offsetY = this.attrs.offsetY || 0;\n at.translate(x - offsetX, y - offsetY);\n }\n return at;\n }\n /**\n * get absolute scale of the node which takes into\n * account its ancestor scales\n * @method\n * @name Konva.Node#getAbsoluteScale\n * @returns {Object}\n * @example\n * // get absolute scale x\n * var scaleX = node.getAbsoluteScale().x;\n */\n getAbsoluteScale(top) {\n // do not cache this calculations,\n // because it use cache transform\n // this is special logic for caching with some shapes with shadow\n let parent = this;\n while (parent) {\n if (parent._isUnderCache) {\n top = parent;\n }\n parent = parent.getParent();\n }\n const transform = this.getAbsoluteTransform(top);\n const attrs = transform.decompose();\n return {\n x: attrs.scaleX,\n y: attrs.scaleY,\n };\n }\n /**\n * get absolute rotation of the node which takes into\n * account its ancestor rotations\n * @method\n * @name Konva.Node#getAbsoluteRotation\n * @returns {Number}\n * @example\n * // get absolute rotation\n * var rotation = node.getAbsoluteRotation();\n */\n getAbsoluteRotation() {\n return this.getAbsoluteTransform().decompose().rotation;\n }\n /**\n * get transform of the node\n * @method\n * @name Konva.Node#getTransform\n * @returns {Konva.Transform}\n */\n getTransform() {\n return this._getCache(TRANSFORM, this._getTransform);\n }\n _getTransform() {\n var _a, _b;\n const m = this._cache[TRANSFORM] || new Transform();\n m.reset();\n // I was trying to use attributes directly here\n // but it doesn't work for Transformer well\n // because it overwrite x,y getters\n const x = this.x(), y = this.y(), rotation = Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;\n if (x !== 0 || y !== 0) {\n m.translate(x, y);\n }\n if (rotation !== 0) {\n m.rotate(rotation);\n }\n if (skewX !== 0 || skewY !== 0) {\n m.skew(skewX, skewY);\n }\n if (scaleX !== 1 || scaleY !== 1) {\n m.scale(scaleX, scaleY);\n }\n if (offsetX !== 0 || offsetY !== 0) {\n m.translate(-1 * offsetX, -1 * offsetY);\n }\n m.dirty = false;\n return m;\n }\n /**\n * clone node. Returns a new Node instance with identical attributes. You can also override\n * the node properties with an object literal, enabling you to use an existing node as a template\n * for another node\n * @method\n * @name Konva.Node#clone\n * @param {Object} obj override attrs\n * @returns {Konva.Node}\n * @example\n * // simple clone\n * var clone = node.clone();\n *\n * // clone a node and override the x position\n * var clone = rect.clone({\n * x: 5\n * });\n */\n clone(obj) {\n // instantiate new node\n let attrs = Util.cloneObject(this.attrs), key, allListeners, len, n, listener;\n // apply attr overrides\n for (key in obj) {\n attrs[key] = obj[key];\n }\n const node = new this.constructor(attrs);\n // copy over listeners\n for (key in this.eventListeners) {\n allListeners = this.eventListeners[key];\n len = allListeners.length;\n for (n = 0; n < len; n++) {\n listener = allListeners[n];\n /*\n * don't include konva namespaced listeners because\n * these are generated by the constructors\n */\n if (listener.name.indexOf(KONVA) < 0) {\n // if listeners array doesn't exist, then create it\n if (!node.eventListeners[key]) {\n node.eventListeners[key] = [];\n }\n node.eventListeners[key].push(listener);\n }\n }\n }\n return node;\n }\n _toKonvaCanvas(config) {\n config = config || {};\n // the client rect is only needed for the parts of the box not configured\n const needsBox = config.x === undefined ||\n config.y === undefined ||\n !config.width ||\n !config.height;\n const box = needsBox\n ? this.getClientRect()\n : { x: 0, y: 0, width: 0, height: 0 };\n if (!isFinite(box.x + box.y + box.width + box.height)) {\n Util.error(`Cannot find the bounds of the node to export, its client rect is ${box.x}, ${box.y}, ${box.width}x${box.height}. Check its position, size and points.`);\n }\n const stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({\n width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),\n height: config.height ||\n Math.ceil(box.height) ||\n (stage ? stage.height() : 0),\n pixelRatio: pixelRatio,\n }), context = canvas.getContext();\n const bufferCanvas = createBufferCanvas(canvas, x, y);\n if (config.imageSmoothingEnabled === false) {\n context._context.imageSmoothingEnabled = false;\n }\n context.save();\n if (x || y) {\n context.translate(-1 * x, -1 * y);\n }\n this.drawScene(canvas, undefined, bufferCanvas);\n context.restore();\n // the buffer is only needed while drawing\n Util.releaseCanvas(bufferCanvas._canvas);\n return canvas;\n }\n /**\n * converts node into an canvas element.\n * @method\n * @name Konva.Node#toCanvas\n * @param {Object} config\n * @param {Function} config.callback function executed when the composite has completed\n * @param {Number} [config.x] x position of canvas section\n * @param {Number} [config.y] y position of canvas section\n * @param {Number} [config.width] width of canvas section\n * @param {Number} [config.height] height of canvas section\n * @param {Number} [config.pixelRatio] pixelRatio of output canvas. Default is 1.\n * You can use that property to increase quality of the image, for example for super hight quality exports\n * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.\n * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.\n * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing\n * @example\n * var canvas = node.toCanvas();\n */\n toCanvas(config) {\n return this._toKonvaCanvas(config)._canvas;\n }\n /**\n * Creates a composite data URL (base64 string). If MIME type is not\n * specified, then \"image/png\" will result. For \"image/jpeg\", specify a quality\n * level as quality (range 0.0 - 1.0)\n * @method\n * @name Konva.Node#toDataURL\n * @param {Object} config\n * @param {String} [config.mimeType] can be \"image/png\" or \"image/jpeg\".\n * \"image/png\" is the default\n * @param {Number} [config.x] x position of canvas section\n * @param {Number} [config.y] y position of canvas section\n * @param {Number} [config.width] width of canvas section\n * @param {Number} [config.height] height of canvas section\n * @param {Number} [config.quality] jpeg quality. If using an \"image/jpeg\" mimeType,\n * you can specify the quality from 0 to 1, where 0 is very poor quality and 1\n * is very high quality\n * @param {Number} [config.pixelRatio] pixelRatio of output image url. Default is 1.\n * You can use that property to increase quality of the image, for example for super hight quality exports\n * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.\n * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.\n * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing\n * @returns {String}\n */\n toDataURL(config) {\n config = config || {};\n const mimeType = config.mimeType || null, quality = config.quality || null;\n const url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);\n if (config.callback) {\n config.callback(url);\n }\n return url;\n }\n /**\n * converts node into an image. Since the toImage\n * method is asynchronous, the resulting image can only be retrieved from the config callback\n * or the returned Promise. toImage is most commonly used\n * to cache complex drawings as an image so that they don't have to constantly be redrawn\n * @method\n * @name Konva.Node#toImage\n * @param {Object} config\n * @param {Function} [config.callback] function executed when the composite has completed\n * @param {String} [config.mimeType] can be \"image/png\" or \"image/jpeg\".\n * \"image/png\" is the default\n * @param {Number} [config.x] x position of canvas section\n * @param {Number} [config.y] y position of canvas section\n * @param {Number} [config.width] width of canvas section\n * @param {Number} [config.height] height of canvas section\n * @param {Number} [config.quality] jpeg quality. If using an \"image/jpeg\" mimeType,\n * you can specify the quality from 0 to 1, where 0 is very poor quality and 1\n * is very high quality\n * @param {Number} [config.pixelRatio] pixelRatio of output image. Default is 1.\n * You can use that property to increase quality of the image, for example for super hight quality exports\n * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.\n * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.\n * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing\n * @return {Promise}\n * @example\n * var image = node.toImage({\n * callback(img) {\n * // do stuff with img\n * }\n * });\n */\n toImage(config) {\n return new Promise((resolve, reject) => {\n try {\n const callback = config === null || config === void 0 ? void 0 : config.callback;\n if (callback)\n delete config.callback;\n Util._urlToImage(this.toDataURL(config), function (img) {\n resolve(img);\n callback === null || callback === void 0 ? void 0 : callback(img);\n });\n }\n catch (err) {\n reject(err);\n }\n });\n }\n /**\n * Converts node into a blob. Since the toBlob method is asynchronous,\n * the resulting blob can only be retrieved from the config callback\n * or the returned Promise.\n * @method\n * @name Konva.Node#toBlob\n * @param {Object} config\n * @param {Function} [config.callback] function executed when the composite has completed\n * @param {Number} [config.x] x position of canvas section\n * @param {Number} [config.y] y position of canvas section\n * @param {Number} [config.width] width of canvas section\n * @param {Number} [config.height] height of canvas section\n * @param {Number} [config.pixelRatio] pixelRatio of output canvas. Default is 1.\n * You can use that property to increase quality of the image, for example for super hight quality exports\n * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.\n * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.\n * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing\n * @example\n * var blob = await node.toBlob({});\n * @returns {Promise} rejects if the canvas can not be encoded\n */\n toBlob(config) {\n return new Promise((resolve, reject) => {\n try {\n const callback = config === null || config === void 0 ? void 0 : config.callback;\n if (callback)\n delete config.callback;\n this.toCanvas(config).toBlob((blob) => {\n // the canvas reports a failed encode by passing null\n if (!blob) {\n reject(new Error('Konva: toBlob() failed, the canvas was not encoded'));\n return;\n }\n resolve(blob);\n callback === null || callback === void 0 ? void 0 : callback(blob);\n }, config === null || config === void 0 ? void 0 : config.mimeType, config === null || config === void 0 ? void 0 : config.quality);\n }\n catch (err) {\n reject(err);\n }\n });\n }\n setSize(size) {\n this.width(size.width);\n this.height(size.height);\n return this;\n }\n getSize() {\n return {\n width: this.width(),\n height: this.height(),\n };\n }\n /**\n * get class name, which may return Stage, Layer, Group, or shape class names like Rect, Circle, Text, etc.\n * @method\n * @name Konva.Node#getClassName\n * @returns {String}\n */\n getClassName() {\n return this.className || this.nodeType;\n }\n /**\n * get the node type, which may return Stage, Layer, Group, or Shape\n * @method\n * @name Konva.Node#getType\n * @returns {String}\n */\n getType() {\n return this.nodeType;\n }\n getDragDistance() {\n // compare with undefined because we need to track 0 value\n if (this.attrs.dragDistance !== undefined) {\n return this.attrs.dragDistance;\n }\n else if (this.parent) {\n return this.parent.getDragDistance();\n }\n else {\n return Konva.dragDistance;\n }\n }\n _off(type, name, callback) {\n let evtListeners = this.eventListeners[type], i, evtName, handler;\n for (i = 0; i < evtListeners.length; i++) {\n evtName = evtListeners[i].name;\n handler = evtListeners[i].handler;\n // the following two conditions must be true in order to remove a handler:\n // 1) the current event name cannot be konva unless the event name is konva\n // this enables developers to force remove a konva specific listener for whatever reason\n // 2) an event name is not specified, or if one is specified, it matches the current event name\n if ((evtName !== 'konva' || name === 'konva') &&\n (!name || evtName === name) &&\n (!callback || callback === handler)) {\n evtListeners.splice(i, 1);\n if (evtListeners.length === 0) {\n delete this.eventListeners[type];\n break;\n }\n i--;\n }\n }\n }\n _fireChangeEvent(attr, oldVal, newVal) {\n this._fire(attr + CHANGE, {\n oldVal: oldVal,\n newVal: newVal,\n });\n }\n /**\n * add name to node\n * @method\n * @name Konva.Node#addName\n * @param {String} name\n * @returns {Konva.Node}\n * @example\n * node.name('red');\n * node.addName('selected');\n * node.name(); // return 'red selected'\n */\n addName(name) {\n if (!this.hasName(name)) {\n const oldName = this.name();\n const newName = oldName ? oldName + ' ' + name : name;\n this.name(newName);\n }\n return this;\n }\n /**\n * check is node has name\n * @method\n * @name Konva.Node#hasName\n * @param {String} name\n * @returns {Boolean}\n * @example\n * node.name('red');\n * node.hasName('red'); // return true\n * node.hasName('selected'); // return false\n * node.hasName(''); // return false\n */\n hasName(name) {\n if (!name) {\n return false;\n }\n const fullName = this.name();\n if (!fullName) {\n return false;\n }\n // if name is '' the \"names\" will be [''], so I added extra check above\n const names = (fullName || '').split(/\\s/g);\n return names.indexOf(name) !== -1;\n }\n /**\n * remove name from node\n * @method\n * @name Konva.Node#removeName\n * @param {String} name\n * @returns {Konva.Node}\n * @example\n * node.name('red selected');\n * node.removeName('selected');\n * node.hasName('selected'); // return false\n * node.name(); // return 'red'\n */\n removeName(name) {\n const names = (this.name() || '').split(/\\s/g);\n const index = names.indexOf(name);\n if (index !== -1) {\n names.splice(index, 1);\n this.name(names.join(' '));\n }\n return this;\n }\n /**\n * set attr\n * @method\n * @name Konva.Node#setAttr\n * @param {String} attr\n * @param {*} val\n * @returns {Konva.Node}\n * @example\n * node.setAttr('x', 5);\n */\n setAttr(attr, val) {\n const func = this[SET + Util._capitalize(attr)];\n if (Util._isFunction(func)) {\n func.call(this, val);\n }\n else {\n // otherwise set directly\n this._setAttr(attr, val);\n }\n return this;\n }\n _requestDraw() {\n if (Konva.autoDrawEnabled) {\n const drawNode = this.getLayer() || this.getStage();\n drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();\n }\n }\n _setAttr(key, val) {\n const oldVal = this.attrs[key];\n if (oldVal === val && !Util.isObject(val)) {\n return;\n }\n if (val === undefined || val === null) {\n delete this.attrs[key];\n }\n else {\n this.attrs[key] = val;\n }\n if (this._attrsVersion !== undefined)\n this._attrsVersion++;\n if (this._shouldFireChangeEvents) {\n this._fireChangeEvent(key, oldVal, val);\n }\n this._requestDraw();\n }\n _fireAndBubble(eventType, evt, compareShape) {\n if (evt && this.nodeType === SHAPE) {\n evt.target = this;\n }\n const nonBubbling = NON_BUBBLING_EVENTS.indexOf(eventType) !== -1;\n const shouldStop = nonBubbling &&\n ((compareShape &&\n (this === compareShape ||\n (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||\n (this.nodeType === 'Stage' && !compareShape));\n if (!shouldStop) {\n this._fire(eventType, evt);\n // simulate event bubbling\n const stopBubble = nonBubbling &&\n compareShape &&\n compareShape.isAncestorOf &&\n compareShape.isAncestorOf(this) &&\n !compareShape.isAncestorOf(this.parent);\n if (((evt && !evt.cancelBubble) || !evt) &&\n this.parent &&\n this.parent.isListening() &&\n !stopBubble) {\n if (compareShape && compareShape.parent) {\n this._fireAndBubble.call(this.parent, eventType, evt, compareShape);\n }\n else {\n this._fireAndBubble.call(this.parent, eventType, evt);\n }\n }\n }\n }\n _getProtoListeners(eventType) {\n var _a, _b;\n const proto = Object.getPrototypeOf(this);\n let allListeners = Node.protoListenerMap.get(proto);\n if (!allListeners) {\n allListeners = {};\n Node.protoListenerMap.set(proto, allListeners);\n }\n let events = allListeners[eventType];\n if (events === undefined) {\n //recalculate cache\n events = [];\n // Dedupe across the prototype chain: subclasses without their own\n // `eventListeners` inherit the parent's, so a single handler would\n // otherwise be pushed once per chain level (Stage→Container→Node = 3x).\n const seen = new Set();\n let obj = Object.getPrototypeOf(this);\n while (obj) {\n const hierarchyEvents = (_b = (_a = obj.eventListeners) === null || _a === void 0 ? void 0 : _a[eventType]) !== null && _b !== void 0 ? _b : [];\n for (let i = 0; i < hierarchyEvents.length; i++) {\n const entry = hierarchyEvents[i];\n if (!seen.has(entry)) {\n seen.add(entry);\n events.push(entry);\n }\n }\n obj = Object.getPrototypeOf(obj);\n }\n // update cache\n allListeners[eventType] = events;\n }\n return events;\n }\n _fire(eventType, evt) {\n evt = evt || {};\n evt.currentTarget = this;\n evt.type = eventType;\n const topListeners = this._getProtoListeners(eventType);\n if (topListeners) {\n // The list is rebuilt when a prototype gains a listener, so no\n // defensive .slice() needed (hot path: every *Change).\n for (let i = 0; i < topListeners.length; i++) {\n topListeners[i].handler.call(this, evt);\n }\n }\n // snapshot prevents skipping listeners when a handler mutates the array\n // (e.g. off + on for the same event), but we also need to fire listeners\n // added during dispatch (e.g. draggable(true) inside mousedown)\n const selfListeners = this.eventListeners[eventType];\n if (selfListeners) {\n const list = selfListeners.slice();\n const origLen = list.length;\n for (let i = 0; i < list.length; i++) {\n list[i].handler.call(this, evt);\n }\n // fire any listeners appended during dispatch\n const liveListeners = this.eventListeners[eventType];\n if (liveListeners) {\n for (let i = origLen; i < liveListeners.length; i++) {\n liveListeners[i].handler.call(this, evt);\n }\n }\n }\n }\n /**\n * draw both scene and hit graphs. If the node being drawn is the stage, all of the layers will be cleared and redrawn\n * @method\n * @name Konva.Node#draw\n * @returns {Konva.Node}\n */\n draw() {\n this.drawScene();\n this.drawHit();\n return this;\n }\n // drag & drop\n _createDragElement(evt) {\n const pointerId = evt ? evt.pointerId : undefined;\n const stage = this.getStage();\n const ap = this.getAbsolutePosition();\n if (!stage) {\n return;\n }\n const pos = stage._getPointerById(pointerId) ||\n stage._changedPointerPositions[0] ||\n ap;\n DD._dragElements.set(this._id, {\n node: this,\n startPointerPos: pos,\n offset: {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n },\n dragStatus: 'ready',\n pointerId,\n startEvent: evt,\n });\n }\n /**\n * initiate drag and drop.\n * @method\n * @name Konva.Node#startDrag\n */\n startDrag(evt, bubbleEvent = true) {\n if (!DD._dragElements.has(this._id)) {\n this._createDragElement(evt);\n }\n const elem = DD._dragElements.get(this._id);\n // a node outside of a stage has no pointer to follow\n if (!elem) {\n return;\n }\n elem.dragStatus = 'dragging';\n this.fire('dragstart', {\n type: 'dragstart',\n target: this,\n // Use the stored start event if available (from mousedown/touchstart),\n // otherwise fall back to the provided event (when startDrag is called programmatically)\n evt: (elem.startEvent && elem.startEvent.evt) || (evt && evt.evt),\n }, bubbleEvent);\n }\n _setDragPosition(evt, elem) {\n const pos = this.getStage()._getPointerById(elem.pointerId);\n if (!pos) {\n return;\n }\n let newNodePos = {\n x: pos.x - elem.offset.x,\n y: pos.y - elem.offset.y,\n };\n const dbf = this.dragBoundFunc();\n if (dbf !== undefined) {\n const bounded = dbf.call(this, newNodePos, evt);\n if (!bounded) {\n Util.warn('dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.');\n }\n else if (!Util._isNumber(bounded.x) || !Util._isNumber(bounded.y)) {\n Util.warn(`dragBoundFunc returned a position with a non-finite x or y (${bounded.x}, ${bounded.y}). The node was not moved.`);\n return;\n }\n else {\n newNodePos = bounded;\n }\n }\n const lastPos = elem.lastPos;\n if (!lastPos || lastPos.x !== newNodePos.x || lastPos.y !== newNodePos.y) {\n this.setAbsolutePosition(newNodePos);\n this._requestDraw();\n }\n elem.lastPos = newNodePos;\n }\n /**\n * stop drag and drop\n * @method\n * @name Konva.Node#stopDrag\n */\n stopDrag(evt) {\n const elem = DD._dragElements.get(this._id);\n if (elem) {\n elem.dragStatus = 'stopped';\n }\n DD._endDragBefore(evt);\n DD._endDragAfter(evt);\n }\n setDraggable(draggable) {\n this._setAttr('draggable', draggable);\n this._dragChange();\n }\n /**\n * determine if node is currently in drag and drop mode\n * @method\n * @name Konva.Node#isDragging\n */\n isDragging() {\n const elem = DD._dragElements.get(this._id);\n return elem ? elem.dragStatus === 'dragging' : false;\n }\n _listenDrag() {\n this._dragCleanup();\n this.on('mousedown.konva touchstart.konva', function (evt) {\n const shouldCheckButton = evt.evt['button'] !== undefined;\n const canDrag = !shouldCheckButton || Konva.dragButtons.indexOf(evt.evt['button']) >= 0;\n if (!canDrag) {\n return;\n }\n if (this.isDragging()) {\n return;\n }\n let hasDraggingChild = false;\n DD._dragElements.forEach((elem) => {\n if (this.isAncestorOf(elem.node)) {\n hasDraggingChild = true;\n }\n });\n // nested drag can be started\n // in that case we don't need to start new drag\n if (!hasDraggingChild) {\n this._createDragElement(evt);\n }\n });\n }\n _dragChange() {\n if (this.attrs.draggable) {\n this._listenDrag();\n }\n else {\n // remove event listeners\n this._dragCleanup();\n /*\n * force drag and drop to end\n * if this node is currently in\n * drag and drop mode\n */\n const stage = this.getStage();\n if (!stage) {\n return;\n }\n const dragElement = DD._dragElements.get(this._id);\n const isDragging = dragElement && dragElement.dragStatus === 'dragging';\n const isReady = dragElement && dragElement.dragStatus === 'ready';\n if (isDragging) {\n this.stopDrag();\n }\n else if (isReady) {\n DD._dragElements.delete(this._id);\n }\n }\n }\n _dragCleanup() {\n this.off('mousedown.konva');\n this.off('touchstart.konva');\n }\n /**\n * determine if node (at least partially) is currently in user-visible area\n * @method\n * @param {(Number | Object)} margin optional margin in pixels\n * @param {Number} margin.x\n * @param {Number} margin.y\n * @returns {Boolean}\n * @name Konva.Node#isClientRectOnScreen\n * @example\n * // get index\n * // default calculations\n * var isOnScreen = node.isClientRectOnScreen()\n * // increase object size (or screen size) for cases when objects close to the screen still need to be marked as \"visible\"\n * var isOnScreen = node.isClientRectOnScreen({ x: stage.width(), y: stage.height() })\n */\n isClientRectOnScreen(margin = { x: 0, y: 0 }) {\n const stage = this.getStage();\n if (!stage) {\n return false;\n }\n const screenRect = {\n x: -margin.x,\n y: -margin.y,\n width: stage.width() + 2 * margin.x,\n height: stage.height() + 2 * margin.y,\n };\n return Util.haveIntersection(screenRect, this.getClientRect());\n }\n /**\n * create node with JSON string or an Object. Deserialization restores attributes only,\n * not functions, images or event handlers (that would make the serialized object huge):\n * `sceneFunc`/`hitFunc` of custom shapes, images and `fillPatternImage`, `clipFunc`,\n * `dragBoundFunc`, filter functions, the `nodes`, `boundBoxFunc` and `anchorStyleFunc`\n * of a Transformer, typed arrays and the `cache()` state. If your app uses them (it probably\n * does), select the nodes after loading the stage and set these properties again with\n * `on()`, `sceneFunc()`, `image()` and so on\n * @method\n * @memberof Konva.Node\n * @param {String|Object} data string or object\n * @param {Element} [container] optional container dom element used only if you're\n * creating a stage node\n */\n static create(data, container) {\n if (Util._isString(data)) {\n data = JSON.parse(data);\n }\n return this._createNode(data, container);\n }\n static _createNode(obj, container) {\n let className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;\n // if container was passed in, add it to attrs\n if (container) {\n obj.attrs.container = container;\n }\n if (!Konva[className]) {\n Util.warn('Can not find a node with class name \"' +\n className +\n '\". Fallback to \"Shape\".');\n className = 'Shape';\n }\n const Class = Konva[className];\n no = new Class(obj.attrs);\n if (children) {\n len = children.length;\n for (n = 0; n < len; n++) {\n no.add(Node._createNode(children[n]));\n }\n }\n return no;\n }\n}\n// Perf: lets a listener inside an absoluteTransform cascade (e.g. Konva\n// .Transformer reacting to a stage drag fan-out across N attached nodes)\n// defer work until the cascade ends — collapses O(N) listener-driven calls\n// into one. Counter is mutated by Container's _clearSelfAndDescendantCache.\nNode._absTransformCascadeDepth = 0;\nNode._pendingAfterCascade = [];\n// keyed by prototype: subclasses that share a nodeType (every shape class)\n// have their own listeners\nNode.protoListenerMap = new WeakMap();\nNode.prototype.nodeType = 'Node';\nNode.prototype._attrsAffectingSize = [];\n// attache events listeners once into prototype\n// that way we don't spend too much time on making an new instance\nNode.prototype.on(TRANSFORM_CHANGE_STR, function () {\n if (this._batchingTransformChange) {\n this._needClearTransformCache = true;\n return;\n }\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n});\nNode.prototype.on('visibleChange.konva', function () {\n this._clearSelfAndDescendantCache(VISIBLE);\n});\nNode.prototype.on('listeningChange.konva', function () {\n this._clearSelfAndDescendantCache(LISTENING);\n});\nNode.prototype.on('opacityChange.konva', function () {\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n});\nconst addGetterSetter = Factory.addGetterSetter;\n/**\n * get/set zIndex relative to the node's siblings who share the same parent.\n * Please remember that zIndex is not absolute (like in CSS). It is relative to parent element only.\n * @name Konva.Node#zIndex\n * @method\n * @param {Number} index\n * @returns {Number}\n * @example\n * // get index\n * var index = node.zIndex();\n *\n * // set index\n * node.zIndex(2);\n */\naddGetterSetter(Node, 'zIndex');\n/**\n * get/set node absolute position\n * @name Konva.Node#absolutePosition\n * @method\n * @param {Object} pos\n * @param {Number} pos.x\n * @param {Number} pos.y\n * @returns {Object}\n * @example\n * // get position\n * var position = node.absolutePosition();\n *\n * // set position\n * node.absolutePosition({\n * x: 5,\n * y: 10\n * });\n */\naddGetterSetter(Node, 'absolutePosition');\naddGetterSetter(Node, 'position');\n/**\n * get/set node position relative to parent\n * @name Konva.Node#position\n * @method\n * @param {Object} pos\n * @param {Number} pos.x\n * @param {Number} pos.y\n * @returns {Object}\n * @example\n * // get position\n * var position = node.position();\n *\n * // set position\n * node.position({\n * x: 5,\n * y: 10\n * });\n */\naddGetterSetter(Node, 'x', 0, getNumberValidator());\n/**\n * get/set x position\n * @name Konva.Node#x\n * @method\n * @param {Number} x\n * @returns {Object}\n * @example\n * // get x\n * var x = node.x();\n *\n * // set x\n * node.x(5);\n */\naddGetterSetter(Node, 'y', 0, getNumberValidator());\n/**\n * get/set y position\n * @name Konva.Node#y\n * @method\n * @param {Number} y\n * @returns {Integer}\n * @example\n * // get y\n * var y = node.y();\n *\n * // set y\n * node.y(5);\n */\naddGetterSetter(Node, 'globalCompositeOperation', 'source-over', getStringValidator());\n/**\n * get/set globalCompositeOperation of a node. globalCompositeOperation DOESN'T affect hit graph of nodes. So they are still trigger to events as they have default \"source-over\" globalCompositeOperation.\n * @name Konva.Node#globalCompositeOperation\n * @method\n * @param {String} type\n * @returns {String}\n * @example\n * // get globalCompositeOperation\n * var globalCompositeOperation = shape.globalCompositeOperation();\n *\n * // set globalCompositeOperation\n * shape.globalCompositeOperation('source-in');\n */\naddGetterSetter(Node, 'opacity', 1, getNumberValidator());\n/**\n * get/set opacity. Opacity values range from 0 to 1.\n * A node with an opacity of 0 is fully transparent, and a node\n * with an opacity of 1 is fully opaque\n * @name Konva.Node#opacity\n * @method\n * @param {Object} opacity\n * @returns {Number}\n * @example\n * // get opacity\n * var opacity = node.opacity();\n *\n * // set opacity\n * node.opacity(0.5);\n */\naddGetterSetter(Node, 'name', '', getStringValidator());\n/**\n * get/set name.\n * @name Konva.Node#name\n * @method\n * @param {String} name\n * @returns {String}\n * @example\n * // get name\n * var name = node.name();\n *\n * // set name\n * node.name('foo');\n *\n * // also node may have multiple names (as css classes)\n * node.name('foo bar');\n */\naddGetterSetter(Node, 'id', '', getStringValidator());\n/**\n * get/set id. Id is global for whole page.\n * @name Konva.Node#id\n * @method\n * @param {String} id\n * @returns {String}\n * @example\n * // get id\n * var name = node.id();\n *\n * // set id\n * node.id('foo');\n */\naddGetterSetter(Node, 'rotation', 0, getNumberValidator());\n/**\n * get/set rotation in degrees\n * @name Konva.Node#rotation\n * @method\n * @param {Number} rotation\n * @returns {Number}\n * @example\n * // get rotation in degrees\n * var rotation = node.rotation();\n *\n * // set rotation in degrees\n * node.rotation(45);\n */\nFactory.addComponentsGetterSetter(Node, 'scale', ['x', 'y']);\n/**\n * get/set scale\n * @name Konva.Node#scale\n * @param {Object} scale\n * @param {Number} scale.x\n * @param {Number} scale.y\n * @method\n * @returns {Object}\n * @example\n * // get scale\n * var scale = node.scale();\n *\n * // set scale\n * shape.scale({\n * x: 2,\n * y: 3\n * });\n */\naddGetterSetter(Node, 'scaleX', 1, getNumberValidator());\n/**\n * get/set scale x\n * @name Konva.Node#scaleX\n * @param {Number} x\n * @method\n * @returns {Number}\n * @example\n * // get scale x\n * var scaleX = node.scaleX();\n *\n * // set scale x\n * node.scaleX(2);\n */\naddGetterSetter(Node, 'scaleY', 1, getNumberValidator());\n/**\n * get/set scale y\n * @name Konva.Node#scaleY\n * @param {Number} y\n * @method\n * @returns {Number}\n * @example\n * // get scale y\n * var scaleY = node.scaleY();\n *\n * // set scale y\n * node.scaleY(2);\n */\nFactory.addComponentsGetterSetter(Node, 'skew', ['x', 'y']);\n/**\n * get/set skew\n * @name Konva.Node#skew\n * @param {Object} skew\n * @param {Number} skew.x\n * @param {Number} skew.y\n * @method\n * @returns {Object}\n * @example\n * // get skew\n * var skew = node.skew();\n *\n * // set skew\n * node.skew({\n * x: 20,\n * y: 10\n * });\n */\naddGetterSetter(Node, 'skewX', 0, getNumberValidator());\n/**\n * get/set skew x\n * @name Konva.Node#skewX\n * @param {Number} x\n * @method\n * @returns {Number}\n * @example\n * // get skew x\n * var skewX = node.skewX();\n *\n * // set skew x\n * node.skewX(3);\n */\naddGetterSetter(Node, 'skewY', 0, getNumberValidator());\n/**\n * get/set skew y\n * @name Konva.Node#skewY\n * @param {Number} y\n * @method\n * @returns {Number}\n * @example\n * // get skew y\n * var skewY = node.skewY();\n *\n * // set skew y\n * node.skewY(3);\n */\nFactory.addComponentsGetterSetter(Node, 'offset', ['x', 'y']);\n/**\n * get/set offset. Offsets the default position and rotation point\n * @method\n * @param {Object} offset\n * @param {Number} offset.x\n * @param {Number} offset.y\n * @returns {Object}\n * @example\n * // get offset\n * var offset = node.offset();\n *\n * // set offset\n * node.offset({\n * x: 20,\n * y: 10\n * });\n */\naddGetterSetter(Node, 'offsetX', 0, getNumberValidator());\n/**\n * get/set offset x\n * @name Konva.Node#offsetX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get offset x\n * var offsetX = node.offsetX();\n *\n * // set offset x\n * node.offsetX(3);\n */\naddGetterSetter(Node, 'offsetY', 0, getNumberValidator());\n/**\n * get/set offset y\n * @name Konva.Node#offsetY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get offset y\n * var offsetY = node.offsetY();\n *\n * // set offset y\n * node.offsetY(3);\n */\naddGetterSetter(Node, 'dragDistance', undefined, getNumberValidator());\n/**\n * get/set drag distance. A drag starts once the pointer moved this far from where it\n * went down, on either axis. Default is `Konva.dragDistance`\n * @name Konva.Node#dragDistance\n * @method\n * @param {Number} distance\n * @returns {Number}\n * @example\n * // get drag distance\n * var dragDistance = node.dragDistance();\n *\n * // set distance\n * // node starts dragging only if pointer moved more then 3 pixels\n * node.dragDistance(3);\n * // or set globally\n * Konva.dragDistance = 3;\n */\naddGetterSetter(Node, 'width', 0, getNumberValidator());\n/**\n * get/set width\n * @name Konva.Node#width\n * @method\n * @param {Number} width\n * @returns {Number}\n * @example\n * // get width\n * var width = node.width();\n *\n * // set width\n * node.width(100);\n */\naddGetterSetter(Node, 'height', 0, getNumberValidator());\n/**\n * get/set height\n * @name Konva.Node#height\n * @method\n * @param {Number} height\n * @returns {Number}\n * @example\n * // get height\n * var height = node.height();\n *\n * // set height\n * node.height(100);\n */\naddGetterSetter(Node, 'listening', true, getBooleanValidator());\n/**\n * get/set listening attr. If you need to determine if a node is listening or not\n * by taking into account its parents, use the isListening() method\n * nodes with listening set to false will not be detected in hit graph\n * so they will be ignored in container.getIntersection() method\n * a non-listening layer (or a layer of a non-listening stage) also\n * releases its hit canvas, so it uses less memory\n * @name Konva.Node#listening\n * @method\n * @param {Boolean} listening Can be true, or false. The default is true.\n * @returns {Boolean}\n * @example\n * // get listening attr\n * var listening = node.listening();\n *\n * // stop listening for events, remove node and all its children from hit graph\n * node.listening(false);\n *\n * // listen to events according to the parent\n * node.listening(true);\n */\n/**\n * get/set preventDefault\n * By default all shapes will prevent default behavior\n * of a browser on a pointer move or tap.\n * that will prevent native scrolling when you are trying to drag&drop a node\n * but sometimes you may need to enable default actions\n * in that case you can set the property to false\n * @name Konva.Node#preventDefault\n * @method\n * @param {Boolean} preventDefault\n * @returns {Boolean}\n * @example\n * // get preventDefault\n * var shouldPrevent = shape.preventDefault();\n *\n * // set preventDefault\n * shape.preventDefault(false);\n */\naddGetterSetter(Node, 'preventDefault', true, getBooleanValidator());\naddGetterSetter(Node, 'filters', undefined, function (val) {\n this._filterUpToDate = false;\n return val;\n});\n/**\n * get/set filters. Supports function filters, CSS filter strings, or mixed arrays.\n * CSS filters are applied using native browser performance when possible, function filters use ImageData manipulation.\n * CSS filters automatically fall back to function filters in unsupported browsers.\n * @name Konva.Node#filters\n * @method\n * @param {Array} filters array of filter functions and/or CSS filter strings\n * @returns {Array}\n * @example\n * // get filters\n * var filters = node.filters();\n *\n * // set CSS filters only (no caching required, uses native performance)\n * node.filters(['blur(5px)', 'brightness(1.2)', 'contrast(1.5)']);\n *\n * // set function filters only (caching required)\n * node.cache();\n * node.filters([Konva.Filters.Blur, Konva.Filters.Sepia, Konva.Filters.Invert]);\n *\n * // mix CSS and function filters (caching required, uses fallback strategy)\n * node.cache();\n * node.filters([\n * 'blur(3px)', // CSS filter\n * Konva.Filters.Invert, // function filter\n * 'brightness(1.5)' // CSS filter\n * ]);\n */\naddGetterSetter(Node, 'visible', true, getBooleanValidator());\n/**\n * get/set visible attr. Can be true, or false. The default is true.\n * If you need to determine if a node is visible or not\n * by taking into account its parents, use the isVisible() method\n * @name Konva.Node#visible\n * @method\n * @param {Boolean} visible\n * @returns {Boolean}\n * @example\n * // get visible attr\n * var visible = node.visible();\n *\n * // make invisible\n * node.visible(false);\n *\n * // make visible (according to the parent)\n * node.visible(true);\n *\n */\naddGetterSetter(Node, 'transformsEnabled', 'all', getStringValidator());\n/**\n * get/set transforms that are enabled. Can be \"all\", \"none\", or \"position\". The default\n * is \"all\"\n * @name Konva.Node#transformsEnabled\n * @method\n * @param {String} enabled\n * @returns {String}\n * @example\n * // enable position transform only to improve draw performance\n * node.transformsEnabled('position');\n *\n * // enable all transforms\n * node.transformsEnabled('all');\n */\n/**\n * get/set node size\n * @name Konva.Node#size\n * @method\n * @param {Object} size\n * @param {Number} size.width\n * @param {Number} size.height\n * @returns {Object}\n * @example\n * // get node size\n * var size = node.size();\n * var width = size.width;\n * var height = size.height;\n *\n * // set size\n * node.size({\n * width: 100,\n * height: 200\n * });\n */\naddGetterSetter(Node, 'size');\n/**\n * get/set drag bound function. This is used to override the default\n * drag and drop position. The function is called with the absolute position\n * the node is about to get and the native event, and must return the\n * absolute position to use\n * @name Konva.Node#dragBoundFunc\n * @method\n * @param {Function} dragBoundFunc function(pos, evt) returning `{ x, y }`\n * @returns {Function}\n * @example\n * // get drag bound function\n * var dragBoundFunc = node.dragBoundFunc();\n *\n * // create vertical drag and drop\n * node.dragBoundFunc(function(pos){\n * // important pos - is absolute position of the node\n * // you should return absolute position too\n * return {\n * x: this.absolutePosition().x,\n * y: pos.y\n * };\n * });\n */\naddGetterSetter(Node, 'dragBoundFunc');\n/**\n * get/set draggable flag\n * @name Konva.Node#draggable\n * @method\n * @param {Boolean} draggable\n * @returns {Boolean}\n * @example\n * // get draggable flag\n * var draggable = node.draggable();\n *\n * // enable drag and drop\n * node.draggable(true);\n *\n * // disable drag and drop\n * node.draggable(false);\n */\naddGetterSetter(Node, 'draggable', false, getBooleanValidator());\nFactory.backCompat(Node, {\n rotateDeg: 'rotate',\n setRotationDeg: 'setRotation',\n getRotationDeg: 'getRotation',\n});\n","import { Factory } from \"./Factory.js\";\nimport { Node } from \"./Node.js\";\nimport { getNumberValidator } from \"./Validators.js\";\n/**\n * Container constructor. Containers are used to contain nodes or other containers\n * @constructor\n * @memberof Konva\n * @augments Konva.Node\n * @abstract\n * @param {Object} config\n * @@nodeParams\n * @@containerParams\n */\nexport class Container extends Node {\n constructor() {\n super(...arguments);\n this.children = [];\n }\n /**\n * returns an array of direct descendant nodes\n * @method\n * @name Konva.Container#getChildren\n * @param {Function} [filterFunc] filter function\n * @returns {Array}\n * @example\n * // get all children\n * var children = layer.getChildren();\n *\n * // get only circles\n * var circles = layer.getChildren(function(node){\n * return node.getClassName() === 'Circle';\n * });\n */\n getChildren(filterFunc) {\n // a copy, so that removing children while iterating over it is safe\n const children = this.children || [];\n return filterFunc ? children.filter(filterFunc) : children.slice();\n }\n /**\n * determine if node has children\n * @method\n * @name Konva.Container#hasChildren\n * @returns {Boolean}\n */\n hasChildren() {\n return this.children.length > 0;\n }\n /**\n * remove all children. Children will be still in memory.\n * If you want to completely destroy all children please use \"destroyChildren\" method instead\n * @method\n * @name Konva.Container#removeChildren\n */\n removeChildren() {\n this.children.forEach((child) => {\n // reset parent to prevent many _setChildrenIndices calls\n child.parent = null;\n child.index = 0;\n child.remove();\n });\n this.children = [];\n // because all children were detached from parent, request draw via container\n this._requestDraw();\n return this;\n }\n /**\n * destroy all children nodes.\n * @method\n * @name Konva.Container#destroyChildren\n */\n destroyChildren() {\n this.children.forEach((child) => {\n // reset parent to prevent many _setChildrenIndices calls\n child.parent = null;\n child.index = 0;\n child.destroy();\n });\n this.children = [];\n // because all children were detached from parent, request draw via container\n this._requestDraw();\n return this;\n }\n /**\n * add a child and children into container\n * @name Konva.Container#add\n * @method\n * @param {...Konva.Node} children\n * @returns {Container}\n * @example\n * layer.add(rect);\n * layer.add(shape1, shape2, shape3);\n * // empty arrays are accepted, though each individual child must be defined\n * layer.add(...shapes);\n */\n add(...children) {\n if (children.length === 0) {\n return this;\n }\n if (children.length > 1) {\n for (let i = 0; i < children.length; i++) {\n this.add(children[i]);\n }\n return this;\n }\n const child = children[0];\n if (child.getParent()) {\n child.moveTo(this);\n return this;\n }\n this._validateAdd(child);\n child.index = this.children.length;\n child.parent = this;\n child._clearCaches();\n this.children.push(child);\n this._fire('add', {\n child: child,\n });\n this._requestDraw();\n // chainable\n return this;\n }\n destroy() {\n if (this.hasChildren()) {\n this.destroyChildren();\n }\n super.destroy();\n return this;\n }\n /**\n * return an array of nodes that match the selector.\n * You can provide a string with '#' for id selections and '.' for name selections.\n * Or a function that will return true/false when a node is passed through. See example below.\n * With strings you can also select by type or class name. Pass multiple selectors\n * separated by a comma.\n * @method\n * @name Konva.Container#find\n * @param {String | Function} selector\n * @returns {Array}\n * @example\n *\n * Passing a string as a selector\n * // select node with id foo\n * var node = stage.find('#foo');\n *\n * // select nodes with name bar inside layer\n * var nodes = layer.find('.bar');\n *\n * // select all groups inside layer\n * var nodes = layer.find('Group');\n *\n * // select all rectangles inside layer\n * var nodes = layer.find('Rect');\n *\n * // select node with an id of foo or a name of bar inside layer\n * var nodes = layer.find('#foo, .bar');\n *\n * Passing a function as a selector\n *\n * // get all groups with a function\n * var groups = stage.find(node => {\n * return node.getType() === 'Group';\n * });\n *\n * // get only Nodes with partial opacity\n * var alphaNodes = layer.find(node => {\n * return node.getType() === 'Node' && node.getAbsoluteOpacity() < 1;\n * });\n */\n find(selector) {\n // protecting _generalFind to prevent user from accidentally adding\n // second argument and getting unexpected `findOne` result\n return this._generalFind(selector, false);\n }\n /**\n * return a first node from `find` method\n * @method\n * @name Konva.Container#findOne\n * @param {String | Function} selector\n * @returns {Konva.Node | Undefined}\n * @example\n * // select node with id foo\n * var node = stage.findOne('#foo');\n *\n * // select node with name bar inside layer\n * var nodes = layer.findOne('.bar');\n *\n * // select the first node to return true in a function\n * var node = stage.findOne(node => {\n * return node.getType() === 'Shape'\n * })\n */\n findOne(selector) {\n const result = this._generalFind(selector, true);\n return result.length > 0 ? result[0] : undefined;\n }\n _generalFind(selector, findOne) {\n const retArr = [];\n this._descendants((node) => {\n const valid = node._isMatch(selector);\n if (valid) {\n retArr.push(node);\n }\n if (valid && findOne) {\n return true;\n }\n return false;\n });\n return retArr;\n }\n _descendants(fn) {\n let shouldStop = false;\n for (const child of this.children) {\n shouldStop = fn(child);\n if (shouldStop) {\n return true;\n }\n if (!child.hasChildren()) {\n continue;\n }\n shouldStop = child._descendants(fn);\n if (shouldStop) {\n return true;\n }\n }\n return false;\n }\n // extenders\n toObject() {\n const obj = Node.prototype.toObject.call(this);\n obj.children = [];\n this.children.forEach((child) => {\n obj.children.push(child.toObject());\n });\n return obj;\n }\n /**\n * determine if node is an ancestor\n * of descendant\n * @method\n * @name Konva.Container#isAncestorOf\n * @param {Konva.Node} node\n */\n isAncestorOf(node) {\n let parent = node.getParent();\n while (parent) {\n if (parent._id === this._id) {\n return true;\n }\n parent = parent.getParent();\n }\n return false;\n }\n clone(obj) {\n // call super method\n const node = Node.prototype.clone.call(this, obj);\n this.children.forEach(function (no) {\n node.add(no.clone());\n });\n return node;\n }\n /**\n * get all shapes that intersect a point. Note: because this method must clear a temporary\n * canvas and redraw every shape inside the container, it should only be used for special situations\n * because it performs very poorly. Please use the {@link Konva.Stage#getIntersection} method if at all possible\n * because it performs much better.\n * Nodes with listening set to false or invisible nodes are not detected\n * @method\n * @name Konva.Container#getAllIntersections\n * @param {Object} pos\n * @param {Number} pos.x\n * @param {Number} pos.y\n * @returns {Array} array of shapes\n */\n getAllIntersections(pos) {\n const arr = [];\n this.find('Shape').forEach((shape) => {\n if (shape.isVisible() && shape.intersects(pos)) {\n arr.push(shape);\n }\n });\n return arr;\n }\n _clearSelfAndDescendantCache(attr) {\n var _a;\n // Perf: bracket absoluteTransform cascades with a depth counter so\n // Node._runAfterAbsTransformCascade can defer work until the outermost\n // walk returns. try/finally so depth/flush survive listener exceptions.\n const isAbsTransform = attr === 'absoluteTransform';\n if (isAbsTransform)\n Node._absTransformCascadeDepth++;\n try {\n super._clearSelfAndDescendantCache(attr);\n // a cached container is drawn from its bitmap, so its descendants keep\n // their transform caches while it moves (perf); Node.getAbsoluteTransform\n // skips those caches under a cached ancestor\n if (isAbsTransform && this.isCached())\n return;\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {\n node._clearSelfAndDescendantCache(attr);\n });\n }\n finally {\n if (isAbsTransform && --Node._absTransformCascadeDepth === 0) {\n const callbacks = Node._pendingAfterCascade;\n if (callbacks.length) {\n Node._pendingAfterCascade = [];\n for (let i = 0; i < callbacks.length; i++)\n callbacks[i]();\n }\n }\n }\n }\n _setChildrenIndices() {\n var _a;\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {\n child.index = n;\n });\n this._requestDraw();\n }\n drawScene(can, top, bufferCanvas) {\n const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;\n const caching = canvas && canvas.isCache;\n if (!this.isVisible() && !caching) {\n return this;\n }\n if (cachedSceneCanvas) {\n context.save();\n const m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedSceneCanvas(context);\n context.restore();\n }\n else {\n this._drawChildren('drawScene', canvas, top, bufferCanvas);\n }\n return this;\n }\n drawHit(can, top) {\n if (!this.shouldDrawHit(top)) {\n return this;\n }\n const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedHitCanvas = this._getCachedHitCanvas(top);\n if (cachedHitCanvas) {\n context.save();\n const m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedHitCanvas(context, cachedHitCanvas);\n context.restore();\n }\n else {\n this._drawChildren('drawHit', canvas, top);\n }\n return this;\n }\n _drawChildren(drawMethod, canvas, top, bufferCanvas) {\n var _a;\n const context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (typeof clipWidth === 'number' && typeof clipHeight === 'number') ||\n clipFunc;\n const selfCache = top === this;\n if (hasClip) {\n context.save();\n const transform = this.getAbsoluteTransform(top);\n let m = transform.getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n context.beginPath();\n let clipArgs;\n if (clipFunc) {\n clipArgs = clipFunc.call(this, context, this);\n }\n else {\n const clipX = this.clipX();\n const clipY = this.clipY();\n context.rect(clipX || 0, clipY || 0, clipWidth, clipHeight);\n }\n context.clip.apply(context, clipArgs);\n m = transform.copy().invert().getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n const hasComposition = !selfCache &&\n this.globalCompositeOperation() !== 'source-over' &&\n drawMethod === 'drawScene';\n if (hasComposition) {\n context.save();\n context._applyGlobalCompositeOperation(this);\n }\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {\n child[drawMethod](canvas, top, bufferCanvas);\n });\n if (hasComposition) {\n context.restore();\n }\n if (hasClip) {\n context.restore();\n }\n }\n getClientRect(config = {}) {\n var _a;\n const skipTransform = config.skipTransform;\n const relativeTo = config.relativeTo;\n let minX, minY, maxX, maxY;\n let selfRect = {\n x: Infinity,\n y: Infinity,\n width: 0,\n height: 0,\n };\n const that = this;\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {\n // skip invisible children\n if (!child.visible()) {\n return;\n }\n const rect = child.getClientRect({\n relativeTo: that,\n skipShadow: config.skipShadow,\n skipStroke: config.skipStroke,\n });\n // skip invisible children (like empty groups) and a child whose rect\n // would poison the whole box\n if ((rect.width === 0 && rect.height === 0) ||\n !isFinite(rect.x + rect.y + rect.width + rect.height)) {\n return;\n }\n if (minX === undefined) {\n // initial value for first child\n minX = rect.x;\n minY = rect.y;\n maxX = rect.x + rect.width;\n maxY = rect.y + rect.height;\n }\n else {\n minX = Math.min(minX, rect.x);\n minY = Math.min(minY, rect.y);\n maxX = Math.max(maxX, rect.x + rect.width);\n maxY = Math.max(maxY, rect.y + rect.height);\n }\n });\n if (minX !== undefined) {\n selfRect = {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n else {\n selfRect = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n if (!skipTransform) {\n return this._transformedRect(selfRect, relativeTo);\n }\n return selfRect;\n }\n}\n// add getters setters\nFactory.addComponentsGetterSetter(Container, 'clip', [\n 'x',\n 'y',\n 'width',\n 'height',\n]);\n/**\n * get/set clip\n * @method\n * @name Konva.Container#clip\n * @param {Object} clip\n * @param {Number} clip.x\n * @param {Number} clip.y\n * @param {Number} clip.width\n * @param {Number} clip.height\n * @returns {Object}\n * @example\n * // get clip\n * var clip = container.clip();\n *\n * // set clip\n * container.clip({\n * x: 20,\n * y: 20,\n * width: 20,\n * height: 20\n * });\n */\nFactory.addGetterSetter(Container, 'clipX', undefined, getNumberValidator());\n/**\n * get/set clip x\n * @name Konva.Container#clipX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get clip x\n * var clipX = container.clipX();\n *\n * // set clip x\n * container.clipX(10);\n */\nFactory.addGetterSetter(Container, 'clipY', undefined, getNumberValidator());\n/**\n * get/set clip y\n * @name Konva.Container#clipY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get clip y\n * var clipY = container.clipY();\n *\n * // set clip y\n * container.clipY(10);\n */\nFactory.addGetterSetter(Container, 'clipWidth', undefined, getNumberValidator());\n/**\n * get/set clip width\n * @name Konva.Container#clipWidth\n * @method\n * @param {Number} width\n * @returns {Number}\n * @example\n * // get clip width\n * var clipWidth = container.clipWidth();\n *\n * // set clip width\n * container.clipWidth(100);\n */\nFactory.addGetterSetter(Container, 'clipHeight', undefined, getNumberValidator());\n/**\n * get/set clip height\n * @name Konva.Container#clipHeight\n * @method\n * @param {Number} height\n * @returns {Number}\n * @example\n * // get clip height\n * var clipHeight = container.clipHeight();\n *\n * // set clip height\n * container.clipHeight(100);\n */\nFactory.addGetterSetter(Container, 'clipFunc');\n/**\n * get/set clip function\n * @name Konva.Container#clipFunc\n * @method\n * @param {Function} function\n * @returns {Function}\n * @example\n * // get clip function\n * var clipFunction = container.clipFunc();\n *\n * // set clip function\n * container.clipFunc(function(ctx) {\n * ctx.rect(0, 0, 100, 100);\n * });\n *\n * container.clipFunc(function(ctx) {\n * // optionally return a clip Path2D and clip-rule or just the clip-rule\n * return [new Path2D('M0 0v50h50Z'), 'evenodd']\n * });\n */\n","import { Util } from \"./Util.js\";\nimport { Factory } from \"./Factory.js\";\nimport { Container } from \"./Container.js\";\nimport { Konva } from \"./Global.js\";\nimport { SceneCanvas, HitCanvas } from \"./Canvas.js\";\nimport { DD } from \"./DragAndDrop.js\";\nimport { _registerNode } from \"./Global.js\";\nimport * as PointerEvents from \"./PointerEvents.js\";\n// CONSTANTS\nconst STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [\n [MOUSEENTER, '_pointerenter'],\n [MOUSEDOWN, '_pointerdown'],\n [MOUSEMOVE, '_pointermove'],\n [MOUSEUP, '_pointerup'],\n [MOUSELEAVE, '_pointerleave'],\n [TOUCHSTART, '_pointerdown'],\n [TOUCHMOVE, '_pointermove'],\n [TOUCHEND, '_pointerup'],\n [TOUCHCANCEL, '_pointercancel'],\n [MOUSEOVER, '_pointerover'],\n [WHEEL, '_wheel'],\n [CONTEXTMENU, '_contextmenu'],\n [POINTERDOWN, '_pointerdown'],\n [POINTERMOVE, '_pointermove'],\n [POINTERUP, '_pointerup'],\n [POINTERCANCEL, '_pointercancel'],\n [POINTERLEAVE, '_pointerleave'],\n [LOSTPOINTERCAPTURE, '_lostpointercapture'],\n];\nconst EVENTS_MAP = {\n mouse: {\n [POINTEROUT]: MOUSEOUT,\n [POINTERLEAVE]: MOUSELEAVE,\n [POINTEROVER]: MOUSEOVER,\n [POINTERENTER]: MOUSEENTER,\n [POINTERMOVE]: MOUSEMOVE,\n [POINTERDOWN]: MOUSEDOWN,\n [POINTERUP]: MOUSEUP,\n [POINTERCANCEL]: 'mousecancel',\n pointerclick: 'click',\n pointerdblclick: 'dblclick',\n },\n touch: {\n [POINTEROUT]: 'touchout',\n [POINTERLEAVE]: 'touchleave',\n [POINTEROVER]: 'touchover',\n [POINTERENTER]: 'touchenter',\n [POINTERMOVE]: TOUCHMOVE,\n [POINTERDOWN]: TOUCHSTART,\n [POINTERUP]: TOUCHEND,\n [POINTERCANCEL]: TOUCHCANCEL,\n pointerclick: 'tap',\n pointerdblclick: 'dbltap',\n },\n pointer: {\n [POINTEROUT]: POINTEROUT,\n [POINTERLEAVE]: POINTERLEAVE,\n [POINTEROVER]: POINTEROVER,\n [POINTERENTER]: POINTERENTER,\n [POINTERMOVE]: POINTERMOVE,\n [POINTERDOWN]: POINTERDOWN,\n [POINTERUP]: POINTERUP,\n [POINTERCANCEL]: POINTERCANCEL,\n pointerclick: 'pointerclick',\n pointerdblclick: 'pointerdblclick',\n },\n};\nconst getEventType = (type) => {\n if (type.indexOf('pointer') >= 0) {\n return 'pointer';\n }\n if (type.indexOf('touch') >= 0) {\n return 'touch';\n }\n return 'mouse';\n};\nconst getEventsMap = (eventType) => {\n const type = getEventType(eventType);\n if (type === 'pointer') {\n return Konva.pointerEventsEnabled && EVENTS_MAP.pointer;\n }\n if (type === 'touch') {\n return EVENTS_MAP.touch;\n }\n if (type === 'mouse') {\n return EVENTS_MAP.mouse;\n }\n};\nfunction checkNoClip(attrs = {}) {\n if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {\n Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');\n }\n return attrs;\n}\nconst NO_POINTERS_MESSAGE = `Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`;\nexport const stages = [];\n// A stage may be rendered in another window than the one Konva was imported\n// into: an iframe, or a window opened with `window.open`. Such a window sends\n// its own events and has its own visibility state, so Konva listens to every\n// window it renders a stage in\nconst listeningWindows = new WeakSet();\nconst listenToWindow = (win) => {\n if (!win || listeningWindows.has(win)) {\n return;\n }\n listeningWindows.add(win);\n DD._listenToWindow(win);\n // chrome is clearing canvas in inactive browser window, causing layer content to be erased\n // so let's redraw layers as soon as window becomes active\n win.document.addEventListener('visibilitychange', () => {\n stages.forEach((stage) => {\n stage.batchDraw();\n });\n });\n};\n/**\n * Stage constructor. A stage is used to contain multiple layers\n * @constructor\n * @memberof Konva\n * @augments Konva.Container\n * @param {Object} config\n * @param {String|Element} config.container Container selector or DOM element\n * @@nodeParams\n * @example\n * var stage = new Konva.Stage({\n * width: 500,\n * height: 800,\n * container: 'containerId' // or \"#containerId\" or \".containerClass\"\n * });\n */\nexport class Stage extends Container {\n constructor(config) {\n super(checkNoClip(config));\n this._pointerPositions = [];\n this._changedPointerPositions = [];\n this._buildDOM();\n this._bindContentEvents();\n stages.push(this);\n this.on('widthChange.konva heightChange.konva', this._resizeDOM);\n this.on('visibleChange.konva', this._checkVisibility);\n this.on('clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva', () => {\n checkNoClip(this.attrs);\n });\n this._checkVisibility();\n }\n _validateAdd(child) {\n const isLayer = child.getType() === 'Layer';\n const isFastLayer = child.getType() === 'FastLayer';\n const valid = isLayer || isFastLayer;\n if (!valid) {\n Util.throw('You may only add layers to the stage.');\n }\n }\n _checkVisibility() {\n if (!this.content) {\n return;\n }\n const style = this.visible() ? '' : 'none';\n this.content.style.display = style;\n }\n /**\n * The window the stage is rendered in. It is not always the window Konva was\n * imported into: the container may belong to an iframe, or to a window\n * opened with `window.open`.\n */\n _getOwnerWindow() {\n var _a;\n const element = this.content || this.container();\n // a document with no browsing context, such as one of `DOMParser`, has no\n // window of its own. The window Konva was imported into is used then\n return (((_a = element === null || element === void 0 ? void 0 : element.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) || (Konva.isBrowser ? window : null));\n }\n /**\n * set container dom element which contains the stage wrapper div element\n * @method\n * @name Konva.Stage#setContainer\n * @param {DomElement} container can pass in a dom element or id string\n */\n setContainer(container) {\n if (typeof container === STRING) {\n let id;\n if (container.charAt(0) === '.') {\n const className = container.slice(1);\n container = document.getElementsByClassName(className)[0];\n }\n else {\n if (container.charAt(0) !== '#') {\n id = container;\n }\n else {\n id = container.slice(1);\n }\n container = document.getElementById(id);\n }\n if (!container) {\n throw 'Can not find container in document with id ' + id;\n }\n }\n this._setAttr('container', container);\n if (this.content) {\n if (this.content.parentElement) {\n this.content.parentElement.removeChild(this.content);\n }\n container.appendChild(this.content);\n // the new container may be in another window, with its own events\n listenToWindow(this._getOwnerWindow());\n }\n return this;\n }\n shouldDrawHit() {\n return true;\n }\n /**\n * clear all layers\n * @method\n * @name Konva.Stage#clear\n */\n clear() {\n const layers = this.children, len = layers.length;\n for (let n = 0; n < len; n++) {\n layers[n].clear();\n }\n return this;\n }\n clone(obj) {\n if (!obj) {\n obj = {};\n }\n obj.container =\n typeof document !== 'undefined' && document.createElement('div');\n return Container.prototype.clone.call(this, obj);\n }\n destroy() {\n super.destroy();\n // a pending double-click timer is what closes the global double-click\n // window, so close the window when the timer goes\n ['mouse', 'touch', 'pointer'].forEach((type) => {\n clearTimeout(this['_' + type + 'DblTimeout']);\n Konva['_' + type + 'InDblClickWindow'] = false;\n });\n const content = this.content;\n if (content && Util._isInDocument(content)) {\n this.container().removeChild(content);\n }\n const index = stages.indexOf(this);\n if (index > -1) {\n stages.splice(index, 1);\n }\n Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);\n return this;\n }\n /**\n * returns ABSOLUTE pointer position which can be a touch position or mouse position\n * pointer position doesn't include any transforms (such as scale) of the stage\n * it is just a plain position of pointer relative to top-left corner of the canvas\n * @method\n * @name Konva.Stage#getPointerPosition\n * @returns {Vector2d|null}\n */\n getPointerPosition() {\n const pos = this._pointerPositions[0] || this._changedPointerPositions[0];\n if (!pos) {\n Util.warn(NO_POINTERS_MESSAGE);\n return null;\n }\n return {\n x: pos.x,\n y: pos.y,\n };\n }\n _getPointerById(id) {\n return this._pointerPositions.find((p) => p.id === id);\n }\n getPointersPositions() {\n return this._pointerPositions;\n }\n getStage() {\n return this;\n }\n getContent() {\n return this.content;\n }\n _toKonvaCanvas(config) {\n config = { ...config };\n config.x = config.x || 0;\n config.y = config.y || 0;\n config.width = config.width || this.width();\n config.height = config.height || this.height();\n const canvas = new SceneCanvas({\n width: config.width,\n height: config.height,\n pixelRatio: config.pixelRatio || 1,\n });\n const _context = canvas.getContext()._context;\n const layers = this.children;\n if (config.x || config.y) {\n _context.translate(-1 * config.x, -1 * config.y);\n }\n // every layer renders on its own canvas, like on screen, so a\n // globalCompositeOperation inside a layer does not reach the layers below\n layers.forEach(function (layer) {\n if (!layer.isVisible()) {\n return;\n }\n const layerCanvas = layer._toKonvaCanvas(config);\n _context.drawImage(layerCanvas._canvas, config.x, config.y, layerCanvas.getWidth() / layerCanvas.getPixelRatio(), layerCanvas.getHeight() / layerCanvas.getPixelRatio());\n Util.releaseCanvas(layerCanvas._canvas);\n });\n return canvas;\n }\n /**\n * get visible intersection shape. This is the preferred\n * method for determining if a point intersects a shape or not.\n * It reads the hit canvas, so it finds what pointer events would: nodes with\n * listening set to false or invisible nodes are not detected, a shape with opacity 0\n * is, and `hitStrokeWidth` counts. The position is relative to the top left corner of the\n * stage container, like `stage.getPointerPosition()`, without the stage transform\n * @method\n * @name Konva.Stage#getIntersection\n * @param {Object} pos\n * @param {Number} pos.x\n * @param {Number} pos.y\n * @returns {Konva.Node}\n * @example\n * var shape = stage.getIntersection({x: 50, y: 50});\n */\n getIntersection(pos) {\n if (!pos) {\n return null;\n }\n const layers = this.children, len = layers.length, end = len - 1;\n for (let n = end; n >= 0; n--) {\n const shape = layers[n].getIntersection(pos);\n if (shape) {\n return shape;\n }\n }\n return null;\n }\n _resizeDOM() {\n const width = this.width();\n const height = this.height();\n if (this.content) {\n // set content dimensions\n this.content.style.width = width + PX;\n this.content.style.height = height + PX;\n }\n // set layer dimensions\n this.children.forEach((layer) => {\n layer._setSize({ width, height });\n layer.draw();\n });\n }\n // \"perfect drawing\" uses bufferCanvas, shape.intersects() uses\n // bufferHitCanvas; both are lazy - created at 0x0 and sized to the stage\n // on first use\n _syncBufferSize(canvas) {\n canvas.setSizeIfChanged(this.width(), this.height());\n return canvas;\n }\n add(layer, ...rest) {\n if (arguments.length > 1) {\n for (let i = 0; i < arguments.length; i++) {\n this.add(arguments[i]);\n }\n return this;\n }\n super.add(layer);\n const length = this.children.length;\n if (length > MAX_LAYERS_NUMBER) {\n Util.warn('The stage has ' +\n length +\n ' layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.');\n }\n layer._setSize({ width: this.width(), height: this.height() });\n // draw layer and append canvas to container\n layer.draw();\n if (Konva.isBrowser) {\n this.content.appendChild(layer.canvas._canvas);\n }\n // chainable\n return this;\n }\n getParent() {\n return null;\n }\n getLayer() {\n return null;\n }\n hasPointerCapture(pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n }\n setPointerCapture(pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n }\n releaseCapture(pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n }\n /**\n * returns an array of layers\n * @method\n * @name Konva.Stage#getLayers\n */\n getLayers() {\n return this.getChildren();\n }\n _bindContentEvents() {\n if (!Konva.isBrowser) {\n return;\n }\n EVENTS.forEach(([event, methodName]) => {\n this.content.addEventListener(event, (evt) => {\n this._batchEvents(() => this[methodName](evt));\n }, { passive: false });\n });\n }\n _batchEvents(callback) {\n Util._batchEvents(this.eventBatchFunc(), callback);\n }\n _pointerenter(evt) {\n this.setPointersPositions(evt);\n const events = getEventsMap(evt.type);\n if (events) {\n this._fire(events.pointerenter, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _pointerover(evt) {\n this.setPointersPositions(evt);\n const events = getEventsMap(evt.type);\n if (events) {\n this._fire(events.pointerover, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _getTargetShape(evenType) {\n let shape = this[evenType + 'targetShape'];\n if (shape && !shape.getStage()) {\n shape = null;\n }\n return shape;\n }\n _pointerleave(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n const targetShape = this._getTargetShape(eventType);\n const eventsEnabled = !(Konva.isDragging() || Konva.isTransforming()) || Konva.hitOnDragEnabled;\n if (targetShape && eventsEnabled) {\n targetShape._fireAndBubble(events.pointerout, { evt: evt });\n targetShape._fireAndBubble(events.pointerleave, { evt: evt });\n this._fire(events.pointerleave, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n this[eventType + 'targetShape'] = null;\n }\n else if (eventsEnabled) {\n this._fire(events.pointerleave, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n this._fire(events.pointerout, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n this.pointerPos = null;\n this._pointerPositions = [];\n }\n _pointerdown(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n let triggeredOnShape = false;\n this._changedPointerPositions.forEach((pos) => {\n const shape = this.getIntersection(pos);\n DD.justDragged = false;\n // probably we are staring a click\n Konva['_' + eventType + 'ListenClick'] = true;\n // no shape detected? do nothing\n if (!shape || !shape.isListening()) {\n this[eventType + 'ClickStartShape'] = undefined;\n return;\n }\n if (Konva.capturePointerEventsEnabled) {\n shape.setPointerCapture(pos.id);\n }\n // save where we started the click\n this[eventType + 'ClickStartShape'] = shape;\n shape._fireAndBubble(events.pointerdown, {\n evt: evt,\n pointerId: pos.id,\n });\n triggeredOnShape = true;\n // only call preventDefault if the shape is listening for events\n const isTouch = evt.type.indexOf('touch') >= 0;\n if (shape.preventDefault() && evt.cancelable && isTouch) {\n evt.preventDefault();\n }\n });\n // trigger down on stage if not already\n if (!triggeredOnShape) {\n this._fire(events.pointerdown, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._pointerPositions[0].id,\n });\n }\n }\n _pointermove(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n // prevent default only for touch-based interactions to avoid blocking\n // native mouse wheel scrolling during drag on desktop\n const isTouchPointer = evt.type.indexOf('touch') >= 0 ||\n evt.pointerType === 'touch';\n if (Konva.isDragging() &&\n DD.node.preventDefault() &&\n evt.cancelable &&\n isTouchPointer) {\n evt.preventDefault();\n }\n this.setPointersPositions(evt);\n const eventsEnabled = !(Konva.isDragging() || Konva.isTransforming()) || Konva.hitOnDragEnabled;\n if (!eventsEnabled) {\n return;\n }\n const processedShapesIds = {};\n let triggeredOnShape = false;\n const targetShape = this._getTargetShape(eventType);\n this._changedPointerPositions.forEach((pos) => {\n const shape = (PointerEvents.getCapturedShape(pos.id) ||\n this.getIntersection(pos));\n const pointerId = pos.id;\n const event = { evt: evt, pointerId };\n const differentTarget = targetShape !== shape;\n if (differentTarget && targetShape) {\n targetShape._fireAndBubble(events.pointerout, { ...event }, shape);\n targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);\n }\n if (shape) {\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n }\n if (shape && shape.isListening()) {\n triggeredOnShape = true;\n if (differentTarget) {\n shape._fireAndBubble(events.pointerover, { ...event }, targetShape);\n shape._fireAndBubble(events.pointerenter, { ...event }, targetShape);\n this[eventType + 'targetShape'] = shape;\n }\n shape._fireAndBubble(events.pointermove, { ...event });\n }\n else {\n if (targetShape) {\n this._fire(events.pointerover, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n this[eventType + 'targetShape'] = null;\n }\n }\n });\n if (!triggeredOnShape) {\n this._fire(events.pointermove, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id,\n });\n }\n }\n _pointerup(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n // the mouse/touch families get their \"listen click\" flags reset by\n // DD._endDragBefore, but native \"pointerup\" fires before the\n // \"mouseup\"/\"touchend\" that ends the drag, so for the pointer family the\n // flags are still set — check the live drag state as well, otherwise\n // \"pointerclick\" fires after a drag while \"click\" does not (issue #1756)\n const wasDragged = DD.justDragged || (eventType === 'pointer' && Konva.isDragging());\n const listenClick = Konva['_' + eventType + 'ListenClick'] && !wasDragged;\n const clickStartShape = this[eventType + 'ClickStartShape'];\n const clickEndShape = this[eventType + 'ClickEndShape'];\n const processedShapesIds = {};\n let skipPointerUpTrigger = false;\n this._changedPointerPositions.forEach((pos) => {\n const shape = (PointerEvents.getCapturedShape(pos.id) ||\n this.getIntersection(pos));\n if (shape) {\n shape.releaseCapture(pos.id);\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n }\n const pointerId = pos.id;\n const event = { evt: evt, pointerId };\n let fireDblClick = false;\n if (Konva['_' + eventType + 'InDblClickWindow']) {\n fireDblClick = true;\n clearTimeout(this['_' + eventType + 'DblTimeout']);\n }\n else if (!wasDragged) {\n // don't set inDblClickWindow after dragging\n Konva['_' + eventType + 'InDblClickWindow'] = true;\n clearTimeout(this['_' + eventType + 'DblTimeout']);\n }\n this['_' + eventType + 'DblTimeout'] = setTimeout(function () {\n Konva['_' + eventType + 'InDblClickWindow'] = false;\n }, Konva.dblClickWindow);\n if (shape && shape.isListening()) {\n skipPointerUpTrigger = true;\n this[eventType + 'ClickEndShape'] = shape;\n shape._fireAndBubble(events.pointerup, { ...event });\n // detect if click or double click occurred\n if (listenClick && clickStartShape === shape) {\n shape._fireAndBubble(events.pointerclick, { ...event });\n if (fireDblClick && clickEndShape && clickEndShape === shape) {\n shape._fireAndBubble(events.pointerdblclick, { ...event });\n }\n }\n }\n else {\n this[eventType + 'ClickEndShape'] = null;\n if (!skipPointerUpTrigger) {\n this._fire(events.pointerup, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id,\n });\n skipPointerUpTrigger = true;\n }\n if (listenClick) {\n this._fire(events.pointerclick, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n }\n if (fireDblClick) {\n this._fire(events.pointerdblclick, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n }\n }\n });\n if (!skipPointerUpTrigger) {\n this._fire(events.pointerup, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id,\n });\n }\n Konva['_' + eventType + 'ListenClick'] = false;\n // always call preventDefault for desktop events because some browsers\n // try to drag and drop the canvas element\n // do not call this function on mobile because it prevent \"click\" event on all parent containers\n // but apps may listen to it.\n if (evt.cancelable && eventType !== 'touch' && eventType !== 'pointer') {\n evt.preventDefault();\n }\n }\n _contextmenu(evt) {\n this.setPointersPositions(evt);\n const shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(CONTEXTMENU, { evt: evt });\n }\n else {\n this._fire(CONTEXTMENU, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _wheel(evt) {\n this.setPointersPositions(evt);\n const shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(WHEEL, { evt: evt });\n }\n else {\n this._fire(WHEEL, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _pointercancel(evt) {\n this.setPointersPositions(evt);\n const events = getEventsMap(evt.type);\n this._changedPointerPositions.forEach((pos) => {\n const shape = PointerEvents.getCapturedShape(pos.id) || this.getIntersection(pos);\n const event = { evt, pointerId: pos.id };\n if (shape) {\n if (events)\n shape._fireAndBubble(events.pointercancel, { ...event });\n // Keep the historical pointerup notification for cancellation listeners.\n shape._fireAndBubble(POINTERUP, { ...event });\n }\n else if (events) {\n this._fire(events.pointercancel, {\n ...event,\n target: this,\n currentTarget: this,\n });\n }\n PointerEvents.releaseCapture(pos.id);\n });\n }\n _lostpointercapture(evt) {\n PointerEvents.releaseCapture(evt.pointerId);\n }\n /**\n * manually register pointers positions (mouse/touch) in the stage.\n * So you can use stage.getPointerPosition(). Usually you don't need to use that method\n * because all internal events are automatically registered. It may be useful if event\n * is triggered outside of the stage, but you still want to use Konva methods to get pointers position.\n * @method\n * @name Konva.Stage#setPointersPositions\n * @param {Object} evt Event object\n * @example\n *\n * window.addEventListener('mousemove', (e) => {\n * stage.setPointersPositions(e);\n * });\n */\n setPointersPositions(evt) {\n const contentPosition = this._getContentPosition();\n let x = null, y = null;\n evt = evt ? evt : window.event;\n // touch events\n if (evt.touches !== undefined) {\n // touchlist has not support for map method\n // so we have to iterate\n this._pointerPositions = [];\n this._changedPointerPositions = [];\n Array.prototype.forEach.call(evt.touches, (touch) => {\n this._pointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,\n });\n });\n Array.prototype.forEach.call(evt.changedTouches || evt.touches, (touch) => {\n this._changedPointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,\n });\n });\n }\n else {\n // mouse events\n x = (evt.clientX - contentPosition.left) / contentPosition.scaleX;\n y = (evt.clientY - contentPosition.top) / contentPosition.scaleY;\n this.pointerPos = {\n x: x,\n y: y,\n };\n this._pointerPositions = [{ x, y, id: Util._getFirstPointerId(evt) }];\n this._changedPointerPositions = [\n { x, y, id: Util._getFirstPointerId(evt) },\n ];\n }\n }\n _setPointerPosition(evt) {\n Util.warn('Method _setPointerPosition is deprecated. Use \"stage.setPointersPositions(event)\" instead.');\n this.setPointersPositions(evt);\n }\n _getContentPosition() {\n if (!this.content || !this.content.getBoundingClientRect) {\n return {\n top: 0,\n left: 0,\n scaleX: 1,\n scaleY: 1,\n };\n }\n const rect = this.content.getBoundingClientRect();\n return {\n top: rect.top,\n left: rect.left,\n // sometimes clientWidth can be equals to 0\n // i saw it in react-konva test, looks like it is because of hidden testing element\n scaleX: rect.width / this.content.clientWidth || 1,\n scaleY: rect.height / this.content.clientHeight || 1,\n };\n }\n _buildDOM() {\n // lazy buffer canvases, see _syncBufferSize\n // https://github.com/konvajs/konva/issues/2009\n this.bufferCanvas = new SceneCanvas({\n width: 0,\n height: 0,\n });\n this.bufferHitCanvas = new HitCanvas({\n pixelRatio: 1,\n width: 0,\n height: 0,\n });\n if (!Konva.isBrowser) {\n return;\n }\n const container = this.container();\n if (!container) {\n throw 'Stage has no container. A container is required.';\n }\n // clear content inside container\n container.innerHTML = '';\n // content\n // the container may belong to another document - an iframe, or a popout\n // window - so the content is created in the document of the container\n this.content = container.ownerDocument.createElement('div');\n this.content.style.position = 'relative';\n this.content.style.userSelect = 'none';\n this.content.className = 'konvajs-content';\n this.content.setAttribute('role', 'presentation');\n container.appendChild(this.content);\n listenToWindow(this._getOwnerWindow());\n this._resizeDOM();\n }\n // currently cache function is now working for stage, because stage has no its own canvas element\n cache() {\n Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');\n return this;\n }\n clearCache() {\n return this;\n }\n /**\n * batch draw\n * @method\n * @name Konva.Stage#batchDraw\n * @return {Konva.Stage} this\n */\n batchDraw() {\n var _a;\n // the config applied by the Node constructor already requests a draw,\n // before the children array exists\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (layer) {\n layer.batchDraw();\n });\n return this;\n }\n}\nStage.prototype.nodeType = STAGE;\n_registerNode(Stage);\n/**\n * get/set container DOM element. The container may belong to another window\n * than the one Konva was imported into: an iframe, or a window opened with\n * `window.open`. The stage then uses the events and the frames of that window.\n * @method\n * @name Konva.Stage#container\n * @returns {DomElement} container\n * @example\n * // get container\n * var container = stage.container();\n * // set container\n * var container = document.createElement('div');\n * body.appendChild(container);\n * stage.container(container);\n *\n * // a stage in a popout window\n * var popout = window.open('', '', 'width=600,height=400');\n * stage.container(popout.document.body);\n */\nFactory.addGetterSetter(Stage, 'container');\n/**\n * Get/set the callback used by framework integrations to batch native input.\n * The callback must invoke its argument exactly once, synchronously. Existing\n * node events keep their order and cancellation behavior. Direct node.fire()\n * and programmatic mutations do not create a batch.\n * Missing calls warn; duplicate or late calls warn and are ignored. Exceptions\n * propagate and skipped input is not replayed, so an invalid callback can\n * prevent input processing and drag cleanup.\n * Each native Konva listener creates its own scope; a DOM event may invoke\n * several listeners. Batching does not reorder or merge those listeners.\n * @method\n * @name Konva.Stage#eventBatchFunc\n * @example\n * stage.eventBatchFunc((run) => frameworkBatch(run));\n */\nFactory.addGetterSetter(Stage, 'eventBatchFunc');\n","import { Konva } from \"./Global.js\";\nimport { Transform, Util } from \"./Util.js\";\nimport { Factory } from \"./Factory.js\";\nimport { Node } from \"./Node.js\";\nimport { getNumberValidator, getNumberOrAutoValidator, getStringValidator, getBooleanValidator, getStringOrGradientValidator, } from \"./Validators.js\";\nimport { _registerNode } from \"./Global.js\";\nimport * as PointerEvents from \"./PointerEvents.js\";\nconst HAS_SHADOW = 'hasShadow';\nconst HAS_FILL = 'hasFill';\nconst HAS_STROKE = 'hasStroke';\nconst SHADOW_RGBA = 'shadowRGBA';\nconst patternImage = 'patternImage';\nconst linearGradient = 'linearGradient';\nconst radialGradient = 'radialGradient';\nlet dummyContext;\nfunction getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util.createCanvasElement().getContext('2d');\n return dummyContext;\n}\nexport const shapes = {};\nfunction _fillFunc(context) {\n const fillRule = this.attrs.fillRule;\n if (fillRule) {\n context.fill(fillRule);\n }\n else {\n context.fill();\n }\n}\nfunction _strokeFunc(context) {\n context.stroke();\n}\nfunction _clearHasShadowCache() {\n this._clearCache(HAS_SHADOW);\n}\nfunction _clearHasFillCache() {\n this._clearCache(HAS_FILL);\n}\nfunction _clearHasStrokeCache() {\n this._clearCache(HAS_STROKE);\n}\nfunction _clearGetShadowRGBACache() {\n this._clearCache(SHADOW_RGBA);\n}\nfunction _clearFillPatternCache() {\n this._clearCache(patternImage);\n}\nfunction _clearLinearGradientCache() {\n this._clearCache(linearGradient);\n}\nfunction _clearRadialGradientCache() {\n this._clearCache(radialGradient);\n}\n/**\n * Shape constructor. Shapes are primitive objects such as rectangles,\n * circles, text, lines, etc.\n * @constructor\n * @memberof Konva\n * @augments Konva.Node\n * @param {Object} config\n * @@shapeParams\n * @@nodeParams\n * @example\n * var customShape = new Konva.Shape({\n * x: 5,\n * y: 10,\n * fill: 'red',\n * // a Konva.Canvas renderer is passed into the sceneFunc function\n * sceneFunc (context, shape) {\n * context.beginPath();\n * context.moveTo(200, 50);\n * context.lineTo(420, 80);\n * context.quadraticCurveTo(300, 100, 260, 170);\n * context.closePath();\n * // Konva specific method\n * context.fillStrokeShape(shape);\n * }\n *});\n */\nexport class Shape extends Node {\n constructor(config) {\n super(config);\n // set colorKey\n let key;\n let attempts = 0;\n while (true) {\n key = Util.getHitColor();\n if (key && !(key in shapes)) {\n break;\n }\n attempts++;\n if (attempts >= 10000) {\n Util.warn('Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.');\n key = Util.getRandomColor();\n break;\n }\n }\n this.colorKey = key;\n shapes[key] = this;\n }\n /**\n * @deprecated\n */\n getContext() {\n Util.warn('shape.getContext() method is deprecated. Please do not use it.');\n return this.getLayer().getContext();\n }\n /**\n * @deprecated\n */\n getCanvas() {\n Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');\n return this.getLayer().getCanvas();\n }\n getSceneFunc() {\n return this.attrs.sceneFunc || this['_sceneFunc'];\n }\n getHitFunc() {\n return this.attrs.hitFunc || this['_hitFunc'];\n }\n /**\n * returns whether or not a shadow will be rendered\n * @method\n * @name Konva.Shape#hasShadow\n * @returns {Boolean}\n */\n hasShadow() {\n return this._getCache(HAS_SHADOW, this._hasShadow);\n }\n _hasShadow() {\n return (this.shadowEnabled() &&\n this.shadowOpacity() !== 0 &&\n !!(this.shadowColor() ||\n this.shadowBlur() ||\n this.shadowOffsetX() ||\n this.shadowOffsetY()));\n }\n _getFillPattern() {\n return this._getCache(patternImage, this.__getFillPattern);\n }\n __getFillPattern() {\n if (this.fillPatternImage()) {\n const ctx = getDummyContext();\n const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');\n if (pattern && pattern.setTransform) {\n const tr = new Transform();\n tr.translate(this.fillPatternX(), this.fillPatternY());\n tr.rotate(Konva.getAngle(this.fillPatternRotation()));\n tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());\n tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());\n const m = tr.getMatrix();\n const matrix = typeof DOMMatrix === 'undefined'\n ? {\n a: m[0], // Horizontal scaling. A value of 1 results in no scaling.\n b: m[1], // Vertical skewing.\n c: m[2], // Horizontal skewing.\n d: m[3],\n e: m[4], // Horizontal translation (moving).\n f: m[5], // Vertical translation (moving).\n }\n : new DOMMatrix(m);\n pattern.setTransform(matrix);\n }\n return pattern;\n }\n }\n _getLinearGradient() {\n return this._getCache(linearGradient, this.__getLinearGradient);\n }\n __getLinearGradient() {\n const colorStops = this.fillLinearGradientColorStops();\n if (colorStops) {\n const ctx = getDummyContext();\n const start = this.fillLinearGradientStartPoint();\n const end = this.fillLinearGradientEndPoint();\n const grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);\n // build color stops\n for (let n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n }\n _getRadialGradient() {\n return this._getCache(radialGradient, this.__getRadialGradient);\n }\n __getRadialGradient() {\n const colorStops = this.fillRadialGradientColorStops();\n if (colorStops) {\n const ctx = getDummyContext();\n const start = this.fillRadialGradientStartPoint();\n const end = this.fillRadialGradientEndPoint();\n const grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());\n // build color stops\n for (let n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n }\n getShadowRGBA() {\n return this._getCache(SHADOW_RGBA, this._getShadowRGBA);\n }\n _getShadowRGBA() {\n if (!this.hasShadow()) {\n return;\n }\n const rgba = Util.colorToRGBA(this.shadowColor());\n if (rgba) {\n return ('rgba(' +\n rgba.r +\n ',' +\n rgba.g +\n ',' +\n rgba.b +\n ',' +\n rgba.a * (this.shadowOpacity() || 1) +\n ')');\n }\n }\n /**\n * returns whether or not the shape will be filled\n * @method\n * @name Konva.Shape#hasFill\n * @returns {Boolean}\n */\n hasFill() {\n return this._getCache(HAS_FILL, this._hasFill);\n }\n _hasFill() {\n return (this.fillEnabled() &&\n !!(this.fill() ||\n this.fillPatternImage() ||\n this.fillLinearGradientColorStops() ||\n this.fillRadialGradientColorStops()));\n }\n /**\n * returns whether or not the shape will be stroked\n * @method\n * @name Konva.Shape#hasStroke\n * @returns {Boolean}\n */\n hasStroke() {\n return this._getCache(HAS_STROKE, this._hasStroke);\n }\n _hasStroke() {\n return (this.strokeEnabled() &&\n !!(this.strokeWidth() &&\n (this.stroke() || this.strokeLinearGradientColorStops())));\n }\n hasHitStroke() {\n const width = this.hitStrokeWidth();\n // on auto just check by stroke\n if (width === 'auto') {\n return this.hasStroke();\n }\n // we should enable hit stroke if stroke is enabled\n // and we have some value from width\n return this.strokeEnabled() && !!width;\n }\n /**\n * determines if point is in the shape, regardless if other shapes are on top of it. Note: because\n * this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times\n * consecutively. Please use the {@link Konva.Stage#getIntersection} method if at all possible\n * because it performs much better. A shape that is invisible, not listening or not on a stage\n * never intersects\n * @method\n * @name Konva.Shape#intersects\n * @param {Object} point\n * @param {Number} point.x\n * @param {Number} point.y\n * @returns {Boolean}\n */\n intersects(point) {\n const stage = this.getStage();\n if (!stage) {\n return false;\n }\n const bufferHitCanvas = stage._syncBufferSize(stage.bufferHitCanvas);\n bufferHitCanvas.getContext().clear();\n this.drawHit(bufferHitCanvas);\n const p = bufferHitCanvas.context.getImageData(Math.floor(point.x), Math.floor(point.y), 1, 1).data;\n return p[3] > 0;\n }\n destroy() {\n Node.prototype.destroy.call(this);\n delete shapes[this.colorKey];\n delete this.colorKey;\n return this;\n }\n // why do we need buffer canvas?\n // it give better result when a shape has\n // stroke with fill and with some opacity\n _useBufferCanvas(forceFill) {\n // image and sprite still has \"fill\" as image\n // so they use that method with forced fill\n // it probably will be simpler, then copy/paste the code\n var _a;\n // force skip buffer canvas\n const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;\n if (!perfectDrawEnabled) {\n return false;\n }\n const hasFill = forceFill || this.hasFill();\n const hasStroke = this.hasStroke();\n const isTransparent = this.getAbsoluteOpacity() !== 1;\n if (hasFill && hasStroke && isTransparent) {\n return true;\n }\n const hasShadow = this.hasShadow();\n const strokeForShadow = this.shadowForStrokeEnabled();\n if (hasFill && hasStroke && hasShadow && strokeForShadow) {\n return true;\n }\n return false;\n }\n setStrokeHitEnabled(val) {\n Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');\n if (val) {\n this.hitStrokeWidth('auto');\n }\n else {\n this.hitStrokeWidth(0);\n }\n }\n getStrokeHitEnabled() {\n if (this.hitStrokeWidth() === 0) {\n return false;\n }\n else {\n return true;\n }\n }\n /**\n * return self rectangle (x, y, width, height) of shape.\n * This method are not taken into account transformation and styles.\n * @method\n * @name Konva.Shape#getSelfRect\n * @returns {Object} rect with {x, y, width, height} properties\n * @example\n *\n * rect.getSelfRect(); // return {x:0, y:0, width:rect.width(), height:rect.height()}\n * circle.getSelfRect(); // return {x: - circle.width() / 2, y: - circle.height() / 2, width:circle.width(), height:circle.height()}\n *\n */\n getSelfRect() {\n const size = this.size();\n return {\n x: this._centroid ? -size.width / 2 : 0,\n y: this._centroid ? -size.height / 2 : 0,\n width: size.width,\n height: size.height,\n };\n }\n getClientRect(config = {}) {\n const skipTransform = config.skipTransform;\n const relativeTo = config.relativeTo;\n const fillRect = this.getSelfRect();\n const applyStroke = !config.skipStroke && this.hasStroke();\n const strokeWidth = (applyStroke && this.strokeWidth()) || 0;\n const fillAndStrokeWidth = fillRect.width + strokeWidth;\n const fillAndStrokeHeight = fillRect.height + strokeWidth;\n const applyShadow = !config.skipShadow && this.hasShadow();\n const shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;\n const shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;\n const preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);\n const preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);\n const blurRadius = (applyShadow && this.shadowBlur()) || 0;\n const width = preWidth + blurRadius * 2;\n const height = preHeight + blurRadius * 2;\n const rect = {\n width: width,\n height: height,\n x: -(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetX, 0) +\n fillRect.x,\n y: -(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetY, 0) +\n fillRect.y,\n };\n if (!skipTransform) {\n return this._transformedRect(rect, relativeTo);\n }\n return rect;\n }\n drawScene(can, top, bufferCanvas) {\n // basically there are 3 drawing modes\n // 1 - simple drawing when nothing is cached.\n // 2 - when we are caching current\n // 3 - when node is cached and we need to draw it into layer\n const layer = this.getLayer();\n const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();\n let stage;\n const cachingSelf = top === this;\n if (!this.isVisible() && !cachingSelf) {\n return this;\n }\n // if node is cached we just need to draw from cache\n if (cachedCanvas) {\n context.save();\n const m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedSceneCanvas(context);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n // if buffer canvas is needed\n if (this._useBufferCanvas()) {\n stage = this.getStage();\n const bc = bufferCanvas || stage._syncBufferSize(stage.bufferCanvas);\n const bufferContext = bc.getContext();\n if (!bufferCanvas) {\n bufferContext.clear();\n }\n else if (!bc.width) {\n // cache() and toCanvas() hand over an empty buffer: size it to the\n // destination on first use and shift it to the buffer origin\n bc.setSize(canvas._logicalWidth, canvas._logicalHeight);\n bufferContext.translate(-bc.x, -bc.y);\n }\n else {\n // the buffer is translated, so reset the transform before clearing\n bufferContext.save();\n bufferContext.setTransform(1, 0, 0, 1, 0, 0);\n bufferContext.clearRect(0, 0, bc.width, bc.height);\n bufferContext.restore();\n }\n bufferContext.save();\n // the buffer canvas is a separate context that does not inherit the\n // destination `imageSmoothingEnabled` flag, so propagate it to keep\n // pattern/image smoothing consistent with the target context.\n bufferContext.imageSmoothingEnabled = context.imageSmoothingEnabled;\n bufferContext._applyLineJoin(this);\n bufferContext._applyMiterLimit(this);\n // layer might be undefined if we are using cache before adding to layer\n const o = this.getAbsoluteTransform(top).getMatrix();\n bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n drawFunc.call(this, bufferContext, this);\n bufferContext.restore();\n const ratio = bc.pixelRatio;\n if (hasShadow) {\n context._applyShadow(this);\n }\n // if we are caching self, we don't need to apply opacity and global composite operation\n // because it will be applied in the cache\n if (!cachingSelf) {\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n context.drawImage(bc._canvas, bc.x, bc.y, bc.width / ratio, bc.height / ratio);\n }\n else {\n context._applyLineJoin(this);\n context._applyMiterLimit(this);\n if (!cachingSelf) {\n const o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n if (hasShadow) {\n context._applyShadow(this);\n }\n drawFunc.call(this, context, this);\n }\n context.restore();\n return this;\n }\n drawHit(can, top) {\n if (!this.shouldDrawHit(top)) {\n return this;\n }\n const layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedHitCanvas = this._getCachedHitCanvas(top);\n if (!this.colorKey) {\n 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()');\n }\n if (cachedHitCanvas) {\n context.save();\n const m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedHitCanvas(context, cachedHitCanvas);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n context._applyLineJoin(this);\n context._applyMiterLimit(this);\n const selfCache = this === top;\n if (!selfCache) {\n const o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n }\n drawFunc.call(this, context, this);\n context.restore();\n return this;\n }\n /**\n * draw hit graph using the cached scene canvas\n * @method\n * @name Konva.Shape#drawHitFromCache\n * @param {Integer} alphaThreshold alpha channel threshold that determines whether or not\n * a pixel should be drawn onto the hit graph. Must be a value between 0 and 255.\n * The default is 0\n * @returns {Konva.Shape}\n * @example\n * shape.cache();\n * shape.drawHitFromCache();\n */\n drawHitFromCache(alphaThreshold = 0) {\n const sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = this._getCachedHitCanvas(), hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight();\n hitContext.clear();\n // the hit context is scaled by its pixel ratio, so it draws logical units\n hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth / hitCanvas.pixelRatio, hitHeight / hitCanvas.pixelRatio);\n try {\n const hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);\n const hitData = hitImageData.data;\n const len = hitData.length;\n const rgbColorKey = Util._hexToRgb(this.colorKey);\n // replace non transparent pixels with color key\n for (let i = 0; i < len; i += 4) {\n const alpha = hitData[i + 3];\n if (alpha > alphaThreshold) {\n hitData[i] = rgbColorKey.r;\n hitData[i + 1] = rgbColorKey.g;\n hitData[i + 2] = rgbColorKey.b;\n hitData[i + 3] = 255;\n }\n else {\n hitData[i + 3] = 0;\n }\n }\n hitContext.putImageData(hitImageData, 0, 0);\n }\n catch (e) {\n Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);\n }\n return this;\n }\n hasPointerCapture(pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n }\n setPointerCapture(pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n }\n releaseCapture(pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n }\n}\nShape.prototype._fillFunc = _fillFunc;\nShape.prototype._strokeFunc = _strokeFunc;\n// the hit graph is filled and stroked the same way as the scene\nShape.prototype._fillFuncHit = _fillFunc;\nShape.prototype._strokeFuncHit = _strokeFunc;\nShape.prototype._centroid = false;\nShape.prototype.nodeType = 'Shape';\n_registerNode(Shape);\nShape.prototype.on('shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);\nShape.prototype.on('shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);\nShape.prototype.on('fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva', _clearHasFillCache);\nShape.prototype.on('strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva', _clearHasStrokeCache);\nShape.prototype.on('fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);\nShape.prototype.on('fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);\nShape.prototype.on('fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);\n// add getters and setters\nFactory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());\n/**\n * get/set stroke color\n * @name Konva.Shape#stroke\n * @method\n * @param {String} color\n * @returns {String}\n * @example\n * // get stroke color\n * var stroke = shape.stroke();\n *\n * // set stroke color with color string\n * shape.stroke('green');\n *\n * // set stroke color with hex\n * shape.stroke('#00ff00');\n *\n * // set stroke color with rgb\n * shape.stroke('rgb(0,255,0)');\n *\n * // set stroke color with rgba and make it 50% opaque\n * shape.stroke('rgba(0,255,0,0.5');\n */\nFactory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());\n/**\n * get/set stroke width\n * @name Konva.Shape#strokeWidth\n * @method\n * @param {Number} strokeWidth\n * @returns {Number}\n * @example\n * // get stroke width\n * var strokeWidth = shape.strokeWidth();\n *\n * // set stroke width\n * shape.strokeWidth(10);\n */\nFactory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);\n/**\n * get/set fillAfterStrokeEnabled property. By default Konva is drawing filling first, then stroke on top of the fill.\n * In rare situations you may want a different behavior. When you have a stroke first then fill on top of it.\n * Especially useful for Text objects.\n * Default is false.\n * @name Konva.Shape#fillAfterStrokeEnabled\n * @method\n * @param {Boolean} fillAfterStrokeEnabled\n * @returns {Boolean}\n * @example\n * // get stroke width\n * var fillAfterStrokeEnabled = shape.fillAfterStrokeEnabled();\n *\n * // set stroke width\n * shape.fillAfterStrokeEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', getNumberOrAutoValidator());\n/**\n * get/set stroke width for hit detection. Default value is \"auto\", it means it will be equals to strokeWidth\n * @name Konva.Shape#hitStrokeWidth\n * @method\n * @param {Number} hitStrokeWidth\n * @returns {Number}\n * @example\n * // get stroke width\n * var hitStrokeWidth = shape.hitStrokeWidth();\n *\n * // set hit stroke width\n * shape.hitStrokeWidth(20);\n * // set hit stroke width always equals to scene stroke width\n * shape.hitStrokeWidth('auto');\n */\nFactory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());\n/**\n * **deprecated, use hitStrokeWidth instead!** get/set strokeHitEnabled property. Useful for performance optimization.\n * You may set `shape.strokeHitEnabled(false)`. In this case stroke will be no draw on hit canvas, so hit area\n * of shape will be decreased (by lineWidth / 2). Remember that non closed line with `strokeHitEnabled = false`\n * will be not drawn on hit canvas, that is mean line will no trigger pointer events (like mouseover)\n * Default value is true.\n * @name Konva.Shape#strokeHitEnabled\n * @method\n * @param {Boolean} strokeHitEnabled\n * @returns {Boolean}\n * @example\n * // get strokeHitEnabled\n * var strokeHitEnabled = shape.strokeHitEnabled();\n *\n * // set strokeHitEnabled\n * shape.strokeHitEnabled();\n */\nFactory.addGetterSetter(Shape, 'perfectDrawEnabled', true, getBooleanValidator());\n/**\n * get/set perfectDrawEnabled. If a shape has fill, stroke and opacity you may set `perfectDrawEnabled` to false to improve performance.\n * See http://konvajs.org/docs/performance/Disable_Perfect_Draw.html for more information.\n * Default value is true\n * @name Konva.Shape#perfectDrawEnabled\n * @method\n * @param {Boolean} perfectDrawEnabled\n * @returns {Boolean}\n * @example\n * // get perfectDrawEnabled\n * var perfectDrawEnabled = shape.perfectDrawEnabled();\n *\n * // set perfectDrawEnabled\n * shape.perfectDrawEnabled();\n */\nFactory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, getBooleanValidator());\n/**\n * get/set shadowForStrokeEnabled. Useful for performance optimization.\n * You may set `shape.shadowForStrokeEnabled(false)`. In this case stroke will no effect shadow.\n * Remember if you set `shadowForStrokeEnabled = false` for non closed line - that line will have no shadow!.\n * Default value is true\n * @name Konva.Shape#shadowForStrokeEnabled\n * @method\n * @param {Boolean} shadowForStrokeEnabled\n * @returns {Boolean}\n * @example\n * // get shadowForStrokeEnabled\n * var shadowForStrokeEnabled = shape.shadowForStrokeEnabled();\n *\n * // set shadowForStrokeEnabled\n * shape.shadowForStrokeEnabled();\n */\nFactory.addGetterSetter(Shape, 'lineJoin');\n/**\n * get/set line join. Can be miter, round, or bevel. The\n * default is miter\n * @name Konva.Shape#lineJoin\n * @method\n * @param {String} lineJoin\n * @returns {String}\n * @example\n * // get line join\n * var lineJoin = shape.lineJoin();\n *\n * // set line join\n * shape.lineJoin('round');\n */\nFactory.addGetterSetter(Shape, 'lineCap');\n/**\n * get/set line cap. Can be butt, round, or square\n * @name Konva.Shape#lineCap\n * @method\n * @param {String} lineCap\n * @returns {String}\n * @example\n * // get line cap\n * var lineCap = shape.lineCap();\n *\n * // set line cap\n * shape.lineCap('round');\n */\nFactory.addGetterSetter(Shape, 'miterLimit');\n/**\n * get/set miterLimit.\n * @name Konva.Shape#miterLimit\n * @method\n * @param {Number} miterLimit\n * @returns {Number}\n * @example\n * // get miter limit\n * var miterLimit = shape.miterLimit();\n *\n * // set miter limit\n * shape.miterLimit(10);\n */\nFactory.addGetterSetter(Shape, 'sceneFunc');\n/**\n * get/set scene draw function. That function is used to draw the shape on a canvas.\n * Also that function will be used to draw hit area of the shape, in case if hitFunc is not defined.\n * @name Konva.Shape#sceneFunc\n * @method\n * @param {Function} drawFunc drawing function\n * @returns {Function}\n * @example\n * // get scene draw function\n * var sceneFunc = shape.sceneFunc();\n *\n * // set scene draw function\n * shape.sceneFunc(function(context, shape) {\n * context.beginPath();\n * context.rect(0, 0, shape.width(), shape.height());\n * context.closePath();\n * // important Konva method that fill and stroke shape from its properties\n * // like stroke and fill\n * context.fillStrokeShape(shape);\n * });\n */\nFactory.addGetterSetter(Shape, 'hitFunc');\n/**\n * get/set hit draw function. That function is used to draw custom hit area of a shape.\n * @name Konva.Shape#hitFunc\n * @method\n * @param {Function} drawFunc drawing function\n * @returns {Function}\n * @example\n * // get hit draw function\n * var hitFunc = shape.hitFunc();\n *\n * // set hit draw function\n * shape.hitFunc(function(context) {\n * context.beginPath();\n * context.rect(0, 0, shape.width(), shape.height());\n * context.closePath();\n * // important Konva method that fill and stroke shape from its properties\n * context.fillStrokeShape(shape);\n * });\n */\nFactory.addGetterSetter(Shape, 'dash');\n/**\n * get/set dash array for stroke.\n * @name Konva.Shape#dash\n * @method\n * @param {Array} dash\n * @returns {Array}\n * @example\n * // apply dashed stroke that is 10px long and 5 pixels apart\n * line.dash([10, 5]);\n * // apply dashed stroke that is made up of alternating dashed\n * // lines that are 10px long and 20px apart, and dots that have\n * // a radius of 5px and are 20px apart\n * line.dash([10, 20, 0.001, 20]);\n */\nFactory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());\n/**\n * get/set dash offset for stroke.\n * @name Konva.Shape#dash\n * @method\n * @param {Number} dash offset\n * @returns {Number}\n * @example\n * // apply dashed stroke that is 10px long and 5 pixels apart with an offset of 5px\n * line.dash([10, 5]);\n * line.dashOffset(5);\n */\nFactory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());\n/**\n * get/set shadow color\n * @name Konva.Shape#shadowColor\n * @method\n * @param {String} color\n * @returns {String}\n * @example\n * // get shadow color\n * var shadow = shape.shadowColor();\n *\n * // set shadow color with color string\n * shape.shadowColor('green');\n *\n * // set shadow color with hex\n * shape.shadowColor('#00ff00');\n *\n * // set shadow color with rgb\n * shape.shadowColor('rgb(0,255,0)');\n *\n * // set shadow color with rgba and make it 50% opaque\n * shape.shadowColor('rgba(0,255,0,0.5');\n */\nFactory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());\n/**\n * get/set shadow blur\n * @name Konva.Shape#shadowBlur\n * @method\n * @param {Number} blur\n * @returns {Number}\n * @example\n * // get shadow blur\n * var shadowBlur = shape.shadowBlur();\n *\n * // set shadow blur\n * shape.shadowBlur(10);\n */\nFactory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());\n/**\n * get/set shadow opacity. must be a value between 0 and 1\n * @name Konva.Shape#shadowOpacity\n * @method\n * @param {Number} opacity\n * @returns {Number}\n * @example\n * // get shadow opacity\n * var shadowOpacity = shape.shadowOpacity();\n *\n * // set shadow opacity\n * shape.shadowOpacity(0.5);\n */\nFactory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);\n/**\n * get/set shadow offset\n * @name Konva.Shape#shadowOffset\n * @method\n * @param {Object} offset\n * @param {Number} offset.x\n * @param {Number} offset.y\n * @returns {Object}\n * @example\n * // get shadow offset\n * var shadowOffset = shape.shadowOffset();\n *\n * // set shadow offset\n * shape.shadowOffset({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());\n/**\n * get/set shadow offset x\n * @name Konva.Shape#shadowOffsetX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get shadow offset x\n * var shadowOffsetX = shape.shadowOffsetX();\n *\n * // set shadow offset x\n * shape.shadowOffsetX(5);\n */\nFactory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());\n/**\n * get/set shadow offset y\n * @name Konva.Shape#shadowOffsetY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get shadow offset y\n * var shadowOffsetY = shape.shadowOffsetY();\n *\n * // set shadow offset y\n * shape.shadowOffsetY(5);\n */\nFactory.addGetterSetter(Shape, 'fillPatternImage');\n/**\n * get/set fill pattern image\n * @name Konva.Shape#fillPatternImage\n * @method\n * @param {Image} image object\n * @returns {Image}\n * @example\n * // get fill pattern image\n * var fillPatternImage = shape.fillPatternImage();\n *\n * // set fill pattern image\n * var imageObj = new Image();\n * imageObj.onload = function() {\n * shape.fillPatternImage(imageObj);\n * };\n * imageObj.src = 'path/to/image/jpg';\n */\nFactory.addGetterSetter(Shape, 'fill', undefined, getStringOrGradientValidator());\n/**\n * get/set fill color\n * @name Konva.Shape#fill\n * @method\n * @param {String} color\n * @returns {String}\n * @example\n * // get fill color\n * var fill = shape.fill();\n *\n * // set fill color with color string\n * shape.fill('green');\n *\n * // set fill color with hex\n * shape.fill('#00ff00');\n *\n * // set fill color with rgb\n * shape.fill('rgb(0,255,0)');\n *\n * // set fill color with rgba and make it 50% opaque\n * shape.fill('rgba(0,255,0,0.5');\n *\n * // shape without fill\n * shape.fill(null);\n */\nFactory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());\n/**\n * get/set fill pattern x\n * @name Konva.Shape#fillPatternX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill pattern x\n * var fillPatternX = shape.fillPatternX();\n * // set fill pattern x\n * shape.fillPatternX(20);\n */\nFactory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());\n/**\n * get/set fill pattern y\n * @name Konva.Shape#fillPatternY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill pattern y\n * var fillPatternY = shape.fillPatternY();\n * // set fill pattern y\n * shape.fillPatternY(20);\n */\nFactory.addGetterSetter(Shape, 'fillLinearGradientColorStops');\n/**\n * get/set fill linear gradient color stops\n * @name Konva.Shape#fillLinearGradientColorStops\n * @method\n * @param {Array} colorStops\n * @returns {Array} colorStops\n * @example\n * // get fill linear gradient color stops\n * var colorStops = shape.fillLinearGradientColorStops();\n *\n * // create a linear gradient that starts with red, changes to blue\n * // halfway through, and then changes to green\n * shape.fillLinearGradientColorStops(0, 'red', 0.5, 'blue', 1, 'green');\n */\nFactory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');\n/**\n * get/set stroke linear gradient color stops\n * @name Konva.Shape#strokeLinearGradientColorStops\n * @method\n * @param {Array} colorStops\n * @returns {Array} colorStops\n * @example\n * // get stroke linear gradient color stops\n * var colorStops = shape.strokeLinearGradientColorStops();\n *\n * // create a linear gradient that starts with red, changes to blue\n * // halfway through, and then changes to green\n * shape.strokeLinearGradientColorStops([0, 'red', 0.5, 'blue', 1, 'green']);\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);\n/**\n * get/set fill radial gradient start radius\n * @name Konva.Shape#fillRadialGradientStartRadius\n * @method\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get radial gradient start radius\n * var startRadius = shape.fillRadialGradientStartRadius();\n *\n * // set radial gradient start radius\n * shape.fillRadialGradientStartRadius(0);\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);\n/**\n * get/set fill radial gradient end radius\n * @name Konva.Shape#fillRadialGradientEndRadius\n * @method\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get radial gradient end radius\n * var endRadius = shape.fillRadialGradientEndRadius();\n *\n * // set radial gradient end radius\n * shape.fillRadialGradientEndRadius(100);\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientColorStops');\n/**\n * get/set fill radial gradient color stops\n * @name Konva.Shape#fillRadialGradientColorStops\n * @method\n * @param {Number} colorStops\n * @returns {Array}\n * @example\n * // get fill radial gradient color stops\n * var colorStops = shape.fillRadialGradientColorStops();\n *\n * // create a radial gradient that starts with red, changes to blue\n * // halfway through, and then changes to green\n * shape.fillRadialGradientColorStops(0, 'red', 0.5, 'blue', 1, 'green');\n */\nFactory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');\n/**\n * get/set fill pattern repeat. Can be 'repeat', 'repeat-x', 'repeat-y', or 'no-repeat'. The default is 'repeat'\n * @name Konva.Shape#fillPatternRepeat\n * @method\n * @param {String} repeat\n * @returns {String}\n * @example\n * // get fill pattern repeat\n * var repeat = shape.fillPatternRepeat();\n *\n * // repeat pattern in x direction only\n * shape.fillPatternRepeat('repeat-x');\n *\n * // do not repeat the pattern\n * shape.fillPatternRepeat('no-repeat');\n */\nFactory.addGetterSetter(Shape, 'fillEnabled', true);\n/**\n * get/set fill enabled flag\n * @name Konva.Shape#fillEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get fill enabled flag\n * var fillEnabled = shape.fillEnabled();\n *\n * // disable fill\n * shape.fillEnabled(false);\n *\n * // enable fill\n * shape.fillEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'strokeEnabled', true);\n/**\n * get/set stroke enabled flag\n * @name Konva.Shape#strokeEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get stroke enabled flag\n * var strokeEnabled = shape.strokeEnabled();\n *\n * // disable stroke\n * shape.strokeEnabled(false);\n *\n * // enable stroke\n * shape.strokeEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'shadowEnabled', true);\n/**\n * get/set shadow enabled flag\n * @name Konva.Shape#shadowEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get shadow enabled flag\n * var shadowEnabled = shape.shadowEnabled();\n *\n * // disable shadow\n * shape.shadowEnabled(false);\n *\n * // enable shadow\n * shape.shadowEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'dashEnabled', true);\n/**\n * get/set dash enabled flag\n * @name Konva.Shape#dashEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get dash enabled flag\n * var dashEnabled = shape.dashEnabled();\n *\n * // disable dash\n * shape.dashEnabled(false);\n *\n * // enable dash\n * shape.dashEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'strokeScaleEnabled', true);\n/**\n * get/set strokeScale enabled flag\n * @name Konva.Shape#strokeScaleEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get stroke scale enabled flag\n * var strokeScaleEnabled = shape.strokeScaleEnabled();\n *\n * // disable stroke scale\n * shape.strokeScaleEnabled(false);\n *\n * // enable stroke scale\n * shape.strokeScaleEnabled(true);\n */\nFactory.addGetterSetter(Shape, 'fillPriority', 'color');\n/**\n * get/set fill priority. can be color, pattern, linear-gradient, or radial-gradient. The default is color.\n * This is handy if you want to toggle between different fill types.\n * @name Konva.Shape#fillPriority\n * @method\n * @param {String} priority\n * @returns {String}\n * @example\n * // get fill priority\n * var fillPriority = shape.fillPriority();\n *\n * // set fill priority\n * shape.fillPriority('linear-gradient');\n */\nFactory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);\n/**\n * get/set fill pattern offset\n * @name Konva.Shape#fillPatternOffset\n * @method\n * @param {Object} offset\n * @param {Number} offset.x\n * @param {Number} offset.y\n * @returns {Object}\n * @example\n * // get fill pattern offset\n * var patternOffset = shape.fillPatternOffset();\n *\n * // set fill pattern offset\n * shape.fillPatternOffset({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());\n/**\n * get/set fill pattern offset x\n * @name Konva.Shape#fillPatternOffsetX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill pattern offset x\n * var patternOffsetX = shape.fillPatternOffsetX();\n *\n * // set fill pattern offset x\n * shape.fillPatternOffsetX(20);\n */\nFactory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());\n/**\n * get/set fill pattern offset y\n * @name Konva.Shape#fillPatternOffsetY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill pattern offset y\n * var patternOffsetY = shape.fillPatternOffsetY();\n *\n * // set fill pattern offset y\n * shape.fillPatternOffsetY(10);\n */\nFactory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);\n/**\n * get/set fill pattern scale\n * @name Konva.Shape#fillPatternScale\n * @method\n * @param {Object} scale\n * @param {Number} scale.x\n * @param {Number} scale.y\n * @returns {Object}\n * @example\n * // get fill pattern scale\n * var patternScale = shape.fillPatternScale();\n *\n * // set fill pattern scale\n * shape.fillPatternScale({\n * x: 2,\n * y: 2\n * });\n */\nFactory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());\n/**\n * get/set fill pattern scale x\n * @name Konva.Shape#fillPatternScaleX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill pattern scale x\n * var patternScaleX = shape.fillPatternScaleX();\n *\n * // set fill pattern scale x\n * shape.fillPatternScaleX(2);\n */\nFactory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());\n/**\n * get/set fill pattern scale y\n * @name Konva.Shape#fillPatternScaleY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill pattern scale y\n * var patternScaleY = shape.fillPatternScaleY();\n *\n * // set fill pattern scale y\n * shape.fillPatternScaleY(2);\n */\nFactory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set fill linear gradient start point\n * @name Konva.Shape#fillLinearGradientStartPoint\n * @method\n * @param {Object} startPoint\n * @param {Number} startPoint.x\n * @param {Number} startPoint.y\n * @returns {Object}\n * @example\n * // get fill linear gradient start point\n * var startPoint = shape.fillLinearGradientStartPoint();\n *\n * // set fill linear gradient start point\n * shape.fillLinearGradientStartPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set stroke linear gradient start point\n * @name Konva.Shape#strokeLinearGradientStartPoint\n * @method\n * @param {Object} startPoint\n * @param {Number} startPoint.x\n * @param {Number} startPoint.y\n * @returns {Object}\n * @example\n * // get stroke linear gradient start point\n * var startPoint = shape.strokeLinearGradientStartPoint();\n *\n * // set stroke linear gradient start point\n * shape.strokeLinearGradientStartPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);\n/**\n * get/set fill linear gradient start point x\n * @name Konva.Shape#fillLinearGradientStartPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill linear gradient start point x\n * var startPointX = shape.fillLinearGradientStartPointX();\n *\n * // set fill linear gradient start point x\n * shape.fillLinearGradientStartPointX(20);\n */\nFactory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);\n/**\n * get/set stroke linear gradient start point x\n * @name Konva.Shape#strokeLinearGradientStartPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get stroke linear gradient start point x\n * var startPointX = shape.strokeLinearGradientStartPointX();\n *\n * // set stroke linear gradient start point x\n * shape.strokeLinearGradientStartPointX(20);\n */\nFactory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);\n/**\n * get/set fill linear gradient start point y\n * @name Konva.Shape#fillLinearGradientStartPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill linear gradient start point y\n * var startPointY = shape.fillLinearGradientStartPointY();\n *\n * // set fill linear gradient start point y\n * shape.fillLinearGradientStartPointY(20);\n */\nFactory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);\n/**\n * get/set stroke linear gradient start point y\n * @name Konva.Shape#strokeLinearGradientStartPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get stroke linear gradient start point y\n * var startPointY = shape.strokeLinearGradientStartPointY();\n *\n * // set stroke linear gradient start point y\n * shape.strokeLinearGradientStartPointY(20);\n */\nFactory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set fill linear gradient end point\n * @name Konva.Shape#fillLinearGradientEndPoint\n * @method\n * @param {Object} endPoint\n * @param {Number} endPoint.x\n * @param {Number} endPoint.y\n * @returns {Object}\n * @example\n * // get fill linear gradient end point\n * var endPoint = shape.fillLinearGradientEndPoint();\n *\n * // set fill linear gradient end point\n * shape.fillLinearGradientEndPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set stroke linear gradient end point\n * @name Konva.Shape#strokeLinearGradientEndPoint\n * @method\n * @param {Object} endPoint\n * @param {Number} endPoint.x\n * @param {Number} endPoint.y\n * @returns {Object}\n * @example\n * // get stroke linear gradient end point\n * var endPoint = shape.strokeLinearGradientEndPoint();\n *\n * // set stroke linear gradient end point\n * shape.strokeLinearGradientEndPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);\n/**\n * get/set fill linear gradient end point x\n * @name Konva.Shape#fillLinearGradientEndPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill linear gradient end point x\n * var endPointX = shape.fillLinearGradientEndPointX();\n *\n * // set fill linear gradient end point x\n * shape.fillLinearGradientEndPointX(20);\n */\nFactory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);\n/**\n * get/set fill linear gradient end point x\n * @name Konva.Shape#strokeLinearGradientEndPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get stroke linear gradient end point x\n * var endPointX = shape.strokeLinearGradientEndPointX();\n *\n * // set stroke linear gradient end point x\n * shape.strokeLinearGradientEndPointX(20);\n */\nFactory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);\n/**\n * get/set fill linear gradient end point y\n * @name Konva.Shape#fillLinearGradientEndPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill linear gradient end point y\n * var endPointY = shape.fillLinearGradientEndPointY();\n *\n * // set fill linear gradient end point y\n * shape.fillLinearGradientEndPointY(20);\n */\nFactory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);\n/**\n * get/set stroke linear gradient end point y\n * @name Konva.Shape#strokeLinearGradientEndPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get stroke linear gradient end point y\n * var endPointY = shape.strokeLinearGradientEndPointY();\n *\n * // set stroke linear gradient end point y\n * shape.strokeLinearGradientEndPointY(20);\n */\nFactory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set fill radial gradient start point\n * @name Konva.Shape#fillRadialGradientStartPoint\n * @method\n * @param {Object} startPoint\n * @param {Number} startPoint.x\n * @param {Number} startPoint.y\n * @returns {Object}\n * @example\n * // get fill radial gradient start point\n * var startPoint = shape.fillRadialGradientStartPoint();\n *\n * // set fill radial gradient start point\n * shape.fillRadialGradientStartPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);\n/**\n * get/set fill radial gradient start point x\n * @name Konva.Shape#fillRadialGradientStartPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill radial gradient start point x\n * var startPointX = shape.fillRadialGradientStartPointX();\n *\n * // set fill radial gradient start point x\n * shape.fillRadialGradientStartPointX(20);\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);\n/**\n * get/set fill radial gradient start point y\n * @name Konva.Shape#fillRadialGradientStartPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill radial gradient start point y\n * var startPointY = shape.fillRadialGradientStartPointY();\n *\n * // set fill radial gradient start point y\n * shape.fillRadialGradientStartPointY(20);\n */\nFactory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [\n 'x',\n 'y',\n]);\n/**\n * get/set fill radial gradient end point\n * @name Konva.Shape#fillRadialGradientEndPoint\n * @method\n * @param {Object} endPoint\n * @param {Number} endPoint.x\n * @param {Number} endPoint.y\n * @returns {Object}\n * @example\n * // get fill radial gradient end point\n * var endPoint = shape.fillRadialGradientEndPoint();\n *\n * // set fill radial gradient end point\n * shape.fillRadialGradientEndPoint({\n * x: 20,\n * y: 10\n * });\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);\n/**\n * get/set fill radial gradient end point x\n * @name Konva.Shape#fillRadialGradientEndPointX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get fill radial gradient end point x\n * var endPointX = shape.fillRadialGradientEndPointX();\n *\n * // set fill radial gradient end point x\n * shape.fillRadialGradientEndPointX(20);\n */\nFactory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);\n/**\n * get/set fill radial gradient end point y\n * @name Konva.Shape#fillRadialGradientEndPointY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get fill radial gradient end point y\n * var endPointY = shape.fillRadialGradientEndPointY();\n *\n * // set fill radial gradient end point y\n * shape.fillRadialGradientEndPointY(20);\n */\nFactory.addGetterSetter(Shape, 'fillPatternRotation', 0);\n/**\n * get/set fill pattern rotation in degrees\n * @name Konva.Shape#fillPatternRotation\n * @method\n * @param {Number} rotation\n * @returns {Konva.Shape}\n * @example\n * // get fill pattern rotation\n * var patternRotation = shape.fillPatternRotation();\n *\n * // set fill pattern rotation\n * shape.fillPatternRotation(20);\n */\nFactory.addGetterSetter(Shape, 'fillRule', undefined, getStringValidator());\n/**\n * get/set fill rule\n * @name Konva.Shape#fillRule\n * @method\n * @param {CanvasFillRule} rotation\n * @returns {Konva.Shape}\n * @example\n * // get fill rule\n * var fillRule = shape.fillRule();\n *\n * // set fill rule\n * shape.fillRule('evenodd');\n */\nFactory.backCompat(Shape, {\n dashArray: 'dash',\n getDashArray: 'getDash',\n setDashArray: 'setDash',\n drawFunc: 'sceneFunc',\n getDrawFunc: 'getSceneFunc',\n setDrawFunc: 'setSceneFunc',\n drawHitFunc: 'hitFunc',\n getDrawHitFunc: 'getHitFunc',\n setDrawHitFunc: 'setHitFunc',\n});\n","import { Util } from \"./Util.js\";\nimport { Container } from \"./Container.js\";\nimport { Node } from \"./Node.js\";\nimport { Factory } from \"./Factory.js\";\nimport { SceneCanvas, HitCanvas } from \"./Canvas.js\";\nimport { shapes } from \"./Shape.js\";\nimport { _registerNode, Konva } from \"./Global.js\";\nimport { DD } from \"./DragAndDrop.js\";\n// constants\nconst BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', \n// getIntersection() reads the hit canvas around an edge pixel in blocks\n// of this radius, doubling it as long as the search goes on\nHIT_SEARCH_RADIUS = 10, HIT_SEARCH_MAX_DISTANCE = 256;\n// the shape drawn at a pixel of the hit graph: an opaque pixel, or an edge\n// pixel that the shape covers by at least half, so that its colour read back\n// premultiplied still rounds to the key of the shape (see getHitColorKey)\nfunction getHitShape(data, i) {\n return data[i + 3] >= 128\n ? shapes[Util.getHitColorKey(data[i], data[i + 1], data[i + 2])]\n : undefined;\n}\n/**\n * Layer constructor. Layers are tied to their own canvas element and are used\n * to contain groups or shapes.\n * @constructor\n * @memberof Konva\n * @augments Konva.Container\n * @param {Object} config\n * @param {Boolean} [config.clearBeforeDraw] set this property to false if you don't want\n * to clear the canvas before each layer draw. The default value is true.\n * @@nodeParams\n * @@containerParams\n * @example\n * var layer = new Konva.Layer();\n * stage.add(layer);\n * // now you can add shapes, groups into the layer\n */\nexport class Layer extends Container {\n constructor(config) {\n super(config);\n this.canvas = new SceneCanvas();\n this.hitCanvas = new HitCanvas({\n pixelRatio: 1,\n });\n this._waitingForDraw = false;\n this.on('visibleChange.konva', this._checkVisibility);\n this._checkVisibility();\n this.on('imageSmoothingEnabledChange.konva', this._setSmoothEnabled);\n this._setSmoothEnabled();\n }\n // for nodejs?\n createPNGStream() {\n const c = this.canvas._canvas;\n return c.createPNGStream();\n }\n /**\n * get layer canvas wrapper\n * @method\n * @name Konva.Layer#getCanvas\n */\n getCanvas() {\n return this.canvas;\n }\n /**\n * get native canvas element\n * @method\n * @name Konva.Layer#getNativeCanvasElement\n */\n getNativeCanvasElement() {\n return this.canvas._canvas;\n }\n /**\n * get layer hit canvas\n * @method\n * @name Konva.Layer#getHitCanvas\n */\n getHitCanvas() {\n return this.hitCanvas;\n }\n /**\n * get layer canvas context\n * @method\n * @name Konva.Layer#getContext\n */\n getContext() {\n return this.getCanvas().getContext();\n }\n /**\n * clear the scene and hit canvas of the layer. The nodes stay and are\n * drawn again by the next `draw()`\n * @method\n * @name Konva.Layer#clear\n * @param {Object} [bounds] clear only this rectangle: `{ x, y, width, height }`\n * @returns {Konva.Layer}\n * @example\n * layer.clear();\n * layer.clear({ x: 0, y: 0, width: 100, height: 100 });\n */\n clear(bounds) {\n this.getContext().clear(bounds);\n this.getHitCanvas().getContext().clear(bounds);\n return this;\n }\n // extend Node.prototype.setZIndex\n setZIndex(index) {\n super.setZIndex(index);\n const stage = this.getStage();\n if (stage && stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n if (index < stage.children.length - 1) {\n stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n }\n return this;\n }\n moveToTop() {\n Node.prototype.moveToTop.call(this);\n const stage = this.getStage();\n if (stage && stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n return true;\n }\n moveUp() {\n const moved = Node.prototype.moveUp.call(this);\n if (!moved) {\n return false;\n }\n const stage = this.getStage();\n if (!stage || !stage.content) {\n return false;\n }\n stage.content.removeChild(this.getNativeCanvasElement());\n if (this.index < stage.children.length - 1) {\n stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[this.index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n return true;\n }\n // extend Node.prototype.moveDown\n moveDown() {\n if (Node.prototype.moveDown.call(this)) {\n const stage = this.getStage();\n if (stage) {\n const children = stage.children;\n if (stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);\n }\n }\n return true;\n }\n return false;\n }\n // extend Node.prototype.moveToBottom\n moveToBottom() {\n if (Node.prototype.moveToBottom.call(this)) {\n const stage = this.getStage();\n if (stage) {\n const children = stage.children;\n if (stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);\n }\n }\n return true;\n }\n return false;\n }\n getLayer() {\n return this;\n }\n remove() {\n const _canvas = this.getNativeCanvasElement();\n Node.prototype.remove.call(this);\n if (_canvas && _canvas.parentNode && Util._isInDocument(_canvas)) {\n _canvas.parentNode.removeChild(_canvas);\n }\n return this;\n }\n getStage() {\n return this.parent;\n }\n // the canvases follow the stage size. The public size() of a layer, like\n // width() and height(), warns and does nothing\n _setSize({ width, height }) {\n this.canvas.setSize(width, height);\n this._syncHitCanvasSize();\n this._setSmoothEnabled();\n return this;\n }\n // the hit canvas is only allocated while the layer is listening;\n // for a non-listening layer it is kept released (0x0), so a purely\n // presentational layer does not pay for a stage-sized hit bitmap\n // https://github.com/konvajs/konva/issues/2009\n _syncHitCanvasSize() {\n const listening = this.isListening();\n this.hitCanvas.setSizeIfChanged((listening ? this.getWidth() : 0) || 0, (listening ? this.getHeight() : 0) || 0);\n }\n _validateAdd(child) {\n const type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util.throw('You may only add groups and shapes to a layer.');\n }\n }\n _toKonvaCanvas(config) {\n config = { ...config };\n config.width = config.width || this.getWidth();\n config.height = config.height || this.getHeight();\n config.x = config.x !== undefined ? config.x : this.x();\n config.y = config.y !== undefined ? config.y : this.y();\n return Node.prototype._toKonvaCanvas.call(this, config);\n }\n _checkVisibility() {\n const visible = this.visible();\n if (visible) {\n this.canvas._canvas.style.display = 'block';\n }\n else {\n this.canvas._canvas.style.display = 'none';\n }\n }\n _setSmoothEnabled() {\n this.getContext()._context.imageSmoothingEnabled =\n this.imageSmoothingEnabled();\n }\n /**\n * get/set width of layer. getter return width of stage. setter doing nothing.\n * if you want change width use `stage.width(value);`\n * @name Konva.Layer#width\n * @method\n * @returns {Number}\n * @example\n * var width = layer.width();\n */\n getWidth() {\n if (this.parent) {\n return this.parent.width();\n }\n }\n setWidth() {\n Util.warn('Can not change width of layer. Use \"stage.width(value)\" function instead.');\n }\n /**\n * get/set height of layer.getter return height of stage. setter doing nothing.\n * if you want change height use `stage.height(value);`\n * @name Konva.Layer#height\n * @method\n * @returns {Number}\n * @example\n * var height = layer.height();\n */\n getHeight() {\n if (this.parent) {\n return this.parent.height();\n }\n }\n setHeight() {\n Util.warn('Can not change height of layer. Use \"stage.height(value)\" function instead.');\n }\n /**\n * batch draw. this function will not do immediate draw\n * but it will schedule drawing to next tick (requestAnimFrame)\n * @method\n * @name Konva.Layer#batchDraw\n * @return {Konva.Layer} this\n */\n batchDraw() {\n var _a;\n if (!this._waitingForDraw) {\n this._waitingForDraw = true;\n // ask the window the stage is rendered in for the frame: a stage in a\n // popout window keeps drawing while the opener window is not visible\n Util.requestAnimFrame(() => {\n // reset before drawing, so a throwing draw does not freeze the layer\n // and a draw handler can request the next frame\n this._waitingForDraw = false;\n this.draw();\n }, (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._getOwnerWindow());\n }\n return this;\n }\n /**\n * get visible intersection shape. This is the preferred\n * method for determining if a point intersects a shape or not.\n * It reads the hit canvas, so it finds what pointer events would: nodes with\n * listening set to false or invisible nodes are not detected, a shape with opacity 0\n * is, and `hitStrokeWidth` counts. The position is relative to the top left corner of the\n * stage container, like `stage.getPointerPosition()`, without the stage transform\n * @method\n * @name Konva.Layer#getIntersection\n * @param {Object} pos\n * @param {Number} pos.x\n * @param {Number} pos.y\n * @returns {Konva.Node}\n * @example\n * var shape = layer.getIntersection({x: 50, y: 50});\n */\n getIntersection(pos) {\n if (!this.isListening() || !this.isVisible()) {\n return null;\n }\n const hit = this._getIntersection(pos);\n if (hit.shape) {\n return hit.shape;\n }\n if (!hit.antialiased) {\n return null;\n }\n // the pointer is on the outer part of an edge, or on an opaque pixel with\n // the colours of two shapes mixed. Walk outward ring by ring to the\n // nearest pixel that resolves to a shape. The smoothed edge of a cached\n // node that is scaled up can be many pixels wide, so keep going while the\n // alpha still rises (the ramp leads into the shape) or the ring holds\n // mixed pixels. A thin line has a flat alpha, so the search stops at once\n // instead of walking along it to an unrelated shape nearby\n const ratio = this.hitCanvas.pixelRatio, cx = Math.floor(pos.x * ratio), cy = Math.floor(pos.y * ratio);\n const read = (r) => this.hitCanvas.context.getImageData(cx - r, cy - r, r * 2 + 1, r * 2 + 1)\n .data;\n let r = HIT_SEARCH_RADIUS, size = r * 2 + 1, data = read(r), previousMax = data[(r * size + r) * 4 + 3];\n for (let d = 1; d <= HIT_SEARCH_MAX_DISTANCE; d++) {\n if (d > r) {\n r = Math.min(HIT_SEARCH_MAX_DISTANCE, r * 2);\n size = r * 2 + 1;\n data = read(r);\n }\n let max = 0;\n for (let y = -d; y <= d; y++) {\n // whole top and bottom rows, only the two side pixels of the others\n const step = Math.abs(y) === d ? 1 : d * 2;\n for (let x = -d; x <= d; x += step) {\n const i = ((y + r) * size + x + r) * 4;\n const shape = getHitShape(data, i);\n if (shape) {\n return shape;\n }\n max = Math.max(max, data[i + 3]);\n }\n }\n // 255 here is a mixed pixel, as an opaque one resolved above\n if (max <= previousMax && max !== 255) {\n return null;\n }\n previousMax = max;\n }\n return null;\n }\n _getIntersection(pos) {\n // a non-listening layer keeps its hit canvas released (0x0),\n // and a just-enabled layer may not have drawn its hit graph yet\n if (!this.hitCanvas.width || !this.hitCanvas.height) {\n return {};\n }\n const ratio = this.hitCanvas.pixelRatio;\n const p = this.hitCanvas.context.getImageData(Math.floor(pos.x * ratio), Math.floor(pos.y * ratio), 1, 1).data;\n const shape = getHitShape(p, 0);\n if (shape) {\n return { shape };\n }\n if (p[3] > 0) {\n // an edge pixel, or an opaque one with the colours of two shapes mixed\n return { antialiased: true };\n }\n return {};\n }\n drawScene(can, top, bufferCanvas) {\n const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());\n this._fire(BEFORE_DRAW, {\n node: this,\n });\n if (this.clearBeforeDraw()) {\n canvas.getContext().clear();\n }\n Container.prototype.drawScene.call(this, canvas, top, bufferCanvas);\n this._fire(DRAW, {\n node: this,\n });\n return this;\n }\n // the hit graph is skipped while a node of the layer (or the stage) is\n // dragged or a transformer on the layer, or of a node on it, is\n // transforming, as the layer is redrawn every frame; the draw that follows\n // restores it\n shouldDrawHit(top) {\n var _a;\n if (!super.shouldDrawHit(top)) {\n return false;\n }\n if (top || Konva.hitOnDragEnabled) {\n return true;\n }\n let underDrag = false;\n DD._dragElements.forEach((elem) => {\n if (elem.dragStatus === 'dragging' &&\n (elem.node.nodeType === 'Stage' || elem.node.getLayer() === this)) {\n underDrag = true;\n }\n });\n return !underDrag && !((_a = Konva['Transformer']) === null || _a === void 0 ? void 0 : _a._isLayerTransforming(this));\n }\n drawHit(can, top) {\n const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);\n if (!can && layer) {\n // allocate or release the hit canvas to match the current listening\n // state - this also picks up a listening change made after the last draw\n layer._syncHitCanvasSize();\n if (layer.clearBeforeDraw()) {\n layer.getHitCanvas().getContext().clear();\n }\n }\n Container.prototype.drawHit.call(this, canvas, top);\n return this;\n }\n /**\n * enable hit graph. **DEPRECATED!** Use `layer.listening(true)` instead.\n * @name Konva.Layer#enableHitGraph\n * @method\n * @returns {Layer}\n */\n enableHitGraph() {\n this.hitGraphEnabled(true);\n return this;\n }\n /**\n * disable hit graph. **DEPRECATED!** Use `layer.listening(false)` instead.\n * @name Konva.Layer#disableHitGraph\n * @method\n * @returns {Layer}\n */\n disableHitGraph() {\n this.hitGraphEnabled(false);\n return this;\n }\n setHitGraphEnabled(val) {\n Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');\n this.listening(val);\n }\n getHitGraphEnabled(val) {\n Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');\n return this.listening();\n }\n /**\n * Show or hide hit canvas over the stage. May be useful for debugging custom hitFunc\n * @name Konva.Layer#toggleHitCanvas\n * @method\n */\n toggleHitCanvas() {\n if (!this.parent || !this.parent['content']) {\n return;\n }\n const parent = this.parent;\n const added = !!this.hitCanvas._canvas.parentNode;\n if (added) {\n parent.content.removeChild(this.hitCanvas._canvas);\n }\n else {\n parent.content.appendChild(this.hitCanvas._canvas);\n }\n }\n destroy() {\n Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);\n return super.destroy();\n }\n}\nLayer.prototype.nodeType = 'Layer';\n_registerNode(Layer);\n/**\n * get/set imageSmoothingEnabled flag\n * For more info see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled\n * @name Konva.Layer#imageSmoothingEnabled\n * @method\n * @param {Boolean} imageSmoothingEnabled\n * @returns {Boolean}\n * @example\n * // get imageSmoothingEnabled flag\n * var imageSmoothingEnabled = layer.imageSmoothingEnabled();\n *\n * layer.imageSmoothingEnabled(false);\n *\n * layer.imageSmoothingEnabled(true);\n */\nFactory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);\n/**\n * get/set clearBeforeDraw flag which determines if the layer is cleared or not\n * before drawing\n * @name Konva.Layer#clearBeforeDraw\n * @method\n * @param {Boolean} clearBeforeDraw\n * @returns {Boolean}\n * @example\n * // get clearBeforeDraw flag\n * var clearBeforeDraw = layer.clearBeforeDraw();\n *\n * // disable clear before draw\n * layer.clearBeforeDraw(false);\n *\n * // enable clear before draw\n * layer.clearBeforeDraw(true);\n */\nFactory.addGetterSetter(Layer, 'clearBeforeDraw', true);\n// the getter and setter are the deprecated ones above\nFactory.addOverloadedGetterSetter(Layer, 'hitGraphEnabled');\n/**\n * get/set hitGraphEnabled flag. **DEPRECATED!** Use `layer.listening(false)` instead.\n * Disabling the hit graph will greatly increase\n * draw performance because the hit graph will not be redrawn each time the layer is\n * drawn. This, however, also disables mouse/touch event detection\n * @name Konva.Layer#hitGraphEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get hitGraphEnabled flag\n * var hitGraphEnabled = layer.hitGraphEnabled();\n *\n * // disable hit graph\n * layer.hitGraphEnabled(false);\n *\n * // enable hit graph\n * layer.hitGraphEnabled(true);\n */\n","import { Util } from \"./Util.js\";\nimport { Layer } from \"./Layer.js\";\nimport { _registerNode } from \"./Global.js\";\n/**\n * FastLayer constructor. **DEPRECATED!** Please use `Konva.Layer({ listening: false})` instead. Layers are tied to their own canvas element and are used\n * to contain shapes only. If you don't need node nesting, mouse and touch interactions,\n * or event pub/sub, you should use FastLayer instead of Layer to create your layers.\n * It renders about 2x faster than normal layers.\n *\n * @constructor\n * @memberof Konva\n * @augments Konva.Layer\n @@containerParams\n * @example\n * var layer = new Konva.FastLayer();\n */\nexport class FastLayer extends Layer {\n constructor(attrs) {\n super(attrs);\n this.listening(false);\n Util.warn('Konva.FastLayer is deprecated. Please use \"new Konva.Layer({ listening: false })\" instead.');\n }\n}\nFastLayer.prototype.nodeType = 'FastLayer';\n_registerNode(FastLayer);\n","import { Util } from \"./Util.js\";\nimport { Container } from \"./Container.js\";\nimport { _registerNode } from \"./Global.js\";\n/**\n * Group constructor. Groups are used to contain shapes or other groups.\n * @constructor\n * @memberof Konva\n * @augments Konva.Container\n * @param {Object} config\n * @@nodeParams\n * @@containerParams\n * @example\n * var group = new Konva.Group();\n */\nexport class Group extends Container {\n _validateAdd(child) {\n const type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util.throw('You may only add groups and shapes to groups.');\n }\n }\n}\nGroup.prototype.nodeType = 'Group';\n_registerNode(Group);\n","var _a;\nimport { glob } from \"./Global.js\";\nimport { Util } from \"./Util.js\";\nconst now = ((_a = glob.performance) === null || _a === void 0 ? void 0 : _a.now)\n ? () => glob.performance.now()\n : Date.now;\n/**\n * Animation constructor.\n * @constructor\n * @memberof Konva\n * @param {AnimationFn} func function executed on each animation frame. The function is passed a frame object, which contains\n * timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed\n * since the last animation frame. The time property is the time in milliseconds that elapsed from the moment the animation started\n * to the current animation frame. The lastTime property is a `time` value from the previous frame. The frameRate property is the current frame rate in frames / second.\n * Return false from function, if you don't need to redraw layer/layers on some frames.\n * @param {Konva.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.\n * Not specifying a node will result in no redraw.\n * @example\n * // move a node to the right at 50 pixels / second\n * var velocity = 50;\n *\n * var anim = new Konva.Animation(function(frame) {\n * var dist = velocity * (frame.timeDiff / 1000);\n * node.move({x: dist, y: 0});\n * }, layer);\n *\n * anim.start();\n */\nexport class Animation {\n constructor(func, layers) {\n this.id = Animation.animIdCounter++;\n this.frame = {\n time: 0,\n timeDiff: 0,\n lastTime: now(),\n frameRate: 0,\n };\n this.func = func;\n this.setLayers(layers);\n }\n /**\n * set layers to be redrawn on each animation frame\n * @method\n * @name Konva.Animation#setLayers\n * @param {Konva.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.\n * @return {Konva.Animation} this\n */\n setLayers(layers) {\n // a copy, so that addLayer() never pushes into the caller's array\n this.layers = layers ? [].concat(layers) : [];\n return this;\n }\n /**\n * get layers\n * @method\n * @name Konva.Animation#getLayers\n * @return {Array} Array of Konva.Layer\n */\n getLayers() {\n return this.layers;\n }\n /**\n * add layer. Returns true if the layer was added, and false if it was not\n * @method\n * @name Konva.Animation#addLayer\n * @param {Konva.Layer} layer to add\n * @return {Bool} true if layer is added to animation, otherwise false\n */\n addLayer(layer) {\n const layers = this.layers;\n const len = layers.length;\n // don't add the layer if it already exists\n for (let n = 0; n < len; n++) {\n if (layers[n]._id === layer._id) {\n return false;\n }\n }\n this.layers.push(layer);\n return true;\n }\n /**\n * determine if animation is running or not. returns true or false\n * @method\n * @name Konva.Animation#isRunning\n * @return {Bool} is animation running?\n */\n isRunning() {\n return Animation.animations.has(this);\n }\n /**\n * start animation\n * @method\n * @name Konva.Animation#start\n * @return {Konva.Animation} this\n */\n start() {\n this.stop();\n this.frame.timeDiff = 0;\n this.frame.lastTime = now();\n Animation._addAnimation(this);\n return this;\n }\n /**\n * stop animation\n * @method\n * @name Konva.Animation#stop\n * @return {Konva.Animation} this\n */\n stop() {\n Animation._removeAnimation(this);\n return this;\n }\n _updateFrameObject(time) {\n this.frame.timeDiff = time - this.frame.lastTime;\n this.frame.lastTime = time;\n this.frame.time += this.frame.timeDiff;\n this.frame.frameRate = 1000 / this.frame.timeDiff;\n }\n static _addAnimation(anim) {\n this.animations.add(anim);\n this._handleAnimation();\n }\n static _removeAnimation(anim) {\n this.animations.delete(anim);\n }\n static _runFrames() {\n // every layer is drawn once, however many animations touch it\n const layersToDraw = new Set();\n // an animation may stop or restart itself, or another one, inside its\n // function: each one runs at most once per frame, a stopped one not at all\n Array.from(this.animations).forEach((anim) => {\n if (!this.animations.has(anim)) {\n return;\n }\n anim._updateFrameObject(now());\n // the function returns false to skip the redraw\n if (anim.func && anim.func.call(anim, anim.frame) === false) {\n return;\n }\n anim.layers.forEach((layer) => layer && layersToDraw.add(layer));\n });\n layersToDraw.forEach((layer) => layer.batchDraw());\n }\n static _animationLoop() {\n const Anim = Animation;\n if (Anim.animations.size) {\n Anim._runFrames();\n Util.requestAnimFrame(Anim._animationLoop);\n }\n else {\n Anim.animRunning = false;\n }\n }\n static _handleAnimation() {\n if (!this.animRunning) {\n this.animRunning = true;\n Util.requestAnimFrame(this._animationLoop);\n }\n }\n}\nAnimation.animations = new Set();\nAnimation.animIdCounter = 0;\nAnimation.animRunning = false;\n","import { Util } from \"./Util.js\";\nimport { Animation } from \"./Animation.js\";\nimport { Node } from \"./Node.js\";\nimport { Konva } from \"./Global.js\";\n// every config key that is not an attribute to tween\nconst blacklist = {\n node: 1,\n duration: 1,\n easing: 1,\n onFinish: 1,\n onUpdate: 1,\n onReset: 1,\n yoyo: 1,\n}, PAUSED = 1, PLAYING = 2, REVERSING = 3, colorAttrs = ['fill', 'stroke', 'shadowColor'];\nlet idCounter = 0;\n// the diff below reads r/g/b/a directly, so a color we can not parse must fail\n// with its own message instead of \"Cannot read properties of undefined\"\nfunction colorToRGBA(color) {\n return (Util.colorToRGBA(color) ||\n Util.throw('can not tween the color \"' +\n color +\n '\", because it is not a valid color.'));\n}\nclass TweenEngine {\n constructor(prop, propFunc, func, begin, finish, duration, yoyo) {\n this.prop = prop;\n this.propFunc = propFunc;\n this.begin = begin;\n this._pos = begin;\n this.duration = duration;\n this._change = 0;\n this.prevPos = 0;\n this.yoyo = yoyo;\n this._time = 0;\n this._position = 0;\n this._startTime = 0;\n this._finish = 0;\n this.func = func;\n this._change = finish - this.begin;\n this.pause();\n }\n fire(str) {\n const handler = this[str];\n if (handler) {\n handler();\n }\n }\n setTime(t) {\n if (t > this.duration) {\n if (this.yoyo) {\n this._time = this.duration;\n this.reverse();\n }\n else {\n this.finish();\n }\n }\n else if (t < 0) {\n if (this.yoyo) {\n this._time = 0;\n this.play();\n }\n else {\n this.reset();\n }\n }\n else {\n this._time = t;\n this.update();\n }\n }\n getTime() {\n return this._time;\n }\n setPosition(p) {\n this.prevPos = this._pos;\n this.propFunc(p);\n this._pos = p;\n }\n getPosition(t) {\n if (t === undefined) {\n t = this._time;\n }\n return this.func(t, this.begin, this._change, this.duration);\n }\n play() {\n this.state = PLAYING;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onPlay');\n }\n reverse() {\n this.state = REVERSING;\n this._time = this.duration - this._time;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onReverse');\n }\n seek(t) {\n this.pause();\n this._time = t;\n this.update();\n this.fire('onSeek');\n }\n reset() {\n this.pause();\n this._time = 0;\n this.update();\n this.fire('onReset');\n }\n finish() {\n this.pause();\n this._time = this.duration;\n this.update();\n this.fire('onFinish');\n }\n update() {\n this.setPosition(this.getPosition(this._time));\n this.fire('onUpdate');\n }\n onEnterFrame() {\n const t = this.getTimer() - this._startTime;\n if (this.state === PLAYING) {\n this.setTime(t);\n }\n else if (this.state === REVERSING) {\n this.setTime(this.duration - t);\n }\n }\n pause() {\n this.state = PAUSED;\n this.fire('onPause');\n }\n getTimer() {\n return Date.now();\n }\n}\n/**\n * Tween constructor. Tweens enable you to animate a node between the current state and a new state.\n * You can play, pause, reverse, seek, reset, and finish tweens. By default, tweens are animated using\n * a linear easing. For more tweening options, check out {@link Konva.Easings}\n * @constructor\n * @memberof Konva\n * @example\n * // instantiate new tween which fully rotates a node in 1 second\n * var tween = new Konva.Tween({\n * // list of tween specific properties\n * node: node,\n * duration: 1,\n * easing: Konva.Easings.EaseInOut,\n * yoyo: false, // play back and forth\n * onUpdate: () => console.log('node attrs updated'),\n * onFinish: () => console.log('finished'),\n * // set new values for any attributes of a passed node\n * rotation: 360,\n * fill: 'red'\n * });\n *\n * // play tween\n * tween.play();\n *\n * // pause tween\n * tween.pause();\n */\nexport class Tween {\n constructor(config) {\n const that = this, node = config.node, nodeId = node._id, easing = config.easing || Easings.Linear, yoyo = !!config.yoyo;\n let duration, key;\n if (typeof config.duration === 'undefined') {\n duration = 0.3;\n }\n else if (config.duration === 0) {\n // zero is bad value for duration\n duration = 0.001;\n }\n else {\n duration = config.duration;\n }\n this.node = node;\n this._id = idCounter++;\n const layers = node.getLayer() ||\n (node instanceof Konva['Stage'] ? node.getLayers() : null);\n if (!layers) {\n Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');\n }\n this.anim = new Animation(function () {\n that.tween.onEnterFrame();\n }, layers);\n this.tween = new TweenEngine(key, function (i) {\n that._tweenFunc(i);\n }, easing, 0, 1, duration * 1000, yoyo);\n this._addListeners();\n // init attrs map\n if (!Tween.attrs[nodeId]) {\n Tween.attrs[nodeId] = {};\n }\n if (!Tween.attrs[nodeId][this._id]) {\n Tween.attrs[nodeId][this._id] = {};\n }\n // init tweens map\n if (!Tween.tweens[nodeId]) {\n Tween.tweens[nodeId] = {};\n }\n for (key in config) {\n if (blacklist[key] === undefined) {\n this._addAttr(key, config[key]);\n }\n }\n this.reset();\n // callbacks\n this.onFinish = config.onFinish;\n this.onReset = config.onReset;\n this.onUpdate = config.onUpdate;\n }\n _addAttr(key, end) {\n // a component attribute ({x, y} of scale, offset, a gradient point...)\n // is tweened through its components: scale -> scaleX, scaleY\n if (Util._isPlainObject(end)) {\n for (const component in end) {\n this._addAttr(key + Util._capitalize(component), end[component]);\n }\n return;\n }\n const node = this.node, nodeId = node._id;\n let diff, len, trueEnd, trueStart, endRGBA;\n // remove conflict from tween map if it exists\n const tweenId = Tween.tweens[nodeId][key];\n if (tweenId !== undefined) {\n delete Tween.attrs[nodeId][tweenId][key];\n }\n // add to tween map\n let start = node.getAttr(key);\n if (Util._isArray(end)) {\n diff = [];\n // an attribute the node does not have yet starts from zeros. A copy,\n // as the colour stops are replaced by RGBA objects below\n start = (start || []).slice();\n len = Math.max(end.length, start.length);\n if (key === 'points' && end.length !== start.length) {\n // before tweening points we need to make sure that start.length === end.length\n // Util._prepareArrayForTween thinking that end.length > start.length\n if (end.length > start.length) {\n // so in this case we will increase number of starting points\n trueStart = start;\n start = Util._prepareArrayForTween(start, end, node.closed());\n }\n else {\n // in this case we will increase number of eding points\n trueEnd = end;\n end = Util._prepareArrayForTween(end, start, node.closed());\n }\n }\n if (key.indexOf('fill') === 0) {\n for (let n = 0; n < len; n++) {\n if (n % 2 === 0) {\n diff.push(end[n] - (start[n] || 0));\n }\n else {\n const startRGBA = colorToRGBA(start[n]);\n endRGBA = colorToRGBA(end[n]);\n start[n] = startRGBA;\n diff.push({\n r: endRGBA.r - startRGBA.r,\n g: endRGBA.g - startRGBA.g,\n b: endRGBA.b - startRGBA.b,\n a: endRGBA.a - startRGBA.a,\n });\n }\n }\n }\n else {\n for (let n = 0; n < len; n++) {\n diff.push(end[n] - (start[n] || 0));\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n start = colorToRGBA(start);\n endRGBA = colorToRGBA(end);\n diff = {\n r: endRGBA.r - start.r,\n g: endRGBA.g - start.g,\n b: endRGBA.b - start.b,\n a: endRGBA.a - start.a,\n };\n }\n else {\n diff = end - start;\n }\n Tween.attrs[nodeId][this._id][key] = {\n start: start,\n diff: diff,\n end: end,\n trueEnd: trueEnd,\n trueStart: trueStart,\n };\n Tween.tweens[nodeId][key] = this._id;\n }\n _tweenFunc(i) {\n const node = this.node, attrs = Tween.attrs[node._id][this._id];\n let key, attr, start, diff, newVal, n, len, end;\n for (key in attrs) {\n attr = attrs[key];\n start = attr.start;\n diff = attr.diff;\n end = attr.end;\n if (Util._isArray(start)) {\n newVal = [];\n len = Math.max(start.length, end.length);\n if (key.indexOf('fill') === 0) {\n for (n = 0; n < len; n++) {\n if (n % 2 === 0) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n else {\n newVal.push('rgba(' +\n Math.round(start[n].r + diff[n].r * i) +\n ',' +\n Math.round(start[n].g + diff[n].g * i) +\n ',' +\n Math.round(start[n].b + diff[n].b * i) +\n ',' +\n (start[n].a + diff[n].a * i) +\n ')');\n }\n }\n }\n else {\n for (n = 0; n < len; n++) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n newVal =\n 'rgba(' +\n Math.round(start.r + diff.r * i) +\n ',' +\n Math.round(start.g + diff.g * i) +\n ',' +\n Math.round(start.b + diff.b * i) +\n ',' +\n (start.a + diff.a * i) +\n ')';\n }\n else {\n newVal = start + diff * i;\n }\n node.setAttr(key, newVal);\n }\n }\n _addListeners() {\n // a running tween is destroyed with its node (the animation loop would\n // keep both alive); a stopped one is not held by the node at all.\n // The namespace contains \"konva\" so clone() does not copy the listener\n const destroyEvent = `destroy.konva-tween${this._id}`;\n const onDestroy = () => this.destroy();\n const start = () => {\n this.node.off(destroyEvent).on(destroyEvent, onDestroy);\n this.anim.start();\n };\n this.tween.onPlay = start;\n this.tween.onReverse = start;\n // stop listeners\n this.tween.onPause = () => {\n this.node.off(destroyEvent);\n this.anim.stop();\n };\n this.tween.onFinish = () => {\n const node = this.node;\n // after tweening points of line we need to set original end\n const attrs = Tween.attrs[node._id][this._id];\n if (attrs.points && attrs.points.trueEnd) {\n node.setAttr('points', attrs.points.trueEnd);\n }\n if (this.onFinish) {\n this.onFinish.call(this);\n }\n };\n this.tween.onReset = () => {\n const node = this.node;\n // after tweening points of line we need to set original start\n const attrs = Tween.attrs[node._id][this._id];\n if (attrs.points && attrs.points.trueStart) {\n node.points(attrs.points.trueStart);\n }\n if (this.onReset) {\n this.onReset();\n }\n };\n this.tween.onUpdate = () => {\n if (this.onUpdate) {\n this.onUpdate.call(this);\n }\n };\n }\n /**\n * play\n * @method\n * @name Konva.Tween#play\n * @returns {Tween}\n */\n play() {\n this.tween.play();\n return this;\n }\n /**\n * reverse\n * @method\n * @name Konva.Tween#reverse\n * @returns {Tween}\n */\n reverse() {\n this.tween.reverse();\n return this;\n }\n /**\n * reset\n * @method\n * @name Konva.Tween#reset\n * @returns {Tween}\n */\n reset() {\n this.tween.reset();\n return this;\n }\n /**\n * seek\n * @method\n * @name Konva.Tween#seek\n * @param {Number} t time in seconds between 0 and the duration\n * @returns {Tween}\n */\n seek(t) {\n this.tween.seek(t * 1000);\n return this;\n }\n /**\n * pause\n * @method\n * @name Konva.Tween#pause\n * @returns {Tween}\n */\n pause() {\n this.tween.pause();\n return this;\n }\n /**\n * finish\n * @method\n * @name Konva.Tween#finish\n * @returns {Tween}\n */\n finish() {\n this.tween.finish();\n return this;\n }\n /**\n * destroy\n * @method\n * @name Konva.Tween#destroy\n */\n destroy() {\n var _a;\n const nodeId = this.node._id, thisId = this._id, owned = (_a = Tween.attrs[nodeId]) === null || _a === void 0 ? void 0 : _a[thisId], owners = Tween.tweens[nodeId];\n this.pause();\n if (this.anim) {\n this.anim.stop();\n }\n // release only the attributes this tween still owns, other tweens on\n // the node keep theirs (nothing left to do when destroyed twice)\n if (owned) {\n if (owners) {\n for (const key in owned) {\n delete owners[key];\n }\n if (Object.keys(owners).length === 0) {\n delete Tween.tweens[nodeId];\n }\n }\n delete Tween.attrs[nodeId][thisId];\n if (Object.keys(Tween.attrs[nodeId]).length === 0) {\n delete Tween.attrs[nodeId];\n }\n }\n }\n}\nTween.attrs = {};\nTween.tweens = {};\n/**\n * Tween node properties. Shorter usage of {@link Konva.Tween} object.\n *\n * @method Konva.Node#to\n * @param {Object} [params] tween params\n * @returns {Konva.Tween}\n * @example\n *\n * circle.to({\n * x : 50,\n * duration : 0.5,\n * onUpdate: () => console.log('props updated'),\n * onFinish: () => console.log('finished'),\n * });\n */\nNode.prototype.to = function (params) {\n const onFinish = params.onFinish;\n // params stay untouched, so the same object can animate several nodes\n const tween = new Tween({\n ...params,\n node: this,\n onFinish() {\n tween.destroy();\n if (onFinish) {\n onFinish();\n }\n },\n });\n tween.play();\n return tween;\n};\n/*\n * These eases were ported from an Adobe Flash tweening library to JavaScript\n * by Xaric\n */\n/**\n * @namespace Easings\n * @memberof Konva\n */\nexport const Easings = {\n /**\n * back ease in\n * @function\n * @memberof Konva.Easings\n */\n BackEaseIn(t, b, c, d) {\n const s = 1.70158;\n return c * (t /= d) * t * ((s + 1) * t - s) + b;\n },\n /**\n * back ease out\n * @function\n * @memberof Konva.Easings\n */\n BackEaseOut(t, b, c, d) {\n const s = 1.70158;\n return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n },\n /**\n * back ease in out\n * @function\n * @memberof Konva.Easings\n */\n BackEaseInOut(t, b, c, d) {\n let s = 1.70158;\n if ((t /= d / 2) < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n },\n /**\n * elastic ease in\n * @function\n * @memberof Konva.Easings\n */\n ElasticEaseIn(t, b, c, d, a, p) {\n // added s = 0\n let s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (-(a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b);\n },\n /**\n * elastic ease out\n * @function\n * @memberof Konva.Easings\n */\n ElasticEaseOut(t, b, c, d, a, p) {\n // added s = 0\n let s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (a * Math.pow(2, -10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) +\n c +\n b);\n },\n /**\n * elastic ease in out\n * @function\n * @memberof Konva.Easings\n */\n ElasticEaseInOut(t, b, c, d, a, p) {\n // added s = 0\n let s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d / 2) === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n if (t < 1) {\n return (-0.5 *\n (a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +\n b);\n }\n return (a *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p) *\n 0.5 +\n c +\n b);\n },\n /**\n * bounce ease out\n * @function\n * @memberof Konva.Easings\n */\n BounceEaseOut(t, b, c, d) {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n }\n else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n }\n else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n }\n else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n },\n /**\n * bounce ease in\n * @function\n * @memberof Konva.Easings\n */\n BounceEaseIn(t, b, c, d) {\n return c - Easings.BounceEaseOut(d - t, 0, c, d) + b;\n },\n /**\n * bounce ease in out\n * @function\n * @memberof Konva.Easings\n */\n BounceEaseInOut(t, b, c, d) {\n if (t < d / 2) {\n return Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;\n }\n else {\n return Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n }\n },\n /**\n * ease in\n * @function\n * @memberof Konva.Easings\n */\n EaseIn(t, b, c, d) {\n return c * (t /= d) * t + b;\n },\n /**\n * ease out\n * @function\n * @memberof Konva.Easings\n */\n EaseOut(t, b, c, d) {\n return -c * (t /= d) * (t - 2) + b;\n },\n /**\n * ease in out\n * @function\n * @memberof Konva.Easings\n */\n EaseInOut(t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n },\n /**\n * strong ease in\n * @function\n * @memberof Konva.Easings\n */\n StrongEaseIn(t, b, c, d) {\n return c * (t /= d) * t * t * t * t + b;\n },\n /**\n * strong ease out\n * @function\n * @memberof Konva.Easings\n */\n StrongEaseOut(t, b, c, d) {\n return c * ((t = t / d - 1) * t * t * t * t + 1) + b;\n },\n /**\n * strong ease in out\n * @function\n * @memberof Konva.Easings\n */\n StrongEaseInOut(t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t * t * t * t + b;\n }\n return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;\n },\n /**\n * linear\n * @function\n * @memberof Konva.Easings\n */\n Linear(t, b, c, d) {\n return (c * t) / d + b;\n },\n};\n","// what is core parts of Konva?\nimport { Konva as Global } from \"./Global.js\";\nimport { Util, Transform } from \"./Util.js\";\nimport { Node } from \"./Node.js\";\nimport { Container } from \"./Container.js\";\nimport { Stage, stages } from \"./Stage.js\";\nimport { Layer } from \"./Layer.js\";\nimport { FastLayer } from \"./FastLayer.js\";\nimport { Group } from \"./Group.js\";\nimport { DD } from \"./DragAndDrop.js\";\nimport { Shape, shapes } from \"./Shape.js\";\nimport { Animation } from \"./Animation.js\";\nimport { Tween, Easings } from \"./Tween.js\";\nimport { Context } from \"./Context.js\";\nimport { Canvas } from \"./Canvas.js\";\nexport const Konva = Util._assign(Global, {\n Util,\n Transform,\n Node,\n Container,\n Stage,\n stages,\n Layer,\n FastLayer,\n Group,\n DD,\n Shape,\n shapes,\n Animation,\n Tween,\n Easings,\n Context,\n Canvas,\n});\nexport default Konva;\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Konva } from \"../Global.js\";\nimport { getNumberValidator, getBooleanValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Arc constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Number} config.angle in degrees\n * @param {Number} config.innerRadius\n * @param {Number} config.outerRadius\n * @param {Boolean} [config.clockwise]\n * @@shapeParams\n * @@nodeParams\n * @example\n * // draw a Arc that's pointing downwards\n * var arc = new Konva.Arc({\n * innerRadius: 40,\n * outerRadius: 80,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 5,\n * angle: 60,\n * rotation: -120\n * });\n */\nexport class Arc extends Shape {\n _sceneFunc(context) {\n const angle = Konva.getAngle(this.angle()), clockwise = this.clockwise();\n context.beginPath();\n context.arc(0, 0, Math.abs(this.outerRadius()), 0, angle, clockwise);\n context.arc(0, 0, Math.abs(this.innerRadius()), angle, 0, !clockwise);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return Math.abs(this.outerRadius()) * 2;\n }\n getHeight() {\n return Math.abs(this.outerRadius()) * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n getSelfRect() {\n const innerRadius = Math.abs(this.innerRadius());\n const outerRadius = Math.abs(this.outerRadius());\n const clockwise = this.clockwise();\n // canvas draws a full circle for any non-zero full-turn end angle regardless\n // of direction, and nothing for angle 0. The 360 - angle flip below maps both\n // onto the same value, so handle exact full turns before the trig formula.\n const rawAngle = Konva.getAngle(this.angle());\n if (rawAngle % (Math.PI * 2) === 0) {\n return rawAngle !== 0\n ? {\n x: -outerRadius,\n y: -outerRadius,\n width: outerRadius * 2,\n height: outerRadius * 2,\n }\n : { x: innerRadius, y: 0, width: outerRadius - innerRadius, height: 0 };\n }\n const angle = Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());\n const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));\n const boundRightRatio = 1;\n const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));\n const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));\n const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);\n const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);\n const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);\n const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);\n return {\n x: boundLeft,\n y: clockwise ? -1 * boundBottom : boundTop,\n width: boundRight - boundLeft,\n height: boundBottom - boundTop,\n };\n }\n}\nArc.prototype._centroid = true;\nArc.prototype.className = 'Arc';\nArc.prototype._attrsAffectingSize = [\n 'innerRadius',\n 'outerRadius',\n 'angle',\n 'clockwise',\n];\n_registerNode(Arc);\n// add getters setters\nFactory.addGetterSetter(Arc, 'innerRadius', 0, getNumberValidator());\n/**\n * get/set innerRadius\n * @name Konva.Arc#innerRadius\n * @method\n * @param {Number} innerRadius\n * @returns {Number}\n * @example\n * // get inner radius\n * var innerRadius = arc.innerRadius();\n *\n * // set inner radius\n * arc.innerRadius(20);\n */\nFactory.addGetterSetter(Arc, 'outerRadius', 0, getNumberValidator());\n/**\n * get/set outerRadius\n * @name Konva.Arc#outerRadius\n * @method\n * @param {Number} outerRadius\n * @returns {Number}\n * @example\n * // get outer radius\n * var outerRadius = arc.outerRadius();\n *\n * // set outer radius\n * arc.outerRadius(20);\n */\nFactory.addGetterSetter(Arc, 'angle', 0, getNumberValidator());\n/**\n * get/set angle in degrees\n * @name Konva.Arc#angle\n * @method\n * @param {Number} angle\n * @returns {Number}\n * @example\n * // get angle\n * var angle = arc.angle();\n *\n * // set angle\n * arc.angle(20);\n */\nFactory.addGetterSetter(Arc, 'clockwise', false, getBooleanValidator());\n/**\n * get/set clockwise flag\n * @name Konva.Arc#clockwise\n * @method\n * @param {Boolean} clockwise\n * @returns {Boolean}\n * @example\n * // get clockwise flag\n * var clockwise = arc.clockwise();\n *\n * // draw arc counter-clockwise\n * arc.clockwise(false);\n *\n * // draw arc clockwise\n * arc.clockwise(true);\n */\n","// Credits: rveciana/svg-path-properties\n// Legendre-Gauss abscissae (xi values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))\nexport const tValues = [\n [],\n [],\n [\n -0.5773502691896257645091487805019574556476,\n 0.5773502691896257645091487805019574556476,\n ],\n [\n 0, -0.7745966692414833770358530799564799221665,\n 0.7745966692414833770358530799564799221665,\n ],\n [\n -0.3399810435848562648026657591032446872005,\n 0.3399810435848562648026657591032446872005,\n -0.8611363115940525752239464888928095050957,\n 0.8611363115940525752239464888928095050957,\n ],\n [\n 0, -0.5384693101056830910363144207002088049672,\n 0.5384693101056830910363144207002088049672,\n -0.9061798459386639927976268782993929651256,\n 0.9061798459386639927976268782993929651256,\n ],\n [\n 0.6612093864662645136613995950199053470064,\n -0.6612093864662645136613995950199053470064,\n -0.2386191860831969086305017216807119354186,\n 0.2386191860831969086305017216807119354186,\n -0.9324695142031520278123015544939946091347,\n 0.9324695142031520278123015544939946091347,\n ],\n [\n 0, 0.4058451513773971669066064120769614633473,\n -0.4058451513773971669066064120769614633473,\n -0.7415311855993944398638647732807884070741,\n 0.7415311855993944398638647732807884070741,\n -0.9491079123427585245261896840478512624007,\n 0.9491079123427585245261896840478512624007,\n ],\n [\n -0.1834346424956498049394761423601839806667,\n 0.1834346424956498049394761423601839806667,\n -0.5255324099163289858177390491892463490419,\n 0.5255324099163289858177390491892463490419,\n -0.7966664774136267395915539364758304368371,\n 0.7966664774136267395915539364758304368371,\n -0.9602898564975362316835608685694729904282,\n 0.9602898564975362316835608685694729904282,\n ],\n [\n 0, -0.8360311073266357942994297880697348765441,\n 0.8360311073266357942994297880697348765441,\n -0.9681602395076260898355762029036728700494,\n 0.9681602395076260898355762029036728700494,\n -0.3242534234038089290385380146433366085719,\n 0.3242534234038089290385380146433366085719,\n -0.6133714327005903973087020393414741847857,\n 0.6133714327005903973087020393414741847857,\n ],\n [\n -0.1488743389816312108848260011297199846175,\n 0.1488743389816312108848260011297199846175,\n -0.4333953941292471907992659431657841622,\n 0.4333953941292471907992659431657841622,\n -0.6794095682990244062343273651148735757692,\n 0.6794095682990244062343273651148735757692,\n -0.8650633666889845107320966884234930485275,\n 0.8650633666889845107320966884234930485275,\n -0.9739065285171717200779640120844520534282,\n 0.9739065285171717200779640120844520534282,\n ],\n [\n 0, -0.2695431559523449723315319854008615246796,\n 0.2695431559523449723315319854008615246796,\n -0.5190961292068118159257256694586095544802,\n 0.5190961292068118159257256694586095544802,\n -0.7301520055740493240934162520311534580496,\n 0.7301520055740493240934162520311534580496,\n -0.8870625997680952990751577693039272666316,\n 0.8870625997680952990751577693039272666316,\n -0.9782286581460569928039380011228573907714,\n 0.9782286581460569928039380011228573907714,\n ],\n [\n -0.1252334085114689154724413694638531299833,\n 0.1252334085114689154724413694638531299833,\n -0.3678314989981801937526915366437175612563,\n 0.3678314989981801937526915366437175612563,\n -0.587317954286617447296702418940534280369,\n 0.587317954286617447296702418940534280369,\n -0.7699026741943046870368938332128180759849,\n 0.7699026741943046870368938332128180759849,\n -0.9041172563704748566784658661190961925375,\n 0.9041172563704748566784658661190961925375,\n -0.9815606342467192506905490901492808229601,\n 0.9815606342467192506905490901492808229601,\n ],\n [\n 0, -0.2304583159551347940655281210979888352115,\n 0.2304583159551347940655281210979888352115,\n -0.4484927510364468528779128521276398678019,\n 0.4484927510364468528779128521276398678019,\n -0.6423493394403402206439846069955156500716,\n 0.6423493394403402206439846069955156500716,\n -0.8015780907333099127942064895828598903056,\n 0.8015780907333099127942064895828598903056,\n -0.9175983992229779652065478365007195123904,\n 0.9175983992229779652065478365007195123904,\n -0.9841830547185881494728294488071096110649,\n 0.9841830547185881494728294488071096110649,\n ],\n [\n -0.1080549487073436620662446502198347476119,\n 0.1080549487073436620662446502198347476119,\n -0.3191123689278897604356718241684754668342,\n 0.3191123689278897604356718241684754668342,\n -0.5152486363581540919652907185511886623088,\n 0.5152486363581540919652907185511886623088,\n -0.6872929048116854701480198030193341375384,\n 0.6872929048116854701480198030193341375384,\n -0.8272013150697649931897947426503949610397,\n 0.8272013150697649931897947426503949610397,\n -0.928434883663573517336391139377874264477,\n 0.928434883663573517336391139377874264477,\n -0.986283808696812338841597266704052801676,\n 0.986283808696812338841597266704052801676,\n ],\n [\n 0, -0.2011940939974345223006283033945962078128,\n 0.2011940939974345223006283033945962078128,\n -0.3941513470775633698972073709810454683627,\n 0.3941513470775633698972073709810454683627,\n -0.5709721726085388475372267372539106412383,\n 0.5709721726085388475372267372539106412383,\n -0.7244177313601700474161860546139380096308,\n 0.7244177313601700474161860546139380096308,\n -0.8482065834104272162006483207742168513662,\n 0.8482065834104272162006483207742168513662,\n -0.9372733924007059043077589477102094712439,\n 0.9372733924007059043077589477102094712439,\n -0.9879925180204854284895657185866125811469,\n 0.9879925180204854284895657185866125811469,\n ],\n [\n -0.0950125098376374401853193354249580631303,\n 0.0950125098376374401853193354249580631303,\n -0.281603550779258913230460501460496106486,\n 0.281603550779258913230460501460496106486,\n -0.45801677765722738634241944298357757354,\n 0.45801677765722738634241944298357757354,\n -0.6178762444026437484466717640487910189918,\n 0.6178762444026437484466717640487910189918,\n -0.7554044083550030338951011948474422683538,\n 0.7554044083550030338951011948474422683538,\n -0.8656312023878317438804678977123931323873,\n 0.8656312023878317438804678977123931323873,\n -0.9445750230732325760779884155346083450911,\n 0.9445750230732325760779884155346083450911,\n -0.9894009349916499325961541734503326274262,\n 0.9894009349916499325961541734503326274262,\n ],\n [\n 0, -0.1784841814958478558506774936540655574754,\n 0.1784841814958478558506774936540655574754,\n -0.3512317634538763152971855170953460050405,\n 0.3512317634538763152971855170953460050405,\n -0.5126905370864769678862465686295518745829,\n 0.5126905370864769678862465686295518745829,\n -0.6576711592166907658503022166430023351478,\n 0.6576711592166907658503022166430023351478,\n -0.7815140038968014069252300555204760502239,\n 0.7815140038968014069252300555204760502239,\n -0.8802391537269859021229556944881556926234,\n 0.8802391537269859021229556944881556926234,\n -0.9506755217687677612227169578958030214433,\n 0.9506755217687677612227169578958030214433,\n -0.9905754753144173356754340199406652765077,\n 0.9905754753144173356754340199406652765077,\n ],\n [\n -0.0847750130417353012422618529357838117333,\n 0.0847750130417353012422618529357838117333,\n -0.2518862256915055095889728548779112301628,\n 0.2518862256915055095889728548779112301628,\n -0.4117511614628426460359317938330516370789,\n 0.4117511614628426460359317938330516370789,\n -0.5597708310739475346078715485253291369276,\n 0.5597708310739475346078715485253291369276,\n -0.6916870430603532078748910812888483894522,\n 0.6916870430603532078748910812888483894522,\n -0.8037049589725231156824174550145907971032,\n 0.8037049589725231156824174550145907971032,\n -0.8926024664975557392060605911271455154078,\n 0.8926024664975557392060605911271455154078,\n -0.9558239495713977551811958929297763099728,\n 0.9558239495713977551811958929297763099728,\n -0.9915651684209309467300160047061507702525,\n 0.9915651684209309467300160047061507702525,\n ],\n [\n 0, -0.1603586456402253758680961157407435495048,\n 0.1603586456402253758680961157407435495048,\n -0.3165640999636298319901173288498449178922,\n 0.3165640999636298319901173288498449178922,\n -0.4645707413759609457172671481041023679762,\n 0.4645707413759609457172671481041023679762,\n -0.6005453046616810234696381649462392798683,\n 0.6005453046616810234696381649462392798683,\n -0.7209661773352293786170958608237816296571,\n 0.7209661773352293786170958608237816296571,\n -0.8227146565371428249789224867127139017745,\n 0.8227146565371428249789224867127139017745,\n -0.9031559036148179016426609285323124878093,\n 0.9031559036148179016426609285323124878093,\n -0.960208152134830030852778840687651526615,\n 0.960208152134830030852778840687651526615,\n -0.9924068438435844031890176702532604935893,\n 0.9924068438435844031890176702532604935893,\n ],\n [\n -0.0765265211334973337546404093988382110047,\n 0.0765265211334973337546404093988382110047,\n -0.227785851141645078080496195368574624743,\n 0.227785851141645078080496195368574624743,\n -0.3737060887154195606725481770249272373957,\n 0.3737060887154195606725481770249272373957,\n -0.5108670019508270980043640509552509984254,\n 0.5108670019508270980043640509552509984254,\n -0.6360536807265150254528366962262859367433,\n 0.6360536807265150254528366962262859367433,\n -0.7463319064601507926143050703556415903107,\n 0.7463319064601507926143050703556415903107,\n -0.8391169718222188233945290617015206853296,\n 0.8391169718222188233945290617015206853296,\n -0.9122344282513259058677524412032981130491,\n 0.9122344282513259058677524412032981130491,\n -0.963971927277913791267666131197277221912,\n 0.963971927277913791267666131197277221912,\n -0.9931285991850949247861223884713202782226,\n 0.9931285991850949247861223884713202782226,\n ],\n [\n 0, -0.1455618541608950909370309823386863301163,\n 0.1455618541608950909370309823386863301163,\n -0.288021316802401096600792516064600319909,\n 0.288021316802401096600792516064600319909,\n -0.4243421202074387835736688885437880520964,\n 0.4243421202074387835736688885437880520964,\n -0.551618835887219807059018796724313286622,\n 0.551618835887219807059018796724313286622,\n -0.667138804197412319305966669990339162597,\n 0.667138804197412319305966669990339162597,\n -0.7684399634756779086158778513062280348209,\n 0.7684399634756779086158778513062280348209,\n -0.8533633645833172836472506385875676702761,\n 0.8533633645833172836472506385875676702761,\n -0.9200993341504008287901871337149688941591,\n 0.9200993341504008287901871337149688941591,\n -0.9672268385663062943166222149076951614246,\n 0.9672268385663062943166222149076951614246,\n -0.9937521706203895002602420359379409291933,\n 0.9937521706203895002602420359379409291933,\n ],\n [\n -0.0697392733197222212138417961186280818222,\n 0.0697392733197222212138417961186280818222,\n -0.2078604266882212854788465339195457342156,\n 0.2078604266882212854788465339195457342156,\n -0.3419358208920842251581474204273796195591,\n 0.3419358208920842251581474204273796195591,\n -0.4693558379867570264063307109664063460953,\n 0.4693558379867570264063307109664063460953,\n -0.5876404035069115929588769276386473488776,\n 0.5876404035069115929588769276386473488776,\n -0.6944872631866827800506898357622567712673,\n 0.6944872631866827800506898357622567712673,\n -0.7878168059792081620042779554083515213881,\n 0.7878168059792081620042779554083515213881,\n -0.8658125777203001365364256370193787290847,\n 0.8658125777203001365364256370193787290847,\n -0.9269567721871740005206929392590531966353,\n 0.9269567721871740005206929392590531966353,\n -0.9700604978354287271239509867652687108059,\n 0.9700604978354287271239509867652687108059,\n -0.994294585482399292073031421161298980393,\n 0.994294585482399292073031421161298980393,\n ],\n [\n 0, -0.1332568242984661109317426822417661370104,\n 0.1332568242984661109317426822417661370104,\n -0.264135680970344930533869538283309602979,\n 0.264135680970344930533869538283309602979,\n -0.390301038030290831421488872880605458578,\n 0.390301038030290831421488872880605458578,\n -0.5095014778460075496897930478668464305448,\n 0.5095014778460075496897930478668464305448,\n -0.6196098757636461563850973116495956533871,\n 0.6196098757636461563850973116495956533871,\n -0.7186613631319501944616244837486188483299,\n 0.7186613631319501944616244837486188483299,\n -0.8048884016188398921511184069967785579414,\n 0.8048884016188398921511184069967785579414,\n -0.8767523582704416673781568859341456716389,\n 0.8767523582704416673781568859341456716389,\n -0.9329710868260161023491969890384229782357,\n 0.9329710868260161023491969890384229782357,\n -0.9725424712181152319560240768207773751816,\n 0.9725424712181152319560240768207773751816,\n -0.9947693349975521235239257154455743605736,\n 0.9947693349975521235239257154455743605736,\n ],\n [\n -0.0640568928626056260850430826247450385909,\n 0.0640568928626056260850430826247450385909,\n -0.1911188674736163091586398207570696318404,\n 0.1911188674736163091586398207570696318404,\n -0.3150426796961633743867932913198102407864,\n 0.3150426796961633743867932913198102407864,\n -0.4337935076260451384870842319133497124524,\n 0.4337935076260451384870842319133497124524,\n -0.5454214713888395356583756172183723700107,\n 0.5454214713888395356583756172183723700107,\n -0.6480936519369755692524957869107476266696,\n 0.6480936519369755692524957869107476266696,\n -0.7401241915785543642438281030999784255232,\n 0.7401241915785543642438281030999784255232,\n -0.8200019859739029219539498726697452080761,\n 0.8200019859739029219539498726697452080761,\n -0.8864155270044010342131543419821967550873,\n 0.8864155270044010342131543419821967550873,\n -0.9382745520027327585236490017087214496548,\n 0.9382745520027327585236490017087214496548,\n -0.9747285559713094981983919930081690617411,\n 0.9747285559713094981983919930081690617411,\n -0.9951872199970213601799974097007368118745,\n 0.9951872199970213601799974097007368118745,\n ],\n];\n// Legendre-Gauss weights (wi values, defined by a function linked to in the Bezier primer article)\nexport const cValues = [\n [],\n [],\n [1.0, 1.0],\n [\n 0.8888888888888888888888888888888888888888,\n 0.5555555555555555555555555555555555555555,\n 0.5555555555555555555555555555555555555555,\n ],\n [\n 0.6521451548625461426269360507780005927646,\n 0.6521451548625461426269360507780005927646,\n 0.3478548451374538573730639492219994072353,\n 0.3478548451374538573730639492219994072353,\n ],\n [\n 0.5688888888888888888888888888888888888888,\n 0.4786286704993664680412915148356381929122,\n 0.4786286704993664680412915148356381929122,\n 0.2369268850561890875142640407199173626432,\n 0.2369268850561890875142640407199173626432,\n ],\n [\n 0.3607615730481386075698335138377161116615,\n 0.3607615730481386075698335138377161116615,\n 0.4679139345726910473898703439895509948116,\n 0.4679139345726910473898703439895509948116,\n 0.1713244923791703450402961421727328935268,\n 0.1713244923791703450402961421727328935268,\n ],\n [\n 0.4179591836734693877551020408163265306122,\n 0.3818300505051189449503697754889751338783,\n 0.3818300505051189449503697754889751338783,\n 0.2797053914892766679014677714237795824869,\n 0.2797053914892766679014677714237795824869,\n 0.1294849661688696932706114326790820183285,\n 0.1294849661688696932706114326790820183285,\n ],\n [\n 0.3626837833783619829651504492771956121941,\n 0.3626837833783619829651504492771956121941,\n 0.3137066458778872873379622019866013132603,\n 0.3137066458778872873379622019866013132603,\n 0.2223810344533744705443559944262408844301,\n 0.2223810344533744705443559944262408844301,\n 0.1012285362903762591525313543099621901153,\n 0.1012285362903762591525313543099621901153,\n ],\n [\n 0.3302393550012597631645250692869740488788,\n 0.1806481606948574040584720312429128095143,\n 0.1806481606948574040584720312429128095143,\n 0.0812743883615744119718921581105236506756,\n 0.0812743883615744119718921581105236506756,\n 0.3123470770400028400686304065844436655987,\n 0.3123470770400028400686304065844436655987,\n 0.2606106964029354623187428694186328497718,\n 0.2606106964029354623187428694186328497718,\n ],\n [\n 0.295524224714752870173892994651338329421,\n 0.295524224714752870173892994651338329421,\n 0.2692667193099963550912269215694693528597,\n 0.2692667193099963550912269215694693528597,\n 0.2190863625159820439955349342281631924587,\n 0.2190863625159820439955349342281631924587,\n 0.1494513491505805931457763396576973324025,\n 0.1494513491505805931457763396576973324025,\n 0.0666713443086881375935688098933317928578,\n 0.0666713443086881375935688098933317928578,\n ],\n [\n 0.272925086777900630714483528336342189156,\n 0.2628045445102466621806888698905091953727,\n 0.2628045445102466621806888698905091953727,\n 0.2331937645919904799185237048431751394317,\n 0.2331937645919904799185237048431751394317,\n 0.1862902109277342514260976414316558916912,\n 0.1862902109277342514260976414316558916912,\n 0.1255803694649046246346942992239401001976,\n 0.1255803694649046246346942992239401001976,\n 0.0556685671161736664827537204425485787285,\n 0.0556685671161736664827537204425485787285,\n ],\n [\n 0.2491470458134027850005624360429512108304,\n 0.2491470458134027850005624360429512108304,\n 0.2334925365383548087608498989248780562594,\n 0.2334925365383548087608498989248780562594,\n 0.2031674267230659217490644558097983765065,\n 0.2031674267230659217490644558097983765065,\n 0.160078328543346226334652529543359071872,\n 0.160078328543346226334652529543359071872,\n 0.1069393259953184309602547181939962242145,\n 0.1069393259953184309602547181939962242145,\n 0.047175336386511827194615961485017060317,\n 0.047175336386511827194615961485017060317,\n ],\n [\n 0.2325515532308739101945895152688359481566,\n 0.2262831802628972384120901860397766184347,\n 0.2262831802628972384120901860397766184347,\n 0.2078160475368885023125232193060527633865,\n 0.2078160475368885023125232193060527633865,\n 0.1781459807619457382800466919960979955128,\n 0.1781459807619457382800466919960979955128,\n 0.1388735102197872384636017768688714676218,\n 0.1388735102197872384636017768688714676218,\n 0.0921214998377284479144217759537971209236,\n 0.0921214998377284479144217759537971209236,\n 0.0404840047653158795200215922009860600419,\n 0.0404840047653158795200215922009860600419,\n ],\n [\n 0.2152638534631577901958764433162600352749,\n 0.2152638534631577901958764433162600352749,\n 0.2051984637212956039659240656612180557103,\n 0.2051984637212956039659240656612180557103,\n 0.1855383974779378137417165901251570362489,\n 0.1855383974779378137417165901251570362489,\n 0.1572031671581935345696019386238421566056,\n 0.1572031671581935345696019386238421566056,\n 0.1215185706879031846894148090724766259566,\n 0.1215185706879031846894148090724766259566,\n 0.0801580871597602098056332770628543095836,\n 0.0801580871597602098056332770628543095836,\n 0.0351194603317518630318328761381917806197,\n 0.0351194603317518630318328761381917806197,\n ],\n [\n 0.2025782419255612728806201999675193148386,\n 0.1984314853271115764561183264438393248186,\n 0.1984314853271115764561183264438393248186,\n 0.1861610000155622110268005618664228245062,\n 0.1861610000155622110268005618664228245062,\n 0.1662692058169939335532008604812088111309,\n 0.1662692058169939335532008604812088111309,\n 0.1395706779261543144478047945110283225208,\n 0.1395706779261543144478047945110283225208,\n 0.1071592204671719350118695466858693034155,\n 0.1071592204671719350118695466858693034155,\n 0.0703660474881081247092674164506673384667,\n 0.0703660474881081247092674164506673384667,\n 0.0307532419961172683546283935772044177217,\n 0.0307532419961172683546283935772044177217,\n ],\n [\n 0.1894506104550684962853967232082831051469,\n 0.1894506104550684962853967232082831051469,\n 0.1826034150449235888667636679692199393835,\n 0.1826034150449235888667636679692199393835,\n 0.1691565193950025381893120790303599622116,\n 0.1691565193950025381893120790303599622116,\n 0.1495959888165767320815017305474785489704,\n 0.1495959888165767320815017305474785489704,\n 0.1246289712555338720524762821920164201448,\n 0.1246289712555338720524762821920164201448,\n 0.0951585116824927848099251076022462263552,\n 0.0951585116824927848099251076022462263552,\n 0.0622535239386478928628438369943776942749,\n 0.0622535239386478928628438369943776942749,\n 0.0271524594117540948517805724560181035122,\n 0.0271524594117540948517805724560181035122,\n ],\n [\n 0.1794464703562065254582656442618856214487,\n 0.1765627053669926463252709901131972391509,\n 0.1765627053669926463252709901131972391509,\n 0.1680041021564500445099706637883231550211,\n 0.1680041021564500445099706637883231550211,\n 0.1540457610768102880814315948019586119404,\n 0.1540457610768102880814315948019586119404,\n 0.1351363684685254732863199817023501973721,\n 0.1351363684685254732863199817023501973721,\n 0.1118838471934039710947883856263559267358,\n 0.1118838471934039710947883856263559267358,\n 0.0850361483171791808835353701910620738504,\n 0.0850361483171791808835353701910620738504,\n 0.0554595293739872011294401653582446605128,\n 0.0554595293739872011294401653582446605128,\n 0.0241483028685479319601100262875653246916,\n 0.0241483028685479319601100262875653246916,\n ],\n [\n 0.1691423829631435918406564701349866103341,\n 0.1691423829631435918406564701349866103341,\n 0.1642764837458327229860537764659275904123,\n 0.1642764837458327229860537764659275904123,\n 0.1546846751262652449254180038363747721932,\n 0.1546846751262652449254180038363747721932,\n 0.1406429146706506512047313037519472280955,\n 0.1406429146706506512047313037519472280955,\n 0.1225552067114784601845191268002015552281,\n 0.1225552067114784601845191268002015552281,\n 0.1009420441062871655628139849248346070628,\n 0.1009420441062871655628139849248346070628,\n 0.0764257302548890565291296776166365256053,\n 0.0764257302548890565291296776166365256053,\n 0.0497145488949697964533349462026386416808,\n 0.0497145488949697964533349462026386416808,\n 0.0216160135264833103133427102664524693876,\n 0.0216160135264833103133427102664524693876,\n ],\n [\n 0.1610544498487836959791636253209167350399,\n 0.1589688433939543476499564394650472016787,\n 0.1589688433939543476499564394650472016787,\n 0.152766042065859666778855400897662998461,\n 0.152766042065859666778855400897662998461,\n 0.1426067021736066117757461094419029724756,\n 0.1426067021736066117757461094419029724756,\n 0.1287539625393362276755157848568771170558,\n 0.1287539625393362276755157848568771170558,\n 0.1115666455473339947160239016817659974813,\n 0.1115666455473339947160239016817659974813,\n 0.0914900216224499994644620941238396526609,\n 0.0914900216224499994644620941238396526609,\n 0.0690445427376412265807082580060130449618,\n 0.0690445427376412265807082580060130449618,\n 0.0448142267656996003328381574019942119517,\n 0.0448142267656996003328381574019942119517,\n 0.0194617882297264770363120414644384357529,\n 0.0194617882297264770363120414644384357529,\n ],\n [\n 0.1527533871307258506980843319550975934919,\n 0.1527533871307258506980843319550975934919,\n 0.1491729864726037467878287370019694366926,\n 0.1491729864726037467878287370019694366926,\n 0.1420961093183820513292983250671649330345,\n 0.1420961093183820513292983250671649330345,\n 0.1316886384491766268984944997481631349161,\n 0.1316886384491766268984944997481631349161,\n 0.118194531961518417312377377711382287005,\n 0.118194531961518417312377377711382287005,\n 0.1019301198172404350367501354803498761666,\n 0.1019301198172404350367501354803498761666,\n 0.0832767415767047487247581432220462061001,\n 0.0832767415767047487247581432220462061001,\n 0.0626720483341090635695065351870416063516,\n 0.0626720483341090635695065351870416063516,\n 0.040601429800386941331039952274932109879,\n 0.040601429800386941331039952274932109879,\n 0.0176140071391521183118619623518528163621,\n 0.0176140071391521183118619623518528163621,\n ],\n [\n 0.1460811336496904271919851476833711882448,\n 0.1445244039899700590638271665537525436099,\n 0.1445244039899700590638271665537525436099,\n 0.1398873947910731547221334238675831108927,\n 0.1398873947910731547221334238675831108927,\n 0.132268938633337461781052574496775604329,\n 0.132268938633337461781052574496775604329,\n 0.1218314160537285341953671771257335983563,\n 0.1218314160537285341953671771257335983563,\n 0.1087972991671483776634745780701056420336,\n 0.1087972991671483776634745780701056420336,\n 0.0934444234560338615532897411139320884835,\n 0.0934444234560338615532897411139320884835,\n 0.0761001136283793020170516533001831792261,\n 0.0761001136283793020170516533001831792261,\n 0.0571344254268572082836358264724479574912,\n 0.0571344254268572082836358264724479574912,\n 0.0369537897708524937999506682993296661889,\n 0.0369537897708524937999506682993296661889,\n 0.0160172282577743333242246168584710152658,\n 0.0160172282577743333242246168584710152658,\n ],\n [\n 0.1392518728556319933754102483418099578739,\n 0.1392518728556319933754102483418099578739,\n 0.1365414983460151713525738312315173965863,\n 0.1365414983460151713525738312315173965863,\n 0.1311735047870623707329649925303074458757,\n 0.1311735047870623707329649925303074458757,\n 0.1232523768105124242855609861548144719594,\n 0.1232523768105124242855609861548144719594,\n 0.1129322960805392183934006074217843191142,\n 0.1129322960805392183934006074217843191142,\n 0.1004141444428809649320788378305362823508,\n 0.1004141444428809649320788378305362823508,\n 0.0859416062170677274144436813727028661891,\n 0.0859416062170677274144436813727028661891,\n 0.0697964684245204880949614189302176573987,\n 0.0697964684245204880949614189302176573987,\n 0.0522933351526832859403120512732112561121,\n 0.0522933351526832859403120512732112561121,\n 0.0337749015848141547933022468659129013491,\n 0.0337749015848141547933022468659129013491,\n 0.0146279952982722006849910980471854451902,\n 0.0146279952982722006849910980471854451902,\n ],\n [\n 0.1336545721861061753514571105458443385831,\n 0.132462039404696617371642464703316925805,\n 0.132462039404696617371642464703316925805,\n 0.1289057221880821499785953393997936532597,\n 0.1289057221880821499785953393997936532597,\n 0.1230490843067295304675784006720096548158,\n 0.1230490843067295304675784006720096548158,\n 0.1149966402224113649416435129339613014914,\n 0.1149966402224113649416435129339613014914,\n 0.1048920914645414100740861850147438548584,\n 0.1048920914645414100740861850147438548584,\n 0.0929157660600351474770186173697646486034,\n 0.0929157660600351474770186173697646486034,\n 0.0792814117767189549228925247420432269137,\n 0.0792814117767189549228925247420432269137,\n 0.0642324214085258521271696151589109980391,\n 0.0642324214085258521271696151589109980391,\n 0.0480376717310846685716410716320339965612,\n 0.0480376717310846685716410716320339965612,\n 0.0309880058569794443106942196418845053837,\n 0.0309880058569794443106942196418845053837,\n 0.0134118594871417720813094934586150649766,\n 0.0134118594871417720813094934586150649766,\n ],\n [\n 0.1279381953467521569740561652246953718517,\n 0.1279381953467521569740561652246953718517,\n 0.1258374563468282961213753825111836887264,\n 0.1258374563468282961213753825111836887264,\n 0.121670472927803391204463153476262425607,\n 0.121670472927803391204463153476262425607,\n 0.1155056680537256013533444839067835598622,\n 0.1155056680537256013533444839067835598622,\n 0.1074442701159656347825773424466062227946,\n 0.1074442701159656347825773424466062227946,\n 0.0976186521041138882698806644642471544279,\n 0.0976186521041138882698806644642471544279,\n 0.086190161531953275917185202983742667185,\n 0.086190161531953275917185202983742667185,\n 0.0733464814110803057340336152531165181193,\n 0.0733464814110803057340336152531165181193,\n 0.0592985849154367807463677585001085845412,\n 0.0592985849154367807463677585001085845412,\n 0.0442774388174198061686027482113382288593,\n 0.0442774388174198061686027482113382288593,\n 0.0285313886289336631813078159518782864491,\n 0.0285313886289336631813078159518782864491,\n 0.0123412297999871995468056670700372915759,\n 0.0123412297999871995468056670700372915759,\n ],\n];\n// LUT for binomial coefficient arrays per curve order 'n'\nexport const binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];\nexport const getCubicArcLength = (xs, ys, t) => {\n let sum;\n let correctedT;\n /*if (xs.length >= tValues.length) {\n throw new Error('too high n bezier');\n }*/\n const n = 20;\n const z = t / 2;\n sum = 0;\n for (let i = 0; i < n; i++) {\n correctedT = z * tValues[n][i] + z;\n sum += cValues[n][i] * BFunc(xs, ys, correctedT);\n }\n return z * sum;\n};\nexport const getQuadraticArcLength = (xs, ys, t) => {\n if (t === undefined) {\n t = 1;\n }\n const ax = xs[0] - 2 * xs[1] + xs[2];\n const ay = ys[0] - 2 * ys[1] + ys[2];\n const bx = 2 * xs[1] - 2 * xs[0];\n const by = 2 * ys[1] - 2 * ys[0];\n const A = 4 * (ax * ax + ay * ay);\n const B = 4 * (ax * bx + ay * by);\n const C = bx * bx + by * by;\n if (A === 0) {\n return (t * Math.sqrt(Math.pow(xs[2] - xs[0], 2) + Math.pow(ys[2] - ys[0], 2)));\n }\n const b = B / (2 * A);\n const c = C / A;\n const u = t + b;\n const k = c - b * b;\n const uuk = u * u + k > 0 ? Math.sqrt(u * u + k) : 0;\n const bbk = b * b + k > 0 ? Math.sqrt(b * b + k) : 0;\n const term = b + Math.sqrt(b * b + k) !== 0\n ? k * Math.log(Math.abs((u + uuk) / (b + bbk)))\n : 0;\n return (Math.sqrt(A) / 2) * (u * uuk - b * bbk + term);\n};\nfunction BFunc(xs, ys, t) {\n const xbase = getDerivative(1, t, xs);\n const ybase = getDerivative(1, t, ys);\n const combined = xbase * xbase + ybase * ybase;\n return Math.sqrt(combined);\n}\n/**\n * Compute the curve derivative (hodograph) at t.\n */\nconst getDerivative = (derivative, t, vs) => {\n // the derivative of any 't'-less function is zero.\n const n = vs.length - 1;\n let _vs;\n let value;\n if (n === 0) {\n return 0;\n }\n // direct values? compute!\n if (derivative === 0) {\n value = 0;\n for (let k = 0; k <= n; k++) {\n value +=\n binomialCoefficients[n][k] *\n Math.pow(1 - t, n - k) *\n Math.pow(t, k) *\n vs[k];\n }\n return value;\n }\n else {\n // Still some derivative? go down one order, then try\n // for the lower order curve's.\n _vs = new Array(n);\n for (let k = 0; k < n; k++) {\n _vs[k] = n * (vs[k + 1] - vs[k]);\n }\n return getDerivative(derivative - 1, t, _vs);\n }\n};\nexport const t2length = (length, totalLength, func) => {\n let error = 1;\n let t = length / totalLength;\n let step = (length - func(t)) / totalLength;\n let numIterations = 0;\n while (error > 0.001) {\n const increasedTLength = func(t + step);\n const increasedTError = Math.abs(length - increasedTLength) / totalLength;\n if (increasedTError < error) {\n error = increasedTError;\n t += step;\n }\n else {\n const decreasedTLength = func(t - step);\n const decreasedTError = Math.abs(length - decreasedTLength) / totalLength;\n if (decreasedTError < error) {\n error = decreasedTError;\n t -= step;\n }\n else {\n step /= 2;\n }\n }\n numIterations++;\n if (numIterations > 500) {\n break;\n }\n }\n return t;\n};\nconst quadraticAt = (p0, p1, p2, t) => {\n const mt = 1 - t;\n return mt * mt * p0 + 2 * mt * t * p1 + t * t * p2;\n};\n/**\n * Points where a quadratic bezier segment reaches its highest or lowest value\n * on one of the two axes, as a flat [x, y, x, y, ...] list. The two end points\n * are not included, because the caller knows them already.\n */\nexport const getQuadraticExtremaPoints = (x0, y0, x1, y1, x2, y2) => {\n const extrema = [];\n for (const axis of [\n [x0, x1, x2],\n [y0, y1, y2],\n ]) {\n // the derivative of the quadratic is linear, so it has one root. A straight\n // segment makes the denominator 0, and the division then gives a value that\n // is not in the range below.\n const t = (axis[0] - axis[1]) / (axis[0] - 2 * axis[1] + axis[2]);\n if (t > 0 && t < 1) {\n extrema.push(quadraticAt(x0, x1, x2, t), quadraticAt(y0, y1, y2, t));\n }\n }\n return extrema;\n};\nconst cubicAt = (p0, p1, p2, p3, t) => {\n const mt = 1 - t;\n return (mt * mt * mt * p0 +\n 3 * mt * mt * t * p1 +\n 3 * mt * t * t * p2 +\n t * t * t * p3);\n};\n/**\n * Points where a cubic bezier segment reaches its highest or lowest value on\n * one of the two axes, as a flat [x, y, x, y, ...] list. The two end points\n * are not included, because the caller knows them already.\n */\nexport const getCubicExtremaPoints = (x0, y0, x1, y1, x2, y2, x3, y3) => {\n const extrema = [];\n for (const axis of [\n [x0, x1, x2, x3],\n [y0, y1, y2, y3],\n ]) {\n // the derivative of the cubic is a * t * t + b * t + c\n const a = -3 * axis[0] + 9 * axis[1] - 9 * axis[2] + 3 * axis[3];\n const b = 6 * axis[0] - 12 * axis[1] + 6 * axis[2];\n const c = -3 * axis[0] + 3 * axis[1];\n const discriminant = b * b - 4 * a * c;\n if (discriminant < 0) {\n continue;\n }\n // stable form of the quadratic formula. The plain (-b +- d) / (2 * a)\n // loses the root that stays finite when a is zero or near zero, which is\n // what a symmetric pair of control points gives. Roots that are not\n // finite fall out of the range test below.\n const q = -(b + (b < 0 ? -1 : 1) * Math.sqrt(discriminant)) / 2;\n for (const t of [q / a, c / q]) {\n if (t > 0 && t < 1) {\n extrema.push(cubicAt(x0, x1, x2, x3, t), cubicAt(y0, y1, y2, y3, t));\n }\n }\n }\n return extrema;\n};\n","import { getCubicExtremaPoints, getQuadraticExtremaPoints, } from \"../BezierFunctions.js\";\nimport { Factory } from \"../Factory.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Util } from \"../Util.js\";\nimport { getNumberArrayValidator, getNumberValidator } from \"../Validators.js\";\nfunction getControlPoints(x0, y0, x1, y1, x2, y2, t) {\n const d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), dSum = d01 + d12;\n // all three points are the same, so the control points collapse into that\n // point. Without this the divisions below are 0 / 0 = NaN.\n if (dSum === 0) {\n return [x1, y1, x1, y1];\n }\n const fa = (t * d01) / dSum, fb = (t * d12) / dSum, p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);\n return [p1x, p1y, p2x, p2y];\n}\nfunction expandPoints(p, tension) {\n const len = p.length, allPoints = [];\n for (let n = 2; n < len - 2; n += 2) {\n const cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);\n if (isNaN(cp[0])) {\n continue;\n }\n allPoints.push(cp[0]);\n allPoints.push(cp[1]);\n allPoints.push(p[n]);\n allPoints.push(p[n + 1]);\n allPoints.push(cp[2]);\n allPoints.push(cp[3]);\n }\n return allPoints;\n}\nfunction getBezierExtremaPoints(points) {\n const extrema = [];\n // points[0], points[1] is the starting point; every subsequent group of\n // 6 values is one cubic bezier segment (cp1x, cp1y, cp2x, cp2y, x, y),\n // whose start is the previous segment's end point (matching the layout\n // Line#_sceneFunc feeds to context.bezierCurveTo in a loop).\n for (let n = 0; n + 7 < points.length; n += 6) {\n // the end point of the segment. It is a joint with the next segment, and\n // the curve can reach its highest or lowest value there without the\n // derivative going to zero on either side.\n extrema.push(points[n + 6], points[n + 7], ...getCubicExtremaPoints(points[n], points[n + 1], points[n + 2], points[n + 3], points[n + 4], points[n + 5], points[n + 6], points[n + 7]));\n }\n return extrema;\n}\n/**\n * Line constructor. Lines are defined by an array of points and\n * a tension\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Array} config.points Flat array of points coordinates. You should define them as [x1, y1, x2, y2, x3, y3].\n * @param {Number} [config.tension] Higher values will result in a more curvy line. A value of 0 will result in no interpolation.\n * The default is 0\n * @param {Boolean} [config.closed] defines whether or not the line shape is closed, creating a polygon or blob\n * @param {Boolean} [config.bezier] if no tension is provided but bezier=true, we draw the line as a bezier using the passed points\n * @@shapeParams\n * @@nodeParams\n * @example\n * var line = new Konva.Line({\n * x: 100,\n * y: 50,\n * points: [73, 70, 340, 23, 450, 60, 500, 20],\n * stroke: 'red',\n * tension: 1\n * });\n */\nexport class Line extends Shape {\n constructor(config) {\n super(config);\n this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {\n this._clearCache('tensionPoints');\n });\n }\n _hasTension() {\n return this.tension() !== 0 && this.points().length > 4;\n }\n /**\n * Report every curve segment of a line with a tension, in draw order. Both\n * the scene function and the bounding rect read the shape through this, so\n * that they can not disagree about which curve the line is.\n *\n * The handlers take plain numbers, because this runs on every frame.\n */\n _eachTensionSegment(onQuadratic, onCubic) {\n const points = this.points(), length = points.length, closed = this.closed(), tp = this.getTensionPoints(), len = tp.length;\n let x0 = points[0], y0 = points[1], \n // a closed line has a curve on both sides of the first point, so it\n // starts on a full cubic. An open one is capped by a quadratic instead\n n = closed ? 0 : 4;\n if (!closed) {\n onQuadratic(x0, y0, tp[0], tp[1], tp[2], tp[3]);\n x0 = tp[2];\n y0 = tp[3];\n }\n while (n < len - 2) {\n const cp1x = tp[n++], cp1y = tp[n++], cp2x = tp[n++], cp2y = tp[n++], x = tp[n++], y = tp[n++];\n onCubic(x0, y0, cp1x, cp1y, cp2x, cp2y, x, y);\n x0 = x;\n y0 = y;\n }\n if (!closed) {\n onQuadratic(x0, y0, tp[len - 2], tp[len - 1], points[length - 2], points[length - 1]);\n }\n }\n _sceneFunc(context) {\n const points = this.points(), length = points.length, closed = this.closed(), bezier = this.bezier();\n if (!length) {\n return;\n }\n let n = 0;\n context.beginPath();\n context.moveTo(points[0], points[1]);\n // tension\n if (this._hasTension()) {\n this._eachTensionSegment((_x0, _y0, cpx, cpy, x, y) => context.quadraticCurveTo(cpx, cpy, x, y), (_x0, _y0, cp1x, cp1y, cp2x, cp2y, x, y) => context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));\n }\n else if (bezier) {\n // no tension but bezier\n n = 2;\n while (n < length) {\n context.bezierCurveTo(points[n++], points[n++], points[n++], points[n++], points[n++], points[n++]);\n }\n }\n else {\n // no tension\n for (n = 2; n < length; n += 2) {\n context.lineTo(points[n], points[n + 1]);\n }\n }\n // closed e.g. polygons and blobs\n if (closed) {\n context.closePath();\n context.fillStrokeShape(this);\n }\n else {\n // open e.g. lines and splines\n context.strokeShape(this);\n }\n }\n getTensionPoints() {\n return this._getCache('tensionPoints', this._getTensionPoints);\n }\n _getTensionPoints() {\n if (this.closed()) {\n return this._getTensionPointsClosed();\n }\n else {\n return expandPoints(this.points(), this.tension());\n }\n }\n _getTensionPointsClosed() {\n const p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]\n .concat(middle)\n .concat([\n lastControlPoints[0],\n lastControlPoints[1],\n p[len - 2],\n p[len - 1],\n lastControlPoints[2],\n lastControlPoints[3],\n firstControlPoints[0],\n firstControlPoints[1],\n p[0],\n p[1],\n ]);\n return tp;\n }\n getWidth() {\n return this.getSelfRect().width;\n }\n getHeight() {\n return this.getSelfRect().height;\n }\n // overload size detection\n getSelfRect() {\n let points = this.points();\n if (points.length < 4) {\n return {\n x: points[0] || 0,\n y: points[1] || 0,\n width: 0,\n height: 0,\n };\n }\n if (this._hasTension()) {\n // the two end points of every segment, plus the points where it turns\n // back on either axis. Together they are the exact bounds of the curve\n const bounds = [points[0], points[1]];\n this._eachTensionSegment((x0, y0, cpx, cpy, x, y) => bounds.push(x, y, ...getQuadraticExtremaPoints(x0, y0, cpx, cpy, x, y)), (x0, y0, cp1x, cp1y, cp2x, cp2y, x, y) => bounds.push(x, y, ...getCubicExtremaPoints(x0, y0, cp1x, cp1y, cp2x, cp2y, x, y)));\n points = bounds;\n }\n else if (this.bezier()) {\n // no trailing point here: the extrema already carry the end point of\n // every segment that is drawn. Adding the last pair of the array back\n // would include a control point of a trailing partial segment, which\n // _sceneFunc never draws.\n points = [points[0], points[1], ...getBezierExtremaPoints(points)];\n }\n return Util._getPointsRect(points);\n }\n}\nLine.prototype.className = 'Line';\nLine.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];\n_registerNode(Line);\n// add getters setters\nFactory.addGetterSetter(Line, 'closed', false);\n/**\n * get/set closed flag. The default is false\n * @name Konva.Line#closed\n * @method\n * @param {Boolean} closed\n * @returns {Boolean}\n * @example\n * // get closed flag\n * var closed = line.closed();\n *\n * // close the shape\n * line.closed(true);\n *\n * // open the shape\n * line.closed(false);\n */\nFactory.addGetterSetter(Line, 'bezier', false);\n/**\n * get/set bezier flag. The default is false\n * @name Konva.Line#bezier\n * @method\n * @param {Boolean} bezier\n * @returns {Boolean}\n * @example\n * // get whether the line is a bezier\n * var isBezier = line.bezier();\n *\n * // set whether the line is a bezier\n * line.bezier(true);\n */\nFactory.addGetterSetter(Line, 'tension', 0, getNumberValidator());\n/**\n * get/set tension\n * @name Konva.Line#tension\n * @method\n * @param {Number} tension Higher values will result in a more curvy line. A value of 0 will result in no interpolation. The default is 0\n * @returns {Number}\n * @example\n * // get tension\n * var tension = line.tension();\n *\n * // set tension\n * line.tension(3);\n */\nFactory.addGetterSetter(Line, 'points', [], getNumberArrayValidator());\n/**\n * get/set points array. Points is a flat array [x1, y1, x2, y2]. It is flat for performance reasons.\n * @name Konva.Line#points\n * @method\n * @param {Array} points\n * @returns {Array}\n * @example\n * // get points\n * var points = line.points();\n *\n * // set points\n * line.points([10, 20, 30, 40, 50, 60]);\n *\n * // push a new point\n * line.points(line.points().concat([70, 80]));\n */\n","import { Factory } from \"../Factory.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Util } from \"../Util.js\";\nimport { getCubicArcLength, getCubicExtremaPoints, getQuadraticArcLength, getQuadraticExtremaPoints, t2length, } from \"../BezierFunctions.js\";\n// how many numbers each path command takes\nconst PARAM_COUNT = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n z: 0,\n};\n/**\n * Path constructor.\n * @author Jason Follas\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {String} config.data SVG data string\n * @@shapeParams\n * @@nodeParams\n * @example\n * var path = new Konva.Path({\n * x: 240,\n * y: 40,\n * data: 'M12.582,9.551C3.251,16.237,0.921,29.021,7.08,38.564l-2.36,1.689l4.893,2.262l4.893,2.262l-0.568-5.36l-0.567-5.359l-2.365,1.694c-4.657-7.375-2.83-17.185,4.352-22.33c7.451-5.338,17.817-3.625,23.156,3.824c5.337,7.449,3.625,17.813-3.821,23.152l2.857,3.988c9.617-6.893,11.827-20.277,4.935-29.896C35.591,4.87,22.204,2.658,12.582,9.551z',\n * fill: 'green',\n * scaleX: 2,\n * scaleY: 2\n * });\n */\nexport class Path extends Shape {\n constructor(config) {\n super(config);\n this.dataArray = [];\n this.pathLength = 0;\n this._readDataAttribute();\n this.on('dataChange.konva', function () {\n this._readDataAttribute();\n });\n }\n _readDataAttribute() {\n this.dataArray = Path.parsePathData(this.data());\n this.pathLength = Path.getPathLength(this.dataArray);\n }\n _sceneFunc(context) {\n const ca = this.dataArray;\n // context position\n context.beginPath();\n let isClosed = false;\n for (let n = 0; n < ca.length; n++) {\n const c = ca[n].command;\n const p = ca[n].points;\n switch (c) {\n case 'L':\n context.lineTo(p[0], p[1]);\n break;\n case 'M':\n context.moveTo(p[0], p[1]);\n break;\n case 'C':\n context.bezierCurveTo(p[0], p[1], p[2], p[3], p[4], p[5]);\n break;\n case 'Q':\n context.quadraticCurveTo(p[0], p[1], p[2], p[3]);\n break;\n case 'A':\n const cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];\n const r = rx > ry ? rx : ry;\n const scaleX = rx > ry ? 1 : rx / ry;\n const scaleY = rx > ry ? ry / rx : 1;\n context.translate(cx, cy);\n context.rotate(psi);\n context.scale(scaleX, scaleY);\n context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);\n context.scale(1 / scaleX, 1 / scaleY);\n context.rotate(-psi);\n context.translate(-cx, -cy);\n break;\n case 'z':\n isClosed = true;\n context.closePath();\n break;\n }\n }\n if (!isClosed && !this.hasFill()) {\n context.strokeShape(this);\n }\n else {\n context.fillStrokeShape(this);\n }\n }\n getWidth() {\n return this.getSelfRect().width;\n }\n getHeight() {\n return this.getSelfRect().height;\n }\n getSelfRect() {\n let points = [];\n this.dataArray.forEach(function (data) {\n if (data.command === 'A') {\n // Approximates by breaking curve into line segments\n const start = data.points[4];\n // 4 = theta\n const dTheta = data.points[5];\n // 5 = dTheta\n const end = data.points[4] + dTheta;\n let inc = Math.PI / 180.0;\n // 1 degree resolution\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n if (dTheta < 0) {\n // clockwise\n for (let t = start - inc; t > end; t -= inc) {\n const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, data.points[6]);\n points.push(point.x, point.y);\n }\n }\n else {\n // counter-clockwise\n for (let t = start + inc; t < end; t += inc) {\n const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, data.points[6]);\n points.push(point.x, point.y);\n }\n }\n }\n else if (data.command === 'C') {\n // the two end points, plus the points where the curve turns back on\n // either axis. Together they are the exact bounds of the segment\n points.push(data.start.x, data.start.y, data.points[4], data.points[5], ...getCubicExtremaPoints(data.start.x, data.start.y, data.points[0], data.points[1], data.points[2], data.points[3], data.points[4], data.points[5]));\n }\n else if (data.command === 'Q') {\n // same as 'C'. Note that 'q', 'T' and 't' are all normalised to 'Q' by\n // the parser, so this one branch covers every quadratic segment\n points.push(data.start.x, data.start.y, data.points[2], data.points[3], ...getQuadraticExtremaPoints(data.start.x, data.start.y, data.points[0], data.points[1], data.points[2], data.points[3]));\n }\n else {\n points = points.concat(data.points);\n }\n });\n return Util._getPointsRect(points);\n }\n /**\n * Return length of the path.\n * @method\n * @name Konva.Path#getLength\n * @returns {Number} length\n * @example\n * var length = path.getLength();\n */\n getLength() {\n return this.pathLength;\n }\n /**\n * Get point on path at specific length of the path\n * @method\n * @name Konva.Path#getPointAtLength\n * @param {Number} length length\n * @returns {Object} point {x,y} point\n * @example\n * var point = path.getPointAtLength(10);\n */\n getPointAtLength(length) {\n return Path.getPointAtLengthOfDataArray(length, this.dataArray);\n }\n static getLineLength(x1, y1, x2, y2) {\n return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n }\n static getPathLength(dataArray) {\n let pathLength = 0;\n for (let i = 0; i < dataArray.length; ++i) {\n pathLength += dataArray[i].pathLength;\n }\n return pathLength;\n }\n static getPointAtLengthOfDataArray(length, dataArray) {\n let points, i = 0, ii = dataArray.length;\n if (!ii) {\n return null;\n }\n while (i < ii && length > dataArray[i].pathLength) {\n length -= dataArray[i].pathLength;\n ++i;\n }\n if (i === ii) {\n // past the end: the end of the last segment\n i--;\n while (i > 0 && dataArray[i].points.length < 2) {\n i--;\n }\n length = dataArray[i].pathLength;\n }\n if (length < 0.01) {\n const cmd = dataArray[i].command;\n if (cmd === 'M') {\n points = dataArray[i].points.slice(0, 2);\n return {\n x: points[0],\n y: points[1],\n };\n }\n else {\n return {\n x: dataArray[i].start.x,\n y: dataArray[i].start.y,\n };\n }\n }\n const cp = dataArray[i];\n const p = cp.points;\n switch (cp.command) {\n case 'L':\n return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);\n case 'C':\n return Path.getPointOnCubicBezier(t2length(length, cp.pathLength, (i) => {\n return getCubicArcLength([cp.start.x, p[0], p[2], p[4]], [cp.start.y, p[1], p[3], p[5]], i);\n }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);\n case 'Q':\n return Path.getPointOnQuadraticBezier(t2length(length, cp.pathLength, (i) => {\n return getQuadraticArcLength([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);\n }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);\n case 'A':\n const cx = p[0], cy = p[1], rx = p[2], ry = p[3], dTheta = p[5], psi = p[6];\n let theta = p[4];\n theta += (dTheta * length) / cp.pathLength;\n return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);\n }\n return null;\n }\n static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {\n fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;\n fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;\n const len = this.getLineLength(P1x, P1y, P2x, P2y);\n if (len < 1e-10) {\n return { x: P1x, y: P1y };\n }\n if (P2x === P1x) {\n // Vertical line\n return { x: fromX, y: fromY + (P2y > P1y ? dist : -dist) };\n }\n const m = (P2y - P1y) / (P2x - P1x);\n const run = Math.sqrt((dist * dist) / (1 + m * m)) * (P2x < P1x ? -1 : 1);\n const rise = m * run;\n if (Math.abs(fromY - P1y - m * (fromX - P1x)) < 1e-10) {\n return { x: fromX + run, y: fromY + rise };\n }\n const u = ((fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y)) / (len * len);\n const ix = P1x + u * (P2x - P1x);\n const iy = P1y + u * (P2y - P1y);\n const pRise = this.getLineLength(fromX, fromY, ix, iy);\n const pRun = Math.sqrt(dist * dist - pRise * pRise);\n const adjustedRun = Math.sqrt((pRun * pRun) / (1 + m * m)) * (P2x < P1x ? -1 : 1);\n const adjustedRise = m * adjustedRun;\n return { x: ix + adjustedRun, y: iy + adjustedRise };\n }\n static getPointOnCubicBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {\n function CB1(t) {\n return t * t * t;\n }\n function CB2(t) {\n return 3 * t * t * (1 - t);\n }\n function CB3(t) {\n return 3 * t * (1 - t) * (1 - t);\n }\n function CB4(t) {\n return (1 - t) * (1 - t) * (1 - t);\n }\n const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);\n const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);\n return { x, y };\n }\n static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) {\n function QB1(t) {\n return t * t;\n }\n function QB2(t) {\n return 2 * t * (1 - t);\n }\n function QB3(t) {\n return (1 - t) * (1 - t);\n }\n const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);\n const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);\n return { x, y };\n }\n static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {\n const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);\n const pt = {\n x: rx * Math.cos(theta),\n y: ry * Math.sin(theta),\n };\n return {\n x: cx + (pt.x * cosPsi - pt.y * sinPsi),\n y: cy + (pt.x * sinPsi + pt.y * cosPsi),\n };\n }\n /*\n * get parsed data array from the data\n * string. V, v, H, h, and l data are converted to\n * L data for the purpose of high performance Path\n * rendering\n */\n static parsePathData(data) {\n // Path Data Segment must begin with a moveTo\n //m (x y)+ Relative moveTo (subsequent points are treated as lineTo)\n //M (x y)+ Absolute moveTo (subsequent points are treated as lineTo)\n //l (x y)+ Relative lineTo\n //L (x y)+ Absolute LineTo\n //h (x)+ Relative horizontal lineTo\n //H (x)+ Absolute horizontal lineTo\n //v (y)+ Relative vertical lineTo\n //V (y)+ Absolute vertical lineTo\n //z (closepath)\n //Z (closepath)\n //c (x1 y1 x2 y2 x y)+ Relative Bezier curve\n //C (x1 y1 x2 y2 x y)+ Absolute Bezier curve\n //q (x1 y1 x y)+ Relative Quadratic Bezier\n //Q (x1 y1 x y)+ Absolute Quadratic Bezier\n //t (x y)+ Shorthand/Smooth Relative Quadratic Bezier\n //T (x y)+ Shorthand/Smooth Absolute Quadratic Bezier\n //s (x2 y2 x y)+ Shorthand/Smooth Relative Bezier curve\n //S (x2 y2 x y)+ Shorthand/Smooth Absolute Bezier curve\n //a (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ Relative Elliptical Arc\n //A (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ Absolute Elliptical Arc\n // return early if data is not defined\n if (!data) {\n return [];\n }\n // command string\n let cs = data;\n // command chars\n const cc = [\n 'm',\n 'M',\n 'l',\n 'L',\n 'v',\n 'V',\n 'h',\n 'H',\n 'z',\n 'Z',\n 'c',\n 'C',\n 'q',\n 'Q',\n 't',\n 'T',\n 's',\n 'S',\n 'a',\n 'A',\n ];\n // convert white spaces to commas\n cs = cs.replace(new RegExp(' ', 'g'), ',');\n // create pipes so that we can split the data\n for (let n = 0; n < cc.length; n++) {\n cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);\n }\n // create array\n const arr = cs.split('|');\n const ca = [];\n const coords = [];\n // init context point\n let cpx = 0;\n let cpy = 0;\n const re = /([-+]?((\\d+\\.\\d+)|((\\d+)|(\\.\\d+)))(?:e[-+]?\\d+)?)/gi;\n let match;\n for (let n = 1; n < arr.length; n++) {\n let str = arr[n];\n let c = str.charAt(0);\n str = str.slice(1);\n coords.length = 0;\n while ((match = re.exec(str))) {\n coords.push(match[0]);\n }\n let p = [];\n // Track param position for A/a commands: 0..6 => rx, ry, psi, fa, fs, x, y\n let arcParamIndex = c === 'A' || c === 'a' ? 0 : -1;\n for (let j = 0, jlen = coords.length; j < jlen; j++) {\n let token = coords[j];\n // SVGO merges the arc flags with the number that follows them:\n // \"01.5.5\" is fa=0 fs=1 x=.5 y=.5\n while ((arcParamIndex === 3 || arcParamIndex === 4) &&\n token.length > 1 &&\n (token[0] === '0' || token[0] === '1')) {\n p.push(+token[0]);\n arcParamIndex++;\n token = token.slice(1);\n }\n const parsed = parseFloat(token);\n p.push(isNaN(parsed) ? 0 : parsed);\n if (arcParamIndex >= 0) {\n arcParamIndex = (arcParamIndex + 1) % 7;\n }\n }\n while (p.length > 0) {\n // z takes no numbers, and a command with too few of them (\"L20\"\n // with no y) is dropped rather than parsed into a NaN segment\n if (p.length < PARAM_COUNT[c.toLowerCase()] || c === 'z' || c === 'Z') {\n break;\n }\n let cmd = '';\n let points = [];\n const startX = cpx, startY = cpy;\n // Move var from within the switch to up here (jshint)\n let prevCmd, ctlPtx, ctlPty; // Ss, Tt\n let rx, ry, psi, fa, fs, x1, y1; // Aa\n // convert l, H, h, V, and v to L\n switch (c) {\n // Note: Keep the lineTo's above the moveTo's in this switch\n case 'l':\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'L':\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n // Note: lineTo handlers need to be above this point\n case 'm':\n const dx = p.shift();\n const dy = p.shift();\n cpx += dx;\n cpy += dy;\n cmd = 'M';\n // After closing the path move the current position\n // to the the first point of the path (if any).\n if (ca.length > 2 && ca[ca.length - 1].command === 'z') {\n for (let idx = ca.length - 2; idx >= 0; idx--) {\n if (ca[idx].command === 'M') {\n cpx = ca[idx].points[0] + dx;\n cpy = ca[idx].points[1] + dy;\n break;\n }\n }\n }\n points.push(cpx, cpy);\n c = 'l';\n // subsequent points are treated as relative lineTo\n break;\n case 'M':\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'M';\n points.push(cpx, cpy);\n c = 'L';\n // subsequent points are treated as absolute lineTo\n break;\n case 'h':\n cpx += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'H':\n cpx = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'v':\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'V':\n cpy = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'C':\n points.push(p.shift(), p.shift(), p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'c':\n points.push(cpx + p.shift(), cpy + p.shift(), cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'S':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if ((prevCmd === null || prevCmd === void 0 ? void 0 : prevCmd.command) === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 's':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if ((prevCmd === null || prevCmd === void 0 ? void 0 : prevCmd.command) === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'Q':\n points.push(p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'q':\n points.push(cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(cpx, cpy);\n break;\n case 'T':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if ((prevCmd === null || prevCmd === void 0 ? void 0 : prevCmd.command) === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 't':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if ((prevCmd === null || prevCmd === void 0 ? void 0 : prevCmd.command) === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 'A':\n case 'a':\n rx = p.shift();\n ry = p.shift();\n psi = p.shift();\n fa = p.shift();\n fs = p.shift();\n x1 = cpx;\n y1 = cpy;\n if (c === 'a') {\n cpx += p.shift();\n cpy += p.shift();\n }\n else {\n cpx = p.shift();\n cpy = p.shift();\n }\n cmd = 'A';\n // per SVG, an arc between coincident end points is omitted\n // and a zero radius makes it a straight line\n if (cpx === x1 && cpy === y1) {\n continue;\n }\n else if (!rx || !ry) {\n cmd = 'L';\n points.push(cpx, cpy);\n }\n else {\n points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);\n }\n break;\n }\n ca.push({\n command: cmd || c,\n points: points,\n start: {\n x: startX,\n y: startY,\n },\n pathLength: this.calcLength(startX, startY, cmd || c, points),\n });\n }\n if (c === 'z' || c === 'Z') {\n ca.push({\n command: 'z',\n points: [],\n start: undefined,\n pathLength: 0,\n });\n }\n }\n return ca;\n }\n static calcLength(x, y, cmd, points) {\n let len, p1, p2, t;\n const path = Path;\n switch (cmd) {\n case 'L':\n return path.getLineLength(x, y, points[0], points[1]);\n case 'C':\n return getCubicArcLength([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);\n case 'Q':\n return getQuadraticArcLength([x, points[0], points[2]], [y, points[1], points[3]], 1);\n case 'A':\n // Approximates by breaking curve into line segments\n len = 0.0;\n const start = points[4];\n // 4 = theta\n const dTheta = points[5];\n // 5 = dTheta\n const end = points[4] + dTheta;\n let inc = Math.PI / 180.0;\n // 1 degree resolution\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n // the arc length does not depend on the x-axis rotation psi, so it is left out\n p1 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], start, 0);\n if (dTheta < 0) {\n // clockwise\n for (t = start - inc; t > end; t -= inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n else {\n // counter-clockwise\n for (t = start + inc; t < end; t += inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], end, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n return len;\n }\n return 0;\n }\n static convertEndpointToCenterParameterization(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {\n // Derived from: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes\n const psi = psiDeg * (Math.PI / 180.0);\n const xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;\n const yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +\n (Math.cos(psi) * (y1 - y2)) / 2.0;\n const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n let f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /\n (rx * rx * (yp * yp) + ry * ry * (xp * xp)));\n if (fa === fs) {\n f *= -1;\n }\n if (isNaN(f)) {\n f = 0;\n }\n const cxp = (f * rx * yp) / ry;\n const cyp = (f * -ry * xp) / rx;\n const cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;\n const cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;\n const vMag = function (v) {\n return Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n };\n const vRatio = function (u, v) {\n return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));\n };\n const vAngle = function (u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));\n };\n const theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);\n const u = [(xp - cxp) / rx, (yp - cyp) / ry];\n const v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];\n let dTheta = vAngle(u, v);\n if (vRatio(u, v) <= -1) {\n dTheta = Math.PI;\n }\n if (vRatio(u, v) >= 1) {\n dTheta = 0;\n }\n if (fs === 0 && dTheta > 0) {\n dTheta = dTheta - 2 * Math.PI;\n }\n if (fs === 1 && dTheta < 0) {\n dTheta = dTheta + 2 * Math.PI;\n }\n return [cx, cy, rx, ry, theta, dTheta, psi, fs];\n }\n}\nPath.prototype.className = 'Path';\nPath.prototype._attrsAffectingSize = ['data'];\n_registerNode(Path);\n/**\n * get/set SVG path data string. This method\n * also automatically parses the data string\n * into a data array. Currently supported SVG data:\n * M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z\n * @name Konva.Path#data\n * @method\n * @param {String} data svg path string\n * @returns {String}\n * @example\n * // get data\n * var data = path.data();\n *\n * // set data\n * path.data('M200,100h100v50z');\n */\nFactory.addGetterSetter(Path, 'data');\n/**\n * get width of the path. It is computed from the path data and cannot be set\n * @name Konva.Path#width\n * @method\n * @returns {Number}\n * @example\n * var width = path.width();\n */\n/**\n * get height of the path. It is computed from the path data and cannot be set\n * @name Konva.Path#height\n * @method\n * @returns {Number}\n * @example\n * var height = path.height();\n */\n","import { Factory } from \"../Factory.js\";\nimport { Line } from \"./Line.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { Path } from \"./Path.js\";\n/**\n * Arrow constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Line\n * @param {Object} config\n * @param {Array} config.points Flat array of points coordinates. You should define them as [x1, y1, x2, y2, x3, y3].\n * @param {Number} [config.tension] Higher values will result in a more curvy line. A value of 0 will result in no interpolation.\n * The default is 0\n * @param {Number} config.pointerLength Arrow pointer length. Default value is 10.\n * @param {Number} config.pointerWidth Arrow pointer width. Default value is 10.\n * @param {Boolean} config.pointerAtBeginning Do we need to draw pointer on beginning position?. Default false.\n * @param {Boolean} config.pointerAtEnding Do we need to draw pointer on ending position?. Default true.\n * @@shapeParams\n * @@nodeParams\n * @example\n * var line = new Konva.Line({\n * points: [73, 70, 340, 23, 450, 60, 500, 20],\n * stroke: 'red',\n * tension: 1,\n * pointerLength : 10,\n * pointerWidth : 12\n * });\n */\nexport class Arrow extends Line {\n _sceneFunc(ctx) {\n super._sceneFunc(ctx);\n const PI2 = Math.PI * 2;\n const points = this.points();\n let tp = points;\n const fromTension = this.tension() !== 0 && points.length > 4;\n if (fromTension) {\n tp = this.getTensionPoints();\n }\n const length = this.pointerLength();\n const n = points.length;\n let dx, dy;\n if (fromTension) {\n const lp = [\n tp[tp.length - 4],\n tp[tp.length - 3],\n tp[tp.length - 2],\n tp[tp.length - 1],\n points[n - 2],\n points[n - 1],\n ];\n const lastLength = Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);\n const previous = Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);\n dx = points[n - 2] - previous.x;\n dy = points[n - 1] - previous.y;\n }\n else {\n dx = points[n - 2] - points[n - 4];\n dy = points[n - 1] - points[n - 3];\n }\n const radians = (Math.atan2(dy, dx) + PI2) % PI2;\n const width = this.pointerWidth();\n if (this.pointerAtEnding()) {\n ctx.save();\n ctx.beginPath();\n ctx.translate(points[n - 2], points[n - 1]);\n ctx.rotate(radians);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n this.__fillStroke(ctx);\n }\n if (this.pointerAtBeginning()) {\n ctx.save();\n ctx.beginPath();\n ctx.translate(points[0], points[1]);\n if (fromTension) {\n dx = (tp[0] + tp[2]) / 2 - points[0];\n dy = (tp[1] + tp[3]) / 2 - points[1];\n }\n else {\n dx = points[2] - points[0];\n dy = points[3] - points[1];\n }\n ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n this.__fillStroke(ctx);\n }\n }\n __fillStroke(ctx) {\n // here is a tricky part\n // we need to disable dash for arrow pointers\n const isDashEnabled = this.dashEnabled();\n if (isDashEnabled) {\n // manually disable dash for head\n // it is better not to use setter here,\n // because it will trigger attr change event\n this.attrs.dashEnabled = false;\n ctx.setLineDash([]);\n }\n ctx.fillStrokeShape(this);\n // restore old value\n if (isDashEnabled) {\n this.attrs.dashEnabled = true;\n }\n }\n getSelfRect() {\n const lineRect = super.getSelfRect();\n const offset = this.pointerWidth() / 2;\n return {\n x: lineRect.x,\n y: lineRect.y - offset,\n width: lineRect.width,\n height: lineRect.height + offset * 2,\n };\n }\n}\nArrow.prototype.className = 'Arrow';\n_registerNode(Arrow);\n/**\n * get/set pointerLength\n * @name Konva.Arrow#pointerLength\n * @method\n * @param {Number} Length of pointer of arrow. The default is 10.\n * @returns {Number}\n * @example\n * // get length\n * var pointerLength = line.pointerLength();\n *\n * // set length\n * line.pointerLength(15);\n */\nFactory.addGetterSetter(Arrow, 'pointerLength', 10, getNumberValidator());\n/**\n * get/set pointerWidth\n * @name Konva.Arrow#pointerWidth\n * @method\n * @param {Number} Width of pointer of arrow.\n * The default is 10.\n * @returns {Number}\n * @example\n * // get width\n * var pointerWidth = line.pointerWidth();\n *\n * // set width\n * line.pointerWidth(15);\n */\nFactory.addGetterSetter(Arrow, 'pointerWidth', 10, getNumberValidator());\n/**\n * get/set pointerAtBeginning\n * @name Konva.Arrow#pointerAtBeginning\n * @method\n * @param {Number} Should pointer displayed at beginning of arrow. The default is false.\n * @returns {Boolean}\n * @example\n * // get value\n * var pointerAtBeginning = line.pointerAtBeginning();\n *\n * // set value\n * line.pointerAtBeginning(true);\n */\nFactory.addGetterSetter(Arrow, 'pointerAtBeginning', false);\n/**\n * get/set pointerAtEnding\n * @name Konva.Arrow#pointerAtEnding\n * @method\n * @param {Number} Should pointer displayed at ending of arrow. The default is true.\n * @returns {Boolean}\n * @example\n * // get value\n * var pointerAtEnding = line.pointerAtEnding();\n *\n * // set value\n * line.pointerAtEnding(false);\n */\nFactory.addGetterSetter(Arrow, 'pointerAtEnding', true);\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Circle constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Number} config.radius\n * @@shapeParams\n * @@nodeParams\n * @example\n * // create circle\n * var circle = new Konva.Circle({\n * radius: 40,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 5\n * });\n */\nexport class Circle extends Shape {\n _sceneFunc(context) {\n context.beginPath();\n context.arc(0, 0, Math.abs(this.attrs.radius || 0), 0, Math.PI * 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return Math.abs(this.radius()) * 2;\n }\n getHeight() {\n return Math.abs(this.radius()) * 2;\n }\n setWidth(width) {\n this.radius(width / 2);\n }\n setHeight(height) {\n this.radius(height / 2);\n }\n}\nCircle.prototype._centroid = true;\nCircle.prototype.className = 'Circle';\nCircle.prototype._attrsAffectingSize = ['radius'];\n_registerNode(Circle);\n/**\n * get/set radius\n * @name Konva.Circle#radius\n * @method\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get radius\n * var radius = circle.radius();\n *\n * // set radius\n * circle.radius(10);\n */\nFactory.addGetterSetter(Circle, 'radius', 0, getNumberValidator());\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Ellipse constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Object} config.radius defines x and y radius\n * @@shapeParams\n * @@nodeParams\n * @example\n * var ellipse = new Konva.Ellipse({\n * radius : {\n * x : 50,\n * y : 50\n * },\n * fill: 'red'\n * });\n */\nexport class Ellipse extends Shape {\n _sceneFunc(context) {\n const rx = Math.abs(this.radiusX()), ry = Math.abs(this.radiusY());\n context.beginPath();\n context.ellipse(0, 0, rx, ry, 0, 0, Math.PI * 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return Math.abs(this.radiusX()) * 2;\n }\n getHeight() {\n return Math.abs(this.radiusY()) * 2;\n }\n setWidth(width) {\n this.radiusX(width / 2);\n }\n setHeight(height) {\n this.radiusY(height / 2);\n }\n}\nEllipse.prototype.className = 'Ellipse';\nEllipse.prototype._centroid = true;\nEllipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];\n_registerNode(Ellipse);\n// add getters setters\nFactory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);\n/**\n * get/set radius\n * @name Konva.Ellipse#radius\n * @method\n * @param {Object} radius\n * @param {Number} radius.x\n * @param {Number} radius.y\n * @returns {Object}\n * @example\n * // get radius\n * var radius = ellipse.radius();\n *\n * // set radius\n * ellipse.radius({\n * x: 200,\n * y: 100\n * });\n */\nFactory.addGetterSetter(Ellipse, 'radiusX', 0, getNumberValidator());\n/**\n * get/set radius x\n * @name Konva.Ellipse#radiusX\n * @method\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get radius x\n * var radiusX = ellipse.radiusX();\n *\n * // set radius x\n * ellipse.radiusX(200);\n */\nFactory.addGetterSetter(Ellipse, 'radiusY', 0, getNumberValidator());\n/**\n * get/set radius y\n * @name Konva.Ellipse#radiusY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get radius y\n * var radiusY = ellipse.radiusY();\n *\n * // set radius y\n * ellipse.radiusY(200);\n */\n","import { Util } from \"../Util.js\";\nimport { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from \"../Validators.js\";\n/**\n * Image constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Image} config.image\n * @param {Object} [config.crop]\n * @@shapeParams\n * @@nodeParams\n * @example\n * var imageObj = new Image();\n * imageObj.onload = function() {\n * var image = new Konva.Image({\n * x: 200,\n * y: 50,\n * image: imageObj,\n * width: 100,\n * height: 100\n * });\n * };\n * imageObj.src = '/path/to/image.jpg'\n */\nexport class Image extends Shape {\n constructor(attrs) {\n super(attrs);\n this._loadListener = () => {\n this._requestDraw();\n };\n this.on('imageChange.konva', (props) => {\n this._removeImageLoad(props.oldVal);\n this._setImageLoad();\n });\n this._setImageLoad();\n }\n _setImageLoad() {\n const image = this.image();\n // check is image is already loaded\n if (image && image.complete) {\n return;\n }\n // check is video is already loaded\n if (image && image.readyState === 4) {\n return;\n }\n if (image && image['addEventListener']) {\n image['addEventListener']('load', this._loadListener);\n }\n }\n _removeImageLoad(image) {\n if (image && image['removeEventListener']) {\n image['removeEventListener']('load', this._loadListener);\n }\n }\n destroy() {\n this._removeImageLoad(this.image());\n super.destroy();\n return this;\n }\n _useBufferCanvas() {\n const hasCornerRadius = !!this.cornerRadius();\n const hasShadow = this.hasShadow();\n if (hasCornerRadius && hasShadow) {\n return true;\n }\n return super._useBufferCanvas(true);\n }\n _sceneFunc(context) {\n const width = this.getWidth();\n const height = this.getHeight();\n const cornerRadius = this.cornerRadius();\n const image = this.attrs.image;\n if (this.hasFill() || this.hasStroke() || cornerRadius) {\n context.beginPath();\n cornerRadius\n ? Util.drawRoundedRectPath(context, width, height, cornerRadius)\n : context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n if (cornerRadius) {\n context.clip();\n }\n const cropWidth = this.attrs.cropWidth;\n const cropHeight = this.attrs.cropHeight;\n if (cropWidth && cropHeight) {\n context.drawImage(image, this.cropX(), this.cropY(), cropWidth, cropHeight, 0, 0, width, height);\n }\n else {\n context.drawImage(image, 0, 0, width, height);\n }\n }\n // If you need to draw later, you need to execute save/restore\n }\n _hitFunc(context) {\n const width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();\n context.beginPath();\n if (!cornerRadius) {\n context.rect(0, 0, width, height);\n }\n else {\n Util.drawRoundedRectPath(context, width, height, cornerRadius);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n var _a, _b, _c;\n return (_c = (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;\n }\n getHeight() {\n var _a, _b, _c;\n return (_c = (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 0;\n }\n /**\n * load image from given url and create `Konva.Image` instance\n * @method\n * @memberof Konva.Image\n * @param {String} url image source\n * @param {Function} callback with Konva.Image instance as first argument\n * @param {Function} onError optional error handler\n * @example\n * Konva.Image.fromURL(imageURL, function(image){\n * // image is Konva.Image instance\n * layer.add(image);\n * });\n */\n static fromURL(url, callback, onError = null) {\n const img = Util.createImageElement();\n img.onload = function () {\n const image = new Image({\n image: img,\n });\n callback(image);\n };\n img.onerror = onError;\n img.crossOrigin = 'Anonymous';\n img.src = url;\n }\n}\nImage.prototype.className = 'Image';\nImage.prototype._attrsAffectingSize = ['image'];\n_registerNode(Image);\n/**\n * get/set corner radius\n * @method\n * @name Konva.Image#cornerRadius\n * @param {Number} cornerRadius\n * @returns {Number}\n * @example\n * // get corner radius\n * var cornerRadius = image.cornerRadius();\n *\n * // set corner radius\n * image.cornerRadius(10);\n *\n * // set different corner radius values\n * // top-left, top-right, bottom-right, bottom-left\n * image.cornerRadius([0, 10, 20, 30]);\n */\nFactory.addGetterSetter(Image, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));\n/**\n * get/set image source. It can be image, canvas or video element\n * @name Konva.Image#image\n * @method\n * @param {Object} image source\n * @returns {Object}\n * @example\n * // get value\n * var image = shape.image();\n *\n * // set value\n * shape.image(img);\n */\nFactory.addGetterSetter(Image, 'image');\nFactory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);\n/**\n * get/set crop\n * @method\n * @name Konva.Image#crop\n * @param {Object} crop\n * @param {Number} crop.x\n * @param {Number} crop.y\n * @param {Number} crop.width\n * @param {Number} crop.height\n * @returns {Object}\n * @example\n * // get crop\n * var crop = image.crop();\n *\n * // set crop\n * image.crop({\n * x: 20,\n * y: 20,\n * width: 20,\n * height: 20\n * });\n */\nFactory.addGetterSetter(Image, 'cropX', 0, getNumberValidator());\n/**\n * get/set crop x\n * @method\n * @name Konva.Image#cropX\n * @param {Number} x\n * @returns {Number}\n * @example\n * // get crop x\n * var cropX = image.cropX();\n *\n * // set crop x\n * image.cropX(20);\n */\nFactory.addGetterSetter(Image, 'cropY', 0, getNumberValidator());\n/**\n * get/set crop y\n * @name Konva.Image#cropY\n * @method\n * @param {Number} y\n * @returns {Number}\n * @example\n * // get crop y\n * var cropY = image.cropY();\n *\n * // set crop y\n * image.cropY(20);\n */\nFactory.addGetterSetter(Image, 'cropWidth', 0, getNumberValidator());\n/**\n * get/set crop width\n * @name Konva.Image#cropWidth\n * @method\n * @param {Number} width\n * @returns {Number}\n * @example\n * // get crop width\n * var cropWidth = image.cropWidth();\n *\n * // set crop width\n * image.cropWidth(20);\n */\nFactory.addGetterSetter(Image, 'cropHeight', 0, getNumberValidator());\n/**\n * get/set crop height\n * @name Konva.Image#cropHeight\n * @method\n * @param {Number} height\n * @returns {Number}\n * @example\n * // get crop height\n * var cropHeight = image.cropHeight();\n *\n * // set crop height\n * image.cropHeight(20);\n */\n","import { Factory } from \"../Factory.js\";\nimport { Util } from \"../Util.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Group } from \"../Group.js\";\nimport { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n// constants\nconst ATTR_CHANGE_LIST = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'padding',\n 'lineHeight',\n 'text',\n 'width',\n 'height',\n 'pointerDirection',\n 'pointerWidth',\n 'pointerHeight',\n], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', \n// cached variables\nattrChangeListLen = ATTR_CHANGE_LIST.length;\n/**\n * Label constructor. Labels are groups that contain a Text and Tag shape\n * @constructor\n * @memberof Konva\n * @param {Object} config\n * @@nodeParams\n * @example\n * // create label\n * var label = new Konva.Label({\n * x: 100,\n * y: 100,\n * draggable: true\n * });\n *\n * // add a tag to the label\n * label.add(new Konva.Tag({\n * fill: '#bbb',\n * stroke: '#333',\n * shadowColor: 'black',\n * shadowBlur: 10,\n * shadowOffset: [10, 10],\n * shadowOpacity: 0.2,\n * lineJoin: 'round',\n * pointerDirection: 'up',\n * pointerWidth: 20,\n * pointerHeight: 20,\n * cornerRadius: 5\n * }));\n *\n * // add text to the label\n * label.add(new Konva.Text({\n * text: 'Hello World!',\n * fontSize: 50,\n * lineHeight: 1.2,\n * padding: 10,\n * fill: 'green'\n * }));\n */\nexport class Label extends Group {\n constructor(config) {\n super(config);\n this.on('add.konva', function (evt) {\n this._addListeners(evt.child);\n this._sync();\n });\n }\n /**\n * get Text shape for the label. You need to access the Text shape in order to update\n * the text properties\n * @name Konva.Label#getText\n * @method\n * @example\n * label.getText().fill('red')\n */\n getText() {\n return this.find('Text')[0];\n }\n /**\n * get Tag shape for the label. You need to access the Tag shape in order to update\n * the pointer properties and the corner radius\n * @name Konva.Label#getTag\n * @method\n */\n getTag() {\n return this.find('Tag')[0];\n }\n _addListeners(text) {\n let that = this, n;\n const func = function () {\n that._sync();\n };\n // update text data for certain attr changes\n for (n = 0; n < attrChangeListLen; n++) {\n text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);\n }\n }\n getWidth() {\n return this.getText().width();\n }\n getHeight() {\n return this.getText().height();\n }\n _sync() {\n let text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;\n if (text && tag) {\n width = text.width();\n height = text.height();\n pointerDirection = tag.pointerDirection();\n pointerWidth = tag.pointerWidth();\n pointerHeight = tag.pointerHeight();\n x = 0;\n y = 0;\n switch (pointerDirection) {\n case UP:\n x = width / 2;\n y = -1 * pointerHeight;\n break;\n case RIGHT:\n x = width + pointerWidth;\n y = height / 2;\n break;\n case DOWN:\n x = width / 2;\n y = height + pointerHeight;\n break;\n case LEFT:\n x = -1 * pointerWidth;\n y = height / 2;\n break;\n }\n tag.setAttrs({\n x: -1 * x,\n y: -1 * y,\n width: width,\n height: height,\n });\n text.setAttrs({\n x: -1 * x,\n y: -1 * y,\n });\n }\n }\n}\nLabel.prototype.className = 'Label';\n_registerNode(Label);\n/**\n * Tag constructor. A Tag can be configured\n * to have a pointer element that points up, right, down, or left\n * @constructor\n * @memberof Konva\n * @param {Object} config\n * @param {String} [config.pointerDirection] can be up, right, down, left, or none; the default\n * is none. When a pointer is present, the positioning of the label is relative to the tip of the pointer.\n * @param {Number} [config.pointerWidth]\n * @param {Number} [config.pointerHeight]\n * @param {Number} [config.cornerRadius]\n */\nexport class Tag extends Shape {\n _sceneFunc(context) {\n const width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();\n const [topLeft, topRight, bottomRight, bottomLeft] = Util._cornerRadii(cornerRadius, width, height);\n context.beginPath();\n context.moveTo(topLeft, 0);\n if (pointerDirection === UP) {\n context.lineTo((width - pointerWidth) / 2, 0);\n context.lineTo(width / 2, -1 * pointerHeight);\n context.lineTo((width + pointerWidth) / 2, 0);\n }\n context.lineTo(width - topRight, 0);\n context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);\n if (pointerDirection === RIGHT) {\n context.lineTo(width, (height - pointerHeight) / 2);\n context.lineTo(width + pointerWidth, height / 2);\n context.lineTo(width, (height + pointerHeight) / 2);\n }\n context.lineTo(width, height - bottomRight);\n context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);\n if (pointerDirection === DOWN) {\n context.lineTo((width + pointerWidth) / 2, height);\n context.lineTo(width / 2, height + pointerHeight);\n context.lineTo((width - pointerWidth) / 2, height);\n }\n context.lineTo(bottomLeft, height);\n context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);\n if (pointerDirection === LEFT) {\n context.lineTo(0, (height + pointerHeight) / 2);\n context.lineTo(-1 * pointerWidth, height / 2);\n context.lineTo(0, (height - pointerHeight) / 2);\n }\n context.lineTo(0, topLeft);\n context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getSelfRect() {\n let x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();\n if (direction === UP) {\n y -= pointerHeight;\n height += pointerHeight;\n }\n else if (direction === DOWN) {\n height += pointerHeight;\n }\n else if (direction === LEFT) {\n x -= pointerWidth;\n width += pointerWidth;\n }\n else if (direction === RIGHT) {\n width += pointerWidth;\n }\n return {\n x: x,\n y: y,\n width: width,\n height: height,\n };\n }\n}\nTag.prototype.className = 'Tag';\n_registerNode(Tag);\n/**\n * get/set pointer direction\n * @name Konva.Tag#pointerDirection\n * @method\n * @param {String} pointerDirection can be up, right, down, left, or none. The default is none.\n * @returns {String}\n * @example\n * tag.pointerDirection('right');\n */\nFactory.addGetterSetter(Tag, 'pointerDirection', NONE);\n/**\n * get/set pointer width\n * @name Konva.Tag#pointerWidth\n * @method\n * @param {Number} pointerWidth\n * @returns {Number}\n * @example\n * tag.pointerWidth(20);\n */\nFactory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());\n/**\n * get/set pointer height\n * @method\n * @name Konva.Tag#pointerHeight\n * @param {Number} pointerHeight\n * @returns {Number}\n * @example\n * tag.pointerHeight(20);\n */\nFactory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());\n/**\n * get/set cornerRadius\n * @name Konva.Tag#cornerRadius\n * @method\n * @param {Number} cornerRadius\n * @returns {Number}\n * @example\n * tag.cornerRadius(20);\n *\n * // set different corner radius values\n * // top-left, top-right, bottom-right, bottom-left\n * tag.cornerRadius([0, 10, 20, 30]);\n */\nFactory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { Util } from \"../Util.js\";\nimport { getNumberOrArrayOfNumbersValidator } from \"../Validators.js\";\n/**\n * Rect constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Number} [config.cornerRadius]\n * @@shapeParams\n * @@nodeParams\n * @example\n * var rect = new Konva.Rect({\n * width: 100,\n * height: 50,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 5\n * });\n */\nexport class Rect extends Shape {\n _sceneFunc(context) {\n const cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();\n context.beginPath();\n if (!cornerRadius) {\n // simple rect - don't bother doing all that complicated maths stuff.\n context.rect(0, 0, width, height);\n }\n else {\n Util.drawRoundedRectPath(context, width, height, cornerRadius);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n}\nRect.prototype.className = 'Rect';\n_registerNode(Rect);\n/**\n * get/set corner radius\n * @method\n * @name Konva.Rect#cornerRadius\n * @param {Number} cornerRadius\n * @returns {Number}\n * @example\n * // get corner radius\n * var cornerRadius = rect.cornerRadius();\n *\n * // set corner radius\n * rect.cornerRadius(10);\n *\n * // set different corner radius values\n * // top-left, top-right, bottom-right, bottom-left\n * rect.cornerRadius([0, 10, 20, 30]);\n */\nFactory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\nimport { Util } from \"../Util.js\";\n/**\n * RegularPolygon constructor. Examples include triangles, squares, pentagons, hexagons, etc.\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Number} [config.cornerRadius]\n * @param {Number} config.sides\n * @param {Number} config.radius\n * @@shapeParams\n * @@nodeParams\n * @example\n * var hexagon = new Konva.RegularPolygon({\n * x: 100,\n * y: 200,\n * sides: 6,\n * radius: 70,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 4\n * });\n */\nexport class RegularPolygon extends Shape {\n _sceneFunc(context) {\n const points = this._getPoints(), radius = this.radius(), sides = this.sides(), cornerRadius = this.cornerRadius();\n if (!points.length) {\n return;\n }\n context.beginPath();\n if (!cornerRadius) {\n context.moveTo(points[0].x, points[0].y);\n for (let n = 1; n < points.length; n++) {\n context.lineTo(points[n].x, points[n].y);\n }\n }\n else {\n Util.drawRoundedPolygonPath(context, points, sides, radius, cornerRadius);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n _getPoints() {\n const sides = this.attrs.sides;\n const radius = this.attrs.radius || 0;\n const points = [];\n for (let n = 0; n < sides; n++) {\n points.push({\n x: radius * Math.sin((n * 2 * Math.PI) / sides),\n y: -1 * radius * Math.cos((n * 2 * Math.PI) / sides),\n });\n }\n return points;\n }\n getSelfRect() {\n const points = this._getPoints();\n if (!points.length) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n let minX = points[0].x;\n let maxX = points[0].x;\n let minY = points[0].y;\n let maxY = points[0].y;\n points.forEach((point) => {\n minX = Math.min(minX, point.x);\n maxX = Math.max(maxX, point.x);\n minY = Math.min(minY, point.y);\n maxY = Math.max(maxY, point.y);\n });\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n getWidth() {\n return this.radius() * 2;\n }\n getHeight() {\n return this.radius() * 2;\n }\n setWidth(width) {\n this.radius(width / 2);\n }\n setHeight(height) {\n this.radius(height / 2);\n }\n}\nRegularPolygon.prototype.className = 'RegularPolygon';\nRegularPolygon.prototype._centroid = true;\nRegularPolygon.prototype._attrsAffectingSize = ['radius'];\n_registerNode(RegularPolygon);\n/**\n * get/set radius\n * @method\n * @name Konva.RegularPolygon#radius\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get radius\n * var radius = shape.radius();\n *\n * // set radius\n * shape.radius(10);\n */\nFactory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());\n/**\n * get/set sides\n * @method\n * @name Konva.RegularPolygon#sides\n * @param {Number} sides\n * @returns {Number}\n * @example\n * // get sides\n * var sides = shape.sides();\n *\n * // set sides\n * shape.sides(10);\n */\nFactory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());\n/**\n * get/set corner radius\n * @method\n * @name Konva.RegularPolygon#cornerRadius\n * @param {Number} cornerRadius\n * @returns {Number}\n * @example\n * // get corner radius\n * var cornerRadius = poly.cornerRadius();\n *\n * // set corner radius\n * poly.cornerRadius(10);\n *\n * // set different corner radius values (pentagon)\n * poly.cornerRadius([0, 10, 20, 30, 40]);\n */\nFactory.addGetterSetter(RegularPolygon, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\nconst PIx2 = Math.PI * 2;\n/**\n * Ring constructor\n * @constructor\n * @augments Konva.Shape\n * @memberof Konva\n * @param {Object} config\n * @param {Number} config.innerRadius\n * @param {Number} config.outerRadius\n * @@shapeParams\n * @@nodeParams\n * @example\n * var ring = new Konva.Ring({\n * innerRadius: 40,\n * outerRadius: 80,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 5\n * });\n */\nexport class Ring extends Shape {\n _sceneFunc(context) {\n const innerRadius = Math.abs(this.innerRadius()), outerRadius = Math.abs(this.outerRadius());\n context.beginPath();\n context.arc(0, 0, innerRadius, 0, PIx2, false);\n context.moveTo(outerRadius, 0);\n context.arc(0, 0, outerRadius, PIx2, 0, true);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return Math.abs(this.outerRadius()) * 2;\n }\n getHeight() {\n return Math.abs(this.outerRadius()) * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n}\nRing.prototype.className = 'Ring';\nRing.prototype._centroid = true;\nRing.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\n_registerNode(Ring);\n/**\n * get/set innerRadius\n * @method\n * @name Konva.Ring#innerRadius\n * @param {Number} innerRadius\n * @returns {Number}\n * @example\n * // get inner radius\n * var innerRadius = ring.innerRadius();\n *\n * // set inner radius\n * ring.innerRadius(20);\n */\nFactory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());\n/**\n * get/set outerRadius\n * @name Konva.Ring#outerRadius\n * @method\n * @param {Number} outerRadius\n * @returns {Number}\n * @example\n * // get outer radius\n * var outerRadius = ring.outerRadius();\n *\n * // set outer radius\n * ring.outerRadius(20);\n */\nFactory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Animation } from \"../Animation.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Sprite constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {String} config.animation animation key\n * @param {Object} config.animations animation map\n * @param {Integer} [config.frameIndex] animation frame index\n * @param {Image} config.image image object\n * @param {Integer} [config.frameRate] animation frame rate\n * @@shapeParams\n * @@nodeParams\n * @example\n * var imageObj = new Image();\n * imageObj.onload = function() {\n * var sprite = new Konva.Sprite({\n * x: 200,\n * y: 100,\n * image: imageObj,\n * animation: 'standing',\n * animations: {\n * standing: [\n * // x, y, width, height (6 frames)\n * 0, 0, 49, 109,\n * 52, 0, 49, 109,\n * 105, 0, 49, 109,\n * 158, 0, 49, 109,\n * 210, 0, 49, 109,\n * 262, 0, 49, 109\n * ],\n * kicking: [\n * // x, y, width, height (6 frames)\n * 0, 109, 45, 98,\n * 45, 109, 45, 98,\n * 95, 109, 63, 98,\n * 156, 109, 70, 98,\n * 229, 109, 60, 98,\n * 287, 109, 41, 98\n * ]\n * },\n * frameRate: 7,\n * frameIndex: 0\n * });\n * };\n * imageObj.src = '/path/to/image.jpg'\n */\nexport class Sprite extends Shape {\n constructor(config) {\n super(config);\n this._updated = true;\n this.anim = new Animation(() => {\n // if we don't need to redraw layer we should return false\n const updated = this._updated;\n this._updated = false;\n return updated;\n });\n this.on('animationChange.konva', function () {\n // reset index when animation changes\n this.frameIndex(0);\n });\n this.on('frameIndexChange.konva', function () {\n this._updated = true;\n });\n // smooth change for frameRate\n this.on('frameRateChange.konva', function () {\n if (!this.anim.isRunning()) {\n return;\n }\n clearInterval(this.interval);\n this._setInterval();\n });\n }\n // the current frame: its box in the sprite sheet and where it is drawn,\n // or nothing when the animation key or the frame index does not exist\n // (then nothing is drawn, like an image without an image)\n _getFrame() {\n var _a, _b;\n const anim = this.animation(), set = (_a = this.animations()) === null || _a === void 0 ? void 0 : _a[anim], index = this.frameIndex(), ix4 = index * 4;\n if (!set || !Number.isInteger(index) || ix4 < 0 || ix4 + 4 > set.length) {\n return;\n }\n const offset = ((_b = this.frameOffsets()) === null || _b === void 0 ? void 0 : _b[anim]) || [];\n return {\n x: set[ix4],\n y: set[ix4 + 1],\n width: set[ix4 + 2],\n height: set[ix4 + 3],\n offsetX: offset[index * 2] || 0,\n offsetY: offset[index * 2 + 1] || 0,\n };\n }\n _sceneFunc(context) {\n const frame = this._getFrame();\n if (!frame) {\n return;\n }\n const { x, y, width, height, offsetX, offsetY } = frame;\n const image = this.image();\n if (this.hasFill() || this.hasStroke()) {\n context.beginPath();\n context.rect(offsetX, offsetY, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n context.drawImage(image, x, y, width, height, offsetX, offsetY, width, height);\n }\n }\n _hitFunc(context) {\n const { x, y, width, height } = this.getSelfRect();\n context.beginPath();\n context.rect(x, y, width, height);\n context.closePath();\n context.fillShape(this);\n }\n getSelfRect() {\n const frame = this._getFrame();\n return frame\n ? {\n x: frame.offsetX,\n y: frame.offsetY,\n width: frame.width,\n height: frame.height,\n }\n : { x: 0, y: 0, width: 0, height: 0 };\n }\n _useBufferCanvas() {\n return super._useBufferCanvas(true);\n }\n _setInterval() {\n const that = this;\n this.interval = setInterval(function () {\n that._updateIndex();\n }, 1000 / this.frameRate());\n }\n /**\n * start sprite animation\n * @method\n * @name Konva.Sprite#start\n */\n start() {\n if (this.isRunning()) {\n return;\n }\n const layer = this.getLayer();\n /*\n * animation object has no executable function because\n * the updates are done with a fixed FPS with the setInterval\n * below. The anim object only needs the layer reference for\n * redraw\n */\n this.anim.setLayers(layer);\n this._setInterval();\n this.anim.start();\n }\n /**\n * stop sprite animation\n * @method\n * @name Konva.Sprite#stop\n */\n stop() {\n this.anim.stop();\n clearInterval(this.interval);\n }\n destroy() {\n this.stop();\n return super.destroy();\n }\n /**\n * determine if animation of sprite is running or not. returns true or false\n * @method\n * @name Konva.Sprite#isRunning\n * @returns {Boolean}\n */\n isRunning() {\n return this.anim.isRunning();\n }\n _updateIndex() {\n var _a;\n const index = this.frameIndex(), set = (_a = this.animations()) === null || _a === void 0 ? void 0 : _a[this.animation()], len = set ? set.length / 4 : 0;\n this.frameIndex(index < len - 1 ? index + 1 : 0);\n }\n}\nSprite.prototype.className = 'Sprite';\n_registerNode(Sprite);\n// add getters setters\nFactory.addGetterSetter(Sprite, 'animation');\n/**\n * get/set animation key\n * @name Konva.Sprite#animation\n * @method\n * @param {String} anim animation key\n * @returns {String}\n * @example\n * // get animation key\n * var animation = sprite.animation();\n *\n * // set animation key\n * sprite.animation('kicking');\n */\nFactory.addGetterSetter(Sprite, 'animations');\n/**\n * get/set animations map\n * @name Konva.Sprite#animations\n * @method\n * @param {Object} animations\n * @returns {Object}\n * @example\n * // get animations map\n * var animations = sprite.animations();\n *\n * // set animations map\n * sprite.animations({\n * standing: [\n * // x, y, width, height (6 frames)\n * 0, 0, 49, 109,\n * 52, 0, 49, 109,\n * 105, 0, 49, 109,\n * 158, 0, 49, 109,\n * 210, 0, 49, 109,\n * 262, 0, 49, 109\n * ],\n * kicking: [\n * // x, y, width, height (6 frames)\n * 0, 109, 45, 98,\n * 45, 109, 45, 98,\n * 95, 109, 63, 98,\n * 156, 109, 70, 98,\n * 229, 109, 60, 98,\n * 287, 109, 41, 98\n * ]\n * });\n */\nFactory.addGetterSetter(Sprite, 'frameOffsets');\n/**\n * get/set frame offsets map\n * @name Konva.Sprite#frameOffsets\n * @method\n * @param {Object} frameOffsets\n * @returns {Object}\n * @example\n * // get frame offsets map\n * var offsets = sprite.frameOffsets();\n *\n * // set frame offsets map\n * sprite.frameOffsets({\n * standing: [\n * // x, y (6 frames)\n * 0, 0,\n * 0, 0,\n * 5, 0,\n * 0, 0,\n * 0, 3,\n * 2, 0\n * ],\n * kicking: [\n * // x, y (6 frames)\n * 0, 5,\n * 5, 0,\n * 10, 0,\n * 0, 0,\n * 2, 1,\n * 0, 0\n * ]\n * });\n */\nFactory.addGetterSetter(Sprite, 'image');\n/**\n * get/set image\n * @name Konva.Sprite#image\n * @method\n * @param {Image} image\n * @returns {Image}\n * @example\n * // get image\n * var image = sprite.image();\n *\n * // set image\n * sprite.image(imageObj);\n */\nFactory.addGetterSetter(Sprite, 'frameIndex', 0, getNumberValidator());\n/**\n * set/set animation frame index\n * @name Konva.Sprite#frameIndex\n * @method\n * @param {Integer} frameIndex\n * @returns {Integer}\n * @example\n * // get animation frame index\n * var frameIndex = sprite.frameIndex();\n *\n * // set animation frame index\n * sprite.frameIndex(3);\n */\nFactory.addGetterSetter(Sprite, 'frameRate', 17, getNumberValidator());\n/**\n * get/set frame rate in frames per second. Increase this number to make the sprite\n * animation run faster, and decrease the number to make the sprite animation run slower\n * The default is 17 frames per second\n * @name Konva.Sprite#frameRate\n * @method\n * @param {Integer} frameRate\n * @returns {Integer}\n * @example\n * // get frame rate\n * var frameRate = sprite.frameRate();\n *\n * // set frame rate to 2 frames per second\n * sprite.frameRate(2);\n */\nFactory.backCompat(Sprite, {\n index: 'frameIndex',\n getIndex: 'getFrameIndex',\n setIndex: 'setFrameIndex',\n});\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Star constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Integer} config.numPoints\n * @param {Number} config.innerRadius\n * @param {Number} config.outerRadius\n * @@shapeParams\n * @@nodeParams\n * @example\n * var star = new Konva.Star({\n * x: 100,\n * y: 200,\n * numPoints: 5,\n * innerRadius: 70,\n * outerRadius: 70,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 4\n * });\n */\nexport class Star extends Shape {\n _sceneFunc(context) {\n const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();\n context.beginPath();\n context.moveTo(0, 0 - outerRadius);\n for (let n = 1; n < numPoints * 2; n++) {\n const radius = n % 2 === 0 ? outerRadius : innerRadius;\n const x = radius * Math.sin((n * Math.PI) / numPoints);\n const y = -1 * radius * Math.cos((n * Math.PI) / numPoints);\n context.lineTo(x, y);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.outerRadius() * 2;\n }\n getHeight() {\n return this.outerRadius() * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n}\nStar.prototype.className = 'Star';\nStar.prototype._centroid = true;\nStar.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\n_registerNode(Star);\n/**\n * get/set number of points\n * @name Konva.Star#numPoints\n * @method\n * @param {Number} numPoints\n * @returns {Number}\n * @example\n * // get inner radius\n * var numPoints = star.numPoints();\n *\n * // set inner radius\n * star.numPoints(20);\n */\nFactory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());\n/**\n * get/set innerRadius\n * @name Konva.Star#innerRadius\n * @method\n * @param {Number} innerRadius\n * @returns {Number}\n * @example\n * // get inner radius\n * var innerRadius = star.innerRadius();\n *\n * // set inner radius\n * star.innerRadius(20);\n */\nFactory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());\n/**\n * get/set outerRadius\n * @name Konva.Star#outerRadius\n * @method\n * @param {Number} outerRadius\n * @returns {Number}\n * @example\n * // get inner radius\n * var outerRadius = star.outerRadius();\n *\n * // set inner radius\n * star.outerRadius(20);\n */\nFactory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());\n","import { Util } from \"../Util.js\";\nimport { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Konva } from \"../Global.js\";\nimport { getNumberValidator, getStringValidator, getNumberOrAutoValidator, getBooleanValidator, } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n// grapheme segmentation: one entry per user-perceived character, so flags,\n// ZWJ emoji sequences and combining marks stay together\nconst segmenter = typeof Intl !== 'undefined' && Intl.Segmenter\n ? new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n : null;\n// canvas has no API for the underline thickness of a font. This is close to\n// what browsers draw for the common fonts\nexport function getDecorationLineWidth(fontSize) {\n return fontSize / 15;\n}\nexport function stringToArray(string) {\n if (!segmenter) {\n // no Intl.Segmenter (Firefox < 125): flags, then a code point with its\n // combining marks, skin tone modifiers, variation selectors and ZWJ joins\n return (string.match(/\\p{RI}\\p{RI}|\\P{M}(?:\\p{M}|\\p{Emoji_Modifier}|\\uFE0F|\\u200D\\P{M})*|\\p{M}+/gu) || []);\n }\n return Array.from(segmenter.segment(string), (s) => s.segment);\n}\n// constants\nconst AUTO = 'auto', \n//CANVAS = 'canvas',\nCENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', RTL = 'rtl', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [\n 'direction',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'padding',\n 'align',\n 'verticalAlign',\n 'lineHeight',\n 'text',\n 'width',\n 'height',\n 'wrap',\n 'ellipsis',\n 'letterSpacing',\n];\n// Safari on macOS renders text shadow even when globalAlpha is 0.\n// This feature check detects that bug so we can work around it with a buffer canvas.\n// Not covered by automated tests (our CI doesn't run Safari).\n// Once Safari fixes the issue this check can be removed.\nlet _shadowOpacityBuggy = null;\nfunction hasShadowOpacityBug() {\n if (_shadowOpacityBuggy !== null) {\n return _shadowOpacityBuggy;\n }\n _shadowOpacityBuggy = false;\n let c;\n try {\n c = Util.createCanvasElement();\n c.width = 10;\n c.height = 10;\n const ctx = c.getContext(CONTEXT_2D);\n if (ctx) {\n ctx.globalAlpha = 0;\n ctx.shadowColor = 'black';\n ctx.shadowBlur = 5;\n ctx.shadowOffsetX = 5;\n ctx.shadowOffsetY = 5;\n ctx.fillStyle = 'black';\n ctx.font = '10px Arial';\n ctx.fillText('X', 0, 10);\n const data = ctx.getImageData(0, 0, 10, 10).data;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i] > 0) {\n _shadowOpacityBuggy = true;\n break;\n }\n }\n }\n }\n catch (e) {\n // no-op (SSR or restricted canvas)\n }\n finally {\n if (c) {\n Util.releaseCanvas(c);\n }\n }\n return _shadowOpacityBuggy;\n}\nfunction normalizeFontFamily(fontFamily) {\n return fontFamily\n .split(',')\n .map((family) => {\n family = family.trim();\n const hasSpace = family.indexOf(' ') >= 0;\n const hasQuotes = family.indexOf('\"') >= 0 || family.indexOf(\"'\") >= 0;\n if (hasSpace && !hasQuotes) {\n family = `\"${family}\"`;\n }\n return family;\n })\n .join(', ');\n}\nlet dummyContext;\nexport function getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util.createCanvasElement().getContext(CONTEXT_2D);\n return dummyContext;\n}\nfunction _fillFunc(context) {\n // re-apply a per-character style set by charRenderFunc (see _sceneFunc)\n if (this._partialFillStyle) {\n context.setAttr('fillStyle', this._partialFillStyle);\n }\n context.fillText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction _strokeFunc(context) {\n context.setAttr('miterLimit', 2);\n if (this._partialStrokeStyle) {\n context.setAttr('strokeStyle', this._partialStrokeStyle);\n }\n context.strokeText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction checkDefaultFill(config) {\n config = config || {};\n // set default color to black\n if (!config.fillLinearGradientColorStops &&\n !config.fillRadialGradientColorStops &&\n !config.fillPatternImage) {\n config.fill = config.fill || 'black';\n }\n return config;\n}\n/**\n * Text constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {String} [config.direction] default is inherit\n * @param {String} [config.fontFamily] default is Arial\n * @param {Number} [config.fontSize] in pixels. Default is 12\n * @param {String} [config.fontStyle] can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.\n * @param {String} [config.fontVariant] can be normal or small-caps. Default is normal\n * @param {String} [config.textDecoration] can be line-through, underline or empty string. Default is empty string.\n * @param {Number} [config.underlineOffset] offset for underline line. Default is calculated based on font size.\n * @param {String} config.text\n * @param {String} [config.align] can be left, center, right or justify\n * @param {String} [config.verticalAlign] can be top, middle or bottom\n * @param {Number} [config.padding]\n * @param {Number} [config.lineHeight] default is 1\n * @param {String} [config.wrap] can be \"word\", \"char\", or \"none\". Default is word\n * @param {Boolean} [config.ellipsis] can be true or false. Default is false. If true, text that does not fit is cut and ends with \"…\". That needs a fixed height or wrap=\"none\"\n * @@shapeParams\n * @@nodeParams\n * @example\n * var text = new Konva.Text({\n * x: 10,\n * y: 15,\n * text: 'Simple Text',\n * fontSize: 30,\n * fontFamily: 'Calibri',\n * fill: 'green'\n * });\n */\nexport class Text extends Shape {\n constructor(config) {\n super(checkDefaultFill(config));\n this._partialTextX = 0;\n this._partialTextY = 0;\n this._setTextData();\n }\n _sceneFunc(context) {\n var _a, _b;\n const textArr = this.textArr, textArrLen = textArr.length;\n if (!this.text()) {\n return;\n }\n let padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), charRenderFunc = this.charRenderFunc(), fill = this.fill(), textDecoration = this.textDecoration(), underlineOffset = this.underlineOffset(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;\n direction = direction === INHERIT ? context.direction : direction;\n let translateY = lineHeightPx / 2;\n let baseline = MIDDLE;\n if (!Konva.legacyTextRendering) {\n const metrics = this.measureSize('M'); // Use a sample character to get the ascent\n baseline = 'alphabetic';\n const ascent = (_a = metrics.fontBoundingBoxAscent) !== null && _a !== void 0 ? _a : metrics.actualBoundingBoxAscent;\n const descent = (_b = metrics.fontBoundingBoxDescent) !== null && _b !== void 0 ? _b : metrics.actualBoundingBoxDescent;\n translateY = (ascent - descent) / 2 + lineHeightPx / 2;\n }\n if (direction === RTL) {\n context.setAttr('direction', direction);\n }\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', baseline);\n context.setAttr('textAlign', LEFT);\n // handle vertical alignment\n if (verticalAlign === MIDDLE) {\n alignY = (this.getHeight() - textArrLen * lineHeightPx - padding * 2) / 2;\n }\n else if (verticalAlign === BOTTOM) {\n alignY = this.getHeight() - textArrLen * lineHeightPx - padding * 2;\n }\n context.translate(padding, alignY + padding);\n // context styles entering the loop, used to detect styles set by\n // charRenderFunc; every character is drawn inside save()/restore(),\n // so the entry state is the same for each one\n const fillStyleBefore = charRenderFunc ? context.fillStyle : undefined;\n const strokeStyleBefore = charRenderFunc ? context.strokeStyle : undefined;\n // global grapheme index passed to charRenderFunc, runs across lines\n let charIndex = 0;\n // draw text lines\n for (n = 0; n < textArrLen; n++) {\n let lineTranslateX = 0;\n let lineTranslateY = 0;\n const obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph;\n // horizontal alignment\n context.save();\n if (align === RIGHT) {\n lineTranslateX += totalWidth - width - padding * 2;\n }\n else if (align === CENTER) {\n lineTranslateX += (totalWidth - width - padding * 2) / 2;\n }\n if (shouldUnderline) {\n context.save();\n context.beginPath();\n const yOffset = underlineOffset !== null && underlineOffset !== void 0 ? underlineOffset : (!Konva.legacyTextRendering\n ? Math.round(fontSize / 4)\n : Math.round(fontSize / 2));\n const x = lineTranslateX;\n const y = translateY + lineTranslateY + yOffset;\n context.moveTo(x, y);\n const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;\n context.lineTo(x + Math.round(lineWidth), y);\n context.lineWidth = getDecorationLineWidth(fontSize);\n const gradient = this._getLinearGradient();\n context.strokeStyle = gradient || fill;\n context.stroke();\n context.restore();\n }\n // store the starting x position for line-through which is drawn after text\n const lineThroughStartX = lineTranslateX;\n // As `letterSpacing` isn't supported on Safari, we use this polyfill.\n // The exception is for RTL text, which we rely on native as it cannot\n // be supported otherwise.\n if (direction !== RTL &&\n (letterSpacing !== 0 || align === JUSTIFY || charRenderFunc)) {\n // var words = text.split(' ');\n const spacesNumber = text.split(' ').length - 1;\n const array = stringToArray(text);\n for (let li = 0; li < array.length; li++) {\n const letter = array[li];\n // skip justify for the last line\n if (letter === ' ' && !lastLine && align === JUSTIFY) {\n lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;\n // context.translate(\n // Math.floor((totalWidth - padding * 2 - width) / spacesNumber),\n // 0\n // );\n }\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = letter;\n // the font of the shape is already set on the context\n const letterWidth = context.measureText(letter).width;\n if (charRenderFunc) {\n context.save();\n charRenderFunc({\n char: letter,\n index: charIndex,\n x: lineTranslateX,\n y: translateY + lineTranslateY,\n lineIndex: n,\n column: li,\n isLastInLine: li === array.length - 1,\n width: letterWidth,\n context,\n });\n // a style the callback set on the context wins for this character;\n // fillStrokeShape() overwrites the context styles from the shape\n // attributes, so stash them for _fillFunc/_strokeFunc to re-apply\n const fillStyleAfter = context.fillStyle;\n if (fillStyleAfter !== fillStyleBefore) {\n this._partialFillStyle = fillStyleAfter;\n }\n const strokeStyleAfter = context.strokeStyle;\n if (strokeStyleAfter !== strokeStyleBefore) {\n this._partialStrokeStyle = strokeStyleAfter;\n }\n }\n context.fillStrokeShape(this);\n if (charRenderFunc) {\n this._partialFillStyle = undefined;\n this._partialStrokeStyle = undefined;\n context.restore();\n }\n lineTranslateX += letterWidth + letterSpacing;\n charIndex++;\n }\n }\n else {\n if (letterSpacing !== 0) {\n context.setAttr('letterSpacing', `${letterSpacing}px`);\n }\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = text;\n context.fillStrokeShape(this);\n }\n // draw line-through above the text content\n if (shouldLineThrough) {\n context.save();\n context.beginPath();\n const yOffset = !Konva.legacyTextRendering\n ? -Math.round(fontSize / 4)\n : 0;\n const x = lineThroughStartX;\n context.moveTo(x, translateY + lineTranslateY + yOffset);\n const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;\n context.lineTo(x + Math.round(lineWidth), translateY + lineTranslateY + yOffset);\n context.lineWidth = getDecorationLineWidth(fontSize);\n const gradient = this._getLinearGradient();\n context.strokeStyle = gradient || fill;\n context.stroke();\n context.restore();\n }\n context.restore();\n if (textArrLen > 1) {\n translateY += lineHeightPx;\n }\n }\n }\n _hitFunc(context) {\n const width = this.getWidth(), height = this.getHeight();\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n setText(text) {\n const str = Util._isString(text)\n ? text\n : text === null || text === undefined\n ? ''\n : text + '';\n this._setAttr(TEXT, str);\n return this;\n }\n getWidth() {\n const isAuto = this.attrs.width === AUTO || this.attrs.width === undefined;\n return isAuto ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;\n }\n getHeight() {\n const isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;\n return isAuto\n ? this.fontSize() * this.textArr.length * this.lineHeight() +\n this.padding() * 2\n : this.attrs.height;\n }\n /**\n * get pure text width without padding\n * @method\n * @name Konva.Text#getTextWidth\n * @returns {Number}\n */\n getTextWidth() {\n return this.textWidth;\n }\n getTextHeight() {\n Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n }\n /**\n * measure string with the font of current text shape.\n * That method can't handle multiline text.\n * @method\n * @name Konva.Text#measureSize\n * @param {String} text text to measure\n * @returns {Object} { width , height } of measured text\n */\n measureSize(text) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n let _context = getDummyContext(), fontSize = this.fontSize(), metrics;\n _context.save();\n _context.font = this._getContextFont();\n metrics = _context.measureText(text);\n _context.restore();\n // Scale the fallback values based on the provided fontSize compared to the sample size (100 in your new case)\n const scaleFactor = fontSize / 100;\n // Note, fallback values are from chrome browser with 100px font size and font-family \"Arial\"\n return {\n actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,\n actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0, // Remains zero as there is no descent in the provided metrics\n actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,\n actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,\n alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0, // Remains zero as it's typically relative to the baseline itself\n emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,\n emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,\n fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,\n fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,\n hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,\n ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,\n width: metrics.width,\n height: fontSize, // Typically set to the font size\n };\n }\n _getContextFont() {\n return (this.fontStyle() +\n SPACE +\n this.fontVariant() +\n SPACE +\n (this.fontSize() + PX_SPACE) +\n // wrap font family into \" so font families with spaces works ok\n normalizeFontFamily(this.fontFamily()));\n }\n _addTextLine(line) {\n const align = this.align();\n if (align === JUSTIFY) {\n line = line.trim();\n }\n const width = this._getTextWidth(line);\n return this.textArr.push({\n text: line,\n width: width,\n lastInParagraph: false,\n });\n }\n _getTextWidth(text, graphemes) {\n const letterSpacing = this.letterSpacing();\n // one spacing per grapheme, as the per-character rendering draws them\n const spacing = letterSpacing\n ? letterSpacing * (graphemes !== null && graphemes !== void 0 ? graphemes : stringToArray(text).length)\n : 0;\n return getDummyContext().measureText(text).width + spacing;\n }\n _setTextData() {\n let lines = this.text().split('\\n'), fontSize = +this.fontSize(), textWidth = 0, lineHeightPx = this.lineHeight() * fontSize, width = this.attrs.width, height = this.attrs.height, fixedWidth = width !== AUTO && width !== undefined, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxWidth = width - padding * 2, maxHeightPx = height - padding * 2, currentHeightPx = 0, wrap = this.wrap(), \n // align = this.align(),\n shouldWrap = wrap !== NONE, wrapAtWord = wrap !== CHAR && shouldWrap, shouldAddEllipsis = this.ellipsis();\n this.textArr = [];\n getDummyContext().font = this._getContextFont();\n const additionalWidth = shouldAddEllipsis\n ? this._getTextWidth(ELLIPSIS)\n : 0;\n for (let i = 0, max = lines.length; i < max; ++i) {\n let line = lines[i];\n let lineWidth = this._getTextWidth(line);\n if (fixedWidth && lineWidth > maxWidth) {\n /*\n * if width is fixed and line does not fit entirely\n * break the line into multiple fitting lines\n */\n const graphemes = stringToArray(line);\n const length = graphemes.length;\n let start = 0;\n const text = (end) => graphemes.slice(start, end).join('');\n const isBreak = (char) => char === SPACE || char === DASH;\n // graphemes per line, estimated from the average grapheme width\n const perLine = Math.max(1, Math.ceil((length * maxWidth) / lineWidth));\n while (start < length) {\n // only reserve the ellipsis width on a line that may be the last\n // visible one\n const extraWidth = shouldAddEllipsis &&\n fixedHeight &&\n currentHeightPx + lineHeightPx > maxHeightPx\n ? additionalWidth\n : 0;\n // width of the longest fitting prefix found so far\n let matchWidth = 0;\n const fits = (end) => {\n const width = this._getTextWidth(text(end), end - start);\n if (width + extraWidth > maxWidth) {\n return false;\n }\n matchWidth = width;\n return true;\n };\n /*\n * find the longest prefix that fits in the specified width:\n * grow a window from the estimate until it stops fitting, then\n * binary search inside it. Every probe measures about one line,\n * not the whole remaining text, so wrapping stays linear\n */\n let low = start, high = Math.min(length, start + perLine);\n while (fits(high)) {\n low = high;\n if (high === length) {\n break;\n }\n high = Math.min(length, high + (high - start));\n }\n while (high - low > 1) {\n const mid = (low + high) >>> 1;\n if (fits(mid)) {\n low = mid;\n }\n else {\n high = mid;\n }\n }\n if (low === start) {\n // not even one character could fit in the element, abort\n break;\n }\n if (low === length) {\n // the rest of the paragraph fits on one line: kept untrimmed and\n // without the ellipsis check, like a paragraph that never wrapped\n this._addTextLine(text(length));\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, matchWidth);\n break;\n }\n if (wrapAtWord && !isBreak(graphemes[low])) {\n // wrap at the last space or dash of the line instead\n let wrapIndex = low - 1;\n while (wrapIndex >= start && !isBreak(graphemes[wrapIndex])) {\n wrapIndex--;\n }\n if (wrapIndex >= start) {\n low = wrapIndex + 1;\n matchWidth = this._getTextWidth(text(low), low - start);\n }\n }\n this._addTextLine(text(low).trimRight());\n textWidth = Math.max(textWidth, matchWidth);\n currentHeightPx += lineHeightPx;\n if (this._shouldHandleEllipsis(currentHeightPx)) {\n this._tryToAddEllipsisToLastLine();\n /*\n * stop wrapping if wrapping is disabled or if adding\n * one more line would overflow the fixed height\n */\n break;\n }\n // the next line starts after the whitespace of the break\n start = low;\n while (start < length && !graphemes[start].trim()) {\n start++;\n }\n }\n }\n else {\n // element width is automatically adjusted to max line width\n this._addTextLine(line);\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, lineWidth);\n if (this._shouldHandleEllipsis(currentHeightPx) && i < max - 1) {\n this._tryToAddEllipsisToLastLine();\n }\n }\n // if element height is fixed, abort if adding one more line would overflow\n if (this.textArr[this.textArr.length - 1]) {\n this.textArr[this.textArr.length - 1].lastInParagraph = true;\n }\n if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {\n break;\n }\n }\n this.textHeight = fontSize;\n // var maxTextWidth = 0;\n // for(var j = 0; j < this.textArr.length; j++) {\n // maxTextWidth = Math.max(maxTextWidth, this.textArr[j].width);\n // }\n this.textWidth = textWidth;\n }\n /**\n * whether to handle ellipsis, there are two cases:\n * 1. the current line is the last line\n * 2. wrap is NONE\n * @param {Number} currentHeightPx\n * @returns {Boolean}\n */\n _shouldHandleEllipsis(currentHeightPx) {\n const fontSize = +this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, height = this.attrs.height, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxHeightPx = height - padding * 2, wrap = this.wrap(), shouldWrap = wrap !== NONE;\n return (!shouldWrap ||\n (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx));\n }\n _tryToAddEllipsisToLastLine() {\n const width = this.attrs.width, fixedWidth = width !== AUTO && width !== undefined, padding = this.padding(), maxWidth = width - padding * 2, shouldAddEllipsis = this.ellipsis();\n const lastLine = this.textArr[this.textArr.length - 1];\n if (!lastLine || !shouldAddEllipsis) {\n return;\n }\n if (fixedWidth) {\n const haveSpace = this._getTextWidth(lastLine.text + ELLIPSIS) < maxWidth;\n if (!haveSpace) {\n lastLine.text = lastLine.text.slice(0, lastLine.text.length - 3);\n }\n }\n this.textArr.splice(this.textArr.length - 1, 1);\n this._addTextLine(lastLine.text + ELLIPSIS);\n }\n // for text we can't disable stroke scaling\n // if we do, the result will be unexpected\n getStrokeScaleEnabled() {\n return true;\n }\n _useBufferCanvas() {\n const hasLine = this.textDecoration().indexOf('underline') !== -1 ||\n this.textDecoration().indexOf('line-through') !== -1;\n const hasShadow = this.hasShadow();\n if (hasLine && hasShadow) {\n return true;\n }\n if (hasShadow && this.getAbsoluteOpacity() !== 1 && hasShadowOpacityBug()) {\n return true;\n }\n return super._useBufferCanvas();\n }\n}\nText.prototype._fillFunc = _fillFunc;\nText.prototype._strokeFunc = _strokeFunc;\nText.prototype.className = TEXT_UPPER;\nText.prototype._attrsAffectingSize = [\n 'text',\n 'fontSize',\n 'padding',\n 'wrap',\n 'lineHeight',\n 'letterSpacing',\n];\n_registerNode(Text);\n// update text data for certain attr changes\nText.prototype.on(ATTR_CHANGE_LIST.map((attr) => attr + CHANGE_KONVA).join(' '), function () {\n this._setTextData();\n});\n/**\n * get/set width of text area, which includes padding.\n * @name Konva.Text#width\n * @method\n * @param {Number} width\n * @returns {Number}\n * @example\n * // get width\n * var width = text.width();\n *\n * // set width\n * text.width(20);\n *\n * // set to auto\n * text.width('auto');\n * text.width() // will return calculated width, and not \"auto\"\n */\nFactory.overWriteSetter(Text, 'width', getNumberOrAutoValidator());\n/**\n * get/set the height of the text area, which takes into account multi-line text, line heights, and padding.\n * @name Konva.Text#height\n * @method\n * @param {Number} height\n * @returns {Number}\n * @example\n * // get height\n * var height = text.height();\n *\n * // set height\n * text.height(20);\n *\n * // set to auto\n * text.height('auto');\n * text.height() // will return calculated height, and not \"auto\"\n */\nFactory.overWriteSetter(Text, 'height', getNumberOrAutoValidator());\n/**\n * get/set direction\n * @name Konva.Text#direction\n * @method\n * @param {String} direction\n * @returns {String}\n * @example\n * // get direction\n * var direction = text.direction();\n *\n * // set direction\n * text.direction('rtl');\n */\nFactory.addGetterSetter(Text, 'direction', INHERIT);\n/**\n * get/set font family\n * @name Konva.Text#fontFamily\n * @method\n * @param {String} fontFamily\n * @returns {String}\n * @example\n * // get font family\n * var fontFamily = text.fontFamily();\n *\n * // set font family\n * text.fontFamily('Arial');\n */\nFactory.addGetterSetter(Text, 'fontFamily', 'Arial');\n/**\n * get/set font size in pixels\n * @name Konva.Text#fontSize\n * @method\n * @param {Number} fontSize\n * @returns {Number}\n * @example\n * // get font size\n * var fontSize = text.fontSize();\n *\n * // set font size to 22px\n * text.fontSize(22);\n */\nFactory.addGetterSetter(Text, 'fontSize', 12, getNumberValidator());\n/**\n * get/set font style. Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.\n * @name Konva.Text#fontStyle\n * @method\n * @param {String} fontStyle\n * @returns {String}\n * @example\n * // get font style\n * var fontStyle = text.fontStyle();\n *\n * // set font style\n * text.fontStyle('bold');\n */\nFactory.addGetterSetter(Text, 'fontStyle', NORMAL);\n/**\n * get/set font variant. Can be 'normal' or 'small-caps'. 'normal' is the default.\n * @name Konva.Text#fontVariant\n * @method\n * @param {String} fontVariant\n * @returns {String}\n * @example\n * // get font variant\n * var fontVariant = text.fontVariant();\n *\n * // set font variant\n * text.fontVariant('small-caps');\n */\nFactory.addGetterSetter(Text, 'fontVariant', NORMAL);\n/**\n * get/set padding\n * @name Konva.Text#padding\n * @method\n * @param {Number} padding\n * @returns {Number}\n * @example\n * // get padding\n * var padding = text.padding();\n *\n * // set padding to 10 pixels\n * text.padding(10);\n */\nFactory.addGetterSetter(Text, 'padding', 0, getNumberValidator());\n/**\n * get/set horizontal align of text. Can be 'left', 'center', 'right' or 'justify'\n * @name Konva.Text#align\n * @method\n * @param {String} align\n * @returns {String}\n * @example\n * // get text align\n * var align = text.align();\n *\n * // center text\n * text.align('center');\n *\n * // align text to right\n * text.align('right');\n *\n * // justify text\n */\nFactory.addGetterSetter(Text, 'align', LEFT);\n/**\n * get/set vertical align of text. Can be 'top', 'middle', 'bottom'.\n * @name Konva.Text#verticalAlign\n * @method\n * @param {String} verticalAlign\n * @returns {String}\n * @example\n * // get text vertical align\n * var verticalAlign = text.verticalAlign();\n *\n * // center text\n * text.verticalAlign('middle');\n */\nFactory.addGetterSetter(Text, 'verticalAlign', TOP);\n/**\n * get/set line height. The default is 1.\n * @name Konva.Text#lineHeight\n * @method\n * @param {Number} lineHeight\n * @returns {Number}\n * @example\n * // get line height\n * var lineHeight = text.lineHeight();\n *\n * // set the line height\n * text.lineHeight(2);\n */\nFactory.addGetterSetter(Text, 'lineHeight', 1, getNumberValidator());\n/**\n * get/set wrap. Can be \"word\", \"char\", or \"none\". Default is \"word\".\n * In \"word\" wrapping any word still can be wrapped if it can't be placed in the required width\n * without breaks.\n * @name Konva.Text#wrap\n * @method\n * @param {String} wrap\n * @returns {String}\n * @example\n * // get wrap\n * var wrap = text.wrap();\n *\n * // set wrap\n * text.wrap('word');\n */\nFactory.addGetterSetter(Text, 'wrap', WORD);\n/**\n * get/set ellipsis. Can be true or false. Default is false. If ellipsis is true,\n * Konva cuts the text that does not fit and ends it with \"…\" (one character).\n * That needs a fixed height or wrap set to \"none\"\n * @name Konva.Text#ellipsis\n * @method\n * @param {Boolean} ellipsis\n * @returns {Boolean}\n * @example\n * // get ellipsis param, returns true or false\n * var ellipsis = text.ellipsis();\n *\n * // set ellipsis\n * text.ellipsis(true);\n */\nFactory.addGetterSetter(Text, 'ellipsis', false, getBooleanValidator());\n/**\n * set letter spacing property. Default value is 0.\n * @name Konva.Text#letterSpacing\n * @method\n * @param {Number} letterSpacing\n */\nFactory.addGetterSetter(Text, 'letterSpacing', 0, getNumberValidator());\n/**\n * get/set text\n * @name Konva.Text#text\n * @method\n * @param {String} text\n * @returns {String}\n * @example\n * // get text\n * var text = text.text();\n *\n * // set text\n * text.text('Hello world!');\n */\nFactory.addGetterSetter(Text, 'text', '', getStringValidator());\n/**\n * get/set text decoration of a text. Possible values are 'underline', 'line-through' or combination of these values separated by space\n * @name Konva.Text#textDecoration\n * @method\n * @param {String} textDecoration\n * @returns {String}\n * @example\n * // get text decoration\n * var textDecoration = text.textDecoration();\n *\n * // underline text\n * text.textDecoration('underline');\n *\n * // strike text\n * text.textDecoration('line-through');\n *\n * // underline and strike text\n * text.textDecoration('underline line-through');\n */\nFactory.addGetterSetter(Text, 'textDecoration', '');\n/**\n * get/set text underline decoration offset. Offset for underline line. Default is calculated based on font size.\n * @name Konva.Text#underlineOffset\n * @method\n * @param {Number} underlineOffset\n * @returns {Number}\n * @example\n * // get underline offset\n * var underlineOffset = text.underlineOffset();\n *\n * // set underline offset\n * text.underlineOffset(5);\n */\nFactory.addGetterSetter(Text, 'underlineOffset', undefined, getNumberValidator());\n/**\n * get/set per-character render hook. The callback is invoked for each grapheme before drawing.\n * It can mutate the provided context (e.g. translate, rotate, change styles) and should return void.\n * Note: per-character rendering may disable native kerning/ligatures.\n * @name Konva.Text#charRenderFunc\n * @method\n * @param {Function} charRenderFunc\n * @returns {Function}\n * @example\n * // apply small x-translation and a custom color to every second character\n * text.charRenderFunc(function(props) {\n * if (props.index % 2 === 1) {\n * props.context.translate(2, 0);\n * props.context.fillStyle = 'red';\n * }\n * });\n */\nFactory.addGetterSetter(Text, 'charRenderFunc', undefined);\n","import { Util } from \"../Util.js\";\nimport { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Path } from \"./Path.js\";\nimport { Text, getDecorationLineWidth, getDummyContext, stringToArray, } from \"./Text.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\nconst EMPTY_STRING = '', NORMAL = 'normal';\nfunction _fillFunc(context) {\n context.fillText(this.partialText, 0, 0);\n}\nfunction _strokeFunc(context) {\n context.strokeText(this.partialText, 0, 0);\n}\n/**\n * Path constructor.\n * @author Jason Follas\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {String} [config.fontFamily] default is Arial\n * @param {Number} [config.fontSize] default is 12\n * @param {String} [config.fontStyle] Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.\n * @param {String} [config.fontVariant] can be normal or small-caps. Default is normal\n * @param {String} [config.textBaseline] Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'. Default is middle\n * @param {String} config.text\n * @param {String} config.data SVG data string\n * @param {Function} config.kerningFunc a getter for kerning values for the specified characters\n * @@shapeParams\n * @@nodeParams\n * @example\n * var kerningPairs = {\n * 'A': {\n * ' ': -0.05517578125,\n * 'T': -0.07421875,\n * 'V': -0.07421875\n * }\n * 'V': {\n * ',': -0.091796875,\n * \":\": -0.037109375,\n * \";\": -0.037109375,\n * \"A\": -0.07421875\n * }\n * }\n * var textpath = new Konva.TextPath({\n * x: 100,\n * y: 50,\n * fill: '#333',\n * fontSize: '24',\n * fontFamily: 'Arial',\n * text: 'All the world\\'s a stage, and all the men and women merely players.',\n * data: 'M10,10 C0,0 10,150 100,100 S300,150 400,50',\n * kerningFunc(leftChar, rightChar) {\n * return kerningPairs.hasOwnProperty(leftChar) ? pairs[leftChar][rightChar] || 0 : 0\n * }\n * });\n */\nexport class TextPath extends Shape {\n constructor(config) {\n // call super constructor\n super(config);\n this.dataArray = [];\n this._readDataAttribute();\n this._setTextData();\n }\n _getTextPathLength() {\n return Path.getPathLength(this.dataArray);\n }\n _getPointAtLength(length) {\n // if path is not defined yet, do nothing\n if (!this.attrs.data) {\n return null;\n }\n const totalLength = this.pathLength;\n if (length > totalLength) {\n return null;\n }\n return Path.getPointAtLengthOfDataArray(length, this.dataArray);\n }\n _readDataAttribute() {\n this.dataArray = Path.parsePathData(this.attrs.data);\n this.pathLength = this._getTextPathLength();\n }\n _sceneFunc(context) {\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', this.textBaseline());\n context.setAttr('textAlign', 'left');\n context.save();\n const textDecoration = this.textDecoration();\n const fill = this.fill();\n const fontSize = this.fontSize();\n const glyphInfo = this.glyphInfo;\n const hasUnderline = textDecoration.indexOf('underline') !== -1;\n const hasLineThrough = textDecoration.indexOf('line-through') !== -1;\n if (hasUnderline) {\n context.beginPath();\n }\n for (let i = 0; i < glyphInfo.length; i++) {\n context.save();\n const p0 = glyphInfo[i].p0;\n context.translate(p0.x, p0.y);\n context.rotate(glyphInfo[i].rotation);\n this.partialText = glyphInfo[i].text;\n context.fillStrokeShape(this);\n if (hasUnderline) {\n if (i === 0) {\n context.moveTo(0, fontSize / 2 + 1);\n }\n context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);\n }\n context.restore();\n //// To assist with debugging visually, uncomment following\n //\n // if (i % 2) context.strokeStyle = 'cyan';\n // else context.strokeStyle = 'green';\n // var p1 = glyphInfo[i].p1;\n // context.moveTo(p0.x, p0.y);\n // context.lineTo(p1.x, p1.y);\n // context.stroke();\n }\n if (hasUnderline) {\n context.strokeStyle = fill;\n context.lineWidth = getDecorationLineWidth(fontSize);\n context.stroke();\n }\n if (hasLineThrough) {\n context.beginPath();\n for (let i = 0; i < glyphInfo.length; i++) {\n context.save();\n const p0 = glyphInfo[i].p0;\n context.translate(p0.x, p0.y);\n context.rotate(glyphInfo[i].rotation);\n if (i === 0) {\n context.moveTo(0, 0);\n }\n context.lineTo(glyphInfo[i].width, 0);\n context.restore();\n }\n context.strokeStyle = fill;\n context.lineWidth = getDecorationLineWidth(fontSize);\n context.stroke();\n }\n context.restore();\n }\n _hitFunc(context) {\n context.beginPath();\n const glyphInfo = this.glyphInfo;\n if (glyphInfo.length >= 1) {\n const p0 = glyphInfo[0].p0;\n context.moveTo(p0.x, p0.y);\n }\n for (let i = 0; i < glyphInfo.length; i++) {\n const p1 = glyphInfo[i].p1;\n context.lineTo(p1.x, p1.y);\n }\n context.setAttr('lineWidth', this.fontSize());\n context.setAttr('strokeStyle', this.colorKey);\n context.stroke();\n }\n /**\n * get text width in pixels\n * @method\n * @name Konva.TextPath#getTextWidth\n */\n getTextWidth() {\n return this.textWidth;\n }\n getTextHeight() {\n Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n }\n setText(text) {\n return Text.prototype.setText.call(this, text);\n }\n _getContextFont() {\n return Text.prototype._getContextFont.call(this);\n }\n _getTextSize(text) {\n const _context = getDummyContext();\n _context.save();\n _context.font = this._getContextFont();\n const metrics = _context.measureText(text);\n _context.restore();\n return {\n width: metrics.width,\n height: parseInt(`${this.fontSize()}`, 10),\n };\n }\n _setTextData() {\n const charArr = stringToArray(this.text());\n // For RTL scripts (Hebrew, Arabic, …) the path is still walked left to\n // right by glyph index, so we lay glyphs out in reversed logical order.\n // A reader scanning the path right-to-left then sees the text in its\n // intended reading order. This does not perform full Unicode bidi or\n // Arabic cursive shaping — those need a real shaping engine — but it\n // makes pure RTL strings render in the right direction.\n if (this.direction() === 'rtl') {\n charArr.reverse();\n }\n const chars = [];\n let width = 0;\n for (let i = 0; i < charArr.length; i++) {\n chars.push({\n char: charArr[i],\n width: this._getTextSize(charArr[i]).width,\n });\n width += chars[i].width;\n }\n const { width: fullTextWidth, height } = this._getTextSize(this.attrs.text);\n this.textWidth = width;\n this.textHeight = height;\n this.glyphInfo = [];\n if (!this.attrs.data) {\n return null;\n }\n const letterSpacing = this.letterSpacing();\n const align = this.align();\n const kerningFunc = this.kerningFunc();\n // The sum of individual character widths can exceed the whole-string width\n // due to kerning (browsers place adjacent glyphs closer together than the\n // individual measurements suggest). This difference is the maximum amount\n // by which the accumulated glyph offset can legitimately overshoot the\n // path length when the path is sized to match the visually-measured text.\n const kerningAdjustment = Math.max(0, width - fullTextWidth);\n // defines the width of the text on a straight line\n const textWidth = Math.max(this.textWidth + (charArr.length - 1) * letterSpacing, 0);\n let offset = 0;\n if (align === 'center') {\n offset = Math.max(0, this.pathLength / 2 - textWidth / 2);\n }\n if (align === 'right') {\n offset = Math.max(0, this.pathLength - textWidth);\n }\n // Algorithm for calculating glyph positions:\n // 1. Get the begging point of the glyph on the path using the offsetToGlyph,\n // 2. Get the ending point of the glyph on the path using the offsetToGlyph plus glyph width,\n // 3. Calculate the rotation, width, and midpoint of the glyph using the start and end points,\n // 4. Add glyph width to the offsetToGlyph and repeat\n let offsetToGlyph = offset;\n for (let i = 0; i < chars.length; i++) {\n const charStartPoint = this._getPointAtLength(offsetToGlyph);\n if (!charStartPoint)\n return;\n const char = chars[i].char;\n let glyphWidth = chars[i].width + letterSpacing;\n if (char === ' ' && align === 'justify') {\n const numberOfSpaces = this.text().split(' ').length - 1;\n glyphWidth += (this.pathLength - textWidth) / numberOfSpaces;\n }\n const charEndLength = offsetToGlyph + glyphWidth;\n // When the path length is sized to match the visually-measured (kerned)\n // text width, the accumulated per-glyph offset can exceed pathLength by\n // up to kerningAdjustment pixels. Clamp to pathLength in that case so\n // the last character is not silently dropped.\n const charEndPoint = this._getPointAtLength(charEndLength > this.pathLength &&\n charEndLength - this.pathLength <= kerningAdjustment\n ? this.pathLength\n : charEndLength);\n if (!charEndPoint) {\n return;\n }\n const width = Path.getLineLength(charStartPoint.x, charStartPoint.y, charEndPoint.x, charEndPoint.y);\n let kern = 0;\n if (kerningFunc && i > 0) {\n try {\n // getKerning is a user provided getter. Make sure it never breaks our logic\n kern = kerningFunc(chars[i - 1].char, char) * this.fontSize();\n }\n catch (e) {\n kern = 0;\n }\n }\n charStartPoint.x += kern;\n charEndPoint.x += kern;\n this.textWidth += kern;\n const midpoint = Path.getPointOnLine(kern + width / 2.0, charStartPoint.x, charStartPoint.y, charEndPoint.x, charEndPoint.y);\n const rotation = Math.atan2(charEndPoint.y - charStartPoint.y, charEndPoint.x - charStartPoint.x);\n this.glyphInfo.push({\n transposeX: midpoint.x,\n transposeY: midpoint.y,\n text: charArr[i],\n rotation: rotation,\n p0: charStartPoint,\n p1: charEndPoint,\n width: width,\n });\n offsetToGlyph += glyphWidth;\n }\n }\n getSelfRect() {\n if (!this.glyphInfo.length) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n const points = [];\n this.glyphInfo.forEach(function (info) {\n points.push(info.p0.x);\n points.push(info.p0.y);\n points.push(info.p1.x);\n points.push(info.p1.y);\n });\n const rect = Util._getPointsRect(points);\n const fontSize = this.fontSize();\n return {\n x: rect.x - fontSize / 2,\n y: rect.y - fontSize / 2,\n width: rect.width + fontSize,\n height: rect.height + fontSize,\n };\n }\n}\nTextPath.prototype._fillFunc = _fillFunc;\nTextPath.prototype._strokeFunc = _strokeFunc;\nTextPath.prototype._fillFuncHit = _fillFunc;\nTextPath.prototype._strokeFuncHit = _strokeFunc;\nTextPath.prototype.className = 'TextPath';\nTextPath.prototype._attrsAffectingSize = ['text', 'fontSize', 'data'];\n_registerNode(TextPath);\nTextPath.prototype.on('dataChange.konva', function () {\n this._readDataAttribute();\n this._setTextData();\n});\n// update text data for certain attr changes\nTextPath.prototype.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva fontStyleChange.konva fontVariantChange.konva directionChange.konva', function () {\n this._setTextData();\n});\n/**\n * get/set SVG path data string. This method\n * also automatically parses the data string\n * into a data array. Currently supported SVG data:\n * M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z\n * @name Konva.TextPath#data\n * @method\n * @param {String} data svg path string\n * @returns {String}\n * @example\n * // get data\n * var data = shape.data();\n *\n * // set data\n * shape.data('M200,100h100v50z');\n */\nFactory.addGetterSetter(TextPath, 'data');\n/**\n * get/set font family\n * @name Konva.TextPath#fontFamily\n * @method\n * @param {String} fontFamily\n * @returns {String}\n * @example\n * // get font family\n * var fontFamily = shape.fontFamily();\n *\n * // set font family\n * shape.fontFamily('Arial');\n */\nFactory.addGetterSetter(TextPath, 'fontFamily', 'Arial');\n/**\n * get/set font size in pixels\n * @name Konva.TextPath#fontSize\n * @method\n * @param {Number} fontSize\n * @returns {Number}\n * @example\n * // get font size\n * var fontSize = shape.fontSize();\n *\n * // set font size to 22px\n * shape.fontSize(22);\n */\nFactory.addGetterSetter(TextPath, 'fontSize', 12, getNumberValidator());\n/**\n * get/set font style. Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.\n * @name Konva.TextPath#fontStyle\n * @method\n * @param {String} fontStyle\n * @returns {String}\n * @example\n * // get font style\n * var fontStyle = shape.fontStyle();\n *\n * // set font style\n * shape.fontStyle('bold');\n */\nFactory.addGetterSetter(TextPath, 'fontStyle', NORMAL);\n/**\n * get/set horizontal align of text. Can be 'left', 'center', 'right' or 'justify'\n * @name Konva.TextPath#align\n * @method\n * @param {String} align\n * @returns {String}\n * @example\n * // get text align\n * var align = text.align();\n *\n * // center text\n * text.align('center');\n *\n * // align text to right\n * text.align('right');\n */\nFactory.addGetterSetter(TextPath, 'align', 'left');\n/**\n * get/set letter spacing. The default is 0.\n * @name Konva.TextPath#letterSpacing\n * @method\n * @param {Number} letterSpacing\n * @returns {Number}\n * @example\n * // get letter spacing value\n * var letterSpacing = shape.letterSpacing();\n *\n * // set the letter spacing value\n * shape.letterSpacing(2);\n */\nFactory.addGetterSetter(TextPath, 'letterSpacing', 0, getNumberValidator());\n/**\n * get/set text baseline. The default is 'middle'. Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'\n * @name Konva.TextPath#textBaseline\n * @method\n * @param {String} textBaseline\n * @returns {String}\n * @example\n * // get current text baseline\n * var textBaseline = shape.textBaseline();\n *\n * // set new text baseline\n * shape.textBaseline('top');\n */\nFactory.addGetterSetter(TextPath, 'textBaseline', 'middle');\n/**\n * get/set font variant. Can be 'normal' or 'small-caps'. 'normal' is the default.\n * @name Konva.TextPath#fontVariant\n * @method\n * @param {String} fontVariant\n * @returns {String}\n * @example\n * // get font variant\n * var fontVariant = shape.fontVariant();\n *\n * // set font variant\n * shape.fontVariant('small-caps');\n */\nFactory.addGetterSetter(TextPath, 'fontVariant', NORMAL);\n/**\n * get/set text\n * @name Konva.TextPath#getText\n * @method\n * @param {String} text\n * @returns {String}\n * @example\n * // get text\n * var text = text.text();\n *\n * // set text\n * text.text('Hello world!');\n */\nFactory.addGetterSetter(TextPath, 'text', EMPTY_STRING);\n/**\n * get/set text decoration of a text. Can be '', 'underline', 'line-through', or a combination like 'underline line-through'.\n * @name Konva.TextPath#textDecoration\n * @method\n * @param {String} textDecoration\n * @returns {String}\n * @example\n * // get text decoration\n * var textDecoration = shape.textDecoration();\n *\n * // underline text\n * shape.textDecoration('underline');\n *\n * // line-through text\n * shape.textDecoration('line-through');\n *\n * // combine both\n * shape.textDecoration('underline line-through');\n */\nFactory.addGetterSetter(TextPath, 'textDecoration', '');\n/**\n * get/set kerning function.\n * @name Konva.TextPath#kerningFunc\n * @method\n * @param {String} kerningFunc\n * @returns {String}\n * @example\n * // get text decoration\n * var kerningFunc = text.kerningFunc();\n *\n * // center text\n * text.kerningFunc(function(leftChar, rightChar) {\n * return 1;\n * });\n */\nFactory.addGetterSetter(TextPath, 'kerningFunc', undefined);\n/**\n * get/set text direction. Can be 'inherit', 'ltr' or 'rtl'. Default is 'inherit'.\n *\n * Setting `'rtl'` reverses the per-glyph layout order along the path, so\n * Hebrew/Arabic strings read correctly when scanned right-to-left. This is a\n * pragmatic fix limited by canvas TextPath rendering: each glyph is still\n * drawn independently, so Arabic cursive joining and full Unicode bidi\n * reordering of mixed-direction text are not supported. For best results,\n * pair `direction: 'rtl'` with `align: 'right'` so the text starts at the\n * end of the path.\n * @name Konva.TextPath#direction\n * @method\n * @param {String} direction\n * @returns {String}\n * @example\n * // get direction\n * var direction = textpath.direction();\n *\n * // set direction\n * textpath.direction('rtl');\n */\nFactory.addGetterSetter(TextPath, 'direction', 'inherit');\n","import { Util, Transform } from \"../Util.js\";\nimport { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Rect } from \"./Rect.js\";\nimport { Group } from \"../Group.js\";\nimport { Konva } from \"../Global.js\";\nimport { getBooleanValidator, getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\nconst EVENTS_NAME = 'tr-konva';\nconst ATTR_CHANGE_LIST = [\n 'resizeEnabledChange',\n 'rotateAnchorOffsetChange',\n 'rotateAnchorAngleChange',\n 'rotateEnabledChange',\n 'enabledAnchorsChange',\n 'anchorSizeChange',\n 'borderEnabledChange',\n 'borderStrokeChange',\n 'borderStrokeWidthChange',\n 'borderDashChange',\n 'anchorStrokeChange',\n 'anchorStrokeWidthChange',\n 'anchorFillChange',\n 'anchorCornerRadiusChange',\n 'ignoreStrokeChange',\n 'anchorStyleFuncChange',\n 'paddingChange',\n]\n .map((e) => e + `.${EVENTS_NAME}`)\n .join(' ');\nconst NODES_RECT = 'nodesRect';\nconst TRANSFORM_CHANGE_STR = [\n 'widthChange',\n 'heightChange',\n 'scaleXChange',\n 'scaleYChange',\n 'skewXChange',\n 'skewYChange',\n 'rotationChange',\n 'offsetXChange',\n 'offsetYChange',\n 'transformsEnabledChange',\n 'strokeWidthChange',\n 'draggableChange',\n];\nconst ANGLES = {\n 'top-left': -45,\n 'top-center': 0,\n 'top-right': 45,\n 'middle-right': -90,\n 'middle-left': 90,\n 'bottom-left': -135,\n 'bottom-center': 180,\n 'bottom-right': 135,\n};\nconst TOUCH_DEVICE = 'ontouchstart' in Konva._global;\nfunction getCursor(anchorName, rad, rotateCursor) {\n if (anchorName === 'rotater') {\n return rotateCursor;\n }\n rad += Util.degToRad(ANGLES[anchorName] || 0);\n const angle = ((Util.radToDeg(rad) % 360) + 360) % 360;\n if (Util._inRange(angle, 315 + 22.5, 360) || Util._inRange(angle, 0, 22.5)) {\n // TOP\n return 'ns-resize';\n }\n else if (Util._inRange(angle, 45 - 22.5, 45 + 22.5)) {\n // TOP - RIGHT\n return 'nesw-resize';\n }\n else if (Util._inRange(angle, 90 - 22.5, 90 + 22.5)) {\n // RIGHT\n return 'ew-resize';\n }\n else if (Util._inRange(angle, 135 - 22.5, 135 + 22.5)) {\n // BOTTOM - RIGHT\n return 'nwse-resize';\n }\n else if (Util._inRange(angle, 180 - 22.5, 180 + 22.5)) {\n // BOTTOM\n return 'ns-resize';\n }\n else if (Util._inRange(angle, 225 - 22.5, 225 + 22.5)) {\n // BOTTOM - LEFT\n return 'nesw-resize';\n }\n else if (Util._inRange(angle, 270 - 22.5, 270 + 22.5)) {\n // RIGHT\n return 'ew-resize';\n }\n else if (Util._inRange(angle, 315 - 22.5, 315 + 22.5)) {\n // BOTTOM - RIGHT\n return 'nwse-resize';\n }\n else {\n // how can we can there?\n Util.error('Transformer has unknown angle for cursor detection: ' + angle);\n return 'pointer';\n }\n}\nconst ANCHORS_NAMES = [\n 'top-left',\n 'top-center',\n 'top-right',\n 'middle-right',\n 'middle-left',\n 'bottom-left',\n 'bottom-center',\n 'bottom-right',\n];\nconst MAX_SAFE_INTEGER = 100000000;\nfunction getCenter(shape) {\n return {\n x: shape.x +\n (shape.width / 2) * Math.cos(shape.rotation) +\n (shape.height / 2) * Math.sin(-shape.rotation),\n y: shape.y +\n (shape.height / 2) * Math.cos(shape.rotation) +\n (shape.width / 2) * Math.sin(shape.rotation),\n };\n}\nfunction rotateAroundPoint(shape, angleRad, point) {\n const x = point.x +\n (shape.x - point.x) * Math.cos(angleRad) -\n (shape.y - point.y) * Math.sin(angleRad);\n const y = point.y +\n (shape.x - point.x) * Math.sin(angleRad) +\n (shape.y - point.y) * Math.cos(angleRad);\n return {\n ...shape,\n rotation: shape.rotation + angleRad,\n x,\n y,\n };\n}\nfunction rotateAroundCenter(shape, deltaRad) {\n const center = getCenter(shape);\n return rotateAroundPoint(shape, deltaRad, center);\n}\nfunction getSnap(snaps, newRotationRad, tol) {\n let snapped = newRotationRad;\n for (let i = 0; i < snaps.length; i++) {\n const angle = Konva.getAngle(snaps[i]);\n const absDiff = Math.abs(angle - newRotationRad) % (Math.PI * 2);\n const dif = Math.min(absDiff, Math.PI * 2 - absDiff);\n if (dif < tol) {\n snapped = angle;\n }\n }\n return snapped;\n}\nconst activeTransformers = new Set();\n/**\n * Transformer constructor. Transformer is a special type of group that allow you transform Konva\n * primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes\n * when you resize them. Instead it changes `scaleX` and `scaleY` properties.\n * @constructor\n * @memberof Konva\n * @param {Object} config\n * @param {Boolean} [config.resizeEnabled] Default is true\n * @param {Boolean} [config.rotateEnabled] Default is true\n * @param {Boolean} [config.rotateLineVisible] Default is true\n * @param {Array} [config.rotationSnaps] Array of angles for rotation snaps. Default is []\n * @param {Number} [config.rotationSnapTolerance] Snapping tolerance. If closer than this it will snap. Default is 5\n * @param {Number} [config.rotateAnchorOffset] Default is 50\n * @param {Number} [config.rotateAnchorAngle] Angle of the rotate anchor around the box, in degrees. Default is 0 (top)\n * @param {String} [config.rotateAnchorCursor] Default is crosshair\n * @param {Number} [config.padding] Default is 0\n * @param {Boolean} [config.borderEnabled] Should we draw border? Default is true\n * @param {String} [config.borderStroke] Border stroke color\n * @param {Number} [config.borderStrokeWidth] Border stroke size\n * @param {Array} [config.borderDash] Array for border dash.\n * @param {String} [config.anchorFill] Anchor fill color\n * @param {String} [config.anchorStroke] Anchor stroke color\n * @param {Number} [config.anchorCornerRadius] Anchor corner radius\n * @param {Number} [config.anchorStrokeWidth] Anchor stroke size\n * @param {Number} [config.anchorSize] Default is 10\n * @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true\n * @param {String} [config.shiftBehavior] How does transformer react on shift key press when we are moving edges? Default is 'default'\n * @param {Boolean} [config.centeredScaling] Should we resize relative to node's center? Default is false\n * @param {Array} [config.enabledAnchors] Array of names of enabled handles\n * @param {Boolean} [config.flipEnabled] Can we flip/mirror shape on transform?. True by default\n * @param {Function} [config.boundBoxFunc] Bounding box function, see {@link Konva.Transformer#boundBoxFunc}\n * @param {Function} [config.anchorDragBoundFunc] Function bounding the position of a dragged anchor, see {@link Konva.Transformer#anchorDragBoundFunc}\n * @param {Function} [config.anchorStyleFunc] Function styling every anchor, see {@link Konva.Transformer#anchorStyleFunc}\n * @param {Boolean} [config.ignoreStroke] Should we ignore stroke size? Default is false\n * @param {Boolean} [config.useSingleNodeRotation] When just one node attached, should we use its rotation for transformer?\n * @param {Boolean} [config.shouldOverdrawWholeArea] Should we fill whole transformer area with fake transparent shape to enable dragging from empty spaces?\n * @example\n * var transformer = new Konva.Transformer({\n * nodes: [rectangle],\n * rotateAnchorOffset: 60,\n * enabledAnchors: ['top-left', 'top-right', 'bottom-left', 'bottom-right']\n * });\n * layer.add(transformer);\n */\nexport class Transformer extends Group {\n // the hit graph of a layer is not drawn while a transformer on it, or of\n // a node on it, is transforming (see Layer.shouldDrawHit)\n static _isLayerTransforming(layer) {\n for (const tr of activeTransformers) {\n if (tr.getLayer() === layer ||\n tr._nodes.some((node) => node.getLayer() === layer)) {\n return true;\n }\n }\n return false;\n }\n constructor(config) {\n // call super constructor\n super(config);\n this._movingAnchorName = null;\n this._anchors = {};\n this._transforming = false;\n // true while _fitNodesInto writes the new attrs into the nodes\n this._fitting = false;\n // the window the transform events are listened to. The stage may be\n // rendered in another window than the one Konva was imported into\n this._transformWindow = null;\n this._elementsCreated = false;\n this._updateScheduled = false;\n this._createElements();\n // bindings\n this._handleMouseMove = this._handleMouseMove.bind(this);\n this._handleMouseUp = this._handleMouseUp.bind(this);\n this.update = this.update.bind(this);\n // update transformer data for certain attr changes\n this.on(ATTR_CHANGE_LIST, this.update);\n if (this.getNode()) {\n this.update();\n }\n }\n /**\n * alias to `tr.nodes([shape])`/ This method is deprecated and will be removed soon.\n * @method\n * @name Konva.Transformer#attachTo\n * @returns {Konva.Transformer}\n * @example\n * transformer.attachTo(shape);\n */\n attachTo(node) {\n this.setNode(node);\n return this;\n }\n setNode(node) {\n Util.warn('tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.');\n return this.setNodes([node]);\n }\n getNode() {\n return this._nodes && this._nodes[0];\n }\n _getEventNamespace() {\n return EVENTS_NAME + this._id;\n }\n setNodes(nodes = []) {\n if (this._nodes && this._nodes.length) {\n this.detach();\n }\n const filteredNodes = nodes.filter((node) => {\n // check if ancestor of the transformer\n if (node.isAncestorOf(this)) {\n Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');\n return false;\n }\n return true;\n });\n this._nodes = nodes = filteredNodes;\n if (nodes.length === 1 && this.useSingleNodeRotation()) {\n this.rotation(nodes[0].getAbsoluteRotation());\n }\n else {\n this.rotation(0);\n }\n this._nodes.forEach((node) => {\n const onChange = () => {\n var _a;\n // Perf: skip the changes _fitNodesInto makes itself — it does the\n // final _resetTransformCache + update, so per-attr fan-out here is\n // pure waste (was O(N*events) per resize step). A change made between\n // two pointer moves (e.g. a deferred state update) must get through.\n if (this._fitting) {\n (_a = this._nodeRectCache) === null || _a === void 0 ? void 0 : _a.delete(node);\n return;\n }\n if (this.nodes().length === 1 && this.useSingleNodeRotation()) {\n this.rotation(this.nodes()[0].getAbsoluteRotation());\n }\n // Cache reset stays synchronous so sync reads of tr.x() etc. are fresh.\n this._resetTransformCache(node);\n if (!this.isDragging()) {\n // Perf: an ancestor cascade (e.g. stage drag) fires\n // absoluteTransformChange on every attached node — without batching,\n // a refresh runs once per node and each call walks all N nodes via\n // __getNodeRect, giving O(N^2) per drag frame.\n this._scheduleUpdate();\n }\n };\n if (node._attrsAffectingSize.length) {\n const additionalEvents = node._attrsAffectingSize\n .map((prop) => prop + 'Change.' + this._getEventNamespace())\n .join(' ');\n node.on(additionalEvents, onChange);\n }\n node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);\n node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);\n node.on(`destroy.${this._getEventNamespace()}`, () => {\n // a destroyed node has nothing left to transform\n this.setNodes(this._nodes.filter((n) => n !== node));\n });\n this._proxyDrag(node);\n });\n this._resetTransformCache();\n // we may need it if we set node in initial props\n // so elements are not defined yet\n if (this._elementsCreated) {\n this.update();\n }\n return this;\n }\n _proxyDrag(node) {\n let lastPos;\n node.on(`dragstart.${this._getEventNamespace()}`, (e) => {\n lastPos = node.getAbsolutePosition();\n // actual dragging of Transformer doesn't make sense\n // but we need to make sure it also has all drag events\n if (!this.isDragging() && node !== this._back) {\n this.startDrag(e, false);\n }\n });\n node.on(`dragmove.${this._getEventNamespace()}`, (e) => {\n if (!lastPos) {\n return;\n }\n const abs = node.getAbsolutePosition();\n const dx = abs.x - lastPos.x;\n const dy = abs.y - lastPos.y;\n this.nodes().forEach((otherNode) => {\n if (otherNode === node) {\n return;\n }\n if (otherNode.isDragging()) {\n return;\n }\n const otherAbs = otherNode.getAbsolutePosition();\n otherNode.setAbsolutePosition({\n x: otherAbs.x + dx,\n y: otherAbs.y + dy,\n });\n otherNode.startDrag(e);\n });\n lastPos = null;\n });\n }\n getNodes() {\n return this._nodes || [];\n }\n /**\n * return the name of current active anchor\n * @method\n * @name Konva.Transformer#getActiveAnchor\n * @returns {String | Null}\n * @example\n * transformer.getActiveAnchor();\n */\n getActiveAnchor() {\n return this._movingAnchorName;\n }\n /**\n * detach transformer from an attached node\n * @method\n * @name Konva.Transformer#detach\n * @returns {Konva.Transformer}\n * @example\n * transformer.detach();\n */\n detach() {\n // remove events\n if (this._nodes) {\n this._nodes.forEach((node) => {\n node.off('.' + this._getEventNamespace());\n });\n }\n this._nodes = [];\n this._resetTransformCache();\n }\n /**\n * bind events to the Transformer. You can use events: `transform`, `transformstart`, `transformend`, `dragstart`, `dragmove`, `dragend`\n * @method\n * @name Konva.Transformer#on\n * @param {String} evtStr e.g. 'transform'\n * @param {Function} handler The handler function. The first argument of that function is event object. Event object has `target` as main target of the event, `currentTarget` as current node listener and `evt` as native browser event.\n * @returns {Konva.Transformer}\n * @example\n * // add click listener\n * tr.on('transformstart', function() {\n * console.log('transform started');\n * });\n */\n _resetTransformCache(changedNode) {\n var _a, _b;\n if (changedNode)\n (_a = this._nodeRectCache) === null || _a === void 0 ? void 0 : _a.delete(changedNode);\n else\n (_b = this._nodeRectCache) === null || _b === void 0 ? void 0 : _b.clear();\n this._clearCache(NODES_RECT);\n this._clearCache('transform');\n this._clearSelfAndDescendantCache('absoluteTransform');\n }\n _getNodeRect() {\n return this._getCache(NODES_RECT, this.__getNodeRect);\n }\n __getNodeRect() {\n var _a;\n const node = this.getNode();\n if (!node) {\n return {\n x: -MAX_SAFE_INTEGER,\n y: -MAX_SAFE_INTEGER,\n width: 0,\n height: 0,\n rotation: 0,\n };\n }\n const rotation = Konva.getAngle(this.rotation());\n const ignoreStroke = this.ignoreStroke();\n const tr = new Transform();\n tr.rotate(-rotation);\n const cache = this._nodeRectCache || (this._nodeRectCache = new Map());\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const node of this.nodes()) {\n // Bounds may only be reused when they are a pure function of the node's\n // own size: then every change reaches us either through _setAttr or\n // through the size probe below. A shape with its own getSelfRect - Line\n // mutates its points array in place, and a user subclass can measure\n // anything at all - may change with no signal, so it is measured every\n // time. Groups depend on their descendants, and a cached ancestor\n // suppresses descendant transform-change notifications, so both are\n // measured too.\n const cacheable = node instanceof Shape &&\n node.getSelfRect === Shape.prototype.getSelfRect &&\n !node._hasCachedAncestor();\n // width() and height() are the only inputs of the default getSelfRect and\n // they can come from outside the attrs (an Image source that loads or\n // resizes, Text metrics), so the attr revision alone cannot key them.\n const width = cacheable ? node.width() : 0;\n const height = cacheable ? node.height() : 0;\n if (cacheable)\n (_a = node._attrsVersion) !== null && _a !== void 0 ? _a : (node._attrsVersion = 0);\n let bounds = cacheable ? cache.get(node) : undefined;\n if (!bounds ||\n bounds.rotation !== rotation ||\n bounds.ignoreStroke !== ignoreStroke ||\n bounds.version !== node._attrsVersion ||\n bounds.width !== width ||\n bounds.height !== height) {\n const box = node.getClientRect({\n skipTransform: true,\n skipShadow: true,\n skipStroke: ignoreStroke,\n });\n const points = [\n { x: box.x, y: box.y },\n { x: box.x + box.width, y: box.y },\n { x: box.x + box.width, y: box.y + box.height },\n { x: box.x, y: box.y + box.height },\n ];\n const trans = node.getAbsoluteTransform();\n bounds = {\n rotation,\n ignoreStroke,\n width,\n height,\n version: node._attrsVersion || 0,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity,\n };\n for (const point of points) {\n const projected = tr.point(trans.point(point));\n bounds.minX = Math.min(bounds.minX, projected.x);\n bounds.minY = Math.min(bounds.minY, projected.y);\n bounds.maxX = Math.max(bounds.maxX, projected.x);\n bounds.maxY = Math.max(bounds.maxY, projected.y);\n }\n if (cacheable)\n cache.set(node, bounds);\n }\n minX = Math.min(minX, bounds.minX);\n minY = Math.min(minY, bounds.minY);\n maxX = Math.max(maxX, bounds.maxX);\n maxY = Math.max(maxY, bounds.maxY);\n }\n tr.invert();\n const p = tr.point({ x: minX, y: minY });\n return {\n x: p.x,\n y: p.y,\n width: maxX - minX,\n height: maxY - minY,\n rotation: Konva.getAngle(this.rotation()),\n };\n }\n getX() {\n return this._getNodeRect().x;\n }\n getY() {\n return this._getNodeRect().y;\n }\n getWidth() {\n return this._getNodeRect().width;\n }\n getHeight() {\n return this._getNodeRect().height;\n }\n _createElements() {\n this._createBack();\n ANCHORS_NAMES.forEach((name) => {\n this._createAnchor(name);\n });\n this._createAnchor('rotater');\n this._elementsCreated = true;\n }\n _createAnchor(name) {\n const anchor = new Rect({\n stroke: 'rgb(0, 161, 255)',\n fill: 'white',\n strokeWidth: 1,\n name: name + ' _anchor',\n dragDistance: 0,\n // make it draggable,\n // so activating the anchor will not start drag&drop of any parent\n draggable: true,\n hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',\n });\n this._anchors[name] = anchor;\n const self = this;\n anchor.on('mousedown touchstart', function (e) {\n self._handleMouseDown(e);\n });\n anchor.on('dragstart', (e) => {\n anchor.stopDrag();\n e.cancelBubble = true;\n });\n anchor.on('dragend', (e) => {\n e.cancelBubble = true;\n });\n // add hover styling\n anchor.on('mouseenter', () => {\n const rad = Konva.getAngle(this.rotation());\n const rotateCursor = this.rotateAnchorCursor();\n const cursor = getCursor(name, rad, rotateCursor);\n anchor.getStage().content &&\n (anchor.getStage().content.style.cursor = cursor);\n this._cursorChange = true;\n });\n anchor.on('mouseout', () => {\n anchor.getStage().content &&\n (anchor.getStage().content.style.cursor = '');\n this._cursorChange = false;\n });\n this.add(anchor);\n }\n _createBack() {\n const back = new Shape({\n name: 'back',\n width: 0,\n height: 0,\n sceneFunc(ctx, shape) {\n const tr = shape.getParent();\n const padding = tr.padding();\n const width = shape.width();\n const height = shape.height();\n ctx.beginPath();\n ctx.rect(-padding, -padding, width + padding * 2, height + padding * 2);\n if (tr.rotateEnabled() && tr.rotateLineVisible()) {\n // Calculate rotation line position based on rotateAnchorAngle\n const rotateAnchorAngle = tr.rotateAnchorAngle();\n const rotateAnchorOffset = tr.rotateAnchorOffset();\n const rad = Util.degToRad(rotateAnchorAngle);\n // Direction vector (0 degrees = up/top)\n const dirX = Math.sin(rad);\n const dirY = -Math.cos(rad);\n // Center of the box\n const cx = width / 2;\n const cy = height / 2;\n // Find intersection with box edge\n let t = Infinity;\n if (dirY < 0) {\n t = Math.min(t, -cy / dirY);\n }\n else if (dirY > 0) {\n t = Math.min(t, (height - cy) / dirY);\n }\n if (dirX < 0) {\n t = Math.min(t, -cx / dirX);\n }\n else if (dirX > 0) {\n t = Math.min(t, (width - cx) / dirX);\n }\n // Edge point (start of line)\n const edgeX = cx + dirX * t;\n const edgeY = cy + dirY * t;\n // End point with offset\n const sign = Util._sign(height);\n const endX = edgeX + dirX * rotateAnchorOffset * sign;\n const endY = edgeY + dirY * rotateAnchorOffset * sign;\n ctx.moveTo(edgeX, edgeY);\n ctx.lineTo(endX, endY);\n }\n ctx.fillStrokeShape(shape);\n },\n hitFunc: (ctx, shape) => {\n if (!this.shouldOverdrawWholeArea()) {\n return;\n }\n const padding = this.padding();\n ctx.beginPath();\n ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);\n ctx.fillStrokeShape(shape);\n },\n });\n this._back = back;\n this.add(back);\n this._proxyDrag(back);\n // do not bubble drag from the back shape\n // because we already \"drag\" whole transformer\n // so we don't want to trigger drag twice on transformer\n back.on('dragstart', (e) => {\n e.cancelBubble = true;\n });\n back.on('dragmove', (e) => {\n e.cancelBubble = true;\n });\n back.on('dragend', (e) => {\n e.cancelBubble = true;\n });\n // force self update when we drag with shouldOverDrawWholeArea setting\n this.on('dragmove', (e) => {\n this.update();\n });\n }\n _handleMouseDown(e) {\n var _a, _b;\n // do nothing if we already transforming\n // that is possible to trigger with multitouch\n if (this._transforming) {\n return;\n }\n this._movingAnchorName = e.target.name().split(' ')[0];\n const attrs = this._getNodeRect();\n const width = attrs.width;\n const height = attrs.height;\n const hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));\n this.sin = Math.abs(height / hypotenuse);\n this.cos = Math.abs(width / hypotenuse);\n // the window that owns the stage is the one that gets the pointer events\n const win = (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._getOwnerWindow();\n this._transformWindow = win || null;\n if (win) {\n win.addEventListener('mousemove', this._handleMouseMove);\n win.addEventListener('touchmove', this._handleMouseMove);\n win.addEventListener('mouseup', this._handleMouseUp, true);\n win.addEventListener('touchend', this._handleMouseUp, true);\n win.addEventListener('touchcancel', this._handleMouseUp, true);\n }\n this._transforming = true;\n // the pointer that hit the anchor (a touchstart can land several fingers)\n this._pointerId = (_b = e.pointerId) !== null && _b !== void 0 ? _b : Util._getFirstPointerId(e.evt);\n const ap = e.target.getAbsolutePosition();\n const pos = e.target.getStage()._getPointerById(this._pointerId);\n this._anchorDragOffset = {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n };\n activeTransformers.add(this);\n this._fire('transformstart', { evt: e.evt, target: this.getNode() });\n this._nodes.forEach((target) => {\n target._fire('transformstart', { evt: e.evt, target });\n });\n }\n _handleMouseMove(e) {\n var _a;\n (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._batchEvents(() => this._moveTransform(e));\n }\n _moveTransform(e) {\n let x, y, newHypotenuse;\n const anchorNode = this._anchors[this._movingAnchorName];\n const stage = anchorNode.getStage();\n stage.setPointersPositions(e);\n const pp = stage._getPointerById(this._pointerId);\n if (!pp) {\n return;\n }\n let newNodePos = {\n x: pp.x - this._anchorDragOffset.x,\n y: pp.y - this._anchorDragOffset.y,\n };\n const oldAbs = anchorNode.getAbsolutePosition();\n if (this.anchorDragBoundFunc()) {\n newNodePos = this.anchorDragBoundFunc()(oldAbs, newNodePos, e);\n }\n anchorNode.setAbsolutePosition(newNodePos);\n const newAbs = anchorNode.getAbsolutePosition();\n // console.log(oldAbs, newNodePos, newAbs);\n if (oldAbs.x === newAbs.x && oldAbs.y === newAbs.y) {\n return;\n }\n // rotater is working very differently, so do it first\n if (this._movingAnchorName === 'rotater') {\n const attrs = this._getNodeRect();\n x = anchorNode.x() - attrs.width / 2;\n y = -anchorNode.y() + attrs.height / 2;\n // Calculate angle from center to current anchor position\n // Offset by rotateAnchorAngle so we measure rotation from the anchor's starting position\n const rotateAnchorAngleRad = Konva.getAngle(this.rotateAnchorAngle());\n let delta = Math.atan2(-y, x) + Math.PI / 2 - rotateAnchorAngleRad;\n if (attrs.height < 0) {\n delta -= Math.PI;\n }\n const oldRotation = Konva.getAngle(this.rotation());\n const newRotation = oldRotation + delta;\n const tol = Konva.getAngle(this.rotationSnapTolerance());\n const snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);\n const diff = snappedRot - attrs.rotation;\n const shape = rotateAroundCenter(attrs, diff);\n this._fitNodesInto(shape, e);\n return;\n }\n const shiftBehavior = this.shiftBehavior();\n let keepProportion;\n if (shiftBehavior === 'inverted') {\n keepProportion = this.keepRatio() && !e.shiftKey;\n }\n else if (shiftBehavior === 'none') {\n keepProportion = this.keepRatio();\n }\n else {\n keepProportion = this.keepRatio() || e.shiftKey;\n }\n let centeredScaling = this.centeredScaling() || e.altKey;\n // with keepRatio, a corner anchor doesn't follow the pointer — the blocks\n // below project it onto the ratio diagonal. _doFitNodesInto must know\n // that to skip the padding flip compensation (issue #1878)\n let anchorProjected = false;\n if (this._movingAnchorName === 'top-left') {\n if (keepProportion) {\n anchorProjected = true;\n const comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this._anchors['bottom-right'].x(),\n y: this._anchors['bottom-right'].y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n const reverseX = this._anchors['top-left'].x() > comparePoint.x ? -1 : 1;\n const reverseY = this._anchors['top-left'].y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this._anchors['top-left'].x(comparePoint.x - x);\n this._anchors['top-left'].y(comparePoint.y - y);\n }\n }\n else if (this._movingAnchorName === 'top-center') {\n this._anchors['top-left'].y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'top-right') {\n if (keepProportion) {\n anchorProjected = true;\n const comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this._anchors['bottom-left'].x(),\n y: this._anchors['bottom-left'].y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n const reverseX = this._anchors['top-right'].x() < comparePoint.x ? -1 : 1;\n const reverseY = this._anchors['top-right'].y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this._anchors['top-right'].x(comparePoint.x + x);\n this._anchors['top-right'].y(comparePoint.y - y);\n }\n var pos = anchorNode.position();\n this._anchors['top-left'].y(pos.y);\n this._anchors['bottom-right'].x(pos.x);\n }\n else if (this._movingAnchorName === 'middle-left') {\n this._anchors['top-left'].x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'middle-right') {\n this._anchors['bottom-right'].x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'bottom-left') {\n if (keepProportion) {\n anchorProjected = true;\n const comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this._anchors['top-right'].x(),\n y: this._anchors['top-right'].y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n const reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;\n const reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n anchorNode.x(comparePoint.x - x);\n anchorNode.y(comparePoint.y + y);\n }\n pos = anchorNode.position();\n this._anchors['top-left'].x(pos.x);\n this._anchors['bottom-right'].y(pos.y);\n }\n else if (this._movingAnchorName === 'bottom-center') {\n this._anchors['bottom-right'].y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'bottom-right') {\n if (keepProportion) {\n anchorProjected = true;\n const comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this._anchors['top-left'].x(),\n y: this._anchors['top-left'].y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n const reverseX = this._anchors['bottom-right'].x() < comparePoint.x ? -1 : 1;\n const reverseY = this._anchors['bottom-right'].y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this._anchors['bottom-right'].x(comparePoint.x + x);\n this._anchors['bottom-right'].y(comparePoint.y + y);\n }\n }\n else {\n console.error(new Error('Wrong position argument of selection resizer: ' +\n this._movingAnchorName));\n }\n centeredScaling = this.centeredScaling() || e.altKey;\n if (centeredScaling) {\n const topLeft = this._anchors['top-left'];\n const bottomRight = this._anchors['bottom-right'];\n const topOffsetX = topLeft.x();\n const topOffsetY = topLeft.y();\n const bottomOffsetX = this.getWidth() - bottomRight.x();\n const bottomOffsetY = this.getHeight() - bottomRight.y();\n bottomRight.move({\n x: -topOffsetX,\n y: -topOffsetY,\n });\n topLeft.move({\n x: bottomOffsetX,\n y: bottomOffsetY,\n });\n }\n const absPos = this._anchors['top-left'].getAbsolutePosition();\n x = absPos.x;\n y = absPos.y;\n const width = this._anchors['bottom-right'].x() - this._anchors['top-left'].x();\n const height = this._anchors['bottom-right'].y() - this._anchors['top-left'].y();\n this._fitNodesInto({\n x: x,\n y: y,\n width: width,\n height: height,\n rotation: Konva.getAngle(this.rotation()),\n }, e, anchorProjected);\n }\n _handleMouseUp(e) {\n // only the pointer that grabbed the anchor ends the transform\n const stage = this.getStage();\n if (stage) {\n stage.setPointersPositions(e);\n if (!stage._changedPointerPositions.some((p) => p.id === this._pointerId)) {\n return;\n }\n }\n if (stage)\n stage._batchEvents(() => this._removeEvents(e));\n else\n this._removeEvents(e);\n }\n // the transformer positions itself in absolute coordinates (see\n // _getNodeRect), whatever the transforms of its ancestors are\n getAbsoluteTransform(top) {\n const at = this.getTransform();\n return top ? top.getAbsoluteTransform().copy().invert().multiply(at) : at;\n }\n _removeEvents(e) {\n var _a;\n if (this._transforming) {\n this._transforming = false;\n const win = this._transformWindow;\n this._transformWindow = null;\n if (win) {\n win.removeEventListener('mousemove', this._handleMouseMove);\n win.removeEventListener('touchmove', this._handleMouseMove);\n win.removeEventListener('mouseup', this._handleMouseUp, true);\n win.removeEventListener('touchend', this._handleMouseUp, true);\n win.removeEventListener('touchcancel', this._handleMouseUp, true);\n }\n const node = this.getNode();\n activeTransformers.delete(this);\n this._fire('transformend', { evt: e, target: node });\n // redraw layer to restore hit graph\n (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n if (node) {\n this._nodes.forEach((target) => {\n var _a;\n target._fire('transformend', { evt: e, target });\n // redraw layer to restore hit graph\n (_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n });\n }\n this._movingAnchorName = null;\n }\n }\n _fitNodesInto(newAttrs, evt, anchorProjected = false) {\n // Perf: suspend autoDraw for the whole method so per-attr _setAttr writes\n // don't each trigger _requestDraw -> getLayer parent-chain walks.\n // batchDraw per affected layer is issued at the end.\n const prevAutoDraw = Konva.autoDrawEnabled;\n Konva.autoDrawEnabled = false;\n this._fitting = true;\n try {\n return this._doFitNodesInto(newAttrs, evt, anchorProjected);\n }\n finally {\n Konva.autoDrawEnabled = prevAutoDraw;\n this._fitting = false;\n }\n }\n _doFitNodesInto(newAttrs, evt, anchorProjected = false) {\n const oldAttrs = this._getNodeRect();\n const minSize = 1;\n // a zero-size box has a singular transform, there is nothing to scale from\n if (!oldAttrs.width ||\n !oldAttrs.height ||\n Util._inRange(newAttrs.width, -this.padding() * 2 - minSize, minSize) ||\n Util._inRange(newAttrs.height, -this.padding() * 2 - minSize, minSize)) {\n this.update();\n return;\n }\n const t = new Transform();\n t.rotate(Konva.getAngle(this.rotation()));\n // the ±2*padding shifts below assume the box size passed through zero\n // continuously (the anchor tied to the pointer). A projected anchor snaps\n // the box across zero instead; the shifts then leave the drag state\n // inconsistent with the real anchor position and the box flips back and\n // forth on every following move (issue #1878) — so flip only the anchor\n // name, exactly as when padding is 0.\n const flipPadding = anchorProjected ? 0 : this.padding() * 2;\n let widthFlip = null;\n let heightFlip = null;\n if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('left') >= 0) {\n const offset = t.point({\n x: -flipPadding,\n y: 0,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n newAttrs.width += flipPadding;\n widthFlip = { axis: 'width', from: 'left', to: 'right', offset };\n }\n else if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('right') >= 0) {\n const offset = t.point({\n x: flipPadding,\n y: 0,\n });\n newAttrs.width += flipPadding;\n widthFlip = { axis: 'width', from: 'right', to: 'left', offset };\n }\n if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('top') >= 0) {\n const offset = t.point({\n x: 0,\n y: -flipPadding,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n newAttrs.height += flipPadding;\n heightFlip = { axis: 'height', from: 'top', to: 'bottom', offset };\n }\n else if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('bottom') >= 0) {\n const offset = t.point({\n x: 0,\n y: flipPadding,\n });\n newAttrs.height += flipPadding;\n heightFlip = { axis: 'height', from: 'bottom', to: 'top', offset };\n }\n if (this.boundBoxFunc()) {\n const bounded = this.boundBoxFunc()(oldAttrs, newAttrs);\n if (bounded) {\n newAttrs = bounded;\n }\n else {\n Util.warn('boundBoxFunc returned falsy. You should return new bound rect from it!');\n }\n }\n // a staged flip survived only if the bounded size is still negative on\n // its axis\n for (const flip of [widthFlip, heightFlip]) {\n if (flip && newAttrs[flip.axis] < 0 && this._movingAnchorName) {\n this._movingAnchorName = this._movingAnchorName.replace(flip.from, flip.to);\n this._anchorDragOffset.x -= flip.offset.x;\n this._anchorDragOffset.y -= flip.offset.y;\n }\n }\n // base size value doesn't really matter\n // we just need to think about bounding boxes as transforms\n // but how?\n // the idea is that we have a transformed rectangle with the size of \"baseSize\"\n const baseSize = 10000000;\n const oldTr = new Transform();\n oldTr.translate(oldAttrs.x, oldAttrs.y);\n oldTr.rotate(oldAttrs.rotation);\n oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);\n const newTr = new Transform();\n const newScaleX = newAttrs.width / baseSize;\n const newScaleY = newAttrs.height / baseSize;\n if (this.flipEnabled() === false) {\n newTr.translate(newAttrs.x, newAttrs.y);\n newTr.rotate(newAttrs.rotation);\n newTr.translate(newAttrs.width < 0 ? newAttrs.width : 0, newAttrs.height < 0 ? newAttrs.height : 0);\n newTr.scale(Math.abs(newScaleX), Math.abs(newScaleY));\n }\n else {\n newTr.translate(newAttrs.x, newAttrs.y);\n newTr.rotate(newAttrs.rotation);\n newTr.scale(newScaleX, newScaleY);\n }\n // now lets think we had [old transform] and n ow we have [new transform]\n // Now, the questions is: how can we transform \"parent\" to go from [old transform] into [new transform]\n // in equation it will be:\n // [delta transform] * [old transform] = [new transform]\n // that means that\n // [delta transform] = [new transform] * [old transform inverted]\n const delta = newTr.multiply(oldTr.invert());\n // Perf: collect unique affected layers and batchDraw each once at the end\n // (was once per node — O(N)).\n const layersToDraw = new Set();\n this._nodes.forEach((node) => {\n // check to close this issue: https://github.com/konvajs/konva/issues/1957\n // a node can be destroyed during the transformation\n // probably a developer must remove it from transformer\n if (!node.getStage()) {\n // do we need a helping message?\n // Util.error(\n // 'Node is not attached to the stage. This is not allowed. Please attach the node to the stage before transforming. If node was destroyed, make sure to remove it from transformer.'\n // );\n return;\n }\n // for each node we have the same [delta transform]\n // the equations is\n // [delta transform] * [parent transform] * [old local transform] = [parent transform] * [new local transform]\n // and we need to find [new local transform]\n // [new local] = [parent inverted] * [delta] * [parent] * [old local]\n const parentTransform = node.getParent().getAbsoluteTransform();\n const localTransform = node.getTransform().copy();\n // skip offset:\n localTransform.translate(node.offsetX(), node.offsetY());\n const newLocalTransform = new Transform();\n newLocalTransform\n .multiply(parentTransform.copy().invert())\n .multiply(delta)\n .multiply(parentTransform)\n .multiply(localTransform);\n const attrs = newLocalTransform.decompose();\n node.setAttrs(attrs);\n const layer = node.getLayer();\n if (layer) {\n layersToDraw.add(layer);\n }\n });\n this.rotation(Util._getRotation(newAttrs.rotation));\n // trigger transform event AFTER we update rotation\n this._nodes.forEach((node) => {\n this._fire('transform', { evt: evt, target: node });\n node._fire('transform', { evt: evt, target: node });\n });\n this._resetTransformCache();\n this.update();\n layersToDraw.add(this.getLayer());\n layersToDraw.forEach((layer) => layer && layer.batchDraw());\n }\n // Inside an absoluteTransform cascade, queue a single update to run when\n // the cascade ends; outside a cascade, run synchronously so reads of\n // transformer state stay consistent.\n _scheduleUpdate() {\n if (this._updateScheduled)\n return;\n this._updateScheduled = true;\n Node._runAfterAbsTransformCascade(() => {\n var _a;\n this._updateScheduled = false;\n if (!((_a = this._nodes) === null || _a === void 0 ? void 0 : _a.length) || this._fitting || this.isDragging()) {\n return;\n }\n this._update();\n });\n }\n /**\n * force update of Konva.Transformer.\n * Use it when you updated attached Konva.Group and now you need to reset transformer size\n * @method\n * @name Konva.Transformer#forceUpdate\n */\n forceUpdate() {\n this._resetTransformCache();\n this.update();\n }\n update() {\n // Explicit updates and Transformer configuration changes also refresh\n // styles and layout when the selected nodes' bounds are unchanged.\n this._lastNodeRect = undefined;\n this._update();\n }\n _update() {\n var _a;\n const attrs = this._getNodeRect();\n this._updateElements(attrs);\n const draggable = this.nodes().some((node) => node.draggable());\n if (this._back.draggable() !== draggable) {\n this._back.draggable(draggable);\n }\n const styleFunc = this.anchorStyleFunc();\n if (styleFunc) {\n Object.values(this._anchors).forEach((node) => styleFunc(node));\n }\n (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n }\n _updateElements(attrs) {\n const previous = this._lastNodeRect;\n // Only element layout is cached. Drag handling, user callbacks and drawing\n // remain in _update(). Custom styling needs fresh defaults on every update.\n if (previous &&\n !this.anchorStyleFunc() &&\n attrs.x === previous.x &&\n attrs.y === previous.y &&\n attrs.width === previous.width &&\n attrs.height === previous.height &&\n attrs.rotation === previous.rotation) {\n return;\n }\n this._lastNodeRect = { ...attrs };\n this.rotation(Util._getRotation(attrs.rotation));\n const width = attrs.width;\n const height = attrs.height;\n const enabledAnchors = this.enabledAnchors();\n const resizeEnabled = this.resizeEnabled();\n const padding = this.padding();\n const anchorSize = this.anchorSize();\n const anchors = Object.values(this._anchors);\n anchors.forEach((node) => {\n node.setAttrs({\n width: anchorSize,\n height: anchorSize,\n offsetX: anchorSize / 2,\n offsetY: anchorSize / 2,\n stroke: this.anchorStroke(),\n strokeWidth: this.anchorStrokeWidth(),\n fill: this.anchorFill(),\n cornerRadius: this.anchorCornerRadius(),\n });\n });\n this._anchors['top-left'].setAttrs({\n x: 0,\n y: 0,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-left') >= 0,\n });\n this._anchors['top-center'].setAttrs({\n x: width / 2,\n y: 0,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-center') >= 0,\n });\n this._anchors['top-right'].setAttrs({\n x: width,\n y: 0,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-right') >= 0,\n });\n this._anchors['middle-left'].setAttrs({\n x: 0,\n y: height / 2,\n offsetX: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-left') >= 0,\n });\n this._anchors['middle-right'].setAttrs({\n x: width,\n y: height / 2,\n offsetX: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-right') >= 0,\n });\n this._anchors['bottom-left'].setAttrs({\n x: 0,\n y: height,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-left') >= 0,\n });\n this._anchors['bottom-center'].setAttrs({\n x: width / 2,\n y: height,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-center') >= 0,\n });\n this._anchors['bottom-right'].setAttrs({\n x: width,\n y: height,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,\n });\n // Calculate rotation anchor position based on rotateAnchorAngle\n const rotateAnchorAngle = this.rotateAnchorAngle();\n const rotateAnchorOffset = this.rotateAnchorOffset();\n const rad = Util.degToRad(rotateAnchorAngle);\n // Direction vector (0 degrees = up/top)\n const dirX = Math.sin(rad);\n const dirY = -Math.cos(rad);\n // Center of the box\n const cx = width / 2;\n const cy = height / 2;\n // Find intersection with box edge\n // Calculate time to hit each edge from center\n let t = Infinity;\n // Handle each direction\n if (dirY < 0) {\n // Moving up, check top edge (y = 0)\n t = Math.min(t, -cy / dirY);\n }\n else if (dirY > 0) {\n // Moving down, check bottom edge (y = height)\n t = Math.min(t, (height - cy) / dirY);\n }\n if (dirX < 0) {\n // Moving left, check left edge (x = 0)\n t = Math.min(t, -cx / dirX);\n }\n else if (dirX > 0) {\n // Moving right, check right edge (x = width)\n t = Math.min(t, (width - cx) / dirX);\n }\n // Edge point\n const edgeX = cx + dirX * t;\n const edgeY = cy + dirY * t;\n // Final position with offset (accounting for height sign and padding)\n const sign = Util._sign(height);\n this._anchors['rotater'].setAttrs({\n x: edgeX + dirX * rotateAnchorOffset * sign,\n y: edgeY + dirY * rotateAnchorOffset * sign - padding * dirY,\n visible: this.rotateEnabled(),\n });\n this._back.setAttrs({\n width: width,\n height: height,\n visible: this.borderEnabled(),\n stroke: this.borderStroke(),\n strokeWidth: this.borderStrokeWidth(),\n dash: this.borderDash(),\n x: 0,\n y: 0,\n });\n }\n /**\n * determine if transformer is in active transform\n * @method\n * @name Konva.Transformer#isTransforming\n * @returns {Boolean}\n */\n isTransforming() {\n return this._transforming;\n }\n /**\n * Stop active transform action\n * @method\n * @name Konva.Transformer#stopTransform\n * @returns {Boolean}\n */\n stopTransform() {\n if (this._transforming) {\n this._removeEvents();\n }\n }\n destroy() {\n if (this.getStage() && this._cursorChange) {\n this.getStage().content && (this.getStage().content.style.cursor = '');\n }\n Group.prototype.destroy.call(this);\n this.detach();\n this._removeEvents();\n return this;\n }\n // Transformer manages its own internal children (anchors, back shape).\n // Adding external nodes as children can cause infinite recursion because\n // the Transformer's absoluteTransform depends on nodes' transforms.\n // Use tr.nodes([node]) to attach nodes instead.\n add(...children) {\n if (this._elementsCreated) {\n Util.error('You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.');\n return this;\n }\n return super.add(...children);\n }\n // do not work as a container\n // we will recreate inner nodes manually\n toObject() {\n return Node.prototype.toObject.call(this);\n }\n // overwrite clone to NOT use method from Container\n clone(obj) {\n const node = Node.prototype.clone.call(this, obj);\n return node;\n }\n getClientRect(config) {\n if (this.nodes().length > 0) {\n return super.getClientRect(config);\n }\n else {\n // if we are detached return zero size\n // so it will be skipped in calculations\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n }\n}\nTransformer.isTransforming = () => {\n return activeTransformers.size > 0;\n};\nfunction validateAnchors(val) {\n if (!(val instanceof Array)) {\n Util.warn('enabledAnchors value should be an array');\n }\n if (val instanceof Array) {\n val.forEach(function (name) {\n if (ANCHORS_NAMES.indexOf(name) === -1) {\n Util.warn('Unknown anchor name: ' +\n name +\n '. Available names are: ' +\n ANCHORS_NAMES.join(', '));\n }\n });\n }\n return val || [];\n}\nTransformer.prototype.className = 'Transformer';\n_registerNode(Transformer);\n/**\n * get/set enabled handlers\n * @name Konva.Transformer#enabledAnchors\n * @method\n * @param {Array} array\n * @returns {Array}\n * @example\n * // get list of handlers\n * var enabledAnchors = transformer.enabledAnchors();\n *\n * // set handlers\n * transformer.enabledAnchors(['top-left', 'top-center', 'top-right', 'middle-right', 'middle-left', 'bottom-left', 'bottom-center', 'bottom-right']);\n */\nFactory.addGetterSetter(Transformer, 'enabledAnchors', ANCHORS_NAMES, validateAnchors);\n/**\n * get/set flip enabled\n * @name Konva.Transformer#flipEnabled\n * @method\n * @param {Boolean} flag\n * @returns {Boolean}\n * @example\n * // get flip enabled property\n * var flipEnabled = transformer.flipEnabled();\n *\n * // set flip enabled property\n * transformer.flipEnabled(false);\n */\nFactory.addGetterSetter(Transformer, 'flipEnabled', true, getBooleanValidator());\n/**\n * get/set resize ability. If false it will automatically hide resizing handlers\n * @name Konva.Transformer#resizeEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get\n * var resizeEnabled = transformer.resizeEnabled();\n *\n * // set\n * transformer.resizeEnabled(false);\n */\nFactory.addGetterSetter(Transformer, 'resizeEnabled', true);\n/**\n * get/set anchor size. Default is 10\n * @name Konva.Transformer#anchorSize\n * @method\n * @param {Number} size\n * @returns {Number}\n * @example\n * // get\n * var anchorSize = transformer.anchorSize();\n *\n * // set\n * transformer.anchorSize(20)\n */\nFactory.addGetterSetter(Transformer, 'anchorSize', 10, getNumberValidator());\n/**\n * get/set ability to rotate.\n * @name Konva.Transformer#rotateEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get\n * var rotateEnabled = transformer.rotateEnabled();\n *\n * // set\n * transformer.rotateEnabled(false);\n */\nFactory.addGetterSetter(Transformer, 'rotateEnabled', true);\n/**\n * get/set visibility of a little line that connects transformer and rotate anchor.\n * @name Konva.Transformer#rotateLineVisible\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get\n * var rotateLineVisible = transformer.rotateLineVisible();\n *\n * // set\n * transformer.rotateLineVisible(false);\n */\nFactory.addGetterSetter(Transformer, 'rotateLineVisible', true);\n/**\n * get/set rotation snaps angles.\n * @name Konva.Transformer#rotationSnaps\n * @method\n * @param {Array} array\n * @returns {Array}\n * @example\n * // get\n * var rotationSnaps = transformer.rotationSnaps();\n *\n * // set\n * transformer.rotationSnaps([0, 90, 180, 270]);\n */\nFactory.addGetterSetter(Transformer, 'rotationSnaps', []);\n/**\n * get/set distance for rotation handler\n * @name Konva.Transformer#rotateAnchorOffset\n * @method\n * @param {Number} offset\n * @returns {Number}\n * @example\n * // get\n * var rotateAnchorOffset = transformer.rotateAnchorOffset();\n *\n * // set\n * transformer.rotateAnchorOffset(100);\n */\nFactory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, getNumberValidator());\n/**\n * get/set the angle (in degrees) of the rotation anchor position around the bounding box.\n * 0 = top-center (default), 90 = middle-right, 180 = bottom-center, -90 = middle-left\n * @name Konva.Transformer#rotateAnchorAngle\n * @method\n * @param {Number} angle\n * @returns {Number}\n * @example\n * // get\n * var rotateAnchorAngle = transformer.rotateAnchorAngle();\n *\n * // set rotation anchor to the right side\n * transformer.rotateAnchorAngle(90);\n *\n * // set rotation anchor to the bottom\n * transformer.rotateAnchorAngle(180);\n */\nFactory.addGetterSetter(Transformer, 'rotateAnchorAngle', 0, getNumberValidator());\n/**\n * get/set rotation anchor cursor\n * @name Konva.Transformer#rotateAnchorCursor\n * @method\n * @param {String} cursorName\n * @returns {String}\n * @example\n * // get\n * var currentRotationAnchorCursor = transformer.rotateAnchorCursor();\n *\n * // set\n * transformer.rotateAnchorCursor('grab');\n */\nFactory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');\n/**\n * get/set distance for rotation tolerance\n * @name Konva.Transformer#rotationSnapTolerance\n * @method\n * @param {Number} tolerance\n * @returns {Number}\n * @example\n * // get\n * var rotationSnapTolerance = transformer.rotationSnapTolerance();\n *\n * // set\n * transformer.rotationSnapTolerance(100);\n */\nFactory.addGetterSetter(Transformer, 'rotationSnapTolerance', 5, getNumberValidator());\n/**\n * get/set visibility of border\n * @name Konva.Transformer#borderEnabled\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get\n * var borderEnabled = transformer.borderEnabled();\n *\n * // set\n * transformer.borderEnabled(false);\n */\nFactory.addGetterSetter(Transformer, 'borderEnabled', true);\n/**\n * get/set anchor stroke color\n * @name Konva.Transformer#anchorStroke\n * @method\n * @param {String} strokeColor\n * @returns {String}\n * @example\n * // get\n * var anchorStroke = transformer.anchorStroke();\n *\n * // set\n * transformer.anchorStroke('red');\n */\nFactory.addGetterSetter(Transformer, 'anchorStroke', 'rgb(0, 161, 255)');\n/**\n * get/set anchor stroke width\n * @name Konva.Transformer#anchorStrokeWidth\n * @method\n * @param {Number} anchorStrokeWidth\n * @returns {Number}\n * @example\n * // get\n * var anchorStrokeWidth = transformer.anchorStrokeWidth();\n *\n * // set\n * transformer.anchorStrokeWidth(3);\n */\nFactory.addGetterSetter(Transformer, 'anchorStrokeWidth', 1, getNumberValidator());\n/**\n * get/set anchor fill color\n * @name Konva.Transformer#anchorFill\n * @method\n * @param {String} anchorFill\n * @returns {String}\n * @example\n * // get\n * var anchorFill = transformer.anchorFill();\n *\n * // set\n * transformer.anchorFill('red');\n */\nFactory.addGetterSetter(Transformer, 'anchorFill', 'white');\n/**\n * get/set anchor corner radius\n * @name Konva.Transformer#anchorCornerRadius\n * @method\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get\n * var anchorCornerRadius = transformer.anchorCornerRadius();\n *\n * // set\n * transformer.anchorCornerRadius(3);\n */\nFactory.addGetterSetter(Transformer, 'anchorCornerRadius', 0, getNumberValidator());\n/**\n * get/set border stroke color\n * @name Konva.Transformer#borderStroke\n * @method\n * @param {Boolean} enabled\n * @returns {Boolean}\n * @example\n * // get\n * var borderStroke = transformer.borderStroke();\n *\n * // set\n * transformer.borderStroke('red');\n */\nFactory.addGetterSetter(Transformer, 'borderStroke', 'rgb(0, 161, 255)');\n/**\n * get/set border stroke width\n * @name Konva.Transformer#borderStrokeWidth\n * @method\n * @param {Number} strokeWidth\n * @returns {Number}\n * @example\n * // get\n * var borderStrokeWidth = transformer.borderStrokeWidth();\n *\n * // set\n * transformer.borderStrokeWidth(3);\n */\nFactory.addGetterSetter(Transformer, 'borderStrokeWidth', 1, getNumberValidator());\n/**\n * get/set border dash array\n * @name Konva.Transformer#borderDash\n * @method\n * @param {Array} dash array\n * @returns {Array}\n * @example\n * // get\n * var borderDash = transformer.borderDash();\n *\n * // set\n * transformer.borderDash([2, 2]);\n */\nFactory.addGetterSetter(Transformer, 'borderDash');\n/**\n * get/set should we keep ratio while resize anchors at corners\n * @name Konva.Transformer#keepRatio\n * @method\n * @param {Boolean} keepRatio\n * @returns {Boolean}\n * @example\n * // get\n * var keepRatio = transformer.keepRatio();\n *\n * // set\n * transformer.keepRatio(false);\n */\nFactory.addGetterSetter(Transformer, 'keepRatio', true);\n/**\n * get/set how to react on skift key while resizing anchors at corners\n * @name Konva.Transformer#shiftBehavior\n * @method\n * @param {String} shiftBehavior\n * @returns {String}\n * @example\n * // get\n * var shiftBehavior = transformer.shiftBehavior();\n *\n * // set\n * transformer.shiftBehavior('none');\n */\nFactory.addGetterSetter(Transformer, 'shiftBehavior', 'default');\n/**\n * get/set should we resize relative to node's center?\n * @name Konva.Transformer#centeredScaling\n * @method\n * @param {Boolean} centeredScaling\n * @returns {Boolean}\n * @example\n * // get\n * var centeredScaling = transformer.centeredScaling();\n *\n * // set\n * transformer.centeredScaling(true);\n */\nFactory.addGetterSetter(Transformer, 'centeredScaling', false);\n/**\n * get/set should we think about stroke while resize? Good to use when a shape has strokeScaleEnabled = false\n * default is false\n * @name Konva.Transformer#ignoreStroke\n * @method\n * @param {Boolean} ignoreStroke\n * @returns {Boolean}\n * @example\n * // get\n * var ignoreStroke = transformer.ignoreStroke();\n *\n * // set\n * transformer.ignoreStroke(true);\n */\nFactory.addGetterSetter(Transformer, 'ignoreStroke', false);\n/**\n * get/set padding\n * @name Konva.Transformer#padding\n * @method\n * @param {Number} padding\n * @returns {Number}\n * @example\n * // get\n * var padding = transformer.padding();\n *\n * // set\n * transformer.padding(10);\n */\nFactory.addGetterSetter(Transformer, 'padding', 0, getNumberValidator());\n/**\n * get/set attached nodes of the Transformer. Transformer will adapt to their size and listen to their events\n * @method\n * @name Konva.Transformer#nodes\n * @returns {Konva.Node}\n * @example\n * // get\n * const nodes = transformer.nodes();\n *\n * // set\n * transformer.nodes([rect, circle]);\n *\n * // push new item:\n * const oldNodes = transformer.nodes();\n * const newNodes = oldNodes.concat([newShape]);\n * // it is important to set new array instance (and concat method above will create it)\n * transformer.nodes(newNodes);\n */\nFactory.addGetterSetter(Transformer, 'nodes');\n// @ts-ignore\n// deprecated\nFactory.addGetterSetter(Transformer, 'node');\n/**\n * get/set bounding box function. **IMPORTANT!** boundBoxFunc operates in absolute coordinates.\n * Both boxes are `{ x, y, width, height, rotation }`, with the rotation in radians.\n * @name Konva.Transformer#boundBoxFunc\n * @method\n * @param {Function} func\n * @returns {Function}\n * @example\n * // get\n * var boundBoxFunc = transformer.boundBoxFunc();\n *\n * // set\n * transformer.boundBoxFunc(function(oldBox, newBox) {\n * // width and height of the boxes are corresponding to total absolute width and height of all nodes combined\n * // so it includes scale of the node.\n * if (newBox.width > 200) {\n * return oldBox;\n * }\n * return newBox;\n * });\n */\nFactory.addGetterSetter(Transformer, 'boundBoxFunc');\n/**\n * get/set dragging func for transformer anchors\n * @name Konva.Transformer#anchorDragBoundFunc\n * @method\n * @param {Function} func\n * @returns {Function}\n * @example\n * // get\n * var anchorDragBoundFunc = transformer.anchorDragBoundFunc();\n *\n * // set\n * transformer.anchorDragBoundFunc(function(oldAbsPos, newAbsPos, event) {\n * return {\n * x: 0,\n * y: newAbsolutePosition.y\n * }\n * });\n */\nFactory.addGetterSetter(Transformer, 'anchorDragBoundFunc');\n/**\n * get/set styling function for transformer anchors to overwrite default styles\n * @name Konva.Transformer#anchorStyleFunc\n * @method\n * @param {Function} func\n * @returns {Function}\n * @example\n * // get\n * var anchorStyleFunc = transformer.anchorStyleFunc();\n *\n * // set\n * transformer.anchorStyleFunc(function(anchor) {\n * // anchor is a simple Konva.Rect instance\n * // it will be executed AFTER all attributes are set, like 'anchorStrokeWidth' or 'anchorFill'\n * if (anchor.hasName('rotater')) {\n * // make rotater anchor filled black and looks like a circle\n * anchor.fill('black');\n * anchor.cornerRadius(anchor.width() / 2);\n * }\n * });\n */\nFactory.addGetterSetter(Transformer, 'anchorStyleFunc');\n/**\n * using this setting you can drag transformer group by dragging empty space between attached nodes\n * shouldOverdrawWholeArea = true may temporary disable all events on attached nodes\n * @name Konva.Transformer#shouldOverdrawWholeArea\n * @method\n * @param {Boolean} shouldOverdrawWholeArea\n * @returns {Boolean}\n * @example\n * // get\n * var shouldOverdrawWholeArea = transformer.shouldOverdrawWholeArea();\n *\n * // set\n * transformer.shouldOverdrawWholeArea(true);\n */\nFactory.addGetterSetter(Transformer, 'shouldOverdrawWholeArea', false);\n/**\n * If you have just one attached node to Transformer it will set its initial rotation to the rotation of that node.\n * In some cases you may need to set a different rotation.\n * @name Konva.Transformer#useSingleNodeRotation\n * @method\n * @param {Boolean} useSingleNodeRotation\n * @returns {Boolean}\n * @example\n * // set flag to false\n * transformer.useSingleNodeRotation(false);\n * // attach a shape\n * transformer.nodes([shape]);\n * transformer.rotation(45);\n * transformer.update();\n */\nFactory.addGetterSetter(Transformer, 'useSingleNodeRotation', true);\nFactory.backCompat(Transformer, {\n lineEnabled: 'borderEnabled',\n rotateHandlerOffset: 'rotateAnchorOffset',\n enabledHandlers: 'enabledAnchors',\n});\n","import { Factory } from \"../Factory.js\";\nimport { Shape } from \"../Shape.js\";\nimport { Konva } from \"../Global.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nimport { _registerNode } from \"../Global.js\";\n/**\n * Wedge constructor\n * @constructor\n * @memberof Konva\n * @augments Konva.Shape\n * @param {Object} config\n * @param {Number} config.angle in degrees\n * @param {Number} config.radius\n * @param {Boolean} [config.clockwise]\n * @@shapeParams\n * @@nodeParams\n * @example\n * // draw a wedge that's pointing downwards\n * var wedge = new Konva.Wedge({\n * radius: 40,\n * fill: 'red',\n * stroke: 'black',\n * strokeWidth: 5,\n * angle: 60,\n * rotation: -120\n * });\n */\nexport class Wedge extends Shape {\n _sceneFunc(context) {\n context.beginPath();\n context.arc(0, 0, Math.abs(this.radius()), 0, Konva.getAngle(this.angle()), this.clockwise());\n context.lineTo(0, 0);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return Math.abs(this.radius()) * 2;\n }\n getHeight() {\n return Math.abs(this.radius()) * 2;\n }\n setWidth(width) {\n this.radius(width / 2);\n }\n setHeight(height) {\n this.radius(height / 2);\n }\n}\nWedge.prototype.className = 'Wedge';\nWedge.prototype._centroid = true;\nWedge.prototype._attrsAffectingSize = ['radius'];\n_registerNode(Wedge);\n/**\n * get/set radius\n * @name Konva.Wedge#radius\n * @method\n * @param {Number} radius\n * @returns {Number}\n * @example\n * // get radius\n * var radius = wedge.radius();\n *\n * // set radius\n * wedge.radius(10);\n */\nFactory.addGetterSetter(Wedge, 'radius', 0, getNumberValidator());\n/**\n * get/set angle in degrees\n * @name Konva.Wedge#angle\n * @method\n * @param {Number} angle\n * @returns {Number}\n * @example\n * // get angle\n * var angle = wedge.angle();\n *\n * // set angle\n * wedge.angle(20);\n */\nFactory.addGetterSetter(Wedge, 'angle', 0, getNumberValidator());\n/**\n * get/set clockwise flag\n * @name Konva.Wedge#clockwise\n * @method\n * @param {Boolean} clockwise\n * @returns {Boolean}\n * @example\n * // get clockwise flag\n * var clockwise = wedge.clockwise();\n *\n * // draw wedge counter-clockwise\n * wedge.clockwise(false);\n *\n * // draw wedge clockwise\n * wedge.clockwise(true);\n */\nFactory.addGetterSetter(Wedge, 'clockwise', false);\nFactory.backCompat(Wedge, {\n angleDeg: 'angle',\n getAngleDeg: 'getAngle',\n setAngleDeg: 'setAngle',\n});\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/*\n the Gauss filter\n master repo: https://github.com/pavelpower/kineticjsGaussFilter\n*/\n/*\n\n StackBlur - a fast almost Gaussian Blur For Canvas\n\n Version: 0.5\n Author: Mario Klingemann\n Contact: mario@quasimondo.com\n Website: http://www.quasimondo.com/StackBlurForCanvas\n Twitter: @quasimondo\n\n In case you find this class useful - especially in commercial projects -\n I am not totally unhappy for a small donation to my PayPal account\n mario@quasimondo.de\n\n Or support me on flattr:\n https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript\n\n Copyright (c) 2010 Mario Klingemann\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n * @license MIT\n */\nfunction BlurStack() {\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n}\nconst mul_table = [\n 512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,\n 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,\n 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,\n 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292,\n 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373,\n 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259,\n 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381,\n 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292,\n 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461,\n 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373,\n 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309,\n 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259,\n 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442,\n 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381,\n 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332,\n 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,\n 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,\n];\nconst shg_table = [\n 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,\n 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,\n 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,\n 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24,\n];\n// the horizontal pass blurs premultiplied colour, otherwise transparent\n// pixels bleed their colour into their neighbours; the vertical pass\n// unpremultiplies again\nfunction premultiply(channel, alpha) {\n return alpha === 255 ? channel : (channel * alpha) / 255;\n}\n// the stack sums overflow 32-bit integers above this radius\nconst MAX_RADIUS = 180;\nfunction filterGaussBlurRGBA(imageData, radius) {\n const pixels = imageData.data, width = imageData.width, height = imageData.height;\n let p, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;\n const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius];\n let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null;\n for (let i = 1; i < div; i++) {\n stack = stack.next = new BlurStack();\n if (i === radiusPlus1) {\n stackEnd = stack;\n }\n }\n stack.next = stackStart;\n yw = yi = 0;\n for (let y = 0; y < height; y++) {\n r_in_sum =\n g_in_sum =\n b_in_sum =\n a_in_sum =\n r_sum =\n g_sum =\n b_sum =\n a_sum =\n 0;\n pa = pixels[yi + 3];\n pr = premultiply(pixels[yi], pa);\n pg = premultiply(pixels[yi + 1], pa);\n pb = premultiply(pixels[yi + 2], pa);\n r_out_sum = radiusPlus1 * pr;\n g_out_sum = radiusPlus1 * pg;\n b_out_sum = radiusPlus1 * pb;\n a_out_sum = radiusPlus1 * pa;\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (let i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n for (let i = 1; i < radiusPlus1; i++) {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n pa = pixels[p + 3];\n r_sum +=\n (stack.r = pr = premultiply(pixels[p], pa)) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = premultiply(pixels[p + 1], pa)) * rbs;\n b_sum += (stack.b = pb = premultiply(pixels[p + 2], pa)) * rbs;\n a_sum += (stack.a = pa) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n }\n stackIn = stackStart;\n stackOut = stackEnd;\n for (let x = 0; x < width; x++) {\n pixels[yi] = (r_sum * mul_sum) >> shg_sum;\n pixels[yi + 1] = (g_sum * mul_sum) >> shg_sum;\n pixels[yi + 2] = (b_sum * mul_sum) >> shg_sum;\n pixels[yi + 3] = (a_sum * mul_sum) >> shg_sum;\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n pa = pixels[p + 3];\n r_in_sum += stackIn.r = premultiply(pixels[p], pa);\n g_in_sum += stackIn.g = premultiply(pixels[p + 1], pa);\n b_in_sum += stackIn.b = premultiply(pixels[p + 2], pa);\n a_in_sum += stackIn.a = pa;\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n a_sum += a_in_sum;\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += 4;\n }\n yw += width;\n }\n for (let x = 0; x < width; x++) {\n g_in_sum =\n b_in_sum =\n a_in_sum =\n r_in_sum =\n g_sum =\n b_sum =\n a_sum =\n r_sum =\n 0;\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (let i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n // the pass primes from the second row, which a 1-pixel-tall image lacks\n let yp = Math.min(1, heightMinus1) * width;\n for (let i = 1; i <= radius; i++) {\n yi = (yp + x) << 2;\n r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;\n b_sum += (stack.b = pb = pixels[yi + 2]) * rbs;\n a_sum += (stack.a = pa = pixels[yi + 3]) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n if (i < heightMinus1) {\n yp += width;\n }\n }\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (let y = 0; y < height; y++) {\n p = yi << 2;\n pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa > 0) {\n pa = 255 / pa;\n pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n }\n else {\n pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;\n }\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p =\n (x +\n ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width) <<\n 2;\n r_sum += r_in_sum += stackIn.r = pixels[p];\n g_sum += g_in_sum += stackIn.g = pixels[p + 1];\n b_sum += b_in_sum += stackIn.b = pixels[p + 2];\n a_sum += a_in_sum += stackIn.a = pixels[p + 3];\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += width;\n }\n }\n}\n/**\n * Blur Filter\n * @function\n * @name Blur\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Blur]);\n * node.blurRadius(10);\n */\nexport const Blur = function Blur(imageData) {\n const radius = Math.min(Math.round(this.blurRadius()), MAX_RADIUS);\n if (radius > 0) {\n filterGaussBlurRGBA(imageData, radius);\n }\n};\nFactory.addGetterSetter(Node, 'blurRadius', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set blur radius. Use with {@link Konva.Filters.Blur} filter\n * @name Konva.Node#blurRadius\n * @method\n * @param {Integer} radius\n * @returns {Integer}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Brighten Filter.\n * @deprecated Use {@link Konva.Filters.Brightness} instead for CSS-compatible behavior.\n * This filter uses additive brightness adjustment (adds a constant value to RGB channels).\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Brighten]);\n * node.brightness(0.8);\n */\nexport const Brighten = function (imageData) {\n const brightness = this.brightness() * 255, data = imageData.data, len = data.length;\n for (let i = 0; i < len; i += 4) {\n // red\n data[i] += brightness;\n // green\n data[i + 1] += brightness;\n // blue\n data[i + 2] += brightness;\n }\n};\nFactory.addGetterSetter(Node, 'brightness', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set filter brightness. With {@link Konva.Filters.Brighten} it is a number between -1 and 1\n * added to every channel: positive values brighten the pixels and negative values darken them.\n * With {@link Konva.Filters.Brightness} it is a CSS-like multiplier: 1 is no change, 1.5 is 50% brighter.\n * @name Konva.Node#brightness\n * @method\n * @param {Number} brightness\n * @returns {Number}\n */\n","/**\n * Brightness Filter.\n * CSS-compatible brightness filter that uses multiplicative approach.\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Brightness]);\n * node.brightness(1.5); // 50% brighter (CSS-compatible)\n */\nexport const Brightness = function (imageData) {\n const brightness = this.brightness(), data = imageData.data, len = data.length;\n for (let i = 0; i < len; i += 4) {\n // red\n data[i] = Math.min(255, data[i] * brightness);\n // green\n data[i + 1] = Math.min(255, data[i + 1] * brightness);\n // blue\n data[i + 2] = Math.min(255, data[i + 2] * brightness);\n }\n};\n// Note: brightness property is already defined in Brighten.ts\n// This filter reuses the existing brightness property but with CSS-compatible behavior\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Contrast Filter.\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Contrast]);\n * node.contrast(10);\n */\nexport const Contrast = function (imageData) {\n const adjust = Math.pow((this.contrast() + 100) / 100, 2);\n const data = imageData.data, nPixels = data.length;\n let red = 150, green = 150, blue = 150;\n for (let i = 0; i < nPixels; i += 4) {\n red = data[i];\n green = data[i + 1];\n blue = data[i + 2];\n //Red channel\n red /= 255;\n red -= 0.5;\n red *= adjust;\n red += 0.5;\n red *= 255;\n //Green channel\n green /= 255;\n green -= 0.5;\n green *= adjust;\n green += 0.5;\n green *= 255;\n //Blue channel\n blue /= 255;\n blue -= 0.5;\n blue *= adjust;\n blue += 0.5;\n blue *= 255;\n red = red < 0 ? 0 : red > 255 ? 255 : red;\n green = green < 0 ? 0 : green > 255 ? 255 : green;\n blue = blue < 0 ? 0 : blue > 255 ? 255 : blue;\n data[i] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n }\n};\n/**\n * get/set filter contrast. The contrast is a number between -100 and 100.\n * Use with {@link Konva.Filters.Contrast} filter.\n * @name Konva.Node#contrast\n * @method\n * @param {Number} contrast value between -100 and 100\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'contrast', 0, getNumberValidator(), Factory.afterSetFilter);\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Emboss Filter.\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Emboss]);\n * node.embossStrength(0.8);\n * node.embossWhiteLevel(0.3);\n * node.embossDirection('right');\n * node.embossBlend(true);\n */\nexport const Emboss = function (imageData) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n const data = imageData.data;\n const w = imageData.width;\n const h = imageData.height;\n // Inputs from Konva node\n const strength01 = Math.min(1, Math.max(0, (_b = (_a = this.embossStrength) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : 0.5)); // [0..1]\n const whiteLevel01 = Math.min(1, Math.max(0, (_d = (_c = this.embossWhiteLevel) === null || _c === void 0 ? void 0 : _c.call(this)) !== null && _d !== void 0 ? _d : 0.5)); // [0..1]\n // Convert string direction to degrees\n const directionMap = {\n 'top-left': 315,\n top: 270,\n 'top-right': 225,\n right: 180,\n 'bottom-right': 135,\n bottom: 90,\n 'bottom-left': 45,\n left: 0,\n };\n const directionDeg = (_g = directionMap[(_f = (_e = this.embossDirection) === null || _e === void 0 ? void 0 : _e.call(this)) !== null && _f !== void 0 ? _f : 'top-left']) !== null && _g !== void 0 ? _g : 315; // degrees\n const blend = !!((_j = (_h = this.embossBlend) === null || _h === void 0 ? void 0 : _h.call(this)) !== null && _j !== void 0 ? _j : false);\n // Internal mapping:\n // - \"strength\" was 0..10; we honor your 0..1 API and scale accordingly.\n // - Sobel directional response is roughly in [-1020..1020] for 8-bit luminance; scale to ~±128.\n const strength = strength01 * 10;\n const bias = whiteLevel01 * 255;\n const dirRad = (directionDeg * Math.PI) / 180;\n const cx = Math.cos(dirRad);\n const cy = Math.sin(dirRad);\n const SCALE = (128 / 1020) * strength; // ≈0.1255 * strength\n // Precompute luminance (Rec.709)\n const src = new Uint8ClampedArray(data); // snapshot\n const lum = new Float32Array(w * h);\n for (let p = 0, i = 0; i < data.length; i += 4, p++) {\n lum[p] = 0.2126 * src[i] + 0.7152 * src[i + 1] + 0.0722 * src[i + 2];\n }\n // Sobel kernels (flattened)\n const Gx = [-1, 0, 1, -2, 0, 2, -1, 0, 1];\n const Gy = [-1, -2, -1, 0, 0, 0, 1, 2, 1];\n // neighbor offsets around center pixel in lum space\n const OFF = [-w - 1, -w, -w + 1, -1, 0, 1, w - 1, w, w + 1];\n // Helpers\n const clamp8 = (v) => (v < 0 ? 0 : v > 255 ? 255 : v);\n // Process: leave a 1px border unchanged (faster/cleaner)\n for (let y = 1; y < h - 1; y++) {\n for (let x = 1; x < w - 1; x++) {\n const p = y * w + x;\n // Directional derivative = (cosθ * Gx + sinθ * Gy) • neighborhood(lum)\n let sx = 0, sy = 0;\n // unroll loop for speed\n sx += lum[p + OFF[0]] * Gx[0];\n sy += lum[p + OFF[0]] * Gy[0];\n sx += lum[p + OFF[1]] * Gx[1];\n sy += lum[p + OFF[1]] * Gy[1];\n sx += lum[p + OFF[2]] * Gx[2];\n sy += lum[p + OFF[2]] * Gy[2];\n sx += lum[p + OFF[3]] * Gx[3];\n sy += lum[p + OFF[3]] * Gy[3];\n // center has 0 weights in both Sobel masks; can skip if desired\n sx += lum[p + OFF[5]] * Gx[5];\n sy += lum[p + OFF[5]] * Gy[5];\n sx += lum[p + OFF[6]] * Gx[6];\n sy += lum[p + OFF[6]] * Gy[6];\n sx += lum[p + OFF[7]] * Gx[7];\n sy += lum[p + OFF[7]] * Gy[7];\n sx += lum[p + OFF[8]] * Gx[8];\n sy += lum[p + OFF[8]] * Gy[8];\n const r = cx * sx + cy * sy; // directional response\n const outGray = clamp8(bias + r * SCALE); // biased, scaled, clamped\n const o = p * 4;\n if (blend) {\n // Add the emboss \"relief\" around chosen bias to original RGB\n const delta = outGray - bias; // symmetric around whiteLevel\n data[o] = clamp8(src[o] + delta);\n data[o + 1] = clamp8(src[o + 1] + delta);\n data[o + 2] = clamp8(src[o + 2] + delta);\n data[o + 3] = src[o + 3];\n }\n else {\n // Grayscale embossed output\n data[o] = data[o + 1] = data[o + 2] = outGray;\n data[o + 3] = src[o + 3];\n }\n }\n }\n // Copy border (untouched) to keep edges clean\n // top & bottom rows\n for (let x = 0; x < w; x++) {\n let oTop = x * 4, oBot = ((h - 1) * w + x) * 4;\n data[oTop] = src[oTop];\n data[oTop + 1] = src[oTop + 1];\n data[oTop + 2] = src[oTop + 2];\n data[oTop + 3] = src[oTop + 3];\n data[oBot] = src[oBot];\n data[oBot + 1] = src[oBot + 1];\n data[oBot + 2] = src[oBot + 2];\n data[oBot + 3] = src[oBot + 3];\n }\n // left & right columns\n for (let y = 1; y < h - 1; y++) {\n let oL = y * w * 4, oR = (y * w + (w - 1)) * 4;\n data[oL] = src[oL];\n data[oL + 1] = src[oL + 1];\n data[oL + 2] = src[oL + 2];\n data[oL + 3] = src[oL + 3];\n data[oR] = src[oR];\n data[oR + 1] = src[oR + 1];\n data[oR + 2] = src[oR + 2];\n data[oR + 3] = src[oR + 3];\n }\n return imageData;\n};\nFactory.addGetterSetter(Node, 'embossStrength', 0.5, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set emboss strength. Use with {@link Konva.Filters.Emboss} filter.\n * @name Konva.Node#embossStrength\n * @method\n * @param {Number} level between 0 and 1. Default is 0.5\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'embossWhiteLevel', 0.5, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set emboss white level. Use with {@link Konva.Filters.Emboss} filter.\n * @name Konva.Node#embossWhiteLevel\n * @method\n * @param {Number} embossWhiteLevel between 0 and 1. Default is 0.5\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'embossDirection', 'top-left', undefined, Factory.afterSetFilter);\n/**\n * get/set emboss direction. Use with {@link Konva.Filters.Emboss} filter.\n * @name Konva.Node#embossDirection\n * @method\n * @param {String} embossDirection can be top-left, top, top-right, right, bottom-right, bottom, bottom-left or left\n * The default is top-left\n * @returns {String}\n */\nFactory.addGetterSetter(Node, 'embossBlend', false, undefined, Factory.afterSetFilter);\n/**\n * get/set emboss blend. Use with {@link Konva.Filters.Emboss} filter.\n * @name Konva.Node#embossBlend\n * @method\n * @param {Boolean} embossBlend\n * @returns {Boolean}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nfunction remap(fromValue, fromMin, fromMax, toMin, toMax) {\n // Compute the range of the data\n const fromRange = fromMax - fromMin, toRange = toMax - toMin;\n // If either range is 0, then the value can only be mapped to 1 value\n if (fromRange === 0) {\n return toMin + toRange / 2;\n }\n if (toRange === 0) {\n return toMin;\n }\n // (1) untranslate, (2) unscale, (3) rescale, (4) retranslate\n let toValue = (fromValue - fromMin) / fromRange;\n toValue = toRange * toValue + toMin;\n return toValue;\n}\n/**\n * Enhance Filter. Adjusts the colors so that they span the widest\n * possible range (ie 0-255). Performs w*h pixel reads and w*h pixel\n * writes.\n * @function\n * @name Enhance\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Enhance]);\n * node.enhance(0.4);\n */\nexport const Enhance = function (imageData) {\n const data = imageData.data, nSubPixels = data.length;\n let rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b;\n // If we are not enhancing anything - don't do any computation\n const enhanceAmount = this.enhance();\n if (enhanceAmount === 0) {\n return;\n }\n // 1st Pass - find the min and max for each channel:\n for (let i = 0; i < nSubPixels; i += 4) {\n r = data[i + 0];\n if (r < rMin) {\n rMin = r;\n }\n else if (r > rMax) {\n rMax = r;\n }\n g = data[i + 1];\n if (g < gMin) {\n gMin = g;\n }\n else if (g > gMax) {\n gMax = g;\n }\n b = data[i + 2];\n if (b < bMin) {\n bMin = b;\n }\n else if (b > bMax) {\n bMax = b;\n }\n //a = data[i + 3];\n //if (a < aMin) { aMin = a; } else\n //if (a > aMax) { aMax = a; }\n }\n // If there is only 1 level - don't remap\n if (rMax === rMin) {\n rMax = 255;\n rMin = 0;\n }\n if (gMax === gMin) {\n gMax = 255;\n gMin = 0;\n }\n if (bMax === bMin) {\n bMax = 255;\n bMin = 0;\n }\n let rGoalMax, rGoalMin, gGoalMax, gGoalMin, bGoalMax, bGoalMin;\n // If the enhancement is positive - stretch the histogram\n if (enhanceAmount > 0) {\n rGoalMax = rMax + enhanceAmount * (255 - rMax);\n rGoalMin = rMin - enhanceAmount * (rMin - 0);\n gGoalMax = gMax + enhanceAmount * (255 - gMax);\n gGoalMin = gMin - enhanceAmount * (gMin - 0);\n bGoalMax = bMax + enhanceAmount * (255 - bMax);\n bGoalMin = bMin - enhanceAmount * (bMin - 0);\n // If the enhancement is negative - compress the histogram\n }\n else {\n const rMid = (rMax + rMin) * 0.5;\n rGoalMax = rMax + enhanceAmount * (rMax - rMid);\n rGoalMin = rMin + enhanceAmount * (rMin - rMid);\n const gMid = (gMax + gMin) * 0.5;\n gGoalMax = gMax + enhanceAmount * (gMax - gMid);\n gGoalMin = gMin + enhanceAmount * (gMin - gMid);\n const bMid = (bMax + bMin) * 0.5;\n bGoalMax = bMax + enhanceAmount * (bMax - bMid);\n bGoalMin = bMin + enhanceAmount * (bMin - bMid);\n }\n // Pass 2 - remap everything, except the alpha\n for (let i = 0; i < nSubPixels; i += 4) {\n data[i + 0] = remap(data[i + 0], rMin, rMax, rGoalMin, rGoalMax);\n data[i + 1] = remap(data[i + 1], gMin, gMax, gGoalMin, gGoalMax);\n data[i + 2] = remap(data[i + 2], bMin, bMax, bGoalMin, bGoalMax);\n //data[i + 3] = remap(data[i + 3], aMin, aMax, aGoalMin, aGoalMax);\n }\n};\n/**\n * get/set enhance. Use with {@link Konva.Filters.Enhance} filter. -1 to 1 values\n * @name Konva.Node#enhance\n * @method\n * @param {Float} amount\n * @returns {Float}\n */\nFactory.addGetterSetter(Node, 'enhance', 0, getNumberValidator(), Factory.afterSetFilter);\n","/**\n * Grayscale Filter\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Grayscale]);\n */\nexport const Grayscale = function (imageData) {\n const data = imageData.data, len = data.length;\n for (let i = 0; i < len; i += 4) {\n const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];\n // red\n data[i] = brightness;\n // green\n data[i + 1] = brightness;\n // blue\n data[i + 2] = brightness;\n }\n};\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nFactory.addGetterSetter(Node, 'hue', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsv hue in degrees. Use with {@link Konva.Filters.HSV} or {@link Konva.Filters.HSL} filter.\n * @name Konva.Node#hue\n * @method\n * @param {Number} hue value between 0 and 359\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'saturation', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsv saturation. Use with {@link Konva.Filters.HSV} or {@link Konva.Filters.HSL} filter.\n * @name Konva.Node#saturation\n * @method\n * @param {Number} saturation 0 is no change, -1.0 halves the saturation, 1.0 doubles, etc..\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'luminance', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsl luminance. Use with {@link Konva.Filters.HSL} filter.\n * @name Konva.Node#luminance\n * @method\n * @param {Number} value from -1 to 1\n * @returns {Number}\n */\n/**\n * HSL Filter. Adjusts the hue, saturation and luminance (or lightness)\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * image.filters([Konva.Filters.HSL]);\n * image.luminance(0.2);\n */\nexport const HSL = function (imageData) {\n const data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = ((this.hue() % 360) + 360) % 360, l = this.luminance() * 127;\n // Basis for the technique used:\n // http://beesbuzz.biz/code/hsv_color_transforms.php\n // V is the value multiplier (1 for none, 2 for double, 0.5 for half)\n // S is the saturation multiplier (1 for none, 2 for double, 0.5 for half)\n // H is the hue shift in degrees (0 to 360)\n // vsu = V*S*cos(H*PI/180);\n // vsw = V*S*sin(H*PI/180);\n //[ .299V+.701vsu+.168vsw .587V-.587vsu+.330vsw .114V-.114vsu-.497vsw ] [R]\n //[ .299V-.299vsu-.328vsw .587V+.413vsu+.035vsw .114V-.114vsu+.292vsw ]*[G]\n //[ .299V-.300vsu+1.25vsw .587V-.588vsu-1.05vsw .114V+.886vsu-.203vsw ] [B]\n // Precompute the values in the matrix:\n const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n // (result spot)(source spot)\n const rr = 0.299 * v + 0.701 * vsu + 0.168 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.292 * vsw;\n const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.588 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.203 * vsw;\n let r, g, b, a;\n for (let i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b + l;\n data[i + 1] = gr * r + gg * g + gb * b + l;\n data[i + 2] = br * r + bg * g + bb * b + l;\n data[i + 3] = a; // alpha\n }\n};\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * HSV Filter. Adjusts the hue, saturation and value\n * @function\n * @name HSV\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * image.filters([Konva.Filters.HSV]);\n * image.value(1); // twice as bright\n */\nexport const HSV = function (imageData) {\n const data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = ((this.hue() % 360) + 360) % 360;\n // Basis for the technique used:\n // http://beesbuzz.biz/code/hsv_color_transforms.php\n // V is the value multiplier (1 for none, 2 for double, 0.5 for half)\n // S is the saturation multiplier (1 for none, 2 for double, 0.5 for half)\n // H is the hue shift in degrees (0 to 360)\n // vsu = V*S*cos(H*PI/180);\n // vsw = V*S*sin(H*PI/180);\n //[ .299V+.701vsu+.168vsw .587V-.587vsu+.330vsw .114V-.114vsu-.497vsw ] [R]\n //[ .299V-.299vsu-.328vsw .587V+.413vsu+.035vsw .114V-.114vsu+.292vsw ]*[G]\n //[ .299V-.300vsu+1.25vsw .587V-.588vsu-1.05vsw .114V+.886vsu-.203vsw ] [B]\n // Precompute the values in the matrix:\n const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n // (result spot)(source spot)\n const rr = 0.299 * v + 0.701 * vsu + 0.168 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.292 * vsw;\n const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.588 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.203 * vsw;\n for (let i = 0; i < nPixels; i += 4) {\n const r = data[i + 0];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b;\n data[i + 1] = gr * r + gg * g + gb * b;\n data[i + 2] = br * r + bg * g + bb * b;\n data[i + 3] = a; // alpha\n }\n};\nFactory.addGetterSetter(Node, 'hue', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsv hue in degrees. Use with {@link Konva.Filters.HSV} or {@link Konva.Filters.HSL} filter.\n * @name Konva.Node#hue\n * @method\n * @param {Number} hue value between 0 and 359\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'saturation', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsv saturation. Use with {@link Konva.Filters.HSV} or {@link Konva.Filters.HSL} filter.\n * @name Konva.Node#saturation\n * @method\n * @param {Number} saturation 0 is no change, -1.0 halves the saturation, 1.0 doubles, etc..\n * @returns {Number}\n */\nFactory.addGetterSetter(Node, 'value', 0, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set hsv value. Use with {@link Konva.Filters.HSV} filter.\n * @name Konva.Node#value\n * @method\n * @param {Number} value 0 is no change, -1.0 halves the value, 1.0 doubles, etc..\n * @returns {Number}\n */\n","/**\n * Invert Filter\n * @function\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Invert]);\n */\nexport const Invert = function (imageData) {\n const data = imageData.data, len = data.length;\n for (let i = 0; i < len; i += 4) {\n // red\n data[i] = 255 - data[i];\n // green\n data[i + 1] = 255 - data[i + 1];\n // blue\n data[i + 2] = 255 - data[i + 2];\n }\n};\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { Util } from \"../Util.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/*\n * ToPolar Filter. Converts image data to polar coordinates. Performs\n * w*h*4 pixel reads and w*h pixel writes. The r axis is placed along\n * what would be the y axis and the theta axis along the x axis.\n * @function\n * @author ippo615\n * @memberof Konva.Filters\n * @param {ImageData} src, the source image data (what will be transformed)\n * @param {ImageData} dst, the destination image data (where it will be saved)\n * @param {Object} opt\n * @param {Number} [opt.polarCenterX] horizontal location for the center of the circle,\n * default is in the middle\n * @param {Number} [opt.polarCenterY] vertical location for the center of the circle,\n * default is in the middle\n */\nconst ToPolar = function (src, dst, opt) {\n const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2;\n // Find the largest radius\n let rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n let x = xSize - xMid;\n let y = ySize - yMid;\n const rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n // We'll be uisng y as the radius, and x as the angle (theta=t)\n const rSize = ySize, tSize = xSize;\n // We want to cover all angles (0-360) and we need to convert to\n // radians (*PI/180)\n const conversion = ((360 / tSize) * Math.PI) / 180;\n // var x1, x2, x1i, x2i, y1, y2, y1i, y2i, scale;\n for (let theta = 0; theta < tSize; theta += 1) {\n const sin = Math.sin(theta * conversion);\n const cos = Math.cos(theta * conversion);\n for (let radius = 0; radius < rSize; radius += 1) {\n x = Math.floor(xMid + ((rMax * radius) / rSize) * cos);\n y = Math.floor(yMid + ((rMax * radius) / rSize) * sin);\n let i = (y * xSize + x) * 4;\n const r = srcPixels[i + 0];\n const g = srcPixels[i + 1];\n const b = srcPixels[i + 2];\n const a = srcPixels[i + 3];\n // Store it\n //i = (theta * xSize + radius) * 4;\n i = (theta + radius * xSize) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\n/*\n * FromPolar Filter. Converts image data from polar coordinates back to rectangular.\n * Performs w*h*4 pixel reads and w*h pixel writes.\n * @function\n * @author ippo615\n * @memberof Konva.Filters\n * @param {ImageData} src, the source image data (what will be transformed)\n * @param {ImageData} dst, the destination image data (where it will be saved)\n * @param {Object} opt\n * @param {Number} [opt.polarCenterX] horizontal location for the center of the circle,\n * default is in the middle\n * @param {Number} [opt.polarCenterY] vertical location for the center of the circle,\n * default is in the middle\n * @param {Number} [opt.polarRotation] amount to rotate the image counterclockwis,\n * 0 is no rotation, 360 degrees is a full rotation\n */\nconst FromPolar = function (src, dst, opt) {\n const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2;\n // Find the largest radius\n let rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n let x = xSize - xMid;\n let y = ySize - yMid;\n const rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n // We'll be uisng x as the radius, and y as the angle (theta=t)\n const rSize = ySize, tSize = xSize, phaseShift = opt.polarRotation || 0;\n // We need to convert to degrees and we need to make sure\n // it's between (0-360)\n // var conversion = tSize/360*180/Math.PI;\n //var conversion = tSize/360*180/Math.PI;\n let x1, y1;\n for (x = 0; x < xSize; x += 1) {\n for (y = 0; y < ySize; y += 1) {\n const dx = x - xMid;\n const dy = y - yMid;\n const radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax;\n let theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360;\n theta = (theta * tSize) / 360;\n x1 = Math.floor(theta);\n y1 = Math.floor(radius);\n let i = (y1 * xSize + x1) * 4;\n const r = srcPixels[i + 0];\n const g = srcPixels[i + 1];\n const b = srcPixels[i + 2];\n const a = srcPixels[i + 3];\n // Store it\n i = (y * xSize + x) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\n//Konva.Filters.ToPolar = Util._FilterWrapDoubleBuffer(ToPolar);\n//Konva.Filters.FromPolar = Util._FilterWrapDoubleBuffer(FromPolar);\n// create a temporary canvas for working - shared between multiple calls\n/**\n * Kaleidoscope Filter.\n * @function\n * @name Kaleidoscope\n * @author ippo615\n * @memberof Konva.Filters\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Kaleidoscope]);\n * node.kaleidoscopePower(3);\n * node.kaleidoscopeAngle(45);\n */\nexport const Kaleidoscope = function (imageData) {\n const xSize = imageData.width, ySize = imageData.height;\n let x, y, xoff, i, r, g, b, a, srcPos, dstPos;\n let power = Math.round(this.kaleidoscopePower());\n const angle = Math.round(this.kaleidoscopeAngle());\n const offset = Math.floor((xSize * (angle % 360)) / 360);\n if (power < 1) {\n return;\n }\n // Work with our shared buffer canvas\n const tempCanvas = Util.createCanvasElement();\n tempCanvas.width = xSize;\n tempCanvas.height = ySize;\n const scratchData = tempCanvas\n .getContext('2d')\n .getImageData(0, 0, xSize, ySize);\n Util.releaseCanvas(tempCanvas);\n // Convert thhe original to polar coordinates\n ToPolar(imageData, scratchData, {\n polarCenterX: xSize / 2,\n polarCenterY: ySize / 2,\n });\n // Determine how big each section will be, if it's too small\n // make it bigger\n let minSectionSize = xSize / Math.pow(2, power);\n while (minSectionSize <= 8) {\n minSectionSize = minSectionSize * 2;\n power -= 1;\n }\n minSectionSize = Math.ceil(minSectionSize);\n let sectionSize = minSectionSize;\n // Copy the offset region to 0\n // Depending on the size of filter and location of the offset we may need\n // to copy the section backwards to prevent it from rewriting itself\n let xStart = 0, xEnd = sectionSize, xDelta = 1;\n if (offset + minSectionSize > xSize) {\n xStart = sectionSize;\n xEnd = 0;\n xDelta = -1;\n }\n for (y = 0; y < ySize; y += 1) {\n for (x = xStart; x !== xEnd; x += xDelta) {\n xoff = Math.round(x + offset) % xSize;\n srcPos = (xSize * y + xoff) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + x) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n }\n // Perform the actual effect\n for (y = 0; y < ySize; y += 1) {\n sectionSize = Math.floor(minSectionSize);\n for (i = 0; i < power; i += 1) {\n for (x = 0; x < sectionSize + 1; x += 1) {\n srcPos = (xSize * y + x) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + sectionSize * 2 - x - 1) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n sectionSize *= 2;\n }\n }\n // Convert back from polar coordinates\n FromPolar(scratchData, imageData, { polarRotation: 0 });\n};\n/**\n * get/set kaleidoscope power. Use with {@link Konva.Filters.Kaleidoscope} filter.\n * @name Konva.Node#kaleidoscopePower\n * @method\n * @param {Integer} power of kaleidoscope\n * @returns {Integer}\n */\nFactory.addGetterSetter(Node, 'kaleidoscopePower', 2, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set kaleidoscope angle. Use with {@link Konva.Filters.Kaleidoscope} filter.\n * @name Konva.Node#kaleidoscopeAngle\n * @method\n * @param {Integer} degrees\n * @returns {Integer}\n */\nFactory.addGetterSetter(Node, 'kaleidoscopeAngle', 0, getNumberValidator(), Factory.afterSetFilter);\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\nfunction pixelAt(idata, x, y) {\n let idx = (y * idata.width + x) * 4;\n const d = [];\n d.push(idata.data[idx++], idata.data[idx++], idata.data[idx++], idata.data[idx++]);\n return d;\n}\nfunction rgbDistance(p1, p2) {\n return Math.sqrt(Math.pow(p1[0] - p2[0], 2) +\n Math.pow(p1[1] - p2[1], 2) +\n Math.pow(p1[2] - p2[2], 2));\n}\nfunction rgbMean(pTab) {\n const m = [0, 0, 0];\n for (let i = 0; i < pTab.length; i++) {\n m[0] += pTab[i][0];\n m[1] += pTab[i][1];\n m[2] += pTab[i][2];\n }\n m[0] /= pTab.length;\n m[1] /= pTab.length;\n m[2] /= pTab.length;\n return m;\n}\nfunction backgroundMask(idata, threshold) {\n const rgbv_no = pixelAt(idata, 0, 0);\n const rgbv_ne = pixelAt(idata, idata.width - 1, 0);\n const rgbv_so = pixelAt(idata, 0, idata.height - 1);\n const rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);\n const thres = threshold || 10;\n if (rgbDistance(rgbv_no, rgbv_ne) < thres &&\n rgbDistance(rgbv_ne, rgbv_se) < thres &&\n rgbDistance(rgbv_se, rgbv_so) < thres &&\n rgbDistance(rgbv_so, rgbv_no) < thres) {\n // Mean color\n const mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);\n // Mask based on color distance\n const mask = [];\n for (let i = 0; i < idata.width * idata.height; i++) {\n const d = rgbDistance(mean, [\n idata.data[i * 4],\n idata.data[i * 4 + 1],\n idata.data[i * 4 + 2],\n ]);\n mask[i] = d < thres ? 0 : 255;\n }\n return mask;\n }\n}\nfunction applyMask(idata, mask) {\n for (let i = 0; i < idata.width * idata.height; i++) {\n idata.data[4 * i + 3] = mask[i];\n }\n}\nfunction erodeMask(mask, sw, sh) {\n const weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];\n const side = Math.round(Math.sqrt(weights.length));\n const halfSide = Math.floor(side / 2);\n const maskResult = [];\n for (let y = 0; y < sh; y++) {\n for (let x = 0; x < sw; x++) {\n const so = y * sw + x;\n let a = 0;\n for (let cy = 0; cy < side; cy++) {\n for (let cx = 0; cx < side; cx++) {\n const scy = y + cy - halfSide;\n const scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n const srcOff = scy * sw + scx;\n const wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a === 255 * 8 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction dilateMask(mask, sw, sh) {\n const weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];\n const side = Math.round(Math.sqrt(weights.length));\n const halfSide = Math.floor(side / 2);\n const maskResult = [];\n for (let y = 0; y < sh; y++) {\n for (let x = 0; x < sw; x++) {\n const so = y * sw + x;\n let a = 0;\n for (let cy = 0; cy < side; cy++) {\n for (let cx = 0; cx < side; cx++) {\n const scy = y + cy - halfSide;\n const scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n const srcOff = scy * sw + scx;\n const wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a >= 255 * 4 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction smoothEdgeMask(mask, sw, sh) {\n const weights = [\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n 1 / 9,\n ];\n const side = Math.round(Math.sqrt(weights.length));\n const halfSide = Math.floor(side / 2);\n const maskResult = [];\n for (let y = 0; y < sh; y++) {\n for (let x = 0; x < sw; x++) {\n const so = y * sw + x;\n let a = 0;\n for (let cy = 0; cy < side; cy++) {\n for (let cx = 0; cx < side; cx++) {\n const scy = y + cy - halfSide;\n const scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n const srcOff = scy * sw + scx;\n const wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a;\n }\n }\n return maskResult;\n}\n/**\n * Mask Filter\n * @function\n * @name Mask\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Mask]);\n * node.threshold(200);\n */\nexport const Mask = function (imageData) {\n // Detect pixels close to the background color\n const threshold = this.threshold();\n let mask = backgroundMask(imageData, threshold);\n if (mask) {\n // Erode\n mask = erodeMask(mask, imageData.width, imageData.height);\n // Dilate\n mask = dilateMask(mask, imageData.width, imageData.height);\n // Gradient\n mask = smoothEdgeMask(mask, imageData.width, imageData.height);\n // Apply mask\n applyMask(imageData, mask);\n }\n return imageData;\n};\nFactory.addGetterSetter(Node, 'threshold', 0, getNumberValidator(), Factory.afterSetFilter);\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Noise Filter. Randomly adds or substracts to the color channels\n * @function\n * @name Noise\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Noise]);\n * node.noise(0.8);\n */\nexport const Noise = function (imageData) {\n const amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2;\n for (let i = 0; i < nPixels; i += 4) {\n data[i + 0] += half - 2 * half * Math.random();\n data[i + 1] += half - 2 * half * Math.random();\n data[i + 2] += half - 2 * half * Math.random();\n }\n};\nFactory.addGetterSetter(Node, 'noise', 0.2, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set noise amount. Must be a value between 0 and 1. Use with {@link Konva.Filters.Noise} filter.\n * @name Konva.Node#noise\n * @method\n * @param {Number} noise\n * @returns {Number}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Util } from \"../Util.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Pixelate Filter. Averages groups of pixels and redraws\n * them as larger pixels\n * @function\n * @name Pixelate\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Pixelate]);\n * node.pixelSize(10);\n */\nexport const Pixelate = function (imageData) {\n let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, \n //pixelsPerBin = pixelSize * pixelSize,\n nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;\n if (pixelSize <= 0) {\n Util.error('pixelSize value can not be <= 0');\n return;\n }\n for (let xBin = 0; xBin < nBinsX; xBin += 1) {\n for (let yBin = 0; yBin < nBinsY; yBin += 1) {\n // Initialize the color accumlators to 0\n let red = 0;\n let green = 0;\n let blue = 0;\n let alpha = 0;\n // Determine which pixels are included in this bin\n const xBinStart = xBin * pixelSize;\n const xBinEnd = xBinStart + pixelSize;\n const yBinStart = yBin * pixelSize;\n const yBinEnd = yBinStart + pixelSize;\n // Add all of the pixels to this bin!\n let pixelsInBin = 0;\n for (let x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (let y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n const i = (width * y + x) * 4;\n red += data[i + 0];\n green += data[i + 1];\n blue += data[i + 2];\n alpha += data[i + 3];\n pixelsInBin += 1;\n }\n }\n // Make sure the channels are between 0-255\n red = red / pixelsInBin;\n green = green / pixelsInBin;\n blue = blue / pixelsInBin;\n alpha = alpha / pixelsInBin;\n // Draw this bin\n for (let x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (let y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n const i = (width * y + x) * 4;\n data[i + 0] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n data[i + 3] = alpha;\n }\n }\n }\n }\n};\nFactory.addGetterSetter(Node, 'pixelSize', 8, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set pixel size. Use with {@link Konva.Filters.Pixelate} filter.\n * @name Konva.Node#pixelSize\n * @method\n * @param {Integer} pixelSize\n * @returns {Integer}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Posterize Filter. Adjusts the channels so that there are no more\n * than n different values for that channel. This is also applied\n * to the alpha channel.\n * @function\n * @name Posterize\n * @author ippo615\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Posterize]);\n * node.levels(0.8); // between 0 and 1\n */\nexport const Posterize = function (imageData) {\n // level must be between 1 and 255\n const levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels;\n for (let i = 0; i < len; i += 1) {\n data[i] = Math.floor(data[i] / scale) * scale;\n }\n};\nFactory.addGetterSetter(Node, 'levels', 0.5, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set levels. Must be a number between 0 and 1. Use with {@link Konva.Filters.Posterize} filter.\n * @name Konva.Node#levels\n * @method\n * @param {Number} level between 0 and 1\n * @returns {Number}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { RGBComponent } from \"../Validators.js\";\n/**\n * RGB Filter\n * @function\n * @name RGB\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * node.cache();\n * node.filters([Konva.Filters.RGB]);\n * node.blue(120);\n * node.green(200);\n */\nexport const RGB = function (imageData) {\n const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue();\n for (let i = 0; i < nPixels; i += 4) {\n const brightness = (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;\n data[i] = brightness * red; // r\n data[i + 1] = brightness * green; // g\n data[i + 2] = brightness * blue; // b\n data[i + 3] = data[i + 3]; // alpha\n }\n};\nFactory.addGetterSetter(Node, 'red', 0, RGBComponent, Factory.afterSetFilter);\n/**\n * get/set filter red value. Use with {@link Konva.Filters.RGB} or {@link Konva.Filters.RGBA} filter.\n * @name red\n * @method\n * @memberof Konva.Node.prototype\n * @param {Integer} red value between 0 and 255\n * @returns {Integer}\n */\nFactory.addGetterSetter(Node, 'green', 0, RGBComponent, Factory.afterSetFilter);\n/**\n * get/set filter green value. Use with {@link Konva.Filters.RGB} or {@link Konva.Filters.RGBA} filter.\n * @name green\n * @method\n * @memberof Konva.Node.prototype\n * @param {Integer} green value between 0 and 255\n * @returns {Integer}\n */\nFactory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);\n/**\n * get/set filter blue value. Use with {@link Konva.Filters.RGB} or {@link Konva.Filters.RGBA} filter.\n * @name blue\n * @method\n * @memberof Konva.Node.prototype\n * @param {Integer} blue value between 0 and 255\n * @returns {Integer}\n */\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\n// red, green and blue are registered there\nimport \"./RGB.js\";\n/**\n * RGBA Filter\n * @function\n * @name RGBA\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author codefo\n * @example\n * node.cache();\n * node.filters([Konva.Filters.RGBA]);\n * node.blue(120);\n * node.green(200);\n * node.alpha(0.3);\n */\nexport const RGBA = function (imageData) {\n const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha();\n for (let i = 0; i < nPixels; i += 4) {\n const ia = 1 - alpha;\n data[i] = red * alpha + data[i] * ia; // r\n data[i + 1] = green * alpha + data[i + 1] * ia; // g\n data[i + 2] = blue * alpha + data[i + 2] * ia; // b\n }\n};\nFactory.addGetterSetter(Node, 'alpha', 1, (val) => Math.min(1, Math.max(0, val)), Factory.afterSetFilter);\n/**\n * get/set filter alpha value. Use with {@link Konva.Filters.RGBA} filter.\n * @name alpha\n * @method\n * @memberof Konva.Node.prototype\n * @param {Float} alpha value between 0 and 1\n * @returns {Float}\n */\n","// based on https://stackoverflow.com/questions/1061093/how-is-a-sepia-tone-created\n/**\n * @function\n * @name Sepia\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Sepia]);\n */\nexport const Sepia = function (imageData) {\n const data = imageData.data, nPixels = data.length;\n for (let i = 0; i < nPixels; i += 4) {\n const r = data[i + 0];\n const g = data[i + 1];\n const b = data[i + 2];\n data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189);\n data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168);\n data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);\n }\n};\n","/**\n * Solarize Filter\n * @function\n * @name Solarize\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Solarize]);\n */\nexport const Solarize = function (imageData) {\n const threshold = 128;\n const d = imageData.data;\n for (let i = 0; i < d.length; i += 4) {\n const r = d[i], g = d[i + 1], b = d[i + 2];\n // sRGB luma\n const L = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n if (L >= threshold) {\n d[i] = 255 - r;\n d[i + 1] = 255 - g;\n d[i + 2] = 255 - b;\n }\n }\n return imageData;\n};\n","import { Factory } from \"../Factory.js\";\nimport { Node } from \"../Node.js\";\nimport { getNumberValidator } from \"../Validators.js\";\n/**\n * Threshold Filter. Pushes any value above the mid point to\n * the max and any value below the mid point to the min.\n * This affects the alpha channel.\n * @function\n * @name Threshold\n * @memberof Konva.Filters\n * @param {Object} imageData\n * @author ippo615\n * @example\n * node.cache();\n * node.filters([Konva.Filters.Threshold]);\n * node.threshold(0.1);\n */\nexport const Threshold = function (imageData) {\n const level = this.threshold() * 255, data = imageData.data, len = data.length;\n for (let i = 0; i < len; i += 1) {\n data[i] = data[i] < level ? 0 : 255;\n }\n};\nFactory.addGetterSetter(Node, 'threshold', 0.5, getNumberValidator(), Factory.afterSetFilter);\n/**\n * get/set threshold. With {@link Konva.Filters.Threshold} it is a value between 0 and 1. With {@link Konva.Filters.Mask} it is the colour distance to the background, 0 to 255, default 10.\n * @name threshold\n * @method\n * @memberof Konva.Node.prototype\n * @param {Number} threshold\n * @returns {Number}\n */\n","// we need to import core of the Konva and then extend it with all additional objects\nimport { Konva as Core } from \"./_CoreInternals.js\";\n// shapes\nimport { Arc } from \"./shapes/Arc.js\";\nimport { Arrow } from \"./shapes/Arrow.js\";\nimport { Circle } from \"./shapes/Circle.js\";\nimport { Ellipse } from \"./shapes/Ellipse.js\";\nimport { Image } from \"./shapes/Image.js\";\nimport { Label, Tag } from \"./shapes/Label.js\";\nimport { Line } from \"./shapes/Line.js\";\nimport { Path } from \"./shapes/Path.js\";\nimport { Rect } from \"./shapes/Rect.js\";\nimport { RegularPolygon } from \"./shapes/RegularPolygon.js\";\nimport { Ring } from \"./shapes/Ring.js\";\nimport { Sprite } from \"./shapes/Sprite.js\";\nimport { Star } from \"./shapes/Star.js\";\nimport { Text } from \"./shapes/Text.js\";\nimport { TextPath } from \"./shapes/TextPath.js\";\nimport { Transformer } from \"./shapes/Transformer.js\";\nimport { Wedge } from \"./shapes/Wedge.js\";\n// filters\nimport { Blur } from \"./filters/Blur.js\";\nimport { Brighten } from \"./filters/Brighten.js\";\nimport { Brightness } from \"./filters/Brightness.js\";\nimport { Contrast } from \"./filters/Contrast.js\";\nimport { Emboss } from \"./filters/Emboss.js\";\nimport { Enhance } from \"./filters/Enhance.js\";\nimport { Grayscale } from \"./filters/Grayscale.js\";\nimport { HSL } from \"./filters/HSL.js\";\nimport { HSV } from \"./filters/HSV.js\";\nimport { Invert } from \"./filters/Invert.js\";\nimport { Kaleidoscope } from \"./filters/Kaleidoscope.js\";\nimport { Mask } from \"./filters/Mask.js\";\nimport { Noise } from \"./filters/Noise.js\";\nimport { Pixelate } from \"./filters/Pixelate.js\";\nimport { Posterize } from \"./filters/Posterize.js\";\nimport { RGB } from \"./filters/RGB.js\";\nimport { RGBA } from \"./filters/RGBA.js\";\nimport { Sepia } from \"./filters/Sepia.js\";\nimport { Solarize } from \"./filters/Solarize.js\";\nimport { Threshold } from \"./filters/Threshold.js\";\nexport const Konva = Core.Util._assign(Core, {\n Arc,\n Arrow,\n Circle,\n Ellipse,\n Image,\n Label,\n Tag,\n Line,\n Path,\n Rect,\n RegularPolygon,\n Ring,\n Sprite,\n Star,\n Text,\n TextPath,\n Transformer,\n Wedge,\n /**\n * @namespace Filters\n * @memberof Konva\n */\n Filters: {\n Blur,\n Brightness,\n Brighten,\n Contrast,\n Emboss,\n Enhance,\n Grayscale,\n HSL,\n HSV,\n Invert,\n Kaleidoscope,\n Mask,\n Noise,\n Pixelate,\n Posterize,\n RGB,\n RGBA,\n Sepia,\n Solarize,\n Threshold,\n },\n});\n","/**\n * @license React\n * react-reconciler.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nmodule.exports = function $$$reconciler($$$hostConfig) {\n var exports = {};\n'use strict';var aa=require(\"react\"),ba=require(\"scheduler\"),ca=Object.assign;function n(a){for(var b=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+a,c=1;ch||e[g]!==f[h]){var k=\"\\n\"+e[g].replace(\" at new \",\" at \");a.displayName&&k.includes(\"\")&&(k=k.replace(\"\",a.displayName));return k}while(1<=g&&0<=h)}break}}}finally{dc=!1,Error.prepareStackTrace=c}return(a=a?a.displayName||a.name:\"\")?cc(a):\"\"}var fc=Object.prototype.hasOwnProperty,gc=[],hc=-1;function ic(a){return{current:a}}\nfunction q(a){0>hc||(a.current=gc[hc],gc[hc]=null,hc--)}function v(a,b){hc++;gc[hc]=a.current;a.current=b}var jc={},x=ic(jc),z=ic(!1),kc=jc;function mc(a,b){var c=a.type.contextTypes;if(!c)return jc;var d=a.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===b)return d.__reactInternalMemoizedMaskedChildContext;var e={},f;for(f in c)e[f]=b[f];d&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=b,a.__reactInternalMemoizedMaskedChildContext=e);return e}\nfunction A(a){a=a.childContextTypes;return null!==a&&void 0!==a}function nc(){q(z);q(x)}function oc(a,b,c){if(x.current!==jc)throw Error(n(168));v(x,b);v(z,c)}function pc(a,b,c){var d=a.stateNode;b=b.childContextTypes;if(\"function\"!==typeof d.getChildContext)return c;d=d.getChildContext();for(var e in d)if(!(e in b))throw Error(n(108,va(a)||\"Unknown\",e));return ca({},c,d)}\nfunction qc(a){a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||jc;kc=x.current;v(x,a);v(z,z.current);return!0}function rc(a,b,c){var d=a.stateNode;if(!d)throw Error(n(169));c?(a=pc(a,b,kc),d.__reactInternalMemoizedMergedChildContext=a,q(z),q(x),v(x,a)):q(z);v(z,c)}var tc=Math.clz32?Math.clz32:sc,uc=Math.log,vc=Math.LN2;function sc(a){a>>>=0;return 0===a?32:31-(uc(a)/vc|0)|0}var wc=64,xc=4194304;\nfunction yc(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;\ndefault:return a}}function zc(a,b){var c=a.pendingLanes;if(0===c)return 0;var d=0,e=a.suspendedLanes,f=a.pingedLanes,g=c&268435455;if(0!==g){var h=g&~e;0!==h?d=yc(h):(f&=g,0!==f&&(d=yc(f)))}else g=c&~e,0!==g?d=yc(g):0!==f&&(d=yc(f));if(0===d)return 0;if(0!==b&&b!==d&&0===(b&e)&&(e=d&-d,f=b&-b,e>=f||16===e&&0!==(f&4194240)))return b;0!==(d&4)&&(d|=c&16);b=a.entangledLanes;if(0!==b)for(a=a.entanglements,b&=d;0c;c++)b.push(a);return b}\nfunction Fc(a,b,c){a.pendingLanes|=b;536870912!==b&&(a.suspendedLanes=0,a.pingedLanes=0);a=a.eventTimes;b=31-tc(b);a[b]=c}function Gc(a,b){var c=a.pendingLanes&~b;a.pendingLanes=b;a.suspendedLanes=0;a.pingedLanes=0;a.expiredLanes&=b;a.mutableReadLanes&=b;a.entangledLanes&=b;b=a.entanglements;var d=a.eventTimes;for(a=a.expirationTimes;0>=g;e-=g;id=1<<32-tc(b)+e|c<t?(E=u,u=null):E=u.sibling;var y=p(e,u,h[t],k);if(null===y){null===u&&(u=E);break}a&&u&&null===y.alternate&&b(e,u);g=f(y,g,t);null===m?l=y:m.sibling=y;m=y;u=E}if(t===h.length)return c(e,u),F&&kd(e,t),l;if(null===u){for(;tt?(E=m,m=null):E=m.sibling;var w=p(e,m,y.value,k);if(null===w){null===m&&(m=E);break}a&&m&&null===w.alternate&&b(e,m);g=f(w,g,t);null===u?l=w:u.sibling=w;u=w;m=E}if(y.done)return c(e,\nm),F&&kd(e,t),l;if(null===m){for(;!y.done;t++,y=h.next())y=r(e,y.value,k),null!==y&&(g=f(y,g,t),null===u?l=y:u.sibling=y,u=y);F&&kd(e,t);return l}for(m=d(e,m);!y.done;t++,y=h.next())y=B(m,e,t,y.value,k),null!==y&&(a&&null!==y.alternate&&m.delete(null===y.key?t:y.key),g=f(y,g,t),null===u?l=y:u.sibling=y,u=y);a&&m.forEach(function(a){return b(e,a)});F&&kd(e,t);return l}function ya(a,d,f,h){\"object\"===typeof f&&null!==f&&f.type===ha&&null===f.key&&(f=f.props.children);if(\"object\"===typeof f&&null!==\nf){switch(f.$$typeof){case ea:a:{for(var k=f.key,l=d;null!==l;){if(l.key===k){k=f.type;if(k===ha){if(7===l.tag){c(a,l.sibling);d=e(l,f.props.children);d.return=a;a=d;break a}}else if(l.elementType===k||\"object\"===typeof k&&null!==k&&k.$$typeof===qa&&Hd(k)===l.type){c(a,l.sibling);d=e(l,f.props);d.ref=Fd(a,l,f);d.return=a;a=d;break a}c(a,l);break}else b(a,l);l=l.sibling}f.type===ha?(d=Nd(f.props.children,a.mode,h,f.key),d.return=a,a=d):(h=Ld(f.type,f.key,f.props,null,a.mode,h),h.ref=Fd(a,d,f),h.return=\na,a=h)}return g(a);case fa:a:{for(l=f.key;null!==d;){if(d.key===l)if(4===d.tag&&d.stateNode.containerInfo===f.containerInfo&&d.stateNode.implementation===f.implementation){c(a,d.sibling);d=e(d,f.children||[]);d.return=a;a=d;break a}else{c(a,d);break}else b(a,d);d=d.sibling}d=Md(f,a.mode,h);d.return=a;a=d}return g(a);case qa:return l=f._init,ya(a,d,l(f._payload),h)}if(Da(f))return w(a,d,f,h);if(ta(f))return Y(a,d,f,h);Gd(a,f)}return\"string\"===typeof f&&\"\"!==f||\"number\"===typeof f?(f=\"\"+f,null!==d&&\n6===d.tag?(c(a,d.sibling),d=e(d,f),d.return=a,a=d):(c(a,d),d=Kd(f,a.mode,h),d.return=a,a=d),g(a)):c(a,d)}return ya}var Od=Id(!0),Pd=Id(!1),Qd=ic(null),Rd=null,Sd=null,Td=null;function Ud(){Td=Sd=Rd=null}function Vd(a,b,c){Sa?(v(Qd,b._currentValue),b._currentValue=c):(v(Qd,b._currentValue2),b._currentValue2=c)}function Wd(a){var b=Qd.current;q(Qd);Sa?a._currentValue=b:a._currentValue2=b}\nfunction Xd(a,b,c){for(;null!==a;){var d=a.alternate;(a.childLanes&b)!==b?(a.childLanes|=b,null!==d&&(d.childLanes|=b)):null!==d&&(d.childLanes&b)!==b&&(d.childLanes|=b);if(a===c)break;a=a.return}}function Yd(a,b){Rd=a;Td=Sd=null;a=a.dependencies;null!==a&&null!==a.firstContext&&(0!==(a.lanes&b)&&(G=!0),a.firstContext=null)}\nfunction Zd(a){var b=Sa?a._currentValue:a._currentValue2;if(Td!==a)if(a={context:a,memoizedValue:b,next:null},null===Sd){if(null===Rd)throw Error(n(308));Sd=a;Rd.dependencies={lanes:0,firstContext:a}}else Sd=Sd.next=a;return b}var $d=null;function ae(a){null===$d?$d=[a]:$d.push(a)}function be(a,b,c,d){var e=b.interleaved;null===e?(c.next=c,ae(b)):(c.next=e.next,e.next=c);b.interleaved=c;return ce(a,d)}\nfunction ce(a,b){a.lanes|=b;var c=a.alternate;null!==c&&(c.lanes|=b);c=a;for(a=a.return;null!==a;)a.childLanes|=b,c=a.alternate,null!==c&&(c.childLanes|=b),c=a,a=a.return;return 3===c.tag?c.stateNode:null}var de=!1;function ee(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}\nfunction fe(a,b){a=a.updateQueue;b.updateQueue===a&&(b.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function ge(a,b){return{eventTime:a,lane:b,tag:0,payload:null,callback:null,next:null}}\nfunction he(a,b,c){var d=a.updateQueue;if(null===d)return null;d=d.shared;if(0!==(H&2)){var e=d.pending;null===e?b.next=b:(b.next=e.next,e.next=b);d.pending=b;return ce(a,c)}e=d.interleaved;null===e?(b.next=b,ae(d)):(b.next=e.next,e.next=b);d.interleaved=b;return ce(a,c)}function ie(a,b,c){b=b.updateQueue;if(null!==b&&(b=b.shared,0!==(c&4194240))){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Hc(a,c)}}\nfunction je(a,b){var c=a.updateQueue,d=a.alternate;if(null!==d&&(d=d.updateQueue,c===d)){var e=null,f=null;c=c.firstBaseUpdate;if(null!==c){do{var g={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};null===f?e=f=g:f=f.next=g;c=c.next}while(null!==c);null===f?e=f=b:f=f.next=b}else e=f=b;c={baseState:d.baseState,firstBaseUpdate:e,lastBaseUpdate:f,shared:d.shared,effects:d.effects};a.updateQueue=c;return}a=c.lastBaseUpdate;null===a?c.firstBaseUpdate=b:a.next=\nb;c.lastBaseUpdate=b}\nfunction ke(a,b,c,d){var e=a.updateQueue;de=!1;var f=e.firstBaseUpdate,g=e.lastBaseUpdate,h=e.shared.pending;if(null!==h){e.shared.pending=null;var k=h,l=k.next;k.next=null;null===g?f=l:g.next=l;g=k;var m=a.alternate;null!==m&&(m=m.updateQueue,h=m.lastBaseUpdate,h!==g&&(null===h?m.firstBaseUpdate=l:h.next=l,m.lastBaseUpdate=k))}if(null!==f){var r=e.baseState;g=0;m=l=k=null;h=f;do{var p=h.lane,B=h.eventTime;if((d&p)===p){null!==m&&(m=m.next={eventTime:B,lane:0,tag:h.tag,payload:h.payload,callback:h.callback,\nnext:null});a:{var w=a,Y=h;p=b;B=c;switch(Y.tag){case 1:w=Y.payload;if(\"function\"===typeof w){r=w.call(B,r,p);break a}r=w;break a;case 3:w.flags=w.flags&-65537|128;case 0:w=Y.payload;p=\"function\"===typeof w?w.call(B,r,p):w;if(null===p||void 0===p)break a;r=ca({},r,p);break a;case 2:de=!0}}null!==h.callback&&0!==h.lane&&(a.flags|=64,p=e.effects,null===p?e.effects=[h]:p.push(h))}else B={eventTime:B,lane:p,tag:h.tag,payload:h.payload,callback:h.callback,next:null},null===m?(l=m=B,k=r):m=m.next=B,g|=\np;h=h.next;if(null===h)if(h=e.shared.pending,null===h)break;else p=h,h=p.next,p.next=null,e.lastBaseUpdate=p,e.shared.pending=null}while(1);null===m&&(k=r);e.baseState=k;e.firstBaseUpdate=l;e.lastBaseUpdate=m;b=e.shared.interleaved;if(null!==b){e=b;do g|=e.lane,e=e.next;while(e!==b)}else null===f&&(e.shared.lanes=0);le|=g;a.lanes=g;a.memoizedState=r}}\nfunction me(a,b,c){a=b.effects;b.effects=null;if(null!==a)for(b=0;bc?c:4;a(!0);var d=Ae.transition;Ae.transition={};try{a(!1),b()}finally{C=c,Ae.transition=d}}function rf(){return Oe().memoizedState}\nfunction sf(a,b,c){var d=tf(a);c={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(uf(a))vf(b,c);else if(c=be(a,b,c,d),null!==c){var e=O();af(c,a,d,e);wf(c,b,d)}}\nfunction cf(a,b,c){var d=tf(a),e={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(uf(a))vf(b,e);else{var f=a.alternate;if(0===a.lanes&&(null===f||0===f.lanes)&&(f=b.lastRenderedReducer,null!==f))try{var g=b.lastRenderedState,h=f(g,c);e.hasEagerState=!0;e.eagerState=h;if(Vc(h,g)){var k=b.interleaved;null===k?(e.next=e,ae(b)):(e.next=k.next,k.next=e);b.interleaved=e;return}}catch(l){}finally{}c=be(a,b,e,d);null!==c&&(e=O(),af(c,a,d,e),wf(c,b,d))}}\nfunction uf(a){var b=a.alternate;return a===J||null!==b&&b===J}function vf(a,b){De=Ce=!0;var c=a.pending;null===c?b.next=b:(b.next=c.next,c.next=b);a.pending=b}function wf(a,b,c){if(0!==(c&4194240)){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Hc(a,c)}}\nvar Le={readContext:Zd,useCallback:M,useContext:M,useEffect:M,useImperativeHandle:M,useInsertionEffect:M,useLayoutEffect:M,useMemo:M,useReducer:M,useRef:M,useState:M,useDebugValue:M,useDeferredValue:M,useTransition:M,useMutableSource:M,useSyncExternalStore:M,useId:M,unstable_isNewReconciler:!1},Ie={readContext:Zd,useCallback:function(a,b){Ne().memoizedState=[a,void 0===b?null:b];return a},useContext:Zd,useEffect:gf,useImperativeHandle:function(a,b,c){c=null!==c&&void 0!==c?c.concat([a]):null;return ef(4194308,\n4,kf.bind(null,b,a),c)},useLayoutEffect:function(a,b){return ef(4194308,4,a,b)},useInsertionEffect:function(a,b){return ef(4,2,a,b)},useMemo:function(a,b){var c=Ne();b=void 0===b?null:b;a=a();c.memoizedState=[a,b];return a},useReducer:function(a,b,c){var d=Ne();b=void 0!==c?c(b):b;d.memoizedState=d.baseState=b;a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b};d.queue=a;a=a.dispatch=sf.bind(null,J,a);return[d.memoizedState,a]},useRef:function(a){var b=\nNe();a={current:a};return b.memoizedState=a},useState:bf,useDebugValue:mf,useDeferredValue:function(a){return Ne().memoizedState=a},useTransition:function(){var a=bf(!1),b=a[0];a=qf.bind(null,a[1]);Ne().memoizedState=a;return[b,a]},useMutableSource:function(){},useSyncExternalStore:function(a,b,c){var d=J,e=Ne();if(F){if(void 0===c)throw Error(n(407));c=c()}else{c=b();if(null===N)throw Error(n(349));0!==(Be&30)||Ye(d,b,c)}e.memoizedState=c;var f={value:c,getSnapshot:b};e.queue=f;gf(Ve.bind(null,d,\nf,a),[a]);d.flags|=2048;We(9,Xe.bind(null,d,f,c,b),void 0,null);return c},useId:function(){var a=Ne(),b=N.identifierPrefix;if(F){var c=jd;var d=id;c=(d&~(1<<32-tc(d)-1)).toString(32)+c;b=\":\"+b+\"R\"+c;c=Ee++;0Dg&&(b.flags|=128,d=!0,Ag(e,!1),b.lanes=4194304)}else{if(!d)if(a=we(f),null!==a){if(b.flags|=128,d=!0,a=a.updateQueue,null!==a&&(b.updateQueue=a,b.flags|=4),Ag(e,!0),null===e.tail&&\"hidden\"===e.tailMode&&!f.alternate&&!F)return Q(b),null}else 2*D()-e.renderingStartTime>Dg&&1073741824!==c&&(b.flags|=128,d=!0,Ag(e,!1),b.lanes=\n4194304);e.isBackwards?(f.sibling=b.child,b.child=f):(a=e.last,null!==a?a.sibling=f:b.child=f,e.last=f)}if(null!==e.tail)return b=e.tail,e.rendering=b,e.tail=b.sibling,e.renderingStartTime=D(),b.sibling=null,a=I.current,v(I,d?a&1|2:a&1),b;Q(b);return null;case 22:case 23:return Eg(),c=null!==b.memoizedState,null!==a&&null!==a.memoizedState!==c&&(b.flags|=8192),c&&0!==(b.mode&1)?0!==($f&1073741824)&&(Q(b),Ta&&b.subtreeFlags&6&&(b.flags|=8192)):Q(b),null;case 24:return null;case 25:return null}throw Error(n(156,\nb.tag));}\nfunction Fg(a,b){nd(b);switch(b.tag){case 1:return A(b.type)&&nc(),a=b.flags,a&65536?(b.flags=a&-65537|128,b):null;case 3:return te(),q(z),q(x),ye(),a=b.flags,0!==(a&65536)&&0===(a&128)?(b.flags=a&-65537|128,b):null;case 5:return ve(b),null;case 13:q(I);a=b.memoizedState;if(null!==a&&null!==a.dehydrated){if(null===b.alternate)throw Error(n(340));Ad()}a=b.flags;return a&65536?(b.flags=a&-65537|128,b):null;case 19:return q(I),null;case 4:return te(),null;case 10:return Wd(b.type._context),null;case 22:case 23:return Eg(),\nnull;case 24:return null;default:return null}}var Gg=!1,S=!1,Hg=\"function\"===typeof WeakSet?WeakSet:Set,T=null;function Ig(a,b){var c=a.ref;if(null!==c)if(\"function\"===typeof c)try{c(null)}catch(d){U(a,b,d)}else c.current=null}function Jg(a,b,c){try{c()}catch(d){U(a,b,d)}}var Kg=!1;\nfunction Lg(a,b){Ha(a.containerInfo);for(T=b;null!==T;)if(a=T,b=a.child,0!==(a.subtreeFlags&1028)&&null!==b)b.return=a,T=b;else for(;null!==T;){a=T;try{var c=a.alternate;if(0!==(a.flags&1024))switch(a.tag){case 0:case 11:case 15:break;case 1:if(null!==c){var d=c.memoizedProps,e=c.memoizedState,f=a.stateNode,g=f.getSnapshotBeforeUpdate(a.elementType===a.type?d:xf(a.type,d),e);f.__reactInternalSnapshotBeforeUpdate=g}break;case 3:Ta&&xb(a.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;\ndefault:throw Error(n(163));}}catch(h){U(a,a.return,h)}b=a.sibling;if(null!==b){b.return=a.return;T=b;break}T=a.return}c=Kg;Kg=!1;return c}function Mg(a,b,c){var d=b.updateQueue;d=null!==d?d.lastEffect:null;if(null!==d){var e=d=d.next;do{if((e.tag&a)===a){var f=e.destroy;e.destroy=void 0;void 0!==f&&Jg(b,c,f)}e=e.next}while(e!==d)}}function Ng(a,b){b=b.updateQueue;b=null!==b?b.lastEffect:null;if(null!==b){var c=b=b.next;do{if((c.tag&a)===a){var d=c.create;c.destroy=d()}c=c.next}while(c!==b)}}\nfunction Og(a){var b=a.ref;if(null!==b){var c=a.stateNode;switch(a.tag){case 5:a=Ea(c);break;default:a=c}\"function\"===typeof b?b(a):b.current=a}}function Pg(a){var b=a.alternate;null!==b&&(a.alternate=null,Pg(b));a.child=null;a.deletions=null;a.sibling=null;5===a.tag&&(b=a.stateNode,null!==b&&Za(b));a.stateNode=null;a.return=null;a.dependencies=null;a.memoizedProps=null;a.memoizedState=null;a.pendingProps=null;a.stateNode=null;a.updateQueue=null}\nfunction Qg(a){return 5===a.tag||3===a.tag||4===a.tag}function Rg(a){a:for(;;){for(;null===a.sibling;){if(null===a.return||Qg(a.return))return null;a=a.return}a.sibling.return=a.return;for(a=a.sibling;5!==a.tag&&6!==a.tag&&18!==a.tag;){if(a.flags&2)continue a;if(null===a.child||4===a.tag)continue a;else a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}\nfunction Sg(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?pb(c,a,b):kb(c,a);else if(4!==d&&(a=a.child,null!==a))for(Sg(a,b,c),a=a.sibling;null!==a;)Sg(a,b,c),a=a.sibling}function Tg(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?ob(c,a,b):jb(c,a);else if(4!==d&&(a=a.child,null!==a))for(Tg(a,b,c),a=a.sibling;null!==a;)Tg(a,b,c),a=a.sibling}var V=null,Ug=!1;function Vg(a,b,c){for(c=c.child;null!==c;)Wg(a,b,c),c=c.sibling}\nfunction Wg(a,b,c){if(Sc&&\"function\"===typeof Sc.onCommitFiberUnmount)try{Sc.onCommitFiberUnmount(Rc,c)}catch(h){}switch(c.tag){case 5:S||Ig(c,b);case 6:if(Ta){var d=V,e=Ug;V=null;Vg(a,b,c);V=d;Ug=e;null!==V&&(Ug?rb(V,c.stateNode):qb(V,c.stateNode))}else Vg(a,b,c);break;case 18:Ta&&null!==V&&(Ug?Yb(V,c.stateNode):Xb(V,c.stateNode));break;case 4:Ta?(d=V,e=Ug,V=c.stateNode.containerInfo,Ug=!0,Vg(a,b,c),V=d,Ug=e):(Ua&&(d=c.stateNode.containerInfo,e=zb(d),Cb(d,e)),Vg(a,b,c));break;case 0:case 11:case 14:case 15:if(!S&&\n(d=c.updateQueue,null!==d&&(d=d.lastEffect,null!==d))){e=d=d.next;do{var f=e,g=f.destroy;f=f.tag;void 0!==g&&(0!==(f&2)?Jg(c,b,g):0!==(f&4)&&Jg(c,b,g));e=e.next}while(e!==d)}Vg(a,b,c);break;case 1:if(!S&&(Ig(c,b),d=c.stateNode,\"function\"===typeof d.componentWillUnmount))try{d.props=c.memoizedProps,d.state=c.memoizedState,d.componentWillUnmount()}catch(h){U(c,b,h)}Vg(a,b,c);break;case 21:Vg(a,b,c);break;case 22:c.mode&1?(S=(d=S)||null!==c.memoizedState,Vg(a,b,c),S=d):Vg(a,b,c);break;default:Vg(a,b,\nc)}}function Xg(a){var b=a.updateQueue;if(null!==b){a.updateQueue=null;var c=a.stateNode;null===c&&(c=a.stateNode=new Hg);b.forEach(function(b){var d=Yg.bind(null,a,b);c.has(b)||(c.add(b),b.then(d,d))})}}\nfunction Zg(a,b){var c=b.deletions;if(null!==c)for(var d=0;d\";case ih:return\":has(\"+(ph(a)||\"\")+\")\";case jh:return'[role=\"'+a.value+'\"]';case lh:return'\"'+a.value+'\"';case kh:return'[data-testname=\"'+a.value+'\"]';default:throw Error(n(365));}}\nfunction qh(a,b){var c=[];a=[a,0];for(var d=0;de&&(e=g);d&=~f}d=e;d=D()-d;d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3E3>d?3E3:4320>d?4320:1960*sh(d/1960))-d;if(10a?16:a;if(null===Dh)var d=!1;else{a=Dh;Dh=null;Eh=0;if(0!==(H&6))throw Error(n(331));var e=H;H|=4;for(T=a.current;null!==T;){var f=T,g=f.child;if(0!==(T.flags&16)){var h=f.deletions;if(null!==h){for(var k=0;kD()-bh?Rh(a,0):xh|=c);Kh(a,b)}function di(a,b){0===b&&(0===(a.mode&1)?b=1:(b=xc,xc<<=1,0===(xc&130023424)&&(xc=4194304)));var c=O();a=ce(a,b);null!==a&&(Fc(a,b,c),Kh(a,c))}function og(a){var b=a.memoizedState,c=0;null!==b&&(c=b.retryLane);di(a,c)}\nfunction Yg(a,b){var c=0;switch(a.tag){case 13:var d=a.stateNode;var e=a.memoizedState;null!==e&&(c=e.retryLane);break;case 19:d=a.stateNode;break;default:throw Error(n(314));}null!==d&&d.delete(b);di(a,c)}var ai;\nai=function(a,b,c){if(null!==a)if(a.memoizedProps!==b.pendingProps||z.current)G=!0;else{if(0===(a.lanes&c)&&0===(b.flags&128))return G=!1,sg(a,b,c);G=0!==(a.flags&131072)?!0:!1}else G=!1,F&&0!==(b.flags&1048576)&&ld(b,ed,b.index);b.lanes=0;switch(b.tag){case 2:var d=b.type;cg(a,b);a=b.pendingProps;var e=mc(b,x.current);Yd(b,c);e=He(null,b,d,a,e,c);var f=Me();b.flags|=1;\"object\"===typeof e&&null!==e&&\"function\"===typeof e.render&&void 0===e.$$typeof?(b.tag=1,b.memoizedState=null,b.updateQueue=null,\nA(d)?(f=!0,qc(b)):f=!1,b.memoizedState=null!==e.state&&void 0!==e.state?e.state:null,ee(b),e.updater=zf,b.stateNode=e,e._reactInternals=b,Df(b,d,a,c),b=dg(null,b,d,!0,f,c)):(b.tag=0,F&&f&&md(b),P(null,b,e,c),b=b.child);return b;case 16:d=b.elementType;a:{cg(a,b);a=b.pendingProps;e=d._init;d=e(d._payload);b.type=d;e=b.tag=ei(d);a=xf(d,a);switch(e){case 0:b=Xf(null,b,d,a,c);break a;case 1:b=bg(null,b,d,a,c);break a;case 11:b=Sf(null,b,d,a,c);break a;case 14:b=Uf(null,b,d,xf(d.type,a),c);break a}throw Error(n(306,\nd,\"\"));}return b;case 0:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:xf(d,e),Xf(a,b,d,e,c);case 1:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:xf(d,e),bg(a,b,d,e,c);case 3:a:{eg(b);if(null===a)throw Error(n(387));d=b.pendingProps;f=b.memoizedState;e=f.element;fe(a,b);ke(b,d,null,c);var g=b.memoizedState;d=g.element;if(Va&&f.isDehydrated)if(f={element:d,isDehydrated:!1,cache:g.cache,pendingSuspenseBoundaries:g.pendingSuspenseBoundaries,transitions:g.transitions},b.updateQueue.baseState=\nf,b.memoizedState=f,b.flags&256){e=Ef(Error(n(423)),b);b=fg(a,b,d,c,e);break a}else if(d!==e){e=Ef(Error(n(424)),b);b=fg(a,b,d,c,e);break a}else for(Va&&(pd=Pb(b.stateNode.containerInfo),od=b,F=!0,rd=null,qd=!1),c=Pd(b,null,d,c),b.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{Ad();if(d===e){b=Tf(a,b,c);break a}P(a,b,d,c)}b=b.child}return b;case 5:return ue(b),null===a&&wd(b),d=b.type,e=b.pendingProps,f=null!==a?a.memoizedProps:null,g=e.children,Na(d,e)?g=null:null!==f&&Na(d,f)&&(b.flags|=32),\nag(a,b),P(a,b,g,c),b.child;case 6:return null===a&&wd(b),null;case 13:return ig(a,b,c);case 4:return se(b,b.stateNode.containerInfo),d=b.pendingProps,null===a?b.child=Od(b,null,d,c):P(a,b,d,c),b.child;case 11:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:xf(d,e),Sf(a,b,d,e,c);case 7:return P(a,b,b.pendingProps,c),b.child;case 8:return P(a,b,b.pendingProps.children,c),b.child;case 12:return P(a,b,b.pendingProps.children,c),b.child;case 10:a:{d=b.type._context;e=b.pendingProps;f=b.memoizedProps;\ng=e.value;Vd(b,d,g);if(null!==f)if(Vc(f.value,g)){if(f.children===e.children&&!z.current){b=Tf(a,b,c);break a}}else for(f=b.child,null!==f&&(f.return=b);null!==f;){var h=f.dependencies;if(null!==h){g=f.child;for(var k=h.firstContext;null!==k;){if(k.context===d){if(1===f.tag){k=ge(-1,c&-c);k.tag=2;var l=f.updateQueue;if(null!==l){l=l.shared;var m=l.pending;null===m?k.next=k:(k.next=m.next,m.next=k);l.pending=k}}f.lanes|=c;k=f.alternate;null!==k&&(k.lanes|=c);Xd(f.return,c,b);h.lanes|=c;break}k=k.next}}else if(10===\nf.tag)g=f.type===b.type?null:f.child;else if(18===f.tag){g=f.return;if(null===g)throw Error(n(341));g.lanes|=c;h=g.alternate;null!==h&&(h.lanes|=c);Xd(g,c,b);g=f.sibling}else g=f.child;if(null!==g)g.return=f;else for(g=f;null!==g;){if(g===b){g=null;break}f=g.sibling;if(null!==f){f.return=g.return;g=f;break}g=g.return}f=g}P(a,b,e.children,c);b=b.child}return b;case 9:return e=b.type,d=b.pendingProps.children,Yd(b,c),e=Zd(e),d=d(e),b.flags|=1,P(a,b,d,c),b.child;case 14:return d=b.type,e=xf(d,b.pendingProps),\ne=xf(d.type,e),Uf(a,b,d,e,c);case 15:return Wf(a,b,b.type,b.pendingProps,c);case 17:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:xf(d,e),cg(a,b),b.tag=1,A(d)?(a=!0,qc(b)):a=!1,Yd(b,c),Bf(b,d,e),Df(b,d,e,c),dg(null,b,d,!0,a,c);case 19:return rg(a,b,c);case 22:return Yf(a,b,c)}throw Error(n(156,b.tag));};function Mh(a,b){return Jc(a,b)}\nfunction fi(a,b,c,d){this.tag=a;this.key=c;this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null;this.index=0;this.ref=null;this.pendingProps=b;this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null;this.mode=d;this.subtreeFlags=this.flags=0;this.deletions=null;this.childLanes=this.lanes=0;this.alternate=null}function td(a,b,c,d){return new fi(a,b,c,d)}function Vf(a){a=a.prototype;return!(!a||!a.isReactComponent)}\nfunction ei(a){if(\"function\"===typeof a)return Vf(a)?1:0;if(void 0!==a&&null!==a){a=a.$$typeof;if(a===ma)return 11;if(a===pa)return 14}return 2}\nfunction Jd(a,b){var c=a.alternate;null===c?(c=td(a.tag,b,a.key,a.mode),c.elementType=a.elementType,c.type=a.type,c.stateNode=a.stateNode,c.alternate=a,a.alternate=c):(c.pendingProps=b,c.type=a.type,c.flags=0,c.subtreeFlags=0,c.deletions=null);c.flags=a.flags&14680064;c.childLanes=a.childLanes;c.lanes=a.lanes;c.child=a.child;c.memoizedProps=a.memoizedProps;c.memoizedState=a.memoizedState;c.updateQueue=a.updateQueue;b=a.dependencies;c.dependencies=null===b?null:{lanes:b.lanes,firstContext:b.firstContext};\nc.sibling=a.sibling;c.index=a.index;c.ref=a.ref;return c}\nfunction Ld(a,b,c,d,e,f){var g=2;d=a;if(\"function\"===typeof a)Vf(a)&&(g=1);else if(\"string\"===typeof a)g=5;else a:switch(a){case ha:return Nd(c.children,e,f,b);case ia:g=8;e|=8;break;case ja:return a=td(12,c,b,e|2),a.elementType=ja,a.lanes=f,a;case na:return a=td(13,c,b,e),a.elementType=na,a.lanes=f,a;case oa:return a=td(19,c,b,e),a.elementType=oa,a.lanes=f,a;case ra:return jg(c,e,f,b);default:if(\"object\"===typeof a&&null!==a)switch(a.$$typeof){case ka:g=10;break a;case la:g=9;break a;case ma:g=11;\nbreak a;case pa:g=14;break a;case qa:g=16;d=null;break a}throw Error(n(130,null==a?a:typeof a,\"\"));}b=td(g,c,b,e);b.elementType=a;b.type=d;b.lanes=f;return b}function Nd(a,b,c,d){a=td(7,a,d,b);a.lanes=c;return a}function jg(a,b,c,d){a=td(22,a,d,b);a.elementType=ra;a.lanes=c;a.stateNode={isHidden:!1};return a}function Kd(a,b,c){a=td(6,a,null,b);a.lanes=c;return a}\nfunction Md(a,b,c){b=td(4,null!==a.children?a.children:[],a.key,b);b.lanes=c;b.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation};return b}\nfunction gi(a,b,c,d,e){this.tag=b;this.containerInfo=a;this.finishedWork=this.pingCache=this.current=this.pendingChildren=null;this.timeoutHandle=Ra;this.callbackNode=this.pendingContext=this.context=null;this.callbackPriority=0;this.eventTimes=Ec(0);this.expirationTimes=Ec(-1);this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0;this.entanglements=Ec(0);this.identifierPrefix=d;this.onRecoverableError=e;Va&&(this.mutableSourceEagerHydrationData=\nnull)}function hi(a,b,c,d,e,f,g,h,k){a=new gi(a,b,c,h,k);1===b?(b=1,!0===f&&(b|=8)):b=0;f=td(3,null,null,b);a.current=f;f.stateNode=a;f.memoizedState={element:d,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null};ee(f);return a}\nfunction ii(a){if(!a)return jc;a=a._reactInternals;a:{if(wa(a)!==a||1!==a.tag)throw Error(n(170));var b=a;do{switch(b.tag){case 3:b=b.stateNode.context;break a;case 1:if(A(b.type)){b=b.stateNode.__reactInternalMemoizedMergedChildContext;break a}}b=b.return}while(null!==b);throw Error(n(171));}if(1===a.tag){var c=a.type;if(A(c))return pc(a,c,b)}return b}\nfunction ji(a){var b=a._reactInternals;if(void 0===b){if(\"function\"===typeof a.render)throw Error(n(188));a=Object.keys(a).join(\",\");throw Error(n(268,a));}a=Aa(b);return null===a?null:a.stateNode}function ki(a,b){a=a.memoizedState;if(null!==a&&null!==a.dehydrated){var c=a.retryLane;a.retryLane=0!==c&&c=l&&f>=r&&e<=m&&g<=p){a.splice(b,1);break}else if(!(d!==l||c.width!==k.width||pg)){r>f&&(k.height+=r-f,k.y=f);pe)){l>d&&(k.width+=\nl-d,k.x=d);mc&&(c=g)),g \")+\"\\n\\nNo matching component was found for:\\n \")+a.join(\" > \")}return null};\nexports.getPublicRootInstance=function(a){a=a.current;if(!a.child)return null;switch(a.child.tag){case 5:return Ea(a.child.stateNode);default:return a.child.stateNode}};\nexports.injectIntoDevTools=function(a){a={bundleType:a.bundleType,version:a.version,rendererPackageName:a.rendererPackageName,rendererConfig:a.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:da.ReactCurrentDispatcher,findHostInstanceByFiber:mi,findFiberByHostInstance:a.findFiberByHostInstance||\nni,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:\"18.3.1\"};if(\"undefined\"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)a=!1;else{var b=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(b.isDisabled||!b.supportsFiber)a=!0;else{try{Rc=b.inject(a),Sc=b}catch(c){}a=b.checkDCE?!0:!1}}return a};exports.isAlreadyRendering=function(){return!1};\nexports.observeVisibleRects=function(a,b,c,d){if(!bb)throw Error(n(363));a=rh(a,b);var e=ib(a,c,d).disconnect;return{disconnect:function(){e()}}};exports.registerMutableSourceForHydration=function(a,b){var c=b._getVersion;c=c(b._source);null==a.mutableSourceEagerHydrationData?a.mutableSourceEagerHydrationData=[b,c]:a.mutableSourceEagerHydrationData.push(b,c)};exports.runWithPriority=function(a,b){var c=C;try{return C=a,b()}finally{C=c}};exports.shouldError=function(){return null};\nexports.shouldSuspend=function(){return!1};exports.updateContainer=function(a,b,c,d){var e=b.current,f=O(),g=tf(e);c=ii(c);null===b.context?b.context=c:b.pendingContext=c;b=ge(f,g);b.payload={element:a};d=void 0===d?null:d;null!==d&&(b.callback=d);a=he(e,b,g);null!==a&&(af(a,e,g,f),ie(a,e,g));return g};\n\n return exports;\n};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-reconciler.production.min.js');\n} else {\n module.exports = require('./cjs/react-reconciler.development.js');\n}\n","/**\n * @license React\n * react-reconciler-constants.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';exports.ConcurrentRoot=1;exports.ContinuousEventPriority=4;exports.DefaultEventPriority=16;exports.DiscreteEventPriority=1;exports.IdleEventPriority=536870912;exports.LegacyRoot=0;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-reconciler-constants.production.min.js');\n} else {\n module.exports = require('./cjs/react-reconciler-constants.development.js');\n}\n","import { Konva } from 'konva/lib/Global.js';\nconst propsToSkip = {\n children: true,\n ref: true,\n key: true,\n style: true,\n forwardedRef: true,\n unstable_applyCache: true,\n unstable_applyDrawHitFromCache: true,\n};\nlet zIndexWarningShowed = false;\nlet dragWarningShowed = false;\nexport const EVENTS_NAMESPACE = '.react-konva-event';\nlet useStrictMode = false;\nexport function toggleStrictMode(value) {\n useStrictMode = value;\n}\nconst DRAGGABLE_WARNING = `ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled.\nPosition of a node will be changed during drag&drop, so you should update state of the react app as well.\nConsider to add onDragMove or onDragEnd events.\nFor more info see: https://github.com/konvajs/react-konva/issues/256\n`;\nconst Z_INDEX_WARNING = `ReactKonva: You are using \"zIndex\" attribute for a Konva node.\nreact-konva may get confused with ordering. Just define correct order of elements in your render function of a component.\nFor more info see: https://github.com/konvajs/react-konva/issues/194\n`;\nconst EMPTY_PROPS = {};\nexport function applyNodeProps(instance, props, oldProps = EMPTY_PROPS) {\n // don't use zIndex in react-konva\n if (!zIndexWarningShowed && 'zIndex' in props) {\n console.warn(Z_INDEX_WARNING);\n zIndexWarningShowed = true;\n }\n // check correct draggable usage\n if (!dragWarningShowed && props.draggable) {\n var hasPosition = props.x !== undefined || props.y !== undefined;\n var hasEvents = props.onDragEnd || props.onDragMove;\n if (hasPosition && !hasEvents) {\n console.warn(DRAGGABLE_WARNING);\n dragWarningShowed = true;\n }\n }\n // check old props\n // we need to unset properties that are not in new props\n // and remove all events\n for (var key in oldProps) {\n if (propsToSkip[key]) {\n continue;\n }\n var isEvent = key.slice(0, 2) === 'on';\n var propChanged = oldProps[key] !== props[key];\n // if that is a changed event, we need to remove it\n if (isEvent && propChanged) {\n var eventName = key.substr(2).toLowerCase();\n if (eventName.substr(0, 7) === 'content') {\n eventName =\n 'content' +\n eventName.substr(7, 1).toUpperCase() +\n eventName.substr(8);\n }\n instance.off(eventName, oldProps[key]);\n }\n var toRemove = !props.hasOwnProperty(key);\n if (toRemove) {\n instance.setAttr(key, undefined);\n }\n }\n var strictUpdate = useStrictMode || props._useStrictMode;\n var updatedProps = {};\n var hasUpdates = false;\n const newEvents = {};\n for (var key in props) {\n if (propsToSkip[key]) {\n continue;\n }\n var isEvent = key.slice(0, 2) === 'on';\n var toAdd = oldProps[key] !== props[key];\n if (isEvent && toAdd) {\n var eventName = key.substr(2).toLowerCase();\n if (eventName.substr(0, 7) === 'content') {\n eventName =\n 'content' +\n eventName.substr(7, 1).toUpperCase() +\n eventName.substr(8);\n }\n // check that event is not undefined\n if (props[key]) {\n newEvents[eventName] = props[key];\n }\n }\n if (!isEvent &&\n (props[key] !== oldProps[key] ||\n (strictUpdate && props[key] !== instance.getAttr(key)))) {\n hasUpdates = true;\n updatedProps[key] = props[key];\n }\n }\n if (hasUpdates) {\n instance.setAttrs(updatedProps);\n updatePicture(instance);\n }\n // subscribe to events AFTER we set attrs\n // we need it to fix https://github.com/konvajs/react-konva/issues/471\n // settings attrs may add events. Like \"draggable: true\" will add \"mousedown\" listener\n for (var eventName in newEvents) {\n instance.on(eventName + EVENTS_NAMESPACE, newEvents[eventName]);\n }\n}\nexport function updatePicture(node) {\n if (!Konva.autoDrawEnabled) {\n var drawingNode = node.getLayer() || node.getStage();\n drawingNode && drawingNode.batchDraw();\n }\n}\n","import Konva from 'konva/lib/Core.js';\nimport { applyNodeProps, updatePicture, EVENTS_NAMESPACE } from './makeUpdates.js';\nexport { unstable_now as now, unstable_IdlePriority as idlePriority, unstable_runWithPriority as run, } from 'scheduler';\nimport { DefaultEventPriority } from 'react-reconciler/constants.js';\nconst NO_CONTEXT = {};\nconst UPDATE_SIGNAL = {};\n// for react-spring capability\nKonva.Node.prototype._applyProps = applyNodeProps;\nexport function appendInitialChild(parentInstance, child) {\n if (typeof child === 'string') {\n // Noop for string children of Text (eg foo )\n console.error(`Do not use plain text as child of Konva.Node. You are using text: ${child}`);\n return;\n }\n parentInstance.add(child);\n updatePicture(parentInstance);\n}\nexport function createInstance(type, props, internalInstanceHandle) {\n let NodeClass = Konva[type];\n if (!NodeClass) {\n console.error(`Konva has no node with the type ${type}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: \"import \"konva/lib/shapes/${type}\" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`);\n NodeClass = Konva.Group;\n }\n // we need to split props into events and non events\n // we we can pass non events into constructor directly\n // that way the performance should be better\n // we we apply change \"applyNodeProps\"\n // then it will trigger change events on first run\n // but we don't need them!\n const propsWithoutEvents = {};\n const propsWithOnlyEvents = {};\n for (var key in props) {\n var isEvent = key.slice(0, 2) === 'on';\n if (isEvent) {\n propsWithOnlyEvents[key] = props[key];\n }\n else {\n propsWithoutEvents[key] = props[key];\n }\n }\n const instance = new NodeClass(propsWithoutEvents);\n applyNodeProps(instance, propsWithOnlyEvents);\n return instance;\n}\nexport function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {\n console.error(`Text components are not supported for now in ReactKonva. Your text is: \"${text}\"`);\n}\nexport function finalizeInitialChildren(domElement, type, props) {\n return false;\n}\nexport function getPublicInstance(instance) {\n return instance;\n}\nexport function prepareForCommit() {\n return null;\n}\nexport function preparePortalMount() {\n return null;\n}\nexport function prepareUpdate(domElement, type, oldProps, newProps) {\n return UPDATE_SIGNAL;\n}\nexport function resetAfterCommit() {\n // Noop\n}\nexport function resetTextContent(domElement) {\n // Noop\n}\nexport function shouldDeprioritizeSubtree(type, props) {\n return false;\n}\nexport function getRootHostContext() {\n return NO_CONTEXT;\n}\nexport function getChildHostContext() {\n return NO_CONTEXT;\n}\nexport const scheduleTimeout = setTimeout;\nexport const cancelTimeout = clearTimeout;\nexport const noTimeout = -1;\n// export const schedulePassiveEffects = scheduleDeferredCallback;\n// export const cancelPassiveEffects = cancelDeferredCallback;\nexport function shouldSetTextContent(type, props) {\n return false;\n}\n// The Konva renderer is secondary to the React DOM renderer.\nexport const isPrimaryRenderer = false;\nexport const warnsIfNotActing = true;\nexport const supportsMutation = true;\nexport function appendChild(parentInstance, child) {\n if (child.parent === parentInstance) {\n child.moveToTop();\n }\n else {\n parentInstance.add(child);\n }\n updatePicture(parentInstance);\n}\nexport function appendChildToContainer(parentInstance, child) {\n if (child.parent === parentInstance) {\n child.moveToTop();\n }\n else {\n parentInstance.add(child);\n }\n updatePicture(parentInstance);\n}\nexport function insertBefore(parentInstance, child, beforeChild) {\n // child._remove() will not stop dragging\n // but child.remove() will stop it, but we don't need it\n // removing will reset zIndexes\n child._remove();\n parentInstance.add(child);\n child.setZIndex(beforeChild.getZIndex());\n updatePicture(parentInstance);\n}\nexport function insertInContainerBefore(parentInstance, child, beforeChild) {\n insertBefore(parentInstance, child, beforeChild);\n}\nexport function removeChild(parentInstance, child) {\n child.destroy();\n child.off(EVENTS_NAMESPACE);\n updatePicture(parentInstance);\n}\nexport function removeChildFromContainer(parentInstance, child) {\n child.destroy();\n child.off(EVENTS_NAMESPACE);\n updatePicture(parentInstance);\n}\nexport function commitTextUpdate(textInstance, oldText, newText) {\n console.error(`Text components are not yet supported in ReactKonva. You text is: \"${newText}\"`);\n}\nexport function commitMount(instance, type, newProps) {\n // Noop\n}\nexport function commitUpdate(instance, updatePayload, type, oldProps, newProps) {\n applyNodeProps(instance, newProps, oldProps);\n}\nexport function hideInstance(instance) {\n instance.hide();\n updatePicture(instance);\n}\nexport function hideTextInstance(textInstance) {\n // Noop\n}\nexport function unhideInstance(instance, props) {\n if (props.visible == null || props.visible) {\n instance.show();\n }\n}\nexport function unhideTextInstance(textInstance, text) {\n // Noop\n}\nexport function clearContainer(container) {\n // Noop\n}\nexport function detachDeletedInstance() { }\nexport const getCurrentEventPriority = () => DefaultEventPriority;\n","import * as React from \"react\";\nvar __defProp = Object.defineProperty;\nvar __defProps = Object.defineProperties;\nvar __getOwnPropDescs = Object.getOwnPropertyDescriptors;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b)) {\n if (__propIsEnum.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n }\n return a;\n};\nvar __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));\nvar _a, _b;\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" && (((_a = window.document) == null ? void 0 : _a.createElement) || ((_b = window.navigator) == null ? void 0 : _b.product) === \"ReactNative\") ? React.useLayoutEffect : React.useEffect;\nfunction traverseFiber(fiber, ascending, selector) {\n if (!fiber)\n return;\n if (selector(fiber) === true)\n return fiber;\n let child = ascending ? fiber.return : fiber.child;\n while (child) {\n const match = traverseFiber(child, ascending, selector);\n if (match)\n return match;\n child = ascending ? null : child.sibling;\n }\n}\nfunction wrapContext(context) {\n try {\n return Object.defineProperties(context, {\n _currentRenderer: {\n get() {\n return null;\n },\n set() {\n }\n },\n _currentRenderer2: {\n get() {\n return null;\n },\n set() {\n }\n }\n });\n } catch (_) {\n return context;\n }\n}\nconst error = console.error;\nconsole.error = function() {\n const message = [...arguments].join(\"\");\n if ((message == null ? void 0 : message.startsWith(\"Warning:\")) && message.includes(\"useContext\")) {\n console.error = error;\n return;\n }\n return error.apply(this, arguments);\n};\nconst FiberContext = wrapContext(React.createContext(null));\nclass FiberProvider extends React.Component {\n render() {\n return /* @__PURE__ */ React.createElement(FiberContext.Provider, {\n value: this._reactInternals\n }, this.props.children);\n }\n}\nfunction useFiber() {\n const root = React.useContext(FiberContext);\n if (root === null)\n throw new Error(\"its-fine: useFiber must be called within a !\");\n const id = React.useId();\n const fiber = React.useMemo(() => {\n for (const maybeFiber of [root, root == null ? void 0 : root.alternate]) {\n if (!maybeFiber)\n continue;\n const fiber2 = traverseFiber(maybeFiber, false, (node) => {\n let state = node.memoizedState;\n while (state) {\n if (state.memoizedState === id)\n return true;\n state = state.next;\n }\n });\n if (fiber2)\n return fiber2;\n }\n }, [root, id]);\n return fiber;\n}\nfunction useContainer() {\n const fiber = useFiber();\n const root = React.useMemo(\n () => traverseFiber(fiber, true, (node) => {\n var _a2;\n return ((_a2 = node.stateNode) == null ? void 0 : _a2.containerInfo) != null;\n }),\n [fiber]\n );\n return root == null ? void 0 : root.stateNode.containerInfo;\n}\nfunction useNearestChild(type) {\n const fiber = useFiber();\n const childRef = React.useRef();\n useIsomorphicLayoutEffect(() => {\n var _a2;\n childRef.current = (_a2 = traverseFiber(\n fiber,\n false,\n (node) => typeof node.type === \"string\" && (type === void 0 || node.type === type)\n )) == null ? void 0 : _a2.stateNode;\n }, [fiber]);\n return childRef;\n}\nfunction useNearestParent(type) {\n const fiber = useFiber();\n const parentRef = React.useRef();\n useIsomorphicLayoutEffect(() => {\n var _a2;\n parentRef.current = (_a2 = traverseFiber(\n fiber,\n true,\n (node) => typeof node.type === \"string\" && (type === void 0 || node.type === type)\n )) == null ? void 0 : _a2.stateNode;\n }, [fiber]);\n return parentRef;\n}\nfunction useContextMap() {\n const fiber = useFiber();\n const [contextMap] = React.useState(() => /* @__PURE__ */ new Map());\n contextMap.clear();\n let node = fiber;\n while (node) {\n if (node.type && typeof node.type === \"object\") {\n const enableRenderableContext = node.type._context === void 0 && node.type.Provider === node.type;\n const context = enableRenderableContext ? node.type : node.type._context;\n if (context && context !== FiberContext && !contextMap.has(context)) {\n contextMap.set(context, React.useContext(wrapContext(context)));\n }\n }\n node = node.return;\n }\n return contextMap;\n}\nfunction useContextBridge() {\n const contextMap = useContextMap();\n return React.useMemo(\n () => Array.from(contextMap.keys()).reduce(\n (Prev, context) => (props) => /* @__PURE__ */ React.createElement(Prev, null, /* @__PURE__ */ React.createElement(context.Provider, __spreadProps(__spreadValues({}, props), {\n value: contextMap.get(context)\n }))),\n (props) => /* @__PURE__ */ React.createElement(FiberProvider, __spreadValues({}, props))\n ),\n [contextMap]\n );\n}\nexport {\n FiberProvider,\n traverseFiber,\n useContainer,\n useContextBridge,\n useContextMap,\n useFiber,\n useNearestChild,\n useNearestParent\n};\n//# sourceMappingURL=index.js.map\n","/**\n * Based on ReactArt.js\n * Copyright (c) 2017-present Lavrenov Anton.\n * All rights reserved.\n *\n * MIT\n */\n'use strict';\nimport React from 'react';\nimport Konva from 'konva/lib/Core.js';\nimport ReactFiberReconciler from 'react-reconciler';\nimport { LegacyRoot } from 'react-reconciler/constants.js';\nimport * as HostConfig from './ReactKonvaHostConfig.js';\nimport { applyNodeProps, toggleStrictMode } from './makeUpdates.js';\nimport { useContextBridge, FiberProvider } from 'its-fine';\nfunction usePrevious(value) {\n const ref = React.useRef({});\n React.useLayoutEffect(() => {\n ref.current = value;\n });\n React.useLayoutEffect(() => {\n return () => {\n // when using suspense it is possible that stage is unmounted\n // but React still keep component ref\n // in that case we need to manually flush props\n // we have a special test for that\n ref.current = {};\n };\n }, []);\n return ref.current;\n}\nconst StageWrap = (props) => {\n const container = React.useRef(null);\n const stage = React.useRef(null);\n const fiberRef = React.useRef(null);\n const oldProps = usePrevious(props);\n const Bridge = useContextBridge();\n const _setRef = (stage) => {\n const { forwardedRef } = props;\n if (!forwardedRef) {\n return;\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(stage);\n }\n else {\n forwardedRef.current = stage;\n }\n };\n React.useLayoutEffect(() => {\n stage.current = new Konva.Stage({\n width: props.width,\n height: props.height,\n container: container.current,\n });\n _setRef(stage.current);\n // @ts-ignore\n fiberRef.current = KonvaRenderer.createContainer(stage.current, LegacyRoot, false, null);\n KonvaRenderer.updateContainer(React.createElement(Bridge, {}, props.children), fiberRef.current);\n return () => {\n if (!Konva.isBrowser) {\n return;\n }\n _setRef(null);\n KonvaRenderer.updateContainer(null, fiberRef.current, null);\n stage.current.destroy();\n };\n }, []);\n React.useLayoutEffect(() => {\n _setRef(stage.current);\n applyNodeProps(stage.current, props, oldProps);\n KonvaRenderer.updateContainer(React.createElement(Bridge, {}, props.children), fiberRef.current, null);\n });\n return React.createElement('div', {\n ref: container,\n id: props.id,\n accessKey: props.accessKey,\n className: props.className,\n role: props.role,\n style: props.style,\n tabIndex: props.tabIndex,\n title: props.title,\n });\n};\nexport const Layer = 'Layer';\nexport const FastLayer = 'FastLayer';\nexport const Group = 'Group';\nexport const Label = 'Label';\nexport const Rect = 'Rect';\nexport const Circle = 'Circle';\nexport const Ellipse = 'Ellipse';\nexport const Wedge = 'Wedge';\nexport const Line = 'Line';\nexport const Sprite = 'Sprite';\nexport const Image = 'Image';\nexport const Text = 'Text';\nexport const TextPath = 'TextPath';\nexport const Star = 'Star';\nexport const Ring = 'Ring';\nexport const Arc = 'Arc';\nexport const Tag = 'Tag';\nexport const Path = 'Path';\nexport const RegularPolygon = 'RegularPolygon';\nexport const Arrow = 'Arrow';\nexport const Shape = 'Shape';\nexport const Transformer = 'Transformer';\nexport const version = '18.2.13';\n// @ts-ignore\nexport const KonvaRenderer = ReactFiberReconciler(HostConfig);\nKonvaRenderer.injectIntoDevTools({\n // @ts-ignore\n findHostInstanceByFiber: () => null,\n bundleType: process.env.NODE_ENV !== 'production' ? 1 : 0,\n version: React.version,\n rendererPackageName: 'react-konva',\n});\nexport const Stage = React.forwardRef((props, ref) => {\n return React.createElement(FiberProvider, {}, React.createElement(StageWrap, { ...props, forwardedRef: ref }));\n});\nexport const useStrictMode = toggleStrictMode;\n// export useContextBridge from its-fine for reuse in react-konva-utils\n// so react-konva-utils don't use its own version of its-fine (it is possible on pnpm)\nexport { useContextBridge };\n","var getDimensionsMinimalRatio=function(a,b,c,d){return Math.min(a/c,b/d)||1};export default getDimensionsMinimalRatio;","export var ROOT_CONTAINER_CLASS_NAME=\"FIE_root\";export var DESIGN_LAYER_ID=\"FIE_design-layer\";export var TRANSFORMERS_LAYER_ID=\"FIE_transformers-layer\";export var IMAGE_NODE_ID=\"FIE_original-image\";export var NODES_TRANSFORMER_ID=\"FIE_nodes-transformer\";export var WATERMARK_ANNOTATION_ID=\"watermark\";export var TRANSLATIONS_GRID_UUID=\"353297d2-40b4-4684-a875-45a2178a8157\";export var DEFAULT_SAVE_QUALITY=.92;export var TABS_IDS={FINETUNE:\"Finetune\",FILTERS:\"Filters\",ADJUST:\"Adjust\",WATERMARK:\"Watermark\",ANNOTATE:\"Annotate\",RESIZE:\"Resize\"};export var TOOLS_IDS={CROP:\"Crop\",ROTATE:\"Rotate\",FLIP_X:\"Flip_X\",FLIP_Y:\"Flip_Y\",BRIGHTNESS:\"Brightness\",CONTRAST:\"Contrast\",HSV:\"HueSaturationValue\",WARMTH:\"Warmth\",BLUR:\"Blur\",THRESHOLD:\"Threshold\",POSTERIZE:\"Posterize\",PIXELATE:\"Pixelate\",NOISE:\"Noise\",FILTERS:\"Filters\",RECT:\"Rect\",ELLIPSE:\"Ellipse\",POLYGON:\"Polygon\",TEXT:\"Text\",LINE:\"Line\",IMAGE:\"Image\",ARROW:\"Arrow\",WATERMARK:\"Watermark\",PEN:\"Pen\",RESIZE:\"Resize\"};export var FLIP_DIRECTIONS={X:\"X\",Y:\"Y\"};export var DEFAULT_ZOOM_FACTOR=1;export var SUPPORTED_IMAGE_TYPES=[\"png\",\"jpeg\",\"jpg\",\"webp\"];export var POSSIBLE_IMAGE_TYPES=[].concat(SUPPORTED_IMAGE_TYPES,[\"svg\",\"gif\",\"avif\",\"apng\"]);export var DEFAULT_IMAGE_TYPE=SUPPORTED_IMAGE_TYPES[0];export var POINTER_ICONS={DEFAULT:\"default\",DRAW:\"crosshair\",SELECT:\"pointer\",MOVE:\"move\",DRAG:\"GRAB\"};export var DEFAULT_ENABLED_ANCHORS=[\"top-left\",\"top-center\",\"top-right\",\"middle-right\",\"middle-left\",\"bottom-left\",\"bottom-center\",\"bottom-right\"];export var ORIGINAL_CROP=\"Crop\";export var CUSTOM_CROP=\"custom\";export var ELLIPSE_CROP=\"ellipse\";export var POSITIONS={TOP_LEFT:\"top-left\",TOP_CENTER:\"top-center\",TOP_RIGHT:\"top-right\",MIDDLE_LEFT:\"middle-left\",MIDDLE_CENTER:\"middle-center\",MIDDLE_RIGHT:\"middle-right\",BOTTOM_LEFT:\"bottom-left\",BOTTOM_CENTER:\"bottom-center\",BOTTOM_RIGHT:\"bottom-right\"};export var MIN_CROP={WIDTH:14,HEIGHT:14};export var CLOSING_REASONS={AFTER_SAVE:\"after-saving\",CLOSE_BUTTON:\"close-button-clicked\",BACK_BUTTON:\"back-button-clicked\"};export var FEEDBACK_STATUSES={WARNING:\"warning\",ERROR:\"error\"};export var EDITOR_TO_CLOUDIMG_POSITIONS={top:\"north\",bottom:\"south\",left:\"west\",center:\"center\",right:\"east\"};export var CLOUDIMG_TO_EDITOR_POSITIONS={northwest:\"top-left\",northcenter:\"top-center\",northeast:\"top-right\",centerwest:\"center-left\",centercenter:\"center-center\",centereast:\"center-right\",southwest:\"bottom-left\",southcenter:\"bottom-center\",southeast:\"bottom-right\"};","import{ELLIPSE_CROP}from\"./constants\";var cropImage=function(a,b){var c=!!(2 {\n exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;\n};\nexports._registerNode = _registerNode;\nexports.Konva._injectGlobal(exports.Konva);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Util = exports.Transform = void 0;\nconst Global_1 = require(\"./Global\");\nclass Transform {\n constructor(m = [1, 0, 0, 1, 0, 0]) {\n this.dirty = false;\n this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];\n }\n reset() {\n this.m[0] = 1;\n this.m[1] = 0;\n this.m[2] = 0;\n this.m[3] = 1;\n this.m[4] = 0;\n this.m[5] = 0;\n }\n copy() {\n return new Transform(this.m);\n }\n copyInto(tr) {\n tr.m[0] = this.m[0];\n tr.m[1] = this.m[1];\n tr.m[2] = this.m[2];\n tr.m[3] = this.m[3];\n tr.m[4] = this.m[4];\n tr.m[5] = this.m[5];\n }\n point(point) {\n var m = this.m;\n return {\n x: m[0] * point.x + m[2] * point.y + m[4],\n y: m[1] * point.x + m[3] * point.y + m[5],\n };\n }\n translate(x, y) {\n this.m[4] += this.m[0] * x + this.m[2] * y;\n this.m[5] += this.m[1] * x + this.m[3] * y;\n return this;\n }\n scale(sx, sy) {\n this.m[0] *= sx;\n this.m[1] *= sx;\n this.m[2] *= sy;\n this.m[3] *= sy;\n return this;\n }\n rotate(rad) {\n var c = Math.cos(rad);\n var s = Math.sin(rad);\n var m11 = this.m[0] * c + this.m[2] * s;\n var m12 = this.m[1] * c + this.m[3] * s;\n var m21 = this.m[0] * -s + this.m[2] * c;\n var m22 = this.m[1] * -s + this.m[3] * c;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n }\n getTranslation() {\n return {\n x: this.m[4],\n y: this.m[5],\n };\n }\n skew(sx, sy) {\n var m11 = this.m[0] + this.m[2] * sy;\n var m12 = this.m[1] + this.m[3] * sy;\n var m21 = this.m[2] + this.m[0] * sx;\n var m22 = this.m[3] + this.m[1] * sx;\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n return this;\n }\n multiply(matrix) {\n var m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];\n var m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];\n var m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];\n var m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];\n var dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];\n var dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n this.m[4] = dx;\n this.m[5] = dy;\n return this;\n }\n invert() {\n var d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);\n var m0 = this.m[3] * d;\n var m1 = -this.m[1] * d;\n var m2 = -this.m[2] * d;\n var m3 = this.m[0] * d;\n var m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);\n var m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);\n this.m[0] = m0;\n this.m[1] = m1;\n this.m[2] = m2;\n this.m[3] = m3;\n this.m[4] = m4;\n this.m[5] = m5;\n return this;\n }\n getMatrix() {\n return this.m;\n }\n decompose() {\n var a = this.m[0];\n var b = this.m[1];\n var c = this.m[2];\n var d = this.m[3];\n var e = this.m[4];\n var f = this.m[5];\n var delta = a * d - b * c;\n let result = {\n x: e,\n y: f,\n rotation: 0,\n scaleX: 0,\n scaleY: 0,\n skewX: 0,\n skewY: 0,\n };\n if (a != 0 || b != 0) {\n var r = Math.sqrt(a * a + b * b);\n result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);\n result.scaleX = r;\n result.scaleY = delta / r;\n result.skewX = (a * c + b * d) / delta;\n result.skewY = 0;\n }\n else if (c != 0 || d != 0) {\n var s = Math.sqrt(c * c + d * d);\n result.rotation =\n Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));\n result.scaleX = delta / s;\n result.scaleY = s;\n result.skewX = 0;\n result.skewY = (a * c + b * d) / delta;\n }\n else {\n }\n result.rotation = exports.Util._getRotation(result.rotation);\n return result;\n }\n}\nexports.Transform = Transform;\nvar OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 132, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 255, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 203],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [119, 128, 144],\n slategrey: [119, 128, 144],\n snow: [255, 255, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n transparent: [255, 255, 255, 0],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 5],\n}, RGB_REGEX = /rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)/, animQueue = [];\nconst req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||\n function (f) {\n setTimeout(f, 60);\n };\nexports.Util = {\n _isElement(obj) {\n return !!(obj && obj.nodeType == 1);\n },\n _isFunction(obj) {\n return !!(obj && obj.constructor && obj.call && obj.apply);\n },\n _isPlainObject(obj) {\n return !!obj && obj.constructor === Object;\n },\n _isArray(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_ARRAY;\n },\n _isNumber(obj) {\n return (Object.prototype.toString.call(obj) === OBJECT_NUMBER &&\n !isNaN(obj) &&\n isFinite(obj));\n },\n _isString(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_STRING;\n },\n _isBoolean(obj) {\n return Object.prototype.toString.call(obj) === OBJECT_BOOLEAN;\n },\n isObject(val) {\n return val instanceof Object;\n },\n isValidSelector(selector) {\n if (typeof selector !== 'string') {\n return false;\n }\n var firstChar = selector[0];\n return (firstChar === '#' ||\n firstChar === '.' ||\n firstChar === firstChar.toUpperCase());\n },\n _sign(number) {\n if (number === 0) {\n return 1;\n }\n if (number > 0) {\n return 1;\n }\n else {\n return -1;\n }\n },\n requestAnimFrame(callback) {\n animQueue.push(callback);\n if (animQueue.length === 1) {\n req(function () {\n const queue = animQueue;\n animQueue = [];\n queue.forEach(function (cb) {\n cb();\n });\n });\n }\n },\n createCanvasElement() {\n var canvas = document.createElement('canvas');\n try {\n canvas.style = canvas.style || {};\n }\n catch (e) { }\n return canvas;\n },\n createImageElement() {\n return document.createElement('img');\n },\n _isInDocument(el) {\n while ((el = el.parentNode)) {\n if (el == document) {\n return true;\n }\n }\n return false;\n },\n _urlToImage(url, callback) {\n var imageObj = exports.Util.createImageElement();\n imageObj.onload = function () {\n callback(imageObj);\n };\n imageObj.src = url;\n },\n _rgbToHex(r, g, b) {\n return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n },\n _hexToRgb(hex) {\n hex = hex.replace(HASH, EMPTY_STRING);\n var bigint = parseInt(hex, 16);\n return {\n r: (bigint >> 16) & 255,\n g: (bigint >> 8) & 255,\n b: bigint & 255,\n };\n },\n getRandomColor() {\n var randColor = ((Math.random() * 0xffffff) << 0).toString(16);\n while (randColor.length < 6) {\n randColor = ZERO + randColor;\n }\n return HASH + randColor;\n },\n getRGB(color) {\n var rgb;\n if (color in COLORS) {\n rgb = COLORS[color];\n return {\n r: rgb[0],\n g: rgb[1],\n b: rgb[2],\n };\n }\n else if (color[0] === HASH) {\n return this._hexToRgb(color.substring(1));\n }\n else if (color.substr(0, 4) === RGB_PAREN) {\n rgb = RGB_REGEX.exec(color.replace(/ /g, ''));\n return {\n r: parseInt(rgb[1], 10),\n g: parseInt(rgb[2], 10),\n b: parseInt(rgb[3], 10),\n };\n }\n else {\n return {\n r: 0,\n g: 0,\n b: 0,\n };\n }\n },\n colorToRGBA(str) {\n str = str || 'black';\n return (exports.Util._namedColorToRBA(str) ||\n exports.Util._hex3ColorToRGBA(str) ||\n exports.Util._hex4ColorToRGBA(str) ||\n exports.Util._hex6ColorToRGBA(str) ||\n exports.Util._hex8ColorToRGBA(str) ||\n exports.Util._rgbColorToRGBA(str) ||\n exports.Util._rgbaColorToRGBA(str) ||\n exports.Util._hslColorToRGBA(str));\n },\n _namedColorToRBA(str) {\n var c = COLORS[str.toLowerCase()];\n if (!c) {\n return null;\n }\n return {\n r: c[0],\n g: c[1],\n b: c[2],\n a: 1,\n };\n },\n _rgbColorToRGBA(str) {\n if (str.indexOf('rgb(') === 0) {\n str = str.match(/rgb\\(([^)]+)\\)/)[1];\n var parts = str.split(/ *, */).map(Number);\n return {\n r: parts[0],\n g: parts[1],\n b: parts[2],\n a: 1,\n };\n }\n },\n _rgbaColorToRGBA(str) {\n if (str.indexOf('rgba(') === 0) {\n str = str.match(/rgba\\(([^)]+)\\)/)[1];\n var parts = str.split(/ *, */).map((n, index) => {\n if (n.slice(-1) === '%') {\n return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;\n }\n return Number(n);\n });\n return {\n r: parts[0],\n g: parts[1],\n b: parts[2],\n a: parts[3],\n };\n }\n },\n _hex8ColorToRGBA(str) {\n if (str[0] === '#' && str.length === 9) {\n return {\n r: parseInt(str.slice(1, 3), 16),\n g: parseInt(str.slice(3, 5), 16),\n b: parseInt(str.slice(5, 7), 16),\n a: parseInt(str.slice(7, 9), 16) / 0xff,\n };\n }\n },\n _hex6ColorToRGBA(str) {\n if (str[0] === '#' && str.length === 7) {\n return {\n r: parseInt(str.slice(1, 3), 16),\n g: parseInt(str.slice(3, 5), 16),\n b: parseInt(str.slice(5, 7), 16),\n a: 1,\n };\n }\n },\n _hex4ColorToRGBA(str) {\n if (str[0] === '#' && str.length === 5) {\n return {\n r: parseInt(str[1] + str[1], 16),\n g: parseInt(str[2] + str[2], 16),\n b: parseInt(str[3] + str[3], 16),\n a: parseInt(str[4] + str[4], 16) / 0xff,\n };\n }\n },\n _hex3ColorToRGBA(str) {\n if (str[0] === '#' && str.length === 4) {\n return {\n r: parseInt(str[1] + str[1], 16),\n g: parseInt(str[2] + str[2], 16),\n b: parseInt(str[3] + str[3], 16),\n a: 1,\n };\n }\n },\n _hslColorToRGBA(str) {\n if (/hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/g.test(str)) {\n const [_, ...hsl] = /hsl\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%\\)/g.exec(str);\n const h = Number(hsl[0]) / 360;\n const s = Number(hsl[1]) / 100;\n const l = Number(hsl[2]) / 100;\n let t2;\n let t3;\n let val;\n if (s === 0) {\n val = l * 255;\n return {\n r: Math.round(val),\n g: Math.round(val),\n b: Math.round(val),\n a: 1,\n };\n }\n if (l < 0.5) {\n t2 = l * (1 + s);\n }\n else {\n t2 = l + s - l * s;\n }\n const t1 = 2 * l - t2;\n const rgb = [0, 0, 0];\n for (let i = 0; i < 3; i++) {\n t3 = h + (1 / 3) * -(i - 1);\n if (t3 < 0) {\n t3++;\n }\n if (t3 > 1) {\n t3--;\n }\n if (6 * t3 < 1) {\n val = t1 + (t2 - t1) * 6 * t3;\n }\n else if (2 * t3 < 1) {\n val = t2;\n }\n else if (3 * t3 < 2) {\n val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n }\n else {\n val = t1;\n }\n rgb[i] = val * 255;\n }\n return {\n r: Math.round(rgb[0]),\n g: Math.round(rgb[1]),\n b: Math.round(rgb[2]),\n a: 1,\n };\n }\n },\n haveIntersection(r1, r2) {\n return !(r2.x > r1.x + r1.width ||\n r2.x + r2.width < r1.x ||\n r2.y > r1.y + r1.height ||\n r2.y + r2.height < r1.y);\n },\n cloneObject(obj) {\n var retObj = {};\n for (var key in obj) {\n if (this._isPlainObject(obj[key])) {\n retObj[key] = this.cloneObject(obj[key]);\n }\n else if (this._isArray(obj[key])) {\n retObj[key] = this.cloneArray(obj[key]);\n }\n else {\n retObj[key] = obj[key];\n }\n }\n return retObj;\n },\n cloneArray(arr) {\n return arr.slice(0);\n },\n degToRad(deg) {\n return deg * PI_OVER_DEG180;\n },\n radToDeg(rad) {\n return rad * DEG180_OVER_PI;\n },\n _degToRad(deg) {\n exports.Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');\n return exports.Util.degToRad(deg);\n },\n _radToDeg(rad) {\n exports.Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');\n return exports.Util.radToDeg(rad);\n },\n _getRotation(radians) {\n return Global_1.Konva.angleDeg ? exports.Util.radToDeg(radians) : radians;\n },\n _capitalize(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n throw(str) {\n throw new Error(KONVA_ERROR + str);\n },\n error(str) {\n console.error(KONVA_ERROR + str);\n },\n warn(str) {\n if (!Global_1.Konva.showWarnings) {\n return;\n }\n console.warn(KONVA_WARNING + str);\n },\n each(obj, func) {\n for (var key in obj) {\n func(key, obj[key]);\n }\n },\n _inRange(val, left, right) {\n return left <= val && val < right;\n },\n _getProjectionToSegment(x1, y1, x2, y2, x3, y3) {\n var x, y, dist;\n var pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n if (pd2 == 0) {\n x = x1;\n y = y1;\n dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);\n }\n else {\n var u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;\n if (u < 0) {\n x = x1;\n y = y1;\n dist = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);\n }\n else if (u > 1.0) {\n x = x2;\n y = y2;\n dist = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);\n }\n else {\n x = x1 + u * (x2 - x1);\n y = y1 + u * (y2 - y1);\n dist = (x - x3) * (x - x3) + (y - y3) * (y - y3);\n }\n }\n return [x, y, dist];\n },\n _getProjectionToLine(pt, line, isClosed) {\n var pc = exports.Util.cloneObject(pt);\n var dist = Number.MAX_VALUE;\n line.forEach(function (p1, i) {\n if (!isClosed && i === line.length - 1) {\n return;\n }\n var p2 = line[(i + 1) % line.length];\n var proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);\n var px = proj[0], py = proj[1], pdist = proj[2];\n if (pdist < dist) {\n pc.x = px;\n pc.y = py;\n dist = pdist;\n }\n });\n return pc;\n },\n _prepareArrayForTween(startArray, endArray, isClosed) {\n var n, start = [], end = [];\n if (startArray.length > endArray.length) {\n var temp = endArray;\n endArray = startArray;\n startArray = temp;\n }\n for (n = 0; n < startArray.length; n += 2) {\n start.push({\n x: startArray[n],\n y: startArray[n + 1],\n });\n }\n for (n = 0; n < endArray.length; n += 2) {\n end.push({\n x: endArray[n],\n y: endArray[n + 1],\n });\n }\n var newStart = [];\n end.forEach(function (point) {\n var pr = exports.Util._getProjectionToLine(point, start, isClosed);\n newStart.push(pr.x);\n newStart.push(pr.y);\n });\n return newStart;\n },\n _prepareToStringify(obj) {\n var desc;\n obj.visitedByCircularReferenceRemoval = true;\n for (var key in obj) {\n if (!(obj.hasOwnProperty(key) && obj[key] && typeof obj[key] == 'object')) {\n continue;\n }\n desc = Object.getOwnPropertyDescriptor(obj, key);\n if (obj[key].visitedByCircularReferenceRemoval ||\n exports.Util._isElement(obj[key])) {\n if (desc.configurable) {\n delete obj[key];\n }\n else {\n return null;\n }\n }\n else if (exports.Util._prepareToStringify(obj[key]) === null) {\n if (desc.configurable) {\n delete obj[key];\n }\n else {\n return null;\n }\n }\n }\n delete obj.visitedByCircularReferenceRemoval;\n return obj;\n },\n _assign(target, source) {\n for (var key in source) {\n target[key] = source[key];\n }\n return target;\n },\n _getFirstPointerId(evt) {\n if (!evt.touches) {\n return evt.pointerId || 999;\n }\n else {\n return evt.changedTouches[0].identifier;\n }\n },\n releaseCanvas(...canvases) {\n if (!Global_1.Konva.releaseCanvasOnDestroy)\n return;\n canvases.forEach((c) => {\n c.width = 0;\n c.height = 0;\n });\n },\n drawRoundedRectPath(context, width, height, cornerRadius) {\n let topLeft = 0;\n let topRight = 0;\n let bottomLeft = 0;\n let bottomRight = 0;\n if (typeof cornerRadius === 'number') {\n topLeft =\n topRight =\n bottomLeft =\n bottomRight =\n Math.min(cornerRadius, width / 2, height / 2);\n }\n else {\n topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);\n topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);\n bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);\n bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);\n }\n context.moveTo(topLeft, 0);\n context.lineTo(width - topRight, 0);\n context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);\n context.lineTo(width, height - bottomRight);\n context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);\n context.lineTo(bottomLeft, height);\n context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);\n context.lineTo(0, topLeft);\n context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);\n },\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getComponentValidator = exports.getBooleanValidator = exports.getNumberArrayValidator = exports.getFunctionValidator = exports.getStringOrGradientValidator = exports.getStringValidator = exports.getNumberOrAutoValidator = exports.getNumberOrArrayOfNumbersValidator = exports.getNumberValidator = exports.alphaComponent = exports.RGBComponent = void 0;\nconst Global_1 = require(\"./Global\");\nconst Util_1 = require(\"./Util\");\nfunction _formatValue(val) {\n if (Util_1.Util._isString(val)) {\n return '\"' + val + '\"';\n }\n if (Object.prototype.toString.call(val) === '[object Number]') {\n return val;\n }\n if (Util_1.Util._isBoolean(val)) {\n return val;\n }\n return Object.prototype.toString.call(val);\n}\nfunction RGBComponent(val) {\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n return Math.round(val);\n}\nexports.RGBComponent = RGBComponent;\nfunction alphaComponent(val) {\n if (val > 1) {\n return 1;\n }\n else if (val < 0.0001) {\n return 0.0001;\n }\n return val;\n}\nexports.alphaComponent = alphaComponent;\nfunction getNumberValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isNumber(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number.');\n }\n return val;\n };\n }\n}\nexports.getNumberValidator = getNumberValidator;\nfunction getNumberOrArrayOfNumbersValidator(noOfElements) {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n let isNumber = Util_1.Util._isNumber(val);\n let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;\n if (!isNumber && !isValidArray) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number or Array(' +\n noOfElements +\n ')');\n }\n return val;\n };\n }\n}\nexports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;\nfunction getNumberOrAutoValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n var isNumber = Util_1.Util._isNumber(val);\n var isAuto = val === 'auto';\n if (!(isNumber || isAuto)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a number or \"auto\".');\n }\n return val;\n };\n }\n}\nexports.getNumberOrAutoValidator = getNumberOrAutoValidator;\nfunction getStringValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isString(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a string.');\n }\n return val;\n };\n }\n}\nexports.getStringValidator = getStringValidator;\nfunction getStringOrGradientValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n const isString = Util_1.Util._isString(val);\n const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||\n (val && val.addColorStop);\n if (!(isString || isGradient)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a string or a native gradient.');\n }\n return val;\n };\n }\n}\nexports.getStringOrGradientValidator = getStringOrGradientValidator;\nfunction getFunctionValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (!Util_1.Util._isFunction(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a function.');\n }\n return val;\n };\n }\n}\nexports.getFunctionValidator = getFunctionValidator;\nfunction getNumberArrayValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;\n if (TypedArray && val instanceof TypedArray) {\n return val;\n }\n if (!Util_1.Util._isArray(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a array of numbers.');\n }\n else {\n val.forEach(function (item) {\n if (!Util_1.Util._isNumber(item)) {\n Util_1.Util.warn('\"' +\n attr +\n '\" attribute has non numeric element ' +\n item +\n '. Make sure that all elements are numbers.');\n }\n });\n }\n return val;\n };\n }\n}\nexports.getNumberArrayValidator = getNumberArrayValidator;\nfunction getBooleanValidator() {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n var isBool = val === true || val === false;\n if (!isBool) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be a boolean.');\n }\n return val;\n };\n }\n}\nexports.getBooleanValidator = getBooleanValidator;\nfunction getComponentValidator(components) {\n if (Global_1.Konva.isUnminified) {\n return function (val, attr) {\n if (val === undefined || val === null) {\n return val;\n }\n if (!Util_1.Util.isObject(val)) {\n Util_1.Util.warn(_formatValue(val) +\n ' is a not valid value for \"' +\n attr +\n '\" attribute. The value should be an object with properties ' +\n components);\n }\n return val;\n };\n }\n}\nexports.getComponentValidator = getComponentValidator;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Factory = void 0;\nconst Util_1 = require(\"./Util\");\nconst Validators_1 = require(\"./Validators\");\nvar GET = 'get', SET = 'set';\nexports.Factory = {\n addGetterSetter(constructor, attr, def, validator, after) {\n exports.Factory.addGetter(constructor, attr, def);\n exports.Factory.addSetter(constructor, attr, validator, after);\n exports.Factory.addOverloadedGetterSetter(constructor, attr);\n },\n addGetter(constructor, attr, def) {\n var method = GET + Util_1.Util._capitalize(attr);\n constructor.prototype[method] =\n constructor.prototype[method] ||\n function () {\n var val = this.attrs[attr];\n return val === undefined ? def : val;\n };\n },\n addSetter(constructor, attr, validator, after) {\n var method = SET + Util_1.Util._capitalize(attr);\n if (!constructor.prototype[method]) {\n exports.Factory.overWriteSetter(constructor, attr, validator, after);\n }\n },\n overWriteSetter(constructor, attr, validator, after) {\n var method = SET + Util_1.Util._capitalize(attr);\n constructor.prototype[method] = function (val) {\n if (validator && val !== undefined && val !== null) {\n val = validator.call(this, val, attr);\n }\n this._setAttr(attr, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n },\n addComponentsGetterSetter(constructor, attr, components, validator, after) {\n var len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), n, component;\n constructor.prototype[getter] = function () {\n var ret = {};\n for (n = 0; n < len; n++) {\n component = components[n];\n ret[component] = this.getAttr(attr + capitalize(component));\n }\n return ret;\n };\n var basicValidator = (0, Validators_1.getComponentValidator)(components);\n constructor.prototype[setter] = function (val) {\n var oldVal = this.attrs[attr], key;\n if (validator) {\n val = validator.call(this, val);\n }\n if (basicValidator) {\n basicValidator.call(this, val, attr);\n }\n for (key in val) {\n if (!val.hasOwnProperty(key)) {\n continue;\n }\n this._setAttr(attr + capitalize(key), val[key]);\n }\n if (!val) {\n components.forEach((component) => {\n this._setAttr(attr + capitalize(component), undefined);\n });\n }\n this._fireChangeEvent(attr, oldVal, val);\n if (after) {\n after.call(this);\n }\n return this;\n };\n exports.Factory.addOverloadedGetterSetter(constructor, attr);\n },\n addOverloadedGetterSetter(constructor, attr) {\n var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;\n constructor.prototype[attr] = function () {\n if (arguments.length) {\n this[setter](arguments[0]);\n return this;\n }\n return this[getter]();\n };\n },\n addDeprecatedGetterSetter(constructor, attr, def, validator) {\n Util_1.Util.error('Adding deprecated ' + attr);\n var method = GET + Util_1.Util._capitalize(attr);\n var message = attr +\n ' property is deprecated and will be removed soon. Look at Konva change log for more information.';\n constructor.prototype[method] = function () {\n Util_1.Util.error(message);\n var val = this.attrs[attr];\n return val === undefined ? def : val;\n };\n exports.Factory.addSetter(constructor, attr, validator, function () {\n Util_1.Util.error(message);\n });\n exports.Factory.addOverloadedGetterSetter(constructor, attr);\n },\n backCompat(constructor, methods) {\n Util_1.Util.each(methods, function (oldMethodName, newMethodName) {\n var method = constructor.prototype[newMethodName];\n var oldGetter = GET + Util_1.Util._capitalize(oldMethodName);\n var oldSetter = SET + Util_1.Util._capitalize(oldMethodName);\n function deprecated() {\n method.apply(this, arguments);\n Util_1.Util.error('\"' +\n oldMethodName +\n '\" method is deprecated and will be removed soon. Use \"\"' +\n newMethodName +\n '\" instead.');\n }\n constructor.prototype[oldMethodName] = deprecated;\n constructor.prototype[oldGetter] = deprecated;\n constructor.prototype[oldSetter] = deprecated;\n });\n },\n afterSetFilter() {\n this._filterUpToDate = false;\n },\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HitContext = exports.SceneContext = exports.Context = void 0;\nconst Util_1 = require(\"./Util\");\nconst Global_1 = require(\"./Global\");\nfunction simplifyArray(arr) {\n var retArr = [], len = arr.length, util = Util_1.Util, n, val;\n for (n = 0; n < len; n++) {\n val = arr[n];\n if (util._isNumber(val)) {\n val = Math.round(val * 1000) / 1000;\n }\n else if (!util._isString(val)) {\n val = val + '';\n }\n retArr.push(val);\n }\n return retArr;\n}\nvar COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [\n 'arc',\n 'arcTo',\n 'beginPath',\n 'bezierCurveTo',\n 'clearRect',\n 'clip',\n 'closePath',\n 'createLinearGradient',\n 'createPattern',\n 'createRadialGradient',\n 'drawImage',\n 'ellipse',\n 'fill',\n 'fillText',\n 'getImageData',\n 'createImageData',\n 'lineTo',\n 'moveTo',\n 'putImageData',\n 'quadraticCurveTo',\n 'rect',\n 'roundRect',\n 'restore',\n 'rotate',\n 'save',\n 'scale',\n 'setLineDash',\n 'setTransform',\n 'stroke',\n 'strokeText',\n 'transform',\n 'translate',\n];\nvar CONTEXT_PROPERTIES = [\n 'fillStyle',\n 'strokeStyle',\n 'shadowColor',\n 'shadowBlur',\n 'shadowOffsetX',\n 'shadowOffsetY',\n 'letterSpacing',\n 'lineCap',\n 'lineDashOffset',\n 'lineJoin',\n 'lineWidth',\n 'miterLimit',\n 'direction',\n 'font',\n 'textAlign',\n 'textBaseline',\n 'globalAlpha',\n 'globalCompositeOperation',\n 'imageSmoothingEnabled',\n];\nconst traceArrMax = 100;\nclass Context {\n constructor(canvas) {\n this.canvas = canvas;\n if (Global_1.Konva.enableTrace) {\n this.traceArr = [];\n this._enableTrace();\n }\n }\n fillShape(shape) {\n if (shape.fillEnabled()) {\n this._fill(shape);\n }\n }\n _fill(shape) {\n }\n strokeShape(shape) {\n if (shape.hasStroke()) {\n this._stroke(shape);\n }\n }\n _stroke(shape) {\n }\n fillStrokeShape(shape) {\n if (shape.attrs.fillAfterStrokeEnabled) {\n this.strokeShape(shape);\n this.fillShape(shape);\n }\n else {\n this.fillShape(shape);\n this.strokeShape(shape);\n }\n }\n getTrace(relaxed, rounded) {\n var traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;\n for (n = 0; n < len; n++) {\n trace = traceArr[n];\n method = trace.method;\n if (method) {\n args = trace.args;\n str += method;\n if (relaxed) {\n str += DOUBLE_PAREN;\n }\n else {\n if (Util_1.Util._isArray(args[0])) {\n str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;\n }\n else {\n if (rounded) {\n args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);\n }\n str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;\n }\n }\n }\n else {\n str += trace.property;\n if (!relaxed) {\n str += EQUALS + trace.val;\n }\n }\n str += SEMICOLON;\n }\n return str;\n }\n clearTrace() {\n this.traceArr = [];\n }\n _trace(str) {\n var traceArr = this.traceArr, len;\n traceArr.push(str);\n len = traceArr.length;\n if (len >= traceArrMax) {\n traceArr.shift();\n }\n }\n reset() {\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);\n }\n getCanvas() {\n return this.canvas;\n }\n clear(bounds) {\n var canvas = this.getCanvas();\n if (bounds) {\n this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);\n }\n else {\n this.clearRect(0, 0, canvas.getWidth() / canvas.pixelRatio, canvas.getHeight() / canvas.pixelRatio);\n }\n }\n _applyLineCap(shape) {\n const lineCap = shape.attrs.lineCap;\n if (lineCap) {\n this.setAttr('lineCap', lineCap);\n }\n }\n _applyOpacity(shape) {\n var absOpacity = shape.getAbsoluteOpacity();\n if (absOpacity !== 1) {\n this.setAttr('globalAlpha', absOpacity);\n }\n }\n _applyLineJoin(shape) {\n const lineJoin = shape.attrs.lineJoin;\n if (lineJoin) {\n this.setAttr('lineJoin', lineJoin);\n }\n }\n setAttr(attr, val) {\n this._context[attr] = val;\n }\n arc(x, y, radius, startAngle, endAngle, counterClockwise) {\n this._context.arc(x, y, radius, startAngle, endAngle, counterClockwise);\n }\n arcTo(x1, y1, x2, y2, radius) {\n this._context.arcTo(x1, y1, x2, y2, radius);\n }\n beginPath() {\n this._context.beginPath();\n }\n bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {\n this._context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);\n }\n clearRect(x, y, width, height) {\n this._context.clearRect(x, y, width, height);\n }\n clip(...args) {\n this._context.clip.apply(this._context, args);\n }\n closePath() {\n this._context.closePath();\n }\n createImageData(width, height) {\n var a = arguments;\n if (a.length === 2) {\n return this._context.createImageData(width, height);\n }\n else if (a.length === 1) {\n return this._context.createImageData(width);\n }\n }\n createLinearGradient(x0, y0, x1, y1) {\n return this._context.createLinearGradient(x0, y0, x1, y1);\n }\n createPattern(image, repetition) {\n return this._context.createPattern(image, repetition);\n }\n createRadialGradient(x0, y0, r0, x1, y1, r1) {\n return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);\n }\n drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {\n var a = arguments, _context = this._context;\n if (a.length === 3) {\n _context.drawImage(image, sx, sy);\n }\n else if (a.length === 5) {\n _context.drawImage(image, sx, sy, sWidth, sHeight);\n }\n else if (a.length === 9) {\n _context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);\n }\n }\n ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {\n this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);\n }\n isPointInPath(x, y, path, fillRule) {\n if (path) {\n return this._context.isPointInPath(path, x, y, fillRule);\n }\n return this._context.isPointInPath(x, y, fillRule);\n }\n fill(...args) {\n this._context.fill.apply(this._context, args);\n }\n fillRect(x, y, width, height) {\n this._context.fillRect(x, y, width, height);\n }\n strokeRect(x, y, width, height) {\n this._context.strokeRect(x, y, width, height);\n }\n fillText(text, x, y, maxWidth) {\n if (maxWidth) {\n this._context.fillText(text, x, y, maxWidth);\n }\n else {\n this._context.fillText(text, x, y);\n }\n }\n measureText(text) {\n return this._context.measureText(text);\n }\n getImageData(sx, sy, sw, sh) {\n return this._context.getImageData(sx, sy, sw, sh);\n }\n lineTo(x, y) {\n this._context.lineTo(x, y);\n }\n moveTo(x, y) {\n this._context.moveTo(x, y);\n }\n rect(x, y, width, height) {\n this._context.rect(x, y, width, height);\n }\n roundRect(x, y, width, height, radii) {\n this._context.roundRect(x, y, width, height, radii);\n }\n putImageData(imageData, dx, dy) {\n this._context.putImageData(imageData, dx, dy);\n }\n quadraticCurveTo(cpx, cpy, x, y) {\n this._context.quadraticCurveTo(cpx, cpy, x, y);\n }\n restore() {\n this._context.restore();\n }\n rotate(angle) {\n this._context.rotate(angle);\n }\n save() {\n this._context.save();\n }\n scale(x, y) {\n this._context.scale(x, y);\n }\n setLineDash(segments) {\n if (this._context.setLineDash) {\n this._context.setLineDash(segments);\n }\n else if ('mozDash' in this._context) {\n this._context['mozDash'] = segments;\n }\n else if ('webkitLineDash' in this._context) {\n this._context['webkitLineDash'] = segments;\n }\n }\n getLineDash() {\n return this._context.getLineDash();\n }\n setTransform(a, b, c, d, e, f) {\n this._context.setTransform(a, b, c, d, e, f);\n }\n stroke(path2d) {\n if (path2d) {\n this._context.stroke(path2d);\n }\n else {\n this._context.stroke();\n }\n }\n strokeText(text, x, y, maxWidth) {\n this._context.strokeText(text, x, y, maxWidth);\n }\n transform(a, b, c, d, e, f) {\n this._context.transform(a, b, c, d, e, f);\n }\n translate(x, y) {\n this._context.translate(x, y);\n }\n _enableTrace() {\n var that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;\n var func = function (methodName) {\n var origMethod = that[methodName], ret;\n that[methodName] = function () {\n args = simplifyArray(Array.prototype.slice.call(arguments, 0));\n ret = origMethod.apply(that, arguments);\n that._trace({\n method: methodName,\n args: args,\n });\n return ret;\n };\n };\n for (n = 0; n < len; n++) {\n func(CONTEXT_METHODS[n]);\n }\n that.setAttr = function () {\n origSetter.apply(that, arguments);\n var prop = arguments[0];\n var val = arguments[1];\n if (prop === 'shadowOffsetX' ||\n prop === 'shadowOffsetY' ||\n prop === 'shadowBlur') {\n val = val / this.canvas.getPixelRatio();\n }\n that._trace({\n property: prop,\n val: val,\n });\n };\n }\n _applyGlobalCompositeOperation(node) {\n const op = node.attrs.globalCompositeOperation;\n var def = !op || op === 'source-over';\n if (!def) {\n this.setAttr('globalCompositeOperation', op);\n }\n }\n}\nexports.Context = Context;\nCONTEXT_PROPERTIES.forEach(function (prop) {\n Object.defineProperty(Context.prototype, prop, {\n get() {\n return this._context[prop];\n },\n set(val) {\n this._context[prop] = val;\n },\n });\n});\nclass SceneContext extends Context {\n constructor(canvas, { willReadFrequently = false } = {}) {\n super(canvas);\n this._context = canvas._canvas.getContext('2d', {\n willReadFrequently,\n });\n }\n _fillColor(shape) {\n var fill = shape.fill();\n this.setAttr('fillStyle', fill);\n shape._fillFunc(this);\n }\n _fillPattern(shape) {\n this.setAttr('fillStyle', shape._getFillPattern());\n shape._fillFunc(this);\n }\n _fillLinearGradient(shape) {\n var grd = shape._getLinearGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n }\n _fillRadialGradient(shape) {\n const grd = shape._getRadialGradient();\n if (grd) {\n this.setAttr('fillStyle', grd);\n shape._fillFunc(this);\n }\n }\n _fill(shape) {\n const hasColor = shape.fill(), fillPriority = shape.getFillPriority();\n if (hasColor && fillPriority === 'color') {\n this._fillColor(shape);\n return;\n }\n const hasPattern = shape.getFillPatternImage();\n if (hasPattern && fillPriority === 'pattern') {\n this._fillPattern(shape);\n return;\n }\n const hasLinearGradient = shape.getFillLinearGradientColorStops();\n if (hasLinearGradient && fillPriority === 'linear-gradient') {\n this._fillLinearGradient(shape);\n return;\n }\n const hasRadialGradient = shape.getFillRadialGradientColorStops();\n if (hasRadialGradient && fillPriority === 'radial-gradient') {\n this._fillRadialGradient(shape);\n return;\n }\n if (hasColor) {\n this._fillColor(shape);\n }\n else if (hasPattern) {\n this._fillPattern(shape);\n }\n else if (hasLinearGradient) {\n this._fillLinearGradient(shape);\n }\n else if (hasRadialGradient) {\n this._fillRadialGradient(shape);\n }\n }\n _strokeLinearGradient(shape) {\n const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);\n if (colorStops) {\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n this.setAttr('strokeStyle', grd);\n }\n }\n _stroke(shape) {\n var dash = shape.dash(), strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (shape.hasStroke()) {\n if (!strokeScaleEnabled) {\n this.save();\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n if (dash && shape.dashEnabled()) {\n this.setLineDash(dash);\n this.setAttr('lineDashOffset', shape.dashOffset());\n }\n this.setAttr('lineWidth', shape.strokeWidth());\n if (!shape.getShadowForStrokeEnabled()) {\n this.setAttr('shadowColor', 'rgba(0,0,0,0)');\n }\n var hasLinearGradient = shape.getStrokeLinearGradientColorStops();\n if (hasLinearGradient) {\n this._strokeLinearGradient(shape);\n }\n else {\n this.setAttr('strokeStyle', shape.stroke());\n }\n shape._strokeFunc(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n }\n _applyShadow(shape) {\n var _a, _b, _c;\n var color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {\n x: 0,\n y: 0,\n }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;\n this.setAttr('shadowColor', color);\n this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));\n this.setAttr('shadowOffsetX', offset.x * scaleX);\n this.setAttr('shadowOffsetY', offset.y * scaleY);\n }\n}\nexports.SceneContext = SceneContext;\nclass HitContext extends Context {\n constructor(canvas) {\n super(canvas);\n this._context = canvas._canvas.getContext('2d', {\n willReadFrequently: true,\n });\n }\n _fill(shape) {\n this.save();\n this.setAttr('fillStyle', shape.colorKey);\n shape._fillFuncHit(this);\n this.restore();\n }\n strokeShape(shape) {\n if (shape.hasHitStroke()) {\n this._stroke(shape);\n }\n }\n _stroke(shape) {\n if (shape.hasHitStroke()) {\n const strokeScaleEnabled = shape.getStrokeScaleEnabled();\n if (!strokeScaleEnabled) {\n this.save();\n var pixelRatio = this.getCanvas().getPixelRatio();\n this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n }\n this._applyLineCap(shape);\n var hitStrokeWidth = shape.hitStrokeWidth();\n var strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;\n this.setAttr('lineWidth', strokeWidth);\n this.setAttr('strokeStyle', shape.colorKey);\n shape._strokeFuncHit(this);\n if (!strokeScaleEnabled) {\n this.restore();\n }\n }\n }\n}\nexports.HitContext = HitContext;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HitCanvas = exports.SceneCanvas = exports.Canvas = void 0;\nconst Util_1 = require(\"./Util\");\nconst Context_1 = require(\"./Context\");\nconst Global_1 = require(\"./Global\");\nconst Factory_1 = require(\"./Factory\");\nconst Validators_1 = require(\"./Validators\");\nvar _pixelRatio;\nfunction getDevicePixelRatio() {\n if (_pixelRatio) {\n return _pixelRatio;\n }\n var canvas = Util_1.Util.createCanvasElement();\n var context = canvas.getContext('2d');\n _pixelRatio = (function () {\n var devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||\n context.mozBackingStorePixelRatio ||\n context.msBackingStorePixelRatio ||\n context.oBackingStorePixelRatio ||\n context.backingStorePixelRatio ||\n 1;\n return devicePixelRatio / backingStoreRatio;\n })();\n Util_1.Util.releaseCanvas(canvas);\n return _pixelRatio;\n}\nclass Canvas {\n constructor(config) {\n this.pixelRatio = 1;\n this.width = 0;\n this.height = 0;\n this.isCache = false;\n var conf = config || {};\n var pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();\n this.pixelRatio = pixelRatio;\n this._canvas = Util_1.Util.createCanvasElement();\n this._canvas.style.padding = '0';\n this._canvas.style.margin = '0';\n this._canvas.style.border = '0';\n this._canvas.style.background = 'transparent';\n this._canvas.style.position = 'absolute';\n this._canvas.style.top = '0';\n this._canvas.style.left = '0';\n }\n getContext() {\n return this.context;\n }\n getPixelRatio() {\n return this.pixelRatio;\n }\n setPixelRatio(pixelRatio) {\n var previousRatio = this.pixelRatio;\n this.pixelRatio = pixelRatio;\n this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);\n }\n setWidth(width) {\n this.width = this._canvas.width = width * this.pixelRatio;\n this._canvas.style.width = width + 'px';\n var pixelRatio = this.pixelRatio, _context = this.getContext()._context;\n _context.scale(pixelRatio, pixelRatio);\n }\n setHeight(height) {\n this.height = this._canvas.height = height * this.pixelRatio;\n this._canvas.style.height = height + 'px';\n var pixelRatio = this.pixelRatio, _context = this.getContext()._context;\n _context.scale(pixelRatio, pixelRatio);\n }\n getWidth() {\n return this.width;\n }\n getHeight() {\n return this.height;\n }\n setSize(width, height) {\n this.setWidth(width || 0);\n this.setHeight(height || 0);\n }\n toDataURL(mimeType, quality) {\n try {\n return this._canvas.toDataURL(mimeType, quality);\n }\n catch (e) {\n try {\n return this._canvas.toDataURL();\n }\n catch (err) {\n Util_1.Util.error('Unable to get data URL. ' +\n err.message +\n ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n return '';\n }\n }\n }\n}\nexports.Canvas = Canvas;\nFactory_1.Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());\nclass SceneCanvas extends Canvas {\n constructor(config = { width: 0, height: 0, willReadFrequently: false }) {\n super(config);\n this.context = new Context_1.SceneContext(this, {\n willReadFrequently: config.willReadFrequently,\n });\n this.setSize(config.width, config.height);\n }\n}\nexports.SceneCanvas = SceneCanvas;\nclass HitCanvas extends Canvas {\n constructor(config = { width: 0, height: 0 }) {\n super(config);\n this.hitCanvas = true;\n this.context = new Context_1.HitContext(this);\n this.setSize(config.width, config.height);\n }\n}\nexports.HitCanvas = HitCanvas;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DD = void 0;\nconst Global_1 = require(\"./Global\");\nconst Util_1 = require(\"./Util\");\nexports.DD = {\n get isDragging() {\n var flag = false;\n exports.DD._dragElements.forEach((elem) => {\n if (elem.dragStatus === 'dragging') {\n flag = true;\n }\n });\n return flag;\n },\n justDragged: false,\n get node() {\n var node;\n exports.DD._dragElements.forEach((elem) => {\n node = elem.node;\n });\n return node;\n },\n _dragElements: new Map(),\n _drag(evt) {\n const nodesToFireEvents = [];\n exports.DD._dragElements.forEach((elem, key) => {\n const { node } = elem;\n const stage = node.getStage();\n stage.setPointersPositions(evt);\n if (elem.pointerId === undefined) {\n elem.pointerId = Util_1.Util._getFirstPointerId(evt);\n }\n const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);\n if (!pos) {\n return;\n }\n if (elem.dragStatus !== 'dragging') {\n var dragDistance = node.dragDistance();\n var distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));\n if (distance < dragDistance) {\n return;\n }\n node.startDrag({ evt });\n if (!node.isDragging()) {\n return;\n }\n }\n node._setDragPosition(evt, elem);\n nodesToFireEvents.push(node);\n });\n nodesToFireEvents.forEach((node) => {\n node.fire('dragmove', {\n type: 'dragmove',\n target: node,\n evt: evt,\n }, true);\n });\n },\n _endDragBefore(evt) {\n const drawNodes = [];\n exports.DD._dragElements.forEach((elem) => {\n const { node } = elem;\n const stage = node.getStage();\n if (evt) {\n stage.setPointersPositions(evt);\n }\n const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);\n if (!pos) {\n return;\n }\n if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {\n exports.DD.justDragged = true;\n Global_1.Konva._mouseListenClick = false;\n Global_1.Konva._touchListenClick = false;\n Global_1.Konva._pointerListenClick = false;\n elem.dragStatus = 'stopped';\n }\n const drawNode = elem.node.getLayer() ||\n (elem.node instanceof Global_1.Konva['Stage'] && elem.node);\n if (drawNode && drawNodes.indexOf(drawNode) === -1) {\n drawNodes.push(drawNode);\n }\n });\n drawNodes.forEach((drawNode) => {\n drawNode.draw();\n });\n },\n _endDragAfter(evt) {\n exports.DD._dragElements.forEach((elem, key) => {\n if (elem.dragStatus === 'stopped') {\n elem.node.fire('dragend', {\n type: 'dragend',\n target: elem.node,\n evt: evt,\n }, true);\n }\n if (elem.dragStatus !== 'dragging') {\n exports.DD._dragElements.delete(key);\n }\n });\n },\n};\nif (Global_1.Konva.isBrowser) {\n window.addEventListener('mouseup', exports.DD._endDragBefore, true);\n window.addEventListener('touchend', exports.DD._endDragBefore, true);\n window.addEventListener('mousemove', exports.DD._drag);\n window.addEventListener('touchmove', exports.DD._drag);\n window.addEventListener('mouseup', exports.DD._endDragAfter, false);\n window.addEventListener('touchend', exports.DD._endDragAfter, false);\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Node = void 0;\nconst Util_1 = require(\"./Util\");\nconst Factory_1 = require(\"./Factory\");\nconst Canvas_1 = require(\"./Canvas\");\nconst Global_1 = require(\"./Global\");\nconst DragAndDrop_1 = require(\"./DragAndDrop\");\nconst Validators_1 = require(\"./Validators\");\nvar ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [\n 'xChange.konva',\n 'yChange.konva',\n 'scaleXChange.konva',\n 'scaleYChange.konva',\n 'skewXChange.konva',\n 'skewYChange.konva',\n 'rotationChange.konva',\n 'offsetXChange.konva',\n 'offsetYChange.konva',\n 'transformsEnabledChange.konva',\n].join(SPACE);\nlet idCounter = 1;\nclass Node {\n constructor(config) {\n this._id = idCounter++;\n this.eventListeners = {};\n this.attrs = {};\n this.index = 0;\n this._allEventListeners = null;\n this.parent = null;\n this._cache = new Map();\n this._attachedDepsListeners = new Map();\n this._lastPos = null;\n this._batchingTransformChange = false;\n this._needClearTransformCache = false;\n this._filterUpToDate = false;\n this._isUnderCache = false;\n this._dragEventId = null;\n this._shouldFireChangeEvents = false;\n this.setAttrs(config);\n this._shouldFireChangeEvents = true;\n }\n hasChildren() {\n return false;\n }\n _clearCache(attr) {\n if ((attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM) &&\n this._cache.get(attr)) {\n this._cache.get(attr).dirty = true;\n }\n else if (attr) {\n this._cache.delete(attr);\n }\n else {\n this._cache.clear();\n }\n }\n _getCache(attr, privateGetter) {\n var cache = this._cache.get(attr);\n var isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;\n var invalid = cache === undefined || (isTransform && cache.dirty === true);\n if (invalid) {\n cache = privateGetter.call(this);\n this._cache.set(attr, cache);\n }\n return cache;\n }\n _calculate(name, deps, getter) {\n if (!this._attachedDepsListeners.get(name)) {\n const depsString = deps.map((dep) => dep + 'Change.konva').join(SPACE);\n this.on(depsString, () => {\n this._clearCache(name);\n });\n this._attachedDepsListeners.set(name, true);\n }\n return this._getCache(name, getter);\n }\n _getCanvasCache() {\n return this._cache.get(CANVAS);\n }\n _clearSelfAndDescendantCache(attr) {\n this._clearCache(attr);\n if (attr === ABSOLUTE_TRANSFORM) {\n this.fire('absoluteTransformChange');\n }\n }\n clearCache() {\n if (this._cache.has(CANVAS)) {\n const { scene, filter, hit } = this._cache.get(CANVAS);\n Util_1.Util.releaseCanvas(scene, filter, hit);\n this._cache.delete(CANVAS);\n }\n this._clearSelfAndDescendantCache();\n this._requestDraw();\n return this;\n }\n cache(config) {\n var conf = config || {};\n var rect = {};\n if (conf.x === undefined ||\n conf.y === undefined ||\n conf.width === undefined ||\n conf.height === undefined) {\n rect = this.getClientRect({\n skipTransform: true,\n relativeTo: this.getParent() || undefined,\n });\n }\n var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;\n if (!width || !height) {\n Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');\n return;\n }\n const extraPaddingX = Math.abs(Math.round(rect.x) - x) > 0.5 ? 1 : 0;\n const extraPaddingY = Math.abs(Math.round(rect.y) - y) > 0.5 ? 1 : 0;\n width += offset * 2 + extraPaddingX;\n height += offset * 2 + extraPaddingY;\n x -= offset;\n y -= offset;\n var cachedSceneCanvas = new Canvas_1.SceneCanvas({\n pixelRatio: pixelRatio,\n width: width,\n height: height,\n }), cachedFilterCanvas = new Canvas_1.SceneCanvas({\n pixelRatio: pixelRatio,\n width: 0,\n height: 0,\n willReadFrequently: true,\n }), cachedHitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: hitCanvasPixelRatio,\n width: width,\n height: height,\n }), sceneContext = cachedSceneCanvas.getContext(), hitContext = cachedHitCanvas.getContext();\n cachedHitCanvas.isCache = true;\n cachedSceneCanvas.isCache = true;\n this._cache.delete(CANVAS);\n this._filterUpToDate = false;\n if (conf.imageSmoothingEnabled === false) {\n cachedSceneCanvas.getContext()._context.imageSmoothingEnabled = false;\n cachedFilterCanvas.getContext()._context.imageSmoothingEnabled = false;\n }\n sceneContext.save();\n hitContext.save();\n sceneContext.translate(-x, -y);\n hitContext.translate(-x, -y);\n this._isUnderCache = true;\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);\n this.drawScene(cachedSceneCanvas, this);\n this.drawHit(cachedHitCanvas, this);\n this._isUnderCache = false;\n sceneContext.restore();\n hitContext.restore();\n if (drawBorder) {\n sceneContext.save();\n sceneContext.beginPath();\n sceneContext.rect(0, 0, width, height);\n sceneContext.closePath();\n sceneContext.setAttr('strokeStyle', 'red');\n sceneContext.setAttr('lineWidth', 5);\n sceneContext.stroke();\n sceneContext.restore();\n }\n this._cache.set(CANVAS, {\n scene: cachedSceneCanvas,\n filter: cachedFilterCanvas,\n hit: cachedHitCanvas,\n x: x,\n y: y,\n });\n this._requestDraw();\n return this;\n }\n isCached() {\n return this._cache.has(CANVAS);\n }\n getClientRect(config) {\n throw new Error('abstract \"getClientRect\" method call');\n }\n _transformedRect(rect, top) {\n var points = [\n { x: rect.x, y: rect.y },\n { x: rect.x + rect.width, y: rect.y },\n { x: rect.x + rect.width, y: rect.y + rect.height },\n { x: rect.x, y: rect.y + rect.height },\n ];\n var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n var trans = this.getAbsoluteTransform(top);\n points.forEach(function (point) {\n var transformed = trans.point(point);\n if (minX === undefined) {\n minX = maxX = transformed.x;\n minY = maxY = transformed.y;\n }\n minX = Math.min(minX, transformed.x);\n minY = Math.min(minY, transformed.y);\n maxX = Math.max(maxX, transformed.x);\n maxY = Math.max(maxY, transformed.y);\n });\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n _drawCachedSceneCanvas(context) {\n context.save();\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n const canvasCache = this._getCanvasCache();\n context.translate(canvasCache.x, canvasCache.y);\n var cacheCanvas = this._getCachedSceneCanvas();\n var ratio = cacheCanvas.pixelRatio;\n context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);\n context.restore();\n }\n _drawCachedHitCanvas(context) {\n var canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;\n context.save();\n context.translate(canvasCache.x, canvasCache.y);\n context.drawImage(hitCanvas._canvas, 0, 0, hitCanvas.width / hitCanvas.pixelRatio, hitCanvas.height / hitCanvas.pixelRatio);\n context.restore();\n }\n _getCachedSceneCanvas() {\n var filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;\n if (filters) {\n if (!this._filterUpToDate) {\n var ratio = sceneCanvas.pixelRatio;\n filterCanvas.setSize(sceneCanvas.width / sceneCanvas.pixelRatio, sceneCanvas.height / sceneCanvas.pixelRatio);\n try {\n len = filters.length;\n filterContext.clear();\n filterContext.drawImage(sceneCanvas._canvas, 0, 0, sceneCanvas.getWidth() / ratio, sceneCanvas.getHeight() / ratio);\n imageData = filterContext.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight());\n for (n = 0; n < len; n++) {\n filter = filters[n];\n if (typeof filter !== 'function') {\n Util_1.Util.error('Filter should be type of function, but got ' +\n typeof filter +\n ' instead. Please check correct filters');\n continue;\n }\n filter.call(this, imageData);\n filterContext.putImageData(imageData, 0, 0);\n }\n }\n catch (e) {\n Util_1.Util.error('Unable to apply filter. ' +\n e.message +\n ' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.');\n }\n this._filterUpToDate = true;\n }\n return filterCanvas;\n }\n return sceneCanvas;\n }\n on(evtStr, handler) {\n this._cache && this._cache.delete(ALL_LISTENERS);\n if (arguments.length === 3) {\n return this._delegate.apply(this, arguments);\n }\n var events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;\n for (n = 0; n < len; n++) {\n event = events[n];\n parts = event.split('.');\n baseEvent = parts[0];\n name = parts[1] || '';\n if (!this.eventListeners[baseEvent]) {\n this.eventListeners[baseEvent] = [];\n }\n this.eventListeners[baseEvent].push({\n name: name,\n handler: handler,\n });\n }\n return this;\n }\n off(evtStr, callback) {\n var events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;\n this._cache && this._cache.delete(ALL_LISTENERS);\n if (!evtStr) {\n for (t in this.eventListeners) {\n this._off(t);\n }\n }\n for (n = 0; n < len; n++) {\n event = events[n];\n parts = event.split('.');\n baseEvent = parts[0];\n name = parts[1];\n if (baseEvent) {\n if (this.eventListeners[baseEvent]) {\n this._off(baseEvent, name, callback);\n }\n }\n else {\n for (t in this.eventListeners) {\n this._off(t, name, callback);\n }\n }\n }\n return this;\n }\n dispatchEvent(evt) {\n var e = {\n target: this,\n type: evt.type,\n evt: evt,\n };\n this.fire(evt.type, e);\n return this;\n }\n addEventListener(type, handler) {\n this.on(type, function (evt) {\n handler.call(this, evt.evt);\n });\n return this;\n }\n removeEventListener(type) {\n this.off(type);\n return this;\n }\n _delegate(event, selector, handler) {\n var stopNode = this;\n this.on(event, function (evt) {\n var targets = evt.target.findAncestors(selector, true, stopNode);\n for (var i = 0; i < targets.length; i++) {\n evt = Util_1.Util.cloneObject(evt);\n evt.currentTarget = targets[i];\n handler.call(targets[i], evt);\n }\n });\n }\n remove() {\n if (this.isDragging()) {\n this.stopDrag();\n }\n DragAndDrop_1.DD._dragElements.delete(this._id);\n this._remove();\n return this;\n }\n _clearCaches() {\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);\n this._clearSelfAndDescendantCache(STAGE);\n this._clearSelfAndDescendantCache(VISIBLE);\n this._clearSelfAndDescendantCache(LISTENING);\n }\n _remove() {\n this._clearCaches();\n var parent = this.getParent();\n if (parent && parent.children) {\n parent.children.splice(this.index, 1);\n parent._setChildrenIndices();\n this.parent = null;\n }\n }\n destroy() {\n this.remove();\n this.clearCache();\n return this;\n }\n getAttr(attr) {\n var method = 'get' + Util_1.Util._capitalize(attr);\n if (Util_1.Util._isFunction(this[method])) {\n return this[method]();\n }\n return this.attrs[attr];\n }\n getAncestors() {\n var parent = this.getParent(), ancestors = [];\n while (parent) {\n ancestors.push(parent);\n parent = parent.getParent();\n }\n return ancestors;\n }\n getAttrs() {\n return (this.attrs || {});\n }\n setAttrs(config) {\n this._batchTransformChanges(() => {\n var key, method;\n if (!config) {\n return this;\n }\n for (key in config) {\n if (key === CHILDREN) {\n continue;\n }\n method = SET + Util_1.Util._capitalize(key);\n if (Util_1.Util._isFunction(this[method])) {\n this[method](config[key]);\n }\n else {\n this._setAttr(key, config[key]);\n }\n }\n });\n return this;\n }\n isListening() {\n return this._getCache(LISTENING, this._isListening);\n }\n _isListening(relativeTo) {\n const listening = this.listening();\n if (!listening) {\n return false;\n }\n const parent = this.getParent();\n if (parent && parent !== relativeTo && this !== relativeTo) {\n return parent._isListening(relativeTo);\n }\n else {\n return true;\n }\n }\n isVisible() {\n return this._getCache(VISIBLE, this._isVisible);\n }\n _isVisible(relativeTo) {\n const visible = this.visible();\n if (!visible) {\n return false;\n }\n const parent = this.getParent();\n if (parent && parent !== relativeTo && this !== relativeTo) {\n return parent._isVisible(relativeTo);\n }\n else {\n return true;\n }\n }\n shouldDrawHit(top, skipDragCheck = false) {\n if (top) {\n return this._isVisible(top) && this._isListening(top);\n }\n var layer = this.getLayer();\n var layerUnderDrag = false;\n DragAndDrop_1.DD._dragElements.forEach((elem) => {\n if (elem.dragStatus !== 'dragging') {\n return;\n }\n else if (elem.node.nodeType === 'Stage') {\n layerUnderDrag = true;\n }\n else if (elem.node.getLayer() === layer) {\n layerUnderDrag = true;\n }\n });\n var dragSkip = !skipDragCheck &&\n !Global_1.Konva.hitOnDragEnabled &&\n (layerUnderDrag || Global_1.Konva.isTransforming());\n return this.isListening() && this.isVisible() && !dragSkip;\n }\n show() {\n this.visible(true);\n return this;\n }\n hide() {\n this.visible(false);\n return this;\n }\n getZIndex() {\n return this.index || 0;\n }\n getAbsoluteZIndex() {\n var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;\n function addChildren(children) {\n nodes = [];\n len = children.length;\n for (n = 0; n < len; n++) {\n child = children[n];\n index++;\n if (child.nodeType !== SHAPE) {\n nodes = nodes.concat(child.getChildren().slice());\n }\n if (child._id === that._id) {\n n = len;\n }\n }\n if (nodes.length > 0 && nodes[0].getDepth() <= depth) {\n addChildren(nodes);\n }\n }\n const stage = this.getStage();\n if (that.nodeType !== UPPER_STAGE && stage) {\n addChildren(stage.getChildren());\n }\n return index;\n }\n getDepth() {\n var depth = 0, parent = this.parent;\n while (parent) {\n depth++;\n parent = parent.parent;\n }\n return depth;\n }\n _batchTransformChanges(func) {\n this._batchingTransformChange = true;\n func();\n this._batchingTransformChange = false;\n if (this._needClearTransformCache) {\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n }\n this._needClearTransformCache = false;\n }\n setPosition(pos) {\n this._batchTransformChanges(() => {\n this.x(pos.x);\n this.y(pos.y);\n });\n return this;\n }\n getPosition() {\n return {\n x: this.x(),\n y: this.y(),\n };\n }\n getRelativePointerPosition() {\n const stage = this.getStage();\n if (!stage) {\n return null;\n }\n var pos = stage.getPointerPosition();\n if (!pos) {\n return null;\n }\n var transform = this.getAbsoluteTransform().copy();\n transform.invert();\n return transform.point(pos);\n }\n getAbsolutePosition(top) {\n let haveCachedParent = false;\n let parent = this.parent;\n while (parent) {\n if (parent.isCached()) {\n haveCachedParent = true;\n break;\n }\n parent = parent.parent;\n }\n if (haveCachedParent && !top) {\n top = true;\n }\n var absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();\n absoluteTransform.m = absoluteMatrix.slice();\n absoluteTransform.translate(offset.x, offset.y);\n return absoluteTransform.getTranslation();\n }\n setAbsolutePosition(pos) {\n const { x, y, ...origTrans } = this._clearTransform();\n this.attrs.x = x;\n this.attrs.y = y;\n this._clearCache(TRANSFORM);\n var it = this._getAbsoluteTransform().copy();\n it.invert();\n it.translate(pos.x, pos.y);\n pos = {\n x: this.attrs.x + it.getTranslation().x,\n y: this.attrs.y + it.getTranslation().y,\n };\n this._setTransform(origTrans);\n this.setPosition({ x: pos.x, y: pos.y });\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n return this;\n }\n _setTransform(trans) {\n var key;\n for (key in trans) {\n this.attrs[key] = trans[key];\n }\n }\n _clearTransform() {\n var trans = {\n x: this.x(),\n y: this.y(),\n rotation: this.rotation(),\n scaleX: this.scaleX(),\n scaleY: this.scaleY(),\n offsetX: this.offsetX(),\n offsetY: this.offsetY(),\n skewX: this.skewX(),\n skewY: this.skewY(),\n };\n this.attrs.x = 0;\n this.attrs.y = 0;\n this.attrs.rotation = 0;\n this.attrs.scaleX = 1;\n this.attrs.scaleY = 1;\n this.attrs.offsetX = 0;\n this.attrs.offsetY = 0;\n this.attrs.skewX = 0;\n this.attrs.skewY = 0;\n return trans;\n }\n move(change) {\n var changeX = change.x, changeY = change.y, x = this.x(), y = this.y();\n if (changeX !== undefined) {\n x += changeX;\n }\n if (changeY !== undefined) {\n y += changeY;\n }\n this.setPosition({ x: x, y: y });\n return this;\n }\n _eachAncestorReverse(func, top) {\n var family = [], parent = this.getParent(), len, n;\n if (top && top._id === this._id) {\n return;\n }\n family.unshift(this);\n while (parent && (!top || parent._id !== top._id)) {\n family.unshift(parent);\n parent = parent.parent;\n }\n len = family.length;\n for (n = 0; n < len; n++) {\n func(family[n]);\n }\n }\n rotate(theta) {\n this.rotation(this.rotation() + theta);\n return this;\n }\n moveToTop() {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveToTop function is ignored.');\n return false;\n }\n var index = this.index, len = this.parent.getChildren().length;\n if (index < len - 1) {\n this.parent.children.splice(index, 1);\n this.parent.children.push(this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n moveUp() {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveUp function is ignored.');\n return false;\n }\n var index = this.index, len = this.parent.getChildren().length;\n if (index < len - 1) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index + 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n moveDown() {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveDown function is ignored.');\n return false;\n }\n var index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.splice(index - 1, 0, this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n moveToBottom() {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. moveToBottom function is ignored.');\n return false;\n }\n var index = this.index;\n if (index > 0) {\n this.parent.children.splice(index, 1);\n this.parent.children.unshift(this);\n this.parent._setChildrenIndices();\n return true;\n }\n return false;\n }\n setZIndex(zIndex) {\n if (!this.parent) {\n Util_1.Util.warn('Node has no parent. zIndex parameter is ignored.');\n return this;\n }\n if (zIndex < 0 || zIndex >= this.parent.children.length) {\n Util_1.Util.warn('Unexpected value ' +\n zIndex +\n ' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' +\n (this.parent.children.length - 1) +\n '.');\n }\n var index = this.index;\n this.parent.children.splice(index, 1);\n this.parent.children.splice(zIndex, 0, this);\n this.parent._setChildrenIndices();\n return this;\n }\n getAbsoluteOpacity() {\n return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);\n }\n _getAbsoluteOpacity() {\n var absOpacity = this.opacity();\n var parent = this.getParent();\n if (parent && !parent._isUnderCache) {\n absOpacity *= parent.getAbsoluteOpacity();\n }\n return absOpacity;\n }\n moveTo(newContainer) {\n if (this.getParent() !== newContainer) {\n this._remove();\n newContainer.add(this);\n }\n return this;\n }\n toObject() {\n var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;\n const obj = {\n attrs: {},\n className: this.getClassName(),\n };\n for (key in attrs) {\n val = attrs[key];\n nonPlainObject =\n Util_1.Util.isObject(val) && !Util_1.Util._isPlainObject(val) && !Util_1.Util._isArray(val);\n if (nonPlainObject) {\n continue;\n }\n getter = typeof this[key] === 'function' && this[key];\n delete attrs[key];\n defaultValue = getter ? getter.call(this) : null;\n attrs[key] = val;\n if (defaultValue !== val) {\n obj.attrs[key] = val;\n }\n }\n return Util_1.Util._prepareToStringify(obj);\n }\n toJSON() {\n return JSON.stringify(this.toObject());\n }\n getParent() {\n return this.parent;\n }\n findAncestors(selector, includeSelf, stopNode) {\n var res = [];\n if (includeSelf && this._isMatch(selector)) {\n res.push(this);\n }\n var ancestor = this.parent;\n while (ancestor) {\n if (ancestor === stopNode) {\n return res;\n }\n if (ancestor._isMatch(selector)) {\n res.push(ancestor);\n }\n ancestor = ancestor.parent;\n }\n return res;\n }\n isAncestorOf(node) {\n return false;\n }\n findAncestor(selector, includeSelf, stopNode) {\n return this.findAncestors(selector, includeSelf, stopNode)[0];\n }\n _isMatch(selector) {\n if (!selector) {\n return false;\n }\n if (typeof selector === 'function') {\n return selector(this);\n }\n var selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;\n for (n = 0; n < len; n++) {\n sel = selectorArr[n];\n if (!Util_1.Util.isValidSelector(sel)) {\n Util_1.Util.warn('Selector \"' +\n sel +\n '\" is invalid. Allowed selectors examples are \"#foo\", \".bar\" or \"Group\".');\n Util_1.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like \"Triangle\".');\n Util_1.Util.warn('Konva is awesome, right?');\n }\n if (sel.charAt(0) === '#') {\n if (this.id() === sel.slice(1)) {\n return true;\n }\n }\n else if (sel.charAt(0) === '.') {\n if (this.hasName(sel.slice(1))) {\n return true;\n }\n }\n else if (this.className === sel || this.nodeType === sel) {\n return true;\n }\n }\n return false;\n }\n getLayer() {\n var parent = this.getParent();\n return parent ? parent.getLayer() : null;\n }\n getStage() {\n return this._getCache(STAGE, this._getStage);\n }\n _getStage() {\n var parent = this.getParent();\n if (parent) {\n return parent.getStage();\n }\n else {\n return null;\n }\n }\n fire(eventType, evt = {}, bubble) {\n evt.target = evt.target || this;\n if (bubble) {\n this._fireAndBubble(eventType, evt);\n }\n else {\n this._fire(eventType, evt);\n }\n return this;\n }\n getAbsoluteTransform(top) {\n if (top) {\n return this._getAbsoluteTransform(top);\n }\n else {\n return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);\n }\n }\n _getAbsoluteTransform(top) {\n var at;\n if (top) {\n at = new Util_1.Transform();\n this._eachAncestorReverse(function (node) {\n var transformsEnabled = node.transformsEnabled();\n if (transformsEnabled === 'all') {\n at.multiply(node.getTransform());\n }\n else if (transformsEnabled === 'position') {\n at.translate(node.x() - node.offsetX(), node.y() - node.offsetY());\n }\n }, top);\n return at;\n }\n else {\n at = this._cache.get(ABSOLUTE_TRANSFORM) || new Util_1.Transform();\n if (this.parent) {\n this.parent.getAbsoluteTransform().copyInto(at);\n }\n else {\n at.reset();\n }\n var transformsEnabled = this.transformsEnabled();\n if (transformsEnabled === 'all') {\n at.multiply(this.getTransform());\n }\n else if (transformsEnabled === 'position') {\n const x = this.attrs.x || 0;\n const y = this.attrs.y || 0;\n const offsetX = this.attrs.offsetX || 0;\n const offsetY = this.attrs.offsetY || 0;\n at.translate(x - offsetX, y - offsetY);\n }\n at.dirty = false;\n return at;\n }\n }\n getAbsoluteScale(top) {\n var parent = this;\n while (parent) {\n if (parent._isUnderCache) {\n top = parent;\n }\n parent = parent.getParent();\n }\n const transform = this.getAbsoluteTransform(top);\n const attrs = transform.decompose();\n return {\n x: attrs.scaleX,\n y: attrs.scaleY,\n };\n }\n getAbsoluteRotation() {\n return this.getAbsoluteTransform().decompose().rotation;\n }\n getTransform() {\n return this._getCache(TRANSFORM, this._getTransform);\n }\n _getTransform() {\n var _a, _b;\n var m = this._cache.get(TRANSFORM) || new Util_1.Transform();\n m.reset();\n var x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;\n if (x !== 0 || y !== 0) {\n m.translate(x, y);\n }\n if (rotation !== 0) {\n m.rotate(rotation);\n }\n if (skewX !== 0 || skewY !== 0) {\n m.skew(skewX, skewY);\n }\n if (scaleX !== 1 || scaleY !== 1) {\n m.scale(scaleX, scaleY);\n }\n if (offsetX !== 0 || offsetY !== 0) {\n m.translate(-1 * offsetX, -1 * offsetY);\n }\n m.dirty = false;\n return m;\n }\n clone(obj) {\n var attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;\n for (key in obj) {\n attrs[key] = obj[key];\n }\n var node = new this.constructor(attrs);\n for (key in this.eventListeners) {\n allListeners = this.eventListeners[key];\n len = allListeners.length;\n for (n = 0; n < len; n++) {\n listener = allListeners[n];\n if (listener.name.indexOf(KONVA) < 0) {\n if (!node.eventListeners[key]) {\n node.eventListeners[key] = [];\n }\n node.eventListeners[key].push(listener);\n }\n }\n }\n return node;\n }\n _toKonvaCanvas(config) {\n config = config || {};\n var box = this.getClientRect();\n var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({\n width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),\n height: config.height ||\n Math.ceil(box.height) ||\n (stage ? stage.height() : 0),\n pixelRatio: pixelRatio,\n }), context = canvas.getContext();\n const bufferCanvas = new Canvas_1.SceneCanvas({\n width: canvas.width / canvas.pixelRatio + Math.abs(x),\n height: canvas.height / canvas.pixelRatio + Math.abs(y),\n pixelRatio: canvas.pixelRatio,\n });\n if (config.imageSmoothingEnabled === false) {\n context._context.imageSmoothingEnabled = false;\n }\n context.save();\n if (x || y) {\n context.translate(-1 * x, -1 * y);\n }\n this.drawScene(canvas, undefined, bufferCanvas);\n context.restore();\n return canvas;\n }\n toCanvas(config) {\n return this._toKonvaCanvas(config)._canvas;\n }\n toDataURL(config) {\n config = config || {};\n var mimeType = config.mimeType || null, quality = config.quality || null;\n var url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);\n if (config.callback) {\n config.callback(url);\n }\n return url;\n }\n toImage(config) {\n return new Promise((resolve, reject) => {\n try {\n const callback = config === null || config === void 0 ? void 0 : config.callback;\n if (callback)\n delete config.callback;\n Util_1.Util._urlToImage(this.toDataURL(config), function (img) {\n resolve(img);\n callback === null || callback === void 0 ? void 0 : callback(img);\n });\n }\n catch (err) {\n reject(err);\n }\n });\n }\n toBlob(config) {\n return new Promise((resolve, reject) => {\n try {\n const callback = config === null || config === void 0 ? void 0 : config.callback;\n if (callback)\n delete config.callback;\n this.toCanvas(config).toBlob((blob) => {\n resolve(blob);\n callback === null || callback === void 0 ? void 0 : callback(blob);\n }, config === null || config === void 0 ? void 0 : config.mimeType, config === null || config === void 0 ? void 0 : config.quality);\n }\n catch (err) {\n reject(err);\n }\n });\n }\n setSize(size) {\n this.width(size.width);\n this.height(size.height);\n return this;\n }\n getSize() {\n return {\n width: this.width(),\n height: this.height(),\n };\n }\n getClassName() {\n return this.className || this.nodeType;\n }\n getType() {\n return this.nodeType;\n }\n getDragDistance() {\n if (this.attrs.dragDistance !== undefined) {\n return this.attrs.dragDistance;\n }\n else if (this.parent) {\n return this.parent.getDragDistance();\n }\n else {\n return Global_1.Konva.dragDistance;\n }\n }\n _off(type, name, callback) {\n var evtListeners = this.eventListeners[type], i, evtName, handler;\n for (i = 0; i < evtListeners.length; i++) {\n evtName = evtListeners[i].name;\n handler = evtListeners[i].handler;\n if ((evtName !== 'konva' || name === 'konva') &&\n (!name || evtName === name) &&\n (!callback || callback === handler)) {\n evtListeners.splice(i, 1);\n if (evtListeners.length === 0) {\n delete this.eventListeners[type];\n break;\n }\n i--;\n }\n }\n }\n _fireChangeEvent(attr, oldVal, newVal) {\n this._fire(attr + CHANGE, {\n oldVal: oldVal,\n newVal: newVal,\n });\n }\n addName(name) {\n if (!this.hasName(name)) {\n var oldName = this.name();\n var newName = oldName ? oldName + ' ' + name : name;\n this.name(newName);\n }\n return this;\n }\n hasName(name) {\n if (!name) {\n return false;\n }\n const fullName = this.name();\n if (!fullName) {\n return false;\n }\n var names = (fullName || '').split(/\\s/g);\n return names.indexOf(name) !== -1;\n }\n removeName(name) {\n var names = (this.name() || '').split(/\\s/g);\n var index = names.indexOf(name);\n if (index !== -1) {\n names.splice(index, 1);\n this.name(names.join(' '));\n }\n return this;\n }\n setAttr(attr, val) {\n var func = this[SET + Util_1.Util._capitalize(attr)];\n if (Util_1.Util._isFunction(func)) {\n func.call(this, val);\n }\n else {\n this._setAttr(attr, val);\n }\n return this;\n }\n _requestDraw() {\n if (Global_1.Konva.autoDrawEnabled) {\n const drawNode = this.getLayer() || this.getStage();\n drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();\n }\n }\n _setAttr(key, val) {\n var oldVal = this.attrs[key];\n if (oldVal === val && !Util_1.Util.isObject(val)) {\n return;\n }\n if (val === undefined || val === null) {\n delete this.attrs[key];\n }\n else {\n this.attrs[key] = val;\n }\n if (this._shouldFireChangeEvents) {\n this._fireChangeEvent(key, oldVal, val);\n }\n this._requestDraw();\n }\n _setComponentAttr(key, component, val) {\n var oldVal;\n if (val !== undefined) {\n oldVal = this.attrs[key];\n if (!oldVal) {\n this.attrs[key] = this.getAttr(key);\n }\n this.attrs[key][component] = val;\n this._fireChangeEvent(key, oldVal, val);\n }\n }\n _fireAndBubble(eventType, evt, compareShape) {\n if (evt && this.nodeType === SHAPE) {\n evt.target = this;\n }\n var shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&\n ((compareShape &&\n (this === compareShape ||\n (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||\n (this.nodeType === 'Stage' && !compareShape));\n if (!shouldStop) {\n this._fire(eventType, evt);\n var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&\n compareShape &&\n compareShape.isAncestorOf &&\n compareShape.isAncestorOf(this) &&\n !compareShape.isAncestorOf(this.parent);\n if (((evt && !evt.cancelBubble) || !evt) &&\n this.parent &&\n this.parent.isListening() &&\n !stopBubble) {\n if (compareShape && compareShape.parent) {\n this._fireAndBubble.call(this.parent, eventType, evt, compareShape);\n }\n else {\n this._fireAndBubble.call(this.parent, eventType, evt);\n }\n }\n }\n }\n _getProtoListeners(eventType) {\n var _a, _b, _c;\n const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== void 0 ? _a : {};\n let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];\n if (events === undefined) {\n events = [];\n let obj = Object.getPrototypeOf(this);\n while (obj) {\n const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === void 0 ? void 0 : _b[eventType]) !== null && _c !== void 0 ? _c : [];\n events.push(...hierarchyEvents);\n obj = Object.getPrototypeOf(obj);\n }\n allListeners[eventType] = events;\n this._cache.set(ALL_LISTENERS, allListeners);\n }\n return events;\n }\n _fire(eventType, evt) {\n evt = evt || {};\n evt.currentTarget = this;\n evt.type = eventType;\n const topListeners = this._getProtoListeners(eventType);\n if (topListeners) {\n for (var i = 0; i < topListeners.length; i++) {\n topListeners[i].handler.call(this, evt);\n }\n }\n const selfListeners = this.eventListeners[eventType];\n if (selfListeners) {\n for (var i = 0; i < selfListeners.length; i++) {\n selfListeners[i].handler.call(this, evt);\n }\n }\n }\n draw() {\n this.drawScene();\n this.drawHit();\n return this;\n }\n _createDragElement(evt) {\n var pointerId = evt ? evt.pointerId : undefined;\n var stage = this.getStage();\n var ap = this.getAbsolutePosition();\n if (!stage) {\n return;\n }\n var pos = stage._getPointerById(pointerId) ||\n stage._changedPointerPositions[0] ||\n ap;\n DragAndDrop_1.DD._dragElements.set(this._id, {\n node: this,\n startPointerPos: pos,\n offset: {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n },\n dragStatus: 'ready',\n pointerId,\n });\n }\n startDrag(evt, bubbleEvent = true) {\n if (!DragAndDrop_1.DD._dragElements.has(this._id)) {\n this._createDragElement(evt);\n }\n const elem = DragAndDrop_1.DD._dragElements.get(this._id);\n elem.dragStatus = 'dragging';\n this.fire('dragstart', {\n type: 'dragstart',\n target: this,\n evt: evt && evt.evt,\n }, bubbleEvent);\n }\n _setDragPosition(evt, elem) {\n const pos = this.getStage()._getPointerById(elem.pointerId);\n if (!pos) {\n return;\n }\n var newNodePos = {\n x: pos.x - elem.offset.x,\n y: pos.y - elem.offset.y,\n };\n var dbf = this.dragBoundFunc();\n if (dbf !== undefined) {\n const bounded = dbf.call(this, newNodePos, evt);\n if (!bounded) {\n Util_1.Util.warn('dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.');\n }\n else {\n newNodePos = bounded;\n }\n }\n if (!this._lastPos ||\n this._lastPos.x !== newNodePos.x ||\n this._lastPos.y !== newNodePos.y) {\n this.setAbsolutePosition(newNodePos);\n this._requestDraw();\n }\n this._lastPos = newNodePos;\n }\n stopDrag(evt) {\n const elem = DragAndDrop_1.DD._dragElements.get(this._id);\n if (elem) {\n elem.dragStatus = 'stopped';\n }\n DragAndDrop_1.DD._endDragBefore(evt);\n DragAndDrop_1.DD._endDragAfter(evt);\n }\n setDraggable(draggable) {\n this._setAttr('draggable', draggable);\n this._dragChange();\n }\n isDragging() {\n const elem = DragAndDrop_1.DD._dragElements.get(this._id);\n return elem ? elem.dragStatus === 'dragging' : false;\n }\n _listenDrag() {\n this._dragCleanup();\n this.on('mousedown.konva touchstart.konva', function (evt) {\n var shouldCheckButton = evt.evt['button'] !== undefined;\n var canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;\n if (!canDrag) {\n return;\n }\n if (this.isDragging()) {\n return;\n }\n var hasDraggingChild = false;\n DragAndDrop_1.DD._dragElements.forEach((elem) => {\n if (this.isAncestorOf(elem.node)) {\n hasDraggingChild = true;\n }\n });\n if (!hasDraggingChild) {\n this._createDragElement(evt);\n }\n });\n }\n _dragChange() {\n if (this.attrs.draggable) {\n this._listenDrag();\n }\n else {\n this._dragCleanup();\n var stage = this.getStage();\n if (!stage) {\n return;\n }\n const dragElement = DragAndDrop_1.DD._dragElements.get(this._id);\n const isDragging = dragElement && dragElement.dragStatus === 'dragging';\n const isReady = dragElement && dragElement.dragStatus === 'ready';\n if (isDragging) {\n this.stopDrag();\n }\n else if (isReady) {\n DragAndDrop_1.DD._dragElements.delete(this._id);\n }\n }\n }\n _dragCleanup() {\n this.off('mousedown.konva');\n this.off('touchstart.konva');\n }\n isClientRectOnScreen(margin = { x: 0, y: 0 }) {\n const stage = this.getStage();\n if (!stage) {\n return false;\n }\n const screenRect = {\n x: -margin.x,\n y: -margin.y,\n width: stage.width() + 2 * margin.x,\n height: stage.height() + 2 * margin.y,\n };\n return Util_1.Util.haveIntersection(screenRect, this.getClientRect());\n }\n static create(data, container) {\n if (Util_1.Util._isString(data)) {\n data = JSON.parse(data);\n }\n return this._createNode(data, container);\n }\n static _createNode(obj, container) {\n var className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;\n if (container) {\n obj.attrs.container = container;\n }\n if (!Global_1.Konva[className]) {\n Util_1.Util.warn('Can not find a node with class name \"' +\n className +\n '\". Fallback to \"Shape\".');\n className = 'Shape';\n }\n const Class = Global_1.Konva[className];\n no = new Class(obj.attrs);\n if (children) {\n len = children.length;\n for (n = 0; n < len; n++) {\n no.add(Node._createNode(children[n]));\n }\n }\n return no;\n }\n}\nexports.Node = Node;\nNode.prototype.nodeType = 'Node';\nNode.prototype._attrsAffectingSize = [];\nNode.prototype.eventListeners = {};\nNode.prototype.on.call(Node.prototype, TRANSFORM_CHANGE_STR, function () {\n if (this._batchingTransformChange) {\n this._needClearTransformCache = true;\n return;\n }\n this._clearCache(TRANSFORM);\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\n});\nNode.prototype.on.call(Node.prototype, 'visibleChange.konva', function () {\n this._clearSelfAndDescendantCache(VISIBLE);\n});\nNode.prototype.on.call(Node.prototype, 'listeningChange.konva', function () {\n this._clearSelfAndDescendantCache(LISTENING);\n});\nNode.prototype.on.call(Node.prototype, 'opacityChange.konva', function () {\n this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);\n});\nconst addGetterSetter = Factory_1.Factory.addGetterSetter;\naddGetterSetter(Node, 'zIndex');\naddGetterSetter(Node, 'absolutePosition');\naddGetterSetter(Node, 'position');\naddGetterSetter(Node, 'x', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'y', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'globalCompositeOperation', 'source-over', (0, Validators_1.getStringValidator)());\naddGetterSetter(Node, 'opacity', 1, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'name', '', (0, Validators_1.getStringValidator)());\naddGetterSetter(Node, 'id', '', (0, Validators_1.getStringValidator)());\naddGetterSetter(Node, 'rotation', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'scale', ['x', 'y']);\naddGetterSetter(Node, 'scaleX', 1, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'scaleY', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'skew', ['x', 'y']);\naddGetterSetter(Node, 'skewX', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'skewY', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Node, 'offset', ['x', 'y']);\naddGetterSetter(Node, 'offsetX', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'offsetY', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'dragDistance', null, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'width', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'height', 0, (0, Validators_1.getNumberValidator)());\naddGetterSetter(Node, 'listening', true, (0, Validators_1.getBooleanValidator)());\naddGetterSetter(Node, 'preventDefault', true, (0, Validators_1.getBooleanValidator)());\naddGetterSetter(Node, 'filters', null, function (val) {\n this._filterUpToDate = false;\n return val;\n});\naddGetterSetter(Node, 'visible', true, (0, Validators_1.getBooleanValidator)());\naddGetterSetter(Node, 'transformsEnabled', 'all', (0, Validators_1.getStringValidator)());\naddGetterSetter(Node, 'size');\naddGetterSetter(Node, 'dragBoundFunc');\naddGetterSetter(Node, 'draggable', false, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.backCompat(Node, {\n rotateDeg: 'rotate',\n setRotationDeg: 'setRotation',\n getRotationDeg: 'getRotation',\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Container = void 0;\nconst Factory_1 = require(\"./Factory\");\nconst Node_1 = require(\"./Node\");\nconst Validators_1 = require(\"./Validators\");\nclass Container extends Node_1.Node {\n constructor() {\n super(...arguments);\n this.children = [];\n }\n getChildren(filterFunc) {\n if (!filterFunc) {\n return this.children || [];\n }\n const children = this.children || [];\n var results = [];\n children.forEach(function (child) {\n if (filterFunc(child)) {\n results.push(child);\n }\n });\n return results;\n }\n hasChildren() {\n return this.getChildren().length > 0;\n }\n removeChildren() {\n this.getChildren().forEach((child) => {\n child.parent = null;\n child.index = 0;\n child.remove();\n });\n this.children = [];\n this._requestDraw();\n return this;\n }\n destroyChildren() {\n this.getChildren().forEach((child) => {\n child.parent = null;\n child.index = 0;\n child.destroy();\n });\n this.children = [];\n this._requestDraw();\n return this;\n }\n add(...children) {\n if (children.length === 0) {\n return this;\n }\n if (children.length > 1) {\n for (var i = 0; i < children.length; i++) {\n this.add(children[i]);\n }\n return this;\n }\n const child = children[0];\n if (child.getParent()) {\n child.moveTo(this);\n return this;\n }\n this._validateAdd(child);\n child.index = this.getChildren().length;\n child.parent = this;\n child._clearCaches();\n this.getChildren().push(child);\n this._fire('add', {\n child: child,\n });\n this._requestDraw();\n return this;\n }\n destroy() {\n if (this.hasChildren()) {\n this.destroyChildren();\n }\n super.destroy();\n return this;\n }\n find(selector) {\n return this._generalFind(selector, false);\n }\n findOne(selector) {\n var result = this._generalFind(selector, true);\n return result.length > 0 ? result[0] : undefined;\n }\n _generalFind(selector, findOne) {\n var retArr = [];\n this._descendants((node) => {\n const valid = node._isMatch(selector);\n if (valid) {\n retArr.push(node);\n }\n if (valid && findOne) {\n return true;\n }\n return false;\n });\n return retArr;\n }\n _descendants(fn) {\n let shouldStop = false;\n const children = this.getChildren();\n for (const child of children) {\n shouldStop = fn(child);\n if (shouldStop) {\n return true;\n }\n if (!child.hasChildren()) {\n continue;\n }\n shouldStop = child._descendants(fn);\n if (shouldStop) {\n return true;\n }\n }\n return false;\n }\n toObject() {\n var obj = Node_1.Node.prototype.toObject.call(this);\n obj.children = [];\n this.getChildren().forEach((child) => {\n obj.children.push(child.toObject());\n });\n return obj;\n }\n isAncestorOf(node) {\n var parent = node.getParent();\n while (parent) {\n if (parent._id === this._id) {\n return true;\n }\n parent = parent.getParent();\n }\n return false;\n }\n clone(obj) {\n var node = Node_1.Node.prototype.clone.call(this, obj);\n this.getChildren().forEach(function (no) {\n node.add(no.clone());\n });\n return node;\n }\n getAllIntersections(pos) {\n var arr = [];\n this.find('Shape').forEach((shape) => {\n if (shape.isVisible() && shape.intersects(pos)) {\n arr.push(shape);\n }\n });\n return arr;\n }\n _clearSelfAndDescendantCache(attr) {\n var _a;\n super._clearSelfAndDescendantCache(attr);\n if (this.isCached()) {\n return;\n }\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {\n node._clearSelfAndDescendantCache(attr);\n });\n }\n _setChildrenIndices() {\n var _a;\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {\n child.index = n;\n });\n this._requestDraw();\n }\n drawScene(can, top, bufferCanvas) {\n var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;\n var caching = canvas && canvas.isCache;\n if (!this.isVisible() && !caching) {\n return this;\n }\n if (cachedSceneCanvas) {\n context.save();\n var m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedSceneCanvas(context);\n context.restore();\n }\n else {\n this._drawChildren('drawScene', canvas, top, bufferCanvas);\n }\n return this;\n }\n drawHit(can, top) {\n if (!this.shouldDrawHit(top)) {\n return this;\n }\n var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;\n if (cachedHitCanvas) {\n context.save();\n var m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedHitCanvas(context);\n context.restore();\n }\n else {\n this._drawChildren('drawHit', canvas, top);\n }\n return this;\n }\n _drawChildren(drawMethod, canvas, top, bufferCanvas) {\n var _a;\n var context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (typeof clipWidth === 'number' && typeof clipHeight === 'number') ||\n clipFunc;\n const selfCache = top === this;\n if (hasClip) {\n context.save();\n var transform = this.getAbsoluteTransform(top);\n var m = transform.getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n context.beginPath();\n let clipArgs;\n if (clipFunc) {\n clipArgs = clipFunc.call(this, context, this);\n }\n else {\n var clipX = this.clipX();\n var clipY = this.clipY();\n context.rect(clipX || 0, clipY || 0, clipWidth, clipHeight);\n }\n context.clip.apply(context, clipArgs);\n m = transform.copy().invert().getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n var hasComposition = !selfCache &&\n this.globalCompositeOperation() !== 'source-over' &&\n drawMethod === 'drawScene';\n if (hasComposition) {\n context.save();\n context._applyGlobalCompositeOperation(this);\n }\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {\n child[drawMethod](canvas, top, bufferCanvas);\n });\n if (hasComposition) {\n context.restore();\n }\n if (hasClip) {\n context.restore();\n }\n }\n getClientRect(config = {}) {\n var _a;\n var skipTransform = config.skipTransform;\n var relativeTo = config.relativeTo;\n var minX, minY, maxX, maxY;\n var selfRect = {\n x: Infinity,\n y: Infinity,\n width: 0,\n height: 0,\n };\n var that = this;\n (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {\n if (!child.visible()) {\n return;\n }\n var rect = child.getClientRect({\n relativeTo: that,\n skipShadow: config.skipShadow,\n skipStroke: config.skipStroke,\n });\n if (rect.width === 0 && rect.height === 0) {\n return;\n }\n if (minX === undefined) {\n minX = rect.x;\n minY = rect.y;\n maxX = rect.x + rect.width;\n maxY = rect.y + rect.height;\n }\n else {\n minX = Math.min(minX, rect.x);\n minY = Math.min(minY, rect.y);\n maxX = Math.max(maxX, rect.x + rect.width);\n maxY = Math.max(maxY, rect.y + rect.height);\n }\n });\n var shapes = this.find('Shape');\n var hasVisible = false;\n for (var i = 0; i < shapes.length; i++) {\n var shape = shapes[i];\n if (shape._isVisible(this)) {\n hasVisible = true;\n break;\n }\n }\n if (hasVisible && minX !== undefined) {\n selfRect = {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n else {\n selfRect = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n if (!skipTransform) {\n return this._transformedRect(selfRect, relativeTo);\n }\n return selfRect;\n }\n}\nexports.Container = Container;\nFactory_1.Factory.addComponentsGetterSetter(Container, 'clip', [\n 'x',\n 'y',\n 'width',\n 'height',\n]);\nFactory_1.Factory.addGetterSetter(Container, 'clipX', undefined, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Container, 'clipY', undefined, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Container, 'clipWidth', undefined, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Container, 'clipHeight', undefined, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Container, 'clipFunc');\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.releaseCapture = exports.setPointerCapture = exports.hasPointerCapture = exports.createEvent = exports.getCapturedShape = void 0;\nconst Global_1 = require(\"./Global\");\nconst Captures = new Map();\nconst SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;\nfunction getCapturedShape(pointerId) {\n return Captures.get(pointerId);\n}\nexports.getCapturedShape = getCapturedShape;\nfunction createEvent(evt) {\n return {\n evt,\n pointerId: evt.pointerId,\n };\n}\nexports.createEvent = createEvent;\nfunction hasPointerCapture(pointerId, shape) {\n return Captures.get(pointerId) === shape;\n}\nexports.hasPointerCapture = hasPointerCapture;\nfunction setPointerCapture(pointerId, shape) {\n releaseCapture(pointerId);\n const stage = shape.getStage();\n if (!stage)\n return;\n Captures.set(pointerId, shape);\n if (SUPPORT_POINTER_EVENTS) {\n shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));\n }\n}\nexports.setPointerCapture = setPointerCapture;\nfunction releaseCapture(pointerId, target) {\n const shape = Captures.get(pointerId);\n if (!shape)\n return;\n const stage = shape.getStage();\n if (stage && stage.content) {\n }\n Captures.delete(pointerId);\n if (SUPPORT_POINTER_EVENTS) {\n shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));\n }\n}\nexports.releaseCapture = releaseCapture;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Stage = exports.stages = void 0;\nconst Util_1 = require(\"./Util\");\nconst Factory_1 = require(\"./Factory\");\nconst Container_1 = require(\"./Container\");\nconst Global_1 = require(\"./Global\");\nconst Canvas_1 = require(\"./Canvas\");\nconst DragAndDrop_1 = require(\"./DragAndDrop\");\nconst Global_2 = require(\"./Global\");\nconst PointerEvents = require(\"./PointerEvents\");\nvar STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [\n [MOUSEENTER, '_pointerenter'],\n [MOUSEDOWN, '_pointerdown'],\n [MOUSEMOVE, '_pointermove'],\n [MOUSEUP, '_pointerup'],\n [MOUSELEAVE, '_pointerleave'],\n [TOUCHSTART, '_pointerdown'],\n [TOUCHMOVE, '_pointermove'],\n [TOUCHEND, '_pointerup'],\n [TOUCHCANCEL, '_pointercancel'],\n [MOUSEOVER, '_pointerover'],\n [WHEEL, '_wheel'],\n [CONTEXTMENU, '_contextmenu'],\n [POINTERDOWN, '_pointerdown'],\n [POINTERMOVE, '_pointermove'],\n [POINTERUP, '_pointerup'],\n [POINTERCANCEL, '_pointercancel'],\n [LOSTPOINTERCAPTURE, '_lostpointercapture'],\n];\nconst EVENTS_MAP = {\n mouse: {\n [POINTEROUT]: MOUSEOUT,\n [POINTERLEAVE]: MOUSELEAVE,\n [POINTEROVER]: MOUSEOVER,\n [POINTERENTER]: MOUSEENTER,\n [POINTERMOVE]: MOUSEMOVE,\n [POINTERDOWN]: MOUSEDOWN,\n [POINTERUP]: MOUSEUP,\n [POINTERCANCEL]: 'mousecancel',\n pointerclick: 'click',\n pointerdblclick: 'dblclick',\n },\n touch: {\n [POINTEROUT]: 'touchout',\n [POINTERLEAVE]: 'touchleave',\n [POINTEROVER]: 'touchover',\n [POINTERENTER]: 'touchenter',\n [POINTERMOVE]: TOUCHMOVE,\n [POINTERDOWN]: TOUCHSTART,\n [POINTERUP]: TOUCHEND,\n [POINTERCANCEL]: TOUCHCANCEL,\n pointerclick: 'tap',\n pointerdblclick: 'dbltap',\n },\n pointer: {\n [POINTEROUT]: POINTEROUT,\n [POINTERLEAVE]: POINTERLEAVE,\n [POINTEROVER]: POINTEROVER,\n [POINTERENTER]: POINTERENTER,\n [POINTERMOVE]: POINTERMOVE,\n [POINTERDOWN]: POINTERDOWN,\n [POINTERUP]: POINTERUP,\n [POINTERCANCEL]: POINTERCANCEL,\n pointerclick: 'pointerclick',\n pointerdblclick: 'pointerdblclick',\n },\n};\nconst getEventType = (type) => {\n if (type.indexOf('pointer') >= 0) {\n return 'pointer';\n }\n if (type.indexOf('touch') >= 0) {\n return 'touch';\n }\n return 'mouse';\n};\nconst getEventsMap = (eventType) => {\n const type = getEventType(eventType);\n if (type === 'pointer') {\n return Global_1.Konva.pointerEventsEnabled && EVENTS_MAP.pointer;\n }\n if (type === 'touch') {\n return EVENTS_MAP.touch;\n }\n if (type === 'mouse') {\n return EVENTS_MAP.mouse;\n }\n};\nfunction checkNoClip(attrs = {}) {\n if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {\n Util_1.Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');\n }\n return attrs;\n}\nconst NO_POINTERS_MESSAGE = `Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`;\nexports.stages = [];\nclass Stage extends Container_1.Container {\n constructor(config) {\n super(checkNoClip(config));\n this._pointerPositions = [];\n this._changedPointerPositions = [];\n this._buildDOM();\n this._bindContentEvents();\n exports.stages.push(this);\n this.on('widthChange.konva heightChange.konva', this._resizeDOM);\n this.on('visibleChange.konva', this._checkVisibility);\n this.on('clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva', () => {\n checkNoClip(this.attrs);\n });\n this._checkVisibility();\n }\n _validateAdd(child) {\n const isLayer = child.getType() === 'Layer';\n const isFastLayer = child.getType() === 'FastLayer';\n const valid = isLayer || isFastLayer;\n if (!valid) {\n Util_1.Util.throw('You may only add layers to the stage.');\n }\n }\n _checkVisibility() {\n if (!this.content) {\n return;\n }\n const style = this.visible() ? '' : 'none';\n this.content.style.display = style;\n }\n setContainer(container) {\n if (typeof container === STRING) {\n if (container.charAt(0) === '.') {\n var className = container.slice(1);\n container = document.getElementsByClassName(className)[0];\n }\n else {\n var id;\n if (container.charAt(0) !== '#') {\n id = container;\n }\n else {\n id = container.slice(1);\n }\n container = document.getElementById(id);\n }\n if (!container) {\n throw 'Can not find container in document with id ' + id;\n }\n }\n this._setAttr('container', container);\n if (this.content) {\n if (this.content.parentElement) {\n this.content.parentElement.removeChild(this.content);\n }\n container.appendChild(this.content);\n }\n return this;\n }\n shouldDrawHit() {\n return true;\n }\n clear() {\n var layers = this.children, len = layers.length, n;\n for (n = 0; n < len; n++) {\n layers[n].clear();\n }\n return this;\n }\n clone(obj) {\n if (!obj) {\n obj = {};\n }\n obj.container =\n typeof document !== 'undefined' && document.createElement('div');\n return Container_1.Container.prototype.clone.call(this, obj);\n }\n destroy() {\n super.destroy();\n var content = this.content;\n if (content && Util_1.Util._isInDocument(content)) {\n this.container().removeChild(content);\n }\n var index = exports.stages.indexOf(this);\n if (index > -1) {\n exports.stages.splice(index, 1);\n }\n Util_1.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);\n return this;\n }\n getPointerPosition() {\n const pos = this._pointerPositions[0] || this._changedPointerPositions[0];\n if (!pos) {\n Util_1.Util.warn(NO_POINTERS_MESSAGE);\n return null;\n }\n return {\n x: pos.x,\n y: pos.y,\n };\n }\n _getPointerById(id) {\n return this._pointerPositions.find((p) => p.id === id);\n }\n getPointersPositions() {\n return this._pointerPositions;\n }\n getStage() {\n return this;\n }\n getContent() {\n return this.content;\n }\n _toKonvaCanvas(config) {\n config = config || {};\n config.x = config.x || 0;\n config.y = config.y || 0;\n config.width = config.width || this.width();\n config.height = config.height || this.height();\n var canvas = new Canvas_1.SceneCanvas({\n width: config.width,\n height: config.height,\n pixelRatio: config.pixelRatio || 1,\n });\n var _context = canvas.getContext()._context;\n var layers = this.children;\n if (config.x || config.y) {\n _context.translate(-1 * config.x, -1 * config.y);\n }\n layers.forEach(function (layer) {\n if (!layer.isVisible()) {\n return;\n }\n var layerCanvas = layer._toKonvaCanvas(config);\n _context.drawImage(layerCanvas._canvas, config.x, config.y, layerCanvas.getWidth() / layerCanvas.getPixelRatio(), layerCanvas.getHeight() / layerCanvas.getPixelRatio());\n });\n return canvas;\n }\n getIntersection(pos) {\n if (!pos) {\n return null;\n }\n var layers = this.children, len = layers.length, end = len - 1, n;\n for (n = end; n >= 0; n--) {\n const shape = layers[n].getIntersection(pos);\n if (shape) {\n return shape;\n }\n }\n return null;\n }\n _resizeDOM() {\n var width = this.width();\n var height = this.height();\n if (this.content) {\n this.content.style.width = width + PX;\n this.content.style.height = height + PX;\n }\n this.bufferCanvas.setSize(width, height);\n this.bufferHitCanvas.setSize(width, height);\n this.children.forEach((layer) => {\n layer.setSize({ width, height });\n layer.draw();\n });\n }\n add(layer, ...rest) {\n if (arguments.length > 1) {\n for (var i = 0; i < arguments.length; i++) {\n this.add(arguments[i]);\n }\n return this;\n }\n super.add(layer);\n var length = this.children.length;\n if (length > MAX_LAYERS_NUMBER) {\n Util_1.Util.warn('The stage has ' +\n length +\n ' layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.');\n }\n layer.setSize({ width: this.width(), height: this.height() });\n layer.draw();\n if (Global_1.Konva.isBrowser) {\n this.content.appendChild(layer.canvas._canvas);\n }\n return this;\n }\n getParent() {\n return null;\n }\n getLayer() {\n return null;\n }\n hasPointerCapture(pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n }\n setPointerCapture(pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n }\n releaseCapture(pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n }\n getLayers() {\n return this.children;\n }\n _bindContentEvents() {\n if (!Global_1.Konva.isBrowser) {\n return;\n }\n EVENTS.forEach(([event, methodName]) => {\n this.content.addEventListener(event, (evt) => {\n this[methodName](evt);\n }, { passive: false });\n });\n }\n _pointerenter(evt) {\n this.setPointersPositions(evt);\n const events = getEventsMap(evt.type);\n if (events) {\n this._fire(events.pointerenter, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _pointerover(evt) {\n this.setPointersPositions(evt);\n const events = getEventsMap(evt.type);\n if (events) {\n this._fire(events.pointerover, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _getTargetShape(evenType) {\n let shape = this[evenType + 'targetShape'];\n if (shape && !shape.getStage()) {\n shape = null;\n }\n return shape;\n }\n _pointerleave(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n var targetShape = this._getTargetShape(eventType);\n var eventsEnabled = !(Global_1.Konva.isDragging() || Global_1.Konva.isTransforming()) || Global_1.Konva.hitOnDragEnabled;\n if (targetShape && eventsEnabled) {\n targetShape._fireAndBubble(events.pointerout, { evt: evt });\n targetShape._fireAndBubble(events.pointerleave, { evt: evt });\n this._fire(events.pointerleave, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n this[eventType + 'targetShape'] = null;\n }\n else if (eventsEnabled) {\n this._fire(events.pointerleave, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n this._fire(events.pointerout, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n this.pointerPos = null;\n this._pointerPositions = [];\n }\n _pointerdown(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n var triggeredOnShape = false;\n this._changedPointerPositions.forEach((pos) => {\n var shape = this.getIntersection(pos);\n DragAndDrop_1.DD.justDragged = false;\n Global_1.Konva['_' + eventType + 'ListenClick'] = true;\n if (!shape || !shape.isListening()) {\n return;\n }\n if (Global_1.Konva.capturePointerEventsEnabled) {\n shape.setPointerCapture(pos.id);\n }\n this[eventType + 'ClickStartShape'] = shape;\n shape._fireAndBubble(events.pointerdown, {\n evt: evt,\n pointerId: pos.id,\n });\n triggeredOnShape = true;\n const isTouch = evt.type.indexOf('touch') >= 0;\n if (shape.preventDefault() && evt.cancelable && isTouch) {\n evt.preventDefault();\n }\n });\n if (!triggeredOnShape) {\n this._fire(events.pointerdown, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._pointerPositions[0].id,\n });\n }\n }\n _pointermove(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n if (Global_1.Konva.isDragging() && DragAndDrop_1.DD.node.preventDefault() && evt.cancelable) {\n evt.preventDefault();\n }\n this.setPointersPositions(evt);\n var eventsEnabled = !(Global_1.Konva.isDragging() || Global_1.Konva.isTransforming()) || Global_1.Konva.hitOnDragEnabled;\n if (!eventsEnabled) {\n return;\n }\n var processedShapesIds = {};\n let triggeredOnShape = false;\n var targetShape = this._getTargetShape(eventType);\n this._changedPointerPositions.forEach((pos) => {\n const shape = (PointerEvents.getCapturedShape(pos.id) ||\n this.getIntersection(pos));\n const pointerId = pos.id;\n const event = { evt: evt, pointerId };\n var differentTarget = targetShape !== shape;\n if (differentTarget && targetShape) {\n targetShape._fireAndBubble(events.pointerout, { ...event }, shape);\n targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);\n }\n if (shape) {\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n }\n if (shape && shape.isListening()) {\n triggeredOnShape = true;\n if (differentTarget) {\n shape._fireAndBubble(events.pointerover, { ...event }, targetShape);\n shape._fireAndBubble(events.pointerenter, { ...event }, targetShape);\n this[eventType + 'targetShape'] = shape;\n }\n shape._fireAndBubble(events.pointermove, { ...event });\n }\n else {\n if (targetShape) {\n this._fire(events.pointerover, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n this[eventType + 'targetShape'] = null;\n }\n }\n });\n if (!triggeredOnShape) {\n this._fire(events.pointermove, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id,\n });\n }\n }\n _pointerup(evt) {\n const events = getEventsMap(evt.type);\n const eventType = getEventType(evt.type);\n if (!events) {\n return;\n }\n this.setPointersPositions(evt);\n const clickStartShape = this[eventType + 'ClickStartShape'];\n const clickEndShape = this[eventType + 'ClickEndShape'];\n var processedShapesIds = {};\n let triggeredOnShape = false;\n this._changedPointerPositions.forEach((pos) => {\n const shape = (PointerEvents.getCapturedShape(pos.id) ||\n this.getIntersection(pos));\n if (shape) {\n shape.releaseCapture(pos.id);\n if (processedShapesIds[shape._id]) {\n return;\n }\n processedShapesIds[shape._id] = true;\n }\n const pointerId = pos.id;\n const event = { evt: evt, pointerId };\n let fireDblClick = false;\n if (Global_1.Konva['_' + eventType + 'InDblClickWindow']) {\n fireDblClick = true;\n clearTimeout(this[eventType + 'DblTimeout']);\n }\n else if (!DragAndDrop_1.DD.justDragged) {\n Global_1.Konva['_' + eventType + 'InDblClickWindow'] = true;\n clearTimeout(this[eventType + 'DblTimeout']);\n }\n this[eventType + 'DblTimeout'] = setTimeout(function () {\n Global_1.Konva['_' + eventType + 'InDblClickWindow'] = false;\n }, Global_1.Konva.dblClickWindow);\n if (shape && shape.isListening()) {\n triggeredOnShape = true;\n this[eventType + 'ClickEndShape'] = shape;\n shape._fireAndBubble(events.pointerup, { ...event });\n if (Global_1.Konva['_' + eventType + 'ListenClick'] &&\n clickStartShape &&\n clickStartShape === shape) {\n shape._fireAndBubble(events.pointerclick, { ...event });\n if (fireDblClick && clickEndShape && clickEndShape === shape) {\n shape._fireAndBubble(events.pointerdblclick, { ...event });\n }\n }\n }\n else {\n this[eventType + 'ClickEndShape'] = null;\n if (Global_1.Konva['_' + eventType + 'ListenClick']) {\n this._fire(events.pointerclick, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n }\n if (fireDblClick) {\n this._fire(events.pointerdblclick, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId,\n });\n }\n }\n });\n if (!triggeredOnShape) {\n this._fire(events.pointerup, {\n evt: evt,\n target: this,\n currentTarget: this,\n pointerId: this._changedPointerPositions[0].id,\n });\n }\n Global_1.Konva['_' + eventType + 'ListenClick'] = false;\n if (evt.cancelable && eventType !== 'touch') {\n evt.preventDefault();\n }\n }\n _contextmenu(evt) {\n this.setPointersPositions(evt);\n var shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(CONTEXTMENU, { evt: evt });\n }\n else {\n this._fire(CONTEXTMENU, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _wheel(evt) {\n this.setPointersPositions(evt);\n var shape = this.getIntersection(this.getPointerPosition());\n if (shape && shape.isListening()) {\n shape._fireAndBubble(WHEEL, { evt: evt });\n }\n else {\n this._fire(WHEEL, {\n evt: evt,\n target: this,\n currentTarget: this,\n });\n }\n }\n _pointercancel(evt) {\n this.setPointersPositions(evt);\n const shape = PointerEvents.getCapturedShape(evt.pointerId) ||\n this.getIntersection(this.getPointerPosition());\n if (shape) {\n shape._fireAndBubble(POINTERUP, PointerEvents.createEvent(evt));\n }\n PointerEvents.releaseCapture(evt.pointerId);\n }\n _lostpointercapture(evt) {\n PointerEvents.releaseCapture(evt.pointerId);\n }\n setPointersPositions(evt) {\n var contentPosition = this._getContentPosition(), x = null, y = null;\n evt = evt ? evt : window.event;\n if (evt.touches !== undefined) {\n this._pointerPositions = [];\n this._changedPointerPositions = [];\n Array.prototype.forEach.call(evt.touches, (touch) => {\n this._pointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,\n });\n });\n Array.prototype.forEach.call(evt.changedTouches || evt.touches, (touch) => {\n this._changedPointerPositions.push({\n id: touch.identifier,\n x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,\n y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,\n });\n });\n }\n else {\n x = (evt.clientX - contentPosition.left) / contentPosition.scaleX;\n y = (evt.clientY - contentPosition.top) / contentPosition.scaleY;\n this.pointerPos = {\n x: x,\n y: y,\n };\n this._pointerPositions = [{ x, y, id: Util_1.Util._getFirstPointerId(evt) }];\n this._changedPointerPositions = [\n { x, y, id: Util_1.Util._getFirstPointerId(evt) },\n ];\n }\n }\n _setPointerPosition(evt) {\n Util_1.Util.warn('Method _setPointerPosition is deprecated. Use \"stage.setPointersPositions(event)\" instead.');\n this.setPointersPositions(evt);\n }\n _getContentPosition() {\n if (!this.content || !this.content.getBoundingClientRect) {\n return {\n top: 0,\n left: 0,\n scaleX: 1,\n scaleY: 1,\n };\n }\n var rect = this.content.getBoundingClientRect();\n return {\n top: rect.top,\n left: rect.left,\n scaleX: rect.width / this.content.clientWidth || 1,\n scaleY: rect.height / this.content.clientHeight || 1,\n };\n }\n _buildDOM() {\n this.bufferCanvas = new Canvas_1.SceneCanvas({\n width: this.width(),\n height: this.height(),\n });\n this.bufferHitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: 1,\n width: this.width(),\n height: this.height(),\n });\n if (!Global_1.Konva.isBrowser) {\n return;\n }\n var container = this.container();\n if (!container) {\n throw 'Stage has no container. A container is required.';\n }\n container.innerHTML = '';\n this.content = document.createElement('div');\n this.content.style.position = 'relative';\n this.content.style.userSelect = 'none';\n this.content.className = 'konvajs-content';\n this.content.setAttribute('role', 'presentation');\n container.appendChild(this.content);\n this._resizeDOM();\n }\n cache() {\n Util_1.Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');\n return this;\n }\n clearCache() {\n return this;\n }\n batchDraw() {\n this.getChildren().forEach(function (layer) {\n layer.batchDraw();\n });\n return this;\n }\n}\nexports.Stage = Stage;\nStage.prototype.nodeType = STAGE;\n(0, Global_2._registerNode)(Stage);\nFactory_1.Factory.addGetterSetter(Stage, 'container');\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Shape = exports.shapes = void 0;\nconst Global_1 = require(\"./Global\");\nconst Util_1 = require(\"./Util\");\nconst Factory_1 = require(\"./Factory\");\nconst Node_1 = require(\"./Node\");\nconst Validators_1 = require(\"./Validators\");\nconst Global_2 = require(\"./Global\");\nconst PointerEvents = require(\"./PointerEvents\");\nvar HAS_SHADOW = 'hasShadow';\nvar SHADOW_RGBA = 'shadowRGBA';\nvar patternImage = 'patternImage';\nvar linearGradient = 'linearGradient';\nvar radialGradient = 'radialGradient';\nlet dummyContext;\nfunction getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util_1.Util.createCanvasElement().getContext('2d');\n return dummyContext;\n}\nexports.shapes = {};\nfunction _fillFunc(context) {\n const fillRule = this.attrs.fillRule;\n if (fillRule) {\n context.fill(fillRule);\n }\n else {\n context.fill();\n }\n}\nfunction _strokeFunc(context) {\n context.stroke();\n}\nfunction _fillFuncHit(context) {\n context.fill();\n}\nfunction _strokeFuncHit(context) {\n context.stroke();\n}\nfunction _clearHasShadowCache() {\n this._clearCache(HAS_SHADOW);\n}\nfunction _clearGetShadowRGBACache() {\n this._clearCache(SHADOW_RGBA);\n}\nfunction _clearFillPatternCache() {\n this._clearCache(patternImage);\n}\nfunction _clearLinearGradientCache() {\n this._clearCache(linearGradient);\n}\nfunction _clearRadialGradientCache() {\n this._clearCache(radialGradient);\n}\nclass Shape extends Node_1.Node {\n constructor(config) {\n super(config);\n let key;\n while (true) {\n key = Util_1.Util.getRandomColor();\n if (key && !(key in exports.shapes)) {\n break;\n }\n }\n this.colorKey = key;\n exports.shapes[key] = this;\n }\n getContext() {\n Util_1.Util.warn('shape.getContext() method is deprecated. Please do not use it.');\n return this.getLayer().getContext();\n }\n getCanvas() {\n Util_1.Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');\n return this.getLayer().getCanvas();\n }\n getSceneFunc() {\n return this.attrs.sceneFunc || this['_sceneFunc'];\n }\n getHitFunc() {\n return this.attrs.hitFunc || this['_hitFunc'];\n }\n hasShadow() {\n return this._getCache(HAS_SHADOW, this._hasShadow);\n }\n _hasShadow() {\n return (this.shadowEnabled() &&\n this.shadowOpacity() !== 0 &&\n !!(this.shadowColor() ||\n this.shadowBlur() ||\n this.shadowOffsetX() ||\n this.shadowOffsetY()));\n }\n _getFillPattern() {\n return this._getCache(patternImage, this.__getFillPattern);\n }\n __getFillPattern() {\n if (this.fillPatternImage()) {\n var ctx = getDummyContext();\n const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');\n if (pattern && pattern.setTransform) {\n const tr = new Util_1.Transform();\n tr.translate(this.fillPatternX(), this.fillPatternY());\n tr.rotate(Global_1.Konva.getAngle(this.fillPatternRotation()));\n tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());\n tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());\n const m = tr.getMatrix();\n const matrix = typeof DOMMatrix === 'undefined'\n ? {\n a: m[0],\n b: m[1],\n c: m[2],\n d: m[3],\n e: m[4],\n f: m[5],\n }\n : new DOMMatrix(m);\n pattern.setTransform(matrix);\n }\n return pattern;\n }\n }\n _getLinearGradient() {\n return this._getCache(linearGradient, this.__getLinearGradient);\n }\n __getLinearGradient() {\n var colorStops = this.fillLinearGradientColorStops();\n if (colorStops) {\n var ctx = getDummyContext();\n var start = this.fillLinearGradientStartPoint();\n var end = this.fillLinearGradientEndPoint();\n var grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n }\n _getRadialGradient() {\n return this._getCache(radialGradient, this.__getRadialGradient);\n }\n __getRadialGradient() {\n var colorStops = this.fillRadialGradientColorStops();\n if (colorStops) {\n var ctx = getDummyContext();\n var start = this.fillRadialGradientStartPoint();\n var end = this.fillRadialGradientEndPoint();\n var grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());\n for (var n = 0; n < colorStops.length; n += 2) {\n grd.addColorStop(colorStops[n], colorStops[n + 1]);\n }\n return grd;\n }\n }\n getShadowRGBA() {\n return this._getCache(SHADOW_RGBA, this._getShadowRGBA);\n }\n _getShadowRGBA() {\n if (!this.hasShadow()) {\n return;\n }\n var rgba = Util_1.Util.colorToRGBA(this.shadowColor());\n if (rgba) {\n return ('rgba(' +\n rgba.r +\n ',' +\n rgba.g +\n ',' +\n rgba.b +\n ',' +\n rgba.a * (this.shadowOpacity() || 1) +\n ')');\n }\n }\n hasFill() {\n return this._calculate('hasFill', [\n 'fillEnabled',\n 'fill',\n 'fillPatternImage',\n 'fillLinearGradientColorStops',\n 'fillRadialGradientColorStops',\n ], () => {\n return (this.fillEnabled() &&\n !!(this.fill() ||\n this.fillPatternImage() ||\n this.fillLinearGradientColorStops() ||\n this.fillRadialGradientColorStops()));\n });\n }\n hasStroke() {\n return this._calculate('hasStroke', [\n 'strokeEnabled',\n 'strokeWidth',\n 'stroke',\n 'strokeLinearGradientColorStops',\n ], () => {\n return (this.strokeEnabled() &&\n this.strokeWidth() &&\n !!(this.stroke() || this.strokeLinearGradientColorStops()));\n });\n }\n hasHitStroke() {\n const width = this.hitStrokeWidth();\n if (width === 'auto') {\n return this.hasStroke();\n }\n return this.strokeEnabled() && !!width;\n }\n intersects(point) {\n var stage = this.getStage();\n if (!stage) {\n return false;\n }\n const bufferHitCanvas = stage.bufferHitCanvas;\n bufferHitCanvas.getContext().clear();\n this.drawHit(bufferHitCanvas, undefined, true);\n const p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;\n return p[3] > 0;\n }\n destroy() {\n Node_1.Node.prototype.destroy.call(this);\n delete exports.shapes[this.colorKey];\n delete this.colorKey;\n return this;\n }\n _useBufferCanvas(forceFill) {\n var _a;\n const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;\n if (!perfectDrawEnabled) {\n return false;\n }\n const hasFill = forceFill || this.hasFill();\n const hasStroke = this.hasStroke();\n const isTransparent = this.getAbsoluteOpacity() !== 1;\n if (hasFill && hasStroke && isTransparent) {\n return true;\n }\n const hasShadow = this.hasShadow();\n const strokeForShadow = this.shadowForStrokeEnabled();\n if (hasFill && hasStroke && hasShadow && strokeForShadow) {\n return true;\n }\n return false;\n }\n setStrokeHitEnabled(val) {\n Util_1.Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');\n if (val) {\n this.hitStrokeWidth('auto');\n }\n else {\n this.hitStrokeWidth(0);\n }\n }\n getStrokeHitEnabled() {\n if (this.hitStrokeWidth() === 0) {\n return false;\n }\n else {\n return true;\n }\n }\n getSelfRect() {\n var size = this.size();\n return {\n x: this._centroid ? -size.width / 2 : 0,\n y: this._centroid ? -size.height / 2 : 0,\n width: size.width,\n height: size.height,\n };\n }\n getClientRect(config = {}) {\n const skipTransform = config.skipTransform;\n const relativeTo = config.relativeTo;\n const fillRect = this.getSelfRect();\n const applyStroke = !config.skipStroke && this.hasStroke();\n const strokeWidth = (applyStroke && this.strokeWidth()) || 0;\n const fillAndStrokeWidth = fillRect.width + strokeWidth;\n const fillAndStrokeHeight = fillRect.height + strokeWidth;\n const applyShadow = !config.skipShadow && this.hasShadow();\n const shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;\n const shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;\n const preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);\n const preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);\n const blurRadius = (applyShadow && this.shadowBlur()) || 0;\n const width = preWidth + blurRadius * 2;\n const height = preHeight + blurRadius * 2;\n const rect = {\n width: width,\n height: height,\n x: -(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetX, 0) +\n fillRect.x,\n y: -(strokeWidth / 2 + blurRadius) +\n Math.min(shadowOffsetY, 0) +\n fillRect.y,\n };\n if (!skipTransform) {\n return this._transformedRect(rect, relativeTo);\n }\n return rect;\n }\n drawScene(can, top, bufferCanvas) {\n var layer = this.getLayer();\n var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;\n var skipBuffer = canvas.isCache;\n var cachingSelf = top === this;\n if (!this.isVisible() && !cachingSelf) {\n return this;\n }\n if (cachedCanvas) {\n context.save();\n var m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedSceneCanvas(context);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n if (this._useBufferCanvas() && !skipBuffer) {\n stage = this.getStage();\n const bc = bufferCanvas || stage.bufferCanvas;\n bufferContext = bc.getContext();\n bufferContext.clear();\n bufferContext.save();\n bufferContext._applyLineJoin(this);\n var o = this.getAbsoluteTransform(top).getMatrix();\n bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n drawFunc.call(this, bufferContext, this);\n bufferContext.restore();\n var ratio = bc.pixelRatio;\n if (hasShadow) {\n context._applyShadow(this);\n }\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);\n }\n else {\n context._applyLineJoin(this);\n if (!cachingSelf) {\n var o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n context._applyOpacity(this);\n context._applyGlobalCompositeOperation(this);\n }\n if (hasShadow) {\n context._applyShadow(this);\n }\n drawFunc.call(this, context, this);\n }\n context.restore();\n return this;\n }\n drawHit(can, top, skipDragCheck = false) {\n if (!this.shouldDrawHit(top, skipDragCheck)) {\n return this;\n }\n var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;\n if (!this.colorKey) {\n Util_1.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()');\n }\n if (cachedHitCanvas) {\n context.save();\n var m = this.getAbsoluteTransform(top).getMatrix();\n context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n this._drawCachedHitCanvas(context);\n context.restore();\n return this;\n }\n if (!drawFunc) {\n return this;\n }\n context.save();\n context._applyLineJoin(this);\n const selfCache = this === top;\n if (!selfCache) {\n var o = this.getAbsoluteTransform(top).getMatrix();\n context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);\n }\n drawFunc.call(this, context, this);\n context.restore();\n return this;\n }\n drawHitFromCache(alphaThreshold = 0) {\n var cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha;\n hitContext.clear();\n hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);\n try {\n hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);\n hitData = hitImageData.data;\n len = hitData.length;\n rgbColorKey = Util_1.Util._hexToRgb(this.colorKey);\n for (i = 0; i < len; i += 4) {\n alpha = hitData[i + 3];\n if (alpha > alphaThreshold) {\n hitData[i] = rgbColorKey.r;\n hitData[i + 1] = rgbColorKey.g;\n hitData[i + 2] = rgbColorKey.b;\n hitData[i + 3] = 255;\n }\n else {\n hitData[i + 3] = 0;\n }\n }\n hitContext.putImageData(hitImageData, 0, 0);\n }\n catch (e) {\n Util_1.Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);\n }\n return this;\n }\n hasPointerCapture(pointerId) {\n return PointerEvents.hasPointerCapture(pointerId, this);\n }\n setPointerCapture(pointerId) {\n PointerEvents.setPointerCapture(pointerId, this);\n }\n releaseCapture(pointerId) {\n PointerEvents.releaseCapture(pointerId, this);\n }\n}\nexports.Shape = Shape;\nShape.prototype._fillFunc = _fillFunc;\nShape.prototype._strokeFunc = _strokeFunc;\nShape.prototype._fillFuncHit = _fillFuncHit;\nShape.prototype._strokeFuncHit = _strokeFuncHit;\nShape.prototype._centroid = false;\nShape.prototype.nodeType = 'Shape';\n(0, Global_2._registerNode)(Shape);\nShape.prototype.eventListeners = {};\nShape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);\nShape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);\nShape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);\nShape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);\nShape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);\nFactory_1.Factory.addGetterSetter(Shape, 'stroke', undefined, (0, Validators_1.getStringOrGradientValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'strokeWidth', 2, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);\nFactory_1.Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', (0, Validators_1.getNumberOrAutoValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'lineJoin');\nFactory_1.Factory.addGetterSetter(Shape, 'lineCap');\nFactory_1.Factory.addGetterSetter(Shape, 'sceneFunc');\nFactory_1.Factory.addGetterSetter(Shape, 'hitFunc');\nFactory_1.Factory.addGetterSetter(Shape, 'dash');\nFactory_1.Factory.addGetterSetter(Shape, 'dashOffset', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowColor', undefined, (0, Validators_1.getStringValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowBlur', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOpacity', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternImage');\nFactory_1.Factory.addGetterSetter(Shape, 'fill', undefined, (0, Validators_1.getStringOrGradientValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternX', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternY', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');\nFactory_1.Factory.addGetterSetter(Shape, 'fillEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'shadowEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'dashEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPriority', 'color');\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);\nFactory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [\n 'x',\n 'y',\n]);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);\nFactory_1.Factory.addGetterSetter(Shape, 'fillRule', undefined, (0, Validators_1.getStringValidator)());\nFactory_1.Factory.backCompat(Shape, {\n dashArray: 'dash',\n getDashArray: 'getDash',\n setDashArray: 'getDash',\n drawFunc: 'sceneFunc',\n getDrawFunc: 'getSceneFunc',\n setDrawFunc: 'setSceneFunc',\n drawHitFunc: 'hitFunc',\n getDrawHitFunc: 'getHitFunc',\n setDrawHitFunc: 'setHitFunc',\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Layer = void 0;\nconst Util_1 = require(\"./Util\");\nconst Container_1 = require(\"./Container\");\nconst Node_1 = require(\"./Node\");\nconst Factory_1 = require(\"./Factory\");\nconst Canvas_1 = require(\"./Canvas\");\nconst Validators_1 = require(\"./Validators\");\nconst Shape_1 = require(\"./Shape\");\nconst Global_1 = require(\"./Global\");\nvar HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [\n { x: 0, y: 0 },\n { x: -1, y: -1 },\n { x: 1, y: -1 },\n { x: 1, y: 1 },\n { x: -1, y: 1 },\n], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;\nclass Layer extends Container_1.Container {\n constructor(config) {\n super(config);\n this.canvas = new Canvas_1.SceneCanvas();\n this.hitCanvas = new Canvas_1.HitCanvas({\n pixelRatio: 1,\n });\n this._waitingForDraw = false;\n this.on('visibleChange.konva', this._checkVisibility);\n this._checkVisibility();\n this.on('imageSmoothingEnabledChange.konva', this._setSmoothEnabled);\n this._setSmoothEnabled();\n }\n createPNGStream() {\n const c = this.canvas._canvas;\n return c.createPNGStream();\n }\n getCanvas() {\n return this.canvas;\n }\n getNativeCanvasElement() {\n return this.canvas._canvas;\n }\n getHitCanvas() {\n return this.hitCanvas;\n }\n getContext() {\n return this.getCanvas().getContext();\n }\n clear(bounds) {\n this.getContext().clear(bounds);\n this.getHitCanvas().getContext().clear(bounds);\n return this;\n }\n setZIndex(index) {\n super.setZIndex(index);\n var stage = this.getStage();\n if (stage && stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n if (index < stage.children.length - 1) {\n stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n }\n return this;\n }\n moveToTop() {\n Node_1.Node.prototype.moveToTop.call(this);\n var stage = this.getStage();\n if (stage && stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n return true;\n }\n moveUp() {\n var moved = Node_1.Node.prototype.moveUp.call(this);\n if (!moved) {\n return false;\n }\n var stage = this.getStage();\n if (!stage || !stage.content) {\n return false;\n }\n stage.content.removeChild(this.getNativeCanvasElement());\n if (this.index < stage.children.length - 1) {\n stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[this.index + 1].getCanvas()._canvas);\n }\n else {\n stage.content.appendChild(this.getNativeCanvasElement());\n }\n return true;\n }\n moveDown() {\n if (Node_1.Node.prototype.moveDown.call(this)) {\n var stage = this.getStage();\n if (stage) {\n var children = stage.children;\n if (stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);\n }\n }\n return true;\n }\n return false;\n }\n moveToBottom() {\n if (Node_1.Node.prototype.moveToBottom.call(this)) {\n var stage = this.getStage();\n if (stage) {\n var children = stage.children;\n if (stage.content) {\n stage.content.removeChild(this.getNativeCanvasElement());\n stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);\n }\n }\n return true;\n }\n return false;\n }\n getLayer() {\n return this;\n }\n remove() {\n var _canvas = this.getNativeCanvasElement();\n Node_1.Node.prototype.remove.call(this);\n if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {\n _canvas.parentNode.removeChild(_canvas);\n }\n return this;\n }\n getStage() {\n return this.parent;\n }\n setSize({ width, height }) {\n this.canvas.setSize(width, height);\n this.hitCanvas.setSize(width, height);\n this._setSmoothEnabled();\n return this;\n }\n _validateAdd(child) {\n var type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util_1.Util.throw('You may only add groups and shapes to a layer.');\n }\n }\n _toKonvaCanvas(config) {\n config = config || {};\n config.width = config.width || this.getWidth();\n config.height = config.height || this.getHeight();\n config.x = config.x !== undefined ? config.x : this.x();\n config.y = config.y !== undefined ? config.y : this.y();\n return Node_1.Node.prototype._toKonvaCanvas.call(this, config);\n }\n _checkVisibility() {\n const visible = this.visible();\n if (visible) {\n this.canvas._canvas.style.display = 'block';\n }\n else {\n this.canvas._canvas.style.display = 'none';\n }\n }\n _setSmoothEnabled() {\n this.getContext()._context.imageSmoothingEnabled =\n this.imageSmoothingEnabled();\n }\n getWidth() {\n if (this.parent) {\n return this.parent.width();\n }\n }\n setWidth() {\n Util_1.Util.warn('Can not change width of layer. Use \"stage.width(value)\" function instead.');\n }\n getHeight() {\n if (this.parent) {\n return this.parent.height();\n }\n }\n setHeight() {\n Util_1.Util.warn('Can not change height of layer. Use \"stage.height(value)\" function instead.');\n }\n batchDraw() {\n if (!this._waitingForDraw) {\n this._waitingForDraw = true;\n Util_1.Util.requestAnimFrame(() => {\n this.draw();\n this._waitingForDraw = false;\n });\n }\n return this;\n }\n getIntersection(pos) {\n if (!this.isListening() || !this.isVisible()) {\n return null;\n }\n var spiralSearchDistance = 1;\n var continueSearch = false;\n while (true) {\n for (let i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {\n const intersectionOffset = INTERSECTION_OFFSETS[i];\n const obj = this._getIntersection({\n x: pos.x + intersectionOffset.x * spiralSearchDistance,\n y: pos.y + intersectionOffset.y * spiralSearchDistance,\n });\n const shape = obj.shape;\n if (shape) {\n return shape;\n }\n continueSearch = !!obj.antialiased;\n if (!obj.antialiased) {\n break;\n }\n }\n if (continueSearch) {\n spiralSearchDistance += 1;\n }\n else {\n return null;\n }\n }\n }\n _getIntersection(pos) {\n const ratio = this.hitCanvas.pixelRatio;\n const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;\n const p3 = p[3];\n if (p3 === 255) {\n const colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);\n const shape = Shape_1.shapes[HASH + colorKey];\n if (shape) {\n return {\n shape: shape,\n };\n }\n return {\n antialiased: true,\n };\n }\n else if (p3 > 0) {\n return {\n antialiased: true,\n };\n }\n return {};\n }\n drawScene(can, top) {\n var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());\n this._fire(BEFORE_DRAW, {\n node: this,\n });\n if (this.clearBeforeDraw()) {\n canvas.getContext().clear();\n }\n Container_1.Container.prototype.drawScene.call(this, canvas, top);\n this._fire(DRAW, {\n node: this,\n });\n return this;\n }\n drawHit(can, top) {\n var layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);\n if (layer && layer.clearBeforeDraw()) {\n layer.getHitCanvas().getContext().clear();\n }\n Container_1.Container.prototype.drawHit.call(this, canvas, top);\n return this;\n }\n enableHitGraph() {\n this.hitGraphEnabled(true);\n return this;\n }\n disableHitGraph() {\n this.hitGraphEnabled(false);\n return this;\n }\n setHitGraphEnabled(val) {\n Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');\n this.listening(val);\n }\n getHitGraphEnabled(val) {\n Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');\n return this.listening();\n }\n toggleHitCanvas() {\n if (!this.parent || !this.parent['content']) {\n return;\n }\n var parent = this.parent;\n var added = !!this.hitCanvas._canvas.parentNode;\n if (added) {\n parent.content.removeChild(this.hitCanvas._canvas);\n }\n else {\n parent.content.appendChild(this.hitCanvas._canvas);\n }\n }\n destroy() {\n Util_1.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);\n return super.destroy();\n }\n}\nexports.Layer = Layer;\nLayer.prototype.nodeType = 'Layer';\n(0, Global_1._registerNode)(Layer);\nFactory_1.Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);\nFactory_1.Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);\nFactory_1.Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, (0, Validators_1.getBooleanValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FastLayer = void 0;\nconst Util_1 = require(\"./Util\");\nconst Layer_1 = require(\"./Layer\");\nconst Global_1 = require(\"./Global\");\nclass FastLayer extends Layer_1.Layer {\n constructor(attrs) {\n super(attrs);\n this.listening(false);\n Util_1.Util.warn('Konva.Fast layer is deprecated. Please use \"new Konva.Layer({ listening: false })\" instead.');\n }\n}\nexports.FastLayer = FastLayer;\nFastLayer.prototype.nodeType = 'FastLayer';\n(0, Global_1._registerNode)(FastLayer);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Group = void 0;\nconst Util_1 = require(\"./Util\");\nconst Container_1 = require(\"./Container\");\nconst Global_1 = require(\"./Global\");\nclass Group extends Container_1.Container {\n _validateAdd(child) {\n var type = child.getType();\n if (type !== 'Group' && type !== 'Shape') {\n Util_1.Util.throw('You may only add groups and shapes to groups.');\n }\n }\n}\nexports.Group = Group;\nGroup.prototype.nodeType = 'Group';\n(0, Global_1._registerNode)(Group);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Animation = void 0;\nconst Global_1 = require(\"./Global\");\nconst Util_1 = require(\"./Util\");\nconst now = (function () {\n if (Global_1.glob.performance && Global_1.glob.performance.now) {\n return function () {\n return Global_1.glob.performance.now();\n };\n }\n return function () {\n return new Date().getTime();\n };\n})();\nclass Animation {\n constructor(func, layers) {\n this.id = Animation.animIdCounter++;\n this.frame = {\n time: 0,\n timeDiff: 0,\n lastTime: now(),\n frameRate: 0,\n };\n this.func = func;\n this.setLayers(layers);\n }\n setLayers(layers) {\n let lays = [];\n if (layers) {\n lays = Array.isArray(layers) ? layers : [layers];\n }\n this.layers = lays;\n return this;\n }\n getLayers() {\n return this.layers;\n }\n addLayer(layer) {\n const layers = this.layers;\n const len = layers.length;\n for (let n = 0; n < len; n++) {\n if (layers[n]._id === layer._id) {\n return false;\n }\n }\n this.layers.push(layer);\n return true;\n }\n isRunning() {\n const a = Animation;\n const animations = a.animations;\n const len = animations.length;\n for (let n = 0; n < len; n++) {\n if (animations[n].id === this.id) {\n return true;\n }\n }\n return false;\n }\n start() {\n this.stop();\n this.frame.timeDiff = 0;\n this.frame.lastTime = now();\n Animation._addAnimation(this);\n return this;\n }\n stop() {\n Animation._removeAnimation(this);\n return this;\n }\n _updateFrameObject(time) {\n this.frame.timeDiff = time - this.frame.lastTime;\n this.frame.lastTime = time;\n this.frame.time += this.frame.timeDiff;\n this.frame.frameRate = 1000 / this.frame.timeDiff;\n }\n static _addAnimation(anim) {\n this.animations.push(anim);\n this._handleAnimation();\n }\n static _removeAnimation(anim) {\n const id = anim.id;\n const animations = this.animations;\n const len = animations.length;\n for (let n = 0; n < len; n++) {\n if (animations[n].id === id) {\n this.animations.splice(n, 1);\n break;\n }\n }\n }\n static _runFrames() {\n const layerHash = {};\n const animations = this.animations;\n for (let n = 0; n < animations.length; n++) {\n const anim = animations[n];\n const layers = anim.layers;\n const func = anim.func;\n anim._updateFrameObject(now());\n const layersLen = layers.length;\n let needRedraw;\n if (func) {\n needRedraw = func.call(anim, anim.frame) !== false;\n }\n else {\n needRedraw = true;\n }\n if (!needRedraw) {\n continue;\n }\n for (let i = 0; i < layersLen; i++) {\n const layer = layers[i];\n if (layer._id !== undefined) {\n layerHash[layer._id] = layer;\n }\n }\n }\n for (let key in layerHash) {\n if (!layerHash.hasOwnProperty(key)) {\n continue;\n }\n layerHash[key].batchDraw();\n }\n }\n static _animationLoop() {\n const Anim = Animation;\n if (Anim.animations.length) {\n Anim._runFrames();\n Util_1.Util.requestAnimFrame(Anim._animationLoop);\n }\n else {\n Anim.animRunning = false;\n }\n }\n static _handleAnimation() {\n if (!this.animRunning) {\n this.animRunning = true;\n Util_1.Util.requestAnimFrame(this._animationLoop);\n }\n }\n}\nexports.Animation = Animation;\nAnimation.animations = [];\nAnimation.animIdCounter = 0;\nAnimation.animRunning = false;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Easings = exports.Tween = void 0;\nconst Util_1 = require(\"./Util\");\nconst Animation_1 = require(\"./Animation\");\nconst Node_1 = require(\"./Node\");\nconst Global_1 = require(\"./Global\");\nvar blacklist = {\n node: 1,\n duration: 1,\n easing: 1,\n onFinish: 1,\n yoyo: 1,\n}, PAUSED = 1, PLAYING = 2, REVERSING = 3, idCounter = 0, colorAttrs = ['fill', 'stroke', 'shadowColor'];\nclass TweenEngine {\n constructor(prop, propFunc, func, begin, finish, duration, yoyo) {\n this.prop = prop;\n this.propFunc = propFunc;\n this.begin = begin;\n this._pos = begin;\n this.duration = duration;\n this._change = 0;\n this.prevPos = 0;\n this.yoyo = yoyo;\n this._time = 0;\n this._position = 0;\n this._startTime = 0;\n this._finish = 0;\n this.func = func;\n this._change = finish - this.begin;\n this.pause();\n }\n fire(str) {\n var handler = this[str];\n if (handler) {\n handler();\n }\n }\n setTime(t) {\n if (t > this.duration) {\n if (this.yoyo) {\n this._time = this.duration;\n this.reverse();\n }\n else {\n this.finish();\n }\n }\n else if (t < 0) {\n if (this.yoyo) {\n this._time = 0;\n this.play();\n }\n else {\n this.reset();\n }\n }\n else {\n this._time = t;\n this.update();\n }\n }\n getTime() {\n return this._time;\n }\n setPosition(p) {\n this.prevPos = this._pos;\n this.propFunc(p);\n this._pos = p;\n }\n getPosition(t) {\n if (t === undefined) {\n t = this._time;\n }\n return this.func(t, this.begin, this._change, this.duration);\n }\n play() {\n this.state = PLAYING;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onPlay');\n }\n reverse() {\n this.state = REVERSING;\n this._time = this.duration - this._time;\n this._startTime = this.getTimer() - this._time;\n this.onEnterFrame();\n this.fire('onReverse');\n }\n seek(t) {\n this.pause();\n this._time = t;\n this.update();\n this.fire('onSeek');\n }\n reset() {\n this.pause();\n this._time = 0;\n this.update();\n this.fire('onReset');\n }\n finish() {\n this.pause();\n this._time = this.duration;\n this.update();\n this.fire('onFinish');\n }\n update() {\n this.setPosition(this.getPosition(this._time));\n this.fire('onUpdate');\n }\n onEnterFrame() {\n var t = this.getTimer() - this._startTime;\n if (this.state === PLAYING) {\n this.setTime(t);\n }\n else if (this.state === REVERSING) {\n this.setTime(this.duration - t);\n }\n }\n pause() {\n this.state = PAUSED;\n this.fire('onPause');\n }\n getTimer() {\n return new Date().getTime();\n }\n}\nclass Tween {\n constructor(config) {\n var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key;\n if (typeof config.duration === 'undefined') {\n duration = 0.3;\n }\n else if (config.duration === 0) {\n duration = 0.001;\n }\n else {\n duration = config.duration;\n }\n this.node = node;\n this._id = idCounter++;\n var layers = node.getLayer() ||\n (node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);\n if (!layers) {\n Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');\n }\n this.anim = new Animation_1.Animation(function () {\n that.tween.onEnterFrame();\n }, layers);\n this.tween = new TweenEngine(key, function (i) {\n that._tweenFunc(i);\n }, easing, 0, 1, duration * 1000, yoyo);\n this._addListeners();\n if (!Tween.attrs[nodeId]) {\n Tween.attrs[nodeId] = {};\n }\n if (!Tween.attrs[nodeId][this._id]) {\n Tween.attrs[nodeId][this._id] = {};\n }\n if (!Tween.tweens[nodeId]) {\n Tween.tweens[nodeId] = {};\n }\n for (key in config) {\n if (blacklist[key] === undefined) {\n this._addAttr(key, config[key]);\n }\n }\n this.reset();\n this.onFinish = config.onFinish;\n this.onReset = config.onReset;\n this.onUpdate = config.onUpdate;\n }\n _addAttr(key, end) {\n var node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA;\n tweenId = Tween.tweens[nodeId][key];\n if (tweenId) {\n delete Tween.attrs[nodeId][tweenId][key];\n }\n start = node.getAttr(key);\n if (Util_1.Util._isArray(end)) {\n diff = [];\n len = Math.max(end.length, start.length);\n if (key === 'points' && end.length !== start.length) {\n if (end.length > start.length) {\n trueStart = start;\n start = Util_1.Util._prepareArrayForTween(start, end, node.closed());\n }\n else {\n trueEnd = end;\n end = Util_1.Util._prepareArrayForTween(end, start, node.closed());\n }\n }\n if (key.indexOf('fill') === 0) {\n for (n = 0; n < len; n++) {\n if (n % 2 === 0) {\n diff.push(end[n] - start[n]);\n }\n else {\n var startRGBA = Util_1.Util.colorToRGBA(start[n]);\n endRGBA = Util_1.Util.colorToRGBA(end[n]);\n start[n] = startRGBA;\n diff.push({\n r: endRGBA.r - startRGBA.r,\n g: endRGBA.g - startRGBA.g,\n b: endRGBA.b - startRGBA.b,\n a: endRGBA.a - startRGBA.a,\n });\n }\n }\n }\n else {\n for (n = 0; n < len; n++) {\n diff.push(end[n] - start[n]);\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n start = Util_1.Util.colorToRGBA(start);\n endRGBA = Util_1.Util.colorToRGBA(end);\n diff = {\n r: endRGBA.r - start.r,\n g: endRGBA.g - start.g,\n b: endRGBA.b - start.b,\n a: endRGBA.a - start.a,\n };\n }\n else {\n diff = end - start;\n }\n Tween.attrs[nodeId][this._id][key] = {\n start: start,\n diff: diff,\n end: end,\n trueEnd: trueEnd,\n trueStart: trueStart,\n };\n Tween.tweens[nodeId][key] = this._id;\n }\n _tweenFunc(i) {\n var node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end;\n for (key in attrs) {\n attr = attrs[key];\n start = attr.start;\n diff = attr.diff;\n end = attr.end;\n if (Util_1.Util._isArray(start)) {\n newVal = [];\n len = Math.max(start.length, end.length);\n if (key.indexOf('fill') === 0) {\n for (n = 0; n < len; n++) {\n if (n % 2 === 0) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n else {\n newVal.push('rgba(' +\n Math.round(start[n].r + diff[n].r * i) +\n ',' +\n Math.round(start[n].g + diff[n].g * i) +\n ',' +\n Math.round(start[n].b + diff[n].b * i) +\n ',' +\n (start[n].a + diff[n].a * i) +\n ')');\n }\n }\n }\n else {\n for (n = 0; n < len; n++) {\n newVal.push((start[n] || 0) + diff[n] * i);\n }\n }\n }\n else if (colorAttrs.indexOf(key) !== -1) {\n newVal =\n 'rgba(' +\n Math.round(start.r + diff.r * i) +\n ',' +\n Math.round(start.g + diff.g * i) +\n ',' +\n Math.round(start.b + diff.b * i) +\n ',' +\n (start.a + diff.a * i) +\n ')';\n }\n else {\n newVal = start + diff * i;\n }\n node.setAttr(key, newVal);\n }\n }\n _addListeners() {\n this.tween.onPlay = () => {\n this.anim.start();\n };\n this.tween.onReverse = () => {\n this.anim.start();\n };\n this.tween.onPause = () => {\n this.anim.stop();\n };\n this.tween.onFinish = () => {\n var node = this.node;\n var attrs = Tween.attrs[node._id][this._id];\n if (attrs.points && attrs.points.trueEnd) {\n node.setAttr('points', attrs.points.trueEnd);\n }\n if (this.onFinish) {\n this.onFinish.call(this);\n }\n };\n this.tween.onReset = () => {\n var node = this.node;\n var attrs = Tween.attrs[node._id][this._id];\n if (attrs.points && attrs.points.trueStart) {\n node.points(attrs.points.trueStart);\n }\n if (this.onReset) {\n this.onReset();\n }\n };\n this.tween.onUpdate = () => {\n if (this.onUpdate) {\n this.onUpdate.call(this);\n }\n };\n }\n play() {\n this.tween.play();\n return this;\n }\n reverse() {\n this.tween.reverse();\n return this;\n }\n reset() {\n this.tween.reset();\n return this;\n }\n seek(t) {\n this.tween.seek(t * 1000);\n return this;\n }\n pause() {\n this.tween.pause();\n return this;\n }\n finish() {\n this.tween.finish();\n return this;\n }\n destroy() {\n var nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key;\n this.pause();\n for (key in attrs) {\n delete Tween.tweens[nodeId][key];\n }\n delete Tween.attrs[nodeId][thisId];\n }\n}\nexports.Tween = Tween;\nTween.attrs = {};\nTween.tweens = {};\nNode_1.Node.prototype.to = function (params) {\n var onFinish = params.onFinish;\n params.node = this;\n params.onFinish = function () {\n this.destroy();\n if (onFinish) {\n onFinish();\n }\n };\n var tween = new Tween(params);\n tween.play();\n};\nexports.Easings = {\n BackEaseIn(t, b, c, d) {\n var s = 1.70158;\n return c * (t /= d) * t * ((s + 1) * t - s) + b;\n },\n BackEaseOut(t, b, c, d) {\n var s = 1.70158;\n return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n },\n BackEaseInOut(t, b, c, d) {\n var s = 1.70158;\n if ((t /= d / 2) < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n },\n ElasticEaseIn(t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (-(a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b);\n },\n ElasticEaseOut(t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d) === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n return (a * Math.pow(2, -10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) +\n c +\n b);\n },\n ElasticEaseInOut(t, b, c, d, a, p) {\n var s = 0;\n if (t === 0) {\n return b;\n }\n if ((t /= d / 2) === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n if (!a || a < Math.abs(c)) {\n a = c;\n s = p / 4;\n }\n else {\n s = (p / (2 * Math.PI)) * Math.asin(c / a);\n }\n if (t < 1) {\n return (-0.5 *\n (a *\n Math.pow(2, 10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +\n b);\n }\n return (a *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - s) * (2 * Math.PI)) / p) *\n 0.5 +\n c +\n b);\n },\n BounceEaseOut(t, b, c, d) {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n }\n else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n }\n else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n }\n else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n },\n BounceEaseIn(t, b, c, d) {\n return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;\n },\n BounceEaseInOut(t, b, c, d) {\n if (t < d / 2) {\n return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;\n }\n else {\n return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n }\n },\n EaseIn(t, b, c, d) {\n return c * (t /= d) * t + b;\n },\n EaseOut(t, b, c, d) {\n return -c * (t /= d) * (t - 2) + b;\n },\n EaseInOut(t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n },\n StrongEaseIn(t, b, c, d) {\n return c * (t /= d) * t * t * t * t + b;\n },\n StrongEaseOut(t, b, c, d) {\n return c * ((t = t / d - 1) * t * t * t * t + 1) + b;\n },\n StrongEaseInOut(t, b, c, d) {\n if ((t /= d / 2) < 1) {\n return (c / 2) * t * t * t * t * t + b;\n }\n return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;\n },\n Linear(t, b, c, d) {\n return (c * t) / d + b;\n },\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Konva = void 0;\nconst Global_1 = require(\"./Global\");\nconst Util_1 = require(\"./Util\");\nconst Node_1 = require(\"./Node\");\nconst Container_1 = require(\"./Container\");\nconst Stage_1 = require(\"./Stage\");\nconst Layer_1 = require(\"./Layer\");\nconst FastLayer_1 = require(\"./FastLayer\");\nconst Group_1 = require(\"./Group\");\nconst DragAndDrop_1 = require(\"./DragAndDrop\");\nconst Shape_1 = require(\"./Shape\");\nconst Animation_1 = require(\"./Animation\");\nconst Tween_1 = require(\"./Tween\");\nconst Context_1 = require(\"./Context\");\nconst Canvas_1 = require(\"./Canvas\");\nexports.Konva = Util_1.Util._assign(Global_1.Konva, {\n Util: Util_1.Util,\n Transform: Util_1.Transform,\n Node: Node_1.Node,\n Container: Container_1.Container,\n Stage: Stage_1.Stage,\n stages: Stage_1.stages,\n Layer: Layer_1.Layer,\n FastLayer: FastLayer_1.FastLayer,\n Group: Group_1.Group,\n DD: DragAndDrop_1.DD,\n Shape: Shape_1.Shape,\n shapes: Shape_1.shapes,\n Animation: Animation_1.Animation,\n Tween: Tween_1.Tween,\n Easings: Tween_1.Easings,\n Context: Context_1.Context,\n Canvas: Canvas_1.Canvas,\n});\nexports.default = exports.Konva;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Arc = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Global_1 = require(\"../Global\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_2 = require(\"../Global\");\nclass Arc extends Shape_1.Shape {\n _sceneFunc(context) {\n var angle = Global_1.Konva.getAngle(this.angle()), clockwise = this.clockwise();\n context.beginPath();\n context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);\n context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.outerRadius() * 2;\n }\n getHeight() {\n return this.outerRadius() * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n getSelfRect() {\n const innerRadius = this.innerRadius();\n const outerRadius = this.outerRadius();\n const clockwise = this.clockwise();\n const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());\n const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));\n const boundRightRatio = 1;\n const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));\n const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));\n const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);\n const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);\n const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);\n const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);\n return {\n x: boundLeft,\n y: clockwise ? -1 * boundBottom : boundTop,\n width: boundRight - boundLeft,\n height: boundBottom - boundTop,\n };\n }\n}\nexports.Arc = Arc;\nArc.prototype._centroid = true;\nArc.prototype.className = 'Arc';\nArc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\n(0, Global_2._registerNode)(Arc);\nFactory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Arc, 'angle', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Arc, 'clockwise', false, (0, Validators_1.getBooleanValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Line = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nfunction getControlPoints(x0, y0, x1, y1, x2, y2, t) {\n var d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);\n return [p1x, p1y, p2x, p2y];\n}\nfunction expandPoints(p, tension) {\n var len = p.length, allPoints = [], n, cp;\n for (n = 2; n < len - 2; n += 2) {\n cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);\n if (isNaN(cp[0])) {\n continue;\n }\n allPoints.push(cp[0]);\n allPoints.push(cp[1]);\n allPoints.push(p[n]);\n allPoints.push(p[n + 1]);\n allPoints.push(cp[2]);\n allPoints.push(cp[3]);\n }\n return allPoints;\n}\nclass Line extends Shape_1.Shape {\n constructor(config) {\n super(config);\n this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {\n this._clearCache('tensionPoints');\n });\n }\n _sceneFunc(context) {\n var points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;\n if (!length) {\n return;\n }\n context.beginPath();\n context.moveTo(points[0], points[1]);\n if (tension !== 0 && length > 4) {\n tp = this.getTensionPoints();\n len = tp.length;\n n = closed ? 0 : 4;\n if (!closed) {\n context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);\n }\n while (n < len - 2) {\n context.bezierCurveTo(tp[n++], tp[n++], tp[n++], tp[n++], tp[n++], tp[n++]);\n }\n if (!closed) {\n context.quadraticCurveTo(tp[len - 2], tp[len - 1], points[length - 2], points[length - 1]);\n }\n }\n else if (bezier) {\n n = 2;\n while (n < length) {\n context.bezierCurveTo(points[n++], points[n++], points[n++], points[n++], points[n++], points[n++]);\n }\n }\n else {\n for (n = 2; n < length; n += 2) {\n context.lineTo(points[n], points[n + 1]);\n }\n }\n if (closed) {\n context.closePath();\n context.fillStrokeShape(this);\n }\n else {\n context.strokeShape(this);\n }\n }\n getTensionPoints() {\n return this._getCache('tensionPoints', this._getTensionPoints);\n }\n _getTensionPoints() {\n if (this.closed()) {\n return this._getTensionPointsClosed();\n }\n else {\n return expandPoints(this.points(), this.tension());\n }\n }\n _getTensionPointsClosed() {\n var p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]\n .concat(middle)\n .concat([\n lastControlPoints[0],\n lastControlPoints[1],\n p[len - 2],\n p[len - 1],\n lastControlPoints[2],\n lastControlPoints[3],\n firstControlPoints[0],\n firstControlPoints[1],\n p[0],\n p[1],\n ]);\n return tp;\n }\n getWidth() {\n return this.getSelfRect().width;\n }\n getHeight() {\n return this.getSelfRect().height;\n }\n getSelfRect() {\n var points = this.points();\n if (points.length < 4) {\n return {\n x: points[0] || 0,\n y: points[1] || 0,\n width: 0,\n height: 0,\n };\n }\n if (this.tension() !== 0) {\n points = [\n points[0],\n points[1],\n ...this._getTensionPoints(),\n points[points.length - 2],\n points[points.length - 1],\n ];\n }\n else {\n points = this.points();\n }\n var minX = points[0];\n var maxX = points[0];\n var minY = points[1];\n var maxY = points[1];\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n}\nexports.Line = Line;\nLine.prototype.className = 'Line';\nLine.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];\n(0, Global_1._registerNode)(Line);\nFactory_1.Factory.addGetterSetter(Line, 'closed', false);\nFactory_1.Factory.addGetterSetter(Line, 'bezier', false);\nFactory_1.Factory.addGetterSetter(Line, 'tension', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Line, 'points', [], (0, Validators_1.getNumberArrayValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = void 0;\nexports.tValues = [\n [],\n [],\n [\n -0.5773502691896257645091487805019574556476,\n 0.5773502691896257645091487805019574556476,\n ],\n [\n 0, -0.7745966692414833770358530799564799221665,\n 0.7745966692414833770358530799564799221665,\n ],\n [\n -0.3399810435848562648026657591032446872005,\n 0.3399810435848562648026657591032446872005,\n -0.8611363115940525752239464888928095050957,\n 0.8611363115940525752239464888928095050957,\n ],\n [\n 0, -0.5384693101056830910363144207002088049672,\n 0.5384693101056830910363144207002088049672,\n -0.9061798459386639927976268782993929651256,\n 0.9061798459386639927976268782993929651256,\n ],\n [\n 0.6612093864662645136613995950199053470064,\n -0.6612093864662645136613995950199053470064,\n -0.2386191860831969086305017216807119354186,\n 0.2386191860831969086305017216807119354186,\n -0.9324695142031520278123015544939946091347,\n 0.9324695142031520278123015544939946091347,\n ],\n [\n 0, 0.4058451513773971669066064120769614633473,\n -0.4058451513773971669066064120769614633473,\n -0.7415311855993944398638647732807884070741,\n 0.7415311855993944398638647732807884070741,\n -0.9491079123427585245261896840478512624007,\n 0.9491079123427585245261896840478512624007,\n ],\n [\n -0.1834346424956498049394761423601839806667,\n 0.1834346424956498049394761423601839806667,\n -0.5255324099163289858177390491892463490419,\n 0.5255324099163289858177390491892463490419,\n -0.7966664774136267395915539364758304368371,\n 0.7966664774136267395915539364758304368371,\n -0.9602898564975362316835608685694729904282,\n 0.9602898564975362316835608685694729904282,\n ],\n [\n 0, -0.8360311073266357942994297880697348765441,\n 0.8360311073266357942994297880697348765441,\n -0.9681602395076260898355762029036728700494,\n 0.9681602395076260898355762029036728700494,\n -0.3242534234038089290385380146433366085719,\n 0.3242534234038089290385380146433366085719,\n -0.6133714327005903973087020393414741847857,\n 0.6133714327005903973087020393414741847857,\n ],\n [\n -0.1488743389816312108848260011297199846175,\n 0.1488743389816312108848260011297199846175,\n -0.4333953941292471907992659431657841622,\n 0.4333953941292471907992659431657841622,\n -0.6794095682990244062343273651148735757692,\n 0.6794095682990244062343273651148735757692,\n -0.8650633666889845107320966884234930485275,\n 0.8650633666889845107320966884234930485275,\n -0.9739065285171717200779640120844520534282,\n 0.9739065285171717200779640120844520534282,\n ],\n [\n 0, -0.2695431559523449723315319854008615246796,\n 0.2695431559523449723315319854008615246796,\n -0.5190961292068118159257256694586095544802,\n 0.5190961292068118159257256694586095544802,\n -0.7301520055740493240934162520311534580496,\n 0.7301520055740493240934162520311534580496,\n -0.8870625997680952990751577693039272666316,\n 0.8870625997680952990751577693039272666316,\n -0.9782286581460569928039380011228573907714,\n 0.9782286581460569928039380011228573907714,\n ],\n [\n -0.1252334085114689154724413694638531299833,\n 0.1252334085114689154724413694638531299833,\n -0.3678314989981801937526915366437175612563,\n 0.3678314989981801937526915366437175612563,\n -0.587317954286617447296702418940534280369,\n 0.587317954286617447296702418940534280369,\n -0.7699026741943046870368938332128180759849,\n 0.7699026741943046870368938332128180759849,\n -0.9041172563704748566784658661190961925375,\n 0.9041172563704748566784658661190961925375,\n -0.9815606342467192506905490901492808229601,\n 0.9815606342467192506905490901492808229601,\n ],\n [\n 0, -0.2304583159551347940655281210979888352115,\n 0.2304583159551347940655281210979888352115,\n -0.4484927510364468528779128521276398678019,\n 0.4484927510364468528779128521276398678019,\n -0.6423493394403402206439846069955156500716,\n 0.6423493394403402206439846069955156500716,\n -0.8015780907333099127942064895828598903056,\n 0.8015780907333099127942064895828598903056,\n -0.9175983992229779652065478365007195123904,\n 0.9175983992229779652065478365007195123904,\n -0.9841830547185881494728294488071096110649,\n 0.9841830547185881494728294488071096110649,\n ],\n [\n -0.1080549487073436620662446502198347476119,\n 0.1080549487073436620662446502198347476119,\n -0.3191123689278897604356718241684754668342,\n 0.3191123689278897604356718241684754668342,\n -0.5152486363581540919652907185511886623088,\n 0.5152486363581540919652907185511886623088,\n -0.6872929048116854701480198030193341375384,\n 0.6872929048116854701480198030193341375384,\n -0.8272013150697649931897947426503949610397,\n 0.8272013150697649931897947426503949610397,\n -0.928434883663573517336391139377874264477,\n 0.928434883663573517336391139377874264477,\n -0.986283808696812338841597266704052801676,\n 0.986283808696812338841597266704052801676,\n ],\n [\n 0, -0.2011940939974345223006283033945962078128,\n 0.2011940939974345223006283033945962078128,\n -0.3941513470775633698972073709810454683627,\n 0.3941513470775633698972073709810454683627,\n -0.5709721726085388475372267372539106412383,\n 0.5709721726085388475372267372539106412383,\n -0.7244177313601700474161860546139380096308,\n 0.7244177313601700474161860546139380096308,\n -0.8482065834104272162006483207742168513662,\n 0.8482065834104272162006483207742168513662,\n -0.9372733924007059043077589477102094712439,\n 0.9372733924007059043077589477102094712439,\n -0.9879925180204854284895657185866125811469,\n 0.9879925180204854284895657185866125811469,\n ],\n [\n -0.0950125098376374401853193354249580631303,\n 0.0950125098376374401853193354249580631303,\n -0.281603550779258913230460501460496106486,\n 0.281603550779258913230460501460496106486,\n -0.45801677765722738634241944298357757354,\n 0.45801677765722738634241944298357757354,\n -0.6178762444026437484466717640487910189918,\n 0.6178762444026437484466717640487910189918,\n -0.7554044083550030338951011948474422683538,\n 0.7554044083550030338951011948474422683538,\n -0.8656312023878317438804678977123931323873,\n 0.8656312023878317438804678977123931323873,\n -0.9445750230732325760779884155346083450911,\n 0.9445750230732325760779884155346083450911,\n -0.9894009349916499325961541734503326274262,\n 0.9894009349916499325961541734503326274262,\n ],\n [\n 0, -0.1784841814958478558506774936540655574754,\n 0.1784841814958478558506774936540655574754,\n -0.3512317634538763152971855170953460050405,\n 0.3512317634538763152971855170953460050405,\n -0.5126905370864769678862465686295518745829,\n 0.5126905370864769678862465686295518745829,\n -0.6576711592166907658503022166430023351478,\n 0.6576711592166907658503022166430023351478,\n -0.7815140038968014069252300555204760502239,\n 0.7815140038968014069252300555204760502239,\n -0.8802391537269859021229556944881556926234,\n 0.8802391537269859021229556944881556926234,\n -0.9506755217687677612227169578958030214433,\n 0.9506755217687677612227169578958030214433,\n -0.9905754753144173356754340199406652765077,\n 0.9905754753144173356754340199406652765077,\n ],\n [\n -0.0847750130417353012422618529357838117333,\n 0.0847750130417353012422618529357838117333,\n -0.2518862256915055095889728548779112301628,\n 0.2518862256915055095889728548779112301628,\n -0.4117511614628426460359317938330516370789,\n 0.4117511614628426460359317938330516370789,\n -0.5597708310739475346078715485253291369276,\n 0.5597708310739475346078715485253291369276,\n -0.6916870430603532078748910812888483894522,\n 0.6916870430603532078748910812888483894522,\n -0.8037049589725231156824174550145907971032,\n 0.8037049589725231156824174550145907971032,\n -0.8926024664975557392060605911271455154078,\n 0.8926024664975557392060605911271455154078,\n -0.9558239495713977551811958929297763099728,\n 0.9558239495713977551811958929297763099728,\n -0.9915651684209309467300160047061507702525,\n 0.9915651684209309467300160047061507702525,\n ],\n [\n 0, -0.1603586456402253758680961157407435495048,\n 0.1603586456402253758680961157407435495048,\n -0.3165640999636298319901173288498449178922,\n 0.3165640999636298319901173288498449178922,\n -0.4645707413759609457172671481041023679762,\n 0.4645707413759609457172671481041023679762,\n -0.6005453046616810234696381649462392798683,\n 0.6005453046616810234696381649462392798683,\n -0.7209661773352293786170958608237816296571,\n 0.7209661773352293786170958608237816296571,\n -0.8227146565371428249789224867127139017745,\n 0.8227146565371428249789224867127139017745,\n -0.9031559036148179016426609285323124878093,\n 0.9031559036148179016426609285323124878093,\n -0.960208152134830030852778840687651526615,\n 0.960208152134830030852778840687651526615,\n -0.9924068438435844031890176702532604935893,\n 0.9924068438435844031890176702532604935893,\n ],\n [\n -0.0765265211334973337546404093988382110047,\n 0.0765265211334973337546404093988382110047,\n -0.227785851141645078080496195368574624743,\n 0.227785851141645078080496195368574624743,\n -0.3737060887154195606725481770249272373957,\n 0.3737060887154195606725481770249272373957,\n -0.5108670019508270980043640509552509984254,\n 0.5108670019508270980043640509552509984254,\n -0.6360536807265150254528366962262859367433,\n 0.6360536807265150254528366962262859367433,\n -0.7463319064601507926143050703556415903107,\n 0.7463319064601507926143050703556415903107,\n -0.8391169718222188233945290617015206853296,\n 0.8391169718222188233945290617015206853296,\n -0.9122344282513259058677524412032981130491,\n 0.9122344282513259058677524412032981130491,\n -0.963971927277913791267666131197277221912,\n 0.963971927277913791267666131197277221912,\n -0.9931285991850949247861223884713202782226,\n 0.9931285991850949247861223884713202782226,\n ],\n [\n 0, -0.1455618541608950909370309823386863301163,\n 0.1455618541608950909370309823386863301163,\n -0.288021316802401096600792516064600319909,\n 0.288021316802401096600792516064600319909,\n -0.4243421202074387835736688885437880520964,\n 0.4243421202074387835736688885437880520964,\n -0.551618835887219807059018796724313286622,\n 0.551618835887219807059018796724313286622,\n -0.667138804197412319305966669990339162597,\n 0.667138804197412319305966669990339162597,\n -0.7684399634756779086158778513062280348209,\n 0.7684399634756779086158778513062280348209,\n -0.8533633645833172836472506385875676702761,\n 0.8533633645833172836472506385875676702761,\n -0.9200993341504008287901871337149688941591,\n 0.9200993341504008287901871337149688941591,\n -0.9672268385663062943166222149076951614246,\n 0.9672268385663062943166222149076951614246,\n -0.9937521706203895002602420359379409291933,\n 0.9937521706203895002602420359379409291933,\n ],\n [\n -0.0697392733197222212138417961186280818222,\n 0.0697392733197222212138417961186280818222,\n -0.2078604266882212854788465339195457342156,\n 0.2078604266882212854788465339195457342156,\n -0.3419358208920842251581474204273796195591,\n 0.3419358208920842251581474204273796195591,\n -0.4693558379867570264063307109664063460953,\n 0.4693558379867570264063307109664063460953,\n -0.5876404035069115929588769276386473488776,\n 0.5876404035069115929588769276386473488776,\n -0.6944872631866827800506898357622567712673,\n 0.6944872631866827800506898357622567712673,\n -0.7878168059792081620042779554083515213881,\n 0.7878168059792081620042779554083515213881,\n -0.8658125777203001365364256370193787290847,\n 0.8658125777203001365364256370193787290847,\n -0.9269567721871740005206929392590531966353,\n 0.9269567721871740005206929392590531966353,\n -0.9700604978354287271239509867652687108059,\n 0.9700604978354287271239509867652687108059,\n -0.994294585482399292073031421161298980393,\n 0.994294585482399292073031421161298980393,\n ],\n [\n 0, -0.1332568242984661109317426822417661370104,\n 0.1332568242984661109317426822417661370104,\n -0.264135680970344930533869538283309602979,\n 0.264135680970344930533869538283309602979,\n -0.390301038030290831421488872880605458578,\n 0.390301038030290831421488872880605458578,\n -0.5095014778460075496897930478668464305448,\n 0.5095014778460075496897930478668464305448,\n -0.6196098757636461563850973116495956533871,\n 0.6196098757636461563850973116495956533871,\n -0.7186613631319501944616244837486188483299,\n 0.7186613631319501944616244837486188483299,\n -0.8048884016188398921511184069967785579414,\n 0.8048884016188398921511184069967785579414,\n -0.8767523582704416673781568859341456716389,\n 0.8767523582704416673781568859341456716389,\n -0.9329710868260161023491969890384229782357,\n 0.9329710868260161023491969890384229782357,\n -0.9725424712181152319560240768207773751816,\n 0.9725424712181152319560240768207773751816,\n -0.9947693349975521235239257154455743605736,\n 0.9947693349975521235239257154455743605736,\n ],\n [\n -0.0640568928626056260850430826247450385909,\n 0.0640568928626056260850430826247450385909,\n -0.1911188674736163091586398207570696318404,\n 0.1911188674736163091586398207570696318404,\n -0.3150426796961633743867932913198102407864,\n 0.3150426796961633743867932913198102407864,\n -0.4337935076260451384870842319133497124524,\n 0.4337935076260451384870842319133497124524,\n -0.5454214713888395356583756172183723700107,\n 0.5454214713888395356583756172183723700107,\n -0.6480936519369755692524957869107476266696,\n 0.6480936519369755692524957869107476266696,\n -0.7401241915785543642438281030999784255232,\n 0.7401241915785543642438281030999784255232,\n -0.8200019859739029219539498726697452080761,\n 0.8200019859739029219539498726697452080761,\n -0.8864155270044010342131543419821967550873,\n 0.8864155270044010342131543419821967550873,\n -0.9382745520027327585236490017087214496548,\n 0.9382745520027327585236490017087214496548,\n -0.9747285559713094981983919930081690617411,\n 0.9747285559713094981983919930081690617411,\n -0.9951872199970213601799974097007368118745,\n 0.9951872199970213601799974097007368118745,\n ],\n];\nexports.cValues = [\n [],\n [],\n [1.0, 1.0],\n [\n 0.8888888888888888888888888888888888888888,\n 0.5555555555555555555555555555555555555555,\n 0.5555555555555555555555555555555555555555,\n ],\n [\n 0.6521451548625461426269360507780005927646,\n 0.6521451548625461426269360507780005927646,\n 0.3478548451374538573730639492219994072353,\n 0.3478548451374538573730639492219994072353,\n ],\n [\n 0.5688888888888888888888888888888888888888,\n 0.4786286704993664680412915148356381929122,\n 0.4786286704993664680412915148356381929122,\n 0.2369268850561890875142640407199173626432,\n 0.2369268850561890875142640407199173626432,\n ],\n [\n 0.3607615730481386075698335138377161116615,\n 0.3607615730481386075698335138377161116615,\n 0.4679139345726910473898703439895509948116,\n 0.4679139345726910473898703439895509948116,\n 0.1713244923791703450402961421727328935268,\n 0.1713244923791703450402961421727328935268,\n ],\n [\n 0.4179591836734693877551020408163265306122,\n 0.3818300505051189449503697754889751338783,\n 0.3818300505051189449503697754889751338783,\n 0.2797053914892766679014677714237795824869,\n 0.2797053914892766679014677714237795824869,\n 0.1294849661688696932706114326790820183285,\n 0.1294849661688696932706114326790820183285,\n ],\n [\n 0.3626837833783619829651504492771956121941,\n 0.3626837833783619829651504492771956121941,\n 0.3137066458778872873379622019866013132603,\n 0.3137066458778872873379622019866013132603,\n 0.2223810344533744705443559944262408844301,\n 0.2223810344533744705443559944262408844301,\n 0.1012285362903762591525313543099621901153,\n 0.1012285362903762591525313543099621901153,\n ],\n [\n 0.3302393550012597631645250692869740488788,\n 0.1806481606948574040584720312429128095143,\n 0.1806481606948574040584720312429128095143,\n 0.0812743883615744119718921581105236506756,\n 0.0812743883615744119718921581105236506756,\n 0.3123470770400028400686304065844436655987,\n 0.3123470770400028400686304065844436655987,\n 0.2606106964029354623187428694186328497718,\n 0.2606106964029354623187428694186328497718,\n ],\n [\n 0.295524224714752870173892994651338329421,\n 0.295524224714752870173892994651338329421,\n 0.2692667193099963550912269215694693528597,\n 0.2692667193099963550912269215694693528597,\n 0.2190863625159820439955349342281631924587,\n 0.2190863625159820439955349342281631924587,\n 0.1494513491505805931457763396576973324025,\n 0.1494513491505805931457763396576973324025,\n 0.0666713443086881375935688098933317928578,\n 0.0666713443086881375935688098933317928578,\n ],\n [\n 0.272925086777900630714483528336342189156,\n 0.2628045445102466621806888698905091953727,\n 0.2628045445102466621806888698905091953727,\n 0.2331937645919904799185237048431751394317,\n 0.2331937645919904799185237048431751394317,\n 0.1862902109277342514260976414316558916912,\n 0.1862902109277342514260976414316558916912,\n 0.1255803694649046246346942992239401001976,\n 0.1255803694649046246346942992239401001976,\n 0.0556685671161736664827537204425485787285,\n 0.0556685671161736664827537204425485787285,\n ],\n [\n 0.2491470458134027850005624360429512108304,\n 0.2491470458134027850005624360429512108304,\n 0.2334925365383548087608498989248780562594,\n 0.2334925365383548087608498989248780562594,\n 0.2031674267230659217490644558097983765065,\n 0.2031674267230659217490644558097983765065,\n 0.160078328543346226334652529543359071872,\n 0.160078328543346226334652529543359071872,\n 0.1069393259953184309602547181939962242145,\n 0.1069393259953184309602547181939962242145,\n 0.047175336386511827194615961485017060317,\n 0.047175336386511827194615961485017060317,\n ],\n [\n 0.2325515532308739101945895152688359481566,\n 0.2262831802628972384120901860397766184347,\n 0.2262831802628972384120901860397766184347,\n 0.2078160475368885023125232193060527633865,\n 0.2078160475368885023125232193060527633865,\n 0.1781459807619457382800466919960979955128,\n 0.1781459807619457382800466919960979955128,\n 0.1388735102197872384636017768688714676218,\n 0.1388735102197872384636017768688714676218,\n 0.0921214998377284479144217759537971209236,\n 0.0921214998377284479144217759537971209236,\n 0.0404840047653158795200215922009860600419,\n 0.0404840047653158795200215922009860600419,\n ],\n [\n 0.2152638534631577901958764433162600352749,\n 0.2152638534631577901958764433162600352749,\n 0.2051984637212956039659240656612180557103,\n 0.2051984637212956039659240656612180557103,\n 0.1855383974779378137417165901251570362489,\n 0.1855383974779378137417165901251570362489,\n 0.1572031671581935345696019386238421566056,\n 0.1572031671581935345696019386238421566056,\n 0.1215185706879031846894148090724766259566,\n 0.1215185706879031846894148090724766259566,\n 0.0801580871597602098056332770628543095836,\n 0.0801580871597602098056332770628543095836,\n 0.0351194603317518630318328761381917806197,\n 0.0351194603317518630318328761381917806197,\n ],\n [\n 0.2025782419255612728806201999675193148386,\n 0.1984314853271115764561183264438393248186,\n 0.1984314853271115764561183264438393248186,\n 0.1861610000155622110268005618664228245062,\n 0.1861610000155622110268005618664228245062,\n 0.1662692058169939335532008604812088111309,\n 0.1662692058169939335532008604812088111309,\n 0.1395706779261543144478047945110283225208,\n 0.1395706779261543144478047945110283225208,\n 0.1071592204671719350118695466858693034155,\n 0.1071592204671719350118695466858693034155,\n 0.0703660474881081247092674164506673384667,\n 0.0703660474881081247092674164506673384667,\n 0.0307532419961172683546283935772044177217,\n 0.0307532419961172683546283935772044177217,\n ],\n [\n 0.1894506104550684962853967232082831051469,\n 0.1894506104550684962853967232082831051469,\n 0.1826034150449235888667636679692199393835,\n 0.1826034150449235888667636679692199393835,\n 0.1691565193950025381893120790303599622116,\n 0.1691565193950025381893120790303599622116,\n 0.1495959888165767320815017305474785489704,\n 0.1495959888165767320815017305474785489704,\n 0.1246289712555338720524762821920164201448,\n 0.1246289712555338720524762821920164201448,\n 0.0951585116824927848099251076022462263552,\n 0.0951585116824927848099251076022462263552,\n 0.0622535239386478928628438369943776942749,\n 0.0622535239386478928628438369943776942749,\n 0.0271524594117540948517805724560181035122,\n 0.0271524594117540948517805724560181035122,\n ],\n [\n 0.1794464703562065254582656442618856214487,\n 0.1765627053669926463252709901131972391509,\n 0.1765627053669926463252709901131972391509,\n 0.1680041021564500445099706637883231550211,\n 0.1680041021564500445099706637883231550211,\n 0.1540457610768102880814315948019586119404,\n 0.1540457610768102880814315948019586119404,\n 0.1351363684685254732863199817023501973721,\n 0.1351363684685254732863199817023501973721,\n 0.1118838471934039710947883856263559267358,\n 0.1118838471934039710947883856263559267358,\n 0.0850361483171791808835353701910620738504,\n 0.0850361483171791808835353701910620738504,\n 0.0554595293739872011294401653582446605128,\n 0.0554595293739872011294401653582446605128,\n 0.0241483028685479319601100262875653246916,\n 0.0241483028685479319601100262875653246916,\n ],\n [\n 0.1691423829631435918406564701349866103341,\n 0.1691423829631435918406564701349866103341,\n 0.1642764837458327229860537764659275904123,\n 0.1642764837458327229860537764659275904123,\n 0.1546846751262652449254180038363747721932,\n 0.1546846751262652449254180038363747721932,\n 0.1406429146706506512047313037519472280955,\n 0.1406429146706506512047313037519472280955,\n 0.1225552067114784601845191268002015552281,\n 0.1225552067114784601845191268002015552281,\n 0.1009420441062871655628139849248346070628,\n 0.1009420441062871655628139849248346070628,\n 0.0764257302548890565291296776166365256053,\n 0.0764257302548890565291296776166365256053,\n 0.0497145488949697964533349462026386416808,\n 0.0497145488949697964533349462026386416808,\n 0.0216160135264833103133427102664524693876,\n 0.0216160135264833103133427102664524693876,\n ],\n [\n 0.1610544498487836959791636253209167350399,\n 0.1589688433939543476499564394650472016787,\n 0.1589688433939543476499564394650472016787,\n 0.152766042065859666778855400897662998461,\n 0.152766042065859666778855400897662998461,\n 0.1426067021736066117757461094419029724756,\n 0.1426067021736066117757461094419029724756,\n 0.1287539625393362276755157848568771170558,\n 0.1287539625393362276755157848568771170558,\n 0.1115666455473339947160239016817659974813,\n 0.1115666455473339947160239016817659974813,\n 0.0914900216224499994644620941238396526609,\n 0.0914900216224499994644620941238396526609,\n 0.0690445427376412265807082580060130449618,\n 0.0690445427376412265807082580060130449618,\n 0.0448142267656996003328381574019942119517,\n 0.0448142267656996003328381574019942119517,\n 0.0194617882297264770363120414644384357529,\n 0.0194617882297264770363120414644384357529,\n ],\n [\n 0.1527533871307258506980843319550975934919,\n 0.1527533871307258506980843319550975934919,\n 0.1491729864726037467878287370019694366926,\n 0.1491729864726037467878287370019694366926,\n 0.1420961093183820513292983250671649330345,\n 0.1420961093183820513292983250671649330345,\n 0.1316886384491766268984944997481631349161,\n 0.1316886384491766268984944997481631349161,\n 0.118194531961518417312377377711382287005,\n 0.118194531961518417312377377711382287005,\n 0.1019301198172404350367501354803498761666,\n 0.1019301198172404350367501354803498761666,\n 0.0832767415767047487247581432220462061001,\n 0.0832767415767047487247581432220462061001,\n 0.0626720483341090635695065351870416063516,\n 0.0626720483341090635695065351870416063516,\n 0.040601429800386941331039952274932109879,\n 0.040601429800386941331039952274932109879,\n 0.0176140071391521183118619623518528163621,\n 0.0176140071391521183118619623518528163621,\n ],\n [\n 0.1460811336496904271919851476833711882448,\n 0.1445244039899700590638271665537525436099,\n 0.1445244039899700590638271665537525436099,\n 0.1398873947910731547221334238675831108927,\n 0.1398873947910731547221334238675831108927,\n 0.132268938633337461781052574496775604329,\n 0.132268938633337461781052574496775604329,\n 0.1218314160537285341953671771257335983563,\n 0.1218314160537285341953671771257335983563,\n 0.1087972991671483776634745780701056420336,\n 0.1087972991671483776634745780701056420336,\n 0.0934444234560338615532897411139320884835,\n 0.0934444234560338615532897411139320884835,\n 0.0761001136283793020170516533001831792261,\n 0.0761001136283793020170516533001831792261,\n 0.0571344254268572082836358264724479574912,\n 0.0571344254268572082836358264724479574912,\n 0.0369537897708524937999506682993296661889,\n 0.0369537897708524937999506682993296661889,\n 0.0160172282577743333242246168584710152658,\n 0.0160172282577743333242246168584710152658,\n ],\n [\n 0.1392518728556319933754102483418099578739,\n 0.1392518728556319933754102483418099578739,\n 0.1365414983460151713525738312315173965863,\n 0.1365414983460151713525738312315173965863,\n 0.1311735047870623707329649925303074458757,\n 0.1311735047870623707329649925303074458757,\n 0.1232523768105124242855609861548144719594,\n 0.1232523768105124242855609861548144719594,\n 0.1129322960805392183934006074217843191142,\n 0.1129322960805392183934006074217843191142,\n 0.1004141444428809649320788378305362823508,\n 0.1004141444428809649320788378305362823508,\n 0.0859416062170677274144436813727028661891,\n 0.0859416062170677274144436813727028661891,\n 0.0697964684245204880949614189302176573987,\n 0.0697964684245204880949614189302176573987,\n 0.0522933351526832859403120512732112561121,\n 0.0522933351526832859403120512732112561121,\n 0.0337749015848141547933022468659129013491,\n 0.0337749015848141547933022468659129013491,\n 0.0146279952982722006849910980471854451902,\n 0.0146279952982722006849910980471854451902,\n ],\n [\n 0.1336545721861061753514571105458443385831,\n 0.132462039404696617371642464703316925805,\n 0.132462039404696617371642464703316925805,\n 0.1289057221880821499785953393997936532597,\n 0.1289057221880821499785953393997936532597,\n 0.1230490843067295304675784006720096548158,\n 0.1230490843067295304675784006720096548158,\n 0.1149966402224113649416435129339613014914,\n 0.1149966402224113649416435129339613014914,\n 0.1048920914645414100740861850147438548584,\n 0.1048920914645414100740861850147438548584,\n 0.0929157660600351474770186173697646486034,\n 0.0929157660600351474770186173697646486034,\n 0.0792814117767189549228925247420432269137,\n 0.0792814117767189549228925247420432269137,\n 0.0642324214085258521271696151589109980391,\n 0.0642324214085258521271696151589109980391,\n 0.0480376717310846685716410716320339965612,\n 0.0480376717310846685716410716320339965612,\n 0.0309880058569794443106942196418845053837,\n 0.0309880058569794443106942196418845053837,\n 0.0134118594871417720813094934586150649766,\n 0.0134118594871417720813094934586150649766,\n ],\n [\n 0.1279381953467521569740561652246953718517,\n 0.1279381953467521569740561652246953718517,\n 0.1258374563468282961213753825111836887264,\n 0.1258374563468282961213753825111836887264,\n 0.121670472927803391204463153476262425607,\n 0.121670472927803391204463153476262425607,\n 0.1155056680537256013533444839067835598622,\n 0.1155056680537256013533444839067835598622,\n 0.1074442701159656347825773424466062227946,\n 0.1074442701159656347825773424466062227946,\n 0.0976186521041138882698806644642471544279,\n 0.0976186521041138882698806644642471544279,\n 0.086190161531953275917185202983742667185,\n 0.086190161531953275917185202983742667185,\n 0.0733464814110803057340336152531165181193,\n 0.0733464814110803057340336152531165181193,\n 0.0592985849154367807463677585001085845412,\n 0.0592985849154367807463677585001085845412,\n 0.0442774388174198061686027482113382288593,\n 0.0442774388174198061686027482113382288593,\n 0.0285313886289336631813078159518782864491,\n 0.0285313886289336631813078159518782864491,\n 0.0123412297999871995468056670700372915759,\n 0.0123412297999871995468056670700372915759,\n ],\n];\nexports.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];\nconst getCubicArcLength = (xs, ys, t) => {\n let z;\n let sum;\n let correctedT;\n const n = 20;\n z = t / 2;\n sum = 0;\n for (let i = 0; i < n; i++) {\n correctedT = z * exports.tValues[n][i] + z;\n sum += exports.cValues[n][i] * BFunc(xs, ys, correctedT);\n }\n return z * sum;\n};\nexports.getCubicArcLength = getCubicArcLength;\nconst getQuadraticArcLength = (xs, ys, t) => {\n if (t === undefined) {\n t = 1;\n }\n const ax = xs[0] - 2 * xs[1] + xs[2];\n const ay = ys[0] - 2 * ys[1] + ys[2];\n const bx = 2 * xs[1] - 2 * xs[0];\n const by = 2 * ys[1] - 2 * ys[0];\n const A = 4 * (ax * ax + ay * ay);\n const B = 4 * (ax * bx + ay * by);\n const C = bx * bx + by * by;\n if (A === 0) {\n return (t * Math.sqrt(Math.pow(xs[2] - xs[0], 2) + Math.pow(ys[2] - ys[0], 2)));\n }\n const b = B / (2 * A);\n const c = C / A;\n const u = t + b;\n const k = c - b * b;\n const uuk = u * u + k > 0 ? Math.sqrt(u * u + k) : 0;\n const bbk = b * b + k > 0 ? Math.sqrt(b * b + k) : 0;\n const term = b + Math.sqrt(b * b + k) !== 0\n ? k * Math.log(Math.abs((u + uuk) / (b + bbk)))\n : 0;\n return (Math.sqrt(A) / 2) * (u * uuk - b * bbk + term);\n};\nexports.getQuadraticArcLength = getQuadraticArcLength;\nfunction BFunc(xs, ys, t) {\n const xbase = getDerivative(1, t, xs);\n const ybase = getDerivative(1, t, ys);\n const combined = xbase * xbase + ybase * ybase;\n return Math.sqrt(combined);\n}\nconst getDerivative = (derivative, t, vs) => {\n const n = vs.length - 1;\n let _vs;\n let value;\n if (n === 0) {\n return 0;\n }\n if (derivative === 0) {\n value = 0;\n for (let k = 0; k <= n; k++) {\n value +=\n exports.binomialCoefficients[n][k] *\n Math.pow(1 - t, n - k) *\n Math.pow(t, k) *\n vs[k];\n }\n return value;\n }\n else {\n _vs = new Array(n);\n for (let k = 0; k < n; k++) {\n _vs[k] = n * (vs[k + 1] - vs[k]);\n }\n return getDerivative(derivative - 1, t, _vs);\n }\n};\nconst t2length = (length, totalLength, func) => {\n let error = 1;\n let t = length / totalLength;\n let step = (length - func(t)) / totalLength;\n let numIterations = 0;\n while (error > 0.001) {\n const increasedTLength = func(t + step);\n const increasedTError = Math.abs(length - increasedTLength) / totalLength;\n if (increasedTError < error) {\n error = increasedTError;\n t += step;\n }\n else {\n const decreasedTLength = func(t - step);\n const decreasedTError = Math.abs(length - decreasedTLength) / totalLength;\n if (decreasedTError < error) {\n error = decreasedTError;\n t -= step;\n }\n else {\n step /= 2;\n }\n }\n numIterations++;\n if (numIterations > 500) {\n break;\n }\n }\n return t;\n};\nexports.t2length = t2length;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Path = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Global_1 = require(\"../Global\");\nconst BezierFunctions_1 = require(\"../BezierFunctions\");\nclass Path extends Shape_1.Shape {\n constructor(config) {\n super(config);\n this.dataArray = [];\n this.pathLength = 0;\n this._readDataAttribute();\n this.on('dataChange.konva', function () {\n this._readDataAttribute();\n });\n }\n _readDataAttribute() {\n this.dataArray = Path.parsePathData(this.data());\n this.pathLength = Path.getPathLength(this.dataArray);\n }\n _sceneFunc(context) {\n var ca = this.dataArray;\n context.beginPath();\n var isClosed = false;\n for (var n = 0; n < ca.length; n++) {\n var c = ca[n].command;\n var p = ca[n].points;\n switch (c) {\n case 'L':\n context.lineTo(p[0], p[1]);\n break;\n case 'M':\n context.moveTo(p[0], p[1]);\n break;\n case 'C':\n context.bezierCurveTo(p[0], p[1], p[2], p[3], p[4], p[5]);\n break;\n case 'Q':\n context.quadraticCurveTo(p[0], p[1], p[2], p[3]);\n break;\n case 'A':\n var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];\n var r = rx > ry ? rx : ry;\n var scaleX = rx > ry ? 1 : rx / ry;\n var scaleY = rx > ry ? ry / rx : 1;\n context.translate(cx, cy);\n context.rotate(psi);\n context.scale(scaleX, scaleY);\n context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);\n context.scale(1 / scaleX, 1 / scaleY);\n context.rotate(-psi);\n context.translate(-cx, -cy);\n break;\n case 'z':\n isClosed = true;\n context.closePath();\n break;\n }\n }\n if (!isClosed && !this.hasFill()) {\n context.strokeShape(this);\n }\n else {\n context.fillStrokeShape(this);\n }\n }\n getSelfRect() {\n var points = [];\n this.dataArray.forEach(function (data) {\n if (data.command === 'A') {\n var start = data.points[4];\n var dTheta = data.points[5];\n var end = data.points[4] + dTheta;\n var inc = Math.PI / 180.0;\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n if (dTheta < 0) {\n for (let t = start - inc; t > end; t -= inc) {\n const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);\n points.push(point.x, point.y);\n }\n }\n else {\n for (let t = start + inc; t < end; t += inc) {\n const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);\n points.push(point.x, point.y);\n }\n }\n }\n else if (data.command === 'C') {\n for (let t = 0.0; t <= 1; t += 0.01) {\n const point = Path.getPointOnCubicBezier(t, data.start.x, data.start.y, data.points[0], data.points[1], data.points[2], data.points[3], data.points[4], data.points[5]);\n points.push(point.x, point.y);\n }\n }\n else {\n points = points.concat(data.points);\n }\n });\n var minX = points[0];\n var maxX = points[0];\n var minY = points[1];\n var maxY = points[1];\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n if (!isNaN(x)) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n }\n if (!isNaN(y)) {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n }\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n getLength() {\n return this.pathLength;\n }\n getPointAtLength(length) {\n return Path.getPointAtLengthOfDataArray(length, this.dataArray);\n }\n static getLineLength(x1, y1, x2, y2) {\n return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n }\n static getPathLength(dataArray) {\n let pathLength = 0;\n for (var i = 0; i < dataArray.length; ++i) {\n pathLength += dataArray[i].pathLength;\n }\n return pathLength;\n }\n static getPointAtLengthOfDataArray(length, dataArray) {\n var point, i = 0, ii = dataArray.length;\n if (!ii) {\n return null;\n }\n while (i < ii && length > dataArray[i].pathLength) {\n length -= dataArray[i].pathLength;\n ++i;\n }\n if (i === ii) {\n point = dataArray[i - 1].points.slice(-2);\n return {\n x: point[0],\n y: point[1],\n };\n }\n if (length < 0.01) {\n point = dataArray[i].points.slice(0, 2);\n return {\n x: point[0],\n y: point[1],\n };\n }\n var cp = dataArray[i];\n var p = cp.points;\n switch (cp.command) {\n case 'L':\n return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);\n case 'C':\n return Path.getPointOnCubicBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {\n return (0, BezierFunctions_1.getCubicArcLength)([cp.start.x, p[0], p[2], p[4]], [cp.start.y, p[1], p[3], p[5]], i);\n }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);\n case 'Q':\n return Path.getPointOnQuadraticBezier((0, BezierFunctions_1.t2length)(length, Path.getPathLength(dataArray), (i) => {\n return (0, BezierFunctions_1.getQuadraticArcLength)([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);\n }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);\n case 'A':\n var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6];\n theta += (dTheta * length) / cp.pathLength;\n return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);\n }\n return null;\n }\n static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {\n if (fromX === undefined) {\n fromX = P1x;\n }\n if (fromY === undefined) {\n fromY = P1y;\n }\n var m = (P2y - P1y) / (P2x - P1x + 0.00000001);\n var run = Math.sqrt((dist * dist) / (1 + m * m));\n if (P2x < P1x) {\n run *= -1;\n }\n var rise = m * run;\n var pt;\n if (P2x === P1x) {\n pt = {\n x: fromX,\n y: fromY + rise,\n };\n }\n else if ((fromY - P1y) / (fromX - P1x + 0.00000001) === m) {\n pt = {\n x: fromX + run,\n y: fromY + rise,\n };\n }\n else {\n var ix, iy;\n var len = this.getLineLength(P1x, P1y, P2x, P2y);\n var u = (fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y);\n u = u / (len * len);\n ix = P1x + u * (P2x - P1x);\n iy = P1y + u * (P2y - P1y);\n var pRise = this.getLineLength(fromX, fromY, ix, iy);\n var pRun = Math.sqrt(dist * dist - pRise * pRise);\n run = Math.sqrt((pRun * pRun) / (1 + m * m));\n if (P2x < P1x) {\n run *= -1;\n }\n rise = m * run;\n pt = {\n x: ix + run,\n y: iy + rise,\n };\n }\n return pt;\n }\n static getPointOnCubicBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {\n function CB1(t) {\n return t * t * t;\n }\n function CB2(t) {\n return 3 * t * t * (1 - t);\n }\n function CB3(t) {\n return 3 * t * (1 - t) * (1 - t);\n }\n function CB4(t) {\n return (1 - t) * (1 - t) * (1 - t);\n }\n var x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);\n var y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);\n return {\n x: x,\n y: y,\n };\n }\n static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) {\n function QB1(t) {\n return t * t;\n }\n function QB2(t) {\n return 2 * t * (1 - t);\n }\n function QB3(t) {\n return (1 - t) * (1 - t);\n }\n var x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);\n var y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);\n return {\n x: x,\n y: y,\n };\n }\n static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {\n var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);\n var pt = {\n x: rx * Math.cos(theta),\n y: ry * Math.sin(theta),\n };\n return {\n x: cx + (pt.x * cosPsi - pt.y * sinPsi),\n y: cy + (pt.x * sinPsi + pt.y * cosPsi),\n };\n }\n static parsePathData(data) {\n if (!data) {\n return [];\n }\n var cs = data;\n var cc = [\n 'm',\n 'M',\n 'l',\n 'L',\n 'v',\n 'V',\n 'h',\n 'H',\n 'z',\n 'Z',\n 'c',\n 'C',\n 'q',\n 'Q',\n 't',\n 'T',\n 's',\n 'S',\n 'a',\n 'A',\n ];\n cs = cs.replace(new RegExp(' ', 'g'), ',');\n for (var n = 0; n < cc.length; n++) {\n cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);\n }\n var arr = cs.split('|');\n var ca = [];\n var coords = [];\n var cpx = 0;\n var cpy = 0;\n var re = /([-+]?((\\d+\\.\\d+)|((\\d+)|(\\.\\d+)))(?:e[-+]?\\d+)?)/gi;\n var match;\n for (n = 1; n < arr.length; n++) {\n var str = arr[n];\n var c = str.charAt(0);\n str = str.slice(1);\n coords.length = 0;\n while ((match = re.exec(str))) {\n coords.push(match[0]);\n }\n var p = [];\n for (var j = 0, jlen = coords.length; j < jlen; j++) {\n if (coords[j] === '00') {\n p.push(0, 0);\n continue;\n }\n var parsed = parseFloat(coords[j]);\n if (!isNaN(parsed)) {\n p.push(parsed);\n }\n else {\n p.push(0);\n }\n }\n while (p.length > 0) {\n if (isNaN(p[0])) {\n break;\n }\n var cmd = '';\n var points = [];\n var startX = cpx, startY = cpy;\n var prevCmd, ctlPtx, ctlPty;\n var rx, ry, psi, fa, fs, x1, y1;\n switch (c) {\n case 'l':\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'L':\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'm':\n var dx = p.shift();\n var dy = p.shift();\n cpx += dx;\n cpy += dy;\n cmd = 'M';\n if (ca.length > 2 && ca[ca.length - 1].command === 'z') {\n for (var idx = ca.length - 2; idx >= 0; idx--) {\n if (ca[idx].command === 'M') {\n cpx = ca[idx].points[0] + dx;\n cpy = ca[idx].points[1] + dy;\n break;\n }\n }\n }\n points.push(cpx, cpy);\n c = 'l';\n break;\n case 'M':\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'M';\n points.push(cpx, cpy);\n c = 'L';\n break;\n case 'h':\n cpx += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'H':\n cpx = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'v':\n cpy += p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'V':\n cpy = p.shift();\n cmd = 'L';\n points.push(cpx, cpy);\n break;\n case 'C':\n points.push(p.shift(), p.shift(), p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'c':\n points.push(cpx + p.shift(), cpy + p.shift(), cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'S':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 's':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'C') {\n ctlPtx = cpx + (cpx - prevCmd.points[2]);\n ctlPty = cpy + (cpy - prevCmd.points[3]);\n }\n points.push(ctlPtx, ctlPty, cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'C';\n points.push(cpx, cpy);\n break;\n case 'Q':\n points.push(p.shift(), p.shift());\n cpx = p.shift();\n cpy = p.shift();\n points.push(cpx, cpy);\n break;\n case 'q':\n points.push(cpx + p.shift(), cpy + p.shift());\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(cpx, cpy);\n break;\n case 'T':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 't':\n ctlPtx = cpx;\n ctlPty = cpy;\n prevCmd = ca[ca.length - 1];\n if (prevCmd.command === 'Q') {\n ctlPtx = cpx + (cpx - prevCmd.points[0]);\n ctlPty = cpy + (cpy - prevCmd.points[1]);\n }\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'Q';\n points.push(ctlPtx, ctlPty, cpx, cpy);\n break;\n case 'A':\n rx = p.shift();\n ry = p.shift();\n psi = p.shift();\n fa = p.shift();\n fs = p.shift();\n x1 = cpx;\n y1 = cpy;\n cpx = p.shift();\n cpy = p.shift();\n cmd = 'A';\n points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);\n break;\n case 'a':\n rx = p.shift();\n ry = p.shift();\n psi = p.shift();\n fa = p.shift();\n fs = p.shift();\n x1 = cpx;\n y1 = cpy;\n cpx += p.shift();\n cpy += p.shift();\n cmd = 'A';\n points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);\n break;\n }\n ca.push({\n command: cmd || c,\n points: points,\n start: {\n x: startX,\n y: startY,\n },\n pathLength: this.calcLength(startX, startY, cmd || c, points),\n });\n }\n if (c === 'z' || c === 'Z') {\n ca.push({\n command: 'z',\n points: [],\n start: undefined,\n pathLength: 0,\n });\n }\n }\n return ca;\n }\n static calcLength(x, y, cmd, points) {\n var len, p1, p2, t;\n var path = Path;\n switch (cmd) {\n case 'L':\n return path.getLineLength(x, y, points[0], points[1]);\n case 'C':\n return (0, BezierFunctions_1.getCubicArcLength)([x, points[0], points[2], points[4]], [y, points[1], points[3], points[5]], 1);\n case 'Q':\n return (0, BezierFunctions_1.getQuadraticArcLength)([x, points[0], points[2]], [y, points[1], points[3]], 1);\n case 'A':\n len = 0.0;\n var start = points[4];\n var dTheta = points[5];\n var end = points[4] + dTheta;\n var inc = Math.PI / 180.0;\n if (Math.abs(start - end) < inc) {\n inc = Math.abs(start - end);\n }\n p1 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], start, 0);\n if (dTheta < 0) {\n for (t = start - inc; t > end; t -= inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n else {\n for (t = start + inc; t < end; t += inc) {\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n p1 = p2;\n }\n }\n p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], end, 0);\n len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);\n return len;\n }\n return 0;\n }\n static convertEndpointToCenterParameterization(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {\n var psi = psiDeg * (Math.PI / 180.0);\n var xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;\n var yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +\n (Math.cos(psi) * (y1 - y2)) / 2.0;\n var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /\n (rx * rx * (yp * yp) + ry * ry * (xp * xp)));\n if (fa === fs) {\n f *= -1;\n }\n if (isNaN(f)) {\n f = 0;\n }\n var cxp = (f * rx * yp) / ry;\n var cyp = (f * -ry * xp) / rx;\n var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;\n var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;\n var vMag = function (v) {\n return Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n };\n var vRatio = function (u, v) {\n return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));\n };\n var vAngle = function (u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));\n };\n var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);\n var u = [(xp - cxp) / rx, (yp - cyp) / ry];\n var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];\n var dTheta = vAngle(u, v);\n if (vRatio(u, v) <= -1) {\n dTheta = Math.PI;\n }\n if (vRatio(u, v) >= 1) {\n dTheta = 0;\n }\n if (fs === 0 && dTheta > 0) {\n dTheta = dTheta - 2 * Math.PI;\n }\n if (fs === 1 && dTheta < 0) {\n dTheta = dTheta + 2 * Math.PI;\n }\n return [cx, cy, rx, ry, theta, dTheta, psi, fs];\n }\n}\nexports.Path = Path;\nPath.prototype.className = 'Path';\nPath.prototype._attrsAffectingSize = ['data'];\n(0, Global_1._registerNode)(Path);\nFactory_1.Factory.addGetterSetter(Path, 'data');\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Arrow = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Line_1 = require(\"./Line\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nconst Path_1 = require(\"./Path\");\nclass Arrow extends Line_1.Line {\n _sceneFunc(ctx) {\n super._sceneFunc(ctx);\n var PI2 = Math.PI * 2;\n var points = this.points();\n var tp = points;\n var fromTension = this.tension() !== 0 && points.length > 4;\n if (fromTension) {\n tp = this.getTensionPoints();\n }\n var length = this.pointerLength();\n var n = points.length;\n var dx, dy;\n if (fromTension) {\n const lp = [\n tp[tp.length - 4],\n tp[tp.length - 3],\n tp[tp.length - 2],\n tp[tp.length - 1],\n points[n - 2],\n points[n - 1],\n ];\n const lastLength = Path_1.Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);\n const previous = Path_1.Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);\n dx = points[n - 2] - previous.x;\n dy = points[n - 1] - previous.y;\n }\n else {\n dx = points[n - 2] - points[n - 4];\n dy = points[n - 1] - points[n - 3];\n }\n var radians = (Math.atan2(dy, dx) + PI2) % PI2;\n var width = this.pointerWidth();\n if (this.pointerAtEnding()) {\n ctx.save();\n ctx.beginPath();\n ctx.translate(points[n - 2], points[n - 1]);\n ctx.rotate(radians);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n this.__fillStroke(ctx);\n }\n if (this.pointerAtBeginning()) {\n ctx.save();\n ctx.beginPath();\n ctx.translate(points[0], points[1]);\n if (fromTension) {\n dx = (tp[0] + tp[2]) / 2 - points[0];\n dy = (tp[1] + tp[3]) / 2 - points[1];\n }\n else {\n dx = points[2] - points[0];\n dy = points[3] - points[1];\n }\n ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);\n ctx.moveTo(0, 0);\n ctx.lineTo(-length, width / 2);\n ctx.lineTo(-length, -width / 2);\n ctx.closePath();\n ctx.restore();\n this.__fillStroke(ctx);\n }\n }\n __fillStroke(ctx) {\n var isDashEnabled = this.dashEnabled();\n if (isDashEnabled) {\n this.attrs.dashEnabled = false;\n ctx.setLineDash([]);\n }\n ctx.fillStrokeShape(this);\n if (isDashEnabled) {\n this.attrs.dashEnabled = true;\n }\n }\n getSelfRect() {\n const lineRect = super.getSelfRect();\n const offset = this.pointerWidth() / 2;\n return {\n x: lineRect.x - offset,\n y: lineRect.y - offset,\n width: lineRect.width + offset * 2,\n height: lineRect.height + offset * 2,\n };\n }\n}\nexports.Arrow = Arrow;\nArrow.prototype.className = 'Arrow';\n(0, Global_1._registerNode)(Arrow);\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerLength', 10, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerWidth', 10, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);\nFactory_1.Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Circle = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nclass Circle extends Shape_1.Shape {\n _sceneFunc(context) {\n context.beginPath();\n context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.radius() * 2;\n }\n getHeight() {\n return this.radius() * 2;\n }\n setWidth(width) {\n if (this.radius() !== width / 2) {\n this.radius(width / 2);\n }\n }\n setHeight(height) {\n if (this.radius() !== height / 2) {\n this.radius(height / 2);\n }\n }\n}\nexports.Circle = Circle;\nCircle.prototype._centroid = true;\nCircle.prototype.className = 'Circle';\nCircle.prototype._attrsAffectingSize = ['radius'];\n(0, Global_1._registerNode)(Circle);\nFactory_1.Factory.addGetterSetter(Circle, 'radius', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Ellipse = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nclass Ellipse extends Shape_1.Shape {\n _sceneFunc(context) {\n var rx = this.radiusX(), ry = this.radiusY();\n context.beginPath();\n context.save();\n if (rx !== ry) {\n context.scale(1, ry / rx);\n }\n context.arc(0, 0, rx, 0, Math.PI * 2, false);\n context.restore();\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.radiusX() * 2;\n }\n getHeight() {\n return this.radiusY() * 2;\n }\n setWidth(width) {\n this.radiusX(width / 2);\n }\n setHeight(height) {\n this.radiusY(height / 2);\n }\n}\nexports.Ellipse = Ellipse;\nEllipse.prototype.className = 'Ellipse';\nEllipse.prototype._centroid = true;\nEllipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];\n(0, Global_1._registerNode)(Ellipse);\nFactory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);\nFactory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Image = void 0;\nconst Util_1 = require(\"../Util\");\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Global_1 = require(\"../Global\");\nconst Validators_1 = require(\"../Validators\");\nclass Image extends Shape_1.Shape {\n constructor(attrs) {\n super(attrs);\n this.on('imageChange.konva', () => {\n this._setImageLoad();\n });\n this._setImageLoad();\n }\n _setImageLoad() {\n const image = this.image();\n if (image && image.complete) {\n return;\n }\n if (image && image.readyState === 4) {\n return;\n }\n if (image && image['addEventListener']) {\n image['addEventListener']('load', () => {\n this._requestDraw();\n });\n }\n }\n _useBufferCanvas() {\n return super._useBufferCanvas(true);\n }\n _sceneFunc(context) {\n const width = this.getWidth();\n const height = this.getHeight();\n const cornerRadius = this.cornerRadius();\n const image = this.attrs.image;\n let params;\n if (image) {\n const cropWidth = this.attrs.cropWidth;\n const cropHeight = this.attrs.cropHeight;\n if (cropWidth && cropHeight) {\n params = [\n image,\n this.cropX(),\n this.cropY(),\n cropWidth,\n cropHeight,\n 0,\n 0,\n width,\n height,\n ];\n }\n else {\n params = [image, 0, 0, width, height];\n }\n }\n if (this.hasFill() || this.hasStroke() || cornerRadius) {\n context.beginPath();\n cornerRadius\n ? Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius)\n : context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n if (cornerRadius) {\n context.clip();\n }\n context.drawImage.apply(context, params);\n }\n }\n _hitFunc(context) {\n var width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();\n context.beginPath();\n if (!cornerRadius) {\n context.rect(0, 0, width, height);\n }\n else {\n Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n var _a, _b;\n return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;\n }\n getHeight() {\n var _a, _b;\n return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;\n }\n static fromURL(url, callback, onError = null) {\n var img = Util_1.Util.createImageElement();\n img.onload = function () {\n var image = new Image({\n image: img,\n });\n callback(image);\n };\n img.onerror = onError;\n img.crossOrigin = 'Anonymous';\n img.src = url;\n }\n}\nexports.Image = Image;\nImage.prototype.className = 'Image';\n(0, Global_1._registerNode)(Image);\nFactory_1.Factory.addGetterSetter(Image, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));\nFactory_1.Factory.addGetterSetter(Image, 'image');\nFactory_1.Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);\nFactory_1.Factory.addGetterSetter(Image, 'cropX', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Image, 'cropY', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Image, 'cropWidth', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Image, 'cropHeight', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Tag = exports.Label = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Group_1 = require(\"../Group\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nvar ATTR_CHANGE_LIST = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'padding',\n 'lineHeight',\n 'text',\n 'width',\n 'height',\n 'pointerDirection',\n 'pointerWidth',\n 'pointerHeight',\n], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;\nclass Label extends Group_1.Group {\n constructor(config) {\n super(config);\n this.on('add.konva', function (evt) {\n this._addListeners(evt.child);\n this._sync();\n });\n }\n getText() {\n return this.find('Text')[0];\n }\n getTag() {\n return this.find('Tag')[0];\n }\n _addListeners(text) {\n var that = this, n;\n var func = function () {\n that._sync();\n };\n for (n = 0; n < attrChangeListLen; n++) {\n text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);\n }\n }\n getWidth() {\n return this.getText().width();\n }\n getHeight() {\n return this.getText().height();\n }\n _sync() {\n var text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;\n if (text && tag) {\n width = text.width();\n height = text.height();\n pointerDirection = tag.pointerDirection();\n pointerWidth = tag.pointerWidth();\n pointerHeight = tag.pointerHeight();\n x = 0;\n y = 0;\n switch (pointerDirection) {\n case UP:\n x = width / 2;\n y = -1 * pointerHeight;\n break;\n case RIGHT:\n x = width + pointerWidth;\n y = height / 2;\n break;\n case DOWN:\n x = width / 2;\n y = height + pointerHeight;\n break;\n case LEFT:\n x = -1 * pointerWidth;\n y = height / 2;\n break;\n }\n tag.setAttrs({\n x: -1 * x,\n y: -1 * y,\n width: width,\n height: height,\n });\n text.setAttrs({\n x: -1 * x,\n y: -1 * y,\n });\n }\n }\n}\nexports.Label = Label;\nLabel.prototype.className = 'Label';\n(0, Global_1._registerNode)(Label);\nclass Tag extends Shape_1.Shape {\n _sceneFunc(context) {\n var width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();\n let topLeft = 0;\n let topRight = 0;\n let bottomLeft = 0;\n let bottomRight = 0;\n if (typeof cornerRadius === 'number') {\n topLeft =\n topRight =\n bottomLeft =\n bottomRight =\n Math.min(cornerRadius, width / 2, height / 2);\n }\n else {\n topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);\n topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);\n bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);\n bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);\n }\n context.beginPath();\n context.moveTo(topLeft, 0);\n if (pointerDirection === UP) {\n context.lineTo((width - pointerWidth) / 2, 0);\n context.lineTo(width / 2, -1 * pointerHeight);\n context.lineTo((width + pointerWidth) / 2, 0);\n }\n context.lineTo(width - topRight, 0);\n context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);\n if (pointerDirection === RIGHT) {\n context.lineTo(width, (height - pointerHeight) / 2);\n context.lineTo(width + pointerWidth, height / 2);\n context.lineTo(width, (height + pointerHeight) / 2);\n }\n context.lineTo(width, height - bottomRight);\n context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);\n if (pointerDirection === DOWN) {\n context.lineTo((width + pointerWidth) / 2, height);\n context.lineTo(width / 2, height + pointerHeight);\n context.lineTo((width - pointerWidth) / 2, height);\n }\n context.lineTo(bottomLeft, height);\n context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);\n if (pointerDirection === LEFT) {\n context.lineTo(0, (height + pointerHeight) / 2);\n context.lineTo(-1 * pointerWidth, height / 2);\n context.lineTo(0, (height - pointerHeight) / 2);\n }\n context.lineTo(0, topLeft);\n context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getSelfRect() {\n var x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();\n if (direction === UP) {\n y -= pointerHeight;\n height += pointerHeight;\n }\n else if (direction === DOWN) {\n height += pointerHeight;\n }\n else if (direction === LEFT) {\n x -= pointerWidth * 1.5;\n width += pointerWidth;\n }\n else if (direction === RIGHT) {\n width += pointerWidth * 1.5;\n }\n return {\n x: x,\n y: y,\n width: width,\n height: height,\n };\n }\n}\nexports.Tag = Tag;\nTag.prototype.className = 'Tag';\n(0, Global_1._registerNode)(Tag);\nFactory_1.Factory.addGetterSetter(Tag, 'pointerDirection', NONE);\nFactory_1.Factory.addGetterSetter(Tag, 'pointerWidth', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Tag, 'pointerHeight', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Tag, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Rect = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Global_1 = require(\"../Global\");\nconst Util_1 = require(\"../Util\");\nconst Validators_1 = require(\"../Validators\");\nclass Rect extends Shape_1.Shape {\n _sceneFunc(context) {\n var cornerRadius = this.cornerRadius(), width = this.width(), height = this.height();\n context.beginPath();\n if (!cornerRadius) {\n context.rect(0, 0, width, height);\n }\n else {\n Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n}\nexports.Rect = Rect;\nRect.prototype.className = 'Rect';\n(0, Global_1._registerNode)(Rect);\nFactory_1.Factory.addGetterSetter(Rect, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.RegularPolygon = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nclass RegularPolygon extends Shape_1.Shape {\n _sceneFunc(context) {\n const points = this._getPoints();\n context.beginPath();\n context.moveTo(points[0].x, points[0].y);\n for (var n = 1; n < points.length; n++) {\n context.lineTo(points[n].x, points[n].y);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n _getPoints() {\n const sides = this.attrs.sides;\n const radius = this.attrs.radius || 0;\n const points = [];\n for (var n = 0; n < sides; n++) {\n points.push({\n x: radius * Math.sin((n * 2 * Math.PI) / sides),\n y: -1 * radius * Math.cos((n * 2 * Math.PI) / sides),\n });\n }\n return points;\n }\n getSelfRect() {\n const points = this._getPoints();\n var minX = points[0].x;\n var maxX = points[0].y;\n var minY = points[0].x;\n var maxY = points[0].y;\n points.forEach((point) => {\n minX = Math.min(minX, point.x);\n maxX = Math.max(maxX, point.x);\n minY = Math.min(minY, point.y);\n maxY = Math.max(maxY, point.y);\n });\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n getWidth() {\n return this.radius() * 2;\n }\n getHeight() {\n return this.radius() * 2;\n }\n setWidth(width) {\n this.radius(width / 2);\n }\n setHeight(height) {\n this.radius(height / 2);\n }\n}\nexports.RegularPolygon = RegularPolygon;\nRegularPolygon.prototype.className = 'RegularPolygon';\nRegularPolygon.prototype._centroid = true;\nRegularPolygon.prototype._attrsAffectingSize = ['radius'];\n(0, Global_1._registerNode)(RegularPolygon);\nFactory_1.Factory.addGetterSetter(RegularPolygon, 'radius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(RegularPolygon, 'sides', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Ring = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nvar PIx2 = Math.PI * 2;\nclass Ring extends Shape_1.Shape {\n _sceneFunc(context) {\n context.beginPath();\n context.arc(0, 0, this.innerRadius(), 0, PIx2, false);\n context.moveTo(this.outerRadius(), 0);\n context.arc(0, 0, this.outerRadius(), PIx2, 0, true);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.outerRadius() * 2;\n }\n getHeight() {\n return this.outerRadius() * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n}\nexports.Ring = Ring;\nRing.prototype.className = 'Ring';\nRing.prototype._centroid = true;\nRing.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\n(0, Global_1._registerNode)(Ring);\nFactory_1.Factory.addGetterSetter(Ring, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Ring, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Sprite = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Animation_1 = require(\"../Animation\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nclass Sprite extends Shape_1.Shape {\n constructor(config) {\n super(config);\n this._updated = true;\n this.anim = new Animation_1.Animation(() => {\n var updated = this._updated;\n this._updated = false;\n return updated;\n });\n this.on('animationChange.konva', function () {\n this.frameIndex(0);\n });\n this.on('frameIndexChange.konva', function () {\n this._updated = true;\n });\n this.on('frameRateChange.konva', function () {\n if (!this.anim.isRunning()) {\n return;\n }\n clearInterval(this.interval);\n this._setInterval();\n });\n }\n _sceneFunc(context) {\n var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), x = set[ix4 + 0], y = set[ix4 + 1], width = set[ix4 + 2], height = set[ix4 + 3], image = this.image();\n if (this.hasFill() || this.hasStroke()) {\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n if (image) {\n if (offsets) {\n var offset = offsets[anim], ix2 = index * 2;\n context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);\n }\n else {\n context.drawImage(image, x, y, width, height, 0, 0, width, height);\n }\n }\n }\n _hitFunc(context) {\n var anim = this.animation(), index = this.frameIndex(), ix4 = index * 4, set = this.animations()[anim], offsets = this.frameOffsets(), width = set[ix4 + 2], height = set[ix4 + 3];\n context.beginPath();\n if (offsets) {\n var offset = offsets[anim];\n var ix2 = index * 2;\n context.rect(offset[ix2 + 0], offset[ix2 + 1], width, height);\n }\n else {\n context.rect(0, 0, width, height);\n }\n context.closePath();\n context.fillShape(this);\n }\n _useBufferCanvas() {\n return super._useBufferCanvas(true);\n }\n _setInterval() {\n var that = this;\n this.interval = setInterval(function () {\n that._updateIndex();\n }, 1000 / this.frameRate());\n }\n start() {\n if (this.isRunning()) {\n return;\n }\n var layer = this.getLayer();\n this.anim.setLayers(layer);\n this._setInterval();\n this.anim.start();\n }\n stop() {\n this.anim.stop();\n clearInterval(this.interval);\n }\n isRunning() {\n return this.anim.isRunning();\n }\n _updateIndex() {\n var index = this.frameIndex(), animation = this.animation(), animations = this.animations(), anim = animations[animation], len = anim.length / 4;\n if (index < len - 1) {\n this.frameIndex(index + 1);\n }\n else {\n this.frameIndex(0);\n }\n }\n}\nexports.Sprite = Sprite;\nSprite.prototype.className = 'Sprite';\n(0, Global_1._registerNode)(Sprite);\nFactory_1.Factory.addGetterSetter(Sprite, 'animation');\nFactory_1.Factory.addGetterSetter(Sprite, 'animations');\nFactory_1.Factory.addGetterSetter(Sprite, 'frameOffsets');\nFactory_1.Factory.addGetterSetter(Sprite, 'image');\nFactory_1.Factory.addGetterSetter(Sprite, 'frameIndex', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Sprite, 'frameRate', 17, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.backCompat(Sprite, {\n index: 'frameIndex',\n getIndex: 'getFrameIndex',\n setIndex: 'setFrameIndex',\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Star = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nclass Star extends Shape_1.Shape {\n _sceneFunc(context) {\n var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();\n context.beginPath();\n context.moveTo(0, 0 - outerRadius);\n for (var n = 1; n < numPoints * 2; n++) {\n var radius = n % 2 === 0 ? outerRadius : innerRadius;\n var x = radius * Math.sin((n * Math.PI) / numPoints);\n var y = -1 * radius * Math.cos((n * Math.PI) / numPoints);\n context.lineTo(x, y);\n }\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.outerRadius() * 2;\n }\n getHeight() {\n return this.outerRadius() * 2;\n }\n setWidth(width) {\n this.outerRadius(width / 2);\n }\n setHeight(height) {\n this.outerRadius(height / 2);\n }\n}\nexports.Star = Star;\nStar.prototype.className = 'Star';\nStar.prototype._centroid = true;\nStar.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];\n(0, Global_1._registerNode)(Star);\nFactory_1.Factory.addGetterSetter(Star, 'numPoints', 5, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Star, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Star, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Text = exports.stringToArray = void 0;\nconst Util_1 = require(\"../Util\");\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nfunction stringToArray(string) {\n return Array.from(string);\n}\nexports.stringToArray = stringToArray;\nvar AUTO = 'auto', CENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', LTR = 'ltr', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', RTL = 'rtl', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [\n 'direction',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'padding',\n 'align',\n 'verticalAlign',\n 'lineHeight',\n 'text',\n 'width',\n 'height',\n 'wrap',\n 'ellipsis',\n 'letterSpacing',\n], attrChangeListLen = ATTR_CHANGE_LIST.length;\nfunction normalizeFontFamily(fontFamily) {\n return fontFamily\n .split(',')\n .map((family) => {\n family = family.trim();\n const hasSpace = family.indexOf(' ') >= 0;\n const hasQuotes = family.indexOf('\"') >= 0 || family.indexOf(\"'\") >= 0;\n if (hasSpace && !hasQuotes) {\n family = `\"${family}\"`;\n }\n return family;\n })\n .join(', ');\n}\nvar dummyContext;\nfunction getDummyContext() {\n if (dummyContext) {\n return dummyContext;\n }\n dummyContext = Util_1.Util.createCanvasElement().getContext(CONTEXT_2D);\n return dummyContext;\n}\nfunction _fillFunc(context) {\n context.fillText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction _strokeFunc(context) {\n context.setAttr('miterLimit', 2);\n context.strokeText(this._partialText, this._partialTextX, this._partialTextY);\n}\nfunction checkDefaultFill(config) {\n config = config || {};\n if (!config.fillLinearGradientColorStops &&\n !config.fillRadialGradientColorStops &&\n !config.fillPatternImage) {\n config.fill = config.fill || 'black';\n }\n return config;\n}\nclass Text extends Shape_1.Shape {\n constructor(config) {\n super(checkDefaultFill(config));\n this._partialTextX = 0;\n this._partialTextY = 0;\n for (var n = 0; n < attrChangeListLen; n++) {\n this.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, this._setTextData);\n }\n this._setTextData();\n }\n _sceneFunc(context) {\n var textArr = this.textArr, textArrLen = textArr.length;\n if (!this.text()) {\n return;\n }\n var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;\n direction = direction === INHERIT ? context.direction : direction;\n var translateY = 0;\n var translateY = lineHeightPx / 2;\n var lineTranslateX = 0;\n var lineTranslateY = 0;\n if (direction === RTL) {\n context.setAttr('direction', direction);\n }\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', MIDDLE);\n context.setAttr('textAlign', LEFT);\n if (verticalAlign === MIDDLE) {\n alignY = (this.getHeight() - textArrLen * lineHeightPx - padding * 2) / 2;\n }\n else if (verticalAlign === BOTTOM) {\n alignY = this.getHeight() - textArrLen * lineHeightPx - padding * 2;\n }\n context.translate(padding, alignY + padding);\n for (n = 0; n < textArrLen; n++) {\n var lineTranslateX = 0;\n var lineTranslateY = 0;\n var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, oneWord, lineWidth;\n context.save();\n if (align === RIGHT) {\n lineTranslateX += totalWidth - width - padding * 2;\n }\n else if (align === CENTER) {\n lineTranslateX += (totalWidth - width - padding * 2) / 2;\n }\n if (shouldUnderline) {\n context.save();\n context.beginPath();\n context.moveTo(lineTranslateX, translateY + lineTranslateY + Math.round(fontSize / 2));\n spacesNumber = text.split(' ').length - 1;\n oneWord = spacesNumber === 0;\n lineWidth =\n align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;\n context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + Math.round(fontSize / 2));\n context.lineWidth = fontSize / 15;\n const gradient = this._getLinearGradient();\n context.strokeStyle = gradient || fill;\n context.stroke();\n context.restore();\n }\n if (shouldLineThrough) {\n context.save();\n context.beginPath();\n context.moveTo(lineTranslateX, translateY + lineTranslateY);\n spacesNumber = text.split(' ').length - 1;\n oneWord = spacesNumber === 0;\n lineWidth =\n align === JUSTIFY && lastLine && !oneWord\n ? totalWidth - padding * 2\n : width;\n context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY);\n context.lineWidth = fontSize / 15;\n const gradient = this._getLinearGradient();\n context.strokeStyle = gradient || fill;\n context.stroke();\n context.restore();\n }\n if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {\n spacesNumber = text.split(' ').length - 1;\n var array = stringToArray(text);\n for (var li = 0; li < array.length; li++) {\n var letter = array[li];\n if (letter === ' ' && !lastLine && align === JUSTIFY) {\n lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;\n }\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = letter;\n context.fillStrokeShape(this);\n lineTranslateX += this.measureSize(letter).width + letterSpacing;\n }\n }\n else {\n if (letterSpacing !== 0) {\n context.setAttr('letterSpacing', `${letterSpacing}px`);\n }\n this._partialTextX = lineTranslateX;\n this._partialTextY = translateY + lineTranslateY;\n this._partialText = text;\n context.fillStrokeShape(this);\n }\n context.restore();\n if (textArrLen > 1) {\n translateY += lineHeightPx;\n }\n }\n }\n _hitFunc(context) {\n var width = this.getWidth(), height = this.getHeight();\n context.beginPath();\n context.rect(0, 0, width, height);\n context.closePath();\n context.fillStrokeShape(this);\n }\n setText(text) {\n var str = Util_1.Util._isString(text)\n ? text\n : text === null || text === undefined\n ? ''\n : text + '';\n this._setAttr(TEXT, str);\n return this;\n }\n getWidth() {\n var isAuto = this.attrs.width === AUTO || this.attrs.width === undefined;\n return isAuto ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;\n }\n getHeight() {\n var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;\n return isAuto\n ? this.fontSize() * this.textArr.length * this.lineHeight() +\n this.padding() * 2\n : this.attrs.height;\n }\n getTextWidth() {\n return this.textWidth;\n }\n getTextHeight() {\n Util_1.Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n }\n measureSize(text) {\n var _context = getDummyContext(), fontSize = this.fontSize(), metrics;\n _context.save();\n _context.font = this._getContextFont();\n metrics = _context.measureText(text);\n _context.restore();\n return {\n width: metrics.width,\n height: fontSize,\n };\n }\n _getContextFont() {\n return (this.fontStyle() +\n SPACE +\n this.fontVariant() +\n SPACE +\n (this.fontSize() + PX_SPACE) +\n normalizeFontFamily(this.fontFamily()));\n }\n _addTextLine(line) {\n const align = this.align();\n if (align === JUSTIFY) {\n line = line.trim();\n }\n var width = this._getTextWidth(line);\n return this.textArr.push({\n text: line,\n width: width,\n lastInParagraph: false,\n });\n }\n _getTextWidth(text) {\n var letterSpacing = this.letterSpacing();\n var length = text.length;\n return (getDummyContext().measureText(text).width +\n (length ? letterSpacing * (length - 1) : 0));\n }\n _setTextData() {\n var lines = this.text().split('\\n'), fontSize = +this.fontSize(), textWidth = 0, lineHeightPx = this.lineHeight() * fontSize, width = this.attrs.width, height = this.attrs.height, fixedWidth = width !== AUTO && width !== undefined, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxWidth = width - padding * 2, maxHeightPx = height - padding * 2, currentHeightPx = 0, wrap = this.wrap(), shouldWrap = wrap !== NONE, wrapAtWord = wrap !== CHAR && shouldWrap, shouldAddEllipsis = this.ellipsis();\n this.textArr = [];\n getDummyContext().font = this._getContextFont();\n var additionalWidth = shouldAddEllipsis ? this._getTextWidth(ELLIPSIS) : 0;\n for (var i = 0, max = lines.length; i < max; ++i) {\n var line = lines[i];\n var lineWidth = this._getTextWidth(line);\n if (fixedWidth && lineWidth > maxWidth) {\n while (line.length > 0) {\n var low = 0, high = line.length, match = '', matchWidth = 0;\n while (low < high) {\n var mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;\n if (substrWidth <= maxWidth) {\n low = mid + 1;\n match = substr;\n matchWidth = substrWidth;\n }\n else {\n high = mid;\n }\n }\n if (match) {\n if (wrapAtWord) {\n var wrapIndex;\n var nextChar = line[match.length];\n var nextIsSpaceOrDash = nextChar === SPACE || nextChar === DASH;\n if (nextIsSpaceOrDash && matchWidth <= maxWidth) {\n wrapIndex = match.length;\n }\n else {\n wrapIndex =\n Math.max(match.lastIndexOf(SPACE), match.lastIndexOf(DASH)) +\n 1;\n }\n if (wrapIndex > 0) {\n low = wrapIndex;\n match = match.slice(0, low);\n matchWidth = this._getTextWidth(match);\n }\n }\n match = match.trimRight();\n this._addTextLine(match);\n textWidth = Math.max(textWidth, matchWidth);\n currentHeightPx += lineHeightPx;\n var shouldHandleEllipsis = this._shouldHandleEllipsis(currentHeightPx);\n if (shouldHandleEllipsis) {\n this._tryToAddEllipsisToLastLine();\n break;\n }\n line = line.slice(low);\n line = line.trimLeft();\n if (line.length > 0) {\n lineWidth = this._getTextWidth(line);\n if (lineWidth <= maxWidth) {\n this._addTextLine(line);\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, lineWidth);\n break;\n }\n }\n }\n else {\n break;\n }\n }\n }\n else {\n this._addTextLine(line);\n currentHeightPx += lineHeightPx;\n textWidth = Math.max(textWidth, lineWidth);\n if (this._shouldHandleEllipsis(currentHeightPx) && i < max - 1) {\n this._tryToAddEllipsisToLastLine();\n }\n }\n if (this.textArr[this.textArr.length - 1]) {\n this.textArr[this.textArr.length - 1].lastInParagraph = true;\n }\n if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {\n break;\n }\n }\n this.textHeight = fontSize;\n this.textWidth = textWidth;\n }\n _shouldHandleEllipsis(currentHeightPx) {\n var fontSize = +this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, height = this.attrs.height, fixedHeight = height !== AUTO && height !== undefined, padding = this.padding(), maxHeightPx = height - padding * 2, wrap = this.wrap(), shouldWrap = wrap !== NONE;\n return (!shouldWrap ||\n (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx));\n }\n _tryToAddEllipsisToLastLine() {\n var width = this.attrs.width, fixedWidth = width !== AUTO && width !== undefined, padding = this.padding(), maxWidth = width - padding * 2, shouldAddEllipsis = this.ellipsis();\n var lastLine = this.textArr[this.textArr.length - 1];\n if (!lastLine || !shouldAddEllipsis) {\n return;\n }\n if (fixedWidth) {\n var haveSpace = this._getTextWidth(lastLine.text + ELLIPSIS) < maxWidth;\n if (!haveSpace) {\n lastLine.text = lastLine.text.slice(0, lastLine.text.length - 3);\n }\n }\n this.textArr.splice(this.textArr.length - 1, 1);\n this._addTextLine(lastLine.text + ELLIPSIS);\n }\n getStrokeScaleEnabled() {\n return true;\n }\n _useBufferCanvas() {\n const hasLine = this.textDecoration().indexOf('underline') !== -1 ||\n this.textDecoration().indexOf('line-through') !== -1;\n const hasShadow = this.hasShadow();\n if (hasLine && hasShadow) {\n return true;\n }\n return super._useBufferCanvas();\n }\n}\nexports.Text = Text;\nText.prototype._fillFunc = _fillFunc;\nText.prototype._strokeFunc = _strokeFunc;\nText.prototype.className = TEXT_UPPER;\nText.prototype._attrsAffectingSize = [\n 'text',\n 'fontSize',\n 'padding',\n 'wrap',\n 'lineHeight',\n 'letterSpacing',\n];\n(0, Global_1._registerNode)(Text);\nFactory_1.Factory.overWriteSetter(Text, 'width', (0, Validators_1.getNumberOrAutoValidator)());\nFactory_1.Factory.overWriteSetter(Text, 'height', (0, Validators_1.getNumberOrAutoValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'direction', INHERIT);\nFactory_1.Factory.addGetterSetter(Text, 'fontFamily', 'Arial');\nFactory_1.Factory.addGetterSetter(Text, 'fontSize', 12, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'fontStyle', NORMAL);\nFactory_1.Factory.addGetterSetter(Text, 'fontVariant', NORMAL);\nFactory_1.Factory.addGetterSetter(Text, 'padding', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'align', LEFT);\nFactory_1.Factory.addGetterSetter(Text, 'verticalAlign', TOP);\nFactory_1.Factory.addGetterSetter(Text, 'lineHeight', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'wrap', WORD);\nFactory_1.Factory.addGetterSetter(Text, 'ellipsis', false, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'letterSpacing', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'text', '', (0, Validators_1.getStringValidator)());\nFactory_1.Factory.addGetterSetter(Text, 'textDecoration', '');\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.TextPath = void 0;\nconst Util_1 = require(\"../Util\");\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Path_1 = require(\"./Path\");\nconst Text_1 = require(\"./Text\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_1 = require(\"../Global\");\nvar EMPTY_STRING = '', NORMAL = 'normal';\nfunction _fillFunc(context) {\n context.fillText(this.partialText, 0, 0);\n}\nfunction _strokeFunc(context) {\n context.strokeText(this.partialText, 0, 0);\n}\nclass TextPath extends Shape_1.Shape {\n constructor(config) {\n super(config);\n this.dummyCanvas = Util_1.Util.createCanvasElement();\n this.dataArray = [];\n this._readDataAttribute();\n this.on('dataChange.konva', function () {\n this._readDataAttribute();\n this._setTextData();\n });\n this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);\n this._setTextData();\n }\n _getTextPathLength() {\n return Path_1.Path.getPathLength(this.dataArray);\n }\n _getPointAtLength(length) {\n if (!this.attrs.data) {\n return null;\n }\n const totalLength = this.pathLength;\n if (length - 1 > totalLength) {\n return null;\n }\n return Path_1.Path.getPointAtLengthOfDataArray(length, this.dataArray);\n }\n _readDataAttribute() {\n this.dataArray = Path_1.Path.parsePathData(this.attrs.data);\n this.pathLength = this._getTextPathLength();\n }\n _sceneFunc(context) {\n context.setAttr('font', this._getContextFont());\n context.setAttr('textBaseline', this.textBaseline());\n context.setAttr('textAlign', 'left');\n context.save();\n var textDecoration = this.textDecoration();\n var fill = this.fill();\n var fontSize = this.fontSize();\n var glyphInfo = this.glyphInfo;\n if (textDecoration === 'underline') {\n context.beginPath();\n }\n for (var i = 0; i < glyphInfo.length; i++) {\n context.save();\n var p0 = glyphInfo[i].p0;\n context.translate(p0.x, p0.y);\n context.rotate(glyphInfo[i].rotation);\n this.partialText = glyphInfo[i].text;\n context.fillStrokeShape(this);\n if (textDecoration === 'underline') {\n if (i === 0) {\n context.moveTo(0, fontSize / 2 + 1);\n }\n context.lineTo(fontSize, fontSize / 2 + 1);\n }\n context.restore();\n }\n if (textDecoration === 'underline') {\n context.strokeStyle = fill;\n context.lineWidth = fontSize / 20;\n context.stroke();\n }\n context.restore();\n }\n _hitFunc(context) {\n context.beginPath();\n var glyphInfo = this.glyphInfo;\n if (glyphInfo.length >= 1) {\n var p0 = glyphInfo[0].p0;\n context.moveTo(p0.x, p0.y);\n }\n for (var i = 0; i < glyphInfo.length; i++) {\n var p1 = glyphInfo[i].p1;\n context.lineTo(p1.x, p1.y);\n }\n context.setAttr('lineWidth', this.fontSize());\n context.setAttr('strokeStyle', this.colorKey);\n context.stroke();\n }\n getTextWidth() {\n return this.textWidth;\n }\n getTextHeight() {\n Util_1.Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');\n return this.textHeight;\n }\n setText(text) {\n return Text_1.Text.prototype.setText.call(this, text);\n }\n _getContextFont() {\n return Text_1.Text.prototype._getContextFont.call(this);\n }\n _getTextSize(text) {\n var dummyCanvas = this.dummyCanvas;\n var _context = dummyCanvas.getContext('2d');\n _context.save();\n _context.font = this._getContextFont();\n var metrics = _context.measureText(text);\n _context.restore();\n return {\n width: metrics.width,\n height: parseInt(`${this.fontSize()}`, 10),\n };\n }\n _setTextData() {\n const { width, height } = this._getTextSize(this.attrs.text);\n this.textWidth = width;\n this.textHeight = height;\n this.glyphInfo = [];\n if (!this.attrs.data) {\n return null;\n }\n const letterSpacing = this.letterSpacing();\n const align = this.align();\n const kerningFunc = this.kerningFunc();\n const textWidth = Math.max(this.textWidth + ((this.attrs.text || '').length - 1) * letterSpacing, 0);\n let offset = 0;\n if (align === 'center') {\n offset = Math.max(0, this.pathLength / 2 - textWidth / 2);\n }\n if (align === 'right') {\n offset = Math.max(0, this.pathLength - textWidth);\n }\n const charArr = (0, Text_1.stringToArray)(this.text());\n let offsetToGlyph = offset;\n for (var i = 0; i < charArr.length; i++) {\n const charStartPoint = this._getPointAtLength(offsetToGlyph);\n if (!charStartPoint)\n return;\n let glyphWidth = this._getTextSize(charArr[i]).width + letterSpacing;\n if (charArr[i] === ' ' && align === 'justify') {\n const numberOfSpaces = this.text().split(' ').length - 1;\n glyphWidth += (this.pathLength - textWidth) / numberOfSpaces;\n }\n const charEndPoint = this._getPointAtLength(offsetToGlyph + glyphWidth);\n if (!charEndPoint)\n return;\n const width = Path_1.Path.getLineLength(charStartPoint.x, charStartPoint.y, charEndPoint.x, charEndPoint.y);\n let kern = 0;\n if (kerningFunc) {\n try {\n kern = kerningFunc(charArr[i - 1], charArr[i]) * this.fontSize();\n }\n catch (e) {\n kern = 0;\n }\n }\n charStartPoint.x += kern;\n charEndPoint.x += kern;\n this.textWidth += kern;\n const midpoint = Path_1.Path.getPointOnLine(kern + width / 2.0, charStartPoint.x, charStartPoint.y, charEndPoint.x, charEndPoint.y);\n const rotation = Math.atan2(charEndPoint.y - charStartPoint.y, charEndPoint.x - charStartPoint.x);\n this.glyphInfo.push({\n transposeX: midpoint.x,\n transposeY: midpoint.y,\n text: charArr[i],\n rotation: rotation,\n p0: charStartPoint,\n p1: charEndPoint,\n });\n offsetToGlyph += glyphWidth;\n }\n }\n getSelfRect() {\n if (!this.glyphInfo.length) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n var points = [];\n this.glyphInfo.forEach(function (info) {\n points.push(info.p0.x);\n points.push(info.p0.y);\n points.push(info.p1.x);\n points.push(info.p1.y);\n });\n var minX = points[0] || 0;\n var maxX = points[0] || 0;\n var minY = points[1] || 0;\n var maxY = points[1] || 0;\n var x, y;\n for (var i = 0; i < points.length / 2; i++) {\n x = points[i * 2];\n y = points[i * 2 + 1];\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n var fontSize = this.fontSize();\n return {\n x: minX - fontSize / 2,\n y: minY - fontSize / 2,\n width: maxX - minX + fontSize,\n height: maxY - minY + fontSize,\n };\n }\n destroy() {\n Util_1.Util.releaseCanvas(this.dummyCanvas);\n return super.destroy();\n }\n}\nexports.TextPath = TextPath;\nTextPath.prototype._fillFunc = _fillFunc;\nTextPath.prototype._strokeFunc = _strokeFunc;\nTextPath.prototype._fillFuncHit = _fillFunc;\nTextPath.prototype._strokeFuncHit = _strokeFunc;\nTextPath.prototype.className = 'TextPath';\nTextPath.prototype._attrsAffectingSize = ['text', 'fontSize', 'data'];\n(0, Global_1._registerNode)(TextPath);\nFactory_1.Factory.addGetterSetter(TextPath, 'data');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontFamily', 'Arial');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontSize', 12, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(TextPath, 'fontStyle', NORMAL);\nFactory_1.Factory.addGetterSetter(TextPath, 'align', 'left');\nFactory_1.Factory.addGetterSetter(TextPath, 'letterSpacing', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(TextPath, 'textBaseline', 'middle');\nFactory_1.Factory.addGetterSetter(TextPath, 'fontVariant', NORMAL);\nFactory_1.Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING);\nFactory_1.Factory.addGetterSetter(TextPath, 'textDecoration', null);\nFactory_1.Factory.addGetterSetter(TextPath, 'kerningFunc', null);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Transformer = void 0;\nconst Util_1 = require(\"../Util\");\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Shape_1 = require(\"../Shape\");\nconst Rect_1 = require(\"./Rect\");\nconst Group_1 = require(\"../Group\");\nconst Global_1 = require(\"../Global\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_2 = require(\"../Global\");\nvar EVENTS_NAME = 'tr-konva';\nvar ATTR_CHANGE_LIST = [\n 'resizeEnabledChange',\n 'rotateAnchorOffsetChange',\n 'rotateEnabledChange',\n 'enabledAnchorsChange',\n 'anchorSizeChange',\n 'borderEnabledChange',\n 'borderStrokeChange',\n 'borderStrokeWidthChange',\n 'borderDashChange',\n 'anchorStrokeChange',\n 'anchorStrokeWidthChange',\n 'anchorFillChange',\n 'anchorCornerRadiusChange',\n 'ignoreStrokeChange',\n 'anchorStyleFuncChange',\n]\n .map((e) => e + `.${EVENTS_NAME}`)\n .join(' ');\nvar NODES_RECT = 'nodesRect';\nvar TRANSFORM_CHANGE_STR = [\n 'widthChange',\n 'heightChange',\n 'scaleXChange',\n 'scaleYChange',\n 'skewXChange',\n 'skewYChange',\n 'rotationChange',\n 'offsetXChange',\n 'offsetYChange',\n 'transformsEnabledChange',\n 'strokeWidthChange',\n];\nvar ANGLES = {\n 'top-left': -45,\n 'top-center': 0,\n 'top-right': 45,\n 'middle-right': -90,\n 'middle-left': 90,\n 'bottom-left': -135,\n 'bottom-center': 180,\n 'bottom-right': 135,\n};\nconst TOUCH_DEVICE = 'ontouchstart' in Global_1.Konva._global;\nfunction getCursor(anchorName, rad, rotateCursor) {\n if (anchorName === 'rotater') {\n return rotateCursor;\n }\n rad += Util_1.Util.degToRad(ANGLES[anchorName] || 0);\n var angle = ((Util_1.Util.radToDeg(rad) % 360) + 360) % 360;\n if (Util_1.Util._inRange(angle, 315 + 22.5, 360) || Util_1.Util._inRange(angle, 0, 22.5)) {\n return 'ns-resize';\n }\n else if (Util_1.Util._inRange(angle, 45 - 22.5, 45 + 22.5)) {\n return 'nesw-resize';\n }\n else if (Util_1.Util._inRange(angle, 90 - 22.5, 90 + 22.5)) {\n return 'ew-resize';\n }\n else if (Util_1.Util._inRange(angle, 135 - 22.5, 135 + 22.5)) {\n return 'nwse-resize';\n }\n else if (Util_1.Util._inRange(angle, 180 - 22.5, 180 + 22.5)) {\n return 'ns-resize';\n }\n else if (Util_1.Util._inRange(angle, 225 - 22.5, 225 + 22.5)) {\n return 'nesw-resize';\n }\n else if (Util_1.Util._inRange(angle, 270 - 22.5, 270 + 22.5)) {\n return 'ew-resize';\n }\n else if (Util_1.Util._inRange(angle, 315 - 22.5, 315 + 22.5)) {\n return 'nwse-resize';\n }\n else {\n Util_1.Util.error('Transformer has unknown angle for cursor detection: ' + angle);\n return 'pointer';\n }\n}\nvar ANCHORS_NAMES = [\n 'top-left',\n 'top-center',\n 'top-right',\n 'middle-right',\n 'middle-left',\n 'bottom-left',\n 'bottom-center',\n 'bottom-right',\n];\nvar MAX_SAFE_INTEGER = 100000000;\nfunction getCenter(shape) {\n return {\n x: shape.x +\n (shape.width / 2) * Math.cos(shape.rotation) +\n (shape.height / 2) * Math.sin(-shape.rotation),\n y: shape.y +\n (shape.height / 2) * Math.cos(shape.rotation) +\n (shape.width / 2) * Math.sin(shape.rotation),\n };\n}\nfunction rotateAroundPoint(shape, angleRad, point) {\n const x = point.x +\n (shape.x - point.x) * Math.cos(angleRad) -\n (shape.y - point.y) * Math.sin(angleRad);\n const y = point.y +\n (shape.x - point.x) * Math.sin(angleRad) +\n (shape.y - point.y) * Math.cos(angleRad);\n return {\n ...shape,\n rotation: shape.rotation + angleRad,\n x,\n y,\n };\n}\nfunction rotateAroundCenter(shape, deltaRad) {\n const center = getCenter(shape);\n return rotateAroundPoint(shape, deltaRad, center);\n}\nfunction getSnap(snaps, newRotationRad, tol) {\n let snapped = newRotationRad;\n for (let i = 0; i < snaps.length; i++) {\n const angle = Global_1.Konva.getAngle(snaps[i]);\n const absDiff = Math.abs(angle - newRotationRad) % (Math.PI * 2);\n const dif = Math.min(absDiff, Math.PI * 2 - absDiff);\n if (dif < tol) {\n snapped = angle;\n }\n }\n return snapped;\n}\nlet activeTransformersCount = 0;\nclass Transformer extends Group_1.Group {\n constructor(config) {\n super(config);\n this._movingAnchorName = null;\n this._transforming = false;\n this._createElements();\n this._handleMouseMove = this._handleMouseMove.bind(this);\n this._handleMouseUp = this._handleMouseUp.bind(this);\n this.update = this.update.bind(this);\n this.on(ATTR_CHANGE_LIST, this.update);\n if (this.getNode()) {\n this.update();\n }\n }\n attachTo(node) {\n this.setNode(node);\n return this;\n }\n setNode(node) {\n Util_1.Util.warn('tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.');\n return this.setNodes([node]);\n }\n getNode() {\n return this._nodes && this._nodes[0];\n }\n _getEventNamespace() {\n return EVENTS_NAME + this._id;\n }\n setNodes(nodes = []) {\n if (this._nodes && this._nodes.length) {\n this.detach();\n }\n const filteredNodes = nodes.filter((node) => {\n if (node.isAncestorOf(this)) {\n Util_1.Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');\n return false;\n }\n return true;\n });\n this._nodes = nodes = filteredNodes;\n if (nodes.length === 1 && this.useSingleNodeRotation()) {\n this.rotation(nodes[0].getAbsoluteRotation());\n }\n else {\n this.rotation(0);\n }\n this._nodes.forEach((node) => {\n const onChange = () => {\n if (this.nodes().length === 1 && this.useSingleNodeRotation()) {\n this.rotation(this.nodes()[0].getAbsoluteRotation());\n }\n this._resetTransformCache();\n if (!this._transforming && !this.isDragging()) {\n this.update();\n }\n };\n const additionalEvents = node._attrsAffectingSize\n .map((prop) => prop + 'Change.' + this._getEventNamespace())\n .join(' ');\n node.on(additionalEvents, onChange);\n node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);\n node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);\n this._proxyDrag(node);\n });\n this._resetTransformCache();\n var elementsCreated = !!this.findOne('.top-left');\n if (elementsCreated) {\n this.update();\n }\n return this;\n }\n _proxyDrag(node) {\n let lastPos;\n node.on(`dragstart.${this._getEventNamespace()}`, (e) => {\n lastPos = node.getAbsolutePosition();\n if (!this.isDragging() && node !== this.findOne('.back')) {\n this.startDrag(e, false);\n }\n });\n node.on(`dragmove.${this._getEventNamespace()}`, (e) => {\n if (!lastPos) {\n return;\n }\n const abs = node.getAbsolutePosition();\n const dx = abs.x - lastPos.x;\n const dy = abs.y - lastPos.y;\n this.nodes().forEach((otherNode) => {\n if (otherNode === node) {\n return;\n }\n if (otherNode.isDragging()) {\n return;\n }\n const otherAbs = otherNode.getAbsolutePosition();\n otherNode.setAbsolutePosition({\n x: otherAbs.x + dx,\n y: otherAbs.y + dy,\n });\n otherNode.startDrag(e);\n });\n lastPos = null;\n });\n }\n getNodes() {\n return this._nodes || [];\n }\n getActiveAnchor() {\n return this._movingAnchorName;\n }\n detach() {\n if (this._nodes) {\n this._nodes.forEach((node) => {\n node.off('.' + this._getEventNamespace());\n });\n }\n this._nodes = [];\n this._resetTransformCache();\n }\n _resetTransformCache() {\n this._clearCache(NODES_RECT);\n this._clearCache('transform');\n this._clearSelfAndDescendantCache('absoluteTransform');\n }\n _getNodeRect() {\n return this._getCache(NODES_RECT, this.__getNodeRect);\n }\n __getNodeShape(node, rot = this.rotation(), relative) {\n var rect = node.getClientRect({\n skipTransform: true,\n skipShadow: true,\n skipStroke: this.ignoreStroke(),\n });\n var absScale = node.getAbsoluteScale(relative);\n var absPos = node.getAbsolutePosition(relative);\n var dx = rect.x * absScale.x - node.offsetX() * absScale.x;\n var dy = rect.y * absScale.y - node.offsetY() * absScale.y;\n const rotation = (Global_1.Konva.getAngle(node.getAbsoluteRotation()) + Math.PI * 2) %\n (Math.PI * 2);\n const box = {\n x: absPos.x + dx * Math.cos(rotation) + dy * Math.sin(-rotation),\n y: absPos.y + dy * Math.cos(rotation) + dx * Math.sin(rotation),\n width: rect.width * absScale.x,\n height: rect.height * absScale.y,\n rotation: rotation,\n };\n return rotateAroundPoint(box, -Global_1.Konva.getAngle(rot), {\n x: 0,\n y: 0,\n });\n }\n __getNodeRect() {\n var node = this.getNode();\n if (!node) {\n return {\n x: -MAX_SAFE_INTEGER,\n y: -MAX_SAFE_INTEGER,\n width: 0,\n height: 0,\n rotation: 0,\n };\n }\n const totalPoints = [];\n this.nodes().map((node) => {\n const box = node.getClientRect({\n skipTransform: true,\n skipShadow: true,\n skipStroke: this.ignoreStroke(),\n });\n var points = [\n { x: box.x, y: box.y },\n { x: box.x + box.width, y: box.y },\n { x: box.x + box.width, y: box.y + box.height },\n { x: box.x, y: box.y + box.height },\n ];\n var trans = node.getAbsoluteTransform();\n points.forEach(function (point) {\n var transformed = trans.point(point);\n totalPoints.push(transformed);\n });\n });\n const tr = new Util_1.Transform();\n tr.rotate(-Global_1.Konva.getAngle(this.rotation()));\n var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n totalPoints.forEach(function (point) {\n var transformed = tr.point(point);\n if (minX === undefined) {\n minX = maxX = transformed.x;\n minY = maxY = transformed.y;\n }\n minX = Math.min(minX, transformed.x);\n minY = Math.min(minY, transformed.y);\n maxX = Math.max(maxX, transformed.x);\n maxY = Math.max(maxY, transformed.y);\n });\n tr.invert();\n const p = tr.point({ x: minX, y: minY });\n return {\n x: p.x,\n y: p.y,\n width: maxX - minX,\n height: maxY - minY,\n rotation: Global_1.Konva.getAngle(this.rotation()),\n };\n }\n getX() {\n return this._getNodeRect().x;\n }\n getY() {\n return this._getNodeRect().y;\n }\n getWidth() {\n return this._getNodeRect().width;\n }\n getHeight() {\n return this._getNodeRect().height;\n }\n _createElements() {\n this._createBack();\n ANCHORS_NAMES.forEach((name) => {\n this._createAnchor(name);\n });\n this._createAnchor('rotater');\n }\n _createAnchor(name) {\n var anchor = new Rect_1.Rect({\n stroke: 'rgb(0, 161, 255)',\n fill: 'white',\n strokeWidth: 1,\n name: name + ' _anchor',\n dragDistance: 0,\n draggable: true,\n hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',\n });\n var self = this;\n anchor.on('mousedown touchstart', function (e) {\n self._handleMouseDown(e);\n });\n anchor.on('dragstart', (e) => {\n anchor.stopDrag();\n e.cancelBubble = true;\n });\n anchor.on('dragend', (e) => {\n e.cancelBubble = true;\n });\n anchor.on('mouseenter', () => {\n var rad = Global_1.Konva.getAngle(this.rotation());\n var rotateCursor = this.rotateAnchorCursor();\n var cursor = getCursor(name, rad, rotateCursor);\n anchor.getStage().content &&\n (anchor.getStage().content.style.cursor = cursor);\n this._cursorChange = true;\n });\n anchor.on('mouseout', () => {\n anchor.getStage().content &&\n (anchor.getStage().content.style.cursor = '');\n this._cursorChange = false;\n });\n this.add(anchor);\n }\n _createBack() {\n var back = new Shape_1.Shape({\n name: 'back',\n width: 0,\n height: 0,\n draggable: true,\n sceneFunc(ctx, shape) {\n var tr = shape.getParent();\n var padding = tr.padding();\n ctx.beginPath();\n ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);\n ctx.moveTo(shape.width() / 2, -padding);\n if (tr.rotateEnabled() && tr.rotateLineVisible()) {\n ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util_1.Util._sign(shape.height()) - padding);\n }\n ctx.fillStrokeShape(shape);\n },\n hitFunc: (ctx, shape) => {\n if (!this.shouldOverdrawWholeArea()) {\n return;\n }\n var padding = this.padding();\n ctx.beginPath();\n ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);\n ctx.fillStrokeShape(shape);\n },\n });\n this.add(back);\n this._proxyDrag(back);\n back.on('dragstart', (e) => {\n e.cancelBubble = true;\n });\n back.on('dragmove', (e) => {\n e.cancelBubble = true;\n });\n back.on('dragend', (e) => {\n e.cancelBubble = true;\n });\n this.on('dragmove', (e) => {\n this.update();\n });\n }\n _handleMouseDown(e) {\n this._movingAnchorName = e.target.name().split(' ')[0];\n var attrs = this._getNodeRect();\n var width = attrs.width;\n var height = attrs.height;\n var hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));\n this.sin = Math.abs(height / hypotenuse);\n this.cos = Math.abs(width / hypotenuse);\n if (typeof window !== 'undefined') {\n window.addEventListener('mousemove', this._handleMouseMove);\n window.addEventListener('touchmove', this._handleMouseMove);\n window.addEventListener('mouseup', this._handleMouseUp, true);\n window.addEventListener('touchend', this._handleMouseUp, true);\n }\n this._transforming = true;\n var ap = e.target.getAbsolutePosition();\n var pos = e.target.getStage().getPointerPosition();\n this._anchorDragOffset = {\n x: pos.x - ap.x,\n y: pos.y - ap.y,\n };\n activeTransformersCount++;\n this._fire('transformstart', { evt: e.evt, target: this.getNode() });\n this._nodes.forEach((target) => {\n target._fire('transformstart', { evt: e.evt, target });\n });\n }\n _handleMouseMove(e) {\n var x, y, newHypotenuse;\n var anchorNode = this.findOne('.' + this._movingAnchorName);\n var stage = anchorNode.getStage();\n stage.setPointersPositions(e);\n const pp = stage.getPointerPosition();\n let newNodePos = {\n x: pp.x - this._anchorDragOffset.x,\n y: pp.y - this._anchorDragOffset.y,\n };\n const oldAbs = anchorNode.getAbsolutePosition();\n if (this.anchorDragBoundFunc()) {\n newNodePos = this.anchorDragBoundFunc()(oldAbs, newNodePos, e);\n }\n anchorNode.setAbsolutePosition(newNodePos);\n const newAbs = anchorNode.getAbsolutePosition();\n if (oldAbs.x === newAbs.x && oldAbs.y === newAbs.y) {\n return;\n }\n if (this._movingAnchorName === 'rotater') {\n var attrs = this._getNodeRect();\n x = anchorNode.x() - attrs.width / 2;\n y = -anchorNode.y() + attrs.height / 2;\n let delta = Math.atan2(-y, x) + Math.PI / 2;\n if (attrs.height < 0) {\n delta -= Math.PI;\n }\n var oldRotation = Global_1.Konva.getAngle(this.rotation());\n const newRotation = oldRotation + delta;\n const tol = Global_1.Konva.getAngle(this.rotationSnapTolerance());\n const snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);\n const diff = snappedRot - attrs.rotation;\n const shape = rotateAroundCenter(attrs, diff);\n this._fitNodesInto(shape, e);\n return;\n }\n var shiftBehavior = this.shiftBehavior();\n var keepProportion;\n if (shiftBehavior === 'inverted') {\n keepProportion = this.keepRatio() && !e.shiftKey;\n }\n else if (shiftBehavior === 'none') {\n keepProportion = this.keepRatio();\n }\n else {\n keepProportion = this.keepRatio() || e.shiftKey;\n }\n var centeredScaling = this.centeredScaling() || e.altKey;\n if (this._movingAnchorName === 'top-left') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.bottom-right').x(),\n y: this.findOne('.bottom-right').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n var reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.top-left').x(comparePoint.x - x);\n this.findOne('.top-left').y(comparePoint.y - y);\n }\n }\n else if (this._movingAnchorName === 'top-center') {\n this.findOne('.top-left').y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'top-right') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.bottom-left').x(),\n y: this.findOne('.bottom-left').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(comparePoint.y - anchorNode.y(), 2));\n var reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.top-right').x(comparePoint.x + x);\n this.findOne('.top-right').y(comparePoint.y - y);\n }\n var pos = anchorNode.position();\n this.findOne('.top-left').y(pos.y);\n this.findOne('.bottom-right').x(pos.x);\n }\n else if (this._movingAnchorName === 'middle-left') {\n this.findOne('.top-left').x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'middle-right') {\n this.findOne('.bottom-right').x(anchorNode.x());\n }\n else if (this._movingAnchorName === 'bottom-left') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.top-right').x(),\n y: this.findOne('.top-right').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n var reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;\n var reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n anchorNode.x(comparePoint.x - x);\n anchorNode.y(comparePoint.y + y);\n }\n pos = anchorNode.position();\n this.findOne('.top-left').x(pos.x);\n this.findOne('.bottom-right').y(pos.y);\n }\n else if (this._movingAnchorName === 'bottom-center') {\n this.findOne('.bottom-right').y(anchorNode.y());\n }\n else if (this._movingAnchorName === 'bottom-right') {\n if (keepProportion) {\n var comparePoint = centeredScaling\n ? {\n x: this.width() / 2,\n y: this.height() / 2,\n }\n : {\n x: this.findOne('.top-left').x(),\n y: this.findOne('.top-left').y(),\n };\n newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +\n Math.pow(anchorNode.y() - comparePoint.y, 2));\n var reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;\n var reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;\n x = newHypotenuse * this.cos * reverseX;\n y = newHypotenuse * this.sin * reverseY;\n this.findOne('.bottom-right').x(comparePoint.x + x);\n this.findOne('.bottom-right').y(comparePoint.y + y);\n }\n }\n else {\n console.error(new Error('Wrong position argument of selection resizer: ' +\n this._movingAnchorName));\n }\n var centeredScaling = this.centeredScaling() || e.altKey;\n if (centeredScaling) {\n var topLeft = this.findOne('.top-left');\n var bottomRight = this.findOne('.bottom-right');\n var topOffsetX = topLeft.x();\n var topOffsetY = topLeft.y();\n var bottomOffsetX = this.getWidth() - bottomRight.x();\n var bottomOffsetY = this.getHeight() - bottomRight.y();\n bottomRight.move({\n x: -topOffsetX,\n y: -topOffsetY,\n });\n topLeft.move({\n x: bottomOffsetX,\n y: bottomOffsetY,\n });\n }\n var absPos = this.findOne('.top-left').getAbsolutePosition();\n x = absPos.x;\n y = absPos.y;\n var width = this.findOne('.bottom-right').x() - this.findOne('.top-left').x();\n var height = this.findOne('.bottom-right').y() - this.findOne('.top-left').y();\n this._fitNodesInto({\n x: x,\n y: y,\n width: width,\n height: height,\n rotation: Global_1.Konva.getAngle(this.rotation()),\n }, e);\n }\n _handleMouseUp(e) {\n this._removeEvents(e);\n }\n getAbsoluteTransform() {\n return this.getTransform();\n }\n _removeEvents(e) {\n var _a;\n if (this._transforming) {\n this._transforming = false;\n if (typeof window !== 'undefined') {\n window.removeEventListener('mousemove', this._handleMouseMove);\n window.removeEventListener('touchmove', this._handleMouseMove);\n window.removeEventListener('mouseup', this._handleMouseUp, true);\n window.removeEventListener('touchend', this._handleMouseUp, true);\n }\n var node = this.getNode();\n activeTransformersCount--;\n this._fire('transformend', { evt: e, target: node });\n (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n if (node) {\n this._nodes.forEach((target) => {\n var _a;\n target._fire('transformend', { evt: e, target });\n (_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n });\n }\n this._movingAnchorName = null;\n }\n }\n _fitNodesInto(newAttrs, evt) {\n var oldAttrs = this._getNodeRect();\n const minSize = 1;\n if (Util_1.Util._inRange(newAttrs.width, -this.padding() * 2 - minSize, minSize)) {\n this.update();\n return;\n }\n if (Util_1.Util._inRange(newAttrs.height, -this.padding() * 2 - minSize, minSize)) {\n this.update();\n return;\n }\n var t = new Util_1.Transform();\n t.rotate(Global_1.Konva.getAngle(this.rotation()));\n if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('left') >= 0) {\n const offset = t.point({\n x: -this.padding() * 2,\n y: 0,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n newAttrs.width += this.padding() * 2;\n this._movingAnchorName = this._movingAnchorName.replace('left', 'right');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n }\n else if (this._movingAnchorName &&\n newAttrs.width < 0 &&\n this._movingAnchorName.indexOf('right') >= 0) {\n const offset = t.point({\n x: this.padding() * 2,\n y: 0,\n });\n this._movingAnchorName = this._movingAnchorName.replace('right', 'left');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.width += this.padding() * 2;\n }\n if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('top') >= 0) {\n const offset = t.point({\n x: 0,\n y: -this.padding() * 2,\n });\n newAttrs.x += offset.x;\n newAttrs.y += offset.y;\n this._movingAnchorName = this._movingAnchorName.replace('top', 'bottom');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.height += this.padding() * 2;\n }\n else if (this._movingAnchorName &&\n newAttrs.height < 0 &&\n this._movingAnchorName.indexOf('bottom') >= 0) {\n const offset = t.point({\n x: 0,\n y: this.padding() * 2,\n });\n this._movingAnchorName = this._movingAnchorName.replace('bottom', 'top');\n this._anchorDragOffset.x -= offset.x;\n this._anchorDragOffset.y -= offset.y;\n newAttrs.height += this.padding() * 2;\n }\n if (this.boundBoxFunc()) {\n const bounded = this.boundBoxFunc()(oldAttrs, newAttrs);\n if (bounded) {\n newAttrs = bounded;\n }\n else {\n Util_1.Util.warn('boundBoxFunc returned falsy. You should return new bound rect from it!');\n }\n }\n const baseSize = 10000000;\n const oldTr = new Util_1.Transform();\n oldTr.translate(oldAttrs.x, oldAttrs.y);\n oldTr.rotate(oldAttrs.rotation);\n oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);\n const newTr = new Util_1.Transform();\n const newScaleX = newAttrs.width / baseSize;\n const newScaleY = newAttrs.height / baseSize;\n if (this.flipEnabled() === false) {\n newTr.translate(newAttrs.x, newAttrs.y);\n newTr.rotate(newAttrs.rotation);\n newTr.translate(newAttrs.width < 0 ? newAttrs.width : 0, newAttrs.height < 0 ? newAttrs.height : 0);\n newTr.scale(Math.abs(newScaleX), Math.abs(newScaleY));\n }\n else {\n newTr.translate(newAttrs.x, newAttrs.y);\n newTr.rotate(newAttrs.rotation);\n newTr.scale(newScaleX, newScaleY);\n }\n const delta = newTr.multiply(oldTr.invert());\n this._nodes.forEach((node) => {\n var _a;\n const parentTransform = node.getParent().getAbsoluteTransform();\n const localTransform = node.getTransform().copy();\n localTransform.translate(node.offsetX(), node.offsetY());\n const newLocalTransform = new Util_1.Transform();\n newLocalTransform\n .multiply(parentTransform.copy().invert())\n .multiply(delta)\n .multiply(parentTransform)\n .multiply(localTransform);\n const attrs = newLocalTransform.decompose();\n node.setAttrs(attrs);\n (_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n });\n this.rotation(Util_1.Util._getRotation(newAttrs.rotation));\n this._nodes.forEach((node) => {\n this._fire('transform', { evt: evt, target: node });\n node._fire('transform', { evt: evt, target: node });\n });\n this._resetTransformCache();\n this.update();\n this.getLayer().batchDraw();\n }\n forceUpdate() {\n this._resetTransformCache();\n this.update();\n }\n _batchChangeChild(selector, attrs) {\n const anchor = this.findOne(selector);\n anchor.setAttrs(attrs);\n }\n update() {\n var _a;\n var attrs = this._getNodeRect();\n this.rotation(Util_1.Util._getRotation(attrs.rotation));\n var width = attrs.width;\n var height = attrs.height;\n var enabledAnchors = this.enabledAnchors();\n var resizeEnabled = this.resizeEnabled();\n var padding = this.padding();\n var anchorSize = this.anchorSize();\n const anchors = this.find('._anchor');\n anchors.forEach((node) => {\n node.setAttrs({\n width: anchorSize,\n height: anchorSize,\n offsetX: anchorSize / 2,\n offsetY: anchorSize / 2,\n stroke: this.anchorStroke(),\n strokeWidth: this.anchorStrokeWidth(),\n fill: this.anchorFill(),\n cornerRadius: this.anchorCornerRadius(),\n });\n });\n this._batchChangeChild('.top-left', {\n x: 0,\n y: 0,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-left') >= 0,\n });\n this._batchChangeChild('.top-center', {\n x: width / 2,\n y: 0,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-center') >= 0,\n });\n this._batchChangeChild('.top-right', {\n x: width,\n y: 0,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('top-right') >= 0,\n });\n this._batchChangeChild('.middle-left', {\n x: 0,\n y: height / 2,\n offsetX: anchorSize / 2 + padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-left') >= 0,\n });\n this._batchChangeChild('.middle-right', {\n x: width,\n y: height / 2,\n offsetX: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('middle-right') >= 0,\n });\n this._batchChangeChild('.bottom-left', {\n x: 0,\n y: height,\n offsetX: anchorSize / 2 + padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-left') >= 0,\n });\n this._batchChangeChild('.bottom-center', {\n x: width / 2,\n y: height,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-center') >= 0,\n });\n this._batchChangeChild('.bottom-right', {\n x: width,\n y: height,\n offsetX: anchorSize / 2 - padding,\n offsetY: anchorSize / 2 - padding,\n visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,\n });\n this._batchChangeChild('.rotater', {\n x: width / 2,\n y: -this.rotateAnchorOffset() * Util_1.Util._sign(height) - padding,\n visible: this.rotateEnabled(),\n });\n this._batchChangeChild('.back', {\n width: width,\n height: height,\n visible: this.borderEnabled(),\n stroke: this.borderStroke(),\n strokeWidth: this.borderStrokeWidth(),\n dash: this.borderDash(),\n x: 0,\n y: 0,\n });\n const styleFunc = this.anchorStyleFunc();\n if (styleFunc) {\n anchors.forEach((node) => {\n styleFunc(node);\n });\n }\n (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();\n }\n isTransforming() {\n return this._transforming;\n }\n stopTransform() {\n if (this._transforming) {\n this._removeEvents();\n var anchorNode = this.findOne('.' + this._movingAnchorName);\n if (anchorNode) {\n anchorNode.stopDrag();\n }\n }\n }\n destroy() {\n if (this.getStage() && this._cursorChange) {\n this.getStage().content && (this.getStage().content.style.cursor = '');\n }\n Group_1.Group.prototype.destroy.call(this);\n this.detach();\n this._removeEvents();\n return this;\n }\n toObject() {\n return Node_1.Node.prototype.toObject.call(this);\n }\n clone(obj) {\n var node = Node_1.Node.prototype.clone.call(this, obj);\n return node;\n }\n getClientRect() {\n if (this.nodes().length > 0) {\n return super.getClientRect();\n }\n else {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n }\n}\nexports.Transformer = Transformer;\nTransformer.isTransforming = () => {\n return activeTransformersCount > 0;\n};\nfunction validateAnchors(val) {\n if (!(val instanceof Array)) {\n Util_1.Util.warn('enabledAnchors value should be an array');\n }\n if (val instanceof Array) {\n val.forEach(function (name) {\n if (ANCHORS_NAMES.indexOf(name) === -1) {\n Util_1.Util.warn('Unknown anchor name: ' +\n name +\n '. Available names are: ' +\n ANCHORS_NAMES.join(', '));\n }\n });\n }\n return val || [];\n}\nTransformer.prototype.className = 'Transformer';\n(0, Global_2._registerNode)(Transformer);\nFactory_1.Factory.addGetterSetter(Transformer, 'enabledAnchors', ANCHORS_NAMES, validateAnchors);\nFactory_1.Factory.addGetterSetter(Transformer, 'flipEnabled', true, (0, Validators_1.getBooleanValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'resizeEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorSize', 10, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateLineVisible', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'rotationSnaps', []);\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');\nFactory_1.Factory.addGetterSetter(Transformer, 'rotationSnapTolerance', 5, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderEnabled', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorStroke', 'rgb(0, 161, 255)');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorStrokeWidth', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorFill', 'white');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorCornerRadius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderStroke', 'rgb(0, 161, 255)');\nFactory_1.Factory.addGetterSetter(Transformer, 'borderStrokeWidth', 1, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'borderDash');\nFactory_1.Factory.addGetterSetter(Transformer, 'keepRatio', true);\nFactory_1.Factory.addGetterSetter(Transformer, 'shiftBehavior', 'default');\nFactory_1.Factory.addGetterSetter(Transformer, 'centeredScaling', false);\nFactory_1.Factory.addGetterSetter(Transformer, 'ignoreStroke', false);\nFactory_1.Factory.addGetterSetter(Transformer, 'padding', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Transformer, 'node');\nFactory_1.Factory.addGetterSetter(Transformer, 'nodes');\nFactory_1.Factory.addGetterSetter(Transformer, 'boundBoxFunc');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorDragBoundFunc');\nFactory_1.Factory.addGetterSetter(Transformer, 'anchorStyleFunc');\nFactory_1.Factory.addGetterSetter(Transformer, 'shouldOverdrawWholeArea', false);\nFactory_1.Factory.addGetterSetter(Transformer, 'useSingleNodeRotation', true);\nFactory_1.Factory.backCompat(Transformer, {\n lineEnabled: 'borderEnabled',\n rotateHandlerOffset: 'rotateAnchorOffset',\n enabledHandlers: 'enabledAnchors',\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Wedge = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Shape_1 = require(\"../Shape\");\nconst Global_1 = require(\"../Global\");\nconst Validators_1 = require(\"../Validators\");\nconst Global_2 = require(\"../Global\");\nclass Wedge extends Shape_1.Shape {\n _sceneFunc(context) {\n context.beginPath();\n context.arc(0, 0, this.radius(), 0, Global_1.Konva.getAngle(this.angle()), this.clockwise());\n context.lineTo(0, 0);\n context.closePath();\n context.fillStrokeShape(this);\n }\n getWidth() {\n return this.radius() * 2;\n }\n getHeight() {\n return this.radius() * 2;\n }\n setWidth(width) {\n this.radius(width / 2);\n }\n setHeight(height) {\n this.radius(height / 2);\n }\n}\nexports.Wedge = Wedge;\nWedge.prototype.className = 'Wedge';\nWedge.prototype._centroid = true;\nWedge.prototype._attrsAffectingSize = ['radius'];\n(0, Global_2._registerNode)(Wedge);\nFactory_1.Factory.addGetterSetter(Wedge, 'radius', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Wedge, 'angle', 0, (0, Validators_1.getNumberValidator)());\nFactory_1.Factory.addGetterSetter(Wedge, 'clockwise', false);\nFactory_1.Factory.backCompat(Wedge, {\n angleDeg: 'angle',\n getAngleDeg: 'getAngle',\n setAngleDeg: 'setAngle',\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Blur = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nfunction BlurStack() {\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n}\nvar mul_table = [\n 512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,\n 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,\n 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,\n 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292,\n 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373,\n 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259,\n 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381,\n 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292,\n 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461,\n 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373,\n 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309,\n 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259,\n 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442,\n 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381,\n 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332,\n 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,\n 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,\n];\nvar shg_table = [\n 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,\n 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,\n 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,\n 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24,\n];\nfunction filterGaussBlurRGBA(imageData, radius) {\n var pixels = imageData.data, width = imageData.width, height = imageData.height;\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;\n var div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius];\n for (i = 1; i < div; i++) {\n stack = stack.next = new BlurStack();\n if (i === radiusPlus1) {\n stackEnd = stack;\n }\n }\n stack.next = stackStart;\n yw = yi = 0;\n for (y = 0; y < height; y++) {\n r_in_sum =\n g_in_sum =\n b_in_sum =\n a_in_sum =\n r_sum =\n g_sum =\n b_sum =\n a_sum =\n 0;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n for (i = 1; i < radiusPlus1; i++) {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = pixels[p + 1]) * rbs;\n b_sum += (stack.b = pb = pixels[p + 2]) * rbs;\n a_sum += (stack.a = pa = pixels[p + 3]) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n }\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++) {\n pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa !== 0) {\n pa = 255 / pa;\n pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n }\n else {\n pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;\n }\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n r_in_sum += stackIn.r = pixels[p];\n g_in_sum += stackIn.g = pixels[p + 1];\n b_in_sum += stackIn.b = pixels[p + 2];\n a_in_sum += stackIn.a = pixels[p + 3];\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n a_sum += a_in_sum;\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += 4;\n }\n yw += width;\n }\n for (x = 0; x < width; x++) {\n g_in_sum =\n b_in_sum =\n a_in_sum =\n r_in_sum =\n g_sum =\n b_sum =\n a_sum =\n r_sum =\n 0;\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n stack = stackStart;\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n yp = width;\n for (i = 1; i <= radius; i++) {\n yi = (yp + x) << 2;\n r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;\n b_sum += (stack.b = pb = pixels[yi + 2]) * rbs;\n a_sum += (stack.a = pa = pixels[yi + 3]) * rbs;\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n stack = stack.next;\n if (i < heightMinus1) {\n yp += width;\n }\n }\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++) {\n p = yi << 2;\n pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa > 0) {\n pa = 255 / pa;\n pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n }\n else {\n pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;\n }\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n p =\n (x +\n ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width) <<\n 2;\n r_sum += r_in_sum += stackIn.r = pixels[p];\n g_sum += g_in_sum += stackIn.g = pixels[p + 1];\n b_sum += b_in_sum += stackIn.b = pixels[p + 2];\n a_sum += a_in_sum += stackIn.a = pixels[p + 3];\n stackIn = stackIn.next;\n r_out_sum += pr = stackOut.r;\n g_out_sum += pg = stackOut.g;\n b_out_sum += pb = stackOut.b;\n a_out_sum += pa = stackOut.a;\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n stackOut = stackOut.next;\n yi += width;\n }\n }\n}\nconst Blur = function Blur(imageData) {\n var radius = Math.round(this.blurRadius());\n if (radius > 0) {\n filterGaussBlurRGBA(imageData, radius);\n }\n};\nexports.Blur = Blur;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blurRadius', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Brighten = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Brighten = function (imageData) {\n var brightness = this.brightness() * 255, data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n};\nexports.Brighten = Brighten;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'brightness', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Contrast = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Contrast = function (imageData) {\n var adjust = Math.pow((this.contrast() + 100) / 100, 2);\n var data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i;\n for (i = 0; i < nPixels; i += 4) {\n red = data[i];\n green = data[i + 1];\n blue = data[i + 2];\n red /= 255;\n red -= 0.5;\n red *= adjust;\n red += 0.5;\n red *= 255;\n green /= 255;\n green -= 0.5;\n green *= adjust;\n green += 0.5;\n green *= 255;\n blue /= 255;\n blue -= 0.5;\n blue *= adjust;\n blue += 0.5;\n blue *= 255;\n red = red < 0 ? 0 : red > 255 ? 255 : red;\n green = green < 0 ? 0 : green > 255 ? 255 : green;\n blue = blue < 0 ? 0 : blue > 255 ? 255 : blue;\n data[i] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n }\n};\nexports.Contrast = Contrast;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'contrast', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Emboss = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Util_1 = require(\"../Util\");\nconst Validators_1 = require(\"../Validators\");\nconst Emboss = function (imageData) {\n var strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), dirY = 0, dirX = 0, data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;\n switch (direction) {\n case 'top-left':\n dirY = -1;\n dirX = -1;\n break;\n case 'top':\n dirY = -1;\n dirX = 0;\n break;\n case 'top-right':\n dirY = -1;\n dirX = 1;\n break;\n case 'right':\n dirY = 0;\n dirX = 1;\n break;\n case 'bottom-right':\n dirY = 1;\n dirX = 1;\n break;\n case 'bottom':\n dirY = 1;\n dirX = 0;\n break;\n case 'bottom-left':\n dirY = 1;\n dirX = -1;\n break;\n case 'left':\n dirY = 0;\n dirX = -1;\n break;\n default:\n Util_1.Util.error('Unknown emboss direction: ' + direction);\n }\n do {\n var offsetY = (y - 1) * w4;\n var otherY = dirY;\n if (y + otherY < 1) {\n otherY = 0;\n }\n if (y + otherY > h) {\n otherY = 0;\n }\n var offsetYOther = (y - 1 + otherY) * w * 4;\n var x = w;\n do {\n var offset = offsetY + (x - 1) * 4;\n var otherX = dirX;\n if (x + otherX < 1) {\n otherX = 0;\n }\n if (x + otherX > w) {\n otherX = 0;\n }\n var offsetOther = offsetYOther + (x - 1 + otherX) * 4;\n var dR = data[offset] - data[offsetOther];\n var dG = data[offset + 1] - data[offsetOther + 1];\n var dB = data[offset + 2] - data[offsetOther + 2];\n var dif = dR;\n var absDif = dif > 0 ? dif : -dif;\n var absG = dG > 0 ? dG : -dG;\n var absB = dB > 0 ? dB : -dB;\n if (absG > absDif) {\n dif = dG;\n }\n if (absB > absDif) {\n dif = dB;\n }\n dif *= strength;\n if (blend) {\n var r = data[offset] + dif;\n var g = data[offset + 1] + dif;\n var b = data[offset + 2] + dif;\n data[offset] = r > 255 ? 255 : r < 0 ? 0 : r;\n data[offset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;\n data[offset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;\n }\n else {\n var grey = greyLevel - dif;\n if (grey < 0) {\n grey = 0;\n }\n else if (grey > 255) {\n grey = 255;\n }\n data[offset] = data[offset + 1] = data[offset + 2] = grey;\n }\n } while (--x);\n } while (--y);\n};\nexports.Emboss = Emboss;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossStrength', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossWhiteLevel', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossDirection', 'top-left', null, Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'embossBlend', false, null, Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Enhance = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nfunction remap(fromValue, fromMin, fromMax, toMin, toMax) {\n var fromRange = fromMax - fromMin, toRange = toMax - toMin, toValue;\n if (fromRange === 0) {\n return toMin + toRange / 2;\n }\n if (toRange === 0) {\n return toMin;\n }\n toValue = (fromValue - fromMin) / fromRange;\n toValue = toRange * toValue + toMin;\n return toValue;\n}\nconst Enhance = function (imageData) {\n var data = imageData.data, nSubPixels = data.length, rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b, i;\n var enhanceAmount = this.enhance();\n if (enhanceAmount === 0) {\n return;\n }\n for (i = 0; i < nSubPixels; i += 4) {\n r = data[i + 0];\n if (r < rMin) {\n rMin = r;\n }\n else if (r > rMax) {\n rMax = r;\n }\n g = data[i + 1];\n if (g < gMin) {\n gMin = g;\n }\n else if (g > gMax) {\n gMax = g;\n }\n b = data[i + 2];\n if (b < bMin) {\n bMin = b;\n }\n else if (b > bMax) {\n bMax = b;\n }\n }\n if (rMax === rMin) {\n rMax = 255;\n rMin = 0;\n }\n if (gMax === gMin) {\n gMax = 255;\n gMin = 0;\n }\n if (bMax === bMin) {\n bMax = 255;\n bMin = 0;\n }\n var rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;\n if (enhanceAmount > 0) {\n rGoalMax = rMax + enhanceAmount * (255 - rMax);\n rGoalMin = rMin - enhanceAmount * (rMin - 0);\n gGoalMax = gMax + enhanceAmount * (255 - gMax);\n gGoalMin = gMin - enhanceAmount * (gMin - 0);\n bGoalMax = bMax + enhanceAmount * (255 - bMax);\n bGoalMin = bMin - enhanceAmount * (bMin - 0);\n }\n else {\n rMid = (rMax + rMin) * 0.5;\n rGoalMax = rMax + enhanceAmount * (rMax - rMid);\n rGoalMin = rMin + enhanceAmount * (rMin - rMid);\n gMid = (gMax + gMin) * 0.5;\n gGoalMax = gMax + enhanceAmount * (gMax - gMid);\n gGoalMin = gMin + enhanceAmount * (gMin - gMid);\n bMid = (bMax + bMin) * 0.5;\n bGoalMax = bMax + enhanceAmount * (bMax - bMid);\n bGoalMin = bMin + enhanceAmount * (bMin - bMid);\n }\n for (i = 0; i < nSubPixels; i += 4) {\n data[i + 0] = remap(data[i + 0], rMin, rMax, rGoalMin, rGoalMax);\n data[i + 1] = remap(data[i + 1], gMin, gMax, gGoalMin, gGoalMax);\n data[i + 2] = remap(data[i + 2], bMin, bMax, bGoalMin, bGoalMax);\n }\n};\nexports.Enhance = Enhance;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'enhance', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Grayscale = void 0;\nconst Grayscale = function (imageData) {\n var data = imageData.data, len = data.length, i, brightness;\n for (i = 0; i < len; i += 4) {\n brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];\n data[i] = brightness;\n data[i + 1] = brightness;\n data[i + 2] = brightness;\n }\n};\nexports.Grayscale = Grayscale;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HSL = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'luminance', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nconst HSL = function (imageData) {\n var data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127, i;\n var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;\n var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;\n var r, g, b, a;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b + l;\n data[i + 1] = gr * r + gg * g + gb * b + l;\n data[i + 2] = br * r + bg * g + bb * b + l;\n data[i + 3] = a;\n }\n};\nexports.HSL = HSL;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HSV = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst HSV = function (imageData) {\n var data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, i;\n var vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);\n var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;\n var gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;\n var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;\n var r, g, b, a;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n a = data[i + 3];\n data[i + 0] = rr * r + rg * g + rb * b;\n data[i + 1] = gr * r + gg * g + gb * b;\n data[i + 2] = br * r + bg * g + bb * b;\n data[i + 3] = a;\n }\n};\nexports.HSV = HSV;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'value', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Invert = void 0;\nconst Invert = function (imageData) {\n var data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n }\n};\nexports.Invert = Invert;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Kaleidoscope = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Util_1 = require(\"../Util\");\nconst Validators_1 = require(\"../Validators\");\nvar ToPolar = function (src, dst, opt) {\n var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, r = 0, g = 0, b = 0, a = 0;\n var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n x = xSize - xMid;\n y = ySize - yMid;\n rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n var rSize = ySize, tSize = xSize, radius, theta;\n var conversion = ((360 / tSize) * Math.PI) / 180, sin, cos;\n for (theta = 0; theta < tSize; theta += 1) {\n sin = Math.sin(theta * conversion);\n cos = Math.cos(theta * conversion);\n for (radius = 0; radius < rSize; radius += 1) {\n x = Math.floor(xMid + ((rMax * radius) / rSize) * cos);\n y = Math.floor(yMid + ((rMax * radius) / rSize) * sin);\n i = (y * xSize + x) * 4;\n r = srcPixels[i + 0];\n g = srcPixels[i + 1];\n b = srcPixels[i + 2];\n a = srcPixels[i + 3];\n i = (theta + radius * xSize) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\nvar FromPolar = function (src, dst, opt) {\n var srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, dx, dy, r = 0, g = 0, b = 0, a = 0;\n var rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid);\n x = xSize - xMid;\n y = ySize - yMid;\n rad = Math.sqrt(x * x + y * y);\n rMax = rad > rMax ? rad : rMax;\n var rSize = ySize, tSize = xSize, radius, theta, phaseShift = opt.polarRotation || 0;\n var x1, y1;\n for (x = 0; x < xSize; x += 1) {\n for (y = 0; y < ySize; y += 1) {\n dx = x - xMid;\n dy = y - yMid;\n radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax;\n theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360;\n theta = (theta * tSize) / 360;\n x1 = Math.floor(theta);\n y1 = Math.floor(radius);\n i = (y1 * xSize + x1) * 4;\n r = srcPixels[i + 0];\n g = srcPixels[i + 1];\n b = srcPixels[i + 2];\n a = srcPixels[i + 3];\n i = (y * xSize + x) * 4;\n dstPixels[i + 0] = r;\n dstPixels[i + 1] = g;\n dstPixels[i + 2] = b;\n dstPixels[i + 3] = a;\n }\n }\n};\nconst Kaleidoscope = function (imageData) {\n var xSize = imageData.width, ySize = imageData.height;\n var x, y, xoff, i, r, g, b, a, srcPos, dstPos;\n var power = Math.round(this.kaleidoscopePower());\n var angle = Math.round(this.kaleidoscopeAngle());\n var offset = Math.floor((xSize * (angle % 360)) / 360);\n if (power < 1) {\n return;\n }\n var tempCanvas = Util_1.Util.createCanvasElement();\n tempCanvas.width = xSize;\n tempCanvas.height = ySize;\n var scratchData = tempCanvas\n .getContext('2d')\n .getImageData(0, 0, xSize, ySize);\n Util_1.Util.releaseCanvas(tempCanvas);\n ToPolar(imageData, scratchData, {\n polarCenterX: xSize / 2,\n polarCenterY: ySize / 2,\n });\n var minSectionSize = xSize / Math.pow(2, power);\n while (minSectionSize <= 8) {\n minSectionSize = minSectionSize * 2;\n power -= 1;\n }\n minSectionSize = Math.ceil(minSectionSize);\n var sectionSize = minSectionSize;\n var xStart = 0, xEnd = sectionSize, xDelta = 1;\n if (offset + minSectionSize > xSize) {\n xStart = sectionSize;\n xEnd = 0;\n xDelta = -1;\n }\n for (y = 0; y < ySize; y += 1) {\n for (x = xStart; x !== xEnd; x += xDelta) {\n xoff = Math.round(x + offset) % xSize;\n srcPos = (xSize * y + xoff) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + x) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n }\n for (y = 0; y < ySize; y += 1) {\n sectionSize = Math.floor(minSectionSize);\n for (i = 0; i < power; i += 1) {\n for (x = 0; x < sectionSize + 1; x += 1) {\n srcPos = (xSize * y + x) * 4;\n r = scratchData.data[srcPos + 0];\n g = scratchData.data[srcPos + 1];\n b = scratchData.data[srcPos + 2];\n a = scratchData.data[srcPos + 3];\n dstPos = (xSize * y + sectionSize * 2 - x - 1) * 4;\n scratchData.data[dstPos + 0] = r;\n scratchData.data[dstPos + 1] = g;\n scratchData.data[dstPos + 2] = b;\n scratchData.data[dstPos + 3] = a;\n }\n sectionSize *= 2;\n }\n }\n FromPolar(scratchData, imageData, { polarRotation: 0 });\n};\nexports.Kaleidoscope = Kaleidoscope;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopePower', 2, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopeAngle', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Mask = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nfunction pixelAt(idata, x, y) {\n var idx = (y * idata.width + x) * 4;\n var d = [];\n d.push(idata.data[idx++], idata.data[idx++], idata.data[idx++], idata.data[idx++]);\n return d;\n}\nfunction rgbDistance(p1, p2) {\n return Math.sqrt(Math.pow(p1[0] - p2[0], 2) +\n Math.pow(p1[1] - p2[1], 2) +\n Math.pow(p1[2] - p2[2], 2));\n}\nfunction rgbMean(pTab) {\n var m = [0, 0, 0];\n for (var i = 0; i < pTab.length; i++) {\n m[0] += pTab[i][0];\n m[1] += pTab[i][1];\n m[2] += pTab[i][2];\n }\n m[0] /= pTab.length;\n m[1] /= pTab.length;\n m[2] /= pTab.length;\n return m;\n}\nfunction backgroundMask(idata, threshold) {\n var rgbv_no = pixelAt(idata, 0, 0);\n var rgbv_ne = pixelAt(idata, idata.width - 1, 0);\n var rgbv_so = pixelAt(idata, 0, idata.height - 1);\n var rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);\n var thres = threshold || 10;\n if (rgbDistance(rgbv_no, rgbv_ne) < thres &&\n rgbDistance(rgbv_ne, rgbv_se) < thres &&\n rgbDistance(rgbv_se, rgbv_so) < thres &&\n rgbDistance(rgbv_so, rgbv_no) < thres) {\n var mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);\n var mask = [];\n for (var i = 0; i < idata.width * idata.height; i++) {\n var d = rgbDistance(mean, [\n idata.data[i * 4],\n idata.data[i * 4 + 1],\n idata.data[i * 4 + 2],\n ]);\n mask[i] = d < thres ? 0 : 255;\n }\n return mask;\n }\n}\nfunction applyMask(idata, mask) {\n for (var i = 0; i < idata.width * idata.height; i++) {\n idata.data[4 * i + 3] = mask[i];\n }\n}\nfunction erodeMask(mask, sw, sh) {\n var weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a === 255 * 8 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction dilateMask(mask, sw, sh) {\n var weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a >= 255 * 4 ? 255 : 0;\n }\n }\n return maskResult;\n}\nfunction smoothEdgeMask(mask, sw, sh) {\n var weights = [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9];\n var side = Math.round(Math.sqrt(weights.length));\n var halfSide = Math.floor(side / 2);\n var maskResult = [];\n for (var y = 0; y < sh; y++) {\n for (var x = 0; x < sw; x++) {\n var so = y * sw + x;\n var a = 0;\n for (var cy = 0; cy < side; cy++) {\n for (var cx = 0; cx < side; cx++) {\n var scy = y + cy - halfSide;\n var scx = x + cx - halfSide;\n if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {\n var srcOff = scy * sw + scx;\n var wt = weights[cy * side + cx];\n a += mask[srcOff] * wt;\n }\n }\n }\n maskResult[so] = a;\n }\n }\n return maskResult;\n}\nconst Mask = function (imageData) {\n var threshold = this.threshold(), mask = backgroundMask(imageData, threshold);\n if (mask) {\n mask = erodeMask(mask, imageData.width, imageData.height);\n mask = dilateMask(mask, imageData.width, imageData.height);\n mask = smoothEdgeMask(mask, imageData.width, imageData.height);\n applyMask(imageData, mask);\n }\n return imageData;\n};\nexports.Mask = Mask;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Noise = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Noise = function (imageData) {\n var amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2, i;\n for (i = 0; i < nPixels; i += 4) {\n data[i + 0] += half - 2 * half * Math.random();\n data[i + 1] += half - 2 * half * Math.random();\n data[i + 2] += half - 2 * half * Math.random();\n }\n};\nexports.Noise = Noise;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'noise', 0.2, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Pixelate = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Util_1 = require(\"../Util\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Pixelate = function (imageData) {\n var pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i, red, green, blue, alpha, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), xBinStart, xBinEnd, yBinStart, yBinEnd, xBin, yBin, pixelsInBin, data = imageData.data;\n if (pixelSize <= 0) {\n Util_1.Util.error('pixelSize value can not be <= 0');\n return;\n }\n for (xBin = 0; xBin < nBinsX; xBin += 1) {\n for (yBin = 0; yBin < nBinsY; yBin += 1) {\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n xBinStart = xBin * pixelSize;\n xBinEnd = xBinStart + pixelSize;\n yBinStart = yBin * pixelSize;\n yBinEnd = yBinStart + pixelSize;\n pixelsInBin = 0;\n for (x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n i = (width * y + x) * 4;\n red += data[i + 0];\n green += data[i + 1];\n blue += data[i + 2];\n alpha += data[i + 3];\n pixelsInBin += 1;\n }\n }\n red = red / pixelsInBin;\n green = green / pixelsInBin;\n blue = blue / pixelsInBin;\n alpha = alpha / pixelsInBin;\n for (x = xBinStart; x < xBinEnd; x += 1) {\n if (x >= width) {\n continue;\n }\n for (y = yBinStart; y < yBinEnd; y += 1) {\n if (y >= height) {\n continue;\n }\n i = (width * y + x) * 4;\n data[i + 0] = red;\n data[i + 1] = green;\n data[i + 2] = blue;\n data[i + 3] = alpha;\n }\n }\n }\n }\n};\nexports.Pixelate = Pixelate;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'pixelSize', 8, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Posterize = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Posterize = function (imageData) {\n var levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels, i;\n for (i = 0; i < len; i += 1) {\n data[i] = Math.floor(data[i] / scale) * scale;\n }\n};\nexports.Posterize = Posterize;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'levels', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.RGB = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst RGB = function (imageData) {\n var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), i, brightness;\n for (i = 0; i < nPixels; i += 4) {\n brightness =\n (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;\n data[i] = brightness * red;\n data[i + 1] = brightness * green;\n data[i + 2] = brightness * blue;\n data[i + 3] = data[i + 3];\n }\n};\nexports.RGB = RGB;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.RGBA = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst RGBA = function (imageData) {\n var data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha(), i, ia;\n for (i = 0; i < nPixels; i += 4) {\n ia = 1 - alpha;\n data[i] = red * alpha + data[i] * ia;\n data[i + 1] = green * alpha + data[i + 1] * ia;\n data[i + 2] = blue * alpha + data[i + 2] * ia;\n }\n};\nexports.RGBA = RGBA;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {\n this._filterUpToDate = false;\n if (val > 255) {\n return 255;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return Math.round(val);\n }\n});\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'alpha', 1, function (val) {\n this._filterUpToDate = false;\n if (val > 1) {\n return 1;\n }\n else if (val < 0) {\n return 0;\n }\n else {\n return val;\n }\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Sepia = void 0;\nconst Sepia = function (imageData) {\n var data = imageData.data, nPixels = data.length, i, r, g, b;\n for (i = 0; i < nPixels; i += 4) {\n r = data[i + 0];\n g = data[i + 1];\n b = data[i + 2];\n data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189);\n data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168);\n data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);\n }\n};\nexports.Sepia = Sepia;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Solarize = void 0;\nconst Solarize = function (imageData) {\n var data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h;\n do {\n var offsetY = (y - 1) * w4;\n var x = w;\n do {\n var offset = offsetY + (x - 1) * 4;\n var r = data[offset];\n var g = data[offset + 1];\n var b = data[offset + 2];\n if (r > 127) {\n r = 255 - r;\n }\n if (g > 127) {\n g = 255 - g;\n }\n if (b > 127) {\n b = 255 - b;\n }\n data[offset] = r;\n data[offset + 1] = g;\n data[offset + 2] = b;\n } while (--x);\n } while (--y);\n};\nexports.Solarize = Solarize;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Threshold = void 0;\nconst Factory_1 = require(\"../Factory\");\nconst Node_1 = require(\"../Node\");\nconst Validators_1 = require(\"../Validators\");\nconst Threshold = function (imageData) {\n var level = this.threshold() * 255, data = imageData.data, len = data.length, i;\n for (i = 0; i < len; i += 1) {\n data[i] = data[i] < level ? 0 : 255;\n }\n};\nexports.Threshold = Threshold;\nFactory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Konva = void 0;\nconst _CoreInternals_1 = require(\"./_CoreInternals\");\nconst Arc_1 = require(\"./shapes/Arc\");\nconst Arrow_1 = require(\"./shapes/Arrow\");\nconst Circle_1 = require(\"./shapes/Circle\");\nconst Ellipse_1 = require(\"./shapes/Ellipse\");\nconst Image_1 = require(\"./shapes/Image\");\nconst Label_1 = require(\"./shapes/Label\");\nconst Line_1 = require(\"./shapes/Line\");\nconst Path_1 = require(\"./shapes/Path\");\nconst Rect_1 = require(\"./shapes/Rect\");\nconst RegularPolygon_1 = require(\"./shapes/RegularPolygon\");\nconst Ring_1 = require(\"./shapes/Ring\");\nconst Sprite_1 = require(\"./shapes/Sprite\");\nconst Star_1 = require(\"./shapes/Star\");\nconst Text_1 = require(\"./shapes/Text\");\nconst TextPath_1 = require(\"./shapes/TextPath\");\nconst Transformer_1 = require(\"./shapes/Transformer\");\nconst Wedge_1 = require(\"./shapes/Wedge\");\nconst Blur_1 = require(\"./filters/Blur\");\nconst Brighten_1 = require(\"./filters/Brighten\");\nconst Contrast_1 = require(\"./filters/Contrast\");\nconst Emboss_1 = require(\"./filters/Emboss\");\nconst Enhance_1 = require(\"./filters/Enhance\");\nconst Grayscale_1 = require(\"./filters/Grayscale\");\nconst HSL_1 = require(\"./filters/HSL\");\nconst HSV_1 = require(\"./filters/HSV\");\nconst Invert_1 = require(\"./filters/Invert\");\nconst Kaleidoscope_1 = require(\"./filters/Kaleidoscope\");\nconst Mask_1 = require(\"./filters/Mask\");\nconst Noise_1 = require(\"./filters/Noise\");\nconst Pixelate_1 = require(\"./filters/Pixelate\");\nconst Posterize_1 = require(\"./filters/Posterize\");\nconst RGB_1 = require(\"./filters/RGB\");\nconst RGBA_1 = require(\"./filters/RGBA\");\nconst Sepia_1 = require(\"./filters/Sepia\");\nconst Solarize_1 = require(\"./filters/Solarize\");\nconst Threshold_1 = require(\"./filters/Threshold\");\nexports.Konva = _CoreInternals_1.Konva.Util._assign(_CoreInternals_1.Konva, {\n Arc: Arc_1.Arc,\n Arrow: Arrow_1.Arrow,\n Circle: Circle_1.Circle,\n Ellipse: Ellipse_1.Ellipse,\n Image: Image_1.Image,\n Label: Label_1.Label,\n Tag: Label_1.Tag,\n Line: Line_1.Line,\n Path: Path_1.Path,\n Rect: Rect_1.Rect,\n RegularPolygon: RegularPolygon_1.RegularPolygon,\n Ring: Ring_1.Ring,\n Sprite: Sprite_1.Sprite,\n Star: Star_1.Star,\n Text: Text_1.Text,\n TextPath: TextPath_1.TextPath,\n Transformer: Transformer_1.Transformer,\n Wedge: Wedge_1.Wedge,\n Filters: {\n Blur: Blur_1.Blur,\n Brighten: Brighten_1.Brighten,\n Contrast: Contrast_1.Contrast,\n Emboss: Emboss_1.Emboss,\n Enhance: Enhance_1.Enhance,\n Grayscale: Grayscale_1.Grayscale,\n HSL: HSL_1.HSL,\n HSV: HSV_1.HSV,\n Invert: Invert_1.Invert,\n Kaleidoscope: Kaleidoscope_1.Kaleidoscope,\n Mask: Mask_1.Mask,\n Noise: Noise_1.Noise,\n Pixelate: Pixelate_1.Pixelate,\n Posterize: Posterize_1.Posterize,\n RGB: RGB_1.RGB,\n RGBA: RGBA_1.RGBA,\n Sepia: Sepia_1.Sepia,\n Solarize: Solarize_1.Solarize,\n Threshold: Threshold_1.Threshold,\n },\n});\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst _FullInternals_1 = require(\"./_FullInternals\");\nmodule.exports = _FullInternals_1.Konva;\n","import _slicedToArray from\"@babel/runtime/helpers/slicedToArray\";function _createForOfIteratorHelper(a,b){var c=\"undefined\"!=typeof Symbol&&a[Symbol.iterator]||a[\"@@iterator\"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&\"number\"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c[\"return\"]||c[\"return\"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if(\"string\"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return\"Object\"===c&&a.constructor&&(c=a.constructor.name),\"Map\"===c||\"Set\"===c?Array.from(a):\"Arguments\"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);cc?-1:c,c=~~(255*c),[b[0]+c,b[1]+c,b[2]+c]}},contrast:function contrast(a){return function(b){var c=a;c*=255;var d=259*(c+255)/(255*(259-c));return[d*(b[0]-128)+128,d*(b[1]-128)+128,d*(b[2]-128)+128]}},saturation:function saturation(a){return function(c){var d=a;d=-1>d?-1:d;var e=c[0],f=c[1],g=c[2],b=.2989*e+.587*f+.114*g;return[-b*d+e*(1+d),-b*d+f*(1+d),-b*d+g*(1+d)]}},grayscale:function grayscale(){return function(a){var c=a[0],d=a[1],e=a[2];return[,,,].fill(.2126*c+.7152*d+.0722*e)}},sepia:function sepia(a){return function(c){var d=c[0],e=c[1],f=c[2];return[d*(1-.607*a)+.769*e*a+.189*f*a,.349*d*a+e*(1-.314*a)+.168*f*a,.272*d*a+.534*e*a+f*(1-.869*a)]}},adjustRGB:function adjustRGB(a){return function(b){return[b[0]*a[0],b[1]*a[1],b[2]*a[2]]}},colorFilter:function colorFilter(a){return function(c){var d=c[0],e=c[1],f=c[2],b=a[3];return[d-(d-a[0])*b,e-(e-a[1])*b,f-(f-a[2])*b]}}};export default BaseFilters;","import BaseFilters from\"./BaseFilters\";function BlackAndWhite(a){BaseFilters.apply(a,function(a){var b=(a[0]+a[1]+a[2])/3>100,c=b?255:0;return[c,c,c]})}BlackAndWhite.filterName=\"BlackAndWhite\";export default BlackAndWhite;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.1,CONTRAST_CONST=.1,SATURATION_CONST=.15;function Clarendon(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.contrast(CONTRAST_CONST),BaseFilters.saturation(SATURATION_CONST))}Clarendon.filterName=\"Clarendon\";export default Clarendon;","import BaseFilters from\"./BaseFilters\";var SEPIA_CONST=.04,CONTRAST_CONST=-.15;function Gingham(a){BaseFilters.apply(a,BaseFilters.sepia(SEPIA_CONST),BaseFilters.contrast(CONTRAST_CONST))}Gingham.filterName=\"Gingham\";export default Gingham;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.1;function Moon(a){BaseFilters.apply(a,BaseFilters.grayscale(),BaseFilters.brightness(BRIGHTNESS_CONST));var b=a.data,c=b.length}Moon.filterName=\"Moon\";export default Moon;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.08,ADJUST_RGB_CONST=[1,1.03,1.05],SATURATION_CONST=.12;function Lark(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.adjustRGB(ADJUST_RGB_CONST),BaseFilters.saturation(SATURATION_CONST))}Lark.filterName=\"Lark\";export default Lark;","import BaseFilters from\"./BaseFilters\";var SEPIA_CONST=.4,BRIGHTNESS_CONST=.13,CONTRAST_CONST=-.05;function Reyes(a){BaseFilters.apply(a,BaseFilters.sepia(SEPIA_CONST),BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.contrast(CONTRAST_CONST))}Reyes.filterName=\"Reyes\";export default Reyes;","import BaseFilters from\"./BaseFilters\";var ADJUST_RGB_CONST=[1.01,1.04,1],SATURATION_CONST=.3;function Juno(a){BaseFilters.apply(a,BaseFilters.adjustRGB(ADJUST_RGB_CONST),BaseFilters.saturation(SATURATION_CONST))}Juno.filterName=\"Juno\";export default Juno;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.1,SATURATION_CONST=-.5;function Slumber(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.saturation(SATURATION_CONST))}Slumber.filterName=\"Slumber\";export default Slumber;","import BaseFilters from\"./BaseFilters\";var ADJUST_RGB_CONST=[1.04,1,1.02],SATURATION_CONST=-.05;function Crema(a){BaseFilters.apply(a,BaseFilters.adjustRGB(ADJUST_RGB_CONST),BaseFilters.saturation(SATURATION_CONST))}Crema.filterName=\"Crema\";export default Crema;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.05,SATURATION_CONST=-.03;function Ludwig(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.saturation(SATURATION_CONST))}Ludwig.filterName=\"Ludwig\";export default Ludwig;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[228,130,225,.13],SATURATION_CONST=-.2;function Aden(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.saturation(SATURATION_CONST))}Aden.filterName=\"Aden\";export default Aden;","import BaseFilters from\"./BaseFilters\";var ADJUST_RGB_CONST=[1.05,1.1,1];function Perpetua(a){BaseFilters.apply(a,BaseFilters.adjustRGB(ADJUST_RGB_CONST))}Perpetua.filterName=\"Perpetua\";export default Perpetua;","import BaseFilters from\"./BaseFilters\";var SATURATION_CONST=.3,BRIGHTNESS_CONST=.15;function Amaro(a){BaseFilters.apply(a,BaseFilters.saturation(SATURATION_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Amaro.filterName=\"Amaro\";export default Amaro;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[230,115,108,.05],SATURATION_CONST=.15;function Mayfair(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.saturation(SATURATION_CONST))}Mayfair.filterName=\"Mayfair\";export default Mayfair;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,170,0,.1],BRIGHTNESS_CONST=.09,SATURATION_CONST=.1;function Rise(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.saturation(SATURATION_CONST))}Rise.filterName=\"Rise\";export default Rise;","import BaseFilters from\"./BaseFilters\";var ADJUST_RGB_CONST=[1,1,1.25],CONTRAST_CONST=.1,BRIGHTNESS_CONST=.15;function Hudson(a){BaseFilters.apply(a,BaseFilters.adjustRGB(ADJUST_RGB_CONST),BaseFilters.contrast(CONTRAST_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Hudson.filterName=\"Hudson\";export default Hudson;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,225,80,.08],SATURATION_CONST=.1,CONTRAST_CONST=.05;function Valencia(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.saturation(SATURATION_CONST),BaseFilters.contrast(CONTRAST_CONST))}Valencia.filterName=\"Valencia\";export default Valencia;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,255,0,.07],SATURATION_CONST=.2,CONTRAST_CONST=.15;function XPro2(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.saturation(SATURATION_CONST),BaseFilters.contrast(CONTRAST_CONST))}XPro2.filterName=\"XPro2\";export default XPro2;","import BaseFilters from\"./BaseFilters\";var CONTRAST_CONST=-.15,SATURATION_CONST=.1;function Sierra(a){BaseFilters.apply(a,BaseFilters.contrast(CONTRAST_CONST),BaseFilters.saturation(SATURATION_CONST))}Sierra.filterName=\"Sierra\";export default Sierra;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[100,28,210,.03],BRIGHTNESS_CONST=.1;function Willow(a){BaseFilters.apply(a,BaseFilters.grayscale(),BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Willow.filterName=\"Willow\";export default Willow;","import BaseFilters from\"./BaseFilters\";var CONTRAST_CONST=.15,SATURATION_CONST=.2;function LoFi(a){BaseFilters.apply(a,BaseFilters.contrast(CONTRAST_CONST),BaseFilters.saturation(SATURATION_CONST))}LoFi.filterName=\"LoFi\";export default LoFi;","import BaseFilters from\"./BaseFilters\";var CONTRAST_CONST=.1,SATURATION_CONST=.15;function Hefe(a){BaseFilters.apply(a,BaseFilters.contrast(CONTRAST_CONST),BaseFilters.saturation(SATURATION_CONST))}Hefe.filterName=\"Hefe\";export default Hefe;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[220,115,188,.12],CONTRAST_CONST=-.05;function Nashville(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.contrast(CONTRAST_CONST))}Nashville.filterName=\"Nashville\";export default Nashville;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.1,SEPIA_CONST=.3;function Stinson(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.sepia(SEPIA_CONST))}Stinson.filterName=\"Stinson\";export default Stinson;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,225,0,.05],BRIGHTNESS_CONST=.06,CONTRAST_CONST=.06;function Vesper(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.contrast(CONTRAST_CONST))}Vesper.filterName=\"Vesper\";export default Vesper;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,165,40,.2];function Earlybird(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST))}Earlybird.filterName=\"Earlybird\";export default Earlybird;","import BaseFilters from\"./BaseFilters\";var CONTRAST_CONST=.2,COLOR_FILTER_CONST=[140,10,185,.1];function Brannan(a){BaseFilters.apply(a,BaseFilters.contrast(CONTRAST_CONST),BaseFilters.colorFilter(COLOR_FILTER_CONST))}Brannan.filterName=\"Brannan\";export default Brannan;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=-.1,SATURATION_CONST=-.1;function Sutro(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.saturation(SATURATION_CONST))}Sutro.filterName=\"Sutro\";export default Sutro;","import BaseFilters from\"./BaseFilters\";var SEPIA_CONST=.1,COLOR_FILTER_CONST=[255,145,0,.2];function Toaster(a){BaseFilters.apply(a,BaseFilters.sepia(SEPIA_CONST),BaseFilters.colorFilter(COLOR_FILTER_CONST))}Toaster.filterName=\"Toaster\";export default Toaster;","import BaseFilters from\"./BaseFilters\";var BRIGHTNESS_CONST=.1,COLOR_FILTER_CONST=[255,255,0,.2];function Walden(a){BaseFilters.apply(a,BaseFilters.brightness(BRIGHTNESS_CONST),BaseFilters.colorFilter(COLOR_FILTER_CONST))}Walden.filterName=\"Walden\";export default Walden;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,25,0,.15],BRIGHTNESS_CONST=.1;function NinteenSeventySeven(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}NinteenSeventySeven.filterName=\"NinteenSeventySeven\";export default NinteenSeventySeven;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,140,0,.1],ADJUST_RGB_CONST=[1.15,1.05,1],SATURATION_CONST=.35;function Kelvin(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.adjustRGB(ADJUST_RGB_CONST),BaseFilters.saturation(SATURATION_CONST))}Kelvin.filterName=\"Kelvin\";export default Kelvin;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[225,240,0,.1],SATURATION_CONST=.25,CONTRAST_CONST=.05;function Maven(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.saturation(SATURATION_CONST),BaseFilters.contrast(CONTRAST_CONST))}Maven.filterName=\"Maven\";export default Maven;","import BaseFilters from\"./BaseFilters\";var SEPIA_CONST=.06,BRIGHTNESS_CONST=.1;function Ginza(a){BaseFilters.apply(a,BaseFilters.sepia(SEPIA_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Ginza.filterName=\"Ginza\";export default Ginza;","import BaseFilters from\"./BaseFilters\";var SATURATION_CONST=.35,BRIGHTNESS_CONST=.1;function Skyline(a){BaseFilters.apply(a,BaseFilters.saturation(SATURATION_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Skyline.filterName=\"Skyline\";export default Skyline;","import BaseFilters from\"./BaseFilters\";var CONTRAST_CONST=.15,BRIGHTNESS_CONST=.1;function Dogpatch(a){BaseFilters.apply(a,BaseFilters.contrast(CONTRAST_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Dogpatch.filterName=\"Dogpatch\";export default Dogpatch;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[25,240,252,.05],SEPIA_CONST=.3;function Brooklyn(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.sepia(SEPIA_CONST))}Brooklyn.filterName=\"Brooklyn\";export default Brooklyn;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[208,208,86,.2],CONTRAST_CONST=.15;function Helena(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.contrast(CONTRAST_CONST))}Helena.filterName=\"Helena\";export default Helena;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,160,25,.1],BRIGHTNESS_CONST=.1;function Ashby(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.brightness(BRIGHTNESS_CONST))}Ashby.filterName=\"Ashby\";export default Ashby;","import BaseFilters from\"./BaseFilters\";var COLOR_FILTER_CONST=[255,50,80,.12],CONTRAST_CONST=.05;function Charmes(a){BaseFilters.apply(a,BaseFilters.colorFilter(COLOR_FILTER_CONST),BaseFilters.contrast(CONTRAST_CONST))}Charmes.filterName=\"Charmes\";export default Charmes;","import Konva from\"konva\";import*as CustomFilters from\"../custom/filters\";var filterStrToClass=function(a){return a?CustomFilters[a]||Konva.Filters[a]:null};export default filterStrToClass;","import Konva from\"konva\";import{Factory as KonvaFactory}from\"konva/lib/Factory\";import{getNumberValidator as konvaGetNumberValidator}from\"konva/lib/Validators\";function Warmth(a){for(var b=this.warmth(),c=a.data,d=c.length,e=0;e=b?255:0,c[e+1]=c[e+1]>=b?255:0,c[e+2]=c[e+2]>=b?255:0)}CustomThreshold.finetuneName=\"CustomThreshold\";export default CustomThreshold;KonvaFactory.addGetterSetter(Konva.Image,\"threshold\",0,konvaGetNumberValidator,KonvaFactory.afterSetFilter);","import Konva from\"konva\";import*as CustomFinetunes from\"../custom/finetunes\";var finetunesStrsToClasses=function(a){return Array.isArray(a)&&0d.status)b(d.response);else{var a;console.warn(\"Error in sending translation key to backend \".concat(null===(a=d.response)||void 0===a?void 0:a.hint,\", \").concat(d.status)),c()}},d.onerror=function(){var a;console.warn(\"Error in sending translation key to backend \".concat(null===(a=d.response)||void 0===a?void 0:a.hint,\", \").concat(d.status)),c()};d.open(\"POST\",\"https://neo.wordplex.io/api/import/request-translations?grid_uuid=\".concat(TRANSLATIONS_GRID_UUID)),d.send(JSON.stringify({grid_uuid:TRANSLATIONS_GRID_UUID,translations_requests:a}))})};export var getBackendTranslations=function(){var a=0f.status){(f.response||[]).forEach(function(a){backendTranslations[e]=_objectSpread(_objectSpread({},backendTranslations[e]),{},_defineProperty({},a.translation_key,a.translations[e]))});var a=[];Object.keys(defaultTranslations).forEach(function(b){var c;b&&!(null!==(c=backendTranslations[e])&&void 0!==c&&c[b])&&a.push({key:b,lang:e,default:defaultTranslations[b]})}),0d,l=0>e;switch(b){case TOOLS_IDS.RECT:c?(h.width=Math.sqrt(i*i+j*j),h.height=h.width,h.x-=k?h.width-i:0,h.y-=l?h.height-j:0):(h.width=i,h.height=j);break;case TOOLS_IDS.ELLIPSE:c?(h.radiusX=Math.sqrt(i*i+j*j)/2,h.radiusY=h.radiusX,h.x-=k?2*h.radiusX-i:0,h.y-=l?2*h.radiusY-j:0):(h.radiusX=i/2,h.radiusY=j/2),h.offsetX=-h.radiusX,h.offsetY=-h.radiusY;break;case TOOLS_IDS.POLYGON:h.radius=(i+j)/2,h.x-=k?2*h.radius-i:0,h.y-=l?2*h.radius-j:0,h.offsetX=-h.radius,h.offsetY=-h.radius;break;case TOOLS_IDS.LINE:case TOOLS_IDS.ARROW:h.x=f,h.y=g,h.points=[0,0],c?h.points.push(i>=j?d:0,j>i?e:0):h.points=[0,0,d,e];break;default:h.width=i,h.height=j}return h};export default getNewAnnotationPreview;","import _objectWithoutProperties from\"@babel/runtime/helpers/objectWithoutProperties\";import _defineProperty from\"@babel/runtime/helpers/defineProperty\";var _excluded=[\"id\",\"x\",\"y\",\"points\"],_excluded2=[\"startedX\",\"startedY\",\"offsetX\",\"offsetY\",\"width\",\"height\"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c=MIN_PIXELS&&latestAnnotationProps.height>=MIN_PIXELS||latestAnnotationProps.radiusX>=MIN_PIXELS&&latestAnnotationProps.radiusY>=MIN_PIXELS||null!==(c=latestAnnotationProps.points)&&void 0!==c&&c[2]||null!==(e=latestAnnotationProps.points)&&void 0!==e&&e[3]||latestAnnotationProps.radius>=MIN_PIXELS)){var f=latestAnnotationProps,g=f.startedX,h=f.startedY,i=f.offsetX,o=f.offsetY,p=f.width,q=f.height,r=_objectWithoutProperties(f,_excluded2);NO_WIDTH_HEIGHT_ANNOTATIONS.includes(b.name)||(r.width=p,r.height=q),d(r,!0)}shownAnnotationPreview=null,textAnnotationWrappedRect=null,latestAnnotationProps=null,a.setAttrs({isDrawing:!1}),a.off(\"mousemove touchmove\",l),a.off(\"mouseleave touchcancel\",m),document.removeEventListener(\"mouseup\",n,eventsOptions),document.removeEventListener(\"touchend\",n,eventsOptions),document.removeEventListener(\"mouseleave\",n,eventsOptions),document.removeEventListener(\"touchcancel\",n,eventsOptions),document.removeEventListener(\"mousemove\",j,eventsOptions),document.removeEventListener(\"touchmove\",j,eventsOptions),pointerDown.isOutOfCanvas=!1},o=function handlePointerDown(b){var d;if(b.evt.preventDefault(),!(b.target.attrs.draggable||1<(null===(d=b.evt.touches)||void 0===d?void 0:d.length))){k();var e=getPointerOffsetPositionBoundedToObject(c,f());pointerDown.startedX=e.offsetX,pointerDown.startedY=e.offsetY,pointerDown.isOutOfCanvas=!1,a.on(\"mousemove touchmove\",l),a.on(\"mouseleave touchcancel\",m),document.addEventListener(\"mouseup\",n,eventsOptions),document.addEventListener(\"touchend\",n,eventsOptions),document.addEventListener(\"mouseleave\",n,eventsOptions),document.addEventListener(\"touchcancel\",n,eventsOptions)}};return a.on(\"mousedown touchstart\",o),function(){k(),a.off(\"mousedown touchstart\",o)}};export default previewThenCallAnnotationAdding;","import{useCallback}from\"react\";import debounce from\"../utils/debounce\";var useDebouncedCallback=function(a,b){var c=2=e?0:function getTopOffset(){return 0>e&&-90=e&&-90<=e?0:function getLeftOffset(){return 90>>32-b},cvtHex=function(a){var b,c,d=\"\";for(b=7;0<=b;b--)c=15&a>>>4*b,d+=c.toString(16);return d},Utf8Encode=function(a){for(var b,d=a.replace(/\\r\\n/g,\"\\n\"),e=\"\",f=0;fb?e+=String.fromCharCode(b):127