presi-slides 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Ken Kubiak
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,111 @@
1
+ var e=class extends CustomEvent{constructor(e,t){super(e,{bubbles:!0,cancelable:!0,composed:!0,detail:t})}};function t(e,...t){let n={execute(){console.log(`▶️ Executing created effect:`,t,e),e(...t.map(e=>e.open(n))),t.forEach(e=>e.close())}};n.execute()}var n=class e{constructor(){this.signals=new WeakMap,this.scheduled=new WeakSet}static{this.scheduler=new e}subscribe(e,t,n){let r=this.signals.get(e);r||(r=new Map,this.signals.set(e,r));let i=r.get(t);i||(i=new Set,r.set(t,i)),i.add(n)}scheduleEffects(e,t){let n=this.signals.get(e);if(!n)return;let r=n.get(t);if(r)for(let e of r)this.scheduled.has(e)||(this.scheduled.add(e),setTimeout(()=>{this.scheduled.delete(e),e.execute()}))}},r=class{constructor(){this.running=[],this.eventType=`un-effect:change`}isRunning(){return this.running.length>0}push(e){this.running.push(e)}pop(){this.running.pop()}current(){let e=this.running.length;return e?this.running[e-1]:void 0}subscribe(e,t){let r=this.current();r&&n.scheduler.subscribe(t,e,r)}runEffects(t,r){if(console.log(`⚙️ Running effects for signal`,t,r),n.scheduler.scheduleEffects(r,t),this.host){let n=new e(this.eventType,{property:t,value:r[t]});this.host.dispatchEvent(n)}}setHost(e,t){this.host=e,t&&(this.eventType=t)}},i=class{static{this.CHANGE_EVENT_TYPE=`un-context:change`}constructor(e,t){t?(this.manager=t.manager,this.object=t.object,this.proxy=t.proxy,this.update(e)):(this.manager=new r,this.object=e,this.proxy=a(this.object,this.manager))}get(e){return this.proxy[e]}set(e,t){this.proxy[e]=t}toObject(){return this.proxy}update(e){Object.assign(this.proxy,e)}apply(e){this.update(e(this.proxy))}createEffect(e){t(e,this)}setHost(e,t){this.manager.setHost(e,t)}open(e){return this.manager.push(e),this.proxy}close(){this.manager.pop()}};function a(e,t){return new Proxy(e,{get:(e,n,r)=>{let i=Reflect.get(e,n,r);return t.isRunning()&&o(i)&&t.subscribe(n,e),i},set:(e,n,r,i)=>{let a=Reflect.set(e,n,r,i);return a&&o(r)&&t.runEffects(n,e),a}})}function o(e){switch(typeof e){case`object`:case`number`:case`string`:case`symbol`:case`boolean`:case`undefined`:return!0;default:return!1}}function s(e,...t){let n=e.map((e,n)=>n?[t[n-1],e]:[e]).flat().join(``),r=new CSSStyleSheet;return r.replaceSync(n),r}function c(e){return Object.entries(e).map(([e,t])=>{customElements.get(e)||customElements.define(e,t)}),customElements}function l(e,t){return Object.assign(e,{render:t}),e}function u(e,t,...n){let r=e.cloneNode(!0);return Array.from(t.entries()).forEach(([e,t])=>{let i=r.querySelector(`[data-${e}]`);i&&t.forEach(e=>e(i,r,...n))}),r}var d=class e{static{this.parser=new DOMParser}constructor(e){this.docType=`text/html`,this.plugins=[],e&&(this.docType=e)}use(e){this.plugins=this.plugins.concat(e)}parse(t,n){let r={},i=t.map((e,i)=>{if(i>=n.length)return[e];let a=n[i],o=this.classifyPlace(i,t),s=this.tryReplacements(o,a);if(s){let t=r[o.nodeLabel];switch(t?t.push(s):r[o.nodeLabel]=[s],o.kind){case`attr value`:return[e,`"" data-${o.nodeLabel}`];case`tag content`:return[e,`data-${o.nodeLabel}`];case`element content`:return[e,`<ins data-${o.nodeLabel}></ins>`]}}else throw console.error(`No match for template parameter`,o,a),`Failed to render template parameter ${i} around ${e}`;return[e]}).flat().join(``),a=e.parser.parseFromString(i,this.docType),o=a.head.childElementCount?a.head.children:a.body.children,s=new DocumentFragment;s.replaceChildren(...o);let c=new Map;for(let e in r){let t=s.querySelector(`[data-${e}]`);t&&r[e].forEach(n=>{let r=n.apply(t,s);if(r){let t=c.get(e);t?t.push(r):c.set(e,[r])}})}return l(s,(...e)=>u(s,c,...e))}static{this.OPEN_RE=/<([a-zA-z][$a-zA-Z0-9.-]*)\s+[^>]*$/}static{this.IN_TAG_RE=/^(\s+|[^<>]*|"[^"]*")*$/}static{this.ATTR_RE=/([$.]?[a-zA-Z][$a-zA-Z0-9.-]*)=\s*$/}static{this.CLOSE_RE=/[/]?>[^<]*$/}classifyPlace(t,n){let r=null;for(let i=t;i>=0&&!(n[i].match(e.CLOSE_RE)||(r=n[i].match(e.OPEN_RE),r)||!n[i].match(e.IN_TAG_RE));i--);if(r){let i=n[t].match(e.ATTR_RE);return i?{kind:`attr value`,nodeLabel:`node${t}`,tagName:r[1],attrName:i[1]}:{kind:`tag content`,nodeLabel:`node${t}`,tagName:r[1]}}return{kind:`element content`,nodeLabel:`node${t}`}}tryReplacements(e,t){let n=this.plugins;for(let r=0;r<n.length;r++){let i=n[r];if(e.kind===i.place&&f(t,i))return i.mutator(e,t)}}};function f(e,t){return typeof t.types==`function`?t.types(e,t):t.types.includes(typeof e)}var p=class{constructor(e){this.place=e}apply(e,t){throw`abstract method 'apply' called`}},m=class extends p{constructor(e,t){super(e),this.content=t}apply(e,t){(e.parentNode||t).replaceChild(this.content,e)}},h=class extends p{constructor(e,t){super(e),this.text=t,this.name=e.attrName}apply(e){e.setAttribute(this.name,this.text)}},g=class extends p{constructor(e,t){super(e),this.fn=t}apply(e,n){let r=this.place.nodeLabel;return(e,n,...i)=>{let a=new Comment(` <<< ${r} `),o=new Comment(` >>> ${r} `),s=new DocumentFragment;s.replaceChildren(a,o),(e.parentNode||n).replaceChild(s,e),t((...e)=>{_(this.fn(...e),a,o)},...i)}}};function _(e,t,n){let r=t.parentNode;if(!r)throw Error(`No parent for placeholder`);let i=e=>{if(Array.isArray(e)){let t=new DocumentFragment,n=e.map(i);return t.replaceChildren(...n),t}return e instanceof Node?e:new Text(e?.toString()||``)},a=i(e),o=t.nextSibling;for(;o&&o!==n;){let e=o;o=o.nextSibling,r.removeChild(e)}a&&r.insertBefore(a,n)}var v=class extends p{constructor(e,t){super(e),this.fn=t,this.name=e.attrName}apply(e,n){return(e,n,...r)=>t((...t)=>{y(this.fn(...t),e,this.name)},...r)}};function y(e,t,n){let r=n.match(/^([.$])(.+)$/);if(r){let[n,a,o]=r;switch(a){case`.`:t[o]=e;break;case`$`:`viewModel`in t&&t.viewModel instanceof i&&t.viewModel.set(o,e)}}else switch(typeof e){case`string`:t.setAttribute(n,e);break;case`undefined`:case`object`:case`boolean`:e?t.setAttribute(n,n):t.removeAttribute(n);break;default:t.setAttribute(n,e?.toString())}}var b=class extends p{constructor(e,t){super(e),this.fn=t}apply(e,n){return(e,n,...r)=>t((...t)=>{let n=this.fn(...t);typeof n==`function`&&n(e)},...r)}},x=new d;x.use([{place:`element content`,types:[`string`,`number`,`bigint`,`symbol`,`boolean`],mutator:(e,t)=>new m(e,new Text(t?.toString()||``))},{place:`attr value`,types:[`string`,`number`,`bigint`,`symbol`],mutator:(e,t)=>new h(e,t?.toString()||``)},{place:`element content`,types:e=>e instanceof Node,mutator:(e,t)=>new m(e,t)},{place:`element content`,types:e=>Array.isArray(e),mutator:(e,t)=>{let n=new DocumentFragment,r=t.map(e=>e instanceof Node?e:new Text(e?.toString()||``));return n.append(...r),new m(e,n)}},{place:`element content`,types:[`function`],mutator:(e,t)=>new g(e,t)},{place:`attr value`,types:[`function`],mutator:(e,t)=>new v(e,t)},{place:`tag content`,types:[`function`],mutator:(e,t)=>new b(e,t)}]);function S(e,...t){return x.parse(e,t)}function C(e,t){for(let n in t)e.addEventListener(n,t[n])}function w(e,t,n){for(let r in n)e.addEventListener(r,function(i){let a=i.target;a&&a instanceof HTMLElement&&(a.matches(t)||e.contains(a.closest(t)))&&n[r](i)})}function ee(e,t,n){let r=e.target,i=new CustomEvent(t,{bubbles:!0,composed:!0,detail:n});r.dispatchEvent(i),e.stopPropagation()}var te={listen:C,delegate:w,relay:ee};function ne(e,t={mode:`open`}){let n=e.shadowRoot||e.attachShadow(t),r={template:i,styles:a,replace:o,root:n,delegate:c,listen:s};return r;function i(e){let t=e.firstElementChild,i=t&&t.tagName===`TEMPLATE`?t:void 0;return i&&n.appendChild(i.content.cloneNode(!0)),r}function a(...e){return n.adoptedStyleSheets=e,r}function o(e){return n.replaceChildren(e),r}function s(e){return te.listen(n,e),r}function c(e,t){return te.delegate(n,e,t),r}}var T=class e extends HTMLElement{static template=S`
2
+ <template>
3
+ <footer>
4
+ <fieldset name="overlay">
5
+ <label>
6
+ <input type="radio" name="overlay" value="pointer" checked>
7
+ <span>Select</span>
8
+ </label>
9
+ <label>
10
+ <input type="radio" name="overlay" value="brush">
11
+ <span>Brush</span>
12
+ </label>
13
+ <label>
14
+ <input type="radio" name="overlay" value="eraser">
15
+ <span>Eraser</span>
16
+ </label>
17
+ <label>
18
+ <input type="radio" name="overlay" value="hidden">
19
+ <span>Hide</span>
20
+ </label>
21
+ </fieldset>
22
+ <span>
23
+ <input name="slide" type="number" min="1" value="1">
24
+ /
25
+ <slot name="count">N</span>
26
+ </span>
27
+ </footer>
28
+ </template>
29
+ `;static styles=s`
30
+ footer {
31
+ display: flex;
32
+ justify-content: space-between;
33
+ color: var(--color-text-inverted);
34
+ }
35
+ span {
36
+ background: rgb(0 0 0 / 0.8);
37
+ border-radius: var(--size-spacing-small);
38
+ padding: var(--size-spacing-small);
39
+ }
40
+ input,
41
+ select {
42
+ font: inherit;
43
+ color: inherit;
44
+ line-height: inherit;
45
+ border: none;
46
+ border-radius: 1px;
47
+ background: transparent;
48
+ }
49
+ input[type="number"] {
50
+ width: 3em;
51
+ }
52
+ `;slideControl=null;overlayControl=null;constructor(){super(),ne(this).template(e.template).styles(e.styles).delegate(`input[name="slide"]`,{input:e=>this.relay(`slide:input`,{slide:e.target.value})}).delegate(`input[name="overlay"]`,{change:e=>this.relay(`slide:overlay`,{overlay:e.target.value})}),this.slideControl=this.shadowRoot.querySelector(`input[name="slide"]`),this.overlayControl=this.shadowRoot.querySelector(`fieldset[name="overlay"]`)}static observedAttributes=[`slide`,`overlay`,`color`];attributeChangedCallback(e,t,n){switch(e){case`slide`:this.slideControl.value=n;break;case`overlay`:{let e=this.overlayControl.querySelector(`input[value="${n}"]`);e&&(e.checked=!0);break}}}relay(e,t){let n=new CustomEvent(e,{bubbles:!0,composed:!0,detail:t});this.dispatchEvent(n)}},E=Math.PI/180;function re(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var D=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},O={_global:D,version:`10.3.1`,isBrowser:re(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return O.angleDeg?e*E:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return O.DD.isDragging},isTransforming(){return O.Transformer?.isTransforming()??!1},isDragReady(){return!!O.DD.node},releaseCanvasOnDestroy:!0,document:D.document,_injectGlobal(e){D.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),D.Konva=e}},k=e=>{O[e.prototype.getClassName()]=e};O._injectGlobal(O);var A=`Konva.js unsupported environment.
53
+
54
+ Looks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.
55
+
56
+ To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.
57
+
58
+ bash: npm install canvas
59
+ js: import "konva/canvas-backend";
60
+
61
+ or
62
+
63
+ bash: npm install skia-canvas
64
+ js: import "konva/skia-backend";
65
+ `,j=()=>{if(typeof document>`u`)throw Error(A)},M=class e{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=(e*n+t*r)/o}return s.rotation=N._getRotation(s.rotation),s}},ie=`[object Array]`,ae=`[object Number]`,oe=`[object String]`,se=`[object Boolean]`,ce=Math.PI/180,le=180/Math.PI,ue=`#`,de=``,fe=`0`,pe=`Konva warning: `,me=`Konva error: `,he={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ge=[],_e=null,ve=typeof requestAnimationFrame<`u`&&requestAnimationFrame||function(e){setTimeout(e,16)},ye=new Map,be=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},xe=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,Se=RegExp(`^(${xe})(%?)$`,`i`),Ce=(e,t)=>{let n=Se.exec(e);return n?n[2]?Number(n[1])/100*t:Number(n[1]):NaN},we=/^#[0-9a-f]+$/i,Te=e=>Math.min(Math.max(e,0),1),Ee=RegExp(`^(${xe})(deg|grad|rad|turn)?$`,`i`),De={deg:1,grad:.9,rad:le,turn:360},N={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===ie},_isNumber(e){return Object.prototype.toString.call(e)===ae&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===oe},_isBoolean(e){return Object.prototype.toString.call(e)===se},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){ge.push(e),ge.length===1&&ve(function(){let e=ge;ge=[],e.forEach(function(e){e()})})},createCanvasElement(){j();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return j(),document.createElement(`img`)},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){let n=N.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(ue,de);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=fe+e;return ue+e},isCanvasFarblingActive(){if(_e!==null)return _e;if(typeof document>`u`)return _e=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return _e=r,this.releaseCanvas(e),_e},getHitColor(){let e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),ue+this._rgbToHex(e,t,n)},getSnappedHexColor(e){let t=this._hexToRgb(e);return ue+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=N.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=N._namedColorToRBA(e)||N._hex3ColorToRGBA(e)||N._hex4ColorToRGBA(e)||N._hex6ColorToRGBA(e)||N._hex8ColorToRGBA(e)||N._rgbColorToRGBA(e)||N._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(N._isNumber))return t},_namedColorToRBA(e){let t=he[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:t.length>3?t[3]:1}:null},_rgbColorToRGBA(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=be(t[1]);if(!(n.length<3||n.length>4))return{r:Ce(n[0],255),g:Ce(n[1],255),b:Ce(n[2],255),a:n.length>3?Ce(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&we.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e.length===7&&we.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e.length===5&&we.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e.length===4&&we.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){let t=/^hsla?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=be(t[1]);if(n.length<3||n.length>4)return;let r=Ee.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?De[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=Te(Ce(n[1],100)/100),c=Te(Ce(n[2],100)/100),l=n.length>3?Ce(n[3],1):1,u=c<.5?c*(1+s):c+s-c*s,d=2*c-u,f=[0,0,0];for(let e=0;e<3;e++){let t=o+1/3*-(e-1);t<0&&t++,t>1&&t--;let n;n=6*t<1?d+(u-d)*6*t:2*t<1?u:3*t<2?d+(u-d)*(2/3-t)*6:d,f[e]=n*255}return{r:Math.round(f[0]),g:Math.round(f[1]),b:Math.round(f[2]),a:l}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){let t={};for(let n in e)t[n]=this._isPlainObject(e[n])?this.cloneObject(e[n]):this._isArray(e[n])?this.cloneArray(e[n]):e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*ce},radToDeg(e){return e*le},_degToRad(e){return N.warn(`Util._degToRad is removed. Please use public Util.degToRad instead.`),N.degToRad(e)},_radToDeg(e){return N.warn(`Util._radToDeg is removed. Please use public Util.radToDeg instead.`),N.radToDeg(e)},_getRotation(e){return O.angleDeg?N.radToDeg(e):e},_capitalize(e){let t=ye.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return ye.set(e,n),n},throw(e){throw Error(me+e)},error(e){console.error(me+e)},warn(e){O.showWarnings&&console.warn(pe+e)},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,i,a){let o,s,c,l=(e-n)*(e-n)+(t-r)*(t-r);if(l==0)o=e,s=t,c=(i-n)*(i-n)+(a-r)*(a-r);else{let u=((i-e)*(n-e)+(a-t)*(r-t))/l;u<0?(o=e,s=t,c=(e-i)*(e-i)+(t-a)*(t-a)):u>1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=N.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=N._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];d<i&&(r.x=l,r.y=u,i=d)}),r},_prepareArrayForTween(e,t,n){let r=[],i=[];if(e.length>t.length){let n=t;t=e,e=n}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let e=0;e<t.length;e+=2)i.push({x:t[e],y:t[e+1]});let a=[];return i.forEach(function(e){let t=N._getProjectionToLine(e,r,n);a.push(t.x),a.push(t.y)}),a},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(let n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]==`object`){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||N._isElement(e[n])){if(t.configurable)delete e[n];else return null}else if(N._prepareToStringify(e[n])===null){if(t.configurable)delete e[n];else return null}}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(let n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){O.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let o=0,s=0,c=0,l=0;typeof r==`number`?o=s=c=l=Math.min(r,t/2,n/2):(o=Math.min(r[0]||0,t/2,n/2),s=Math.min(r[1]||0,t/2,n/2),l=Math.min(r[2]||0,t/2,n/2),c=Math.min(r[3]||0,t/2,n/2)),e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-l),e.arc(i+t-l,a+n-l,l,0,Math.PI/2,!1),e.lineTo(i+c,a+n),e.arc(i+c,a+n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;a<n;a++){let o=t[(a-1+n)%n],s=t[a],c=t[(a+1)%n],l={x:s.x-o.x,y:s.y-o.y},u={x:c.x-s.x,y:c.y-s.y},d=Math.hypot(l.x,l.y),f=Math.hypot(u.x,u.y),p;p=typeof i==`number`?i:a<i.length?i[a]:0,p=r*Math.cos(Math.PI/n)*Math.min(1,p/r*2);let m={x:l.x/d,y:l.y/d},h={x:u.x/f,y:u.y/f},g={x:s.x-m.x*p,y:s.y-m.y*p},_={x:s.x+h.x*p,y:s.y+h.y*p};a===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y),e.arcTo(s.x,s.y,_.x,_.y,p)}}};function Oe(e){let t=[],n=e.length,r=N;for(let i=0;i<n;i++){let n=e[i];r._isNumber(n)?n=Math.round(n*1e3)/1e3:r._isString(n)||(n+=``),t.push(n)}return t}var ke=`,`,Ae=`(`,je=`)`,Me=`([`,Ne=`])`,Pe=`;`,Fe=`()`,Ie=`=`,Le=`arc.arcTo.beginPath.bezierCurveTo.clearRect.clip.closePath.createLinearGradient.createPattern.createRadialGradient.drawImage.ellipse.fill.fillText.getImageData.createImageData.lineTo.moveTo.putImageData.quadraticCurveTo.rect.roundRect.restore.rotate.save.scale.setLineDash.setTransform.stroke.strokeText.transform.translate`.split(`.`),Re=[`fillStyle`,`strokeStyle`,`shadowColor`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`letterSpacing`,`lineCap`,`lineDashOffset`,`lineJoin`,`lineWidth`,`miterLimit`,`direction`,`font`,`textAlign`,`textBaseline`,`globalAlpha`,`globalCompositeOperation`,`imageSmoothingEnabled`,`filter`],ze=100,Be=null;function Ve(){if(Be!==null)return Be;try{let e=N.createCanvasElement().getContext(`2d`);return e?!!e&&`filter`in e:(Be=!1,!1)}catch{return Be=!1,!1}}var He=class{constructor(e){this.canvas=e,O.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,i=``,a,o,s,c;for(a=0;a<r;a++)o=n[a],s=o.method,s?(c=o.args,i+=s,e?i+=Fe:N._isArray(c[0])?i+=Me+c.join(ke)+Ne:(t&&(c=c.map(e=>typeof e==`number`?Math.floor(e):e)),i+=Ae+c.join(ke)+je)):(i+=o.property,e||(i+=Ie+o.val)),i+=Pe;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ze&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_applyOpacity(e){let t=e.getAbsoluteOpacity();t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):`mozDash`in this._context?this._context.mozDash=e:`webkitLineDash`in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=Le.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Oe(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r<t;r++)a(Le[r]);e.setAttr=function(){n.apply(e,arguments);let t=arguments[0],r=arguments[1];(t===`shadowOffsetX`||t===`shadowOffsetY`||t===`shadowBlur`)&&(r/=this.canvas.getPixelRatio()),e._trace({property:t,val:r})}}_applyGlobalCompositeOperation(e){let t=e.attrs.globalCompositeOperation;!t||t===`source-over`||this.setAttr(`globalCompositeOperation`,t)}};Re.forEach(function(e){Object.defineProperty(He.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var Ue=class extends He{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:t})}_fillColor(e){let t=e.fill();this.setAttr(`fillStyle`,t),e._fillFunc(this)}_fillPattern(e){let t=this._context;`patternQuality`in t&&(t.patternQuality=t.imageSmoothingEnabled?`good`:`nearest`),this.setAttr(`fillStyle`,e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){let t=e._getLinearGradient();t&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_fillRadialGradient(e){let t=e._getRadialGradient();t&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_fill(e){let t=e.fill(),n=e.getFillPriority();if(t&&n===`color`){this._fillColor(e);return}let r=e.getFillPatternImage();if(r&&n===`pattern`){this._fillPattern(e);return}let i=e.getFillLinearGradientColorStops();if(i&&n===`linear-gradient`){this._fillLinearGradient(e);return}let a=e.getFillRadialGradientColorStops();if(a&&n===`radial-gradient`){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):i?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let e=0;e<r.length;e+=2)i.addColorStop(r[e],r[e+1]);this.setAttr(`strokeStyle`,i)}}_stroke(e){let t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr(`lineDashOffset`,e.dashOffset())),this.setAttr(`lineWidth`,e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr(`shadowColor`,`rgba(0,0,0,0)`),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr(`strokeStyle`,e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){let t=e.getShadowRGBA()??`black`,n=e.getShadowBlur()??5,r=e.getShadowOffset()??{x:0,y:0},i=e.getAbsoluteScale(),a=this.canvas.getPixelRatio(),o=i.x*a,s=i.y*a;this.setAttr(`shadowColor`,t),this.setAttr(`shadowBlur`,n*Math.min(Math.abs(o),Math.abs(s))),this.setAttr(`shadowOffsetX`,r.x*o),this.setAttr(`shadowOffsetY`,r.y*s)}},We=class extends He{constructor(e){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr(`fillStyle`,e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){let t=e.getStrokeScaleEnabled();if(!t){this.save();let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(e);let n=e.hitStrokeWidth(),r=n===`auto`?e.strokeWidth():n;this.setAttr(`lineWidth`,r),this.setAttr(`strokeStyle`,e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},Ge;function Ke(){if(Ge)return Ge;let e=N.createCanvasElement(),t=e.getContext(`2d`);return Ge=(function(){return(O._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),N.releaseCanvas(e),Ge}var qe=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;let t=(e||{}).pixelRatio||O.pixelRatio||Ke();this.pixelRatio=t,this._canvas=N.createCanvasElement(),this._canvas.style.padding=`0`,this._canvas.style.margin=`0`,this._canvas.style.border=`0`,this._canvas.style.background=`transparent`,this._canvas.style.position=`absolute`,this._canvas.style.top=`0`,this._canvas.style.left=`0`}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){let t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+`px`;let t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+`px`;let t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(e){return N.error(`Unable to get data URL. `+e.message+` For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.`),``}}}},Je=class extends qe{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new Ue(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Ye=class extends qe{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new We(this),this.setSize(e.width,e.height)}},P={get isDragging(){let e=!1;return P._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},justDragged:!1,get node(){let e;return P._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){let t=[];P._dragElements.forEach((n,r)=>{let{node:i}=n,a=i.getStage();a.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=N._getFirstPointerId(e));let o=a._changedPointerPositions.find(e=>e.id===n.pointerId);if(o){if(n.dragStatus!==`dragging`){let t=i.dragDistance();if(Math.max(Math.abs(o.x-n.startPointerPos.x),Math.abs(o.y-n.startPointerPos.y))<t||(i.startDrag({evt:e}),!i.isDragging()))return}i._setDragPosition(e,n),t.push(i)}}),t.forEach(t=>{t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e){let t=[];P._dragElements.forEach(n=>{let{node:r}=n,i=r.getStage();if(e&&i.setPointersPositions(e),!i._changedPointerPositions.find(e=>e.id===n.pointerId))return;(n.dragStatus===`dragging`||n.dragStatus===`stopped`)&&(P.justDragged=!0,O._mouseListenClick=!1,O._touchListenClick=!1,O._pointerListenClick=!1,n.dragStatus=`stopped`);let a=n.node.getLayer()||n.node instanceof O.Stage&&n.node;a&&t.indexOf(a)===-1&&t.push(a)}),t.forEach(e=>{e.draw()})},_endDragAfter(e){P._dragElements.forEach((t,n)=>{t.dragStatus===`stopped`&&t.node.fire(`dragend`,{type:`dragend`,target:t.node,evt:e},!0),t.dragStatus!==`dragging`&&P._dragElements.delete(n)})}};O.isBrowser&&(window.addEventListener(`mouseup`,P._endDragBefore,!0),window.addEventListener(`touchend`,P._endDragBefore,!0),window.addEventListener(`touchcancel`,P._endDragBefore,!0),window.addEventListener(`mousemove`,P._drag),window.addEventListener(`touchmove`,P._drag),window.addEventListener(`mouseup`,P._endDragAfter,!1),window.addEventListener(`touchend`,P._endDragAfter,!1),window.addEventListener(`touchcancel`,P._endDragAfter,!1));function Xe(e){return N._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||N._isBoolean(e)?e:Object.prototype.toString.call(e)}function Ze(e){return e>255?255:e<0?0:Math.round(e)}function F(){if(O.isUnminified)return function(e,t){return N._isNumber(e)||N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function Qe(e){if(O.isUnminified)return function(t,n){let r=N._isNumber(t),i=N._isArray(t)&&t.length==e;return!r&&!i&&N.warn(Xe(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array<number>(`+e+`)`),t}}function $e(){if(O.isUnminified)return function(e,t){return N._isNumber(e)||e===`auto`||N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function et(){if(O.isUnminified)return function(e,t){return N._isString(e)||N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function tt(){if(O.isUnminified)return function(e,t){let n=N._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function nt(){if(O.isUnminified)return function(e,t){let n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(N._isArray(e)?e.forEach(function(e){N._isNumber(e)||N.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function I(){if(O.isUnminified)return function(e,t){return e!==!0&&e!==!1&&N.warn(Xe(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function rt(e){if(O.isUnminified)return function(t,n){return t==null||N.isObject(t)||N.warn(Xe(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var it=`get`,at=`set`,L={addGetterSetter(e,t,n,r,i){L.addGetter(e,t,n),L.addSetter(e,t,r,i),L.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=it+N._capitalize(t);e.prototype[r]=e.prototype[r]||function(){let e=this.attrs[t];return e===void 0?n:e}},addSetter(e,t,n,r){let i=at+N._capitalize(t);e.prototype[i]||L.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=at+N._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=N._capitalize,s=it+o(t),c=at+o(t);e.prototype[s]=function(){let e={};for(let r=0;r<a;r++){let i=n[r];e[i]=this.getAttr(t+o(i))}return e};let l=rt(n);e.prototype[c]=function(e){let a=this.attrs[t];r&&(e=r.call(this,e,t)),l&&l.call(this,e,t);for(let n in e)e.hasOwnProperty(n)&&this._setAttr(t+o(n),e[n]);return e||n.forEach(e=>{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},L.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=N._capitalize(t),r=at+n,i=it+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(e,t,n,r){N.error(`Adding deprecated `+t);let i=it+N._capitalize(t),a=t+` property is deprecated and will be removed soon. Look at Konva change log for more information.`;e.prototype[i]=function(){N.error(a);let e=this.attrs[t];return e===void 0?n:e},L.addSetter(e,t,r,function(){N.error(a)}),L.addOverloadedGetterSetter(e,t)},backCompat(e,t){N.each(t,function(t,n){let r=e.prototype[n],i=it+N._capitalize(t),a=at+N._capitalize(t);function o(){r.apply(this,arguments),N.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function ot(e){let t=/(\w+)\(([^)]+)\)/g,n;for(;(n=t.exec(e))!==null;){let[,e,t]=n;switch(e){case`blur`:{let e=parseFloat(t.replace(`px`,``));return function(t){this.blurRadius(e*.5);let n=O.Filters;n&&n.Blur&&n.Blur.call(this,t)}}case`brightness`:{let e=t.includes(`%`)?parseFloat(t)/100:parseFloat(t);return function(t){this.brightness(e);let n=O.Filters;n&&n.Brightness&&n.Brightness.call(this,t)}}case`contrast`:{let e=parseFloat(t);return function(t){let n=100*(Math.sqrt(e)-1);this.contrast(n);let r=O.Filters;r&&r.Contrast&&r.Contrast.call(this,t)}}case`grayscale`:return function(e){let t=O.Filters;t&&t.Grayscale&&t.Grayscale.call(this,e)};case`sepia`:return function(e){let t=O.Filters;t&&t.Sepia&&t.Sepia.call(this,e)};case`invert`:return function(e){let t=O.Filters;t&&t.Invert&&t.Invert.call(this,e)};default:N.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}var st=`absoluteOpacity`,ct=`allEventListeners`,R=`absoluteTransform`,lt=`absoluteScale`,ut=`canvas`,dt=`Change`,ft=`children`,pt=`konva`,mt=`listening`,ht=`mouseenter`,gt=`mouseleave`,_t=`pointerenter`,vt=`pointerleave`,yt=`touchenter`,bt=`touchleave`,xt=`set`,St=`Shape`,Ct=` `,wt=`stage`,z=`transform`,Tt=`Stage`,Et=`visible`,Dt=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(Ct),Ot=1,B=class e{constructor(e){this._id=Ot++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===z||e===R)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){let n=this._cache.get(e);return(n===void 0||(e===z||e===R)&&n.dirty===!0)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){let n=t.map(e=>e+`Change.konva`).join(Ct);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(ut)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===R&&this.fire(`absoluteTransformChange`)}static _runAfterAbsTransformCascade(t){e._absTransformCascadeDepth>0?e._pendingAfterCascade.push(t):t()}clearCache(){if(this._cache.has(ut)){let{scene:e,filter:t,hit:n}=this._cache.get(ut);N.releaseCanvas(e._canvas,t._canvas,n._canvas),this._cache.delete(ut)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let r=Math.ceil(t.width||n.width),i=Math.ceil(t.height||n.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(n.x):t.x,s=t.y===void 0?Math.floor(n.y):t.y,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!r||!i){N.error(`Can not cache the node. Width or height of the node equals 0. Caching is skipped.`);return}let d=+(Math.abs(Math.round(n.x)-o)>.5),f=+(Math.abs(Math.round(n.y)-s)>.5);r+=c*2+d,i+=c*2+f,o-=c,s-=c;let p=new Je({pixelRatio:a,width:r,height:i}),m=new Je({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),h=new Ye({pixelRatio:u,width:r,height:i}),g=p.getContext(),_=h.getContext(),v=new Je({width:p.width/p.pixelRatio+Math.abs(o),height:p.height/p.pixelRatio+Math.abs(s),pixelRatio:p.pixelRatio}),y=v.getContext();return h.isCache=!0,p.isCache=!0,this._cache.delete(ut),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),g.save(),_.save(),y.save(),g.translate(-o,-s),_.translate(-o,-s),y.translate(-o,-s),v.x=o,v.y=s,this._isUnderCache=!0,this._clearSelfAndDescendantCache(st),this._clearSelfAndDescendantCache(lt),this.drawScene(p,this,v),this.drawHit(h,this),this._isUnderCache=!1,g.restore(),_.restore(),l&&(g.save(),g.beginPath(),g.rect(0,0,r,i),g.closePath(),g.setAttr(`strokeStyle`,`red`),g.setAttr(`lineWidth`,5),g.stroke(),g.restore()),N.releaseCanvas(v._canvas),this._cache.set(ut,{scene:p,filter:m,hit:h,x:o,y:s}),this._requestDraw(),this}isCached(){return this._cache.has(ut)}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_transformedRect(e,t){let n=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],r=1/0,i=1/0,a=-1/0,o=-1/0,s=this.getAbsoluteTransform(t);return n.forEach(function(e){let t=s.point(e);r===void 0&&(r=a=t.x,i=o=t.y),r=Math.min(r,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y)}),{x:r,y:i,width:a-r,height:o-i}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){let t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Ve(),typeof e[t]!=`string`||!Ve()){l=!1;break}let u=n.pixelRatio;if(r.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio),l){let t=e.join(` `);return i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s<a;s++)c=e[s],typeof c==`string`&&(c=ot(c)),c.call(this,o),i.putImageData(o,0,0)}catch(e){N.error(`Unable to apply filter. `+e.message+` This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.`)}return this._filterUpToDate=!0,r}on(...e){let t=e[0],n=e[1];if(e[2],this._cache&&this._cache.delete(ct),e.length===3)return this._delegate.apply(this,e);let r=t.split(Ct);for(let e=0;e<r.length;e++){let t=r[e].split(`.`),i=t[0],a=t[1]||``;this.eventListeners[i]||(this.eventListeners[i]=[]),this.eventListeners[i].push({name:a,handler:n})}return this}off(e,t){let n=(e||``).split(Ct),r=n.length,i,a,o,s,c,l;if(this._cache&&this._cache.delete(ct),!e)for(a in this.eventListeners)this._off(a);for(i=0;i<r;i++)if(o=n[i],s=o.split(`.`),c=s[0],l=s[1],c)this.eventListeners[c]&&this._off(c,l,t);else for(a in this.eventListeners)this._off(a,l,t);return this}dispatchEvent(e){let t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(e){t.call(this,e.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){let r=this;return this.on(e,function(e){let i=e.target.findAncestors(t,!0,r);for(let t=0;t<i.length;t++)e=N.cloneObject(e),e.currentTarget=i[t],n.call(i[t],e)}),this}remove(){return this.isDragging()&&this.stopDrag(),P._dragElements.delete(this._id),P._dragElements.forEach((e,t)=>{this.isAncestorOf(e.node)&&P._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(R),this._clearSelfAndDescendantCache(st),this._clearSelfAndDescendantCache(lt),this._clearSelfAndDescendantCache(wt),this._clearSelfAndDescendantCache(Et),this._clearSelfAndDescendantCache(mt)}_remove(){this._clearCaches();let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+N._capitalize(e);return N._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==ft&&(n=xt+N._capitalize(t),N._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(mt,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(Et,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);let n=this.getLayer(),r=!1;P._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node.nodeType===`Stage`||e.node.getLayer()===n)&&(r=!0)});let i=!t&&!O.hitOnDragEnabled&&(r||O.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a<i;a++)o=c[a],n++,o.nodeType!==St&&(r=r.concat(o.getChildren().slice())),o._id===t._id&&(a=i);r.length>0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==Tt&&c&&s(c.getChildren()),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(z),this._clearSelfAndDescendantCache(R)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);let r=this.getAbsoluteTransform(e).getMatrix(),i=new M,a=this.offset();return i.m=r.slice(),i.translate(a.x,a.y),i.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(z);let i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(e.x,e.y),e={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(r),this.setPosition({x:e.x,y:e.y}),this._clearCache(z),this._clearSelfAndDescendantCache(R),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}_eachAncestorReverse(e,t){let n=[],r=this.getParent(),i,a;if(!(t&&t._id===this._id)){for(n.unshift(this);r&&(!t||r._id!==t._id);)n.unshift(r),r=r.parent;for(i=n.length,a=0;a<i;a++)e(n[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return N.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return N.warn(`Node has no parent. moveUp function is ignored.`),!1;let e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return N.warn(`Node has no parent. moveDown function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return N.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return N.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&N.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(st,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i,a,o={attrs:{},className:this.getClassName()};for(t in e)n=e[t],a=N.isObject(n)&&!N._isPlainObject(n)&&!N._isArray(n),!a&&(r=typeof this[t]==`function`&&this[t],delete e[t],i=r?r.call(this):null,e[t]=n,i!==n&&(o.attrs[t]=n));return N._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r<n;r++)if(i=t[r],N.isValidSelector(i)||(N.warn(`Selector "`+i+`" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".`),N.warn(`If you have a custom shape with such className, please change it to start with upper letter like "Triangle".`),N.warn(`Konva is awesome, right?`)),i.charAt(0)===`#`){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)===`.`){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){let e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(wt,this._getStage)}_getStage(){let e=this.getParent();return e?e.getStage():null}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(R,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let t;if(e)return t=new M,this._eachAncestorReverse(function(e){let n=e.transformsEnabled();n===`all`?t.multiply(e.getTransform()):n===`position`&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())},e),t;{t=this._cache.get(R)||new M,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();let e=this.transformsEnabled();if(e===`all`)t.multiply(this.getTransform());else if(e===`position`){let e=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;t.translate(e-r,n-i)}return t.dirty=!1,t}}getAbsoluteScale(e){let t=this;for(;t;)t._isUnderCache&&(e=t),t=t.getParent();let n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(z,this._getTransform)}_getTransform(){let e=this._cache.get(z)||new M;e.reset();let t=this.x(),n=this.y(),r=O.getAngle(this.rotation()),i=this.attrs.scaleX??1,a=this.attrs.scaleY??1,o=this.attrs.skewX||0,s=this.attrs.skewY||0,c=this.attrs.offsetX||0,l=this.attrs.offsetY||0;return(t!==0||n!==0)&&e.translate(t,n),r!==0&&e.rotate(r),(o!==0||s!==0)&&e.skew(o,s),(i!==1||a!==1)&&e.scale(i,a),(c!==0||l!==0)&&e.translate(-1*c,-1*l),e.dirty=!1,e}clone(e){let t=N.cloneObject(this.attrs),n,r,i,a,o;for(n in e)t[n]=e[n];let s=new this.constructor(t);for(n in this.eventListeners)for(r=this.eventListeners[n],i=r.length,a=0;a<i;a++)o=r[a],o.name.indexOf(pt)<0&&(s.eventListeners[n]||(s.eventListeners[n]=[]),s.eventListeners[n].push(o));return s}_toKonvaCanvas(e){e||={};let t=this.getClientRect(),n=this.getStage(),r=e.x===void 0?Math.floor(t.x):e.x,i=e.y===void 0?Math.floor(t.y):e.y,a=e.pixelRatio||1,o=new Je({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:a}),s=o.getContext(),c=new Je({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(i),pixelRatio:o.pixelRatio});return e.imageSmoothingEnabled===!1&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||i)&&s.translate(-1*r,-1*i),this.drawScene(o,void 0,c),s.restore(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e||={};let t=e.mimeType||null,n=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise((t,n)=>{try{let n=e?.callback;n&&delete e.callback,N._urlToImage(this.toDataURL(e),function(e){t(e),n?.(e)})}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{let n=e?.callback;n&&delete e.callback,this.toCanvas(e).toBlob(e=>{t(e),n?.(e)},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():O.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i<r.length;i++)if(a=r[i].name,o=r[i].handler,(a!==`konva`||t===`konva`)&&(!t||a===t)&&(!n||n===o)){if(r.splice(i,1),r.length===0){delete this.eventListeners[e];break}i--}}_fireChangeEvent(e,t,n){this._fire(e+dt,{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){let t=this.name(),n=t?t+` `+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;let t=this.name();return t?(t||``).split(/\s/g).indexOf(e)!==-1:!1}removeName(e){let t=(this.name()||``).split(/\s/g),n=t.indexOf(e);return n!==-1&&(t.splice(n,1),this.name(t.join(` `))),this}setAttr(e,t){let n=this[xt+N._capitalize(e)];return N._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){O.autoDrawEnabled&&(this.getLayer()||this.getStage())?.batchDraw()}_setAttr(e,t){let n=this.attrs[e];n===t&&!N.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){let r;n!==void 0&&(r=this.attrs[e],r||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,r,n))}_fireAndBubble(e,t,n){t&&this.nodeType===St&&(t.target=this);let r=[ht,gt,_t,vt,yt,bt];if(!(r.indexOf(e)!==-1&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType===`Stage`&&!n))){this._fire(e,t);let i=r.indexOf(e)!==-1&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(t){let{nodeType:n}=this,r=e.protoListenerMap.get(n)||{},i=r?.[t];if(i===void 0){i=[];let a=new Set,o=Object.getPrototypeOf(this);for(;o;){let e=o.eventListeners?.[t]??[];for(let t=0;t<e.length;t++){let n=e[t];a.has(n)||(a.add(n),i.push(n))}o=Object.getPrototypeOf(o)}r[t]=i,e.protoListenerMap.set(n,r)}return i}_fire(e,t){t||={},t.currentTarget=this,t.type=e;let n=this._getProtoListeners(e);if(n)for(let e=0;e<n.length;e++)n[e].handler.call(this,t);let r=this.eventListeners[e];if(r){let n=r.slice(),i=n.length;for(let e=0;e<n.length;e++)n[e].handler.call(this,t);let a=this.eventListeners[e];if(a)for(let e=i;e<a.length;e++)a[e].handler.call(this,t)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){let t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition();if(!n)return;let i=n._getPointerById(t)||n._changedPointerPositions[0]||r;P._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-r.x,y:i.y-r.y},dragStatus:`ready`,pointerId:t,startEvent:e})}startDrag(e,t=!0){P._dragElements.has(this._id)||this._createDragElement(e);let n=P._dragElements.get(this._id);n.dragStatus=`dragging`,this.fire(`dragstart`,{type:`dragstart`,target:this,evt:n.startEvent&&n.startEvent.evt||e&&e.evt},t)}_setDragPosition(e,t){let n=this.getStage()._getPointerById(t.pointerId);if(!n)return;let r={x:n.x-t.offset.x,y:n.y-t.offset.y},i=this.dragBoundFunc();if(i!==void 0){let t=i.call(this,r,e);t?r=t:N.warn(`dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.`)}(!this._lastPos||this._lastPos.x!==r.x||this._lastPos.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(e){let t=P._dragElements.get(this._id);t&&(t.dragStatus=`stopped`),P._endDragBefore(e),P._endDragAfter(e)}setDraggable(e){this._setAttr(`draggable`,e),this._dragChange()}isDragging(){let e=P._dragElements.get(this._id);return e?e.dragStatus===`dragging`:!1}_listenDrag(){this._dragCleanup(),this.on(`mousedown.konva touchstart.konva`,function(e){if(!(e.evt.button===void 0||O.dragButtons.indexOf(e.evt.button)>=0)||this.isDragging())return;let t=!1;P._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=P._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&P._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return N.haveIntersection(n,this.getClientRect())}static create(e,t){return N._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;n&&(t.attrs.container=n),O[r]||(N.warn(`Can not find a node with class name "`+r+`". Fallback to "Shape".`),r=`Shape`);let c=O[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s<o;s++)a.add(e._createNode(i[s]));return a}};B._absTransformCascadeDepth=0,B._pendingAfterCascade=[],B.protoListenerMap=new Map,B.prototype.nodeType=`Node`,B.prototype._attrsAffectingSize=[],B.prototype.eventListeners={},B.prototype.on(Dt,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(z),this._clearSelfAndDescendantCache(R)}),B.prototype.on(`visibleChange.konva`,function(){this._clearSelfAndDescendantCache(Et)}),B.prototype.on(`listeningChange.konva`,function(){this._clearSelfAndDescendantCache(mt)}),B.prototype.on(`opacityChange.konva`,function(){this._clearSelfAndDescendantCache(st)});var V=L.addGetterSetter;V(B,`zIndex`),V(B,`absolutePosition`),V(B,`position`),V(B,`x`,0,F()),V(B,`y`,0,F()),V(B,`globalCompositeOperation`,`source-over`,et()),V(B,`opacity`,1,F()),V(B,`name`,``,et()),V(B,`id`,``,et()),V(B,`rotation`,0,F()),L.addComponentsGetterSetter(B,`scale`,[`x`,`y`]),V(B,`scaleX`,1,F()),V(B,`scaleY`,1,F()),L.addComponentsGetterSetter(B,`skew`,[`x`,`y`]),V(B,`skewX`,0,F()),V(B,`skewY`,0,F()),L.addComponentsGetterSetter(B,`offset`,[`x`,`y`]),V(B,`offsetX`,0,F()),V(B,`offsetY`,0,F()),V(B,`dragDistance`,void 0,F()),V(B,`width`,0,F()),V(B,`height`,0,F()),V(B,`listening`,!0,I()),V(B,`preventDefault`,!0,I()),V(B,`filters`,void 0,function(e){return this._filterUpToDate=!1,e}),V(B,`visible`,!0,I()),V(B,`transformsEnabled`,`all`,et()),V(B,`size`),V(B,`dragBoundFunc`),V(B,`draggable`,!1,I()),L.backCompat(B,{rotateDeg:`rotate`,setRotationDeg:`setRotation`,getRotationDeg:`getRotation`});var H=class extends B{constructor(){super(...arguments),this.children=[]}getChildren(e){let t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t<e.length;t++)this.add(e[t]);return this}let t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire(`add`,{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){let t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1,n=this.getChildren();for(let r of n)if(t=e(r),t||r.hasChildren()&&(t=r._descendants(e),t))return!0;return!1}toObject(){let e=B.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=B.prototype.clone.call(this,e);return this.getChildren().forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;let n=e===`absoluteTransform`;n&&B._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(e),this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{if(n&&--B._absTransformCascadeDepth===0){let e=B._pendingAfterCascade;if(e.length){B._pendingAfterCascade=[];for(let t=0;t<e.length;t++)e[t]()}}}}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._requestDraw()}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas(),a=i&&i.getContext(),o=this._getCanvasCache(),s=o&&o.scene,c=i&&i.isCache;if(!this.isVisible()&&!c)return this;if(s){a.save();let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren(`drawScene`,i,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCanvasCache();if(a&&a.hit){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n,r){var i;let a=t&&t.getContext(),o=this.clipWidth(),s=this.clipHeight(),c=this.clipFunc(),l=typeof o==`number`&&typeof s==`number`||c,u=n===this;if(l){a.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),a.beginPath();let r;if(c)r=c.call(this,a,this);else{let e=this.clipX(),t=this.clipY();a.rect(e||0,t||0,o,s)}a.clip.apply(a,r),t=e.copy().invert().getMatrix(),a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let d=!u&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;d&&(a.save(),a._applyGlobalCompositeOperation(this)),(i=this.children)==null||i.forEach(function(i){i[e](t,n,r)}),d&&a.restore(),l&&a.restore()}getClientRect(e={}){var t;let n=e.skipTransform,r=e.relativeTo,i,a,o,s,c={x:1/0,y:1/0,width:0,height:0},l=this;(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l,skipShadow:e.skipShadow,skipStroke:e.skipStroke});(n.width!==0||n.height!==0)&&(i===void 0?(i=n.x,a=n.y,o=n.x+n.width,s=n.y+n.height):(i=Math.min(i,n.x),a=Math.min(a,n.y),o=Math.max(o,n.x+n.width),s=Math.max(s,n.y+n.height)))});let u=this.find(`Shape`),d=!1;for(let e=0;e<u.length;e++)if(u[e]._isVisible(this)){d=!0;break}return c=d&&i!==void 0?{x:i,y:a,width:o-i,height:s-a}:{x:0,y:0,width:0,height:0},n?c:this._transformedRect(c,r)}};L.addComponentsGetterSetter(H,`clip`,[`x`,`y`,`width`,`height`]),L.addGetterSetter(H,`clipX`,void 0,F()),L.addGetterSetter(H,`clipY`,void 0,F()),L.addGetterSetter(H,`clipWidth`,void 0,F()),L.addGetterSetter(H,`clipHeight`,void 0,F()),L.addGetterSetter(H,`clipFunc`);var kt=new Map,At=O._global.PointerEvent!==void 0;function jt(e){return kt.get(e)}function Mt(e){return{evt:e,pointerId:e.pointerId}}function Nt(e,t){return kt.get(e)===t}function Pt(e,t){Ft(e),t.getStage()&&(kt.set(e,t),At&&t._fire(`gotpointercapture`,Mt(new PointerEvent(`gotpointercapture`))))}function Ft(e,t){let n=kt.get(e);if(!n)return;let r=n.getStage();r&&r.content,kt.delete(e),At&&n._fire(`lostpointercapture`,Mt(new PointerEvent(`lostpointercapture`)))}var It=`Stage`,Lt=`string`,Rt=`px`,zt=`mouseout`,Bt=`mouseleave`,Vt=`mouseover`,Ht=`mouseenter`,Ut=`mousemove`,Wt=`mousedown`,Gt=`mouseup`,Kt=`pointermove`,qt=`pointerdown`,Jt=`pointerup`,Yt=`pointercancel`,Xt=`lostpointercapture`,Zt=`pointerout`,Qt=`pointerleave`,$t=`pointerover`,en=`pointerenter`,tn=`contextmenu`,nn=`touchstart`,rn=`touchend`,an=`touchmove`,on=`touchcancel`,sn=`wheel`,cn=5,ln=[[Ht,`_pointerenter`],[Wt,`_pointerdown`],[Ut,`_pointermove`],[Gt,`_pointerup`],[Bt,`_pointerleave`],[nn,`_pointerdown`],[an,`_pointermove`],[rn,`_pointerup`],[on,`_pointercancel`],[Vt,`_pointerover`],[sn,`_wheel`],[tn,`_contextmenu`],[qt,`_pointerdown`],[Kt,`_pointermove`],[Jt,`_pointerup`],[Yt,`_pointercancel`],[Qt,`_pointerleave`],[Xt,`_lostpointercapture`]],un={mouse:{[Zt]:zt,[Qt]:Bt,[$t]:Vt,[en]:Ht,[Kt]:Ut,[qt]:Wt,[Jt]:Gt,[Yt]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[Zt]:`touchout`,[Qt]:`touchleave`,[$t]:`touchover`,[en]:`touchenter`,[Kt]:an,[qt]:nn,[Jt]:rn,[Yt]:on,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[Zt]:Zt,[Qt]:Qt,[$t]:$t,[en]:en,[Kt]:Kt,[qt]:qt,[Jt]:Jt,[Yt]:Yt,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},dn=e=>e.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`,fn=e=>{let t=dn(e);if(t===`pointer`)return O.pointerEventsEnabled&&un.pointer;if(t===`touch`)return un.touch;if(t===`mouse`)return un.mouse};function pn(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&N.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var mn=`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);`,hn=[],gn=class extends H{constructor(e){super(pn(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),hn.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{pn(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||N.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}setContainer(e){if(typeof e===Lt){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||={},e.container=typeof document<`u`&&document.createElement(`div`),H.prototype.clone.call(this,e)}destroy(){super.destroy();let e=this.content;e&&N._isInDocument(e)&&this.container().removeChild(e);let t=hn.indexOf(this);return t>-1&&hn.splice(t,1),N.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(N.warn(mn),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new Je({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+Rt,this.content.style.height=t+Rt),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}super.add(e);let n=this.children.length;return n>cn&&N.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e.setSize({width:this.width(),height:this.height()}),e.draw(),O.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Nt(e,this)}setPointerCapture(e){Pt(e,this)}releaseCapture(e){Ft(e,this)}getLayers(){return this.children}_bindContentEvents(){O.isBrowser&&ln.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this[t](e)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);let t=fn(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=fn(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+`targetShape`];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){let t=fn(e.type),n=dn(e.type);if(!t)return;this.setPointersPositions(e);let r=this._getTargetShape(n),i=!(O.isDragging()||O.isTransforming())||O.hitOnDragEnabled;r&&i?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+`targetShape`]=null):i&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){let t=fn(e.type),n=dn(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i);if(P.justDragged=!1,O[`_`+n+`ListenClick`]=!0,!a||!a.isListening()){this[n+`ClickStartShape`]=void 0;return}O.capturePointerEventsEnabled&&a.setPointerCapture(i.id),this[n+`ClickStartShape`]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let o=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&o&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){let t=fn(e.type),n=dn(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(O.isDragging()&&P.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(O.isDragging()||O.isTransforming())||O.hitOnDragEnabled))return;let i={},a=!1,o=this._getTargetShape(n);this._changedPointerPositions.forEach(r=>{let s=jt(r.id)||this.getIntersection(r),c=r.id,l={evt:e,pointerId:c},u=o!==s;if(u&&o&&(o._fireAndBubble(t.pointerout,{...l},s),o._fireAndBubble(t.pointerleave,{...l},s)),s){if(i[s._id])return;i[s._id]=!0}s&&s.isListening()?(a=!0,u&&(s._fireAndBubble(t.pointerover,{...l},o),s._fireAndBubble(t.pointerenter,{...l},o),this[n+`targetShape`]=s),s._fireAndBubble(t.pointermove,{...l})):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+`targetShape`]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=fn(e.type),n=dn(e.type);if(!t)return;this.setPointersPositions(e);let r=this[n+`ClickStartShape`],i=this[n+`ClickEndShape`],a={},o=!1;this._changedPointerPositions.forEach(s=>{let c=jt(s.id)||this.getIntersection(s);if(c){if(c.releaseCapture(s.id),a[c._id])return;a[c._id]=!0}let l=s.id,u={evt:e,pointerId:l},d=!1;O[`_`+n+`InDblClickWindow`]?(d=!0,clearTimeout(this[n+`DblTimeout`])):P.justDragged||(O[`_`+n+`InDblClickWindow`]=!0,clearTimeout(this[n+`DblTimeout`])),this[n+`DblTimeout`]=setTimeout(function(){O[`_`+n+`InDblClickWindow`]=!1},O.dblClickWindow),c&&c.isListening()?(o=!0,this[n+`ClickEndShape`]=c,c._fireAndBubble(t.pointerup,{...u}),O[`_`+n+`ListenClick`]&&r&&r===c&&(c._fireAndBubble(t.pointerclick,{...u}),d&&i&&i===c&&c._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+`ClickEndShape`]=null,o||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),O[`_`+n+`ListenClick`]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:l}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:l}))}),o||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),O[`_`+n+`ListenClick`]=!1,e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(tn,{evt:e}):this._fire(tn,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(sn,{evt:e}):this._fire(sn,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=jt(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(Jt,Mt(e)),Ft(e.pointerId)}_lostpointercapture(e){Ft(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:N._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:N._getFirstPointerId(e)}]):(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){N.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Je({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Ye({pixelRatio:1,width:this.width(),height:this.height()}),!O.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=document.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),this._resizeDOM()}cache(){return N.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};gn.prototype.nodeType=It,k(gn),L.addGetterSetter(gn,`container`),O.isBrowser&&document.addEventListener(`visibilitychange`,()=>{hn.forEach(e=>{e.batchDraw()})});var _n=`hasShadow`,vn=`shadowRGBA`,yn=`patternImage`,bn=`linearGradient`,xn=`radialGradient`,Sn;function Cn(){return Sn||(Sn=N.createCanvasElement().getContext(`2d`),Sn)}var wn={};function Tn(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function En(e){e.stroke()}function Dn(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function On(e){e.stroke()}function kn(){this._clearCache(_n)}function An(){this._clearCache(vn)}function jn(){this._clearCache(yn)}function Mn(){this._clearCache(bn)}function Nn(){this._clearCache(xn)}var U=class extends B{constructor(e){super(e);let t,n=0;for(;t=N.getHitColor(),!(t&&!(t in wn));)if(n++,n>=1e4){N.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.`),t=N.getRandomColor();break}this.colorKey=t,wn[t]=this}getContext(){return N.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return N.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(_n,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(yn,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=Cn().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new M;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(O.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(bn,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Cn(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}_getRadialGradient(){return this._getCache(xn,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=Cn(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}getShadowRGBA(){return this._getCache(vn,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=N.colorToRGBA(this.shadowColor());if(e)return`rgba(`+e.r+`,`+e.g+`,`+e.b+`,`+e.a*(this.shadowOpacity()||1)+`)`}hasFill(){return this._calculate(`hasFill`,[`fillEnabled`,`fill`,`fillPatternImage`,`fillLinearGradientColorStops`,`fillRadialGradientColorStops`],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate(`hasStroke`,[`strokeEnabled`,`strokeWidth`,`stroke`,`strokeLinearGradientColorStops`],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){let e=this.hitStrokeWidth();return e===`auto`?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){let t=this.getStage();if(!t)return!1;let n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return B.prototype.destroy.call(this),delete wn[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let t=e||this.hasFill(),n=this.hasStroke(),r=this.getAbsoluteOpacity()!==1;if(t&&n&&r)return!0;let i=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(t&&n&&i&&a)}setStrokeHitEnabled(e){N.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}let r=e.skipTransform,i=e.relativeTo||t&&this.getStage()||void 0,a=this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,s=a.width+o,c=a.height+o,l=!e.skipShadow&&this.hasShadow(),u=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,f=s+Math.abs(u),p=c+Math.abs(d),m=l&&this.shadowBlur()||0,h={width:f+m*2,height:p+m*2,x:-(o/2+m)+Math.min(u,0)+a.x,y:-(o/2+m)+Math.min(d,0)+a.y};return r?h:this._transformedRect(h,i)}drawScene(e,t,n){let r=this.getLayer(),i=(e||r.getCanvas()).getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),s=this.hasShadow(),c,l=t===this;if(!this.isVisible()&&!l)return this;if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!o)return this;if(i.save(),this._useBufferCanvas()){c=this.getStage();let e=n||c.bufferCanvas,r=e.getContext();n?(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()):r.clear(),r.save(),r.imageSmoothingEnabled=i.imageSmoothingEnabled,r._applyLineJoin(this),r._applyMiterLimit(this);let a=this.getAbsoluteTransform(t).getMatrix();r.transform(a[0],a[1],a[2],a[3],a[4],a[5]),o.call(this,r,this),r.restore();let u=e.pixelRatio;s&&i._applyShadow(this),l||(i._applyOpacity(this),i._applyGlobalCompositeOperation(this)),i.drawImage(e._canvas,e.x||0,e.y||0,e.width/u,e.height/u)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}s&&i._applyShadow(this),o.call(this,i,this)}return i.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;let r=this.getLayer(),i=e||r.hitCanvas,a=i&&i.getContext(),o=this.hitFunc()||this.sceneFunc(),s=this._getCanvasCache(),c=s&&s.hit;if(this.colorKey||N.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()`),c){a.save();let e=this.getAbsoluteTransform(t).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),a._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){let t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,i=r.getContext(),a=r.getWidth(),o=r.getHeight();i.clear(),i.drawImage(n._canvas,0,0,a,o);try{let t=i.getImageData(0,0,a,o),n=t.data,r=n.length,s=N._hexToRgb(this.colorKey);for(let t=0;t<r;t+=4)n[t+3]>e?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;i.putImageData(t,0,0)}catch(e){N.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return Nt(e,this)}setPointerCapture(e){Pt(e,this)}releaseCapture(e){Ft(e,this)}};U.prototype._fillFunc=Tn,U.prototype._strokeFunc=En,U.prototype._fillFuncHit=Dn,U.prototype._strokeFuncHit=On,U.prototype._centroid=!1,U.prototype.nodeType=`Shape`,k(U),U.prototype.eventListeners={},U.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,kn),U.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,An),U.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,jn),U.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,Mn),U.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,Nn),L.addGetterSetter(U,`stroke`,void 0,tt()),L.addGetterSetter(U,`strokeWidth`,2,F()),L.addGetterSetter(U,`fillAfterStrokeEnabled`,!1),L.addGetterSetter(U,`hitStrokeWidth`,`auto`,$e()),L.addGetterSetter(U,`strokeHitEnabled`,!0,I()),L.addGetterSetter(U,`perfectDrawEnabled`,!0,I()),L.addGetterSetter(U,`shadowForStrokeEnabled`,!0,I()),L.addGetterSetter(U,`lineJoin`),L.addGetterSetter(U,`lineCap`),L.addGetterSetter(U,`miterLimit`),L.addGetterSetter(U,`sceneFunc`),L.addGetterSetter(U,`hitFunc`),L.addGetterSetter(U,`dash`),L.addGetterSetter(U,`dashOffset`,0,F()),L.addGetterSetter(U,`shadowColor`,void 0,et()),L.addGetterSetter(U,`shadowBlur`,0,F()),L.addGetterSetter(U,`shadowOpacity`,1,F()),L.addComponentsGetterSetter(U,`shadowOffset`,[`x`,`y`]),L.addGetterSetter(U,`shadowOffsetX`,0,F()),L.addGetterSetter(U,`shadowOffsetY`,0,F()),L.addGetterSetter(U,`fillPatternImage`),L.addGetterSetter(U,`fill`,void 0,tt()),L.addGetterSetter(U,`fillPatternX`,0,F()),L.addGetterSetter(U,`fillPatternY`,0,F()),L.addGetterSetter(U,`fillLinearGradientColorStops`),L.addGetterSetter(U,`strokeLinearGradientColorStops`),L.addGetterSetter(U,`fillRadialGradientStartRadius`,0),L.addGetterSetter(U,`fillRadialGradientEndRadius`,0),L.addGetterSetter(U,`fillRadialGradientColorStops`),L.addGetterSetter(U,`fillPatternRepeat`,`repeat`),L.addGetterSetter(U,`fillEnabled`,!0),L.addGetterSetter(U,`strokeEnabled`,!0),L.addGetterSetter(U,`shadowEnabled`,!0),L.addGetterSetter(U,`dashEnabled`,!0),L.addGetterSetter(U,`strokeScaleEnabled`,!0),L.addGetterSetter(U,`fillPriority`,`color`),L.addComponentsGetterSetter(U,`fillPatternOffset`,[`x`,`y`]),L.addGetterSetter(U,`fillPatternOffsetX`,0,F()),L.addGetterSetter(U,`fillPatternOffsetY`,0,F()),L.addComponentsGetterSetter(U,`fillPatternScale`,[`x`,`y`]),L.addGetterSetter(U,`fillPatternScaleX`,1,F()),L.addGetterSetter(U,`fillPatternScaleY`,1,F()),L.addComponentsGetterSetter(U,`fillLinearGradientStartPoint`,[`x`,`y`]),L.addComponentsGetterSetter(U,`strokeLinearGradientStartPoint`,[`x`,`y`]),L.addGetterSetter(U,`fillLinearGradientStartPointX`,0),L.addGetterSetter(U,`strokeLinearGradientStartPointX`,0),L.addGetterSetter(U,`fillLinearGradientStartPointY`,0),L.addGetterSetter(U,`strokeLinearGradientStartPointY`,0),L.addComponentsGetterSetter(U,`fillLinearGradientEndPoint`,[`x`,`y`]),L.addComponentsGetterSetter(U,`strokeLinearGradientEndPoint`,[`x`,`y`]),L.addGetterSetter(U,`fillLinearGradientEndPointX`,0),L.addGetterSetter(U,`strokeLinearGradientEndPointX`,0),L.addGetterSetter(U,`fillLinearGradientEndPointY`,0),L.addGetterSetter(U,`strokeLinearGradientEndPointY`,0),L.addComponentsGetterSetter(U,`fillRadialGradientStartPoint`,[`x`,`y`]),L.addGetterSetter(U,`fillRadialGradientStartPointX`,0),L.addGetterSetter(U,`fillRadialGradientStartPointY`,0),L.addComponentsGetterSetter(U,`fillRadialGradientEndPoint`,[`x`,`y`]),L.addGetterSetter(U,`fillRadialGradientEndPointX`,0),L.addGetterSetter(U,`fillRadialGradientEndPointY`,0),L.addGetterSetter(U,`fillPatternRotation`,0),L.addGetterSetter(U,`fillRule`,void 0,et()),L.backCompat(U,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`getDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var Pn=`beforeDraw`,Fn=`draw`,In=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Ln=In.length,Rn=class extends H{constructor(e){super(e),this.canvas=new Je,this.hitCanvas=new Ye({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){B.prototype.moveToTop.call(this);let e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!B.prototype.moveUp.call(this))return!1;let e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(B.prototype.moveDown.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(B.prototype.moveToBottom.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){let e=this.getNativeCanvasElement();return B.prototype.remove.call(this),e&&e.parentNode&&N._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&N.throw(`You may only add groups and shapes to a layer.`)}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x===void 0?this.x():e.x,e.y=e.y===void 0?this.y():e.y,B.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display=`block`:this.canvas._canvas.style.display=`none`}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){N.warn(`Can not change width of layer. Use "stage.width(value)" function instead.`)}getHeight(){if(this.parent)return this.parent.height()}setHeight(){N.warn(`Can not change height of layer. Use "stage.height(value)" function instead.`)}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,N.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<Ln;r++){let i=In[r],a=this._getIntersection({x:e.x+i.x*t,y:e.y+i.y*t}),o=a.shape;if(o)return o;if(n=!!a.antialiased,!a.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){let e=wn[N.getHitColorKey(n[0],n[1],n[2])];return e?{shape:e}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(Pn,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),H.prototype.drawScene.call(this,i,t,n),this._fire(Fn,{node:this}),this}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),H.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){N.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return N.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return N.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Rn.prototype.nodeType=`Layer`,k(Rn),L.addGetterSetter(Rn,`imageSmoothingEnabled`,!0),L.addGetterSetter(Rn,`clearBeforeDraw`,!0),L.addGetterSetter(Rn,`hitGraphEnabled`,!0,I());var zn=class extends Rn{constructor(e){super(e),this.listening(!1),N.warn(`Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};zn.prototype.nodeType=`FastLayer`,k(zn);var Bn=class extends H{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&N.throw(`You may only add groups and shapes to groups.`)}};Bn.prototype.nodeType=`Group`,k(Bn);var Vn=(function(){return D.performance&&D.performance.now?function(){return D.performance.now()}:function(){return new Date().getTime()}})(),Hn=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Vn(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){let t=[];return e&&(t=Array.isArray(e)?e:[e]),this.layers=t,this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r<n;r++)if(t[r]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){let t=e.animations,n=t.length;for(let e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Vn(),e._addAnimation(this),this}stop(){return e._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){let t=e.id,n=this.animations,r=n.length;for(let e=0;e<r;e++)if(n[e].id===t){this.animations.splice(e,1);break}}static _runFrames(){let e={},t=this.animations;for(let n=0;n<t.length;n++){let r=t[n],i=r.layers,a=r.func;r._updateFrameObject(Vn());let o=i.length,s;if(s=!a||a.call(r,r.frame)!==!1,s)for(let t=0;t<o;t++){let n=i[t];n._id!==void 0&&(e[n._id]=n)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){let t=e;t.animations.length?(t._runFrames(),N.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,N.requestAnimFrame(this._animationLoop))}};Hn.animations=[],Hn.animIdCounter=0,Hn.animRunning=!1;var Un={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Wn=1,Gn=2,Kn=3,qn=[`fill`,`stroke`,`shadowColor`],Jn=0;function Yn(e){return N.colorToRGBA(e)||N.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}var Xn=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=Gn,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onPlay`)}reverse(){this.state=Kn,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onReverse`)}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===Gn?this.setTime(e):this.state===Kn&&this.setTime(this.duration-e)}pause(){this.state=Wn,this.fire(`onPause`)}getTimer(){return new Date().getTime()}},Zn=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||Qn.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=Jn++;let l=r.getLayer()||(r instanceof O.Stage?r.getLayers():null);for(c in l||N.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Hn(function(){n.tween.onEnterFrame()},l),this.tween=new Xn(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)Un[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){let r=this.node,i=r._id,a,o,s,c,l,u=e.tweens[i][t];u&&delete e.attrs[i][u][t];let d=r.getAttr(t);if(N._isArray(n)){if(a=[],o=Math.max(n.length,d.length),t===`points`&&n.length!==d.length&&(n.length>d.length?(c=d,d=N._prepareArrayForTween(d,n,r.closed())):(s=n,n=N._prepareArrayForTween(n,d,r.closed()))),t.indexOf(`fill`)===0)for(let e=0;e<o;e++)if(e%2==0)a.push(n[e]-d[e]);else{let t=Yn(d[e]);l=Yn(n[e]),d[e]=t,a.push({r:l.r-t.r,g:l.g-t.g,b:l.b-t.b,a:l.a-t.a})}else for(let e=0;e<o;e++)a.push(n[e]-d[e])}else qn.indexOf(t)===-1?a=n-d:(d=Yn(d),l=Yn(n),a={r:l.r-d.r,g:l.g-d.g,b:l.b-d.b,a:l.a-d.a});e.attrs[i][this._id][t]={start:d,diff:a,end:n,trueEnd:s,trueStart:c},e.tweens[i][t]=this._id}_tweenFunc(t){let n=this.node,r=e.attrs[n._id][this._id],i,a,o,s,c,l,u,d;for(i in r){if(a=r[i],o=a.start,s=a.diff,d=a.end,N._isArray(o)){if(c=[],u=Math.max(o.length,d.length),i.indexOf(`fill`)===0)for(l=0;l<u;l++)l%2==0?c.push((o[l]||0)+s[l]*t):c.push(`rgba(`+Math.round(o[l].r+s[l].r*t)+`,`+Math.round(o[l].g+s[l].g*t)+`,`+Math.round(o[l].b+s[l].b*t)+`,`+(o[l].a+s[l].a*t)+`)`);else for(l=0;l<u;l++)c.push((o[l]||0)+s[l]*t)}else c=qn.indexOf(i)===-1?o+s*t:`rgba(`+Math.round(o.r+s.r*t)+`,`+Math.round(o.g+s.g*t)+`,`+Math.round(o.b+s.b*t)+`,`+(o.a+s.a*t)+`)`;n.setAttr(i,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr(`points`,n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.tweens[t];this.pause(),this.anim&&this.anim.stop();for(let n in r)delete e.tweens[t][n];delete e.attrs[t][n],e.tweens[t]&&(Object.keys(e.tweens[t]).length===0&&delete e.tweens[t],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t])}};Zn.attrs={},Zn.tweens={},B.prototype.to=function(e){let t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Zn(e).play()};var Qn={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),-(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t)},ElasticEaseOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),i*2**(-10*e)*Math.sin((e*r-o)*(2*Math.PI)/a)+n+t)},ElasticEaseInOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r/2)==2?t+n:(a||=.3*1.5*r,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),e<1?-.5*(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t:i*2**(-10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-Qn.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Qn.BounceEaseIn(e*2,0,n,r)*.5+t:Qn.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},$n=N._assign(O,{Util:N,Transform:M,Node:B,Container:H,Stage:gn,stages:hn,Layer:Rn,FastLayer:zn,Group:Bn,DD:P,Shape:U,shapes:wn,Animation:Hn,Tween:Zn,Easings:Qn,Context:He,Canvas:qe}),W=class extends U{_sceneFunc(e){let t=O.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=O.getAngle(this.angle());if(r%(Math.PI*2)==0)return r===0?{x:e,y:0,width:t-e,height:0}:{x:-t,y:-t,width:t*2,height:t*2};let i=O.getAngle(n?360-this.angle():this.angle()),a=Math.cos(Math.min(i,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,i),3*Math.PI/2)),s=Math.sin(Math.min(i,Math.PI/2)),c=a*(a>0?e:t),l=1*t,u=o*(o>0?e:t),d=s*(s>0?t:e);return{x:c,y:n?-1*d:u,width:l-c,height:d-u}}};W.prototype._centroid=!0,W.prototype.className=`Arc`,W.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],k(W),L.addGetterSetter(W,`innerRadius`,0,F()),L.addGetterSetter(W,`outerRadius`,0,F()),L.addGetterSetter(W,`angle`,0,F()),L.addGetterSetter(W,`clockwise`,!1,I());var er=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],tr=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],nr=[[1],[1,1],[1,2,1],[1,3,3,1]],rr=(e,t,n)=>{let r,i,a=n/2;r=0;for(let n=0;n<20;n++)i=a*er[20][n]+a,r+=tr[20][n]*ar(e,t,i);return a*r},ir=(e,t,n)=>{n===void 0&&(n=1);let r=e[0]-2*e[1]+e[2],i=t[0]-2*t[1]+t[2],a=2*e[1]-2*e[0],o=2*t[1]-2*t[0],s=4*(r*r+i*i),c=4*(r*a+i*o),l=a*a+o*o;if(s===0)return n*Math.sqrt((e[2]-e[0])**2+(t[2]-t[0])**2);let u=c/(2*s),d=l/s,f=n+u,p=d-u*u,m=f*f+p>0?Math.sqrt(f*f+p):0,h=u*u+p>0?Math.sqrt(u*u+p):0,g=u+Math.sqrt(u*u+p)===0?0:p*Math.log(Math.abs((f+m)/(u+h)));return Math.sqrt(s)/2*(f*m-u*h+g)};function ar(e,t,n){let r=or(1,n,e),i=or(1,n,t),a=r*r+i*i;return Math.sqrt(a)}var or=(e,t,n)=>{let r=n.length-1,i,a;if(r===0)return 0;if(e===0){a=0;for(let e=0;e<=r;e++)a+=nr[r][e]*(1-t)**(r-e)*t**+e*n[e];return a}i=Array(r);for(let e=0;e<r;e++)i[e]=r*(n[e+1]-n[e]);return or(e-1,t,i)},sr=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c<r)r=c,i+=a;else{let o=n(i-a),s=Math.abs(e-o)/t;s<r?(r=s,i-=a):a/=2}if(o++,o>500)break}return i},cr=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},lr=(e,t,n,r,i,a)=>{let o=[];for(let s of[[e,n,i],[t,r,a]]){let c=(s[0]-s[1])/(s[0]-2*s[1]+s[2]);c>0&&c<1&&o.push(cr(e,n,i,c),cr(t,r,a,c))}return o},ur=(e,t,n,r,i)=>{let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r},dr=(e,t,n,r,i,a,o,s)=>{let c=[];for(let l of[[e,n,i,o],[t,r,a,s]]){let u=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],f=-3*l[0]+3*l[1],p=d*d-4*u*f;if(p<0)continue;let m=-(d+(d<0?-1:1)*Math.sqrt(p))/2;for(let l of[m/u,f/m])l>0&&l<1&&c.push(ur(e,n,i,o,l),ur(t,r,a,s,l))}return c};function fr(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=s+c;if(l===0)return[n,r,n,r];let u=o*s/l,d=o*c/l;return[n-u*(i-e),r-u*(a-t),n+d*(i-e),r+d*(a-t)]}function pr(e,t){let n=e.length,r=[];for(let i=2;i<n-2;i+=2){let n=fr(e[i-2],e[i-1],e[i],e[i+1],e[i+2],e[i+3],t);isNaN(n[0])||(r.push(n[0]),r.push(n[1]),r.push(e[i]),r.push(e[i+1]),r.push(n[2]),r.push(n[3]))}return r}function mr(e){let t=[];for(let n=0;n+7<e.length;n+=6)t.push(e[n+6],e[n+7],...dr(e[n],e[n+1],e[n+2],e[n+3],e[n+4],e[n+5],e[n+6],e[n+7]));return t}var G=class extends U{constructor(e){super(e),this.on(`pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva`,function(){this._clearCache(`tensionPoints`)})}_hasTension(){return this.tension()!==0&&this.points().length>4}_eachTensionSegment(e,t){let n=this.points(),r=n.length,i=this.closed(),a=this.getTensionPoints(),o=a.length,s=n[0],c=n[1],l=i?0:4;for(i||(e(s,c,a[0],a[1],a[2],a[3]),s=a[2],c=a[3]);l<o-2;){let e=a[l++],n=a[l++],r=a[l++],i=a[l++],o=a[l++],u=a[l++];t(s,c,e,n,r,i,o,u),s=o,c=u}i||e(s,c,a[o-2],a[o-1],n[r-2],n[r-1])}_sceneFunc(e){let t=this.points(),n=t.length,r=this.closed(),i=this.bezier();if(!n)return;let a=0;if(e.beginPath(),e.moveTo(t[0],t[1]),this._hasTension())this._eachTensionSegment((t,n,r,i,a,o)=>e.quadraticCurveTo(r,i,a,o),(t,n,r,i,a,o,s,c)=>e.bezierCurveTo(r,i,a,o,s,c));else if(i)for(a=2;a<n;)e.bezierCurveTo(t[a++],t[a++],t[a++],t[a++],t[a++],t[a++]);else for(a=2;a<n;a+=2)e.lineTo(t[a],t[a+1]);r?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache(`tensionPoints`,this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():pr(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,n=this.tension(),r=fr(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=fr(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=pr(e,n);return[r[2],r[3]].concat(a,[i[0],i[1],e[t-2],e[t-1],i[2],i[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};if(this._hasTension()){let t=[e[0],e[1]];this._eachTensionSegment((e,n,r,i,a,o)=>t.push(a,o,...lr(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...dr(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...mr(e)]);let t=e[0],n=e[0],r=e[1],i=e[1],a,o;for(let s=0;s<e.length/2;s++)a=e[s*2],o=e[s*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,o),i=Math.max(i,o);return{x:t,y:r,width:n-t,height:i-r}}};G.prototype.className=`Line`,G.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`],k(G),L.addGetterSetter(G,`closed`,!1),L.addGetterSetter(G,`bezier`,!1),L.addGetterSetter(G,`tension`,0,F()),L.addGetterSetter(G,`points`,[],nt());var K=class e extends U{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r<t.length;r++){let i=t[r].command,a=t[r].points;switch(i){case`L`:e.lineTo(a[0],a[1]);break;case`M`:e.moveTo(a[0],a[1]);break;case`C`:e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case`Q`:e.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case`A`:let t=a[0],r=a[1],i=a[2],o=a[3],s=a[4],c=a[5],l=a[6],u=a[7],d=i>o?i:o,f=i>o?1:i/o,p=i>o?o/i:1;e.translate(t,r),e.rotate(l),e.scale(f,p),e.arc(0,0,d,s,s+c,1-u),e.scale(1/f,1/p),e.rotate(-l),e.translate(-t,-r);break;case`z`:n=!0,e.closePath()}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(n){if(n.command===`A`){let r=n.points[4],i=n.points[5],a=n.points[4]+i,o=Math.PI/180;if(Math.abs(r-a)<o&&(o=Math.abs(r-a)),i<0)for(let i=r-o;i>a;i-=o){let r=e.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],i,0);t.push(r.x,r.y)}else for(let i=r+o;i<a;i+=o){let r=e.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],i,0);t.push(r.x,r.y)}}else n.command===`C`?t.push(n.start.x,n.start.y,n.points[4],n.points[5],...dr(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3],n.points[4],n.points[5])):n.command===`Q`?t.push(n.start.x,n.start.y,n.points[2],n.points[3],...lr(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3])):t=t.concat(n.points)});let n=t[0],r=t[0],i=t[1],a=t[1],o,s;for(let e=0;e<t.length/2;e++)o=t[e*2],s=t[e*2+1],isNaN(o)||(n=Math.min(n,o),r=Math.max(r,o)),isNaN(s)||(i=Math.min(i,s),a=Math.max(a,s));return{x:n,y:i,width:r-n,height:a-i}}getLength(){return this.pathLength}getPointAtLength(t){return e.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPathLength(e){let t=0;for(let n=0;n<e.length;++n)t+=e[n].pathLength;return t}static getPointAtLengthOfDataArray(t,n){let r,i=0,a=n.length;if(!a)return null;for(;i<a&&t>n[i].pathLength;)t-=n[i].pathLength,++i;if(i===a){let e=i-1;for(;e>0&&n[e].points.length<2;)e--;return r=n[e].points.slice(-2),{x:r[0],y:r[1]}}if(t<.01)return n[i].command===`M`?(r=n[i].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[i].start.x,y:n[i].start.y};let o=n[i],s=o.points;switch(o.command){case`L`:return e.getPointOnLine(t,o.start.x,o.start.y,s[0],s[1]);case`C`:return e.getPointOnCubicBezier(sr(t,e.getPathLength(n),e=>rr([o.start.x,s[0],s[2],s[4]],[o.start.y,s[1],s[3],s[5]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case`Q`:return e.getPointOnQuadraticBezier(sr(t,e.getPathLength(n),e=>ir([o.start.x,s[0],s[2]],[o.start.y,s[1],s[3]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3]);case`A`:let r=s[0],i=s[1],a=s[2],c=s[3],l=s[5],u=s[6],d=s[4];return d+=l*t/o.pathLength,e.getPointOnEllipticalArc(r,i,a,c,d,u)}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r<t?-1:1),u=c*l;if(Math.abs(o-n-c*(a-t))<1e-10)return{x:a+l,y:o+u};let d=((a-t)*(r-t)+(o-n)*(i-n))/(s*s),f=t+d*(r-t),p=n+d*(i-n),m=this.getLineLength(a,o,f,p),h=Math.sqrt(e*e-m*m),g=Math.sqrt(h*h/(1+c*c))*(r<t?-1:1),_=c*g;return{x:f+g,y:p+_}}static getPointOnCubicBezier(e,t,n,r,i,a,o,s,c){function l(e){return e*e*e}function u(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function f(e){return(1-e)*(1-e)*(1-e)}return{x:s*l(e)+a*u(e)+r*d(e)+t*f(e),y:c*l(e)+o*u(e)+i*d(e)+n*f(e)}}static getPointOnQuadraticBezier(e,t,n,r,i,a,o){function s(e){return e*e}function c(e){return 2*e*(1-e)}function l(e){return(1-e)*(1-e)}return{x:a*s(e)+r*c(e)+t*l(e),y:o*s(e)+i*c(e)+n*l(e)}}static getPointOnEllipticalArc(e,t,n,r,i,a){let o=Math.cos(a),s=Math.sin(a),c={x:n*Math.cos(i),y:r*Math.sin(i)};return{x:e+(c.x*o-c.y*s),y:t+(c.x*s+c.y*o)}}static parsePathData(e){if(!e)return[];let t=e,n=[`m`,`M`,`l`,`L`,`v`,`V`,`h`,`H`,`z`,`Z`,`c`,`C`,`q`,`Q`,`t`,`T`,`s`,`S`,`a`,`A`];t=t.replace(RegExp(` `,`g`),`,`);for(let e=0;e<n.length;e++)t=t.replace(new RegExp(n[e],`g`),`|`+n[e]);let r=t.split(`|`),i=[],a=[],o=0,s=0,c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,l;for(let e=1;e<r.length;e++){let t=r[e],n=t.charAt(0);for(t=t.slice(1),a.length=0;l=c.exec(t);)a.push(l[0]);let u=[],d=n===`A`||n===`a`?0:-1;for(let e=0,t=a.length;e<t;e++){let t=a[e];if(t===`00`){u.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7));continue}if(d>=0){if(d===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),u.push(parseFloat(t.slice(2))),d+=3,d>=7&&(d-=7);continue}if(t===`11`||t===`10`||t===`01`){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}else if(d===4){if(/^[01]\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseFloat(t.slice(1))),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e),d+=1,d>=7&&(d-=7)}else{let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e)}}for(;u.length>0&&!isNaN(u[0]);){let e=``,t=[],r=o,a=s,c,l,d,f,p,m,h,g,_,v;switch(n){case`l`:o+=u.shift(),s+=u.shift(),e=`L`,t.push(o,s);break;case`L`:o=u.shift(),s=u.shift(),t.push(o,s);break;case`m`:let r=u.shift(),a=u.shift();if(o+=r,s+=a,e=`M`,i.length>2&&i[i.length-1].command===`z`){for(let e=i.length-2;e>=0;e--)if(i[e].command===`M`){o=i[e].points[0]+r,s=i[e].points[1]+a;break}}t.push(o,s),n=`l`;break;case`M`:o=u.shift(),s=u.shift(),e=`M`,t.push(o,s),n=`L`;break;case`h`:o+=u.shift(),e=`L`,t.push(o,s);break;case`H`:o=u.shift(),e=`L`,t.push(o,s);break;case`v`:s+=u.shift(),e=`L`,t.push(o,s);break;case`V`:s=u.shift(),e=`L`,t.push(o,s);break;case`C`:t.push(u.shift(),u.shift(),u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`c`:t.push(o+u.shift(),s+u.shift(),o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`S`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,u.shift(),u.shift()),o=u.shift(),s=u.shift(),e=`C`,t.push(o,s);break;case`s`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`Q`:t.push(u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`q`:t.push(o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(o,s);break;case`T`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o=u.shift(),s=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`t`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`A`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o=u.shift(),s=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m);break;case`a`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o+=u.shift(),s+=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m)}i.push({command:e||n,points:t,start:{x:r,y:a},pathLength:this.calcLength(r,a,e||n,t)})}(n===`z`||n===`Z`)&&i.push({command:`z`,points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,i){let a,o,s,c,l=e;switch(r){case`L`:return l.getLineLength(t,n,i[0],i[1]);case`C`:return rr([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return ir([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:a=0;let e=i[4],r=i[5],u=i[4]+r,d=Math.PI/180;if(Math.abs(e-u)<d&&(d=Math.abs(e-u)),o=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],e,0),r<0)for(c=e-d;c>u;c-=d)s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;else for(c=e+d;c<u;c+=d)s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;return s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],u,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),a}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},x=b([1,0],[(u-m)/o,(d-h)/s]),S=[(u-m)/o,(d-h)/s],C=[(-1*u-m)/o,(-1*d-h)/s],w=b(S,C);return y(S,C)<=-1&&(w=Math.PI),y(S,C)>=1&&(w=0),a===0&&w>0&&(w-=2*Math.PI),a===1&&w<0&&(w+=2*Math.PI),[g,_,o,s,x,w,l,a]}};K.prototype.className=`Path`,K.prototype._attrsAffectingSize=[`data`],k(K),L.addGetterSetter(K,`data`);var hr=class extends G{_sceneFunc(e){super._sceneFunc(e);let t=Math.PI*2,n=this.points(),r=n,i=this.tension()!==0&&n.length>4;i&&(r=this.getTensionPoints());let a=this.pointerLength(),o=n.length,s,c;if(i){let e=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[o-2],n[o-1]],t=K.calcLength(r[r.length-4],r[r.length-3],`C`,e),i=K.getPointOnQuadraticBezier(Math.min(1,1-a/t),e[0],e[1],e[2],e[3],e[4],e[5]);s=n[o-2]-i.x,c=n[o-1]-i.y}else s=n[o-2]-n[o-4],c=n[o-1]-n[o-3];let l=(Math.atan2(c,s)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[o-2],n[o-1]),e.rotate(l),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),i?(s=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(s=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-s)+t)%t),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){let t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){let e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};hr.prototype.className=`Arrow`,k(hr),L.addGetterSetter(hr,`pointerLength`,10,F()),L.addGetterSetter(hr,`pointerWidth`,10,F()),L.addGetterSetter(hr,`pointerAtBeginning`,!1),L.addGetterSetter(hr,`pointerAtEnding`,!0);var gr=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};gr.prototype._centroid=!0,gr.prototype.className=`Circle`,gr.prototype._attrsAffectingSize=[`radius`],k(gr),L.addGetterSetter(gr,`radius`,0,F());var _r=class extends U{_sceneFunc(e){let t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};_r.prototype.className=`Ellipse`,_r.prototype._centroid=!0,_r.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],k(_r),L.addComponentsGetterSetter(_r,`radius`,[`x`,`y`]),L.addGetterSetter(_r,`radiusX`,0,F()),L.addGetterSetter(_r,`radiusY`,0,F());var q=class e extends U{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){let e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener(`load`,this._loadListener)}_removeImageLoad(e){e&&e.removeEventListener&&e.removeEventListener(`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){let e=!!this.cornerRadius(),t=this.hasShadow();return e&&t?!0:super._useBufferCanvas(!0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image,a;if(i){let e=this.attrs.cropWidth,r=this.attrs.cropHeight;a=e&&r?[i,this.cropX(),this.cropY(),e,r,0,0,t,n]:[i,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?N.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?N.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.attrs.width??this.image()?.width??0}getHeight(){return this.attrs.height??this.image()?.height??0}static fromURL(t,n,r=null){let i=N.createImageElement();i.onload=function(){n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};q.prototype.className=`Image`,q.prototype._attrsAffectingSize=[`image`],k(q),L.addGetterSetter(q,`cornerRadius`,0,Qe(4)),L.addGetterSetter(q,`image`),L.addComponentsGetterSetter(q,`crop`,[`x`,`y`,`width`,`height`]),L.addGetterSetter(q,`cropX`,0,F()),L.addGetterSetter(q,`cropY`,0,F()),L.addGetterSetter(q,`cropWidth`,0,F()),L.addGetterSetter(q,`cropHeight`,0,F());var vr=[`fontFamily`,`fontSize`,`fontStyle`,`padding`,`lineHeight`,`text`,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`],yr=`Change.konva`,br=`none`,xr=`up`,Sr=`right`,Cr=`down`,wr=`left`,Tr=vr.length,Er=class extends Bn{constructor(e){super(e),this.on(`add.konva`,function(e){this._addListeners(e.child),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}_addListeners(e){let t=this,n,r=function(){t._sync()};for(n=0;n<Tr;n++)e.on(vr[n]+yr,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case xr:o=n/2,s=-1*c;break;case Sr:o=n+a,s=r/2;break;case Cr:o=n/2,s=r+c;break;case wr:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};Er.prototype.className=`Label`,k(Er);var Dr=class extends U{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),s=0,c=0,l=0,u=0;typeof o==`number`?s=c=l=u=Math.min(o,t/2,n/2):(s=Math.min(o[0]||0,t/2,n/2),c=Math.min(o[1]||0,t/2,n/2),u=Math.min(o[2]||0,t/2,n/2),l=Math.min(o[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(s,0),r===xr&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===Sr&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===Cr&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(l,n),e.arc(l,n-l,l,Math.PI/2,Math.PI,!1),r===wr&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),a=this.width(),o=this.height();return i===xr?(t-=r,o+=r):i===Cr?o+=r:i===wr?(e-=n*1.5,a+=n):i===Sr&&(a+=n*1.5),{x:e,y:t,width:a,height:o}}};Dr.prototype.className=`Tag`,k(Dr),L.addGetterSetter(Dr,`pointerDirection`,br),L.addGetterSetter(Dr,`pointerWidth`,0,F()),L.addGetterSetter(Dr,`pointerHeight`,0,F()),L.addGetterSetter(Dr,`cornerRadius`,0,Qe(4));var Or=class extends U{_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?N.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Or.prototype.className=`Rect`,k(Or),L.addGetterSetter(Or,`cornerRadius`,0,Qe(4));var kr=class extends U{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(e.beginPath(),i)N.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){let e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){let e=this._getPoints(),t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};kr.prototype.className=`RegularPolygon`,kr.prototype._centroid=!0,kr.prototype._attrsAffectingSize=[`radius`],k(kr),L.addGetterSetter(kr,`radius`,0,F()),L.addGetterSetter(kr,`sides`,0,F()),L.addGetterSetter(kr,`cornerRadius`,0,Qe(4));var Ar=Math.PI*2,jr=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Ar,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Ar,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};jr.prototype.className=`Ring`,jr.prototype._centroid=!0,jr.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],k(jr),L.addGetterSetter(jr,`innerRadius`,0,F()),L.addGetterSetter(jr,`outerRadius`,0,F());var J=class extends U{constructor(e){super(e),this._updated=!0,this.anim=new Hn(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+0],s=i[r+1],c=i[r+2],l=i[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,c,l),e.closePath(),e.fillStrokeShape(this)),u){if(a){let r=a[t],i=n*2;e.drawImage(u,o,s,c,l,r[i+0],r[i+1],c,l)}else e.drawImage(u,o,s,c,l,0,0,c,l)}}_hitFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+2],s=i[r+3];if(e.beginPath(),a){let r=a[t],i=n*2;e.rect(r[i+0],r[i+1],o,s)}else e.rect(0,0,o,s);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};J.prototype.className=`Sprite`,k(J),L.addGetterSetter(J,`animation`),L.addGetterSetter(J,`animations`),L.addGetterSetter(J,`frameOffsets`),L.addGetterSetter(J,`image`),L.addGetterSetter(J,`frameIndex`,0,F()),L.addGetterSetter(J,`frameRate`,17,F()),L.backCompat(J,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var Y=class extends U{_sceneFunc(e){let t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){let a=i%2==0?n:t,o=a*Math.sin(i*Math.PI/r),s=-1*a*Math.cos(i*Math.PI/r);e.lineTo(o,s)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Y.prototype.className=`Star`,Y.prototype._centroid=!0,Y.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],k(Y),L.addGetterSetter(Y,`numPoints`,5,F()),L.addGetterSetter(Y,`innerRadius`,0,F()),L.addGetterSetter(Y,`outerRadius`,0,F());function Mr(e){return[...e].reduce((e,t,n,r)=>{if(/\p{Emoji}/u.test(t)){let i=r[n+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(e.push(t+i),r[n+1]=``):e.push(t)}else/\p{Regional_Indicator}{2}/u.test(t+(r[n+1]||``))?e.push(t+r[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(t)?e[e.length-1]+=t:t&&e.push(t);return e},[])}var Nr=`auto`,Pr=`center`,Fr=`inherit`,Ir=`justify`,Lr=`Change.konva`,Rr=`2d`,zr=`-`,Br=`left`,Vr=`text`,Hr=`Text`,Ur=`top`,Wr=`bottom`,Gr=`middle`,Kr=`normal`,qr=`px `,Jr=` `,Yr=`right`,Xr=`rtl`,Zr=`word`,Qr=`char`,$r=`none`,ei=`…`,ti=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],ni=ti.length,ri=null;function ii(){if(ri!==null)return ri;ri=!1;try{let e=document.createElement(`canvas`);e.width=10,e.height=10;let t=e.getContext(Rr);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t<e.length;t+=4)if(e[t]>0){ri=!0;break}}}catch{}return ri}function ai(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var oi;function si(){return oi||(oi=N.createCanvasElement().getContext(Rr),oi)}function ci(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function li(e){e.setAttr(`miterLimit`,2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function ui(e){return e||={},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||`black`),e}var X=class extends U{constructor(e){super(ui(e)),this._partialTextX=0,this._partialTextY=0;for(let e=0;e<ni;e++)this.on(ti[e]+Lr,this._setTextData);this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.verticalAlign(),s=this.direction(),c=0,l=this.align(),u=this.getWidth(),d=this.letterSpacing(),f=this.charRenderFunc(),p=this.fill(),m=this.textDecoration(),h=this.underlineOffset(),g=m.indexOf(`underline`)!==-1,_=m.indexOf(`line-through`)!==-1,v;s=s===Fr?e.direction:s;let y=a/2,b=Gr;if(!O.legacyTextRendering){let e=this.measureSize(`M`);b=`alphabetic`,y=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}for(s===Xr&&e.setAttr(`direction`,s),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,b),e.setAttr(`textAlign`,Br),o===Gr?c=(this.getHeight()-n*a-r*2)/2:o===Wr&&(c=this.getHeight()-n*a-r*2),e.translate(r,c+r),v=0;v<n;v++){let o=0,c=t[v],m=c.text,b=c.width,x=c.lastInParagraph;if(e.save(),l===Yr?o+=u-b-r*2:l===Pr&&(o+=(u-b-r*2)/2),g){e.save(),e.beginPath();let t=h??(O.legacyTextRendering?Math.round(i/2):Math.round(i/4)),n=o,a=y+0+t;e.moveTo(n,a);let s=l===Ir&&!x?u-r*2:b;e.lineTo(n+Math.round(s),a),e.lineWidth=i/15,e.strokeStyle=this._getLinearGradient()||p,e.stroke(),e.restore()}let S=o;if(s!==Xr&&(d!==0||l===Ir||f)){let n=m.split(` `).length-1,i=Mr(m);for(let a=0;a<i.length;a++){let s=i[a];if(s===` `&&!x&&l===Ir&&(o+=(u-r*2-b)/n),this._partialTextX=o,this._partialTextY=y+0,this._partialText=s,f){e.save();let n=t.slice(0,v).reduce((e,t)=>e+Mr(t.text).length,0);f({char:s,index:a+n,x:o,y:y+0,lineIndex:v,column:a,isLastInLine:x,width:this.measureSize(s).width,context:e})}e.fillStrokeShape(this),f&&e.restore(),o+=this.measureSize(s).width+d}}else d!==0&&e.setAttr(`letterSpacing`,`${d}px`),this._partialTextX=o,this._partialTextY=y+0,this._partialText=m,e.fillStrokeShape(this);if(_){e.save(),e.beginPath();let t=O.legacyTextRendering?0:-Math.round(i/4),n=S;e.moveTo(n,y+0+t);let a=l===Ir&&!x?u-r*2:b;e.lineTo(n+Math.round(a),y+0+t),e.lineWidth=i/15,e.strokeStyle=this._getLinearGradient()||p,e.stroke(),e.restore()}e.restore(),n>1&&(y+=a)}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=N._isString(e)?e:e==null?``:e+``;return this._setAttr(Vr,t),this}getWidth(){return this.attrs.width===Nr||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Nr||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return N.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=si(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+Jr+this.fontVariant()+Jr+(this.fontSize()+qr)+ai(this.fontFamily())}_addTextLine(e){this.align()===Ir&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){let t=this.letterSpacing(),n=e.length;return si().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
66
+ `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,a=this.attrs.height,o=i!==Nr&&i!==void 0,s=a!==Nr&&a!==void 0,c=this.padding(),l=i-c*2,u=a-c*2,d=0,f=this.wrap(),p=f!==Qr&&f!==$r,m=this.ellipsis();this.textArr=[],si().font=this._getContextFont();let h=m?this._getTextWidth(ei):0;for(let t=0,i=e.length;t<i;++t){let a=e[t],c=this._getTextWidth(a);if(o&&c>l)for(;a.length>0;){let e=Mr(a),t=0,i=e.length,o=``,f=0;for(;t<i;){let n=t+i>>>1,a=e.slice(0,n+1).join(``),c=this._getTextWidth(a);(m&&s&&d+r>u?c+h:c)<=l?(t=n+1,o=a,f=c):i=n}if(o){if(p){let n=Mr(o),r=e[n.length],i=r===Jr||r===zr,a;if(i&&f<=l)a=n.length;else{let e=n.lastIndexOf(Jr),t=n.lastIndexOf(zr);a=Math.max(e,t)+1}a>0&&(t=a,o=e.slice(0,t).join(``),f=this._getTextWidth(o))}if(o=o.trimRight(),this._addTextLine(o),n=Math.max(n,f),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(a=e.slice(t).join(``).trimLeft(),a.length>0&&(c=this._getTextWidth(a),c<=l)){this._addTextLine(a),d+=r,n=Math.max(n,c);break}}else break}else this._addTextLine(a),d+=r,n=Math.max(n,c),this._shouldHandleEllipsis(d)&&t<i-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Nr&&r!==void 0,a=r-this.padding()*2;return this.wrap()===$r||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Nr&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+ei)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+ei))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){let e=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&ii()?!0:super._useBufferCanvas()}};X.prototype._fillFunc=ci,X.prototype._strokeFunc=li,X.prototype.className=Hr,X.prototype._attrsAffectingSize=[`text`,`fontSize`,`padding`,`wrap`,`lineHeight`,`letterSpacing`],k(X),L.overWriteSetter(X,`width`,$e()),L.overWriteSetter(X,`height`,$e()),L.addGetterSetter(X,`direction`,Fr),L.addGetterSetter(X,`fontFamily`,`Arial`),L.addGetterSetter(X,`fontSize`,12,F()),L.addGetterSetter(X,`fontStyle`,Kr),L.addGetterSetter(X,`fontVariant`,Kr),L.addGetterSetter(X,`padding`,0,F()),L.addGetterSetter(X,`align`,Br),L.addGetterSetter(X,`verticalAlign`,Ur),L.addGetterSetter(X,`lineHeight`,1,F()),L.addGetterSetter(X,`wrap`,Zr),L.addGetterSetter(X,`ellipsis`,!1,I()),L.addGetterSetter(X,`letterSpacing`,0,F()),L.addGetterSetter(X,`text`,``,et()),L.addGetterSetter(X,`textDecoration`,``),L.addGetterSetter(X,`underlineOffset`,void 0,F()),L.addGetterSetter(X,`charRenderFunc`,void 0);var di=``,fi=`normal`;function pi(e){e.fillText(this.partialText,0,0)}function mi(e){e.strokeText(this.partialText,0,0)}var Z=class extends U{constructor(e){super(e),this.dummyCanvas=N.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),this.on(`textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva`,this._setTextData),this._setTextData()}_getTextPathLength(){return K.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:K.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=K.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),this.partialText=i[t].text,e.fillStrokeShape(this),a&&(t===0&&e.moveTo(0,r/2+1),e.lineTo(i[t].width,r/2+1)),e.restore()}if(a&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),o){e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),t===0&&e.moveTo(0,0),e.lineTo(i[t].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();let t=this.glyphInfo;if(t.length>=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){let r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr(`lineWidth`,this.fontSize()),e.setAttr(`strokeStyle`,this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return N.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return X.prototype.setText.call(this,e)}_getContextFont(){return X.prototype._getContextFont.call(this)}_getTextSize(e){let t=this.dummyCanvas.getContext(`2d`);t.save(),t.font=this._getContextFont();let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=Mr(this.text());this.direction()===`rtl`&&e.reverse();let t=[],n=0;for(let r=0;r<e.length;r++)t.push({char:e[r],width:this._getTextSize(e[r]).width}),n+=t[r].width;let{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;let a=this.letterSpacing(),o=this.align(),s=this.kerningFunc(),c=Math.max(0,n-r),l=Math.max(this.textWidth+((this.attrs.text||``).length-1)*a,0),u=0;o===`center`&&(u=Math.max(0,this.pathLength/2-l/2)),o===`right`&&(u=Math.max(0,this.pathLength-l));let d=u;for(let n=0;n<t.length;n++){let r=this._getPointAtLength(d);if(!r)return;let i=t[n].char,u=t[n].width+a;if(i===` `&&o===`justify`){let e=this.text().split(` `).length-1;u+=(this.pathLength-l)/e}let f=d+u,p=this._getPointAtLength(f>this.pathLength&&f-this.pathLength<=c?this.pathLength:f);if(!p)return;let m=K.getLineLength(r.x,r.y,p.x,p.y),h=0;if(s)try{h=s(t[n-1].char,i)*this.fontSize()}catch{h=0}r.x+=h,p.x+=h,this.textWidth+=h;let g=K.getPointOnLine(h+m/2,r.x,r.y,p.x,p.y),_=Math.atan2(p.y-r.y,p.x-r.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:e[n],rotation:_,p0:r,p1:p,width:m}),d+=u}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,a,o;for(let s=0;s<e.length/2;s++)a=e[s*2],o=e[s*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,o),i=Math.max(i,o);let s=this.fontSize();return{x:t-s/2,y:r-s/2,width:n-t+s,height:i-r+s}}destroy(){return N.releaseCanvas(this.dummyCanvas),super.destroy()}};Z.prototype._fillFunc=pi,Z.prototype._strokeFunc=mi,Z.prototype._fillFuncHit=pi,Z.prototype._strokeFuncHit=mi,Z.prototype.className=`TextPath`,Z.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`],k(Z),L.addGetterSetter(Z,`data`),L.addGetterSetter(Z,`fontFamily`,`Arial`),L.addGetterSetter(Z,`fontSize`,12,F()),L.addGetterSetter(Z,`fontStyle`,fi),L.addGetterSetter(Z,`align`,`left`),L.addGetterSetter(Z,`letterSpacing`,0,F()),L.addGetterSetter(Z,`textBaseline`,`middle`),L.addGetterSetter(Z,`fontVariant`,fi),L.addGetterSetter(Z,`text`,di),L.addGetterSetter(Z,`textDecoration`,``),L.addGetterSetter(Z,`kerningFunc`,void 0),L.addGetterSetter(Z,`direction`,`inherit`);var hi=`tr-konva`,gi=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`].map(e=>e+`.${hi}`).join(` `),_i=`nodesRect`,vi=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`draggableChange`],yi={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},bi=`ontouchstart`in O._global;function xi(e,t,n){if(e===`rotater`)return n;t+=N.degToRad(yi[e]||0);let r=(N.radToDeg(t)%360+360)%360;return N._inRange(r,337.5,360)||N._inRange(r,0,22.5)?`ns-resize`:N._inRange(r,22.5,67.5)?`nesw-resize`:N._inRange(r,67.5,112.5)?`ew-resize`:N._inRange(r,112.5,157.5)?`nwse-resize`:N._inRange(r,157.5,202.5)?`ns-resize`:N._inRange(r,202.5,247.5)?`nesw-resize`:N._inRange(r,247.5,292.5)?`ew-resize`:N._inRange(r,292.5,337.5)?`nwse-resize`:(N.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var Si=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function Ci(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function wi(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function Ti(e,t){return wi(e,t,Ci(e))}function Ei(e,t,n){let r=t;for(let i=0;i<e.length;i++){let a=O.getAngle(e[i]),o=Math.abs(a-t)%(Math.PI*2);Math.min(o,Math.PI*2-o)<n&&(r=a)}return r}var Di=0,Q=class extends Bn{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._updateScheduled=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(gi,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return N.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return hi+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=e.filter(e=>!e.isAncestorOf(this)||(N.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),!1));return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{this._transforming||(this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this.isDragging()||this._scheduleUpdate())};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(vi.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)}),this._resetTransformCache(),this.findOne(`.top-left`)&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(`.back`)&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(_i),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_getNodeRect(){return this._getCache(_i,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){let r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),a=e.getAbsolutePosition(n),o=r.x*i.x-e.offsetX()*i.x,s=r.y*i.y-e.offsetY()*i.y,c=(O.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return wi({x:a.x+o*Math.cos(c)+s*Math.sin(-c),y:a.y+s*Math.cos(c)+o*Math.sin(c),width:r.width*i.x,height:r.height*i.y,rotation:c},-O.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=[];this.nodes().map(t=>{let n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=t.getAbsoluteTransform();r.forEach(function(t){let n=i.point(t);e.push(n)})});let t=new M;t.rotate(-O.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(function(e){let o=t.point(e);n===void 0&&(n=i=o.x,r=a=o.y),n=Math.min(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),a=Math.max(a,o.y)}),t.invert();let o=t.point({x:n,y:r});return{x:o.x,y:o.y,width:i-n,height:a-r,rotation:O.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Si.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new Or({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:bi?10:`auto`}),n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{let n=xi(e,O.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{t.getStage().content&&(t.getStage().content.style.cursor=``),this._cursorChange=!1}),this.add(t)}_createBack(){let e=new U({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent(),r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=n.rotateAnchorAngle(),r=n.rotateAnchorOffset(),o=N.degToRad(t),s=Math.sin(o),c=-Math.cos(o),l=i/2,u=a/2,d=1/0;c<0?d=Math.min(d,-u/c):c>0&&(d=Math.min(d,(a-u)/c)),s<0?d=Math.min(d,-l/s):s>0&&(d=Math.min(d,(i-l)/s));let f=l+s*d,p=u+c*d,m=N._sign(a),h=f+s*r*m,g=p+c*r*m;e.moveTo(f,p),e.lineTo(h,g)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<`u`&&(window.addEventListener(`mousemove`,this._handleMouseMove),window.addEventListener(`touchmove`,this._handleMouseMove),window.addEventListener(`mouseup`,this._handleMouseUp,!0),window.addEventListener(`touchend`,this._handleMouseUp,!0)),this._transforming=!0;let a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},Di++,this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){let t,n,r,i=this.findOne(`.`+this._movingAnchorName),a=i.getStage();a.setPointersPositions(e);let o=a.getPointerPosition(),s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=O.getAngle(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a;r.height<0&&(o-=Math.PI);let s=O.getAngle(this.rotation())+o,c=O.getAngle(this.rotationSnapTolerance()),l=Ti(r,Ei(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName===`top-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-right`).x(),y:this.findOne(`.bottom-right`).y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this.findOne(`.top-left`).x()>e.x?-1:1,o=this.findOne(`.top-left`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-left`).x(e.x-t),this.findOne(`.top-left`).y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this.findOne(`.top-left`).y(i.y());else if(this._movingAnchorName===`top-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-left`).x(),y:this.findOne(`.bottom-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this.findOne(`.top-right`).x()<e.x?-1:1,o=this.findOne(`.top-right`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-right`).x(e.x+t),this.findOne(`.top-right`).y(e.y-n)}var p=i.position();this.findOne(`.top-left`).y(p.y),this.findOne(`.bottom-right`).x(p.x)}else if(this._movingAnchorName===`middle-left`)this.findOne(`.top-left`).x(i.x());else if(this._movingAnchorName===`middle-right`)this.findOne(`.bottom-right`).x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-right`).x(),y:this.findOne(`.top-right`).y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x<i.x()?-1:1,o=i.y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,i.x(e.x-t),i.y(e.y+n)}p=i.position(),this.findOne(`.top-left`).x(p.x),this.findOne(`.bottom-right`).y(p.y)}else if(this._movingAnchorName===`bottom-center`)this.findOne(`.bottom-right`).y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-left`).x(),y:this.findOne(`.top-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this.findOne(`.bottom-right`).x()<e.x?-1:1,o=this.findOne(`.bottom-right`).y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.bottom-right`).x(e.x+t),this.findOne(`.bottom-right`).y(e.y+n)}}else console.error(Error(`Wrong position argument of selection resizer: `+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){let e=this.findOne(`.top-left`),t=this.findOne(`.bottom-right`),n=e.x(),r=e.y(),i=this.getWidth()-t.x(),a=this.getHeight()-t.y();t.move({x:-n,y:-r}),e.move({x:i,y:a})}let m=this.findOne(`.top-left`).getAbsolutePosition();t=m.x,n=m.y;let h=this.findOne(`.bottom-right`).x()-this.findOne(`.top-left`).x(),g=this.findOne(`.bottom-right`).y()-this.findOne(`.top-left`).y();this._fitNodesInto({x:t,y:n,width:h,height:g,rotation:O.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<`u`&&(window.removeEventListener(`mousemove`,this._handleMouseMove),window.removeEventListener(`touchmove`,this._handleMouseMove),window.removeEventListener(`mouseup`,this._handleMouseUp,!0),window.removeEventListener(`touchend`,this._handleMouseUp,!0));let n=this.getNode();Di--,this._fire(`transformend`,{evt:e,target:n}),(t=this.getLayer())==null||t.batchDraw(),n&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){let n=O.autoDrawEnabled;O.autoDrawEnabled=!1;try{return this._doFitNodesInto(e,t)}finally{O.autoDrawEnabled=n}}_doFitNodesInto(e,t){let n=this._getNodeRect();if(N._inRange(e.width,-this.padding()*2-1,1)){this.update();return}if(N._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let r=new M;if(r.rotate(O.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=r.point({x:-this.padding()*2,y:0});e.x+=t.x,e.y+=t.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace(`left`,`right`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=r.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace(`right`,`left`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=r.point({x:0,y:-this.padding()*2});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace(`top`,`bottom`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=r.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace(`bottom`,`top`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(n,e);t?e=t:N.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}let i=1e7,a=new M;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/i,n.height/i);let o=new M,s=e.width/i,c=e.height/i;this.flipEnabled()===!1?(o.translate(e.x,e.y),o.rotate(e.rotation),o.translate(e.width<0?e.width:0,e.height<0?e.height:0),o.scale(Math.abs(s),Math.abs(c))):(o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(s,c));let l=o.multiply(a.invert()),u=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new M;r.multiply(t.copy().invert()).multiply(l).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&u.add(a)}),this.rotation(N._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),u.add(this.getLayer()),u.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,B._runAfterAbsTransformCascade(()=>{this._updateScheduled=!1,!(!this._nodes?.length||this._transforming||this.isDragging())&&this.update()}))}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;let t=this._getNodeRect();this.rotation(N._getRotation(t.rotation));let n=t.width,r=t.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize(),c=this.find(`._anchor`);c.forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(`.top-left`,{x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._batchChangeChild(`.top-center`,{x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._batchChangeChild(`.top-right`,{x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._batchChangeChild(`.middle-left`,{x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._batchChangeChild(`.middle-right`,{x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._batchChangeChild(`.bottom-left`,{x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._batchChangeChild(`.bottom-center`,{x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._batchChangeChild(`.bottom-right`,{x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let l=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=N.degToRad(l),f=Math.sin(d),p=-Math.cos(d),m=n/2,h=r/2,g=1/0;p<0?g=Math.min(g,-h/p):p>0&&(g=Math.min(g,(r-h)/p)),f<0?g=Math.min(g,-m/f):f>0&&(g=Math.min(g,(n-m)/f));let _=m+f*g,v=h+p*g,y=N._sign(r);this._batchChangeChild(`.rotater`,{x:_+f*u*y,y:v+p*u*y-o*p,visible:this.rotateEnabled()}),this._batchChangeChild(`.back`,{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(e=>e.draggable()),x:0,y:0});let b=this.anchorStyleFunc();b&&c.forEach(e=>{b(e)}),(e=this.getLayer())==null||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();let e=this.findOne(`.`+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),Bn.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(N.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return B.prototype.toObject.call(this)}clone(e){return B.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Q.isTransforming=()=>Di>0;function Oi(e){return e instanceof Array||N.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){Si.indexOf(e)===-1&&N.warn(`Unknown anchor name: `+e+`. Available names are: `+Si.join(`, `))}),e||[]}Q.prototype.className=`Transformer`,k(Q),L.addGetterSetter(Q,`enabledAnchors`,Si,Oi),L.addGetterSetter(Q,`flipEnabled`,!0,I()),L.addGetterSetter(Q,`resizeEnabled`,!0),L.addGetterSetter(Q,`anchorSize`,10,F()),L.addGetterSetter(Q,`rotateEnabled`,!0),L.addGetterSetter(Q,`rotateLineVisible`,!0),L.addGetterSetter(Q,`rotationSnaps`,[]),L.addGetterSetter(Q,`rotateAnchorOffset`,50,F()),L.addGetterSetter(Q,`rotateAnchorAngle`,0,F()),L.addGetterSetter(Q,`rotateAnchorCursor`,`crosshair`),L.addGetterSetter(Q,`rotationSnapTolerance`,5,F()),L.addGetterSetter(Q,`borderEnabled`,!0),L.addGetterSetter(Q,`anchorStroke`,`rgb(0, 161, 255)`),L.addGetterSetter(Q,`anchorStrokeWidth`,1,F()),L.addGetterSetter(Q,`anchorFill`,`white`),L.addGetterSetter(Q,`anchorCornerRadius`,0,F()),L.addGetterSetter(Q,`borderStroke`,`rgb(0, 161, 255)`),L.addGetterSetter(Q,`borderStrokeWidth`,1,F()),L.addGetterSetter(Q,`borderDash`),L.addGetterSetter(Q,`keepRatio`,!0),L.addGetterSetter(Q,`shiftBehavior`,`default`),L.addGetterSetter(Q,`centeredScaling`,!1),L.addGetterSetter(Q,`ignoreStroke`,!1),L.addGetterSetter(Q,`padding`,0,F()),L.addGetterSetter(Q,`nodes`),L.addGetterSetter(Q,`node`),L.addGetterSetter(Q,`boundBoxFunc`),L.addGetterSetter(Q,`anchorDragBoundFunc`),L.addGetterSetter(Q,`anchorStyleFunc`),L.addGetterSetter(Q,`shouldOverdrawWholeArea`,!1),L.addGetterSetter(Q,`useSingleNodeRotation`,!0),L.backCompat(Q,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var $=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,O.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};$.prototype.className=`Wedge`,$.prototype._centroid=!0,$.prototype._attrsAffectingSize=[`radius`],k($),L.addGetterSetter($,`radius`,0,F()),L.addGetterSetter($,`angle`,0,F()),L.addGetterSetter($,`clockwise`,!1),L.backCompat($,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function ki(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Ai=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],ji=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Mi(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,ee=t+t+1,te=r-1,ne=i-1,T=t+1,E=T*(T+1)/2,re=new ki,D=Ai[t],O=ji[t],k=null,A=re,j=null,M=null;for(let e=1;e<ee;e++)A=A.next=new ki,e===T&&(k=A);A.next=re,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,f=T*(b=n[o]),p=T*(x=n[o+1]),m=T*(S=n[o+2]),h=T*(C=n[o+3]),c+=E*b,l+=E*x,u+=E*S,d+=E*C,A=re;for(let e=0;e<T;e++)A.r=b,A.g=x,A.b=S,A.a=C,A=A.next;for(let e=1;e<T;e++)a=o+((te<e?te:e)<<2),c+=(A.r=b=n[a])*(w=T-e),l+=(A.g=x=n[a+1])*w,u+=(A.b=S=n[a+2])*w,d+=(A.a=C=n[a+3])*w,g+=b,_+=x,v+=S,y+=C,A=A.next;j=re,M=k;for(let e=0;e<r;e++)n[o+3]=C=d*D>>O,C===0?n[o]=n[o+1]=n[o+2]=0:(C=255/C,n[o]=(c*D>>O)*C,n[o+1]=(l*D>>O)*C,n[o+2]=(u*D>>O)*C),c-=f,l-=p,u-=m,d-=h,f-=j.r,p-=j.g,m-=j.b,h-=j.a,a=s+((a=e+t+1)<te?a:te)<<2,g+=j.r=n[a],_+=j.g=n[a+1],v+=j.b=n[a+2],y+=j.a=n[a+3],c+=g,l+=_,u+=v,d+=y,j=j.next,f+=b=M.r,p+=x=M.g,m+=S=M.b,h+=C=M.a,g-=b,_-=x,v-=S,y-=C,M=M.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=T*(b=n[o]),p=T*(x=n[o+1]),m=T*(S=n[o+2]),h=T*(C=n[o+3]),c+=E*b,l+=E*x,u+=E*S,d+=E*C,A=re;for(let e=0;e<T;e++)A.r=b,A.g=x,A.b=S,A.a=C,A=A.next;let s=r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(A.r=b=n[o])*(w=T-i),l+=(A.g=x=n[o+1])*w,u+=(A.b=S=n[o+2])*w,d+=(A.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,A=A.next,i<ne&&(s+=r);o=e,j=re,M=k;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=d*D>>O,C>0?(C=255/C,n[a]=(c*D>>O)*C,n[a+1]=(l*D>>O)*C,n[a+2]=(u*D>>O)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=j.r,p-=j.g,m-=j.b,h-=j.a,a=e+((a=t+T)<ne?a:ne)*r<<2,c+=g+=j.r=n[a],l+=_+=j.g=n[a+1],u+=v+=j.b=n[a+2],d+=y+=j.a=n[a+3],j=j.next,f+=b=M.r,p+=x=M.g,m+=S=M.b,h+=C=M.a,g-=b,_-=x,v-=S,y-=C,M=M.next,o+=r}}var Ni=function(e){let t=Math.round(this.blurRadius());t>0&&Mi(e,t)};L.addGetterSetter(B,`blurRadius`,0,F(),L.afterSetFilter);var Pi=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]+=t,n[e+1]+=t,n[e+2]+=t};L.addGetterSetter(B,`brightness`,0,F(),L.afterSetFilter);var Fi=function(e){let t=this.brightness(),n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]=Math.min(255,n[e]*t),n[e+1]=Math.min(255,n[e+1]*t),n[e+2]=Math.min(255,n[e+2]*t)},Ii=function(e){let t=((this.contrast()+100)/100)**2,n=e.data,r=n.length,i=150,a=150,o=150;for(let e=0;e<r;e+=4)i=n[e],a=n[e+1],o=n[e+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,a/=255,a-=.5,a*=t,a+=.5,a*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,i=i<0?0:i>255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};L.addGetterSetter(B,`contrast`,0,F(),L.afterSetFilter);var Li=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Uint8ClampedArray(t),h=new Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)h[e]=.2126*m[n]+.7152*m[n+1]+.0722*m[n+2];let g=[-1,0,1,-2,0,2,-1,0,1],_=[-1,-2,-1,0,0,0,1,2,1],v=[-n-1,-n,-n+1,-1,0,1,n-1,n,n+1],y=e=>e<0?0:e>255?255:e;for(let e=1;e<r-1;e++)for(let r=1;r<n-1;r++){let i=e*n+r,a=0,o=0;a+=h[i+v[0]]*g[0],o+=h[i+v[0]]*_[0],a+=h[i+v[1]]*g[1],o+=h[i+v[1]]*_[1],a+=h[i+v[2]]*g[2],o+=h[i+v[2]]*_[2],a+=h[i+v[3]]*g[3],o+=h[i+v[3]]*_[3],a+=h[i+v[5]]*g[5],o+=h[i+v[5]]*_[5],a+=h[i+v[6]]*g[6],o+=h[i+v[6]]*_[6],a+=h[i+v[7]]*g[7],o+=h[i+v[7]]*_[7],a+=h[i+v[8]]*g[8],o+=h[i+v[8]]*_[8];let c=y(l+(d*a+f*o)*p),u=i*4;if(s){let e=c-l;t[u]=y(m[u]+e),t[u+1]=y(m[u+1]+e),t[u+2]=y(m[u+2]+e),t[u+3]=m[u+3]}else t[u]=t[u+1]=t[u+2]=c,t[u+3]=m[u+3]}for(let e=0;e<n;e++){let i=e*4,a=((r-1)*n+e)*4;t[i]=m[i],t[i+1]=m[i+1],t[i+2]=m[i+2],t[i+3]=m[i+3],t[a]=m[a],t[a+1]=m[a+1],t[a+2]=m[a+2],t[a+3]=m[a+3]}for(let e=1;e<r-1;e++){let r=e*n*4,i=(e*n+(n-1))*4;t[r]=m[r],t[r+1]=m[r+1],t[r+2]=m[r+2],t[r+3]=m[r+3],t[i]=m[i],t[i+1]=m[i+1],t[i+2]=m[i+2],t[i+3]=m[i+3]}return e};L.addGetterSetter(B,`embossStrength`,.5,F(),L.afterSetFilter),L.addGetterSetter(B,`embossWhiteLevel`,.5,F(),L.afterSetFilter),L.addGetterSetter(B,`embossDirection`,`top-left`,void 0,L.afterSetFilter),L.addGetterSetter(B,`embossBlend`,!1,void 0,L.afterSetFilter);function Ri(e,t,n,r,i){let a=n-t,o=i-r;if(a===0)return r+o/2;if(o===0)return r;let s=(e-t)/a;return s=o*s+r,s}var zi=function(e){let t=e.data,n=t.length,r=t[0],i=r,a,o=t[1],s=o,c,l=t[2],u=l,d,f=this.enhance();if(f===0)return;for(let e=0;e<n;e+=4)a=t[e+0],a<r?r=a:a>i&&(i=a),c=t[e+1],c<o?o=c:c>s&&(s=c),d=t[e+2],d<l?l=d:d>u&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;e<n;e+=4)t[e+0]=Ri(t[e+0],r,i,m,p),t[e+1]=Ri(t[e+1],o,s,g,h),t[e+2]=Ri(t[e+2],l,u,v,_)};L.addGetterSetter(B,`enhance`,0,F(),L.afterSetFilter);var Bi=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=.34*t[e]+.5*t[e+1]+.16*t[e+2];t[e]=n,t[e+1]=n,t[e+2]=n}};L.addGetterSetter(B,`hue`,0,F(),L.afterSetFilter),L.addGetterSetter(B,`saturation`,0,F(),L.afterSetFilter),L.addGetterSetter(B,`luminance`,0,F(),L.afterSetFilter);var Vi=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=Math.abs(this.hue()+360)%360,a=this.luminance()*127,o=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),c=.299+.701*o+.167*s,l=.587-.587*o+.33*s,u=.114-.114*o-.497*s,d=.299-.299*o-.328*s,f=.587+.413*o+.035*s,p=.114-.114*o+.293*s,m=.299-.3*o+1.25*s,h=.587-.586*o-1.05*s,g=.114+.886*o-.2*s,_,v,y,b;for(let e=0;e<n;e+=4)_=t[e+0],v=t[e+1],y=t[e+2],b=t[e+3],t[e+0]=c*_+l*v+u*y+a,t[e+1]=d*_+f*v+p*y+a,t[e+2]=m*_+h*v+g*y+a,t[e+3]=b},Hi=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=Math.abs(this.hue()+360)%360,o=r*i*Math.cos(a*Math.PI/180),s=r*i*Math.sin(a*Math.PI/180),c=.299*r+.701*o+.167*s,l=.587*r-.587*o+.33*s,u=.114*r-.114*o-.497*s,d=.299*r-.299*o-.328*s,f=.587*r+.413*o+.035*s,p=.114*r-.114*o+.293*s,m=.299*r-.3*o+1.25*s,h=.587*r-.586*o-1.05*s,g=.114*r+.886*o-.2*s;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2],a=t[e+3];t[e+0]=c*n+l*r+u*i,t[e+1]=d*n+f*r+p*i,t[e+2]=m*n+h*r+g*i,t[e+3]=a}};L.addGetterSetter(B,`hue`,0,F(),L.afterSetFilter),L.addGetterSetter(B,`saturation`,0,F(),L.afterSetFilter),L.addGetterSetter(B,`value`,0,F(),L.afterSetFilter);var Ui=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},Wi=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;e<m;e+=1){let t=Math.sin(e*h),n=Math.cos(e*h);for(let o=0;o<p;o+=1){u=Math.floor(s+l*o/p*n),d=Math.floor(c+l*o/p*t);let f=(d*a+u)*4,m=r[f+0],h=r[f+1],g=r[f+2],_=r[f+3];f=(e+o*a)*4,i[f+0]=m,i[f+1]=h,i[f+2]=g,i[f+3]=_}}},Gi=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;u<a;u+=1)for(d=0;d<o;d+=1){let e=u-s,t=d-c,n=Math.sqrt(e*e+t*t)*p/l,o=(Math.atan2(t,e)*180/Math.PI+360+h)%360;o=o*m/360,g=Math.floor(o),_=Math.floor(n);let f=(_*a+g)*4,v=r[f+0],y=r[f+1],b=r[f+2],x=r[f+3];f=(d*a+u)*4,i[f+0]=v,i[f+1]=y,i[f+2]=b,i[f+3]=x}},Ki=function(e){let t=e.width,n=e.height,r,i,a,o,s,c,l,u,d,f,p=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),h=Math.floor(m%360*t/360);if(p<1)return;let g=N.createCanvasElement();g.width=t,g.height=n;let _=g.getContext(`2d`).getImageData(0,0,t,n);N.releaseCanvas(g),Wi(e,_,{polarCenterX:t/2,polarCenterY:n/2});let v=t/2**p;for(;v<=8;)v*=2,--p;v=Math.ceil(v);let y=v,b=0,x=y,S=1;for(h+v>t&&(b=y,x=0,S=-1),i=0;i<n;i+=1)for(r=b;r!==x;r+=S)a=Math.round(r+h)%t,d=(t*i+a)*4,s=_.data[d+0],c=_.data[d+1],l=_.data[d+2],u=_.data[d+3],f=(t*i+r)*4,_.data[f+0]=s,_.data[f+1]=c,_.data[f+2]=l,_.data[f+3]=u;for(i=0;i<n;i+=1)for(y=Math.floor(v),o=0;o<p;o+=1){for(r=0;r<y+1;r+=1)d=(t*i+r)*4,s=_.data[d+0],c=_.data[d+1],l=_.data[d+2],u=_.data[d+3],f=(t*i+y*2-r-1)*4,_.data[f+0]=s,_.data[f+1]=c,_.data[f+2]=l,_.data[f+3]=u;y*=2}Gi(_,e,{polarRotation:0})};L.addGetterSetter(B,`kaleidoscopePower`,2,F(),L.afterSetFilter),L.addGetterSetter(B,`kaleidoscopeAngle`,0,F(),L.afterSetFilter);function qi(e,t,n){let r=(n*e.width+t)*4,i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function Ji(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function Yi(e){let t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function Xi(e,t){let n=qi(e,0,0),r=qi(e,e.width-1,0),i=qi(e,0,e.height-1),a=qi(e,e.width-1,e.height-1),o=t||10;if(Ji(n,r)<o&&Ji(r,a)<o&&Ji(a,i)<o&&Ji(i,n)<o){let t=Yi([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++){let r=Ji(t,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]]);s[n]=r<o?0:255}return s}}function Zi(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Qi(e,t,n){let r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u===2040?255:0}return o}function $i(e,t,n){let r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u>=1020?255:0}return o}function ea(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u}return o}var ta=function(e){let t=Xi(e,this.threshold());return t&&(t=Qi(t,e.width,e.height),t=$i(t,e.width,e.height),t=ea(t,e.width,e.height),Zi(e,t)),e};L.addGetterSetter(B,`threshold`,0,F(),L.afterSetFilter);var na=function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e<r;e+=4)n[e+0]+=i-2*i*Math.random(),n[e+1]+=i-2*i*Math.random(),n[e+2]+=i-2*i*Math.random()};L.addGetterSetter(B,`noise`,.2,F(),L.afterSetFilter);var ra=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),a=Math.ceil(r/t),o=e.data;if(t<=0){N.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<i;e+=1)for(let i=0;i<a;i+=1){let a=0,s=0,c=0,l=0,u=e*t,d=u+t,f=i*t,p=f+t,m=0;for(let e=u;e<d;e+=1)if(!(e>=n))for(let t=f;t<p;t+=1){if(t>=r)continue;let i=(n*t+e)*4;a+=o[i+0],s+=o[i+1],c+=o[i+2],l+=o[i+3],m+=1}a/=m,s/=m,c/=m,l/=m;for(let e=u;e<d;e+=1)if(!(e>=n))for(let t=f;t<p;t+=1){if(t>=r)continue;let i=(n*t+e)*4;o[i+0]=a,o[i+1]=s,o[i+2]=c,o[i+3]=l}}};L.addGetterSetter(B,`pixelSize`,8,F(),L.afterSetFilter);var ia=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e<r;e+=1)n[e]=Math.floor(n[e]/i)*i};L.addGetterSetter(B,`levels`,.5,F(),L.afterSetFilter);var aa=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue();for(let e=0;e<n;e+=4){let n=(.34*t[e]+.5*t[e+1]+.16*t[e+2])/255;t[e]=n*r,t[e+1]=n*i,t[e+2]=n*a,t[e+3]=t[e+3]}};L.addGetterSetter(B,`red`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),L.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),L.addGetterSetter(B,`blue`,0,Ze,L.afterSetFilter);var oa=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e<n;e+=4){let n=1-o;t[e]=r*o+t[e]*n,t[e+1]=i*o+t[e+1]*n,t[e+2]=a*o+t[e+2]*n}};L.addGetterSetter(B,`red`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),L.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),L.addGetterSetter(B,`blue`,0,Ze,L.afterSetFilter),L.addGetterSetter(B,`alpha`,1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var sa=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2];t[e+0]=Math.min(255,n*.393+r*.769+i*.189),t[e+1]=Math.min(255,n*.349+r*.686+i*.168),t[e+2]=Math.min(255,n*.272+r*.534+i*.131)}},ca=function(e){let t=e.data;for(let e=0;e<t.length;e+=4){let n=t[e],r=t[e+1],i=t[e+2];.2126*n+.7152*r+.0722*i>=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},la=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=1)n[e]=n[e]<t?0:255};L.addGetterSetter(B,`threshold`,.5,F(),L.afterSetFilter);var ua=$n.Util._assign($n,{Arc:W,Arrow:hr,Circle:gr,Ellipse:_r,Image:q,Label:Er,Tag:Dr,Line:G,Path:K,Rect:Or,RegularPolygon:kr,Ring:jr,Sprite:J,Star:Y,Text:X,TextPath:Z,Transformer:Q,Wedge:$,Filters:{Blur:Ni,Brightness:Fi,Brighten:Pi,Contrast:Ii,Emboss:Li,Enhance:zi,Grayscale:Bi,HSL:Vi,HSV:Hi,Invert:Ui,Kaleidoscope:Ki,Mask:ta,Noise:na,Pixelate:ra,Posterize:ia,RGB:aa,RGBA:oa,Sepia:sa,Solarize:ca,Threshold:la}}),da=class e extends HTMLElement{static template=S`
67
+ <template>
68
+ <slot></slot>
69
+ <div id="overlay"></div>
70
+ </template>
71
+ `;static styles=s`
72
+ :host {
73
+ --slide-pointer-events: none;
74
+ --slide-opacity: 1;
75
+ --slide-overlay-visibility: hidden;
76
+ /*position: relative;*/
77
+ }
78
+ @media screen {
79
+ :host {
80
+ --slide-opacity: 1; // make it 0.2 for fading effect on scroll;
81
+ --slide-overlay-visibility: visible;
82
+ }
83
+ :host([active]) {
84
+ --slide-opacity: 1;
85
+ }
86
+ :host([overlay]) {
87
+ cursor: pointer;
88
+ }
89
+ :host([overlay="hidden"]) {
90
+ --slide-overlay-visibility: hidden;
91
+ }
92
+ :host([overlay="brush"]) {
93
+ cursor: url("/includes/pencil.png") 0 100, crosshair;
94
+ --slide-pointer-events: auto;
95
+ }
96
+ :host([overlay="eraser"]) {
97
+ cursor: not-allowed;
98
+ --slide-pointer-events: auto;
99
+ }
100
+ #overlay {
101
+ position: absolute;
102
+ inset: 0;
103
+ pointer-events: var(--slide-pointer-events);
104
+ visibility: var(--slide-overlay-visibility);
105
+ }
106
+ ::slotted(*) {
107
+ opacity: var(--slide-opacity);
108
+ transition: opacity 1s;
109
+ }
110
+ }
111
+ `;isPaint=!1;overlayMode=`pointer`;overlayColor=`red`;stage=null;constructor(){super(),ne(this).template(e.template).styles(e.styles)}static observedAttributes=[`active`,`overlay`];attributeChangedCallback(e,t,n){switch(e){case`overlay`:this.overlayMode=n,this.createOverlay();break;case`color`:this.overlayColor=n}}disconnectedCallback(){this.stage&&delete this.stage}createOverlay(){if(this.stage)return;let e=this.shadowRoot.getElementById(`overlay`);console.log(`Creating overlay if needed`,this.stage),this.stage=new ua.Stage({container:e,width:e?.clientWidth,height:e?.clientHeight}),this.layer=new ua.Layer,this.stage.add(this.layer),this.stage.on(`mousedown touchstart`,e=>{this.isPaint=!0;let t=this.stage.getPointerPosition();console.log(`touchstart`,t),this.lastLine=new ua.Line({stroke:this.overlayColor,strokeWidth:this.overlayMode===`eraser`?10:4,globalCompositeOperation:this.overlayMode===`brush`?`source-over`:`destination-out`,lineCap:`round`,lineJoin:`round`,points:[t.x,t.y,t.x,t.y]}),this.layer.add(this.lastLine)}),this.stage.on(`mouseup touchend`,()=>{this.isPaint=!1,console.log(`touchend`)}),this.stage.on(`mousemove touchmove`,e=>{if(!this.isPaint)return;e.evt.preventDefault();let t=this.stage.getPointerPosition(),n=this.lastLine.points().concat([t.x,t.y]);this.lastLine.points(n)})}},fa=.4,pa=.8,ma=class extends HTMLElement{VIEW_ELEMENT=`slide-view`;FOOTER_ELEMENT=`slide-footer`;controls=null;active=null;observer=new IntersectionObserver(e=>{let t=0,n=null;e.forEach(e=>{if(e.isIntersecting){let r=e.target;e.intersectionRatio<fa?r.removeAttribute(`active`):e.intersectionRatio>t&&(t=e.intersectionRatio,n=r)}}),n&&n!==this.active&&this.setActiveSlide(n)},{threshold:[0,fa,pa,1],delay:300});constructor(){super(),this.addEventListener(`slide:input`,e=>{let{slide:t}=e.detail,n=this.slide(t);this.setActiveSlide(n),this.jumpToSlide(n)}),this.addEventListener(`slide:overlay`,e=>{this.manageOverlay(e.detail)})}slide(e){return Array.from(this.querySelectorAll(this.VIEW_ELEMENT))[e-1]}connectedCallback(){let e=Array.from(this.querySelectorAll(this.VIEW_ELEMENT));this.controls=this.querySelector(this.FOOTER_ELEMENT),e.forEach(e=>this.observer.observe(e))}gotoSlide(e){console.log(`Going to slide`,e),e&&e.scrollIntoView({behavior:`smooth`,block:`center`,inline:`nearest`})}jumpToSlide(e){e&&e.scrollIntoView({block:`center`,inline:`nearest`})}setActiveSlide(e){if(this.active=e,this.active){this.active.setAttribute(`active`,`active`);let t=Array.from(this.querySelectorAll(this.VIEW_ELEMENT)).findIndex(t=>t===e);this.controls&&(this.controls.setAttribute(`slide`,t+1),this.controls.setAttribute(`overlay`,e.getAttribute(`overlay`)||`pointer`))}}manageOverlay(e){let{overlay:t}=e||{};console.log(`Overlay options`,e),this.active&&t&&this.active.setAttribute(`overlay`,t)}};function ha(){window.addEventListener(`resize`,ga),ga()}function ga(){let e=document.body,t=document.documentElement.clientWidth,n=document.documentElement.clientHeight;e.classList.add(`presentation-scaled`),e.style.setProperty(`--viewport-width`,t.toString()),e.style.setProperty(`--viewport-height`,n.toString()),console.log(`Rescaled`,t,n)}c({"slide-presi":ma,"slide-view":da,"slide-footer":T}),ha();